Skip to content

v1.94.5.0 fix(autoplan): keep secret files and keys out of the lean reviewer prompt (GST-1164, #3914) - #3921

Merged
capy-ai[bot] merged 8 commits into
mainfrom
gsta258-s1-envrc-redact
Nov 3, 2026
Merged

capy-ai[bot] merged 8 commits into
mainfrom
gsta258-s1-envrc-redact

Conversation

@garrytan

@garrytan garrytan commented Nov 3, 2026 •

Copy link
Copy Markdown
Owner
{
  "schema_version": 1,
  "pr": 3921,
  "head": "735ddb265475d8ce4cde00a96e2d85719e9abe0c",
  "version": "1.94.2.0",
  "base": "main",
  "gate": {
    "focused": {
      "pass": 34,
      "fail": 0,
      "skip": 0
    }
  },
  "session_kind": "unattended",
  "head_tree": "57ef626e156675bde3b157ddac62ae1bdda0d27c",
  "product_patch_id": "b11c710a1e25e89fcc1ac2fed5f8037f32a3dd04",
  "gstack_version": "1.94.1.0",
  "review_depth": {
    "depth": "light",
    "class": "code",
    "runtime_lines": 47,
    "rules": "b2272efd321ce7cb",
    "base": "7d475a4ea4e846e688cd5cdc170d8616595c1b1b",
    "registry": "7d475a4ea4e846e688cd5cdc170d8616595c1b1b",
    "gate_scan": {
      "tagged": 0,
      "head": "735ddb265475d8ce4cde00a96e2d85719e9abe0c"
    },
    "reasons": [
      "runtime=47"
    ],
    "risk": []
  },
  "pregate": "requires-remote cleared @57ef626e1566 (7 checks, current for 735ddb265475)",
  "requires_remote": [
    "free-tests.yml/macos-named-regressions: https://github.com/garrytan/gstack/actions/runs/41577778087/attempts/1",
    "pregate.json/remote_gate: remote-gate tree=57ef626e1566 tests=34590 skipped=70 runs=41577778087/1 profiles=ci-reuse/free-tests heads=735ddb265475 verified=2026-11-03T04:31:24.088Z"
  ],
  "issues": {
    "fixes": [
      3914
    ],
    "refs": [],
    "flakes": []
  },
  "docs": {
    "status": "current",
    "scope": "base b42ad1e to head e8aef87: changelog.d/gsta258-s1-envrc-redact.md, docs/unattended.md, lib/autoplan-lean.ts, test/autoplan-lean.test.ts; 134-doc inventory checked; audit s1-docs-1"
  },
  "review_loop": {
    "passes": 2,
    "blocking_found": 4,
    "deferred": 0,
    "noted": 7,
    "fixed": 4,
    "scope": "frozen",
    "fix_checks": 1,
    "rounds": 3,
    "unrecorded": 1,
    "ledgers_read": 3,
    "dispatches": {
      "specialist": 2,
      "red-team": 1
    }
  },
  "review_loop_exception": {
    "accepted_by": "GStack Minder",
    "date": "2026-11-03",
    "via": "GSTA-258",
    "reason": "standing grant, GSTA-258 builds, 2026-11-03: anything still at the floor after the one fix-check ships as an open note",
    "fix_check": {
      "head": "f8571f33d5a3ecc931e7acc544e1167cca30d69f",
      "findings": 2,
      "files": [
        "lib/autoplan-lean.ts",
        "test/autoplan-lean.test.ts",
        "docs/unattended.md",
        "changelog.d/gsta258-s1-envrc-redact.md"
      ]
    }
  }
}

What changed

The four new leak tests fail on main (fake keys and secret files reach the lean reviewer draft) and pass on this branch

The four new leak tests fail on main (fake keys and secret files reach the lean reviewer draft) and pass on this branch.

Before/after as text: The four new leak tests fail on main (fake keys and secret files reach the lean reviewer draft) and pass on this branch
--- Before · before.txt · captured output
+++ After · after.txt · captured output
+$ bun test test/autoplan-lean.test.ts  # this branch
+ 0 fail
+ 4 pass
+(pass) draft capture edges > a key inside an ordinary file is redacted, untracked or edited in the working tree
+(pass) draft capture edges > a secret file committed or edited on the branch is left out of the tracked diff too
+(pass) draft capture edges > a secret file renamed on the branch stays out under both names
+(pass) draft capture edges > the whole .env family and other secret files are left out before they are read (GST-1164, #3914)
-$ bun test test/autoplan-lean.test.ts  # lib/autoplan-lean.ts at main b42ad1e
- 0 pass
- 4 fail
-(fail) draft capture edges > a key inside an ordinary file is redacted, untracked or edited in the working tree
-(fail) draft capture edges > a secret file committed or edited on the branch is left out of the tracked diff too
-(fail) draft capture edges > a secret file renamed on the branch stays out under both names
-(fail) draft capture edges > the whole .env family and other secret files are left out before they are read (GST-1164, #3914)
 

Why

The /ship review of #3901 filed a CRITICAL finding (#3914): "Untracked .envrc / .env-production files are not excluded (only .env and .env.*) and can be inlined into the lean reviewer prompt." That prompt goes to an outside model provider, so a direnv .envrc or a key sitting in a source file could leave the machine. Now secret-named files never get read into the draft, and everything else goes through gstack's redact engine first.

Blast radius

Only captureDraft in lib/autoplan-lean.ts changes, and its one caller (lib/autoplan-run.ts:182, the lean /autoplan run) gets the same return shape. The draft can only lose content, as a left-out file or a <REDACTED-…> span. Its hash, DRAFT: receipt and inline cap work as before (script ran: all 34 tests in test/autoplan-lean.test.ts pass, including the existing receipt, cap and capture-failure cases).

Approvals

Date Asked Exact words Outcome Covers Still pending
2026-11-03 review_loop_grant: one scoped fix-check at stop head f8571f3 (rename/copy handling in lib/autoplan-lean.ts captureDraft) “standing grant, GSTA-258 builds, 2026-11-03” (GStack Minder) approved review_loop_grant f8571f3: one scoped fix-check covering the rename/copy handling; anything still at the floor ships as an open note; no second grant none

Source: gstack-approvals record for gsta258-s1-envrc-redact (display only; not an approval citation).

Summary

What could leak, and since when. Since v1.93.36.0 (#3897), the lean /autoplan run (--kind feature, the default for an unattended Capy run) has put the branch's draft code into a prompt sent to an outside model provider. The issue said main excluded only .env and .env.*. That undersold the old rule, which also left out untracked *.pem, *.key, id_rsa, .netrc, .npmrc, credentials.* and *secret*. But it missed .envrc, .env-production, .env_local, credentials-prod.json, _netrc, .pgpass, .git-credentials and id_ed25519_sk. It applied no name rule at all to tracked files, so a committed or edited .envrc went out whole. And it never checked content, so an API key pasted into an ordinary source file went out as written.

What blocks it now.

  • The name rule covers the whole .env* family, *credentials*, _netrc/.netrc, .npmrc, .pypirc, .pgpass, *.pem/*.key/*.p12/*.pfx/*.keystore/*.jks, SSH private keys including _sk keys, and *secret*. It runs before any read, on untracked files and on tracked changes (excluded by :(exclude,literal) pathspec, so git never diffs them). It also catches both sides of a rename or copy that git detects (-M -C). The draft says which files it left out.
  • Every other file's patch goes through redactFindingSpans (lib/redact-engine.ts), the same engine telemetry and the flaky-run records use. It also catches the values of credential-named environment variables. A patch it can't redact safely, including one over 1 MiB, is left out with a note.

Security call-out (R45). This change reads no secrets or environment variables of its own, makes no network calls, and doesn't touch workflows, setup, install or upgrade scripts. The redact engine it now calls reads credential-named environment variables by value so it can redact them; that is the engine's existing behavior.

Test Coverage

All new code paths have test coverage. Four failing-first tests in test/autoplan-lean.test.ts: untracked secret files (.envrc, .env-production and six more) stay out; a committed and edited .envrc stays out of the tracked diff; .envrc renamed to .envrc.local and .pgpass renamed to pg.txt stay out while an ordinary rename stays compact; a fake key in an untracked file and in a working-tree edit comes out redacted. All four fail on main at b42ad1e and pass here. The draft tests now ignore the developer's global and system git config.

Regression proof: fails at main (b42ad1e) · passes after fix (f8571f3, and at 735ddb2 after merging main).

Tests ran: focused 34

Pre-Landing Review

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

Review-loop exception: accepted by GStack Minder 2026-11-03 via GSTA-258: standing grant, GSTA-258 builds, 2026-11-03: anything still at the floor after the one fix-check ships as an open note (fix-check at f8571f3, 2 findings)

Gate edits: none detected (0 listed, 0 read; GATE_SCAN tagged=0 at f8571f3)

Review depth: the plan gstack-review-plan printed (light: one batched specialist with the testing, security, state-machine and red-team checklists, plus the native adversarial reader). Pass 2 was scoped (red team and adversarial), and then the granted fix-check ran. Outside voice: skipped by the review plan (code class, no numeric claims).

Fixed: a rename between secret names leaked the old file's lines (pass 1); the round-1 --no-renames fix sent a secret renamed to an ordinary name in full (pass 2); and the draft tests read the developer's global git excludes.

Review notes

Open notes. None of these fails a test, and none is a regression from main.

  • Open at the floor (fix-check, CRITICAL): a secret moved in the working tree without git add (mv .pgpass pg.txt) shows up as an untracked ordinary-named file, so its content goes out, guarded only by the redact engine (which doesn't recognize a .pgpass line). Main leaks the same file, and also its old lines. A secret copied unchanged and committed under an ordinary name, or renamed and edited past git's 50% rename threshold, behaves the same way. The docs and changelog now say so.
  • Redaction covers every redact-engine category, not only secrets: emails, private URLs such as http://127.0.0.1:8080, public IPs and TODO(name) markers also come out as <REDACTED-…>, sometimes swallowing a closing quote. That costs the reviewer some syntax fidelity, never data.
  • The name rule checks file names, not folders (secrets/prod.yaml, .aws/config, .ssh/config, *.tfstate rely on content redaction).
  • *credentials* and *secret* also hide source files like lib/secret-scan.ts from the outside reviewer (with a note).
  • Thousands of secret-named tracked paths could overflow argv; that fails closed as DRAFT: none (draft capture failed…).
  • The withheld-patch note prints the raw diff --git header instead of the path.

Eval Results

No paid evals. The change alters the reviewer prompt's draft text only when it holds secret-named files or credential spans, and no eval fixture does. bun run eval:select selects 265 cases through the dependents of lib/autoplan-lean.ts, and those stay on the train's gate.

Issues

Fixes #3914

Documentation

Status: current. No documentation edits were needed.

Scope: base b42ad1e to head e8aef87 on gsta258-s1-envrc-redact. The candidate has 4 committed files: the changelog fragment, docs/unattended.md, lib/autoplan-lean.ts and test/autoplan-lean.test.ts. Nothing was staged, unstaged or untracked. The 134-doc candidate inventory was checked for relevance, and the banned-terms check returned none.

Documentation health

  • docs/unattended.md: current. The secret-name list, rename/copy handling, redact-engine hand-off and the content-check caveat all match the code.
  • changelog.d/gsta258-s1-envrc-redact.md: current. Its claims match the code, including the 1 MiB redact cap.
  • autoplan/DRIVER.md.tmpl: current. It makes no claim the change contradicts.
  • All other inventoried docs: unaffected by this diff.

Coverage debt: none critical. The reference coverage is in docs/unattended.md, and a how-to or tutorial is not needed for this fix. No architecture diagrams are affected, and no regeneration is required.

Test plan

  • bun test test/autoplan-lean.test.ts: 34 pass, 0 fail (also 34/34 with a global git excludesFile listing .envrc)
  • bun run typecheck: clean; bun run typecheck:test: 814 known diagnostics, none new
  • bun test test/module-size-ratchet.test.ts test/spawnsync-timeout-tripwire.test.ts: pass

🤖 Generated with Claude Code

garrytan and others added 6 commits November 3, 2026 03:44
…eviewer's draft (GST-1164, #3914)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
… draft, redact the rest (GST-1164, #3914)

The lean reviewer's prompt goes to an outside model provider. captureDraft left
out only some secret-named untracked files (.env and .env.*, not .envrc or
.env-production), applied no name rule to tracked files and did no content
check. Secret-named files are now never diffed, tracked or untracked, and
every other patch goes through redactFindingSpans; a patch it cannot redact is
left out with a note.

Refs #3914

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…e stays out of the draft (GST-1164)

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>
…ret file renamed or copied on the branch (GST-1164)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
… catches (GST-1164)

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

trunk-io Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

😎 This pull request was merged.

@github-actions github-actions Bot changed the title fix(autoplan): keep secret files and keys out of the lean reviewer prompt (GST-1164, #3914) v1.94.5.0 fix(autoplan): keep secret files and keys out of the lean reviewer prompt (GST-1164, #3914) Nov 3, 2026
@capy-ai
capy-ai Bot merged commit ed5c948 into main Nov 3, 2026
45 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.

Deferred review finding: lib/autoplan-lean.ts:83 — Untracked .envrc / .env-production files are not excluded (only .env

1 participant