Skip to content

fix(review-exclude): ready binds an older digest when no selection holds a PR file; name scan greps consumers only (GST-1434, GST-1435) - #4036

Merged
capy-ai[bot] merged 3 commits into
mainfrom
capy/gst-1434-review-exclude-ready-scan
Nov 5, 2026
Merged

capy-ai[bot] merged 3 commits into
mainfrom
capy/gst-1434-review-exclude-ready-scan

Conversation

@garrytan

@garrytan garrytan commented Nov 5, 2026 •

Copy link
Copy Markdown
Owner
{
  "schema_version": 1,
  "pr": 4036,
  "head": "c1243eaa16940dfd20347c4825d085d367f9c9be",
  "version": "1.96.0.0",
  "base": "main",
  "gate": {
    "free": {
      "pass": 1590,
      "fail": 0,
      "skip": 0
    }
  },
  "ci_carried": [
    {
      "lane": "free",
      "run": 42054283988,
      "attempt": 1,
      "tree": "9152abd60e7f068c0cfa2f850859c423183ee070"
    }
  ],
  "session_kind": "unattended",
  "head_tree": "9152abd60e7f068c0cfa2f850859c423183ee070",
  "product_patch_id": "51f95644d6ff9f4b8901de72c2a60882068ba68c",
  "gstack_version": "1.96.0.0",
  "review_depth": {
    "depth": "full",
    "class": "gate",
    "runtime_lines": 92,
    "rules": "70895942bb8a8ee2",
    "base": "467be16ab2f8d30ef1008e451c4ccad2814501c3",
    "registry": "467be16ab2f8d30ef1008e451c4ccad2814501c3",
    "gate_scan": {
      "tagged": 0,
      "head": "c1243eaa16940dfd20347c4825d085d367f9c9be"
    },
    "reasons": [
      "gate-class",
      "risk:money",
      "runtime=92"
    ],
    "risk": [
      "money"
    ],
    "mode": "panel"
  },
  "pregate": "pass @9152abd60e7f (7 checks, current for c1243eaa1694)",
  "issues": {
    "fixes": [],
    "refs": [
      269,
      274,
      276,
      278,
      4030
    ],
    "flakes": []
  },
  "docs": {
    "status": "updated",
    "scope": "AGENTS.md, CLAUDE.md, CONTRIBUTING.md, README.md and docs/ (authored docs naming review_exclude, the receipt, carry and the queue)"
  },
  "review_loop": {
    "passes": 2,
    "blocking_found": 1,
    "deferred": 0,
    "noted": 1,
    "fixed": 1,
    "scope": "frozen",
    "rounds": 2,
    "ledgers_read": 3,
    "unbound": 1,
    "dispatches": {
      "specialist": 2,
      "red-team": 2
    }
  },
  "review_targeted": {
    "classes": [
      "money"
    ],
    "rules": "30e6bce187be0d59",
    "brief_sha": "7f92a0d0a8319c3c0e076fb3b1a4689c45120b2be2c14dfc7d4cb03aafa9d6a5",
    "product_patch_id": "51f95644d6ff9f4b8901de72c2a60882068ba68c",
    "status": "done",
    "findings": 0,
    "raised_by": "targeted"
  }
}

What changed

On a 6,500-file results PR the review pass used to time out its name scan, keep every file and stop over the diff ceiling; now it excludes the data and plans every reader in about 13 s

On a 6,500-file results PR the review pass used to time out its name scan, keep every file and stop over the diff ceiling; now it excludes the data and plans every reader in about 13 s.

Before/after as text: On a 6,500-file results PR the review pass used to time out its name scan, keep every file and stop over the diff ceiling; now it excludes the data and plans every reader in about 13 s
--- Before · before.txt · captured output
+++ After · after.txt · captured output
+$ gstack-review-dispatch pass --base main --voices -- --gate-tagged 0   # this branch 99946df, same tree
+REVIEW_EXCLUDE: patterns=1/1 excluded=6500 bytes=26187790 kept=0 content=data:6500
+DIFF_CMD: targeted git diff <diff-base> -- . ':(top,exclude,glob)results/**'
+pass exit=0 after about 13 s
-$ gstack-review-dispatch pass --base main --voices -- --gate-tagged 0   # main 467be16, harness-evals #279 shape
-REVIEW_EXCLUDE: patterns=0/1 excluded=0 bytes=0 kept=6500 content=none
-REVIEW_EXCLUDE_KEPT: consumer-scan-unavailable results/run-0/case-0/result.json
-... (6,500 files kept: the name scan timed out)
-gstack-review-dispatch pass: the reader's diff is over the review ceiling (reader=adversarial-native bytes=27721060 max=2000000 top=results:27721060 policy=origin/main@f5a2b76c3078); fix: still over a...
-pass exit=3 after about 249 s
 

GST-1434. gstack-ship-queue ready (and train build and land, through bindShippedReceipt) now binds a receipt whose recorded review_exclude digest is older than the base policy's when neither the recorded selection nor HEAD's holds a file the PR changed. It reuses carryExcludeBinds, the predicate carry has used since #4030, so carry and the queue apply one rule. A selection that holds a PR file (excluded or kept, on either side) and an unreadable base policy still refuse.

GST-1435. The named-by-code scan in lib/review-exclude.ts ran one git grep -F -o -f <candidates> over the whole tree at the head and the merge base. It now lists each tree, keeps only consumer files (code and tests outside the candidates, the same consumer() filter as before) and greps those through literal pathspecs in 24 KB chunks. Data under the patterns is never read. A git failure or timeout still returns null, so every candidate stays kept as consumer-scan-unavailable. After review, a consumer whose name does not survive UTF-8 decoding also returns null, because its literal pathspec would match nothing and the data it names would be excluded instead of kept.

Why

harness-evals #274 and #276 were refused by ready after policy PR #278 merged (recorded=5ae7e95a07b5 expected=323c17cf6249) though neither PR touches a pattern. On #269 the whole-tree grep took 278 s against its 120 s limit and kept all 4,354 files (30 MB), which put the PR over every reviewer and carry cap. Now those receipts bind, and the scan's cost follows the code a results PR can be read by rather than the data it adds.

Proof

  • Failing first: the #274 shape test was red on main (RECEIPT_INVALID field=review_exclude) and is green here; the consumer scan greps only consumer files was red on main (git grep got no pathspecs) and is green here. The review fix's test (a consumer whose name is not valid UTF-8 keeps the candidates) was red at 99946df and is green at 5c7b0ef.
  • Synthetic tree (300 code files, receipts/** on the base policy, result.json files that name each other's paths), reviewExclude at the head, 4-core Capy machine:
data files (bytes) main 467be16 this branch
1,000 (6.7 MB) 16.6 s 0.5 s
4,300 (29.1 MB) 120.3 s, timed out: excluded=0, kept=4,300 consumer-scan-unavailable 1.9 s, excluded=4,300
harness-evals #279 shape: base policy results/**, 6,500 results files, 27.7 MB diff, gstack-review-dispatch pass --base main --voices -- --gate-tagged 0 (targeted reader in the voices stage) exit 3 after about 249 s: REVIEW_EXCLUDE excluded=0 kept=6500, REVIEW_DIFF_TOO_LARGE (bytes=27721060 max=2000000) exit 0 in about 13 s: excluded=6500, bytes=26187790, targeted reader planned with DIFF_CMD git diff <diff-base> -- . ':(top,exclude,glob)results/**'

The remaining growth comes from the per-candidate steps (pattern count, blob sniffing), not from the scan reading the data.

Blast radius

excludeMismatch only accepts more receipts, exactly those carryExcludeBinds already accepts at carry; its one caller is bindShippedReceipt (lib/ship-receipt-depth.ts:444), which refuses an unreadable policy before it gets there (file:line read, and the red-team reader traced it). The scan change affects which files git grep reads, not which references count, because the consumer filter only looks at paths (script ran: the focused file passes 36 of 36). One existing GST-1408 test asserted the old refusal of an older digest; it is replaced by the #274-shape test plus refusal cases for a PR file in either selection and an unreadable policy.

Approvals

No approvals recorded for branch capy/gst-1434-review-exclude-ready-scan.

Summary

Results PRs in harness-evals hit two walls in the merge checks: ready refused receipts after an unrelated review_exclude_paths edit on main, and the review_exclude name scan timed out on large result sets and kept every file. The queue now uses carry's rule for a policy change that touches none of the PR's files, and the scan reads only code and tests. Review added one fail-closed guard for file names git cannot hand back through a literal pathspec, and the docs audit corrected the matching paragraph in docs/troubleshooting.md.

Test Coverage

All new code paths have test coverage. Coverage: deterministic (each of 4 changed runtime files has a changed test naming it; no audit reader).
Tests ran: free 1590 (files, carried from CI run 42046075541/1 at 99946df; the final head's run is carried in accept)

Pre-Landing Review

Pass 1 (full panel: batched specialist, red team, targeted, Claude adversarial, outside voice on openai/gpt-6.1-sol): one blocking finding, found by the outside voice and confirmed by the adversarial reader. grepFixed decoded the tree listing as UTF-8, so a consumer with a non-UTF-8 name became a pathspec that matched nothing and the data it names was excluded instead of kept. Fixed in 5c7b0ef with a failing-first test. Pass 2 (full on the range): no blocking findings.

REVIEW_LOOP: passes=2 blocking_found=1 deferred=0 noted=1 fixed=1 scope=frozen unbound=1 ledgers_read=3 dispatches=4

(unbound=1 is the fix commit's second Review-Finding trailer, p1/adversarial-native#1, which the judge folded into p1/outside-voice#1 as a duplicate.)

Gate edits: none detected (3 listed, 2 read; patterns: RH-1,RH-3,RH-4,RH-12,RH-13,RH-14,RH-15,RH-16; unlisted idioms: none)

Outside review: completed (openai/gpt-6.1-sol, host subagent); its one finding is fixed.

Review notes

Below the blocking floor (advisory, informational, test-gap or wording items); recorded here and not fixed in this PR.

  • INFORMATIONAL lib/review-exclude.ts:256 timeout: each chunk keeps the 120 s git timeout, but the scan has no overall limit, so a very large code tree could outlast its caller's timeout before any chunk times out.
  • INFORMATIONAL docs/ship-policy.md:1429 docs: with no head, the scan lists the index through ls-files rather than a tree, and untracked files are not grepped (unchanged from main).
  • INFORMATIONAL lib/review-exclude.ts:261 testing: one non-UTF-8 consumer name anywhere in the tree makes the scan keep every candidate for that repo, with no line naming the cause. It fails safe; a REVIEW_EXCLUDE note naming the file would make the cause visible.
  • Unconfirmed (red team, pass 2): on macOS with core.precomposeUnicode=true, a consumer stored under a decomposed (NFD) name might not match its literal pathspec. Not reproducible on Linux.

Exploratory QA

Status: pass (smoke, 4 probes at 5c7b0ef, functional surface: the ship-queue receipt binding and the review_exclude name scan, through the repository's focused tests; the 3-probe run at 99946df is superseded by this one after the review fix).

  • 001 the CodeBuddy adapter — all 21 skills ported and working #274 shape binds an older digest when neither selection holds a PR file: pass
  • 002 a differing digest still refuses when either selection holds a PR file: pass
  • 003 the consumer scan greps consumer files only and still finds full-path references: pass
  • 004 a consumer with a non-UTF-8 name keeps the candidates: pass

Limits: smoke only; no plan checks are bound to this branch.

Design Review

No frontend files changed — design review skipped.

Eval Results

No prompt-related files changed — evals skipped.

Review bot comments

No review bot comments.

Scope Drift

Scope Check: CLEAN

Plan Completion

Plan completion audit: not run (no plan is bound to this branch and no docs/designs/ file matches). Fix: add "Plan: " to the PR body, or run /autoplan.

Issues

Refs #269
Refs #274
Refs #276
Refs #278
Refs #4030
Refs p1/adversarial-native#1
Refs p1/outside-voice#1

Verification Results

No Step 8.1 obligations (no plan is bound to this branch).

TODOS

No TODO items completed in this PR.

Documentation

Status: updated. One stale paragraph in docs/troubleshooting.md was corrected.

Scope: the diff from base 467be16 to head 5c7b0ef plus the unstaged changelog fragment. That covers the review-exclude name scan (GST-1435) and the queue's ready check, which now follows carry's rule (GST-1434). I audited the authored docs that name review_exclude, the receipt, carry and the queue.

Documentation health:

  • docs/ship-policy.md: current. It already documents the consumer-only name scan, chunked literal pathspecs and the shared carry-and-queue exception.
  • docs/troubleshooting.md: updated. The field=review_exclude note said the queue skips only recorded=none receipts. It now says the queue binds any differing digest when neither selection holds a PR file.
  • docs/review-policy.md: current.
  • changelog.d/capy-gst-1434-review-exclude-ready-scan.md: reviewed only. It matches the behavior.

Coverage debt: none. Both changes are covered in reference form in ship-policy and troubleshooting. No diagram drift.

Test plan

  • bun run test (free lane): carried from CI run 42054283988/1 at c1243ea, tree 9152abd60e7f, 1590 files
  • bun --no-env-file test --timeout=30000 test/review-exclude.test.ts: 36 pass, 0 fail at 5c7b0ef
  • gstack-pregate --allow-repo-commands: PREGATE: pass tree=9152abd60e7f head=c1243eaa1694 checks=7

🤖 Generated with Claude Code

Open in Capy

…lds a PR file; the name scan greps consumers only (GST-1434, GST-1435)

GST-1434: gstack-ship-queue ready (and train build, land) refused any receipt whose
recorded review_exclude digest differed from the base policy's, so a policy edit on
main voided every receipted PR even when no PR file fell under a pattern
(harness-evals #274, #276 after #278). excludeMismatch now uses carryExcludeBinds,
the predicate carry uses since #4030: a digest change binds when neither the recorded
selection nor HEAD's holds a file the PR changed; anything else still refuses.

GST-1435: the named-by-code scan ran git grep over the whole tree, so on
harness-evals #269 it searched 30 MB of receipts for 4,354 candidate paths, ran
278 s past its 120 s limit and kept every file. It now lists each tree, keeps the
consumer files (code and tests outside the candidates) and greps only those through
literal pathspecs in 24 KB chunks. A git failure or timeout still keeps every
candidate.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@trunk-io

trunk-io Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

😎 This pull request was merged.

garrytan and others added 2 commits November 5, 2026 15:10
grepFixed keeps every candidate when a consumer's name does not survive UTF-8 decoding, since its literal pathspec would match nothing.

Review-Finding: p1/outside-voice#1 reader=outside-voice
Review-Finding: p1/adversarial-native#1 reader=adversarial-native
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@capy-ai
capy-ai Bot marked this pull request as ready for review November 5, 2026 15:31
@capy-ai
capy-ai Bot merged commit 6278ee4 into main Nov 5, 2026
46 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant