CLI: qvr¶
The qvr console script ships with the package as a thin wrapper around the parser, the
constraint solver, and the compiler. check
validates source files,
run runs one entry point, transpile
writes target source, and repl and lsp give interactive and editor access. Fitting a posterior
with stochastic variational inference (SVI) or Markov chain Monte Carlo (MCMC) goes through the inference API.
qvr check FILES...¶
Parse, run the constraint solver on, and compile every .qvr file given.
The command emits structured diagnostics and exits with 0 on full success
and 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 Quivers Indexed Effect Core (QIEC) computation with the selected transpiler's advertised capabilities. Unsupported features are errors, so this mode serves as an early release gate for one target. It does not render the target program, soqvr transpile --to TARGET FILEremains the check of the whole lowering and rendering path.
Diagnostic codes:
parse: tree-sitter rejected the source.compile: the compiler raisedCompileError.residuated_constraint: a slash category appears outside a residuated context, that is, outside a schema parameterized by a declaredFreeResiduatedset of categories.effect_constraint: an applied effect has a name that neither starts with an uppercase letter nor contains an underscore.bundle_unknown_member: abundledeclaration names a member that is not 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 didactic lowering route from the QVR source protocol to the QIEC core ABI is unavailable or does not match.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: static evidence local to a branch 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 migrators between adjacent grammar releases defined in
quivers.cli.migrations, so the intermediate releases need not be
named. --from and --to select part of the chain.
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.--dependency PKG@OLD..NEW: migrate the modules of the package containing the working directory (or--package DIR), and the run records given as paths, from the locked version of a dependency to the version its manifest now resolves to, along the dependency's interface lens (migrating dependents of a package). Every place that names a removed symbol is listed with its location and its file is left unchanged; the exit status is then 1.
Directory arguments are walked recursively, and individual .qvr
files may also be given. Markdown files, including literate .qvr.md
modules, are migrated block by block: each fenced qvr block is rewritten
in place according to its <!-- compile: ... --> marker, and every
compile: false fragment is listed as review PATH:LINE for a reader to
check. 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 lock, qvr build, qvr bump, qvr publish¶
The package commands (packages, lockfiles, and versions) work on
the package containing the working directory, or the one --package DIR names.
qvr lock: resolveqvr.tomlby minimal version selection, check every module of every package, and writeqvr.lockwith each module's content hashes. A resolution failure prints its derivation.qvr build: resolve againstqvr.lock(offline once its commits are cached), refuse a stale lockfile (package-lock-stale) or a module whose hashes differ from their pins (package-pin-mismatch), and check every module of the package.qvr bump --against REF: compare the package's interface with the version atREF(a directory or a git revision of its repository) and print every change with the version it requires.--to VERSIONchecks a version,--writewrites the required one intoqvr.toml, and--jsonprints the changes as data. A version that understates the change exits 1; a major change writes its dependency lens intolenses/.qvr publish INDEX --git URL [--rev REV]: check and pin the package at a commit of its repository and commit its entry intoINDEX, a working tree of a package index, refusing a version that is already listed or that understates its change from the newest listed one.--cache DIRnames the git cache.
Each exits with 0 on success and 1 on a refusal, printing qvr: <message>.
qvr repl [FILE] [--plain] [--target TARGET]¶
Start the interactive REPL. Without a file, the REPL opens an empty
session. With a file, it loads and elaborates the file before showing
the prompt. --plain uses the plain front end that reads one line at a time 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
(Interactive tools).
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 signature gives its value
parameters, static parameters, performed effects, and result type. A program's
gives its data inputs, its 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, the
library's interpreter for QIEC. Its random instance replays the sites given with --site and
draws and scores every other site, and its score instance accumulates. The run reports the
program's value with the log joint density 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 from
the data where the data fix them, so --static names only an extent that no data fixes, such as the
object parameter of a program template (qvr run pooling.qvr school_effects 0.6 --static K=8). The
run fixes a program's handlers, 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: give one program parameter by name (a data input, an observation, an index map from rows to groups, or a scalar). Repeatable.--site NAME=JSON: condition one sample site of a program on a value, drawing every other site. 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.--exact: compute a computation's reals exactly, as rationals (NumberDomain.exact); the result prints asp/q, a float argument is read as the decimal it spells, and an operation the rationals are not closed under (exp,log,sqrt,sigmoid, ...) stops the run with an error naming it. A program draws and scores in floating point, so it takes no--exact.--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 passes 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, the prelude kinds draw, draw-scoring, replay, score,
and param, and the kind declared, which serves a
foreign handler by the semantics its declaration states: a
search, a collector, an enumeration, or a settlement, whose options
on_failure and reports give its
FailurePolicy and the list its
report goes to. These options give the clause behavior, which lives only in
the running Python process. 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 test PATHS...¶
Run the test, property and example declarations of every
module named: a .qvr file is one module, and a directory is a package of every module under it.
Tests run on the reference machine, exactly over the rationals unless a test declares floating
numbers. The command exits with 0 when every module loads and every test passes, and 1 otherwise.
Flags:
--json: print the machine-readable report ofTestReport.to_dataon stdout.--match TEXT: run only the tests whose title containsTEXT.--no-cache: run every test; by default a test whose content, code, and options are unchanged since it passed is reported from the cache.--mutate: run each module's tests against every mutant of its rules, lexical entries, and constants (mutate_module), and report the mutants that survive; the exit status is 1 when any does.
No flag changes a test's tolerance, seed, case count, or number domain: those are pinned in the declaration.
qvr hash FILES...¶
Print the content identities of every .qvr file named
(Content identity): the core hash of each checked declaration
(families, effects, handlers, computations, entries, custom distribution families, instances, and
index sorts), the module digest, the program digest a fit is keyed by, the hash of the exact bytes
with the panproto commit of the grammar, and the alpha-normalized source hash of each top-level
statement. Core hashes are invariant under renaming, reordering, comments, formatting, and every
syntactic migration hop, and change with any change of meaning. The command exits with 0 when
every file checks and 1 otherwise.
$ qvr hash regression.qvr
regression.qvr
module 79817211fa3ef17cac97f50aa0a2ef473c16b43aeffd0910e70e838b26880d80
program 9f2bd056504fbf74f50ad8401116b87bfdb8072ea9096a1aa488b6027f5bf1fd
source 3ee5e80d4d71... (grammar cc279318096d...)
computation 42a0e13b1ef8... model
entry 3168dc6f65dc... model
...
Flags:
--json: print one JSON record per file.--normal-form KIND:NAME: print the canonical core form the declaration's hash digests, for one file (for example--normal-form computation:model), to see why two declarations hash apart.--check-migrations [PATHS...]: instead of hashing, run the migration-invariance gate (check_migration_invariance) over the given files and directories, or over the corpus when none are given. Every hop of the migration chain, and every feature of the release hop on its own, is applied to each file that is valid source at the hop's revision, and the migrated file must have the file's own core hashes unless the hop declares itself semantic. The exit status is 1 on any failure.
qvr cache¶
Inspect and manage the project's persistent cache
(ArtifactStore): checked modules and query results,
fits (FitCache), and runs, each stored under the digest of
everything that determines it. The cache lives in .qvr/cache at the project root (the nearest
directory holding qvr.toml, .qvr, or .git), in $QVR_CACHE_DIR when that is set, or in the
directory --dir PATH names; it is never placed in a temporary directory. Writing past its size
limit (2 GiB unless set) evicts the least recently used entries, and every entry's payload is
checked against its recorded digest when read.
Actions:
info: the directory, the limit, and the entries and bytes of each namespace.list [--namespace NS]: every entry, most recently used first.clear [--namespace NS]: delete entries.prune [--max-size SIZE] [--older-than AGE]: evict entries unused forAGE, then the least recently used until the cache fitsSIZE(its limit by default).limit [SIZE]: show the limit, or set it and evict down to it.
Sizes take a K, M, or G suffix (powers of 1024) and ages an s, m, h, or d suffix.
--json prints info and list as JSON.
qvr experiment¶
Run, hash, check, and export the experiments a module declares.
Each action takes FILE:NAME (a .qvr or .qvr.md file, or a dotted module path below
--root), where :NAME may be left out when the module declares one experiment. The command exits
with 0 on success and 1 when anything is refused or a check fails; a refusal names its code and
its clause's line and column (error[experiment-data-pin]: model.qvr:13:4: ...).
Actions:
run TARGET [--rerun] [--json] [--export DIR]: run every point of the experiment and store each record under its hash in the project's cache (namespaceexperiment); a point whose record is stored is read, not run, unless--rerunis given.--export DIRalso writes a Workflow Run RO-Crate of the runs.hash TARGET [--json]: print the experiment's hash, its program's content hash, and each point's hash, without running anything (plan_experiment).check TARGET [--json] [--write-reference PATH]: compare the runs with the experiment's pinned reference within its pinned tolerances (check_experiment); with--write-reference, store the current results as the reference filePATHand print thereferenceclause that pins it.export TARGET --to DIR: write a Workflow Run RO-Crate with a W3C PROV account of each run (write_crate).list FILE: list the experiments a module declares with their entries and methods.
qvr weave DOCUMENTS...¶
Write the results of the experiments named by the {experiment} directives of each
literate module, with their hashes
(weave_document), running an experiment only when its
records are not stored. --check writes nothing: it refuses a stale or unwoven result, a directive
naming no experiment, and a prose reference naming no declaration, each as
FILE:LINE:COLUMN: error[CODE]: ... (check_document).
--rerun computes every run. The command exits with 0 when every document is woven or checks,
and 1 otherwise.
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 over the
Language Server Protocol. The server accepts later target changes through
workspace/didChangeConfiguration, with either
{"qvr": {"transpileTarget": "TARGET"}} or
{"transpileTarget": "TARGET"}, and an empty target turns these diagnostics off
(Interactive tools).
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 flag selects the destination of a run for one target, and
--out-dir that of a run for several.
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: checking of each file, 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 MODULES...: load, resolve, and compile every supplied.qvrfile or dotted module path with the modules it imports, emitting structured diagnostics. Exits 0 on full success, non-zero when any module 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 MODULE[:ENTRY] [ENTRY] [ARGS...]: execute one checked QIEC computation or program of a file or a module path (qvr run pkg.experiments.boolean:fit) with JSON value arguments and an explicit runtime configuration.qvr doc MODULES...: render each module's public interface.qvr test PATHS...: run thetest,propertyandexampledeclarations of.qvrmodules and packages;--mutatereports the mutants of a module's code that its tests do not reject.qvr hash FILES...: print the content hash of every checked declaration, each statement's source hash, and the file's digests;--check-migrationschecks that every syntactic migration hop preserves every core hash.qvr cache {info,list,clear,prune,limit}: inspect and manage the project's persistent cache of checked modules, fits, and runs.
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:
|
Completion
didactic-model
¶
Bases: Model
One immutable completion candidate.
| PARAMETER | DESCRIPTION |
|---|---|
text
|
Insertion text.
TYPE:
|
kind
|
Candidate category, such as an environment name or command.
TYPE:
|
detail
|
Short description shown with the candidate.
TYPE:
|
Span
didactic-model
¶
Span(*, start: int, end: int, token: str, text: str, line: int = 0, col: int = 0, end_line: int = 0, end_col: int = 0)
Bases: Model
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:
|
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
583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 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 | |
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
747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 | |
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
1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 | |
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
1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 | |
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.
check_file
¶
check_file(path: Path | str, *, target: str | None = None, roots: tuple[Path, ...] | None = None) -> list[CheckDiagnostic]
Parse, resolve, constraint-check, and compile one module and its imports.
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:
|
roots
|
The directories module paths are relative to; for a file, its own directory when omitted, and for a module path the working directory.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[CheckDiagnostic]
|
Every diagnostic the file produces, empty when it checks cleanly. |
Source code in src/quivers/cli/check.py
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 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 | |
hole_notes
¶
hole_notes(qiec_module: QiecModule, module: Module, file: str) -> list[CheckDiagnostic]
Report every typed hole of a checked module as a goal.
A module with holes checks; what its author needs back is each hole's goal type and the bindings in scope there, which these notes carry.
| PARAMETER | DESCRIPTION |
|---|---|
qiec_module
|
The checked module.
TYPE:
|
module
|
The parsed source, which locates type holes.
TYPE:
|
file
|
The checked file, named in each note.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[CheckDiagnostic]
|
One |
Source code in src/quivers/cli/check.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, observation-option, 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) -> Text
Build a rich.text.Text from the highlighted source.
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. |
| RAISES | DESCRIPTION |
|---|---|
ModuleNotFoundError
|
If the optional Rich dependency is absent. |
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
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 | |
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
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
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
build_parser
¶
The qvr command line's parser, every subcommand included.
| RETURNS | DESCRIPTION |
|---|---|
ArgumentParser
|
The parser; its subcommand is |
Source code in src/quivers/cli/__init__.py
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 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 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 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 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 | |
main
¶
Run the qvr command line.
| PARAMETER | DESCRIPTION |
|---|---|
argv
|
The arguments after the program name;
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
int
|
The process exit status of the selected subcommand. |
Source code in src/quivers/cli/__init__.py
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.
During development the newest released revision migrates to "HEAD"
through one release hop package (v<released>_to_v<next>), whose
feature modules each contribute span-edit collectors; see
quivers.cli.migrations._features. That edge is open: the working
grammar may or may not differ from the released one yet.
To prepare a release:
- Freeze the working grammar as an immutable parser snapshot under
grammars/qvr/vcs/parsers/v<next>and pin its asset hashes and panproto schema commit inquivers._grammar_manifest. - Set the release hop's
TARGET_REVISIONto"v<next>". - Insert
"v<next>"immediately before"HEAD"inCHAINand register the explicit identity migrator for("v<next>", "HEAD").
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', 'v0.62.0', 'v0.64.2', 'v0.65.0', 'v0.66.0', 'v0.67.0', 'v0.68.0', 'v0.69.0', 'v0.70.0', _hop_weighted_total.SOURCE_REVISION, _hop_score_heads.SOURCE_REVISION, _hop_law_values.SOURCE_REVISION, _hop_model_binds.SOURCE_REVISION, _hop_site_groups.SOURCE_REVISION, _hop_site_groups.TARGET_REVISION, _hop_release.TARGET_REVISION, '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', resolve_commit=commit_id), ('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', resolve_commit=commit_id), ('v0.16.0', 'v0.17.0'): _identity.migrator('v0.16.0', 'v0.17.0', resolve_commit=commit_id), ('v0.17.0', 'v0.18.0'): _identity.migrator('v0.17.0', 'v0.18.0', resolve_commit=commit_id), ('v0.18.0', 'v0.19.0'): _hop_18_19.migrate, ('v0.19.0', 'v0.62.0'): _hop_19_62.migrate, ('v0.62.0', 'v0.64.2'): _hop_62_64.migrate, ('v0.64.2', 'v0.65.0'): _hop_64_65.migrate, ('v0.65.0', 'v0.66.0'): _identity.migrator('v0.65.0', 'v0.66.0', resolve_commit=commit_id), ('v0.66.0', 'v0.67.0'): _identity.migrator('v0.66.0', 'v0.67.0', resolve_commit=commit_id), ('v0.67.0', 'v0.68.0'): _hop_67_68.migrate, ('v0.68.0', 'v0.69.0'): _identity.migrator('v0.68.0', 'v0.69.0', resolve_commit=commit_id), ('v0.69.0', 'v0.70.0'): _identity.migrator('v0.69.0', 'v0.70.0', resolve_commit=commit_id), ('v0.70.0', _hop_weighted_total.SOURCE_REVISION): _hop_weighted_total.from_release, (_hop_weighted_total.SOURCE_REVISION, _hop_score_heads.SOURCE_REVISION): _hop_weighted_total.migrate, (_hop_score_heads.SOURCE_REVISION, _hop_law_values.SOURCE_REVISION): _hop_score_heads.migrate, (_hop_law_values.SOURCE_REVISION, _hop_law_values.TARGET_REVISION): _hop_law_values.migrate, (_hop_model_binds.SOURCE_REVISION, _hop_site_groups.SOURCE_REVISION): _hop_model_binds.migrate, (_hop_site_groups.SOURCE_REVISION, _hop_site_groups.TARGET_REVISION): _hop_site_groups.migrate, (_hop_release.SOURCE_REVISION, _hop_release.TARGET_REVISION): _hop_release.migrate, (_hop_release.TARGET_REVISION, 'HEAD'): _identity.migrator(_hop_release.TARGET_REVISION, 'HEAD', resolve_commit=commit_id)}
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', 'v0.62.0'): _hop_19_62.SOURCE_RULE_COVERAGE, ('v0.62.0', 'v0.64.2'): _hop_62_64.SOURCE_RULE_COVERAGE, ('v0.64.2', 'v0.65.0'): _hop_64_65.SOURCE_RULE_COVERAGE, ('v0.65.0', 'v0.66.0'): _identity.SOURCE_RULE_COVERAGE, ('v0.66.0', 'v0.67.0'): _identity.SOURCE_RULE_COVERAGE, ('v0.67.0', 'v0.68.0'): _hop_67_68.SOURCE_RULE_COVERAGE, ('v0.68.0', 'v0.69.0'): _identity.SOURCE_RULE_COVERAGE, ('v0.69.0', 'v0.70.0'): _identity.SOURCE_RULE_COVERAGE, ('v0.70.0', _hop_weighted_total.SOURCE_REVISION): frozenset(), (_hop_weighted_total.SOURCE_REVISION, _hop_score_heads.SOURCE_REVISION): _hop_weighted_total.SOURCE_RULE_COVERAGE, (_hop_score_heads.SOURCE_REVISION, _hop_law_values.SOURCE_REVISION): _hop_score_heads.SOURCE_RULE_COVERAGE, (_hop_law_values.SOURCE_REVISION, _hop_law_values.TARGET_REVISION): _hop_law_values.SOURCE_RULE_COVERAGE, (_hop_model_binds.SOURCE_REVISION, _hop_site_groups.SOURCE_REVISION): _hop_model_binds.SOURCE_RULE_COVERAGE, (_hop_site_groups.SOURCE_REVISION, _hop_site_groups.TARGET_REVISION): _hop_site_groups.SOURCE_RULE_COVERAGE, (_hop_release.SOURCE_REVISION, _hop_release.TARGET_REVISION): _hop_release.SOURCE_RULE_COVERAGE, (_hop_release.TARGET_REVISION, 'HEAD'): _identity.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.
SEMANTIC_HOPS
module-attribute
¶
SEMANTIC_HOPS: dict[tuple[str, str], str] = {(_hop_release.SOURCE_REVISION, _hop_release.TARGET_REVISION): _RELEASE_SEMANTICS} if _RELEASE_SEMANTICS else {}
The adjacent pairs of CHAIN whose hop may change the checked meaning of
the source, with the reason. A hop absent from this table must preserve the
content hash of every declaration it rewrites.
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
didactic-model
¶
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)
Bases: Model
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
didactic-model
¶
DiffCoverageReport(*, from_ref: str, to_ref: str, added_rules: tuple[str, ...], removed_rules: tuple[str, ...], uncovered_removed: tuple[str, ...])
Bases: Model
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
The frozen 0.72.0 to 0.73.0 release hop is a package of feature modules.
It loads them in name order into FEATURES and applies them over one parse
of each file. The following hop from v0.73.0 to HEAD is an identity
until development opens a new release hop
(changing the QVR language).
v0_72_0_to_v0_73_0
¶
Migrate v0.72.0 source to the v0.73.0 grammar through every feature's rewrites.
The modules of this package each describe one language feature as a
quivers.cli.migrations._features.Feature: the span-edit collectors that
rewrite the feature's v0.72.0 surface, the v0.72.0 rules they translate, the
released forms that keep their spelling and meaning, the exact rewrites and
refusals the feature promises, and the keywords it adds. The hop loads every
module that defines FEATURE, in module-name order, and runs all of their
collectors over one v0.72.0 parse of each file. Edits from different features
never overlap; an overlap is refused rather than ordered.
A file is migrated in four steps. It must parse at v0.72.0 without recovery vertices. Every feature's collectors then return byte span edits, or refuse a construct with its line, column, and replacement. The edits are checked pairwise and applied. The result must parse at the target revision without recovery vertices and must not end a line in whitespace that the source did not. Source that uses none of the rewritten constructs is returned byte for byte.
SOURCE_REVISION
module-attribute
¶
The released grammar revision the hop migrates from.
TARGET_REVISION
module-attribute
¶
The released grammar revision the hop migrates to.
FEATURES
module-attribute
¶
Every feature of the hop, in composition order.
SOURCE_RULE_COVERAGE
module-attribute
¶
SOURCE_RULE_COVERAGE: frozenset[str] = frozenset().union(*(feature.source_rule_coverage for feature in FEATURES))
The v0.72.0 rules translated by some feature's collectors.
SEMANTIC_REASONS
module-attribute
¶
SEMANTIC_REASONS: dict[str, str] = {feature.name: feature.semantic for feature in FEATURES if feature.semantic}
Each feature whose rewrites change checked meaning, with the reason.
migrate
¶
Migrate one v0.72.0 file through every feature's rewrites.
| PARAMETER | DESCRIPTION |
|---|---|
source
|
A complete file in the v0.72.0 surface.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bytes
|
The complete file in the target surface. |
| RAISES | DESCRIPTION |
|---|---|
MigrationError
|
If the source is not v0.72.0 surface, a feature refuses one of its constructs, two features' edits overlap, or the output does not parse at the target revision. |
Source code in src/quivers/cli/migrations/v0_72_0_to_v0_73_0/__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.
HoleFill
didactic-model
¶
Bases: Model
One way to fill a hole.
| PARAMETER | DESCRIPTION |
|---|---|
title
|
What the editor shows,
TYPE:
|
text
|
The text that replaces the hole's span.
TYPE:
|
HoleSpan
didactic-model
¶
Bases: Model
Where a hole is written, in 0-based lines and character columns.
| PARAMETER | DESCRIPTION |
|---|---|
line
|
The line of its first character.
TYPE:
|
start
|
The column of its first character.
TYPE:
|
end
|
The column just past its last character, on the same line.
TYPE:
|
declaration
|
Whether the hole is a declaration hole
TYPE:
|
NotationTarget
didactic-model
¶
Bases: Model
Where a production is declared.
| PARAMETER | DESCRIPTION |
|---|---|
file
|
Its file, or empty for the document itself.
TYPE:
|
line
|
Its 0-based line in that file.
TYPE:
|
col
|
Its 0-based column.
TYPE:
|
length
|
The length of the production's name.
TYPE:
|
SpanLocation
didactic-model
¶
Bases: Model
A name's span in one file.
| ATTRIBUTE | DESCRIPTION |
|---|---|
file |
The absolute file path.
TYPE:
|
start, end |
The byte span.
TYPE:
|
Workspace
¶
The module roots and open buffers of one editor session.
| PARAMETER | DESCRIPTION |
|---|---|
roots
|
The directories module paths are relative to.
TYPE:
|
Source code in src/quivers/lsp/workspace.py
set_roots
¶
Replace the module roots.
| PARAMETER | DESCRIPTION |
|---|---|
roots
|
The new roots.
TYPE:
|
open
¶
Lay an open buffer over its file.
| PARAMETER | DESCRIPTION |
|---|---|
file
|
The buffer's file.
TYPE:
|
text
|
Its current text.
TYPE:
|
close
¶
Stop laying a closed buffer over its file.
| PARAMETER | DESCRIPTION |
|---|---|
file
|
The buffer's file.
TYPE:
|
text_of
¶
The current text of a file: its open buffer, or what is on disk.
| PARAMETER | DESCRIPTION |
|---|---|
file
|
The file.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
Its text. |
| RAISES | DESCRIPTION |
|---|---|
OSError
|
If the file is not open and cannot be read. |
Source code in src/quivers/lsp/workspace.py
roots_for
¶
The roots a file's module path is relative to.
| PARAMETER | DESCRIPTION |
|---|---|
file
|
A module file.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[Path, ...]
|
The workspace roots when one contains the file; otherwise the file's own directory. |
Source code in src/quivers/lsp/workspace.py
graph_for
¶
graph_for(file: Path) -> ModuleGraph
Load and check the module graph rooted at a file.
| PARAMETER | DESCRIPTION |
|---|---|
file
|
The root module's file.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ModuleGraph
|
The checked graph, open buffers laid over disk. |
| RAISES | DESCRIPTION |
|---|---|
ModuleError
|
If the graph does not load or resolve. |
ParseError
|
If a module does not parse. |
Source code in src/quivers/lsp/workspace.py
module_files
¶
Every module file below the roots, open buffers included.
| RETURNS | DESCRIPTION |
|---|---|
tuple[Path, ...]
|
The files, sorted. |
Source code in src/quivers/lsp/workspace.py
file_resolutions
staticmethod
¶
file_resolutions(graph: ModuleGraph) -> tuple[Resolution, ...]
Every resolution of the root file, its module bodies included.
A module, signature, or functor declared in the file, and a
computation with module parameters, resolve their names in scopes
of their own (quivers.dsl.modules.elaborate); their resolutions
join the file's own. A body whose names do not resolve contributes
nothing.
| PARAMETER | DESCRIPTION |
|---|---|
graph
|
A graph rooted at the file.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[Resolution, ...]
|
The resolutions, the file's first. |
Source code in src/quivers/lsp/workspace.py
resolution_at
classmethod
¶
resolution_at(graph: ModuleGraph, offset: int) -> Resolution | None
The resolution of the root file whose name spans a byte offset.
| PARAMETER | DESCRIPTION |
|---|---|
graph
|
A graph rooted at the file.
TYPE:
|
offset
|
A byte offset in the root file.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Resolution | None
|
The resolution whose own-name segment covers the offset, in the file or in a module body declared in it. |
Source code in src/quivers/lsp/workspace.py
declaration_of
staticmethod
¶
declaration_of(graph: ModuleGraph, symbol: Symbol) -> SpanLocation | None
Where a module-level name is declared.
| PARAMETER | DESCRIPTION |
|---|---|
graph
|
A graph containing the declaring module.
TYPE:
|
symbol
|
The name.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
SpanLocation | None
|
The first declaring token, or |
Source code in src/quivers/lsp/workspace.py
definition
¶
definition(file: Path, offset: int) -> SpanLocation | None
Where the module-level name at a position is declared.
| PARAMETER | DESCRIPTION |
|---|---|
file
|
The file.
TYPE:
|
offset
|
A byte offset in it.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
SpanLocation | None
|
The declaration, or |
| RAISES | DESCRIPTION |
|---|---|
ModuleError
|
If the file's graph does not load or resolve. |
ParseError
|
If a module does not parse. |
Source code in src/quivers/lsp/workspace.py
symbol_at
¶
symbol_at(file: Path, offset: int) -> Symbol | None
The module-level name at a position.
| PARAMETER | DESCRIPTION |
|---|---|
file
|
The file.
TYPE:
|
offset
|
A byte offset in it.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Symbol | None
|
The name, or |
| RAISES | DESCRIPTION |
|---|---|
ModuleError
|
If the file's graph does not load or resolve. |
ParseError
|
If a module does not parse. |
Source code in src/quivers/lsp/workspace.py
references
¶
references(symbol: Symbol) -> tuple[SpanLocation, ...]
Every place in the workspace that spells a module-level name.
Each module file is checked as a root; a file whose graph does not load contributes nothing, since none of its names resolve.
| PARAMETER | DESCRIPTION |
|---|---|
symbol
|
The name, identified by its declaring module.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[SpanLocation, ...]
|
The spans of its own-name segment in declarations, references, exports, and import lists, sorted by file and offset. |
Source code in src/quivers/lsp/workspace.py
fill_candidates
¶
fill_candidates(goal: HoleGoal, module: QiecModule) -> tuple[HoleFill, ...]
The fills of a hole from what is in scope at it.
| PARAMETER | DESCRIPTION |
|---|---|
goal
|
The goal.
TYPE:
|
module
|
The checked module, whose families give the constructors.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[HoleFill, ...]
|
The bindings of the goal's type, innermost first; then the goal family's constructors in declaration order; then literals of a builtin goal type. |
Source code in src/quivers/lsp/holes.py
fill_edit
¶
The text edit a fill makes.
| PARAMETER | DESCRIPTION |
|---|---|
source
|
The document.
TYPE:
|
span
|
The hole's span.
TYPE:
|
fill
|
The fill.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[HoleSpan, str]
|
The span to replace and its replacement. A value hole is replaced by
the fill; a declaration hole |
Source code in src/quivers/lsp/holes.py
goal_at
¶
goal_at(module: QiecModule, source: str, line: int, column: int) -> HoleGoal | None
The goal of the hole under a position.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
The checked module.
TYPE:
|
source
|
The document.
TYPE:
|
line
|
The 0-based line.
TYPE:
|
column
|
The 0-based character column.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
HoleGoal or None
|
The goal whose hole covers the position, if any. |
Source code in src/quivers/lsp/holes.py
goals_of
¶
goals_of(module: QiecModule) -> tuple[HoleGoal, ...]
The goals of a checked module's value holes, computed once per module.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
The checked module.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[HoleGoal, ...]
|
One goal per hole occurrence. |
Source code in src/quivers/lsp/holes.py
hole_diagnostics
¶
hole_diagnostics(module: QiecModule) -> list[Diagnostic]
Publish each hole's goal as an information diagnostic.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
The checked module.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[Diagnostic]
|
One |
Source code in src/quivers/lsp/holes.py
hole_span
¶
Find where a goal's hole is written in its document.
| PARAMETER | DESCRIPTION |
|---|---|
source
|
The document the module was checked from.
TYPE:
|
goal
|
The goal.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
HoleSpan or None
|
The span of the hole ( |
Source code in src/quivers/lsp/holes.py
render_goal
¶
render_goal(goal: HoleGoal) -> str
Render a goal for a hover pane.
| PARAMETER | DESCRIPTION |
|---|---|
goal
|
The goal.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
Markdown: the hole and its type, then each binding in scope. |
Source code in src/quivers/lsp/holes.py
notation_definition
¶
notation_definition(module: Module, source: str, line: int, col: int, *, file: str, source_map: SourceMap | None = None) -> NotationTarget | None
The production that read the token of a quotation at a position.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
The document's program.
TYPE:
|
source
|
The document's text.
TYPE:
|
line
|
The 0-based line.
TYPE:
|
col
|
The 0-based character column.
TYPE:
|
file
|
The document.
TYPE:
|
source_map
|
Maps a line of the flat program to its file, when the program is a module graph.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
NotationTarget | None
|
The production's name in its declaration, or |
Source code in src/quivers/lsp/notation.py
notation_hover
¶
notation_hover(module: Module, source: str, line: int, col: int, *, file: str) -> str | None
The hover text of a quotation: the term it elaborates to.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
The document's program.
TYPE:
|
source
|
The document's text.
TYPE:
|
line
|
The 0-based line.
TYPE:
|
col
|
The 0-based character column.
TYPE:
|
file
|
The document, for diagnostics.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str | None
|
Markdown naming the sort, the elaborated constructor tree, and the
printed form; the refusal when the quotation does not elaborate;
|
Source code in src/quivers/lsp/notation.py
quotation_at
¶
quotation_at(module: Module, source: str, line: int, col: int) -> tuple[Quotation, int] | None
The quotation of a document's own module at a position.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
The program (the document's own statements come first).
TYPE:
|
source
|
The document's text.
TYPE:
|
line
|
The 0-based line.
TYPE:
|
col
|
The 0-based character column.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[Quotation, int] | None
|
The innermost quotation covering the position and the position's
byte offset, or |
Source code in src/quivers/lsp/notation.py
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
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 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 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 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 | |
byte_offset
¶
The byte offset of a line and character column.
| PARAMETER | DESCRIPTION |
|---|---|
text
|
The file's text.
TYPE:
|
line
|
A 0-based line.
TYPE:
|
column
|
A 0-based character column.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
int
|
The UTF-8 byte offset. |
Source code in src/quivers/lsp/workspace.py
file_of_uri
¶
The file a file:// document URI names.
| PARAMETER | DESCRIPTION |
|---|---|
uri
|
A document URI.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Path | None
|
The file, or |
Source code in src/quivers/lsp/workspace.py
line_column
¶
The 0-based line and character column of a byte offset.
| PARAMETER | DESCRIPTION |
|---|---|
text
|
The file's text.
TYPE:
|
offset
|
A UTF-8 byte offset.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[int, int]
|
The line and the character column. |
Source code in src/quivers/lsp/workspace.py
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
do_execute
¶
do_execute(code: str, silent: bool, store_history: bool = True, user_expressions: dict[str, Any] | None = None, allow_stdin: bool = False, *, cell_id: str | None = None) -> dict[str, Any]
Dispatch each chunk of a cell to the session.
A :quit chunk ends the cell: the chunks after it are not
dispatched, and the kernel stays up, since a kernel is shut down
by its front end. Unless silent, a note on standard error
says so.
| PARAMETER | DESCRIPTION |
|---|---|
code
|
The cell.
TYPE:
|
silent
|
Whether to suppress the cell's output streams.
TYPE:
|
store_history
|
Unused; part of the ipykernel signature.
TYPE:
|
user_expressions
|
Unused; part of the ipykernel signature.
TYPE:
|
allow_stdin
|
Unused; part of the ipykernel signature.
TYPE:
|
cell_id
|
Unused; part of the ipykernel signature.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
The execute reply: |
Source code in src/quivers/kernel/quivers_kernel.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 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 | |
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 |
Source code in src/quivers/kernel/install.py
__getattr__
¶
__getattr__(name: str) -> type[QuiversKernel]
Resolve the kernel class when its optional runtime is requested.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The requested public name.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
type[QuiversKernel]
|
The Jupyter kernel implementation. |
| RAISES | DESCRIPTION |
|---|---|
AttributeError
|
If the name is not the kernel class. |
ModuleNotFoundError
|
If the Jupyter kernel dependencies are absent. |