CLI: qvr¶
The qvr console script ships with the package as a thin wrapper
around the parser, constraint solver, and compiler. Subcommands:
qvr check FILES...¶
Parse, run the constraint solver, and compile every supplied
.qvr file. It emits structured diagnostics and exits 0 on full
success, 1 on any error.
Flags:
--json: emit a single JSON document on stdout containing the full diagnostic list, as expected by CI and pre-commit hooks.--target TARGET: compare every checked QIEC computation with the selected transpiler's advertised capabilities. Unsupported features are errors, so this mode is useful as an early target-specific release gate. It does not render the target program; runqvr transpile --to TARGET FILEbefore release to validate the complete lowering and rendering path.
Diagnostic codes:
parse: tree-sitter rejected the source.compile: the compiler raisedCompileError.residuated_constraint: aTypeSlashpattern appears outside a residuated context.effect_constraint: aTypeEffectApplyreferences an effect whose name doesn't match the conventional pattern.bundle_unknown_member: abundledeclaration references a member that isn't a declared rule, schema, bundle, or built-in schema.family-arg-shape: a distribution call has the wrong number of arguments or incompatible argument shapes.implicit-family-defaults: a distribution call relies on deprecated implicit defaults. This diagnostic is a warning.qiec-route: the exactqvr-source/v0.20toqiec-core/v1alpha1Didactic route is unavailable or mismatched.qiec-kind: a static argument or binder has the wrong kind.qiec-index: an index expression has the wrong sort or constructor shape.qiec-row: an effect row violates instance identity, unification, or alacksconstraint.qiec-coverage: indexed case branches are incomplete, duplicated, or not justified by refinement.qiec-skolem-escape: branch-local static evidence escapes its scope.qiec-handler: a handler signature violates coverage, forwarding, or resumption requirements.qiec-unhandled-effect: a computation performs an instance absent from its declared row.qiec-backend: a requested backend boundary cannot preserve a QIEC form.qiec:capability:FEATURE:COMPUTATION:--targetselected a backend that cannot preserveFEATUREin the named computation.io: a file-system error, such as a missing or unreadable file.
qvr migrate PATHS...¶
Lower .qvr source forward along the QVR grammar release chain.
The composer chains the adjacent-pair migrators defined in
quivers.cli.migrations so users do not
have to know the intermediate versions; pinning the boundary with
--from / --to selects a sub-chain when needed.
Flags:
--from VERSION: required source revision in the chain. QVR files do not encode an unambiguous grammar version.--to VERSION: target revision (defaults toHEAD).--dry-run: report which files would change without writing.--output DIR: write migrated copies underDIRinstead of overwriting the originals.--check: compare each adjacent grammar pair with its migrator and fail if a removed rule has no converter. This mode does not migrate files.
Directory arguments are walked recursively; individual .qvr
files may also be supplied. The migration tooling is built on the
in-tree panproto VCS at grammars/qvr/vcs/. A new release adds a
migration without changing the earlier migration steps.
qvr repl [FILE] [--plain] [--target TARGET]¶
Start the interactive REPL. Without a file, opens an empty
session; with a file, loads and elaborates it before dropping to
the prompt. --plain uses the single-line front end instead of the
TUI, and --target TARGET makes every load report the capability
diagnostics of that transpile target beside the module's own, as
qvr check --target does. See
REPL and Language Server.
qvr run FILE [ENTRY [ARGUMENTS...]]¶
Execute one entry point of a checked module: a define computation or a
program. With no entry name, or with --list, the command prints every
entry point with its signature: a computation's value parameters, statics,
performed effects, and result type; a program's data parameters, result type,
and the sample sites a run may condition on.
Each positional argument is a JSON literal and corresponds to one value
parameter in declaration order. A computation runs under the configured
runtime providers, validating the arguments and result against the
specialized QIEC types with a fresh attachment table. A program runs forward
on the reference machine: its random instance is handled by a conditioning
replay of the sites given with --site inside a scoring draw of every other
site, and its score instance by an accumulator, so the run reports the
program's value together with the log joint of the drawn and given sites, its
observations, and its scores. A program's parameters may also be given by name
with --data; its extents are read off the data where the data fix them, so
--static names only an extent no data fixes, the object parameter of a
program template (qvr run pooling.qvr school_effects 0.6 --static K=8), and
its handlers are fixed by the run, so --runtime applies to computations
only.
Flags:
--list: print the file's entry points and exit.--static NAME=TERM: specialize one static telescope binder with a closed type, index, or effect term. Repeat the flag once for every binder.--data NAME=JSON: supply one program parameter by name (its data, an observation, a fibration, or a scalar). Repeatable.--site NAME=JSON: condition one sample site of a program on a value; every other site is drawn. Repeatable. A site the run never reaches is an error.--seed N: seed the reference generator a program run draws with, so two runs seeded alike draw alike.--runtime FILE.json: select runtime providers and their options through a non-executable JSON configuration.--fuel STEPS: bound the number of evaluation steps.--trace: write stable execution events to stderr in human-readable mode.--json: emit the result, runtime label, and complete trace as JSON, with the entry's kind and a program's log joint. A failure instead emits a JSON diagnostic and exits 1.
For instance, this command specializes A to Int and supplies the value
argument 7:
and this one runs a program on four observations with its site a fixed:
The same invocation is available from Python through
Program.run on a loaded module, from
Compiler.entry and
invoke_entry on its checked module,
and from the REPL's :run, with the same validation, providers, trace, and
diagnostic codes.
The default runtime configuration selects the built-in core provider. A
configuration can select that provider with handler behavior or name an
installed quivers.qiec_runtime entry point:
{
"providers": [
{
"name": "core",
"options": {
"handlers": {
"pass": {"kind": "passthrough"}
}
}
}
]
}
The core provider accepts passthrough, scripted, and state handler
configurations, and the prelude kinds draw, draw-scoring, enumerate,
replay, collect, score, search, and param. These options supply
process-local clause behavior; the source handler still fixes the checked
effect, coverage, forwarding policy, clause set, and resumption grades.
Runtime plugins are discoverable by name but are loaded only when the
configuration explicitly selects them.
Execution failures use stable codes including qiec-run-computation,
qiec-run-config, qiec-run-arity, qiec-run-static, qiec-run-provider,
qiec-run-validator, qiec-run-argument, qiec-run-evaluation,
qiec-run-fuel, and qiec-run-result.
qvr lsp¶
Run the Language Server over stdio, or pass --tcp PORT to bind a
TCP port. --target TARGET enables live qiec:capability:* diagnostics for
the selected transpiler. Editor extensions invoke this command; the protocol
is LSP 3.17. The server accepts later target changes through
workspace/didChangeConfiguration, using either
{"qvr": {"transpileTarget": "TARGET"}} or
{"transpileTarget": "TARGET"}; an empty target disables these diagnostics.
See REPL and Language Server.
qvr transpile FILE¶
Transpile a .qvr file to a registered probabilistic-programming
backend. Use --to BACKEND for one target, --to-all for every
registered target, or --list-targets to inspect the registry. The
--output and --out-dir flags select destinations for single- and
multi-target runs, respectively.
qvr kernel¶
Install or run the Quivers Jupyter kernel. qvr kernel install
registers the kernelspec; --user selects the user kernel directory,
and --prefix PREFIX selects an explicit Jupyter prefix.
Module reference¶
The quivers.cli package exports the qvr entry point together with
the tooling its subcommands share: per-file checking, the REPL session
and its front ends, completion, and highlighting.
quivers.cli.migrations exports the grammar migration chain, the
language server is built by quivers.lsp, and the Jupyter kernel
lives in quivers.kernel.
cli
¶
Command-line entry points for quivers.
The main function is registered as the qvr console script
in pyproject.toml.
Subcommands:
qvr check FILES...: parse and compile every supplied.qvrfile, emitting structured diagnostics. Exits 0 on full success, non-zero when any file produces an error.qvr migrate --from VER --to VER PATHS...: lower.qvrsource files from one tagged grammar revision to another, via panproto migrations composed from the in-treegrammars/qvr/vcschain.qvr run FILE COMPUTATION [ARGS...]: execute one checked QIEC computation with JSON value arguments and an explicit runtime configuration.
Output format: human-readable by default, structured JSON when
--json is supplied. Each diagnostic carries:
file: source path,line,col: 1-indexed source location,severity:"error","warning", or"note",code: stable diagnostic code (parse,compile,effect_constraint,residuated_constraint),message: human-readable description.
The Python surface beside main is the tooling the subcommands share:
check_file and CheckDiagnostic for checking, and ReplSession
with its completion, highlighting, and front-end helpers for driving
a REPL session from Python. run_tui binds lazily because its
Textual front end is an optional dependency.
SEMANTIC_TOKEN_MODIFIERS
module-attribute
¶
The semantic token modifiers the language server advertises in its legend.
SEMANTIC_TOKEN_TYPES
module-attribute
¶
SEMANTIC_TOKEN_TYPES: tuple[str, ...] = ('comment', 'keyword', 'operator', 'punctuation', 'string', 'number', 'variable', 'type', 'function', 'namespace', 'decorator', 'error')
The semantic token types every QVR token reduces to. The order is significant: a token's index here is its type in the LSP semantic-token legend.
STYLE_TABLE
module-attribute
¶
STYLE_TABLE: dict[str, str] = {'comment': 'italic #5c6370', 'keyword': 'bold #c678dd', 'operator': '#56b6c2', 'punctuation': '#7f848e', 'string': '#98c379', 'number': '#d19a66', 'variable': '#abb2bf', 'type': 'bold #61afef', 'function': 'bold #e5c07b', 'namespace': 'bold #e06c75', 'decorator': '#c678dd', 'error': 'bold #e06c75 underline'}
Rich style strings keyed by semantic token type, shared by the TUI, the prompt_toolkit lexer, and the Jupyter kernel so that every front end colours a token alike.
CheckSeverity
¶
The severity of a CheckDiagnostic.
CheckDiagnostic
didactic-model
¶
CheckDiagnostic(*, file: str, line: int, col: int, severity: CheckSeverity, code: str, message: str)
Bases: Model
One structured diagnostic that qvr check reports for a file.
| PARAMETER | DESCRIPTION |
|---|---|
file
|
The path of the checked file.
TYPE:
|
line
|
The 1-indexed source line, or
TYPE:
|
col
|
The 1-indexed source column, or
TYPE:
|
severity
|
TYPE:
|
code
|
The stable diagnostic code, such as
TYPE:
|
message
|
The human-readable description.
TYPE:
|
Diagnostic
didactic-model
¶
Diagnostic(*, message: str, severity: Severity, line: int = 0, col: int = 0, end_line: int = 0, end_col: int = 0, code: str = '')
Bases: Model
One structured diagnostic surfaced by the REPL or LSP.
ReplResponse
didactic-model
¶
ReplResponse(*, body: str = '', diagnostics: tuple[Diagnostic, ...] = (), body_kind: Literal['text', 'qvr', 'json', 'markdown'] = 'text')
Bases: Model
A single command's result, ready for any frontend to render.
body is the primary payload, which a frontend renders by
pairing it with body_kind (text / qvr / json /
markdown); each frontend is responsible for choosing the
concrete renderer (Rich syntax block, prompt_toolkit ANSI, etc.)
from body_kind. diagnostics carry structured errors and
warnings.
ReplSession
¶
Stateful evaluator for a single REPL session.
Source code in src/quivers/cli/repl_session.py
env
property
¶
Live environment dict (every declared atom: objects, spaces, morphisms, rules, programs, deductions, signatures, encoders, decoders, losses, bundles, contractions).
last_entry
property
¶
last_entry: EntryRun | None
The most recent entry-point run of this session, or None.
last_failure
property
¶
last_failure: ExecutionDiagnostic | None
The diagnostic of the most recent failed run, or None once a
run succeeds after it.
watch_results
¶
env_kinds
¶
Return a name -> semantic-token-type map for the live env.
Frontends pass this to the highlighter so an identifier renders in its env-known colour everywhere it appears, regardless of whether the surrounding grammar context parses cleanly.
Source code in src/quivers/cli/repl_session.py
dispatch
¶
dispatch(line: str) -> ReplResponse
Route a raw input line to the right handler.
Source code in src/quivers/cli/repl_session.py
type_of
¶
type_of(expr_source: str) -> ReplResponse
Print the type of a value-level expression.
Mirrors GHCi's :type: works on morphisms, programs,
deductions, scoped sample / observe / let sites, and any
expression that resolves to a morphism. For type-level names
(objects, spaces, sorts), returns an error directing the user
to :kind.
Source code in src/quivers/cli/repl_session.py
464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 | |
transpile_module
¶
transpile_module(target: str) -> ReplResponse
Emit the loaded module as source for the named transpile backend.
Mirrors the qvr transpile CLI
subcommand, dispatched in-session against the currently-loaded
Module. Returns the
transpiled bytes decoded as UTF-8; never mutates session state.
Errors:
- No module loaded yet (caller must run
:load FILEfirst). - Empty or whitespace-only target string.
- Target is not in
available_targets. - The walker raises
UnsupportedConstruct(the message carries the offending construct kinds).
Source code in src/quivers/cli/repl_session.py
runtime
¶
runtime(specification: str = '') -> ReplResponse
Show or replace the explicit runtime-provider configuration.
Source code in src/quivers/cli/repl_session.py
detach_runtime
¶
detach_runtime() -> ReplResponse
Remove every runtime provider from this session.
Source code in src/quivers/cli/repl_session.py
run_computation
¶
run_computation(invocation: str) -> ReplResponse
Execute NAME [JSON ...] [--data NAME=JSON] [--site NAME=JSON]
[--static NAME=TERM] [--fuel STEPS] [--seed N].
The entry is a define computation or a program, invoked
through the same invoke_entry
as qvr run, so its validation, providers, trace, and error
codes are those of the command line. :run alone lists the
module's entry points.
| PARAMETER | DESCRIPTION |
|---|---|
invocation
|
The entry name and its arguments, as typed after
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ReplResponse
|
The value, its type, the runtime label, the trace length, and a program's log joint; or the diagnostic of a failure. |
Source code in src/quivers/cli/repl_session.py
622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 | |
kind_of
¶
kind_of(expr_source: str) -> ReplResponse
Print the kind of a type-level name or type expression.
Mirrors GHCi's :kind: works on objects, spaces, sorts,
atoms, constructors, and bare type expressions like
FinSet 3 or A * B. For value-level names (morphisms,
programs, sites), returns an error directing the user to
:type.
Source code in src/quivers/cli/repl_session.py
1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 | |
plate
¶
plate(name: str, *, fmt: str = 'table') -> ReplResponse
Render the plate diagram for name (a program).
fmt selects the output format: "table" (default,
in-TUI Rich table; also has a plain-text fallback),
"mermaid", "dot", "tikz", "daft", or
"open" (render via daft or graphviz, save to a temp
PNG, and open with the system default opener).
Source code in src/quivers/cli/repl_session.py
graph
¶
graph(name: str, *, fmt: str = 'table') -> ReplResponse
Render a step-flow view of name (a program).
The step-flow view lists the program's body steps one per
row with their dependency parents on the side, plus an
indented sub-block for any marginalize body. Same fmt
flags as :plate.
Source code in src/quivers/cli/repl_session.py
where
¶
where(name: str) -> ReplResponse
List every scope path whose final segment is name.
Source code in src/quivers/cli/repl_session.py
effects
¶
effects(name: str) -> ReplResponse
Compare declared and inferred effect sets for a program.
Source code in src/quivers/cli/repl_session.py
1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 | |
shape
¶
shape(name: str) -> ReplResponse
Render the ChainShape of the named program.
Source code in src/quivers/cli/repl_session.py
trace
¶
trace(expr_source: str) -> ReplResponse
Step through elaboration of a morphism expression.
Source code in src/quivers/cli/repl_session.py
save
¶
save(path: str = '') -> ReplResponse
Write the live module back to a .qvr file.
Source code in src/quivers/cli/repl_session.py
watch
¶
watch(expr: str) -> ReplResponse
Pin an expression for re-evaluation on every recompile.
Source code in src/quivers/cli/repl_session.py
unwatch
¶
unwatch(expr: str) -> ReplResponse
Remove a previously-pinned watch expression.
Source code in src/quivers/cli/repl_session.py
autoreload_if_stale
¶
autoreload_if_stale() -> ReplResponse | None
Re-run :reload if the loaded file's mtime advanced.
Source code in src/quivers/cli/repl_session.py
SessionOptions
didactic-model
¶
SessionOptions(*, highlight: bool = True, unicode: bool = True, show_axes: bool = True, paranoid: bool = False, autoload_on_save: bool = True, theme: str = 'ansi_dark', target: str = '')
Bases: Model
User-tunable knobs exposed via :set.
theme selects a Rich syntax theme for QVR bodies rendered
via :info / :dump etc. Common values: ansi_dark,
ansi_light, monokai, nord, solarized-dark,
solarized-light, github-dark.
target
class-attribute
instance-attribute
¶
A transpile target whose capability diagnostics :load and
:reload report beside the checked module's own, as qvr check
--target does; empty for none.
Span
dataclass
¶
Span(start: int, end: int, token: str, text: str, line: int = 0, col: int = 0, end_line: int = 0, end_col: int = 0)
One styled run of source.
| PARAMETER | DESCRIPTION |
|---|---|
start
|
The run's start byte offset in the source.
TYPE:
|
end
|
The run's end byte offset, exclusive.
TYPE:
|
token
|
Its semantic token type, one of
TYPE:
|
text
|
The source text of the run.
TYPE:
|
line
|
Its 0-indexed start line.
TYPE:
|
col
|
Its 0-indexed start column, in UTF-16 code units.
TYPE:
|
end_line
|
Its 0-indexed end line.
TYPE:
|
end_col
|
Its 0-indexed end column, in UTF-16 code units.
TYPE:
|
check_file
¶
check_file(path: Path, *, target: str | None = None) -> list[CheckDiagnostic]
Parse, constraint-check, and compile one .qvr file.
This is the per-file pipeline behind qvr check. It reports
failures as diagnostics rather than raising, so an unreadable file
yields an io diagnostic and a syntax error a parse one.
| PARAMETER | DESCRIPTION |
|---|---|
path
|
The
TYPE:
|
target
|
A transpile target whose missing capabilities are also
reported, as
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[CheckDiagnostic]
|
Every diagnostic the file produces, empty when it checks cleanly. |
Source code in src/quivers/cli/check.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 | |
render_qiec_signature
¶
render_qiec_signature(module: Module, name: str) -> str | None
Return a compact source signature for one QIEC binding.
This works from the authored AST rather than a backend compiler object, so it remains available when a document contains only indexed families or effect interfaces.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
The parsed module holding the binding.
TYPE:
|
name
|
The QIEC binding to describe.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str or None
|
The compact signature, or |
Source code in src/quivers/cli/repl_session.py
render_signature
¶
render_signature(compiler: Compiler | None, name: str) -> str | None
Return the GHCi-style name :: type (or object NAME : ...
for type-level bindings) for a top-level name, or None when
the compiler is absent or the name is unknown.
This is the shared entry point used by both the REPL (:type
/ :kind / bare-expression fallback) and the LSP server's
hover panel: by routing every surface that wants a one-line
signature through the same function, a binding looks identical
regardless of whether the user is in the TUI or hovering in an
editor.
| PARAMETER | DESCRIPTION |
|---|---|
compiler
|
The compiler holding the elaborated environment.
TYPE:
|
name
|
The top-level name to describe.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str or None
|
The one-line signature, or |
Source code in src/quivers/cli/repl_session.py
all_completions
¶
all_completions(session: ReplSession, prefix: str) -> list[Completion]
Return every candidate whose text starts with prefix.
The caller (prompt_toolkit Completer, LSP completion handler) decides which slice to show.
| PARAMETER | DESCRIPTION |
|---|---|
session
|
The session whose environment supplies name completions.
TYPE:
|
prefix
|
The text typed so far.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[Completion]
|
Meta-command, transpile-target, environment, keyword, and path candidates, in that order. |
Source code in src/quivers/cli/repl_complete.py
public_meta_commands
¶
Return one public spelling for every registered meta-command.
The dispatch table registers each long spelling before its short aliases. Keeping the first name for each handler thus makes completion and the TUI palette follow the executable command surface without advertising aliases.
| RETURNS | DESCRIPTION |
|---|---|
tuple[str, ...]
|
The long spelling of each meta-command, in registration order. |
Source code in src/quivers/cli/repl_complete.py
to_pygments_pairs
¶
Build (Pygments token, text) pairs suitable for prompt_toolkit.
prompt_toolkit's PygmentsLexer wraps a Pygments Lexer that yields
(index, token, text); here we deliver the simpler (token,
text) form directly used by prompt_toolkit.formatted_text.
| PARAMETER | DESCRIPTION |
|---|---|
source
|
The QVR source to highlight.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[tuple[_TokenType, str]]
|
One pair per span, in source order. |
Source code in src/quivers/cli/repl_highlight.py
to_rich_text
¶
to_rich_text(source: str, *, env_kinds: dict[str, str] | None = None, link_action: str | None = None) -> Any
Build a rich.text.Text from the highlighted source.
Rich is imported lazily so that importing this module does not pull rich in for callers that need only raw spans.
If link_action is set (e.g. "info"), identifiers that the
grammar or env classified as something meaningful (type / function
/ namespace / variable when the name is in env_kinds) are wrapped
as Rich console links pointing to "<link_action>:<name>". The
TUI's RichLog on_click translator then runs :link_action
<name> when the user clicks.
| PARAMETER | DESCRIPTION |
|---|---|
source
|
The QVR source to highlight.
TYPE:
|
env_kinds
|
Semantic kinds of names bound in the environment, as for
TYPE:
|
link_action
|
The meta-command clickable identifiers run, or
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Text
|
The styled text. |
Source code in src/quivers/cli/repl_highlight.py
to_semantic_token_data
¶
Encode source as the LSP SemanticTokens 5-tuple stream.
The stream is delta-encoded as [deltaLine, deltaStart, length,
tokenType, tokenModifiers] per LSP 3.17. See
https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_semanticTokens
for the encoding rules.
| PARAMETER | DESCRIPTION |
|---|---|
source
|
The QVR source to encode.
TYPE:
|
env_kinds
|
Semantic kinds of names bound in the environment, as for
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[int]
|
Five integers per token. |
Source code in src/quivers/cli/repl_highlight.py
to_semantic_token_legend
¶
Return the semantic-token legend the language server advertises.
| RETURNS | DESCRIPTION |
|---|---|
tuple[tuple[str, ...], tuple[str, ...]]
|
|
Source code in src/quivers/cli/repl_highlight.py
tokenize
¶
tokenize(source: str | bytes, *, env_kinds: dict[str, str] | None = None) -> list[Span]
Return the styled span list for source.
| PARAMETER | DESCRIPTION |
|---|---|
source
|
The QVR source to highlight.
TYPE:
|
env_kinds
|
Semantic kinds of names bound in the environment, as described
below;
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[Span]
|
The source's spans in order, each tagged with a semantic token type. |
Drives directly on the tree-sitter parse so that anonymous tokens
|
|
(keywords, punctuation) are preserved; panproto's Schema view
|
|
strips those, so we go to tree-sitter for highlighting and keep
|
|
panproto for parsing into the didactic AST.
|
|
``env_kinds`` enables semantic highlighting: a mapping from name
|
|
to one of ``"type"``, ``"function"``, ``"namespace"`` (or any
|
|
SEMANTIC_TOKEN_TYPES value). Identifiers the grammar leaves as
|
|
``"variable"`` are upgraded to their env-known kind, so a name
|
|
looks the same across the input pane, ``:type``, ``:info``, and
|
|
any other surface, regardless of whether the surrounding context
|
|
parses as a valid declaration.
|
|
Failure path: if the parser raises, the entire source is returned
|
|
as a single ``error`` span. Callers can downgrade to a no-highlight
|
|
render but the buffer still displays.
|
|
Source code in src/quivers/cli/repl_highlight.py
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 | |
run_plain
¶
run_plain(session: ReplSession) -> int
Run the single-line REPL front end on session.
The front end reads with prompt_toolkit when it is installed and with bare standard input otherwise.
| PARAMETER | DESCRIPTION |
|---|---|
session
|
The session that evaluates each line.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
int
|
The process exit status, |
Source code in src/quivers/cli/repl_prompt.py
run_tui
¶
run_tui(session: ReplSession) -> int
Run the Textual REPL front end on session.
| PARAMETER | DESCRIPTION |
|---|---|
session
|
The session that evaluates each input.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
int
|
The process exit status, |
Source code in src/quivers/cli/repl_tui.py
__getattr__
¶
__getattr__(name: str) -> Callable[[ReplSession], int]
Bind the re-exports whose modules need optional dependencies.
Importing run_tui loads Textual, which only the repl extra
installs, so the package binds it on first access rather than at
import time.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The attribute being looked up.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Callable[[ReplSession], int]
|
The lazily bound front end. |
| RAISES | DESCRIPTION |
|---|---|
AttributeError
|
When |
Source code in src/quivers/cli/__init__.py
main
¶
Run the qvr command line on sys.argv.
| RETURNS | DESCRIPTION |
|---|---|
int
|
The process exit status of the selected subcommand. |
Source code in src/quivers/cli/__init__.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 | |
migrations
¶
Registry of structural one-hop .qvr source migrations.
Each adjacent-pair migrator is a callable bytes -> bytes built
on the panproto pipeline in quivers.cli.migrations._common:
parse with the source revision's tree-sitter parser, build the
target schema by walking the source parse tree and emitting target
vertices/edges/constraints, then emit canonical target bytes via
the target revision's emit_pretty. The third stage is grammar-
bound by panproto: a target schema that does not satisfy the target
grammar's rules cannot emit.
The CHAIN tuple lists releases in chronological order with
"HEAD" always last. Each adjacent pair (CHAIN[i], CHAIN[i+1])
must have a registered migrator in MIGRATORS.
compose_migration walks CHAIN between any two listed
releases and composes the intermediate hops into a single
bytes -> bytes callable.
To add the next release:
- Tag the release in git.
- Run
python grammars/qvr/vcs/build_schemas.pyandpython grammars/qvr/vcs/build_parsers.py. - Replace the current
v<latest> -> HEADedge with the pinnedv<latest> -> v<next>hop, then add a newv<next> -> HEADhop covering the next batch of grammar changes. Use the explicit identity migrator when the authored grammar is unchanged. - Insert the new release immediately before
"HEAD"inCHAINand register both affected edges inMIGRATORS.
The qvr migrate CLI consumes compose_migration and is
agnostic to which pairs are registered.
CHAIN
module-attribute
¶
CHAIN: tuple[str, ...] = ('v0.2.0', 'v0.3.0', 'v0.4.0', 'v0.5.0', 'v0.6.0', 'v0.7.0', 'v0.9.0', 'v0.10.0', 'v0.11.0', 'v0.14.0', 'v0.15.0', 'v0.16.0', 'v0.17.0', 'v0.18.0', 'v0.19.0', 'HEAD')
The QVR grammar releases a migration can start or end at, oldest
first, with "HEAD" (the current grammar) always last.
MIGRATORS
module-attribute
¶
MIGRATORS: dict[tuple[str, str], _Migrator] = {('v0.2.0', 'v0.3.0'): _hop_2_3.migrate, ('v0.3.0', 'v0.4.0'): _hop_3_4.migrate, ('v0.4.0', 'v0.5.0'): _hop_4_5.migrate, ('v0.5.0', 'v0.6.0'): _hop_5_6.migrate, ('v0.6.0', 'v0.7.0'): _hop_6_7.migrate, ('v0.7.0', 'v0.9.0'): _hop_7_9.migrate, ('v0.9.0', 'v0.10.0'): _identity.migrator('v0.9.0', 'v0.10.0'), ('v0.10.0', 'v0.11.0'): _hop_10_11.migrate, ('v0.11.0', 'v0.14.0'): _hop_11_14.migrate, ('v0.14.0', 'v0.15.0'): _hop_14_15.migrate, ('v0.15.0', 'v0.16.0'): _identity.migrator('v0.15.0', 'v0.16.0'), ('v0.16.0', 'v0.17.0'): _identity.migrator('v0.16.0', 'v0.17.0'), ('v0.17.0', 'v0.18.0'): _identity.migrator('v0.17.0', 'v0.18.0'), ('v0.18.0', 'v0.19.0'): _hop_18_19.migrate, ('v0.19.0', 'HEAD'): _hop_19_head.migrate}
The one-hop migrator registered for each adjacent pair of CHAIN,
a bytes -> bytes rewrite of .qvr source.
COVERAGE
module-attribute
¶
COVERAGE: dict[tuple[str, str], frozenset[str]] = {('v0.2.0', 'v0.3.0'): _hop_2_3.SOURCE_RULE_COVERAGE, ('v0.3.0', 'v0.4.0'): _hop_3_4.SOURCE_RULE_COVERAGE, ('v0.4.0', 'v0.5.0'): _hop_4_5.SOURCE_RULE_COVERAGE, ('v0.5.0', 'v0.6.0'): _hop_5_6.SOURCE_RULE_COVERAGE, ('v0.6.0', 'v0.7.0'): _hop_6_7.SOURCE_RULE_COVERAGE, ('v0.7.0', 'v0.9.0'): _hop_7_9.SOURCE_RULE_COVERAGE, ('v0.9.0', 'v0.10.0'): _identity.SOURCE_RULE_COVERAGE, ('v0.10.0', 'v0.11.0'): _hop_10_11.SOURCE_RULE_COVERAGE, ('v0.11.0', 'v0.14.0'): _hop_11_14.SOURCE_RULE_COVERAGE, ('v0.14.0', 'v0.15.0'): _hop_14_15.SOURCE_RULE_COVERAGE, ('v0.15.0', 'v0.16.0'): _identity.SOURCE_RULE_COVERAGE, ('v0.16.0', 'v0.17.0'): _identity.SOURCE_RULE_COVERAGE, ('v0.17.0', 'v0.18.0'): _identity.SOURCE_RULE_COVERAGE, ('v0.18.0', 'v0.19.0'): _hop_18_19.SOURCE_RULE_COVERAGE, ('v0.19.0', 'HEAD'): _hop_19_head.SOURCE_RULE_COVERAGE}
The source-side grammar rules each hop's converters cover, keyed by
adjacent pair of CHAIN. vcs_coverage_report checks these against
the schema diff between the two revisions.
IDENTITY_PAIRS
module-attribute
¶
The adjacent pairs of CHAIN whose grammars are identical, so that
their registered migrator returns its source unchanged.
MigrationError
¶
Bases: Exception
Raised when a requested migration cannot be composed, or when a source construct admits no rewrite under the target grammar.
BlameReport
dataclass
¶
BlameReport(rule: str, introduced_at_commit: str | None, introduced_at_tag: str | None, last_present_at_commit: str | None, last_present_at_tag: str | None)
Where in the grammar's history a rule first appeared or was last seen.
| PARAMETER | DESCRIPTION |
|---|---|
rule
|
The tree-sitter rule name.
TYPE:
|
introduced_at_commit
|
The commit that introduced the rule, when the VCS records one.
TYPE:
|
introduced_at_tag
|
The release tag of that commit, when it has one.
TYPE:
|
last_present_at_commit
|
The newest commit whose schema contains the rule.
TYPE:
|
last_present_at_tag
|
The release tag of that commit, when it has one.
TYPE:
|
DiffCoverageReport
dataclass
¶
DiffCoverageReport(from_ref: str, to_ref: str, added_rules: tuple[str, ...], removed_rules: tuple[str, ...], uncovered_removed: tuple[str, ...])
The schema diff between two revisions, classified against a hop's declared converters.
| PARAMETER | DESCRIPTION |
|---|---|
from_ref
|
The source release.
TYPE:
|
to_ref
|
The target release.
TYPE:
|
added_rules
|
Grammar rules present at
TYPE:
|
removed_rules
|
Grammar rules present at
TYPE:
|
uncovered_removed
|
The removed rules that the hop declares no converter for.
TYPE:
|
uncovered_removed
instance-attribute
¶
Rules removed at the target revision that are also absent
from declared_converters. Each one is a source-side vertex
kind that the migrator's dispatch passes through as a structural
clone, which emit_pretty then misrenders or drops. These are
the actionable misses.
format
¶
Render the report for CLI display.
| RETURNS | DESCRIPTION |
|---|---|
str
|
A multi-line summary of the added, removed, and uncovered rules. |
Source code in src/quivers/cli/migrations/_vcs.py
blame_kind
¶
blame_kind(rule: str) -> BlameReport
Report when a tree-sitter rule was introduced or removed.
The migrators' failure path uses this to point at the release that needs a new converter.
| PARAMETER | DESCRIPTION |
|---|---|
rule
|
The tree-sitter rule name.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
BlameReport
|
The rule's introduction and last appearance in the grammar's VCS history. |
Source code in src/quivers/cli/migrations/_vcs.py
check_chain_coverage
¶
check_chain_coverage(chain: tuple[str, ...], converters_by_pair: dict[tuple[str, str], frozenset[str]]) -> list[DiffCoverageReport]
Run diff_coverage on every adjacent pair of a chain.
| PARAMETER | DESCRIPTION |
|---|---|
chain
|
Releases in chronological order.
TYPE:
|
converters_by_pair
|
The source-side rule names each
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[DiffCoverageReport]
|
One report per adjacent pair, in chain order. |
Source code in src/quivers/cli/migrations/_vcs.py
diff_coverage
¶
diff_coverage(from_ref: str, to_ref: str, declared_converters: frozenset[str]) -> DiffCoverageReport
Diff two revisions' grammar schemas against a hop's converters.
A rule appearing in from_ref's schema but not in to_ref's
is a removed rule. A removed rule that declared_converters
does not list would pass through the migrator unconverted, likely
producing incorrect output; such rules surface in
uncovered_removed. Identity hops, whose revisions share a
commit, report no diff.
| PARAMETER | DESCRIPTION |
|---|---|
from_ref
|
The source release.
TYPE:
|
to_ref
|
The target release.
TYPE:
|
declared_converters
|
The source-side rule names the hop declares it converts.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
DiffCoverageReport
|
The classified diff. |
Source code in src/quivers/cli/migrations/_vcs.py
commit_id
¶
Resolve a release name to its pinned panproto VCS commit id.
The commit ids come from the schema-commit manifest and are computed once, on first call.
| PARAMETER | DESCRIPTION |
|---|---|
ref
|
A release name in
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
The commit id, or |
| RAISES | DESCRIPTION |
|---|---|
MigrationError
|
When the manifest disagrees with |
Source code in src/quivers/cli/migrations/__init__.py
vcs_coverage_report
¶
vcs_coverage_report() -> list[DiffCoverageReport]
Check every registered hop against the grammar's schema diff.
For each adjacent pair of CHAIN, the report carries the schema
diff between the two revisions and the removed source rules that
the hop's COVERAGE entry does not cover. qvr migrate --check
runs this, and a CI test can run it to catch a migrator that has
fallen behind a grammar change.
| RETURNS | DESCRIPTION |
|---|---|
list[DiffCoverageReport]
|
One report per adjacent pair of |
| RAISES | DESCRIPTION |
|---|---|
MigrationError
|
When |
Source code in src/quivers/cli/migrations/__init__.py
compose_migration
¶
Compose the hops between two releases into one migrator.
| PARAMETER | DESCRIPTION |
|---|---|
from_ref
|
The source release, a member of
TYPE:
|
to_ref
|
The target release, a member of
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Callable[[bytes], bytes]
|
A rewrite of |
| RAISES | DESCRIPTION |
|---|---|
MigrationError
|
When either release is not in |
Source code in src/quivers/cli/migrations/__init__.py
available_targets
¶
List the releases a migration from from_ref can target.
| PARAMETER | DESCRIPTION |
|---|---|
from_ref
|
The source release.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[str, ...]
|
|
Source code in src/quivers/cli/migrations/__init__.py
lsp
¶
QVR Language Server.
Public entry: build_server returns a configured pygls
LanguageServer that speaks LSP 3.17 over stdio. The qvr lsp
subcommand wraps it with stdio and TCP plumbing.
The server reuses every analytic component the REPL uses: per-document
state in the style of ReplSession,
tokenize for semantic tokens, and
all_completions for completion. There
is no duplicate parser, type-checker, or token vocabulary.
SERVER_NAME
module-attribute
¶
The server name reported to clients and attached to diagnostics.
SERVER_VERSION
module-attribute
¶
The server version reported to clients in the initialize response.
build_server
¶
Build a QVR language server with every feature registered.
| PARAMETER | DESCRIPTION |
|---|---|
target
|
A transpile target whose missing capabilities are published as
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
LanguageServer
|
The configured pygls server, ready for |
Source code in src/quivers/lsp/server.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 | |
kernel
¶
Jupyter kernel for QVR.
Two console-script entry points:
qvr kernel installregisters the kernelspec.qvr kernel runis invoked by Jupyter once a notebook starts.
The kernel reuses ReplSession so
notebook cells behave exactly like the REPL: leading : runs a meta
command; bare cells parse first as statements (appended to the
session's module) and fall back to type-printing.
KERNELSPEC
module-attribute
¶
KERNELSPEC = {'argv': [sys.executable, '-m', 'quivers.kernel', '_run_f', '{connection_file}'], 'display_name': 'quivers', 'language': 'qvr', 'interrupt_mode': 'signal', 'metadata': {'debugger': False}}
The kernel.json document install_kernelspec registers: it launches the
kernel with the running interpreter and names the language qvr.
QuiversKernel
¶
Bases: Kernel
A Jupyter kernel that evaluates QVR cells in a ReplSession.
Each line of a cell is dispatched to the session as the REPL would
dispatch it, so a leading : runs a meta-command and other input
is elaborated against the session's module. Jupyter constructs the
kernel; install_kernelspec registers it.
| PARAMETER | DESCRIPTION |
|---|---|
**kwargs
|
Keyword arguments forwarded to
TYPE:
|
Source code in src/quivers/kernel/quivers_kernel.py
install_kernelspec
¶
Register the QVR kernelspec with Jupyter.
| PARAMETER | DESCRIPTION |
|---|---|
user
|
Install into the per-user kernel directory rather than the system one.
TYPE:
|
prefix
|
An explicit Jupyter prefix to install under, as
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Path
|
The directory the kernelspec was installed into. |
| RAISES | DESCRIPTION |
|---|---|
ImportError
|
When |