diff --git a/.changeset/lab-136-brief-byte-identical.md b/.changeset/lab-136-brief-byte-identical.md new file mode 100644 index 0000000000..c62f752b78 --- /dev/null +++ b/.changeset/lab-136-brief-byte-identical.md @@ -0,0 +1,6 @@ +--- +--- + +Internal only — no published package changes. + +Adds one model-free goal, `goals/context-supply/assembles-the-same-brief-every-pass`, proving that a phase's context recipe hands the model a byte-identical brief on every pass and that its standing half survives a change of issue. Three files in one goal folder; no workspace member, no config edit, no change to any package. The assembly seam was deterministic across every pass, so there is no framework finding to file. diff --git a/goals/context-supply/assembles-the-same-brief-every-pass/fixtures/world.json b/goals/context-supply/assembles-the-same-brief-every-pass/fixtures/world.json new file mode 100644 index 0000000000..65573df1eb --- /dev/null +++ b/goals/context-supply/assembles-the-same-brief-every-pass/fixtures/world.json @@ -0,0 +1,42 @@ +{ + "phase": { + "instructions": "You are reviewing a pull request. Read the change against the standards below and report only what the author must decide before this can merge. Do not restate the diff back to the author." + }, + "grounding": { + "project": "We ship small, reversible changes. Every change earns its place: no speculative abstraction, no configurability nobody asked for, and no second way to do a thing that already has one. When code and its written grounding disagree, that is a gap to surface, not to route around.", + "standards": "A review must cover four things and say so explicitly: (1) whether the change does what its issue asked and nothing more; (2) whether every claim it rests on has an evidence path someone else could re-run; (3) whether it tolerates the shapes already in flight, including the null and legacy ones; (4) whether the tests could actually fail if the behaviour regressed." + }, + "objective": { + "id": "OBJ-7", + "title": "Reviews that a second reader can trust without re-reading the diff", + "summary": "A reviewer's write-up should let a second person act on it without opening the change themselves. That holds only if every reviewer is handed the same standards, the same project grounding, and the same objective on every pass." + }, + "issues": [ + { + "id": "ISSUE-1", + "title": "Reported token usage drops to zero after a retry", + "body": "When a generation is retried after a transport error, the usage numbers attached to the finished turn read zero instead of the totals for the attempt that succeeded. Billing reads those numbers, so a retried turn currently bills as free. Reproduced on every retry path we tried; not reproducible without a retry.", + "pullRequest": { + "number": 101, + "filesChanged": 3, + "linesAdded": 47, + "linesRemoved": 12, + "diff": "--- a/usage-accumulator\n+++ b/usage-accumulator\n@@\n- totals = attemptTotals\n+ totals = mergeTotals(totals, attemptTotals)\n@@\n- reset() { totals = EMPTY }\n+ reset() { if (!retrying) totals = EMPTY }", + "verification": "Added a regression test that fails a transport error on the first attempt and asserts the finished turn's totals equal the successful attempt's. Confirmed red before the change, green after. No test covers two consecutive retries." + } + }, + { + "id": "ISSUE-2", + "title": "Scheduled runs fire twice when a worker restarts mid-window", + "body": "A worker that restarts inside a schedule's firing window runs the same scheduled action a second time, because the claim marking the window as handled is written after the action completes rather than before it starts. Downstream effects are not idempotent, so a duplicate send reaches real recipients.", + "pullRequest": { + "number": 102, + "filesChanged": 5, + "linesAdded": 88, + "linesRemoved": 30, + "diff": "--- a/window-claim\n+++ b/window-claim\n@@\n- await runAction(due)\n- await claimWindow(due.windowId)\n+ const claimed = await claimWindow(due.windowId)\n+ if (!claimed) return\n+ await runAction(due)", + "verification": "Two workers racing one window are driven concurrently in a new test; the action must run exactly once, counted by a real side effect rather than by de-duplicated output. Not yet exercised against a worker killed between the claim and the run." + } + } + ] +} diff --git a/goals/context-supply/assembles-the-same-brief-every-pass/goal.md b/goals/context-supply/assembles-the-same-brief-every-pass/goal.md new file mode 100644 index 0000000000..6ddd130e4c --- /dev/null +++ b/goals/context-supply/assembles-the-same-brief-every-pass/goal.md @@ -0,0 +1,93 @@ +# context-supply › it assembles-the-same-brief-every-pass + +**Issue:** LAB-136 + +**Outcome:** One phase of work — review — is handed a brief that is what that phase actually needs, judged once by a human against the written review standard the brief itself carries, and identical byte for byte on every pass. Round eight behaves like round one. The brief is shaped as a standing half (the phase's instructions, the project's grounding, the review standards, the objective) and a small changing half (this issue, this pull request, this diff), and the standing half must survive a change of issue. The human read is a real gate with a real red state: if the brief is missing something a reviewer needs, the verdict is FAIL and the recipe changes. It has already gone red once — see the verdict log. + +**Input:** `fixtures/world.json` — a hand-built world with no database and no event feed: two issues, each with a pull request, its diff and what the author verified; the project's grounding; the review standards; the objective they sit under. Identifiers are invented (`ISSUE-1`, `#101`) and never real tracker ids (BP-006). Held-out: `run.mts` reads the world from the fixture and grades every fact against it, so swapping in another valid world still passes a correct recipe. No brief text is hardcoded in the check — the graded set is *derived* by walking the fixture. One setup guard protects swappability: **overlapping identifiers**. The leak check uses substring containment, so a world whose two issues carry `ISSUE-1` and `ISSUE-10`, or `#10` and `#101`, is rejected at setup instead of reported as a false leak. A second guard, for fixture content colliding with a region label, was tried and **backed out** — see the coverage list below for why. Each pass reads a fresh `structuredClone`. + +**Signal:** +- **Eight passes, one issue.** Eight assemblies of the recipe, each over a fresh copy of the world, render to the same bytes under one named comparator (`briefsAgree`). +- **The precondition.** Exactly one leading `system` message and none after it — which is what makes "the leading system run *is* the standing half" exact for this recipe rather than a heuristic. If it fails, the boundary derivation is void and the standing-half signal is withdrawn, not reinterpreted. +- **Exactly one model invocation per pass.** Each invocation overwrites the capture, so a second call would silently discard the first handoff and leave every check below grading the *last* brief rather than the one the recipe assembled. This recipe is tool-free and terminal at step 0, so a second call is a regression by definition — asserting one is both the guard and its own canary. Accumulating instead would grade something the design says cannot happen. +- **Every contribution the brief claims to carry is present *and correctly placed*.** The expected set is derived by *walking the fixture world*, never hand-listed — the phase instructions, the project grounding, the review standards and the objective in the standing half; the issue's id, title, body, PR metrics, diff and verification statement in the changing half. A contribution added to the world but never rendered fails here, and the list cannot drift out of agreement with what the brief promises. Placement is graded two ways, because there are two different hazards and **neither mechanism covers the other** — established by test, not by argument: + + - **Across regions.** Each contribution is graded inside *its own region*, not across the whole half. Without this, swapping `project` and `standards`, or `issue.body` and the verification statement, leaves both strings present and every signal green while the model reads each under the other's heading. **The two halves need different mechanisms, and that is honest rather than untidy:** the standing half is tag-structured, so its regions are read off the recipe's own context object — its keys *are* the tags the framework renders, so a recipe that grows a fourth grounding key is covered without anyone updating the check. The changing half is prose with labels and has no tags, so it is sliced at the labels `renderTail` writes (`Issue `, `PR #`, `Verification: `), kept beside the renderer. Forcing the tag mechanism onto the tail would be one mechanism stretched past where it fits. A label that goes missing voids the tail's scoping loudly rather than silently widening the search back to the whole half — which is how this hole appeared in the first place. + - **Within one region.** Region scoping cannot see a transposition inside a region: all four PR scalars render into the same untagged tail, so `linesAdded` and `linesRemoved` can swap without leaving it. Those fields are graded on their **labelled fragment** — `+47`, `−12`, `3 files`, `#101` — rather than the bare digits. The labels mirror `renderTail` and are kept beside it. (Verified: with the labelled fragments removed and region scoping alone in place, the transposed brief goes **green** again.) + +Without all of this the *shape* could stay perfectly stable while the *content* silently vanished or transposed: eight passes would still agree, the split would still hold, the canary would still fire. +- **Two different issues.** The standing half is byte-identical between issue A and issue B; the changing half **differs**; each carries its own contributions; and neither carries the other's identifying facts (id, title, PR number). + +**Anti-game:** A hollow pass here looks like one of seven things, and each has a check that closes it. Five of the six are the same failure at different depths — *an instrument that cannot see what it claims to measure, reporting fine* — which is worth naming, because it is the shape every defect found on this issue has taken. +1. *A comparator that could never return false.* → A variant recipe whose grounding appends a **per-call counter** must make the same named `briefsAgree` return false. A counter, never the clock: in-process assemblies can land in one tick, and a flaky check is worse than none. Two assemblies suffice for the canary — a per-call counter differs on the second; the primary loop runs eight because that is the claim's language. +2. *A brief so thin nothing in it could drift.* → Every fact graded is pulled from the fixture; the assembled brief is printed on every run so a human sees what was actually measured. +3. *A stable shape over draining content.* → The derived contribution assertions above. This is the one that makes the goal a regression check rather than a shape check, because the human read that would otherwise catch it is a one-time verdict-log row that `goal:all` never re-runs. (Verified: dropping the diff and the verification statement, then the standards and the objective summary, turns it red and names the missing fixture paths — while every other signal stays green.) +4. *Content present but transposed.* → Labelled-fragment grading for the fields whose bare value is ambiguous. (Verified: swapping `linesAdded` and `linesRemoved` in `renderTail` turns it red naming `+47` and `−12`; before this it was fully green, since both digits were still in the tail.) +5. *A capture that quietly lost the brief it was measuring.* → The one-invocation assertion. (Verified: giving the recipe a tool and scripting a tool call on the first step produces two invocations and turns it red.) +6. *A standing-half comparison between two briefs that are secretly the same brief.* → Requiring the changing halves to differ and to carry their own fixture's facts. Without those two assertions a recipe that assembled issue A twice passes every other signal. (Verified: forcing exactly that turns three assertions red.) +7. *Measuring the wrong mechanism and passing green.* → The model stub is step-capable and its legacy `generate` **throws**. A `generate()`-only stub drives the SDK-owned compatibility path, which contains no `emitGeneratorStep` call sites and which production never takes. (Verified: removing `generateStep` routes the run into `generate()` and the guard fires.) + +The stub implements `generateStep` and **not** `streamStep`. Both are optional on `GeneratorModel` (only `modelId` and `generate` are required), and this recipe is tool-free and identity-less, so `canStream` is false and the streaming branch is unreachable — a `streamStep` here would be dead surface. Adding tools or `itemVisibility` later cannot silently reroute to a legacy path either: `canStream` also requires `stream` or `streamStep` to exist, and neither does. + +The check must **not** assert on `assembleMessages`'s return value — that is the unit suite's job. This grades what the model was handed, through the step-method path production uses. + +**Recipe constraint — load-bearing, not stylistic.** Every dynamic contribution in this recipe must be a **top-level slot function**. No functions may survive inside a slot's returned value. + +`resolveSlotValues` calls top-level slot functions and stops; a function nested inside object-form context (`context: { drift: () => … }`) is resolved *later*, by `aggregateContextEntries`, and so never enters the capture. Such a formatter drifts the assembled bytes while the capture reports the slot perfectly stable — and the localization step below would then blame the framework for this recipe's own nondeterminism. That is a false framework finding, which under the issue's decision 3 pauses the epic. + +Anyone extending this recipe needs to know that the constraint is what makes attribution sound, not a style preference. It is enforced in the two places where it changes an outcome — inside `localize`, which consults it before it may say "seam", and in the nested-formatter variant, which proves the guard fires. There is deliberately no third, always-on check: on a green run it would restate a constraint nothing is currently relying on. + +**Localization — and the correction this issue made to it.** On a red byte comparison, the check attributes the drift before anything is reported: slot outputs are compared **from the same eight runs** (never a fresh re-run, which is a different sample and can report "slots were stable" for drift the slots caused). Slot outputs differ → recipe drift, ours to fix here. Slot outputs agree → the assembly seam, which is a framework finding to file, not to repair here. + +Spelled that way alone, the step is unsound. The constraint check has to run **inside** the attribution, first: an unresolved slot means the capture is blind, and blindness is not evidence of stability. Before that ordering was in place, a nested recipe formatter produced a confident *"report and stop — the drift is in the assembly seam"*. It now produces *"ours to fix here, NOT a framework finding."* Both outputs are recorded in the verdict log. + +**Coverage this does not have** (stated rather than papered over): +- The **seam** verdict is reachable but has never fired on a real drift. Producing one would require making the framework itself nondeterministic, which means editing `packages/*` — a non-goal of this issue. What is proven is that the classifier reaches that branch only when the capture can see every dynamic contribution. +- A grounding contribution that reads the **clock** is not reliably detected: eight immediate in-process assemblies can share a tick. The honest coverage is per-call variation. +- **Fixture mutation** is not detected either way — every pass starts from a fresh copy, so every pass performs the same mutation on clean data. +- **Grading is substring matching over rendered text, and that is the approach's ceiling** (tracked on FIX-1183, not folded here). Three known consequences, all of the same shape: + - `carries` is a bare `includes`, so a body repeating its own title would let a removed title still be "found". The current fixture has no same-object leaf overlaps, so the recorded verdicts are sound. + - Fixture content containing a region label (`Issue `, `PR #`, a grounding tag in the unescaped prompt) would send the slicing's `indexOf` to the embedded occurrence. **A guard for this was written and then backed out**: two attempts over-rejected valid worlds in opposite directions — first by matching a bare `PR #`, which refuses a body that merely mentions one; then by requiring each anchor to occur exactly once, which refuses a title containing the word "Issue" even though `indexOf` returns offset 0 either way and no boundary can move. It was never protecting anything real, and it broke the swappability it existed to defend. Backed out rather than attempted a third time. + - The message-boundary precondition is asserted for issue A only, while the two-issue signals assume it for B — so a regression emitting a later `system` message for B alone would not be caught. + + These are one problem, not three. Every guard here (region scoping, escape handling, identifier overlap, and the reverted anchor check) exists to protect substring matching against arbitrary substituted content, and the anchor guard's second bug was introduced by the fix for its first. The approach *is* the limit: substring matching over rendered text cannot reliably separate *present in the right place* from *present somewhere*. The fix is structured, field-specific comparison — a redesign of the grading, not another guard. +- **Transposition of two unlabelled fields inside one region** is not detected. Regions are the finest scope the render offers, and within one region only the labelled fragments distinguish fields. `issue.id` carries the `Issue ` label and `linesAdded`/`linesRemoved` carry `+`/`−`, so those are covered; two adjacent unlabelled values in the same region would not be. Closing it further would mean labelling the brief for the test's benefit, which is the tail wagging the dog. +- Variance across **machines, processes, locales, timezones** is not covered. Eight passes seconds apart in one process are materially weaker than "round eight behaves like round one" in production. Do not report a green here as the epic's headline claim having been met. + +**Model:** n/a — model-free. The stub records the messages it was handed and returns empty text; it cannot influence the brief, so the assembly under test is the framework's real one. Introducing a real model would put nondeterminism inside a determinism proof and would answer a different question (was the review any good?). + +**Run:** `pnpm tsx goals/context-supply/assembles-the-same-brief-every-pass/run.mts` + +## Verdict log +| Date | Commit | Model | Verdict | Notes | +|------|--------|-------|---------|-------| +| 2026-08-18 | f56c6b216 (+goal) | n/a | FAIL (human read) | First read of the assembled brief against the standards it carries. Assembly was correct and all machine signals were green, but the brief asked a reviewer to check that "every claim has a re-runnable evidence path" while giving them nothing to check it against — no tests, no statement of what the author ran. Gap was in the recipe's world, not in the framework's assembly. Fixed by adding a `verification` field per pull request and rendering it in the changing half. Recorded because the human gate is only real if its red state is. | +| 2026-08-18 | f56c6b216 (+goal) | n/a | PASS | 8 passes over `ISSUE-1`, fresh world each, byte-identical (2153 bytes; standing half 1258). Precondition held: exactly one leading system message. `ISSUE-2` left the standing half unchanged, differed in the changing half, and carried its own facts and none of `ISSUE-1`'s. Anti-game: the per-call-counter variant made `briefsAgree` return false and localized to the **recipe**. Constraint guard: a nested context formatter looks stable to the raw slot signal (the hazard), is caught by the guard, and localization consequently refuses to blame the seam. **No framework finding** — the assembly seam was deterministic across every pass. | +| 2026-08-18 | f56c6b216 (+goal, review round 1) | n/a | PASS | Re-run after review. The check now grades **all 15 contributions** the brief claims to carry, derived by walking the fixture — previously only 3 (id, title, PR number), which left the body, diff, verification, PR metrics, project grounding, standards and objective ungraded and a content-drop invisible to every automated signal. Also: substring-overlap guard at setup so the held-out claim survives a colliding replacement world; per-pass `goalSessionId` slugs (the stamp is per-process, so a bare slug would share one session across all eight passes and accumulate history); canary reduced to 2 assemblies; the always-on constraint check removed as redundant with `localize`'s ordering and the nested canary; `streamStep` removed from the stub as unreachable on this non-streaming path. Same result: byte-identical across eight passes, standing half survives a change of issue, no framework finding. | +| 2026-08-18 | f56c6b216 (+goal, review round 2) | n/a | PASS | Two more blind-instrument holes closed. (1) The capture itself could lose data and report green: each invocation overwrote `capture.messages`, so a second call would discard the first handoff and leave everything grading the last brief — now asserted at exactly one invocation, which for a tool-free step-0-terminal recipe is guard and canary in one. (2) The 15-contribution grader checked presence, not placement: swapping `linesAdded` and `linesRemoved` left every leaf present and every signal green while the brief reported the wrong change size — the ambiguous fields are now graded on their labelled fragment (`+47`, `−12`, `3 files`, `#101`). Both verified by breaking them. Same result: byte-identical across eight passes, standing half survives a change of issue, no framework finding. | +| 2026-08-18 | f56c6b216 (+goal, review round 2 completions) | n/a | PASS | Placement grading extended from four named fields to **every** contribution: each is now graded inside its own tag's content, with the tags read off the recipe's context object rather than a list, so `project` rendered under `` fails where it previously passed. The labelled fragments were kept rather than replaced — emptying them and relying on region scoping alone lets a transposed `+47 −12` pass, because all four PR scalars share one untagged region. Both mechanisms verified by breaking them, and the redundant-looking pair is the tested minimum, not belt-and-braces. Also renamed the flow kind and session slug off the ticket id (BP-006): `review-brief-goal` and `review-brief-pass-N`. Same result: byte-identical across eight passes, standing half survives a change of issue, no framework finding. | +| 2026-08-18 | f56c6b216 (+goal, round 2 completion) | n/a | PASS | Region scoping extended to the **changing** half, which the first pass left searched whole — swapping `issue.body` with the verification statement kept both present and every signal green. The tail is prose with labels rather than tags, so it gets its own mechanism (sliced at `Issue `, `PR #`, `Verification: `) instead of the standing half's stretched to fit; a missing label voids the scoping loudly rather than widening it. Verified: the body/verification swap goes red, and the metric transposition still goes red afterwards, so the two mechanisms compose. Remaining limit recorded above: two *unlabelled* fields transposed inside one region. Same result: byte-identical across eight passes, standing half survives a change of issue, no framework finding. | +| 2026-08-18 | `e380252d9` | n/a | PASS | Run on a clean tree at the implementing commit. Setup guard completed: it already rejected a fixture whose two issues share identifying facts, but not one whose *content* contains a region label — `indexOf` would find the embedded occurrence, cut the regions at the wrong offsets, and report a contribution missing from a correct recipe. Same class, now rejected the same way. The guarded list is asymmetric on purpose and the asymmetry is evidence-backed: grounding values are XML-escaped on the way into the standing half, so `` inside one cannot collide — put there deliberately, the goal passes rather than being rejected, confirming the guard does not over-reject a valid world. The prompt and tail are verbatim and are what is checked. Proved able to fire in both branches (`PR #` / `Verification: ` in an issue body; `` in the prompt). The existing fixture was verified clean beforehand, so no earlier verdict is withdrawn. | +| 2026-08-18 | `5a44782d6` | n/a | PASS | Run on a clean tree at the implementing commit. The anchor guard above over-rejected: it stripped the leading newline before testing, while the slicing searches for the newline-prefixed form, so a fixture merely mentioning `PR #123` mid-sentence was refused though it cannot move a boundary. Now tested against the **rendered tail** — an anchor must occur exactly once — because neither per-leaf test is exact: the bare label over-rejects an inline mention, and the newline-prefixed one misses a body that *starts* with the label and takes the newline from the join. That second case was executed, not reasoned about. Both directions verified. Also records why BP-017 does not apply to this recipe, so it is not re-raised. | +| 2026-08-18 | `172d47228` | n/a | PASS | Run on a clean tree at the implementing commit. The anchor-collision guard from the two rows above is **backed out in full** — it over-rejected valid worlds twice, in opposite directions (a body mentioning `PR #123`; a title containing the word "Issue", where the anchor is always at offset 0 and no boundary can move), and it was never protecting anything: the fixture has no collisions, so those earlier verdicts were sound regardless. Backing out beat a third attempt. Verified the revert restores what it broke — both previously-rejected worlds now pass. The limit is recorded in the coverage list with the two others of its family rather than lost. | + +### Falsification runs behind that PASS +Each was performed by breaking the check on purpose and confirming it went red, then reverting. A green from a check nobody has seen fail is decoration. + +| What was broken | Result | +|---|---| +| Issue B assembled as issue A (the vacuous-green hole) | RED — three assertions: changing halves identical, B's facts missing, A's facts leaked | +| A raw string added to the context slot | RED — precondition saw 2 leading system messages. Also settles by execution the spec's source-read claim that a string context entry becomes an extra system message | +| `generateStep` removed from the stub | RED — the run routed into legacy `generate()` and the guard threw. Confirms the wrong-mechanism failure is real and would otherwise have passed green | +| A nested-formatter drift on the eight passes, **before** the localization fix | RED, but attributed to the **seam** — a false framework finding | +| The same drift, **after** the fix | RED, attributed to the **recipe** — "ours to fix here" | +| The diff and the verification statement dropped from the tail | RED — named `issue(ISSUE-1).pullRequest.diff` and `.verification`, for both issues. Every other signal stayed green, which is the point | +| The standards and the objective summary dropped from the grounding | RED — named `grounding.standards`, `objective.summary` | +| A replacement world whose two issues are `ISSUE-1` and `ISSUE-10` | RED at setup — the leak check uses substring containment, so overlapping identifiers are rejected at the boundary rather than reported as a false leak | +| `linesAdded` and `linesRemoved` swapped in `renderTail` | RED — named `+47` and `−12` as the expected fragments. Fully green before labelled-fragment grading, since both digits were still present in the tail | +| A tool added and a tool call scripted on step 0, forcing two invocations | RED — "called 2 time(s), expected exactly 1. The capture is void." Before the assertion the second call would have overwritten the first brief and everything downstream would have graded the wrong one | +| `project` and `standards` swapped in `reviewGrounding` | RED — both values still present in the half, but each outside its own tag. Green before region scoping | +| The labelled fragments removed, leaving region scoping alone, with the metrics transposed | **PASS** — which is why both mechanisms are kept. Region scoping cannot see a transposition *inside* a region, and the four PR scalars share one untagged region | +| `issue.body` and the verification statement swapped in `renderTail` | RED — both named. Green before the tail was sliced at its labels, since both strings were still somewhere in the half | +| The metrics transposed again, *after* the tail was region-scoped | RED — confirms the labelled fragments still fire once regions exist, i.e. the two mechanisms compose rather than one masking the other | +| A world whose issue body mentions `PR #123`, or whose title contains the word "Issue" | **PASS** — these are valid worlds. Both were wrongly rejected by the anchor guard that has since been backed out; the row is kept as the regression check on that revert | diff --git a/goals/context-supply/assembles-the-same-brief-every-pass/run.mts b/goals/context-supply/assembles-the-same-brief-every-pass/run.mts new file mode 100644 index 0000000000..a5872fdff7 --- /dev/null +++ b/goals/context-supply/assembles-the-same-brief-every-pass/run.mts @@ -0,0 +1,649 @@ +/** + * Goal check — one phase's context recipe hands the model the SAME brief on + * every pass, and its standing half survives a change of issue (LAB-136). + * + * The contract, the recipe constraint, the localization rule and the anti-game + * design live in `goal.md`. This file implements them. Two points are repeated + * here only because getting either wrong produces a silent GREEN: + * + * - The stub must be step-capable, and its legacy `generate` therefore throws. + * A `generate()`-only stub drives the SDK-owned path production never takes. + * - `localize` consults the recipe constraint FIRST. An unresolved slot means + * the capture is blind, and blindness is not evidence of stability. + * + * WHAT A GREEN HERE DOES NOT PROVE: eight passes seconds apart in one process + * rule out per-call nondeterminism and nothing else. Not drift across restarts, + * machines, processes or locales; not a clock read landing inside one tick; not + * fixture mutation. Do not report this as the epic's headline claim having been + * met. `goal.md` → "Coverage this does not have" is the full list. + * + * Run: pnpm tsx goals/context-supply/assembles-the-same-brief-every-pass/run.mts + */ +import { defineFlow, generator } from "@flow-state-dev/core"; +import type { GeneratorModel, GeneratorModelCallOptions } from "@flow-state-dev/core"; +import { createInMemoryStores, runAction } from "@flow-state-dev/engine"; +import { goalSessionId, loadFixture, runGoal, silentLogger } from "../../lib/index.mts"; + +// --- the fixture world ----------------------------------------------------- + +interface PullRequest { + number: number; + filesChanged: number; + linesAdded: number; + linesRemoved: number; + diff: string; + /** What the author ran, and what they did not. Added after the first human + * read: the standards the brief carries ask a reviewer to check that every + * claim has a re-runnable evidence path, and the brief gave them nothing to + * check it against. See the verdict log's first row. */ + verification: string; +} +interface Issue { + id: string; + title: string; + body: string; + pullRequest: PullRequest; +} +interface World { + phase: { instructions: string }; + grounding: { project: string; standards: string }; + objective: { id: string; title: string; summary: string }; + issues: Issue[]; +} + +const WORLD = loadFixture(import.meta.url, "world.json"); + +/** A fresh copy per pass, so nothing a pass does can reach the next one. */ +const freshWorld = (): World => structuredClone(WORLD); + +const issueOf = (world: World, id: string): Issue => { + const found = world.issues.find((i) => i.id === id); + if (found === undefined) throw new Error(`fixture has no issue "${id}"`); + return found; +}; + +// --- the recipe: one generator, three slots -------------------------------- +// +// RECIPE CONSTRAINT — every dynamic contribution is a TOP-LEVEL slot function, +// and no function may survive inside a slot's returned value. This is +// load-bearing for localization's attribution, not stylistic; `goal.md` carries +// the reasoning. `unresolvedSlots` enforces it and the nested variant below +// proves that guard fires. + +type SlotName = "instructions" | "grounding" | "tail"; + +/** What one pass observed: the brief the model got, and what each slot returned. */ +interface Capture { + messages: unknown[]; + slots: Partial>; + /** Step-method invocations this pass. Must be exactly 1 — see `assemble`. */ + calls: number; +} + +/** The changing half: this issue, this pull request, this diff. */ +function renderTail(world: World, issueId: string): string { + const issue = issueOf(world, issueId); + const pr = issue.pullRequest; + return [ + `Issue ${issue.id} — ${issue.title}`, + issue.body, + "", + `PR #${pr.number} — ${pr.filesChanged} files, +${pr.linesAdded} −${pr.linesRemoved}`, + pr.diff, + "", + `Verification: ${pr.verification}`, + ].join("\n"); +} + +/** The standing grounding contribution the real recipe uses. */ +function reviewGrounding(world: World): unknown { + return { + project: world.grounding.project, + standards: world.grounding.standards, + objective: `${world.objective.id} — ${world.objective.title}\n${world.objective.summary}`, + }; +} + +/** + * Run the recipe once and capture what the framework handed the model. + * + * `grounding` is a parameter only so the anti-game variants can swap that one + * slot; everything else is identical between the real recipe and the variants, + * which is what makes the variants evidence about this recipe. + */ +async function assemble( + world: World, + issueId: string, + grounding: (w: World) => unknown, + passLabel: string, +): Promise { + const capture: Capture = { messages: [], slots: {}, calls: 0 }; + const record = (slot: SlotName, value: T): T => { + capture.slots[slot] = value; + return value; + }; + + const model: GeneratorModel = { + modelId: "stub/recorder", + async generate() { + throw new Error( + "legacy generate() was called — this check would have measured the SDK-owned " + + "compatibility path, which production never takes. The capture is void.", + ); + }, + // `generateStep` only. `streamStep` is optional on `GeneratorModel` and this + // recipe is tool-free and identity-less, so `canStream` is false and the + // streaming branch is unreachable — a `streamStep` here would be dead + // surface. Adding tools or `itemVisibility` later cannot silently reroute to + // a legacy path either: `canStream` also requires `stream` or `streamStep` to + // exist, and neither does. + async generateStep(options: GeneratorModelCallOptions) { + capture.calls += 1; + capture.messages = options.messages; + return { text: "", finishReason: "stop" }; + }, + }; + + // BP-017 does not apply here, and this note exists so it is not re-raised: it + // governs production recipes, where structured material belongs in `context` + // and `user` stays short. This recipe's job is to exercise the framework's + // assembly, which means populating all three slots and covering BOTH the + // escaped path (`context` → XML-tagged, `<` escaped) and the verbatim one + // (`prompt` and `user`). Routing the tail through `context` would make the + // check test less, not more. + const recipe = generator({ + name: "review-brief", + model: "stub/recorder", + prompt: () => record("instructions", world.phase.instructions), + context: () => record("grounding", grounding(world)), + user: () => record("tail", renderTail(world, issueId)), + }); + + const flow = defineFlow({ + kind: "review-brief-goal", + requireUser: true, + actions: { review: { block: recipe as never } }, + })({ id: "default" }); + + const result = await runAction({ + flow, + actionName: "review" as never, + input: {}, + userId: "goal-user", + // Per-pass slug is load-bearing, not decorative: `goalSessionId`'s stamp is + // per-PROCESS, so a bare slug would hand all eight passes one session, and + // the accumulated history would make pass 2 legitimately differ from pass 1. + sessionId: goalSessionId(`review-brief-${passLabel}`), + stores: createInMemoryStores(), + runtimeConfig: { + modelResolver: Object.assign(() => model, { resolveId: (id: string) => id }), + logger: silentLogger, + } as never, + }); + if (result.error) throw new Error(`assembly run failed: ${result.error.message}`); + // Exactly one, not "at least one". Each invocation OVERWRITES `capture.messages`, + // so on a second call every earlier handoff is silently discarded and the checks + // below grade only the last one — a malformed or pass-dependent first brief would + // be invisible. This recipe is tool-free and terminal at step 0, so a second call + // is a regression by definition: asserting it is both the guard and the canary. + if (capture.calls !== 1) { + throw new Error( + `the model stub was called ${capture.calls} time(s), expected exactly 1. The capture keeps ` + + `only the last handoff, so every brief graded below would be the final call rather than ` + + `the one the recipe assembled. The capture is void.`, + ); + } + return capture; +} + +// --- one named comparator, used by every check ----------------------------- + +const renderBrief = (messages: unknown[]): string => JSON.stringify(messages); + +function briefsAgree(captures: Capture[]): boolean { + // An empty set must not "agree" — `[].every()` is true, and a vacuous green is + // the failure mode this whole goal exists to avoid. + if (captures.length === 0) return false; + const first = renderBrief(captures[0]!.messages); + return captures.every((c) => renderBrief(c.messages) === first); +} + +// --- the standing / changing boundary -------------------------------------- +// +// The leading system run IS the standing half — exactly, for this recipe's +// shape, not as a heuristic. Asserted rather than assumed; `goal.md` has the +// derivation. + +const roleOf = (m: unknown): string | undefined => + typeof m === "object" && m !== null ? (m as { role?: string }).role : undefined; + +function preconditionFailure(messages: unknown[]): string | undefined { + let lead = 0; + while (lead < messages.length && roleOf(messages[lead]) === "system") lead += 1; + if (lead !== 1) { + return `expected exactly 1 leading system message, saw ${lead} (roles: ${messages.map(roleOf).join(", ")})`; + } + if (messages.slice(lead).some((m) => roleOf(m) === "system")) { + return `a system message appears after the leading run (roles: ${messages.map(roleOf).join(", ")})`; + } + return undefined; +} + +/** Byte views — for the identity claims. */ +const standingHalf = (c: Capture): string => renderBrief(c.messages.slice(0, 1)); +const changingHalf = (c: Capture): string => renderBrief(c.messages.slice(1)); + +/** Text views — what the model actually reads; for the content assertions. */ +const textOf = (messages: unknown[]): string => + messages.map((m) => String((m as { content?: unknown }).content ?? "")).join("\n"); +const standingText = (c: Capture): string => textOf(c.messages.slice(0, 1)); +const changingText = (c: Capture): string => textOf(c.messages.slice(1)); + +// --- what the brief must actually carry ------------------------------------ +// +// Derived by walking the fixture, never hand-listed, so the graded set cannot +// drift from what the brief promises. Without it the shape stays stable while +// the content drains away and every other signal stays green. + +interface Leaf { + path: string; + text: string; +} + +function leaves(value: unknown, path: string): Leaf[] { + if (value === null || value === undefined) return []; + if (typeof value === "string" || typeof value === "number") { + return [{ path, text: String(value) }]; + } + if (Array.isArray(value)) return value.flatMap((v, i) => leaves(v, `${path}[${i}]`)); + if (typeof value === "object") { + return Object.entries(value as Record).flatMap(([k, v]) => + leaves(v, path === "" ? k : `${path}.${k}`), + ); + } + return []; +} + +/** Contributions the standing half claims to carry. */ +const standingContributions = (): Leaf[] => [ + ...leaves(WORLD.phase, "phase"), + ...leaves(WORLD.grounding, "grounding"), + ...leaves(WORLD.objective, "objective"), +]; + +/** Contributions one issue's changing half claims to carry. Rooted at a stable + * `issue` prefix (not the issue's id) so a path suffix means the same thing for + * every issue; the failure message already names which issue it was. */ +const changingContributions = (id: string): Leaf[] => leaves(issueOf(WORLD, id), "issue"); + +/** + * How a field is PLACED in the brief, for the fields whose bare value cannot + * identify them. Mirrors the labels in `renderTail` — keep the two together. + * + * Placement is graded two ways, because the two hazards are different and + * neither mechanism covers the other. Verified, not assumed — emptying this + * table and transposing the metrics turns the check GREEN again: + * + * - ACROSS regions (`project` rendered under ``): caught by + * `standingRegion`, which scopes each contribution to its own tag. + * - WITHIN one region (`linesAdded` rendered where `linesRemoved` belongs): + * region scoping cannot see it — all four PR scalars render into the same + * untagged tail — so these are graded on their labelled fragment instead. + * + * Leaves absent from this list are distinctive prose and are graded on their + * text within their region. + */ +const PLACED: Array<[string, (v: string) => string]> = [ + ["issue.id", (v) => `Issue ${v}`], + ["pullRequest.number", (v) => `#${v}`], + ["pullRequest.filesChanged", (v) => `${v} files`], + ["pullRequest.linesAdded", (v) => `+${v}`], + ["pullRequest.linesRemoved", (v) => `−${v}`], +]; + +const expectedFragment = (leaf: Leaf): string => { + const placed = PLACED.find(([suffix]) => leaf.path.endsWith(suffix)); + return placed === undefined ? leaf.text : placed[1](leaf.text); +}; + +/** Context values are XML-escaped on the way into the system message; prompt and + * user values are not. Accept either form so the check works for both slots. */ +const escapeXml = (s: string): string => + s.replace(/&/g, "&").replace(//g, ">"); +const carries = (haystack: string, fragment: string): boolean => + haystack.includes(fragment) || haystack.includes(escapeXml(fragment)); + +/** + * The slice of the brief that is supposed to carry a contribution. + * + * Scoped, not whole-half: an unscoped search cannot tell a value rendered under + * the right tag from the same value rendered under the wrong one, so swapping + * `project` and `standards` would leave both present and every signal green + * while the model reads each under the other's heading. + * + * The tags are read off the recipe's own context object — its keys ARE the tags + * the framework renders — so this is derived from the recipe, not declared + * beside it, and a recipe that grows a fourth grounding key is covered without + * anyone remembering to add it here. + */ +const GROUNDING_TAGS = Object.keys(reviewGrounding(WORLD) as Record); + +function taggedRegion(text: string, tag: string): string { + const open = `<${tag}>`; + const start = text.indexOf(open); + if (start < 0) return ""; + const end = text.indexOf(``, start); + return end < 0 ? "" : text.slice(start + open.length, end); +} + +function standingRegion(text: string, leafPath: string): string { + const tag = GROUNDING_TAGS.find((t) => leafPath.includes(t)); + if (tag !== undefined) return taggedRegion(text, tag); + // The untagged prompt: everything ahead of the first tag the recipe declares. + const firstTag = GROUNDING_TAGS.map((t) => text.indexOf(`<${t}>`)) + .filter((i) => i >= 0) + .sort((x, y) => x - y)[0]; + return firstTag === undefined ? text : text.slice(0, firstTag); +} + +/** + * The changing half's regions. The tail is NOT tag-structured the way the + * standing half is — it is prose with labels — so `taggedRegion` does not apply + * and forcing it to would be one mechanism stretched past where it fits. These + * anchors are the labels `renderTail` writes; keep the two together. + * + * Without this, every changing contribution is searched across the whole tail: + * swap `issue.body` with `pullRequest.verification` and both strings are still + * present, so the brief assigns content to the wrong fields while every signal + * stays green — the same hole region scoping closed in the standing half. + */ +const TAIL_ANCHORS = ["Issue ", "\nPR #", "\nVerification: "] as const; + +/** Which anchored region a changing contribution belongs to. */ +const tailRegionIndex = (path: string): number => + path.includes("pullRequest.verification") ? 2 : path.includes("pullRequest.") ? 1 : 0; + +function tailRegion(text: string, index: number): string { + const starts = TAIL_ANCHORS.map((a) => text.indexOf(a)); + // A missing label voids the scoping loudly rather than silently widening the + // search back to the whole tail, which is how this hole appeared in the first place. + if (starts.some((s) => s < 0)) return ""; + const from = starts[index]!; + const to = index + 1 < starts.length ? starts[index + 1]! : text.length; + return text.slice(from, to); +} + +const missingFrom = (expected: Leaf[], regionFor: (leaf: Leaf) => string): string[] => + expected + .filter((l) => !carries(regionFor(l), expectedFragment(l))) + .map((l) => { + const fragment = expectedFragment(l); + return fragment === l.text ? l.path : `${l.path} (expected ${JSON.stringify(fragment)})`; + }); + +// --- identity, for the leak check and the setup guard ---------------------- + +const identifyingFacts = (id: string): string[] => { + const issue = issueOf(WORLD, id); + return [issue.id, issue.title, `#${issue.pullRequest.number}`]; +}; + +/** Substring, not equality: the leak check uses `includes`, so `ISSUE-1` against a + * world also holding `ISSUE-10` would report a leak that is really an overlap. */ +const collides = (x: string, y: string): boolean => x.includes(y) || y.includes(x); + +// --- the recipe constraint, enforced rather than documented ---------------- + +function containsFunction(value: unknown): boolean { + if (typeof value === "function") return true; + if (value === null || typeof value !== "object") return false; + if (Array.isArray(value)) return value.some(containsFunction); + return Object.values(value as Record).some(containsFunction); +} + +/** Slot names whose captured value still holds an unresolved function. */ +function unresolvedSlots(c: Capture): SlotName[] { + return (Object.keys(c.slots) as SlotName[]).filter((k) => containsFunction(c.slots[k])); +} + +// --- localization (decision 3) --------------------------------------------- +// +// Reads slot outputs captured DURING the same runs; there is no code path that +// re-runs to localize, because a fresh run is a different sample. + +/** Raw signal, deliberately NOT an attribution — see `localize`. */ +function slotOutputsAgree(captures: Capture[]): { agree: boolean; drifted: SlotName[] } { + const names = [...new Set(captures.flatMap((c) => Object.keys(c.slots) as SlotName[]))]; + const drifted = names.filter((name) => { + const first = JSON.stringify(captures[0]?.slots[name]); + return captures.some((c) => JSON.stringify(c.slots[name]) !== first); + }); + return { agree: drifted.length === 0, drifted }; +} + +interface Attribution { + /** `recipe` — ours to fix here. `seam` — a framework finding, filed not repaired. */ + verdict: "recipe" | "seam"; + detail: string; +} + +function localize(captures: Capture[]): Attribution { + // The constraint FIRST. Spelled the obvious way — slots differ → recipe, else + // → seam — this step emits a confident `seam` for a recipe whose nested + // formatter the capture never saw: a false framework finding, which under + // decision 3 pauses the epic. + const unresolved = [...new Set(captures.flatMap(unresolvedSlots))]; + if (unresolved.length > 0) { + return { + verdict: "recipe", + detail: + `slot(s) [${unresolved.join(", ")}] returned an unresolved function, so their per-call values ` + + `never entered the capture. Attribution to the seam is unavailable — fix the recipe first`, + }; + } + const { agree, drifted } = slotOutputsAgree(captures); + return agree + ? { verdict: "seam", detail: "every slot returned the same value on every pass" } + : { verdict: "recipe", detail: `slot output varies between passes: ${drifted.join(", ")}` }; +} + +// --- the checks ------------------------------------------------------------ + +const PASSES = 8; +const [ISSUE_A, ISSUE_B] = WORLD.issues.map((i) => i.id) as [string, string]; + +await runGoal(async () => { + const failures: string[] = []; + + // S0 — setup honesty guard. The two issues must be distinguishable, or the + // leak check could pass (or fail) on an overlap rather than on a real leak. + const overlaps = identifyingFacts(ISSUE_A).flatMap((x) => + identifyingFacts(ISSUE_B).filter((y) => collides(x, y)).map((y) => `${x} ~ ${y}`), + ); + if (overlaps.length > 0) { + return { + failures: [ + `setup invalid: the two fixture issues have overlapping identifying facts, so the ` + + `leak check cannot distinguish them: ${overlaps.join("; ")}`, + ], + evidence: "", + }; + } + + // NOT guarded here, deliberately: a fixture whose CONTENT contains one of the + // region labels. Two attempts at that guard over-rejected valid worlds in + // opposite directions, and it was never protecting anything — the collision it + // describes is one instance of a broader limit (see `goal.md` → coverage): this + // check grades by substring over rendered text, and every guard bolted onto + // that is a patch on the approach rather than a fix. Tracked as its own issue. + + // S1 — eight passes over the same issue, each on a fresh copy of the world. + const eight: Capture[] = []; + for (let i = 0; i < PASSES; i += 1) { + eight.push(await assemble(freshWorld(), ISSUE_A, reviewGrounding, `pass-${i}`)); + } + if (!briefsAgree(eight)) { + const where = localize(eight); + failures.push( + `the ${PASSES} passes were NOT byte-identical. Localized to the ${where.verdict}: ${where.detail}. ` + + (where.verdict === "recipe" + ? "That is this recipe's own formatter drifting — ours to fix here, NOT a framework finding." + : "Slot outputs were stable across the same runs, so the drift is in the assembly seam — " + + "report and stop (decision 3); do not repair it here."), + ); + } + + // S2 — the precondition the standing/changing derivation depends on. + const preFail = preconditionFailure(eight[0]!.messages); + if (preFail !== undefined) { + failures.push(`standing/changing boundary is not derivable: ${preFail}`); + } + + const a = eight[0]!; + const b = await assemble(freshWorld(), ISSUE_B, reviewGrounding, "issue-b"); + + // S3 — the brief carries every contribution it claims to. Without this the + // shape can stay perfectly stable while the content drains away. + const standingMissing = missingFrom(standingContributions(), (l) => + standingRegion(standingText(a), l.path), + ); + if (standingMissing.length > 0) { + failures.push( + `the standing half is missing contributions it claims to carry, or carries them under the ` + + `wrong heading: ${standingMissing.join(", ")}`, + ); + } + for (const [id, capture] of [ + [ISSUE_A, a], + [ISSUE_B, b], + ] as const) { + const tailMissing = missingFrom(changingContributions(id), (l) => + tailRegion(changingText(capture), tailRegionIndex(l.path)), + ); + if (tailMissing.length > 0) { + failures.push( + `${id}'s changing half is missing contributions it claims to carry, or carries them ` + + `under the wrong label: ${tailMissing.join(", ")}`, + ); + } + } + + // S4 — two DIFFERENT issues. Standing half holds; the changing half actually + // changes and carries its own identity, not the other's. Without the last two, + // a recipe that silently assembled issue A twice passes every other signal. + if (preFail !== undefined) { + failures.push("the two-issue signals were not evaluated — the boundary precondition failed above"); + } else { + if (standingHalf(a) !== standingHalf(b)) { + failures.push("the standing half changed between two different issues — the split does not hold"); + } + if (changingHalf(a) === changingHalf(b)) { + failures.push( + "the changing half is IDENTICAL for two different issues — issue B was never really assembled, " + + "so the standing-half comparison above compared a brief with itself", + ); + } + for (const [id, capture, other] of [ + [ISSUE_A, a, ISSUE_B], + [ISSUE_B, b, ISSUE_A], + ] as const) { + const leaked = identifyingFacts(other).filter((f) => changingText(capture).includes(f)); + if (leaked.length > 0) { + failures.push(`${id}'s changing half carries ${other}'s facts: ${leaked.join(", ")}`); + } + } + } + + // A1/A2 — anti-game: a per-call COUNTER in the grounding (never the clock — + // in-process assemblies can share a tick). The same named comparator must + // return false, and localization must attribute it to the recipe. Two + // assemblies suffice: a per-call counter differs on the second. The primary + // loop runs eight because that is the claim's language; the canary has no such + // obligation. + let calls = 0; + const countingGrounding = (w: World): unknown => ({ + ...(reviewGrounding(w) as Record), + drift: `call ${(calls += 1)}`, + }); + const canary: Capture[] = []; + for (let i = 0; i < 2; i += 1) { + canary.push(await assemble(freshWorld(), ISSUE_A, countingGrounding, `canary-${i}`)); + } + if (briefsAgree(canary)) { + failures.push( + "the drift canary went GREEN: the comparator could not detect a per-call counter in the " + + "grounding, so every other signal above is decoration", + ); + } + const canaryWhere = localize(canary); + if (canaryWhere.verdict !== "recipe") { + failures.push( + `localization misattributed the drift canary to the ${canaryWhere.verdict} (${canaryWhere.detail}). ` + + `The canary's drift is a recipe formatter; calling it a framework finding is the expensive ` + + `direction of decision 3's failure mode.`, + ); + } + + // A3/A4 — the constraint's own anti-game. A nested context function drifts the + // brief while its top-level slot value looks unchanged: the raw slot signal + // says "stable" (the hazard), the guard sees the unresolved function, and + // localization therefore refuses to blame the seam. + let nested = 0; + const nestedGrounding = (w: World): unknown => ({ + ...(reviewGrounding(w) as Record), + drift: () => `call ${(nested += 1)}`, + }); + const nestedRuns = [ + await assemble(freshWorld(), ISSUE_A, nestedGrounding, "nested-0"), + await assemble(freshWorld(), ISSUE_A, nestedGrounding, "nested-1"), + ]; + if (briefsAgree(nestedRuns)) { + failures.push("setup invalid: the nested-drift variant did not actually drift the brief"); + } + if (!slotOutputsAgree(nestedRuns).agree) { + failures.push( + "characterization drifted: the RAW slot signal was expected to look stable for a nested " + + "formatter (that is the hazard the constraint exists for), but it detected the drift. " + + "If the capture now sees nested values, the constraint may be relaxable — re-derive it.", + ); + } + if (nestedRuns.flatMap(unresolvedSlots).length === 0) { + failures.push( + "the recipe constraint guard did NOT fire on a nested context function — the guard is " + + "decoration, and nothing stands between localization and a false framework finding", + ); + } + const nestedWhere = localize(nestedRuns); + if (nestedWhere.verdict !== "recipe") { + failures.push( + `localization blamed the ${nestedWhere.verdict} for a nested RECIPE formatter — the false ` + + `framework finding decision 3 must never emit. The constraint check has come loose from the ` + + `attribution; it has to run inside localize(), not beside it.`, + ); + } + + // The brief itself is the product of this issue. Put it in front of the human. + console.log(`\n===== the brief, issue ${ISSUE_A} =====\n${textOf(a.messages)}\n`); + console.log(`===== the brief, issue ${ISSUE_B} (standing half elided) =====\n${changingText(b)}\n`); + + const graded = standingContributions().length + changingContributions(ISSUE_A).length; + return { + failures, + evidence: + `${PASSES} passes of the review recipe, each over a fresh copy of the fixture world, handed the ` + + `model a byte-identical brief (${renderBrief(a.messages).length} bytes, standing half ` + + `${standingHalf(a).length}); the boundary precondition held (exactly one leading system ` + + `message); each pass called the model exactly once, so no handoff was overwritten; all ` + + `${graded} contributions the brief claims to carry were present, derived by walking the ` + + `fixture rather than hand-listed and graded on their rendered placement, not bare presence, ` + + `so a value under the wrong label fails; assembling ${ISSUE_B} instead left the standing ` + + `half unchanged while the changing half differed, carried its own contributions and none of ` + + `${ISSUE_A}'s identity. The comparator is proved able to fire: the same named comparator over ` + + `a grounding that appends a per-call counter returned false, and localization attributed ` + + `it to the recipe (${canaryWhere.detail}) rather than the assembly seam. The recipe constraint ` + + `is proved able to fire too: for a nested context formatter the raw slot signal looks stable — ` + + `the hazard — the guard sees the unresolved function, and localization consequently refuses to ` + + `blame the seam. Model n/a throughout — the stub records what it was handed and its legacy ` + + `generate() throws, so the assembly measured is the framework's own.`, + }; +});