Migration hash gate¶
The check that every syntactic migration hop preserves every core hash, run by
qvr hash --check-migrations and in CI over the whole corpus.
migration_gate
¶
The gate that every syntactic migration hop preserves every core hash.
A migration hop rewrites source from one grammar revision to the next. A
syntactic hop must not change what the source means, and the core hash of
a checked declaration (module_hashes)
is exactly what it means, with names, comments, and layout factored out. So a
syntactic hop must leave the multiset of core hashes of every file it rewrites
unchanged. A hop that may change meaning declares so in
SEMANTIC_HOPS, and a feature of the
release hop in its semantic field.
Only the current grammar's compiler can check source, so the gate checks each
hop on the corpus files that are also valid source at the hop's revision: it
migrates such a file from that revision to HEAD and requires the result to
have the core hashes of the file itself. A hop that rewrites a construct it
should have left alone, renames inconsistently, or changes a constant fails,
even when every parse gate passes. Each feature of the release hop is checked
alone as well, so a failure names the feature responsible.
CORPUS_ROOTS
module-attribute
¶
CORPUS_ROOTS: tuple[str, ...] = ('docs/examples/source', 'docs/examples/qiec', 'docs/tutorials/qvr/source', 'tests/benchmarks/models', 'tests/transpile/fixtures', 'regression.qvr')
The .qvr corpus the gate runs over, relative to the repository root.
HopStatus
¶
What the gate found for one hop and one file:
preserved: the hop rewrote the file and every core hash survived;identical: the hop left the bytes unchanged;changed: the hop rewrote the file and some core hash changed, which fails the gate;rejected: the file is not valid source at the hop's revision, or the migrated text does not check atHEAD, so the hop is not tested on it;semantic: the hop declares that it may change meaning.
GateHop
didactic-model
¶
GateHop(*, source: str, target: str, feature: str = '', migrate: Callable[[bytes], bytes] = field(opaque=True, extras=OPAQUE_BY_IDENTITY), semantic: str = '')
Bases: ValueModel
One migration step the gate checks.
| PARAMETER | DESCRIPTION |
|---|---|
source
|
The revision the step starts at.
TYPE:
|
target
|
The revision the hop under test ends at.
TYPE:
|
feature
|
The release-hop feature applied alone, or empty for a whole hop.
TYPE:
|
migrate
|
The rewrite from the hop's source revision all the way to
TYPE:
|
semantic
|
Why the step may change meaning, or empty for a syntactic step.
TYPE:
|
label
property
¶
The step's name in reports.
| RETURNS | DESCRIPTION |
|---|---|
str
|
|
HopOutcome
didactic-model
¶
HopOutcome(*, hop: str, file: str, status: HopStatus, detail: str = '')
Bases: Model
The gate's finding for one step and one file.
| PARAMETER | DESCRIPTION |
|---|---|
hop
|
The step's label.
TYPE:
|
file
|
The file.
TYPE:
|
status
|
What was found.
TYPE:
|
detail
|
The reason for a rejection, the semantic declaration, or the core hashes that appeared and disappeared.
TYPE:
|
InvarianceReport
didactic-model
¶
InvarianceReport(*, files: tuple[str, ...] = (), unchecked: tuple[str, ...] = (), outcomes: tuple[HopOutcome, ...] = ())
Bases: Model
Everything the gate found.
| PARAMETER | DESCRIPTION |
|---|---|
files
|
The corpus files that check at
TYPE:
|
unchecked
|
The corpus files that do not check at
TYPE:
|
outcomes
|
One outcome per step and usable file.
TYPE:
|
failures
property
¶
failures: tuple[HopOutcome, ...]
The outcomes that fail the gate.
| RETURNS | DESCRIPTION |
|---|---|
tuple[HopOutcome, ...]
|
Every |
ok
property
¶
Whether every syntactic step preserved every core hash.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True when no outcome is |
summary_lines
¶
A human-readable report.
| RETURNS | DESCRIPTION |
|---|---|
tuple[str, ...]
|
One line per step with its counts, then one per failure. |
Source code in src/quivers/incremental/migration_gate.py
corpus_files
¶
Every .qvr file under some roots.
| PARAMETER | DESCRIPTION |
|---|---|
roots
|
Files and directories.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[Path, ...]
|
The files, each directory's sorted. |
Source code in src/quivers/incremental/migration_gate.py
default_hops
¶
default_hops(*, chain: Sequence[str] = CHAIN, migrators: Mapping[tuple[str, str], Callable[[bytes], bytes]] = MIGRATORS, semantic: Mapping[tuple[str, str], str] = SEMANTIC_HOPS) -> tuple[GateHop, ...]
The steps the gate checks for a migration chain.
| PARAMETER | DESCRIPTION |
|---|---|
chain
|
The revisions, oldest first,
TYPE:
|
migrators
|
The hop of each adjacent pair.
TYPE:
|
semantic
|
The hops that declare they may change meaning.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[GateHop, ...]
|
One step per hop, migrating from the hop's source revision to
|
Source code in src/quivers/incremental/migration_gate.py
check_migration_invariance
¶
check_migration_invariance(files: Sequence[Path], *, hops: Sequence[GateHop] | None = None) -> InvarianceReport
Run the gate over corpus files.
| PARAMETER | DESCRIPTION |
|---|---|
files
|
The corpus files, written in the
TYPE:
|
hops
|
The steps to check;
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
InvarianceReport
|
Every outcome; |