Skip to content

Commit 48f50af

Browse files
committed
feat(shadow-infra): the engine protocol — each engine reports its layers, and declares what it could produce (#260/#269 cp2)
P-022 step 7a, checkpoint 2. Still INFRASTRUCTURE for shadow mode, still no parity claim, and — this checkpoint's sharpest line — still not a comparison: an artifact now carries two engines' captures side by side and nothing reads one against the other. Comparing them is #260's acceptance, blocked by #259. What landed: * own_shadow::capture — the port's half of the protocol, driving own-bridge's three layer surfaces (lower, dump_summaries, check_facts) into the shared envelope. The reference's half is ownlang/repro.py::project_layers, and the two stay independent readings of one frozen format. * `projection` on the layer envelope (format version 2): each layer declares what its engine could PRODUCE — {"kind":"full"} or {"kind":"partial", "members":[...], "reason":"..."}. * An engine writes only its own entry. The reference authors python-ownlang and carries foreign entries through untouched; the port authors rust-own-bridge under OWN_SHADOW_WRITE=1. Each half is produced with zero of the other's runtime, and neither can quietly become a comparison of one implementation against itself. * own-shadow gains own-ir/own-lowered/own-bridge in the allowed DAG edge set — a deliberate, reviewed edit. The constraint running the other way did not move: no core crate, nor own-bridge, may depend on the harness. Why a projection: the port is mid-migration. Two of its layers emit the whole frozen surface; check_facts is at the #259 cp4 projection, missing message, related and flow. Without the field it could only emit a short document a comparison would score as agreement, or refuse a layer it can mostly produce. A test holds the claim to the records, so the field cannot be prose. Measured (generated: docs/generated/p022-shadow-census.md): 9 artifacts carrying both engines; 4 layer envelopes where the statuses differ, every one a boundary the port DECLARES (the OBL protocol analysis; the typed door, which is upstream of every layer and so refuses all three). Campaign (docs/notes/p022-shadow-infra-checkpoint2-data/): round 1 was 8 caught, 1 compile error, 2 survivors. M39 found genuinely untested code — no committed artifact had a document the typed door refuses — fixed by promoting verdict_door_effect_deps_not_strings to an artifact. M41 found a control that stopped at a missing reason and never tried an empty one. M37 did not compile and is recorded as a compile error, never as "caught". Round 2: 11/11 caught, 0 survivors, control clean. The --check gate earned its keep: reshaping the layer envelope broke two of checkpoint 1's mutation anchors (M11, M15), and the gate caught it before the recorded result could go on describing a tree that no longer exists. They were re-anchored and cp1 re-run: 30/30, unchanged. The census is now one live view of the slice rather than a per-checkpoint snapshot that would be stale by design; each checkpoint's recorded campaign stays frozen at what it measured. Gates: cargo fmt --check, cargo clippy --workspace --all-targets (zero warnings), cargo test --workspace --no-fail-fast, ruff check ., mypy, python tests/run_tests.py. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Kh6wpfbBUNLbeCJZ263gYM
1 parent fc30319 commit 48f50af

32 files changed

Lines changed: 3520 additions & 317 deletions
Lines changed: 101 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,18 @@
33
Checked by: tests/test_generated_docs.py (a stale copy is a red build).
44
Every figure below is read out of committed evidence; none is typed. -->
55

6-
# P-022 step 7a — shadow-mode infrastructure, checkpoint 1: census
6+
# P-022 step 7a — shadow-mode infrastructure: census
77

88
**Infrastructure for shadow mode, not shadow mode.** Nothing measured here
9-
compares two engines' end diagnostics; that comparison is #260's acceptance
10-
and is blocked on #259 (cp5 and 4b). Nothing here is a parity claim either.
9+
compares two engines' end diagnostics — or any of their layer *contents*. That
10+
comparison is #260's acceptance and is blocked on #259 (cp5 and 4b). Nothing
11+
here is a parity claim either.
1112

12-
## The measured set
13+
This document is the **live view** of the slice as it stands; each checkpoint's
14+
recorded mutation campaign stays frozen at what it measured, under
15+
`docs/notes/p022-shadow-infra-checkpoint*-data/`.
16+
17+
## The measured set — same-input capture (checkpoint 1)
1318

1419
| corpus | documents |
1520
|---|---|
@@ -30,40 +35,73 @@ checked fact rather than an assumption.
3035
| documents captured and digest-pinned | 80 |
3136
| tamper controls (one changed character per document, refusal required) | 80 |
3237
| documents both engines must REFUSE to name (`domain_refusals`) | 6 |
33-
| reproduction artifacts committed and replayed byte-for-byte | 8 |
34-
| layer envelopes carried by those artifacts — produced | 21 |
35-
| layer envelopes carried by those artifacts — refused | 3 |
36-
| structural negative controls on `verify` (each side) | 12 |
38+
| reproduction artifacts committed and replayed byte-for-byte | 9 |
39+
| structural negative controls on `verify` (each side) | 18 |
3740
| value-level domain backstop controls | 5 |
3841

39-
## Divergence classification over the measured set
42+
## The engine protocol (checkpoint 2)
43+
44+
Each engine authors only its own `engines[]` entry, and declares per layer what
45+
it could **produce**. Over the committed artifacts:
46+
47+
| engine | layers produced | layers refused | projection `full` | projection `partial` |
48+
|---|---|---|---|---|
49+
| `python-ownlang` | 24 | 3 | 27 | 0 |
50+
| `rust-own-bridge` | 20 | 7 | 19 | 8 |
51+
52+
The port's `partial` layers are its verdict surface: `own_bridge::check_facts`
53+
is at the #259 checkpoint-4 projection, which carries every `Finding` member
54+
except `message`, `related` and `flow`. It says so in the artifact rather than
55+
emitting a short document a later comparison would score as agreement, and a
56+
test asserts the claim matches the records byte for byte.
57+
58+
**Layer envelopes where the two engines' status differs** — structural
59+
accounting, not a content comparison, and every one of them a boundary the port
60+
declares rather than a disagreement it stumbled into:
4061

41-
**Python-only 0 / Rust-only 0 / Changed 0 / Ordering-only n/a / Unexplained 0.**
62+
| case | layer | statuses |
63+
|---|---|---|
64+
| `protocol_isloaded_violation` | `verdicts` | python-ownlang: produced, rust-own-bridge: refused |
65+
| `verdict_door_effect_deps_not_strings` | `lowered` | python-ownlang: produced, rust-own-bridge: refused |
66+
| `verdict_door_effect_deps_not_strings` | `summaries` | python-ownlang: produced, rust-own-bridge: refused |
67+
| `verdict_door_effect_deps_not_strings` | `verdicts` | python-ownlang: produced, rust-own-bridge: refused |
68+
69+
## Divergence classification
70+
71+
**Python-only 0 / Rust-only 0 / Changed 0 / Ordering-only n/a / Unexplained 0**,
72+
over the 80-document same-input set — the only cross-engine
73+
quantity this slice measures.
4274

43-
These are enforced by a gate, not counted by this generator: the port asserts
75+
It is enforced by a gate, not counted by this generator: the port asserts
4476
per-document equality of the canonical identity and byte-exact equality of
4577
every committed artifact, so a non-zero counter is not representable as a
46-
passing build. *Ordering-only* is **not applicable** at this layer and is
47-
named rather than reported as a zero that would mean something else — the
48-
canonical form sorts by construction, so there is no ordered output being
49-
compared yet. The gates:
78+
passing build. *Ordering-only* is **not applicable** and is named rather than
79+
reported as a zero that would mean something else — the canonical form sorts by
80+
construction, so there is no ordered output being compared yet.
81+
82+
A classification over *layer contents* does not exist yet, and this document
83+
does not invent one: the two engines' captures sit side by side in the
84+
artifacts and nothing reads one against the other. The gates:
5085

5186
- `own-shadow/tests/repro.rs::a_changed_byte_in_the_embedded_document_is_refused`
5287
- `own-shadow/tests/repro.rs::every_committed_artifact_round_trips_and_verifies`
5388
- `own-shadow/tests/repro.rs::every_declared_unnameable_document_is_refused`
5489
- `own-shadow/tests/repro.rs::every_shared_document_hashes_to_the_recorded_digest`
5590
- `own-shadow/tests/repro.rs::the_canonical_form_ignores_only_insignificant_text_formatting`
5691
- `own-shadow/tests/repro.rs::values_outside_the_canonical_domain_are_refused_at_parse`
92+
- `own-shadow/tests/engine.rs::a_partial_projection_names_exactly_the_members_it_carries`
93+
- `own-shadow/tests/engine.rs::both_engines_report_the_same_layers_in_the_same_order`
94+
- `own-shadow/tests/engine.rs::this_engine_reproduces_its_committed_capture`
5795

5896
## The unmeasured set, named
5997

6098
- **End diagnostics compared as an acceptance surface** — #260's acceptance,
6199
blocked by #259 (cp5 and 4b). Not attempted, not approximated.
62-
- **The engine protocol** (how the port fills its own `engines[]` entry), the
63-
**`AnalysisTrace` schema** (#269) and **stable-ID normalization**, and
100+
- **Any comparison of the two engines' layer contents.** The artifacts pair
101+
them; nothing reads the pair. That is the reduction checkpoint's job.
102+
- **The `AnalysisTrace` schema** (#269) and **stable-ID normalization**, and
64103
**first-divergence reduction** over the lowered/MOS layers — the remaining
65-
step-7a checkpoints. The artifact format has the slots; one engine fills
66-
them today.
104+
step-7a checkpoints.
67105
- **Rendered-byte parity of the three layer surfaces.** The artifact carries
68106
layer outputs as JSON *values*, so a rendering difference (indent,
69107
`ensure_ascii`) is invisible here. That contract stays with each layer's own
@@ -79,12 +117,17 @@ compared yet. The gates:
79117
128-level cap differ; `spec/OwnIR.md` §4.2 bounds a conforming document
80118
well inside both, so no conforming document reaches the difference.
81119

82-
## Mutation campaign
120+
## Mutation campaigns
121+
122+
Definitions and recorded results live under
123+
`docs/notes/p022-shadow-infra-checkpoint*-data/`. Every layer runs for every
124+
mutation (P-022 discipline 3: no fail-fast), and every mutation edits a
125+
**production** surface (discipline 2). The runs are recorded, not reproduced in
126+
CI; what CI gates is that each definition still **anchors** to this tree and
127+
that each recorded result is internally consistent
128+
(`tests/test_generated_docs.py`).
83129

84-
Definition: `docs/notes/p022-shadow-infra-checkpoint1-data/mutations.json`.
85-
Recorded result: `.../campaign.json`. Both layers run for every mutation
86-
(P-022 discipline 3: no fail-fast), and every mutation edits a **production**
87-
surface (discipline 2).
130+
### checkpoint 1 — capture and artifact (`p022-shadow-cp1`)
88131

89132
| | |
90133
|---|---|
@@ -93,11 +136,8 @@ surface (discipline 2).
93136
| survived | **0** |
94137
| compile errors (reported as such, never as "caught") | 0 |
95138
| harness-honesty controls reporting zero failures | 1 |
96-
| catches attributed to the reference harness | 19 |
97-
| catches attributed to the port's suite | 30 |
98-
| mutations with exactly **one** catching layer | 15 |
99-
100-
A rule with a single catcher is a rule with a single control: M04, M05, M06, M07, M08, M09, M10, M11, M12, M14, M15, M21, M24, M25, M26.
139+
| catches by layer | `python` 19, `rust` 38 |
140+
| mutations with exactly **one** catching layer | 15 — M04, M05, M06, M07, M08, M09, M10, M11, M12, M14, M15, M21, M24, M25, M26 |
101141

102142
| id | mutation | caught by |
103143
|---|---|---|
@@ -116,9 +156,9 @@ A rule with a single catcher is a rule with a single control: M04, M05, M06, M07
116156
| M13 | the reference reorders the frozen layer vocabulary | `python::artifact-verify`, `python::capture-verify` |
117157
| M14 | the reference's verification stops checking the frozen engine order | `python::structural-control` |
118158
| M15 | the reference renders the artifact with a different indent | `python::artifact-golden` |
119-
| M16 | the port's canonical form stops sorting object keys | `rust::every_committed_artifact_round_trips_and_verifies`, `rust::every_shared_document_hashes_to_the_recorded_digest`, `rust::verify_refuses_each_structural_violation` |
120-
| M17 | the port escapes U+007F, which the reference emits raw | `rust::every_committed_artifact_round_trips_and_verifies`, `rust::every_shared_document_hashes_to_the_recorded_digest` |
121-
| M18 | the port escapes control code points with uppercase hex | `rust::every_committed_artifact_round_trips_and_verifies`, `rust::every_shared_document_hashes_to_the_recorded_digest` |
159+
| M16 | the port's canonical form stops sorting object keys | `rust::every_committed_artifact_round_trips_and_verifies`, `rust::every_shared_document_hashes_to_the_recorded_digest`, `rust::this_engine_reproduces_its_committed_capture`, `rust::verify_refuses_each_structural_violation` |
160+
| M17 | the port escapes U+007F, which the reference emits raw | `rust::every_committed_artifact_round_trips_and_verifies`, `rust::every_shared_document_hashes_to_the_recorded_digest`, `rust::this_engine_reproduces_its_committed_capture` |
161+
| M18 | the port escapes control code points with uppercase hex | `rust::every_committed_artifact_round_trips_and_verifies`, `rust::every_shared_document_hashes_to_the_recorded_digest`, `rust::this_engine_reproduces_its_committed_capture` |
122162
| M19 | the port renders the artifact with a different indent width | `rust::every_committed_artifact_round_trips_and_verifies`, `rust::the_canonical_form_ignores_only_insignificant_text_formatting` |
123163
| M20 | the port renders an artifact's objects in sorted rather than document order | `rust::every_committed_artifact_round_trips_and_verifies`, `rust::the_canonical_form_ignores_only_insignificant_text_formatting` |
124164
| M21 | the port resolves a duplicate key first-wins instead of last-wins | `rust::the_canonical_form_ignores_only_insignificant_text_formatting` |
@@ -127,7 +167,32 @@ A rule with a single catcher is a rule with a single control: M04, M05, M06, M07
127167
| M24 | the port's verification stops comparing the recomputed digest | `rust::a_changed_byte_in_the_embedded_document_is_refused` |
128168
| M25 | the port's verification stops checking the frozen layer order | `rust::verify_refuses_each_structural_violation` |
129169
| M26 | the port's verification stops checking the frozen engine order | `rust::verify_refuses_each_structural_violation` |
130-
| M27 | the port renders the digest with uppercase hex | `rust::every_committed_artifact_round_trips_and_verifies`, `rust::every_shared_document_hashes_to_the_recorded_digest`, `rust::verify_refuses_each_structural_violation` |
131-
| M28 | the port hashes the RENDERING form instead of the canonical form | `rust::every_committed_artifact_round_trips_and_verifies`, `rust::every_shared_document_hashes_to_the_recorded_digest`, `rust::the_canonical_form_ignores_only_insignificant_text_formatting`, `rust::verify_refuses_each_structural_violation` |
132-
| M29 | the port reorders the frozen layer vocabulary | `rust::every_committed_artifact_round_trips_and_verifies`, `rust::verify_refuses_each_structural_violation` |
133-
| M30 | the port's `has` stops distinguishing a present member from an absent one | `rust::every_committed_artifact_round_trips_and_verifies`, `rust::verify_refuses_each_structural_violation` |
170+
| M27 | the port renders the digest with uppercase hex | `rust::every_committed_artifact_round_trips_and_verifies`, `rust::every_shared_document_hashes_to_the_recorded_digest`, `rust::this_engine_reproduces_its_committed_capture`, `rust::verify_refuses_each_structural_violation` |
171+
| M28 | the port hashes the RENDERING form instead of the canonical form | `rust::every_committed_artifact_round_trips_and_verifies`, `rust::every_shared_document_hashes_to_the_recorded_digest`, `rust::the_canonical_form_ignores_only_insignificant_text_formatting`, `rust::this_engine_reproduces_its_committed_capture`, `rust::verify_refuses_each_structural_violation` |
172+
| M29 | the port reorders the frozen layer vocabulary | `rust::both_engines_report_the_same_layers_in_the_same_order`, `rust::every_committed_artifact_round_trips_and_verifies`, `rust::this_engine_reproduces_its_committed_capture`, `rust::verify_refuses_each_structural_violation` |
173+
| M30 | the port's `has` stops distinguishing a present member from an absent one | `rust::every_committed_artifact_round_trips_and_verifies`, `rust::this_engine_reproduces_its_committed_capture`, `rust::verify_refuses_each_structural_violation` |
174+
### checkpoint 2 — engine protocol (`p022-shadow-cp2`)
175+
176+
| | |
177+
|---|---|
178+
| mutations | **11** |
179+
| caught | **11** |
180+
| survived | **0** |
181+
| compile errors (reported as such, never as "caught") | 0 |
182+
| harness-honesty controls reporting zero failures | 1 |
183+
| catches by layer | `python` 5, `rust-engine` 6, `rust-repro` 2 |
184+
| mutations with exactly **one** catching layer | 9 — M32, M33, M34, M35, M37, M38, M39, M40, M41 |
185+
186+
| id | mutation | caught by |
187+
|---|---|---|
188+
| M31 | the reference stops declaring a projection on its layers | `python::artifact-golden`, `python::capture-verify` |
189+
| M32 | the reference silently drops the foreign engine entries when regenerating | `python::artifact-golden` |
190+
| M33 | the reference's verification accepts a partial projection that names no members | `python::structural-control` |
191+
| M34 | the reference's verification accepts a 'full' projection that also names members | `python::structural-control` |
192+
| M35 | the port declares its verdict layer FULL while it is at the checkpoint-4 projection | `rust-engine::this_engine_reproduces_its_committed_capture` |
193+
| M36 | the port drops `column` from its verdict records while still claiming it | `rust-engine::a_partial_projection_names_exactly_the_members_it_carries`, `rust-engine::this_engine_reproduces_its_committed_capture` |
194+
| M37 | the port stamps a refused layer with the 'produced' status | `rust-engine::this_engine_reproduces_its_committed_capture` |
195+
| M38 | the port claims a surface version for the MOS dump, which has none | `rust-engine::this_engine_reproduces_its_committed_capture` |
196+
| M39 | the port reports a typed-door refusal on one layer instead of all three | `rust-engine::this_engine_reproduces_its_committed_capture` |
197+
| M40 | the port's verification stops rejecting a 'full' projection that names members | `rust-repro::verify_refuses_each_structural_violation` |
198+
| M41 | the port's verification accepts an EMPTY reason on a partial projection | `rust-repro::verify_refuses_each_structural_violation` |

‎docs/notes/p022-shadow-infra-checkpoint1-data/campaign.json‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@
168168
"caught_by": [
169169
"rust::every_committed_artifact_round_trips_and_verifies",
170170
"rust::every_shared_document_hashes_to_the_recorded_digest",
171+
"rust::this_engine_reproduces_its_committed_capture",
171172
"rust::verify_refuses_each_structural_violation"
172173
]
173174
},
@@ -178,7 +179,8 @@
178179
"status": "caught",
179180
"caught_by": [
180181
"rust::every_committed_artifact_round_trips_and_verifies",
181-
"rust::every_shared_document_hashes_to_the_recorded_digest"
182+
"rust::every_shared_document_hashes_to_the_recorded_digest",
183+
"rust::this_engine_reproduces_its_committed_capture"
182184
]
183185
},
184186
{
@@ -188,7 +190,8 @@
188190
"status": "caught",
189191
"caught_by": [
190192
"rust::every_committed_artifact_round_trips_and_verifies",
191-
"rust::every_shared_document_hashes_to_the_recorded_digest"
193+
"rust::every_shared_document_hashes_to_the_recorded_digest",
194+
"rust::this_engine_reproduces_its_committed_capture"
192195
]
193196
},
194197
{
@@ -275,6 +278,7 @@
275278
"caught_by": [
276279
"rust::every_committed_artifact_round_trips_and_verifies",
277280
"rust::every_shared_document_hashes_to_the_recorded_digest",
281+
"rust::this_engine_reproduces_its_committed_capture",
278282
"rust::verify_refuses_each_structural_violation"
279283
]
280284
},
@@ -287,6 +291,7 @@
287291
"rust::every_committed_artifact_round_trips_and_verifies",
288292
"rust::every_shared_document_hashes_to_the_recorded_digest",
289293
"rust::the_canonical_form_ignores_only_insignificant_text_formatting",
294+
"rust::this_engine_reproduces_its_committed_capture",
290295
"rust::verify_refuses_each_structural_violation"
291296
]
292297
},
@@ -296,7 +301,9 @@
296301
"rule": "artifact: layers are an ORDERED array in pipeline order",
297302
"status": "caught",
298303
"caught_by": [
304+
"rust::both_engines_report_the_same_layers_in_the_same_order",
299305
"rust::every_committed_artifact_round_trips_and_verifies",
306+
"rust::this_engine_reproduces_its_committed_capture",
300307
"rust::verify_refuses_each_structural_violation"
301308
]
302309
},
@@ -307,6 +314,7 @@
307314
"status": "caught",
308315
"caught_by": [
309316
"rust::every_committed_artifact_round_trips_and_verifies",
317+
"rust::this_engine_reproduces_its_committed_capture",
310318
"rust::verify_refuses_each_structural_violation"
311319
]
312320
}

0 commit comments

Comments
 (0)