You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(capture): cite tracked prose in gate refusals - #531
When tracked prose helps settle a gate refusal, where now appends the repo-relative file for the matched passage after the command declarations. This uses the same file representation as the tracked-text branch. The existing matched field still carries the scrubbed, bounded candidate span, including its prose. Verdicts and evidence field types are unchanged.
Windows verification: all 137 case-bank tests passed. The new assertion failed before the fix. A second mutation that cited the first scanned file instead of the matching file also failed. The command-only control cites only the declaration.
Implemented with GPT-6.2 Sol in T3 Code. Claude Opus independently reviewed the change before publication and reproduced the issue and the citation fix.
Review — PR #531fix(capture): cite tracked prose in gate refusals
Seat: combined architecture-conformance + code review (one reviewer bot holding both seats; disclosed). Heads: head 59bcad8 vs base 6c743ff (current main; merge-base confirmed — the diff is exactly git diff 6c743ff..pr531). Scratch: fresh git archive of pr531 into a throwaway dir with a symlinked node_modules; main tree untouched. Everything below was run or opened there this session. Ticket #513 labels, measured: enhancement,capture,severity:medium,tier:standard.
Tier honesty: the diff invents no predicate and no policy — it reuses the existing fileAt attribution and the already-computed restRegion, appending a string to an existing refusal field. tier:standard is honest.
Scope
Exactly two files, matching the claimed stat: bench/fixtures/availability-cases.ts (+17), src/capture/available.ts (+15/−6). Five hunks, all audited:
fixture — add tracked ACKNOWLEDGMENTS.md to gate-prose-settle-verbatim (availability-cases.ts:1052);
fixture — add expectWhere to gate-prose-settle-verbatim (:1049) and the new control case gate-prose-citation-declaration-only (:1065);
fixture — add expectWhere to gate-pairing-cross-command-refuse (:1085);
src/capture/available.ts:1201-1210 — declared_gate refusal appends fileAt(restRegion.start) to cited (deduped) when restRegion !== null.
Bank contract (module load, both sides — never source-grep)
import { AVAILABILITY_CASES } under bun in scratch trees of base and head:
base 6c743ff: 134 cases, 5 with expectWhere
head 59bcad8: 135 cases, 8 with expectWhere
Added ids: gate-prose-citation-declaration-only (the ticket-ordered control: command-only row, expectWhere: "package.json scripts.deploy"). Removed ids: none. Relative order of the 134 shared ids: identical.
The +17 is not pure append: two existing rows gained expectWhere (gate-prose-settle-verbatim, gate-pairing-cross-command-refuse) and gate-prose-settle-verbatim's files map gained a tracked ACKNOWLEDGMENTS.md. Checked against #513 §Constraints: the ticket orders "a bank row whose expectWhere names both the declaration and the region, plus a same-shape control" — strengthening these two rows is the ticket-ordered pin, and no existing expectation flips (tag/reason assertions byte-identical; expectWhere is purely additive, both rows pass pre-fix and post-fix on their older assertions). Nit recorded below.
Verdict-neutrality
Head case bank: 137 pass / 0 fail (bun test test/capture/availability-case-bank.test.ts, 202 expect() calls). Matches the author's claim; test-windows CI job passes, so the Windows claim is corroborated (I did not run Windows myself).
check() produces verdicts at exactly two sites: available.ts:1092-1096 (in_tracked_file) and available.ts:1211-1215 (declared_gate). Only the latter's where changed; reason and matched (safeWhole.slice(0, 120)) byte-identical, field types untouched (available.ts:68).
in_tracked_file (available.ts:1094): the refactor moves relative(...) || "?" from the call site into fileAt — same expression, same result string.
The citation fires only under restRegion !== null (available.ts:1207). restRegion is null exactly when the residual is empty (available.ts:1179-1180), so the command-only control branch keeps the pre-existing cited loop untouched.
fileAt has exactly two call sites (available.ts:1094, :1208); no other consumer of the old raw-name representation exists.
Mutations (both reproduced; tree restored byte-exact after, cmp clean)
(a) Revert available.ts to base → 135 pass / 2 fail, and the two failures are exactly the new assertions:
error: gate-prose-settle-verbatim: expected the refusal to cite [package.json scripts.deploy, README.md] — got [package.json scripts.deploy], so the evidence line does not name every declaration this verdict rested on
error: gate-pairing-cross-command-refuse: expected the refusal to cite [package.json scripts.rollback, README.md] — got [package.json scripts.rollback], …
The control row stays green under (a) — a base build cannot pass it by accident, and the head build must not cite prose there.
(b) Cite the FIRST scanned file instead of the matching file (fileAt(restRegion.start) → cite slices[0]) → 136 pass / 1 fail:
error: gate-prose-settle-verbatim: expected the refusal to cite [package.json scripts.deploy, README.md] — got [package.json scripts.deploy, ACKNOWLEDGMENTS.md], …
Note: only the ACKNOWLEDGMENTS.md row catches (b) — in gate-pairing-cross-command-refuse README happens to be scanned first, so the wrong-origin bug would slip past its expectWhere alone. The fixture edit is load-bearing mutation cover, not decoration.
Class audit — wrong-where this design admits
Citation when prose settled nothing — impossible: refusal requires rest.length === 0 || (restRegion !== null && coversAssertion(...)) (available.ts:1184-1187), and restRegion === null exactly on an empty residual (:1179-1180). A non-null region is the one the prose matched and the figure check (:1193-1199) tested.
Right file, wrong origin label — declarations cite label form (g.where, e.g. package.json scripts.deploy); prose cites the bare relative path — the same representation the tracked branch uses, as the ticket orders. The reader distinguishes them by form.
Duplicates — cited.includes guards both the declaration loop (:1206) and the prose push (:1209). If a prose file is already named by a declaration's where, it appears once; no information loss.
Ordering for existing consumers — declarations keep their order, prose appends last: append, not redefine (the ticket's log-tooling constraint). The only downstream consumer found is src/capture/runtime.ts:921, which copies avail.where into the evidence field verbatim — no parsing.
Non-refusal leakage — none: keep-paths return null; the two verdict sites are the whole production surface.
"?" sentinel appended after declarations — restRegion.start is a non-empty needle match start inside the haystack, and needles carry no \u0000 separator, so it falls inside a slice; the sentinel was already reachable on the tracked branch. No new reachable path.
Prose stated in two files — cites the first scanned slice, identical to the pre-existing in_tracked_file behavior of fileAt; consistent, not a new asymmetry.
Suite
Local full suite at head: 1848 pass / 22 skip / 0 fail (14975 expect(), 150 files). Baseline 1847/22/0 + exactly the one new bank case.
CI (gh pr checks 531): lint pass, smoke pass, test-windows pass, test fail — 1854 pass / 1 fail, the failure being cooldown shared across setup() registrations > an idle broadcast reaches every live subscription, and pays exactly ONE model call (test/capture/capture-compaction.test.ts:471). That test is timing-budgeted (waitFor + sleep(150), and its own comment admits "which loop wins the shared cooldown is scheduling luck"); it shares zero code paths with this diff. The same base's cooldown suite passed Linux CI on two adjacent PR runs minutes apart from the red run (runs 45697330118 @ 20:41, 45703204107 @ 21:19). Classification: environmental flake, not caused by this PR.
Prose
New comment (available.ts:1201-1202) and the two new fixture source strings carry no issue numbers, dates, or shas; ACKNOWLEDGMENTS.md fixture content is neutral prose. Neighboring sources follow the same convention. README untouched (diff is two files).
Verdict: APPROVE
nit (bank, non-blocking): two existing rows were strengthened rather than appended (expectWhere on gate-prose-settle-verbatim and gate-pairing-cross-command-refuse, plus files on the former). Within A gate refusal resting on a tracked passage cites only the declarations, not the passage #513 §Constraints — the ticket orders exactly these pins and nothing flips — but worth flagging since the bank's standing rule reads append-only.
follow-up (not this PR): the cooldown shared across setup() registrations test flaked red on this PR's CI run; consider hardening its timing budget on the Linux runner (it already has a comment conceding scheduling luck). Re-run the red test job before merge.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #513.
When tracked prose helps settle a gate refusal,
wherenow appends the repo-relative file for the matched passage after the command declarations. This uses the same file representation as the tracked-text branch. The existingmatchedfield still carries the scrubbed, bounded candidate span, including its prose. Verdicts and evidence field types are unchanged.Windows verification: all 137 case-bank tests passed. The new assertion failed before the fix. A second mutation that cited the first scanned file instead of the matching file also failed. The command-only control cites only the declaration.
Implemented with GPT-6.2 Sol in T3 Code. Claude Opus independently reviewed the change before publication and reproduced the issue and the citation fix.