fix(autoplan): keep the .env* family and secret files out of the lean 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>
This commit is contained in:
garrytanandcapy-ai[bot] committed 2026-11-03 03:44:01 +00:00
1 parent f3f176b9e2
commit e16009e054
3 files changed
+36 -11

No files matched your search

+8 -3
View File
@@ -385,9 +385,14 @@ The example above is the full run. The first `next` also takes `--kind`:
hashed into `run.json` (`phases.eng.draft`) and the `phase_opened` journal
row. With no code yet, the run says so: `DRAFT: none (<why>)`. A git
command that fails is `DRAFT: none (draft capture failed: …)`, never a
partial draft. An untracked file whose name looks like a secret (`.env*`,
`*.pem`, `*.key`, `id_rsa`, `credentials*`, `*secret*`) is left out with a
note, and the `DRAFT:` line names the checkout it diffed (`root=`). The prompt inlines the diff in a fence longer than any tilde
partial draft. The draft goes to a model provider, so a file whose name
looks like a secret (the whole `.env*` family, `.envrc` included, `*.pem`,
`*.key`, `*.p12`, `id_rsa` and the other SSH private keys, `.netrc`,
`.npmrc`, `.pgpass`, `*credentials*`, `*secret*`) is never read, tracked or
untracked, and is left out with a note. Every other file's patch goes
through the redact engine (`lib/redact-engine.ts`), so a key in an ordinary
file reaches the reviewer as `<REDACTED-…>`; a patch it can't redact safely
is left out with a note. The `DRAFT:` line names the checkout it diffed (`root=`). The prompt inlines the diff in a fence longer than any tilde
run inside it, cut at 100,000 bytes (`shown=` on the `DRAFT:` line) with a
note asking the reviewer to name what it didn't see. The reviewer's
line after INPUT names the draft (`DRAFT: <sha256>` or `DRAFT: none`), or