Skip to content

/cso keeps going when a .env-style file cannot be read, and reports it as unread - #4688

Merged
capy-ai[bot] merged 5 commits into
mainfrom
fix/cso-unreadable-secret-files
Nov 22, 2026
Merged

capy-ai[bot] merged 5 commits into
mainfrom
fix/cso-unreadable-secret-files

Conversation

@garrytan

@garrytan garrytan commented Nov 22, 2026 •

Copy link
Copy Markdown
Owner

/cso's start no longer aborts when a tracked secret-like file (.env.example and the like) cannot be read because of a sandbox deny rule or file permissions; the file is listed as unread and the run's source coverage reads partial.
Why: with Claude Code's sandbox and a Read(**/.env*) deny rule, /cso could not run at all on any repo tracking such a file.
Nothing to do after merge.

Repro and fix

Repro on main (c2b4f0d), as a normal user: a repo tracking .env.example with mode 000 gives {"ok":false,"error":{"code":"UNSAFE_PATH","message":"Source could not be opened as a regular file: .env.example"}}. When the sandbox also denies lstat (the reported case), the raw EPERM escapes and start prints the generic INVALID_SCHEMA. Both are tests in test/cso-unreadable-secret-file.test.ts that fail on main.

Fix, all in lib/cso/snapshot.ts:

  • A permission error (EACCES/EPERM) on lstat or open of a path that exclusion() already keeps out of snapshot/ records an entry with originalHash: not-read and withheld: … unreadable (EACCES); its payload was not assessed. It has no excluded: prefix on purpose, so coverage counts it as an in-scope gap rather than a clean exclusion.
  • The special-file walk skips such a path without opening it, and the end-of-capture stability check requires a path whose lstat was denied to stay denied.
  • Any other unreadable file still fails with UNSAFE_PATH and the same message as before.

Five tests in test/cso-unreadable-secret-file.test.ts cover this: the two repros above, an ordinary unreadable file that still refuses, an ordinary file whose lstat is denied that still refuses, and a denied secret file that becomes readable during capture, which raises SNAPSHOT_RACE.

After the fix, start on the repro repo runs and reports snapshot-inputs: partial with that line.

Not changed: an old run whose readable/ folder already holds a copy of such a file can still fail retention cleanup under the same deny rule, and the generic INVALID_SCHEMA message does not yet name the errno.

Security read

This touches /cso's capture boundary, so the read was about what can now get past it. The only new path is: a file whose name /cso already treats as a credential (the exclusion() list) and which the OS refuses to let us read. Such a file is never opened, copied, redacted or handed to a scanner; it is reported as an unread gap, so the report cannot claim it was checked. A non-excluded unreadable file, a FIFO, a symlink or a hard link keeps today's refusal. No CI, install, dependency, network, auth or process-spawning change.

Review notes (4, all below the blocking floor)

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

  • INFORMATIONAL lib/cso/snapshot.ts:901 With --paths plus --base, an out-of-scope secret-like file that can be lstat'd but not opened still aborts start: gitBlobStable -> readStableWith throws UnreadableSource uncaught. Not a regression (same abort as main).
  • INFORMATIONAL lib/cso/snapshot.ts:837 An lstat-denied secret-like file outside --paths is labelled 'withheld: unreadable' instead of OUTSIDE_AUDIT_PATHS, so coverage counts it as an in-scope unread gap.
  • INFORMATIONAL lib/cso/snapshot.ts:305 exclusion() also matches omittedPath() (agent config under .claude/, .agents/, .codex/, .cursor/, .github/agents/), so unreadable files there are withheld too; still reported as a coverage gap. The changelog's 'any other unreadable file still stops the run' overstates strictness.
  • INFORMATIONAL lib/cso/snapshot.ts:1088 Withheld entries set no gitHashes/gitModes, so under --base they always count as changed; safe default, adds noise to diff-scoped reports.
Documentation

Status: current. Audited the release docs for this branch and found none stale, so nothing was edited.

Scope: base c2b4f0d2 to head 7356635 (4 commits): lib/cso/snapshot.ts, test/cso-unreadable-secret-file.test.ts, changelog.d/fix-cso-unreadable-secret-files.md. Nothing was staged, unstaged or untracked. I checked the /cso docs: cso/SKILL.md.tmpl, docs/cso-scanners.md, and the /cso entries in docs/troubleshooting.md.

Documentation health:

  • cso/SKILL.md.tmpl: Current (its partial-coverage reporting rules already cover an unread input)
  • docs/cso-scanners.md: Current (unaffected)
  • docs/troubleshooting.md: Current (nothing documented the old abort)
  • changelog.d/fix-cso-unreadable-secret-files.md: Current (describes the fix accurately; not edited)

Coverage debt: when /cso hits an unreadable secret-like file, it now records the file as withheld and reports source coverage as partial. That behavior is documented only in the changelog fragment, with no troubleshooting entry next to #cso-capacity (reference-only gap). Diagram drift: none; no diagrams reference the snapshot capture path.

Issues

Fixes #4395

Agent notes

Outside-report lane GSTA-802 (GST-3484), #4395 from @kado-ta (no outside code). /ship (run ship-4688): one review round, 0 blocking, 1 informational finding fixed (commit 591d730), 4 notes above. Head 99d9b61 is a base-only merge of main into reviewed head 7356635 (the PR's own lines are unchanged); CI green at 99d9b61 (run 44996781596). Focused: cso lane pass, tests_ran=107.

Open in Capy

{
  "schema_version": 1,
  "pr": 4688,
  "head": "99d9b61f5c4f4712fc897785d933e7d8c5a86218",
  "version": "1.102.2.0",
  "base": "main",
  "gate": {
    "cso": {
      "pass": 107,
      "fail": 0,
      "skip": 0
    }
  },
  "calls": 41,
  "session_kind": "unattended",
  "run": "ship-4688",
  "head_tree": "144eaf339f86e0f865b382fe52553a4ade19d636",
  "product_patch_id": "a32d23c07a5f3f6abe4ad378c0b71c800613016a",
  "gstack_version": "1.102.2.0",
  "review_depth": {
    "depth": "light",
    "class": "code",
    "runtime_lines": 63,
    "rules": "630fd3101899e28e",
    "base": "0b4f0ceeec19fef62480db6c8eb00c4015380a39",
    "registry": "0b4f0ceeec19fef62480db6c8eb00c4015380a39",
    "gate_scan": {
      "tagged": 0,
      "head": "99d9b61f5c4f4712fc897785d933e7d8c5a86218"
    },
    "reasons": [
      "runtime=63"
    ],
    "risk": [],
    "mode": "panel"
  },
  "pregate": "requires-remote cleared @144eaf339f86 (8 checks, current for 99d9b61f5c4f)",
  "requires_remote": [
    "free-tests.yml/macos-named-regressions: https://github.com/garrytan/gstack/actions/runs/44996781596/attempts/1",
    "pregate.json/remote_gate: remote-gate tree=144eaf339f86 tests=38837 runs=44996781596/1 profiles=ci-reuse/free-tests heads=99d9b61f5c4f verified=2026-11-22T07:33:43.927Z"
  ],
  "issues": {
    "fixes": [
      4395
    ],
    "refs": [],
    "flakes": []
  },
  "docs": {
    "status": "current",
    "scope": "docs/, README.md and cso/ (cso/SKILL.md.tmpl, docs/cso-scanners.md, docs/troubleshooting.md read in full)"
  },
  "review_loop": {
    "passes": 1,
    "blocking_found": 0,
    "deferred": 0,
    "noted": 4,
    "fixed": 1,
    "scope": "frozen",
    "rounds": 1,
    "ledgers_read": 1,
    "dispatches": {
      "specialist": 3,
      "red-team": 1
    }
  },
  "gate_dispositions": []
}

A tracked file that /cso already keeps out of the audited snapshot, such as
.env.example, aborted start when a sandbox deny rule or a mode-000 file made it
unreadable. Such a file is now recorded as an unread input and reported as a
snapshot-inputs coverage gap. Every other unreadable file still fails the
capture.

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

trunk-io Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

😎 This pull request was merged.

garrytan and others added 4 commits November 22, 2026 06:10
…de beforeAll

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…at a denied secret that turns readable is a race

Review-Finding: p1/specialist-batched#1 reader=testing
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…d of stopping

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

cso: start aborts with INVALID_SCHEMA when a tracked secret-like file is unreadable

1 participant