Skip to content

/ship's review plan finishes on repositories with large trial files (HARN-98) - #4651

Merged
capy-ai[bot] merged 8 commits into
mainfrom
review-consumer-scan-fast
Nov 22, 2026
Merged

capy-ai[bot] merged 8 commits into
mainfrom
review-consumer-scan-fast

Conversation

@garrytan

@garrytan garrytan commented Nov 22, 2026 •

Copy link
Copy Markdown
Owner

/ship's review plan no longer runs out of time on results repositories whose trial files name many data files. On harness-evals #551 the scan now takes about 40 s instead of running past its limit.
Why: harness-evals #551 is blocked on it. git's grep -o with about 80 file names took 220 s on one 16 MB trials file, and the plan timed out at 1,703 s.
Nothing to do.

What changed

Results repositories hit a review plan that never finished. The scan that decides whether a changed data file is read by code ran git grep -o with every data file name, and git's -o retries every name after each match, so one 16 MB trials file took 220 s. The scan now lists the files that can hold a name once per scan, finds the ones that do with git grep -l over a scratch index, and picks their matches itself the way -o does (earliest start, longest name there, then on from its end), so its output is byte-identical to the old grep.

  • Matching files are read a bounded amount at a time, with blobs in git cat-file --batch calls of at most 64 MB, working-tree files one at a time, and a file larger than the output cap goes back to git's own -o grep. Lines are added one at a time against the byte cap, so a file with a million matches gives git's lines or fails closed instead of crashing.
  • The scratch index lives under the repository's git directory, so an unwritable TMPDIR no longer fails the scan; a directory it cannot create is a named scan failure.
  • Untracked, unmerged and non-regular files go back to git by pathspec. Non-UTF-8 names and patterns that hold a newline keep the old whole-tree -o path.
  • scanConsumers credits each match through a per-depth lookup instead of testing every probe against every line (about 50 s on feat: design binary — real UI mockup generation for gstack skills (v0.13.0.0) #551).
  • Docs: docs/review-policy.md (consumer scan). Changelog fragment added.
Evidence
  • harness-evals feat: design binary — real UI mockup generation for gstack skills (v0.13.0.0) #551 at e3f2a019 (304,000 files), 4-core machine. Before: the scan ran past its 120 s deadline (consumer_scan_failed). Given an unbounded deadline, it took 2,382 s and found 1,327 consumed data files. After: the commit scan took 38 s and the working-tree scan took 39 s, and both found the identical 1,327 files.
  • Byte-identical output: the existing whole-tree comparisons in test/review-collect.test.ts pass unchanged, including the overlap fixture, 1.1M matches and the byte cap. The new test/review-consumer-scan-speed.test.ts compares against git grep -o on a seeded fixture with overlapping, nested and repeated names, an edited file, assume-unchanged and skip-worktree entries, an untracked file and a symlink, at a commit and in the working tree.
  • Failing-first timing test: 80 names over a 16 MB trials file with 400 names per line. The old scan times out at a 5 s deadline, and the new one finishes inside it.
Why

"The plan timed out at 1,703 s" on harness-evals #551 even with a 30-minute limit, which blocked that results PR. Results PRs with large trial files now get their review plan in about 40 s, with the same consumed-file answer as before.

Blast radius

The only caller is scanConsumers in lib/review-collect.ts, which feeds the review depth; every scan failure still returns consumer_scan_failed and fails the depth closed (walked failure path, lib/review-collect.ts). Output equality with git grep -o is checked by seeded differential tests at a commit and in the working tree (script ran), and reviewers compared 19 more edge-case repos byte for byte.

Test Coverage

Coverage: 65% of the 17 new code paths (11 covered, 4 strongly); the 6 gaps are fail-closed error branches and rare fallbacks.
Tests: 1859 → 1860 test files (+1 new: test/review-consumer-scan-speed.test.ts with 4 tests).
Tests ran: focused 35
Tests ran: tests 1740 (files, from CI run 44984635840)

Pre-Landing Review

Two full review passes, a second-model review, an adversarial read and a targeted read. Fixed: blob bodies read under one 256 MB buffer at a commit, a whole chunk of working-tree files held in memory at once, and a crash when git's fallback returned about a million matches. A later CI failure (an unwritable TMPDIR) was fixed by moving the scratch index under the git directory. The second-model review (openai/gpt-6.1-sol) found the crash; it was fixed and rechecked clean.

Review notes

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

  • INFORMATIONAL lib/review-collect.ts:283 The output cap is checked only after a whole chunk of matches is collected in memory (now checked per line as lines are added).
  • INFORMATIONAL lib/review-collect.ts:172 With core.splitIndex=true the scratch update-index writes a sharedindex file into the real .git.
  • INFORMATIONAL lib/review-collect.ts:172 A temp-directory failure threw instead of returning a scan failure (since fixed: it is now a named scan failure).
  • INFORMATIONAL test/review-consumer-scan-speed.test.ts:86 The 5 s wall-clock bound may flake on a loaded runner (the scan measures about 0.5 s there).
  • INFORMATIONAL lib/review-collect.ts:176 update-index verify_path may refuse historical paths, failing the scan closed.
  • INFORMATIONAL test/review-consumer-scan-speed.test.ts:66 The batch/oversize equality test also passes on the code before that fix.
  • INFORMATIONAL lib/review-collect.ts:290 No test covers the cat-file --batch-check missing-object or size-mismatch failure branches.
  • INFORMATIONAL lib/review-collect.ts:174 A deadline that hits the new rev-parse in a linked worktree reports an unwritable directory instead of a timeout (still fails closed).
  • INFORMATIONAL lib/review-collect.ts:176 A killed scan leaves its scratch index under .git/gstack-consumers; nothing sweeps them.
Exploratory QA

Smoke, 2 probes: the 16 MB, 80-name trials fixture scans in 537 ms at a commit and 327 ms in the working tree with 586,800 identical lines each; the batch and oversize equality test passes. No failed, blocked or not-run probes.

Eval Results

No prompt-related files changed — evals skipped.

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). Bug fix, plan exempt.

Issues

Refs #538
Refs #551
Refs p1/red-team#1
Refs p1/specialist-batched#1
Refs v1/outside-voice#1

TODOS

No TODO items completed in this PR.

Documentation

Status: current. The docs already match the change, so no edits were made.

Scope: the committed diff from 8d0e827 to a80aefc on review-consumer-scan-fast: lib/review-collect.ts, docs/review-policy.md, changelog.d/review-consumer-scan-fast.md and test/review-consumer-scan-speed.test.ts. There are no staged, unstaged or new files.

Documentation health:

  • docs/review-policy.md: Current. The consumer-scan paragraph matches the code: one extension pass per scan for each commit and the working tree, a scratch index read with git grep -l, and matches picked the way -o picks them (byte-identical results). The 120 s deadline and 256 MB cap are unchanged.
  • docs/ship-policy.md: Current. The review-exclude name scan is unaffected.
  • changelog.d/review-consumer-scan-fast.md: Current. It is consistent with the code and the policy doc.
  • docs/troubleshooting.md: Current, with one gap noted below.

Coverage debt: the scan's new scratch-index step has reference and explanation coverage in docs/review-policy.md. The new failure that names an unwritable scratch directory under the git directory has no troubleshooting.md entry (a common gap).

Diagram drift: none.

Tests
  • bun test test/review-collect.test.ts test/review-consumer-scan-speed.test.ts: 35 pass, 0 fail
  • bun test test/ship-receipt-carry-large-diff.test.ts test/review-collect.test.ts test/review-consumer-scan-speed.test.ts: 39 pass, 0 fail
  • bun run typecheck: clean
  • CI free-tests (run 44984635840, workflow_dispatch at a80aefc): green, 1740 test files
Agent notes

Lane GSTA-757 for GST-3425 (HARN-98, relayed through HARN-1). Built on #4643 (merged).

Open in Capy

REVIEW_LOOP: passes=2 blocking_found=1 deferred=0 noted=9 fixed=3 scope=frozen ledgers_read=7 fix_checks=2 dispatches=8
Gate edits: none detected (GATE_SCAN tagged=0)

Approvals

Approved: yes (record r-0102f706aa29). The full approval record stays private.
Plan: exempt: bug fix GST-3425 under the GSTA-36 brief
Plan check: exempt bug fix

{
  "schema_version": 1,
  "pr": 4651,
  "head": "a80aefc1d9d6f7ab46c2ebd5664e19150ee2e4f9",
  "version": "1.102.2.0",
  "base": "main",
  "gate": {
    "focused": {
      "pass": 35,
      "fail": 0,
      "skip": 0
    },
    "tests": {
      "pass": 1740,
      "fail": 0,
      "skip": 0
    }
  },
  "ci_carried": [
    {
      "lane": "tests",
      "run": 44984635840,
      "attempt": 1,
      "tree": "58f81a7a18f010f31739e8dac82e25eba9a2f8a0"
    }
  ],
  "calls": 61,
  "session_kind": "unattended",
  "run": "ship-4651",
  "head_tree": "58f81a7a18f010f31739e8dac82e25eba9a2f8a0",
  "product_patch_id": "fc7cfc32418040cba2d60b54feb4f420746f94c5",
  "gstack_version": "1.102.2.0",
  "review_depth": {
    "depth": "full",
    "class": "gate",
    "runtime_lines": 198,
    "rules": "630fd3101899e28e",
    "base": "6963fa8089afbce2a36a4839b2b8986f2e4b2f81",
    "registry": "6963fa8089afbce2a36a4839b2b8986f2e4b2f81",
    "gate_scan": {
      "tagged": 0,
      "head": "a80aefc1d9d6f7ab46c2ebd5664e19150ee2e4f9"
    },
    "reasons": [
      "gate-class",
      "risk:money",
      "risk:security",
      "runtime=198"
    ],
    "risk": [
      "money",
      "security"
    ],
    "mode": "panel"
  },
  "pregate": "requires-remote cleared @58f81a7a18f0 (8 checks, current for a80aefc1d9d6)",
  "requires_remote": [
    "free-tests.yml/macos-named-regressions: https://github.com/garrytan/gstack/actions/runs/44984635840/attempts/1",
    "windows-smoke.yml/windows-smoke: https://github.com/garrytan/gstack/actions/runs/44984276468/attempts/1",
    "pregate.json/remote_gate: remote-gate tree=58f81a7a18f0 tests=38756 skipped=65 runs=44984635840/1 profiles=ci-reuse/free-tests heads=a80aefc1d9d6 verified=2026-11-22T04:26:42.834Z"
  ],
  "issues": {
    "fixes": [],
    "refs": [
      538,
      551
    ],
    "flakes": []
  },
  "docs": {
    "status": "current",
    "scope": "docs/ and README.md (151 docs files hashed; review-policy.md, ship-policy.md, inventory.md and the changelog fragment read)"
  },
  "review_loop": {
    "passes": 2,
    "blocking_found": 1,
    "deferred": 0,
    "noted": 9,
    "fixed": 3,
    "scope": "frozen",
    "fix_checks": 2,
    "rounds": 2,
    "ledgers_read": 7,
    "dispatches": {
      "specialist": 6,
      "red-team": 2
    }
  },
  "review_round_grants": [
    {
      "kind": "fix-check",
      "head": "eae963f54d3e5550f847e46147d6295cfcff3f93",
      "pr": 4651,
      "by": "GSTA-36",
      "reason": "Regression in the PR's own lines: ~1M grep lines spread into one push throw RangeError and crash the planner; fix appends per line with a byte cap; failing-first 1.2M-match test.",
      "at": "2026-11-22T02:59:08.454Z",
      "approval": "a-f4ae5bd0edee",
      "stop_run": "ship-4651",
      "findings": [
        "v1/outside-voice#1"
      ]
    },
    {
      "kind": "fix-check",
      "head": "30dd58a93bc1254ed0cbb26b7601be202e4ee6f0",
      "pr": 4651,
      "by": "GSTA-36",
      "reason": "free-suite (2) GST-448 failure: the scratch index moves under `git rev-parse --git-path gstack-consumers`, and a directory it can't create fails closed as a named scan failure.",
      "at": "2026-11-22T04:07:26.460Z",
      "approval": "a-eb826d7f6865",
      "stop_run": "ship-4651",
      "findings": [
        "ci/free-suite-2-gst448"
      ]
    }
  ],
  "gate_dispositions": [],
  "review_targeted": {
    "classes": [
      "money"
    ],
    "rules": "b3f6f8b4843c0c30",
    "brief_sha": "7f92a0d0a8319c3c0e076fb3b1a4689c45120b2be2c14dfc7d4cb03aafa9d6a5",
    "product_patch_id": "fc7cfc32418040cba2d60b54feb4f420746f94c5",
    "status": "done",
    "findings": 0,
    "raised_by": "targeted"
  }
}
{"head":"eae963f54d3e5550f847e46147d6295cfcff3f93","run":"ship-4651","mark":"stop","tree":"171b018c735a095946df9956f0e607ca4651010f"}

garrytan and others added 5 commits November 21, 2026 23:52
…eview, and the consumer-scan cap can be raised (HARN-64)

The exclusion's name scan used git grep -o with every candidate path, which ran past its
120 s bound on harness-evals #538 (2,140 paths in one pins.sha256), so every file stayed in
review. It now lists hit files with git grep -l and reads each one, and a file whose lines are
all digests and paths names nothing. Those manifest lines also no longer set money, security,
data or eval risk; secret lines still count. GSTACK_REVIEW_CONSUMER_SCAN_CAP raises the
2,000-file consumer-scan cap, and a tripped cap prints a CONSUMER_SCAN line naming both fixes.

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

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

# Conflicts:
#	bin/gstack-review-plan
Planning 460 recent main commits across gstack, harness-evals and gstack-evals with the old
and new rules gives the same class and risk classes on all 460 (replay HARN-64).

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…HARN-98)

The consumer scan ran git grep -o with every data basename, and git's -o retries every
pattern after each match: on harness-evals #551 one 16 MB trials file took 220 s. The scan
now lists candidate files once per scan, greps a scratch index of them with -l, and picks
the matches itself the way -o does, so its lines are byte-identical. #551's scan takes
about 40 s instead of passing its 120 s deadline.

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

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

# Conflicts:
#	docs/review-policy.md
#	lib/review-exclude.ts
#	test/review-exclude-pin-manifest.test.ts
@capy-ai
capy-ai Bot changed the base branch from review-scan-cap-and-hash-manifests to main November 22, 2026 02:24
@trunk-io

trunk-io Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

😎 This pull request was merged.

garrytan and others added 3 commits November 22, 2026 02:42
At a commit it reads blobs in cat-file batches of at most 64 MB, in the working tree it reads one file at a time, and a file larger than the output cap goes to git's own -o grep, so many large trial files no longer fail the scan or exhaust memory. (HARN-98)

Review-Finding: p1/specialist-batched#1 reader=testing
Review-Finding: p1/red-team#1 reader=red-team
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…es for one file

Lines from git's fallback grep are now added one at a time, and the byte cap is checked as each line is added, so a large file with about a million name matches gives git's lines or fails closed instead of throwing RangeError. (HARN-98)

Review-Finding: v1/outside-voice#1 reader=outside-voice
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
The scan's scratch index now lives under the repository's git directory, as patch-id diffs do, so an unwritable TMPDIR no longer throws; a directory it cannot create fails the scan closed with a named error. (HARN-98)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@capy-ai
capy-ai Bot merged commit c2b4f0d into main Nov 22, 2026
76 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