Skip to content

v1.91.42.0 fix(cso): lift the snapshot file-count ceiling, bound report lists, actionable capacity errors - #3078

Merged
capy-ai[bot] merged 7 commits into
mainfrom
capy/fixwave-A-cso-file-ceiling
Oct 8, 2026
Merged

capy-ai[bot] merged 7 commits into
mainfrom
capy/fixwave-A-cso-file-ceiling

Conversation

@garrytan

@garrytan garrytan commented Oct 8, 2026

Copy link
Copy Markdown
Owner

/cso refused any repository with more than about 3,100 files before an audit started ("Snapshot manifest exceeds the 1 MiB private-state admission limit"). This PR lifts that ceiling to about 50,000 files. It does not make /cso work on every real-size repository: repositories with more than 64 MiB of tracked source, or with any tracked symlink, are still refused. The error now names the limit that applied and says what to do next.

What shipped

The snapshot list gets its own cap

  • snapshot.json is written as compact JSON and capped at 16 MiB (SNAPSHOT_MANIFEST_LIMIT, local to lib/cso/snapshot.ts). readJson takes a per-artifact cap. readSnapshotManifest(dir) is the only reader of snapshot.json: all 13 sites in cli.ts use it, and a source test fails if a direct read comes back. Every other private artifact keeps MAX_STATE_FILE at 1 MiB, and MAX_OUTPUT and contracts.ts are unchanged.
  • Pretty-printed manifests written by older releases still load in recheck and inspect.

The failure doesn't just move into the audit

  • boundedList (lib/cso/state.ts) keeps the first entries that fit a byte budget, measured as the pretty-printed JSON they add, and ends the list with one omitted-count item. It bounds these lists:
    • In report.json: the snapshot coverage gaps, exclusions and source transformations, under one 256 KiB budget split 128/96/32 KiB. Counts and status are computed before trimming, so they stay exact.
    • In sensitive-evidence.json: 512 KiB of evidence plus an omitted-count record.
  • The start/recheck stdout (the public report) is bounded the same way.
  • Git's path listings during capture (ls-files and ls-tree) were clamped at the shared 1 MiB process-output cap. That was the next wall: roughly 11k to 23k files depending on path length, and 7k to 10k with --diff/--base. runProcess now lets raw callers opt in to up to 16 MiB; non-raw callers keep the MAX_OUTPUT clamp.
  • Snapshot coverage and publicSnapshotPath no longer scan the whole manifest for every entry (that was O(n²)).

Actionable capacity errors

Measured on public repositories

Shallow clones measured 2026-10-08 with start --offline, before and after this PR:

Repository Files Tracked bytes main this PR Symlinks removed (scratch commit)
sveltejs/svelte 9,182 7,198,416 refused: manifest > 1 MiB pass: 2,957,206 B manifest, 10 KB report, 14 s n/a
facebook/react 7,252 40,629,727 refused: manifest > 1 MiB pass: 2,452,970 B manifest, 53 KB report, 23 s n/a
laravel/framework 3,439 26,930,953 refused: manifest > 1 MiB pass: 1,021,096 B manifest, 30 KB report, 11 s n/a
django/django 7,085 46,143,674 refused: symlink refused: 4 symlinks pass: 2.07 MB manifest, 234 KB report
rails/rails 5,007 39,947,903 refused: symlink refused: 1 symlink pass: 1.50 MB manifest, 99 KB report
hashicorp/terraform 5,562 26,846,902 refused: symlink refused: 10 symlinks pass: 1.70 MB manifest, 52 KB report
grafana/grafana 23,749 220,958,802 refused: Git listing > 1 MiB refused: 7 symlinks 64 MiB source cap (210.7 MiB)
microsoft/vscode 20,238 566,238,484 refused: Git listing > 1 MiB refused: 1 symlink 64 MiB source cap (540.0 MiB)

Three of eight repositories now pass with no changes. Five are refused for tracked symlinks, mostly test fixtures. That fail-closed rule predates this PR and is now the most common blocker. Treating symlinks as unread exclusions is a security design call, recorded in TODOS.md. With symlinks removed, 6 of 8 pass, and only the two repositories over 20k files hit the 64 MiB cap. #2993's aggregate cap stays open, with a stream-hash follow-up in TODOS.md.

Validation

Revision d8b1c01ff0e028ea1bcdbbaf24af7b1ca41c2a27, merged with main at v1.91.36.0. The full suite ran on b6d006d0f; the only later change is the release-version bump, in 5 metadata files.

  • Reproduced on main first. At 2,500 files the manifest is 829,282 B and the run passes; 4,000 and 5,000 files are refused with /cso refuses the repo before any audit runs #3068's message. With only the two caps raised, a secret-heavy 5,000-file repository wrote a 1,968,861 B report.json, a 1,683,003 B sensitive-evidence.json and 1.97 MB of stdout, all over 1 MiB.

  • New test/cso-file-ceiling.test.ts (10 tests). It drives a 5,000-file synthetic repository with long nested paths, mostly excluded or withheld and with 999 files carrying scanner hits, through start, inspect, submit, finish (the final saveReport) and recheck, and asserts every omitted-count line. It also covers:

    • a 2,500-file regression;
    • a retained pretty-printed snapshot.json loading in recheck;
    • a non-snapshot artifact over 1 MiB still being rejected, with MAX_OUTPUT still 1 MiB;
    • the source assertion of zero direct snapshot.json reads;
    • all five parts of both capacity errors, plus the 64 MiB fail-closed path through the launcher;
    • Git listings over 1 MiB, with and without a comparison base.

    The listing tests fail on the pre-fix code.

  • Focused CSO suites: 361 pass, 0 fail across 18 files, rerun after the process change. After the merge with main: 99 pass, 0 fail.

  • Cheap checks:

    • Credential scan: 0 high, 1 advisory (the VERSION line).
    • format:cso:check, typecheck and typecheck:test (865 known diagnostics, none new) are clean.
    • gen:skill-docs --dry-run reports everything fresh.
    • Parity suite, spawnSync tripwire, module-size ratchet, agents-digest and version-bump tests: 85 pass, 0 fail.
  • bun run eval:bg:pr (local backend): selected 0 of 243 tests, cost $0, EXIT=0. No skill prompt changed. cso-diff-mode, cso-full-audit and cso-infra-scope are deferred to broad coverage.

  • Final acceptance: bun run test:ubicloud (the free suite on a standard-16 Ubicloud VM) passed on all 17 shards: 26,563 tests in 1,118 files, 26,475 pass, 88 skip, 0 fail.

  • Not verified: Windows and macOS runs of the new tests. The change is platform-neutral TypeScript, and the new test assumes /usr/bin/git and /bin/sh, like the existing CSO CLI tests.

Fixes #3068
Refs #2993

Thanks to @almoatasemm for the report (#3068) and @saanjay for the capacity diagnosis of the manifest, reader and source caps (#2993).

Open in Capy

garrytan and others added 6 commits October 8, 2026 06:21
…ty errors

/cso refused any repository with more than about 3,100 tracked files before
an audit started: the snapshot manifest was pretty-printed and both its
writer and every reader capped it at the shared 1 MiB private-state limit
(#3068, manifest half of #2993).

- snapshot.json is written compactly and capped by SNAPSHOT_MANIFEST_LIMIT
  (16 MiB), a constant local to the snapshot module.
- readJson takes a per-artifact cap; readSnapshotManifest is the only
  reader of snapshot.json and passes the snapshot cap through recovery and
  the private-file size check. MAX_STATE_FILE and MAX_OUTPUT stay 1 MiB.
- The manifest-cap and 64 MiB source-cap errors name the bound cap, the
  measured value, what counts toward it, the next step and #2993. A single
  file that would cross 64 MiB now hits the same message before it is read.
- Older pretty-printed manifests still load (recheck, inspect).

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Lifting the manifest cap alone moved the failure into the audit: report.json
listed one transformation per transformed entry plus one coverage gap or
exclusion per omitted entry (1.97 MB for 5,000 nested paths), and
sensitive-evidence.json grew per scanner hit (1.68 MB), both under the
1 MiB private-state cap that saveReport and the start stdout share.

- boundedList (state.ts) keeps the leading entries that fit a byte budget,
  measured as the pretty-printed JSON they add at their nesting depth, and
  ends the list with one summary carrying the omitted count.
- report.json snapshot lists share one 256 KiB budget (gaps 128 KiB,
  transformations 96 KiB, exclusions 32 KiB); coverage counts and status are
  computed before trimming, so they stay exact.
- sensitive-evidence.json keeps 512 KiB of per-file evidence plus an
  omitted-count record.
- Snapshot coverage and publicSnapshotPath no longer scan the whole manifest
  per entry.

Test: 5,000 long nested paths, mostly excluded or withheld, 999 files with
scanner hits, driven through start, inspect, submit, finish and recheck.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
With the manifest cap lifted, the next file-count wall was the shared 1 MiB
process-output cap on Git's path listings: ls-files/ls-tree --name-only
failed at roughly 15-20k files (23,749-file grafana/grafana fails there) and
the comparison-base ls-tree near 8-10k.

runProcess lets raw callers, whose output is never printed or persisted,
opt in to up to 16 MiB; git() forwards an optional cap, and the four
snapshot listings pass SNAPSHOT_MANIFEST_LIMIT. Every other caller keeps
the MAX_OUTPUT clamp.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
docs/troubleshooting.md#cso-capacity covers the snapshot-list cap, the 64 MiB
source cap and the tracked-symlink refusal. TODOS.md records the symlink
design call, the #2993 aggregate cap, the full-manifest inspect output and
repair-bundle transformations.

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>
@trunk-io

trunk-io Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

😎 This pull request was merged.

@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

E2E Evals: ✅ PASS

[test:paid] VERDICT GREEN — lane gate/pr, attempt 1
  rule 0/0 · behavior 0/0 · judge 0/0 · quarantined 0 (0 failing the lane)
  SKIPPED 0 · INFRA 0 · INCOMPLETE 0 · unattributed 0 · ACTION REQUIRED 0
  wall 0m00s · cost $0.00

0 executed, 0 reused rule/judge records | 0 manual accepted (unscored; no score-cache credit) | $0 rule/judge cost | reconcile exit: 0

Profile: pr / mode pr; selected behaviors: 0, judges: 0. Deferred to scheduled/release coverage: 3 behaviors and 0 changed prompt files. Deferred checks did not run and receive no PR-pass credit.

Rule and judge shards
Shard Automated result Manual/unscored Executed Reused Status Cost
Fail-closed reconciliation
[test:paid] report: 1/1 slices, 0 planned shards, tier=gate, attempt 1
[test:paid] coverage: profile=pr mode=pr; selected E2E=0, judges=0
[test:paid] deferred: 3 broad behaviors, 0 changed prompts without quick live coverage; these are not PR passes
[test:paid] collector final outcomes: 0 executed, 0 reused; 0 passed, 0 failed, 0 manual accepted (unscored; no score-cache credit) (0 attempt records from 0 collectors; every record counts)
[test:paid] VERDICT GREEN — lane gate/pr, attempt 1
  rule 0/0 · behavior 0/0 · judge 0/0 · quarantined 0 (0 failing the lane)
  SKIPPED 0 · INFRA 0 · INCOMPLETE 0 · unattributed 0 · ACTION REQUIRED 0
  wall 0m00s · cost $0.00
[test:paid] report: every planned shard accounted and passed

Sliced lane: planner → duration-packed executors → fail-closed report. Behavior cases run a pre-registered 3-trial panel (PASS at 2/3 with no contract violation); a PASS 2/3 is shown with its failed trial, never as a clean pass. Reused results retain their original provenance and expiry.

…le-ceiling

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

# Conflicts:
#	CHANGELOG.md
#	TODOS.md
#	VERSION
#	agents-digest/gstack-AGENTS.md
#	package.json
@capy-ai
capy-ai Bot merged commit 52eec18 into main Oct 8, 2026
66 checks passed
BenjaminDSmithy added a commit to BenjaminDSmithy/gstack that referenced this pull request Oct 8, 2026
Upstream moved to 1.91.42.0 (garrytan#3074, garrytan#3076, garrytan#3078), above this
branch's 1.91.35.0, and the release queue holds 1.91.43.0 to
1.91.47.0, so the release moves to 1.91.48.0 (PATCH, from
bin/gstack-next-version: bumped past claimed 1.91.47.0).

- CHANGELOG.md: main's file byte-identical from line 44 down, with
  this branch's entry on top, re-headed [1.91.48.0].
- VERSION, package.json and the agents digest: main's side, then
  bin/gstack-version-bump write --version 1.91.48.0 --regen-digest.

bin/gstack-hook-check on the merged tree: 9 ok, rc 0. Focused set
(the hook-check, doctor, session-update, autoplan, version and
digest files): 609 pass, 6 skip, 0 fail across 16 files.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
levi85 pushed a commit to levi85/gstack that referenced this pull request Oct 14, 2026
…rt lists, actionable capacity errors (garrytan#3078)

* fix(cso): give snapshot.json its own 16 MiB cap and actionable capacity errors

/cso refused any repository with more than about 3,100 tracked files before
an audit started: the snapshot manifest was pretty-printed and both its
writer and every reader capped it at the shared 1 MiB private-state limit
(garrytan#3068, manifest half of garrytan#2993).

- snapshot.json is written compactly and capped by SNAPSHOT_MANIFEST_LIMIT
  (16 MiB), a constant local to the snapshot module.
- readJson takes a per-artifact cap; readSnapshotManifest is the only
  reader of snapshot.json and passes the snapshot cap through recovery and
  the private-file size check. MAX_STATE_FILE and MAX_OUTPUT stay 1 MiB.
- The manifest-cap and 64 MiB source-cap errors name the bound cap, the
  measured value, what counts toward it, the next step and garrytan#2993. A single
  file that would cross 64 MiB now hits the same message before it is read.
- Older pretty-printed manifests still load (recheck, inspect).

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

* fix(cso): bound per-entry report and evidence lists with omitted counts

Lifting the manifest cap alone moved the failure into the audit: report.json
listed one transformation per transformed entry plus one coverage gap or
exclusion per omitted entry (1.97 MB for 5,000 nested paths), and
sensitive-evidence.json grew per scanner hit (1.68 MB), both under the
1 MiB private-state cap that saveReport and the start stdout share.

- boundedList (state.ts) keeps the leading entries that fit a byte budget,
  measured as the pretty-printed JSON they add at their nesting depth, and
  ends the list with one summary carrying the omitted count.
- report.json snapshot lists share one 256 KiB budget (gaps 128 KiB,
  transformations 96 KiB, exclusions 32 KiB); coverage counts and status are
  computed before trimming, so they stay exact.
- sensitive-evidence.json keeps 512 KiB of per-file evidence plus an
  omitted-count record.
- Snapshot coverage and publicSnapshotPath no longer scan the whole manifest
  per entry.

Test: 5,000 long nested paths, mostly excluded or withheld, 999 files with
scanner hits, driven through start, inspect, submit, finish and recheck.

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

* fix(cso): admit Git path listings above 1 MiB during snapshot capture

With the manifest cap lifted, the next file-count wall was the shared 1 MiB
process-output cap on Git's path listings: ls-files/ls-tree --name-only
failed at roughly 15-20k files (23,749-file grafana/grafana fails there) and
the comparison-base ls-tree near 8-10k.

runProcess lets raw callers, whose output is never printed or persisted,
opt in to up to 16 MiB; git() forwards an optional cap, and the four
snapshot listings pass SNAPSHOT_MANIFEST_LIMIT. Every other caller keeps
the MAX_OUTPUT clamp.

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

* docs(cso): explain the capacity refusals and file the follow-ups

docs/troubleshooting.md#cso-capacity covers the snapshot-list cap, the 64 MiB
source cap and the tracked-symlink refusal. TODOS.md records the symlink
design call, the garrytan#2993 aggregate cap, the full-manifest inspect output and
repair-bundle transformations.

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

* chore(release): v1.91.42.0 /cso lifts its file-count ceiling

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>
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.

/cso refuses the repo before any audit runs

1 participant