Skip to content

v1.91.243.0 fix(capy): source the launch environment from a 0600 file; no skill fence may print the environment (GSTA-104) - #3449

Merged
capy-ai[bot] merged 25 commits into
mainfrom
gsta-104-launch-env-never-echoed
Oct 26, 2026
Merged

capy-ai[bot] merged 25 commits into
mainfrom
gsta-104-launch-env-never-echoed

Conversation

@garrytan

@garrytan garrytan commented Oct 26, 2026 •

Copy link
Copy Markdown
Owner
{
  "schema_version": 1,
  "pr": 3449,
  "head": "6343fd012d04cd50706c0de2cd968a599747d745",
  "version": "1.91.226.0",
  "base": "main",
  "gate": {
    "pregate.json/remote_gate (free tier, Ubicloud, tree 315a72e3ef91)": {
      "pass": 22513,
      "fail": 0,
      "skip": 0
    },
    "requires-remote free-tests.yml/cso-macos-launcher (macos, uncleared)": {
      "pass": 0,
      "fail": 0,
      "skip": 5
    },
    "requires-remote free-tests.yml/macos-named-regressions (macos, uncleared)": {
      "pass": 0,
      "fail": 0,
      "skip": 7
    },
    "requires-remote free-tests.yml/cso-windows-launcher (windows, uncleared)": {
      "pass": 0,
      "fail": 0,
      "skip": 1
    },
    "requires-remote windows-free-tests.yml/windows-free-shard (windows, uncleared)": {
      "pass": 0,
      "fail": 0,
      "skip": 813
    },
    "llm-judges test/skill-llm-eval.test.ts (reused, inputs identical)": {
      "pass": 24,
      "fail": 0,
      "skip": 0
    },
    "paid docsync-spawned (rerun at 6343fd0)": {
      "pass": 1,
      "fail": 0,
      "skip": 0
    },
    "paid document-release (reused, inputs identical)": {
      "pass": 1,
      "fail": 0,
      "skip": 0
    }
  },
  "spend_usd": 3.21,
  "session_kind": "unattended",
  "queue_mode": "stamp-at-merge",
  "issues": {
    "fixes": [],
    "refs": [
      3425
    ],
    "flakes": []
  }
}

What changed

The launch line is a file now, and nothing in a skill fence may print the environment.

docs/capy-install.md § The launch line, before (base 8d95013) and after (this branch): the installer adds GSTACK_LAUNCH_FILE, a 0600 sourceable copy of the assignments, and callers source it instead of re-typing the line that leaked an environment in GSTA-96

Before: one GSTACK_LAUNCH: line and prose telling callers to prefix or export the assignments themselves. After: the same line plus GSTACK_LAUNCH_FILE:, applied with . <file>, a verdict-gated write, an echo ratchet and an env-value redaction finding. Why: the re-typing path is what dumped three API keys into GSTA-96's transcript.

The installer now prints GSTACK_LAUNCH_FILE, a 0600 sourceable copy of the launch assignments; callers source it instead of re-typing the line that leaked an environment in GSTA-96.

Before/after as text: The installer now prints GSTACK_LAUNCH_FILE, a 0600 sourceable copy of the launch assignments; callers source it instead of re-typing the line that leaked an environment in GSTA-96.
--- Before · docs/capy-install.md § The launch line at 8d95013 · source text
+++ After · docs/capy-install.md § The launch line on this branch · source text
@@ ⋯ 3 unchanged ⋯ @@
 ```
 GSTACK_LAUNCH: PATH=<dir>:$PATH GSTACK_SESSION_KIND=unattended GSTACK_STATE_ROOT=<path> GSTACK_EPHEMERAL=1 GSTACK_CAPY=1 GSTACK_INSTALL_VERDICT=<file>
 GSTACK_LAUNCH_PATH: <dir>
+GSTACK_LAUNCH_FILE: <verdict file without .json>.env
 ```
 
+`GSTACK_LAUNCH_FILE` names the same assignments as a sourceable script (mode
+0600, beside the verdict under the state root; the PATH prepend is idempotent).
+The file is part of the ok verdict: a passing run that cannot write it exits 1
+with `gstack: fail launch-file — could not write the launch file <path>; fix:
+make <dir> writable, or set GSTACK_STATE_ROOT to a writable directory
+(LAUNCH_FILE_UNWRITABLE)`, and a failing run prints no `GSTACK_LAUNCH_FILE` line
+and removes the file an earlier passing run left beside the verdict it rewrites
+(a profile check that keeps a fuller ok verdict leaves that verdict's file).
+`. <that file>` at the start of a shell applies them without ever printing them,
+which is the only way to hand them to a child agent: pass the path, never the
+values. None of the assignments is a secret, but during GSTA-96's unattended
+/ship a docs-audit child re-typed them as `export $(...)`; the substitution came
+back empty, the bare `export` printed the whole environment, and three API key
+values landed in its tool output. Never `export $(...)`, `env`, `printenv`, a
+bare `set` or a bare `export` in a tool fence (`test/launch-env-echo-ratchet.test.ts`
+keeps them out of every skill fence and shell helper), and the redaction
+engine now refuses the VALUE of any `*_KEY`, `*_TOKEN`, `*_SECRET`,
+`*_PASSWORD`, `*_PASSWD`, `*_PASS`, `*_PAT`, `*_APIKEY` or `*_PWD` variable
+in the writer's environment (any case; names carrying a `PUBLIC` word are
+framework-public and exempt, gstack's own `GSTACK_BRAIN_LOCK_TOKEN` is not a
+secret) (`env.value`, HIGH), so a leaked value cannot reach a PR body, receipt,
+report or Drive file. There is no path exemption: a path-valued `SSL_KEY` that
+must appear in a text goes through `bin/gstack-redact --allowlist` or the
+pre-push hook's committed `.gstack-redact-allowlist`; the other writers
+(`gstack-post`, receipts, reports) take no allowlist, so for one of those
+commands set the variable empty for that command alone
+(`SSL_KEY= gstack-post …`): an empty value is below the length floor.
+
 `PATH=<dir>:$PATH` and `GSTACK_LAUNCH_PATH` appear only when the certified Bun,
 or the project's resolved Node, is not first on PATH (older Capy images ship
 `/usr/local/bin/bun` 1.3.14; 57 gstack commands start with `#!/usr/bin/env bun`).
@@ ⋯ 5 unchanged ⋯ @@
 never puts that directory's other tools (the image's node) in front of PATH.
 The pregate's lanes launch through the same directory. A child shell's `export` cannot
 configure the parent's later commands, so the parent supplies these
+assignments to every gstack command it launches by sourcing the launch file
+(`. <GSTACK_LAUNCH_FILE>`) at the start of the shell that runs it. A fresh shell without them keeps
-assignments to every gstack command it launches (prefix the command, or
-export them once in the shell that runs it). A fresh shell without them keeps
 reporting the Bun it would really run: `FAIL runtime — bun 1.3.14 at
 /usr/local/bin/bun ...; verified bun 1.4.2 found at ~/.bun/bin (not on PATH);
 fix: export PATH="$HOME/.bun/bin:$PATH" or prefix commands with the

Why

During GSTA-96's unattended /ship on #3425, the Step 14.5 docs-audit child re-typed the GSTACK_LAUNCH assignments as export $(...); the substitution came back empty, the bare export printed the whole environment, and three API key values landed in its tool output. This branch closes that at every layer: gstack-capy-install writes the assignments to a 0600 file and prints GSTACK_LAUNCH_FILE: (the file is part of the ok verdict, LAUNCH_FILE_UNWRITABLE when it cannot be written), every skill fence applies them with . <file> and a ratchet (test/launch-env-echo-ratchet.test.ts) rejects export $(...), env, printenv, bare set and bare export in skill prose and shell helpers, and the redaction engine refuses the VALUE of any credential-named variable in the writer's environment (env.value, HIGH) so a leaked value cannot reach a PR body, receipt, report or Drive file. A Capy agent that follows the skill never sees the values; a child agent gets the path.

Approvals

Ask Words By Scope
Fix the GSTA-96 launch-env leak in gstack, one PR GStack Minder brief, 2026-10-25 (incident response; no product decision) GStack Minder this PR

gstack-approvals render: no approval rows recorded on this branch (the brief above is the Captain's task, not a person's decision).

Summary

  • Launch file instead of a typed line (bin/gstack-capy-install, capy/skill/gstack/SKILL.md, docs/capy-install.md, docs/state-root.md): the installer writes <verdict>.env (0600, atomic, single-quoted through shq, idempotent PATH prepend) and prints GSTACK_LAUNCH_FILE:; only a passing run writes it, a failing run removes the file it would otherwise leave stale (a kept fuller ok verdict keeps its file), a passing run that cannot write it fails with gstack: fail launch-file … (LAUNCH_FILE_UNWRITABLE) (registered in lib/result-codes-capy.ts, troubleshooting anchor, regenerated doctor components); a failed write removes only its own temp file.
  • No fence may print the environment (test/launch-env-echo-ratchet.test.ts, test/fixtures/launch-env-echo/, ship/document-release/autoplan/skill-start prose): the ratchet scans every skill fence, setup and scripts/*.sh for export $(...), backtick and $VAR exports, typeset -p, env/printenv with flags and a bare set in any pipeline segment; Step 14.5 and the document-release spawned note hand a child the launch-file path, never the values.
  • env.value redaction (lib/redact-engine.ts, test/redact-env-value.test.ts): the value of any *_KEY, *_TOKEN, *_SECRET, *_PASSWORD, *_PASSWD, *_PASS, *_PAT, *_APIKEY or *_PWD variable (any case; PUBLIC names and gstack's own GSTACK_BRAIN_LOCK_TOKEN exempt) is a HIGH finding wherever it appears; values are trimmed, matched in normalized form (zero-width and fullwidth splits), a prefix value defers to the longer match, the preview is masked, the allowlist and placeholder rules see the normalized value, and there is no path exemption (the engine stays I/O-free).
  • Test harness (test-setup.ts, scripts/lib/shard-engine.ts): the shard sandbox and the direct-bun test preload strip the same CAPY_LAUNCH_MARKERS list, so a test run under a Capy session matches CI; the Windows late-completion remote-caller case gives its second attempt a 2s budget (the one test-budget change, by the parent in c33c796).
  • Docs: CHANGELOG [Unreleased] entry; Step 14.5 audit updated docs/state-root.md, docs/CONTRIBUTOR_REFERENCE.md and docs/capy-install.md to the launch-file contract.

Test Coverage

CODE PATHS                                                              | USER FLOWS
------------------------------------------------------------------------+---------------------------------------------------------------
bin/gstack-capy-install                                                 |
  write_launch_file: <verdict>.env beside verdict, 0600, atomic mv  [★★★ TESTED] gstack-capy-install.test.ts:336,:417
  PATH prepend line when LAUNCH_DIR set; idempotent on re-source    [★★★ TESTED] :336 (sourced twice, bunDir once)
  no PATH line when LAUNCH_DIR empty; sources under sh, PATH kept   [★★★ TESTED] :417 (Step 7)
  _sq quoting: quote + space in state root / launch dir / verdict   [★★★ TESTED] :769 "paths with a single quote" (Step 7)
  GSTACK_EPHEMERAL passthrough into the file                        [★★★ TESTED] :769 (Step 7)
  write failure: message, no GSTACK_LAUNCH_FILE line, fail trailer  [★★★ TESTED] :433 "cannot be written" (Step 7; skipIf root)
  own temp file removed on failure, sibling survives (mv shim)      [TESTED] 93b793c
  launch file only on a passing run; kept profile verdict keeps it  [TESTED] 6aab86b, 3866c30, 870c626
lib/redact-engine.ts                                                    |  F1 agent sources the file in a fresh shell ........ [★★★ TESTED]
  credentialEnvValues: suffix-word name filter, unset/padded skipped [★★ TESTED] redact-env-value.test.ts:40
  value < 8 chars or placeholder skipped                            [★★★ TESTED] :40        F7 state root with ' and space ............ [★★★ TESTED]
  scan: one HIGH env.value per occurrence, masked preview, line/col [★★★ TESTED] :60        F5 unwritable verdict dir ................. [★★★ TESTED]
  allowlist suppresses; processEnv {} scans nothing by value        [★★★ TESTED] :87
  processEnv defaults to process.env                                [★★ TESTED] :104
  spans -> redactFindingSpans removes every occurrence              [★★ TESTED] :94        F3 writer scans text holding an env value .. [★★★ TESTED]
  match on NORMALIZED text (zero-width / fullwidth), original span  [★★★ TESTED] :66 (Step 7)
  normalized allowlist / placeholder rules                          [TESTED] 9c8f7cf
  prefix value defers to the longer match; PUBLIC / lock-token skip [TESTED] 58f456a, 726fe10, 55a89af
  dedupe by offset when two names share one value                   [GAP] declined: no credible regression (double count only)
scripts/lib/shard-engine.ts / test-setup.ts                             |
  sandbox and preload drop the CAPY_LAUNCH_MARKERS, keep STATE_ROOT [★★ TESTED] shard-engine.test.ts:239, e32274c   F4 shard fixture under a Capy session [★★ TESTED]
test/launch-env-echo-ratchet.test.ts (its own scanner)                  |
  rulesFor vs negative controls (md fenced, sh whole, allowed clean)[★★★ TESTED] :113,:134
  target enumeration (SKILL/sections/DRIVER/capy skill, bin, setup, scripts/*.sh) [★★ TESTED] :141, 55a89af
Prompt / instruction text                                               |  F2 child briefed with the launch-file path ......... [→EVAL]
  bin/gstack-skill-start capy-asks sentence                         [→EVAL] structural: ratchet :156; paid docsync-spawned PASS
  ship/sections/documentation.md.tmpl Step 14.5 launch line         [→EVAL] structural: ratchet :152; paid docsync-spawned PASS; judges 24/24
  document-release/SKILL.md.tmpl spawned note                       [→EVAL] structural: ratchet :152; paid document-release PASS; judges 24/24
  autoplan/DRIVER.md.tmpl                                           [→EVAL] structural: ratchet :152; no focused paid case (nearest autoplan-dual-voice)

Tests: 1441 → 1441 (+0 new) at Step 7 (no new test files; 5 tests added by extending 2 existing files); the six review cycles later added tests in 93b793c, 9c8f7cf, 870c626, b8a59b9, e32274c and 55a89af.
Coverage: 70% value-weighted (95% including 5 weakly covered paths) at Step 7; the Step 7 rater then rated all five new tests ★★★ (12 mutants).
Test value: 5 tests written, 0 rejected by the authoring gate, 2 existing tests extended, 0 paths weakly covered after rating (1 gap declined: dedupe by offset, double count only).
Tests ran: pregate.json/remote_gate (free tier, Ubicloud, tree 315a72e3ef91) 22513
Tests ran: requires-remote free-tests.yml/cso-macos-launcher (macos) 0 — uncleared, 5 skipped (cannot run from this Linux machine)
Tests ran: requires-remote free-tests.yml/macos-named-regressions (macos) 0 — uncleared, 7 skipped
Tests ran: requires-remote free-tests.yml/cso-windows-launcher (windows) 0 — uncleared, 1 skipped
Tests ran: requires-remote windows-free-tests.yml/windows-free-shard (windows) 0 — uncleared, 813 skipped
Tests ran: llm-judges test/skill-llm-eval.test.ts 24 (reused, inputs identical)
Tests ran: paid docsync-spawned 1 (rerun at 6343fd0)
Tests ran: paid document-release 1 (reused, inputs identical)

Pre-Landing Review

Six Step 9/11 cycles (quality_score 0.5 → 7.0 → 7.5 → 6.0 → 9.5 → 10.0; cycle 6 converged, review binding verified at tree 240ffbbb6054, HEAD 870c626). Cycle 1: 21 findings (1 CRITICAL: env.value prefix dedup; 20 INFO), 13 auto-fixed (58f456a 9e5ccbb e32274c b8a59b9 9a475d5). Cycles 2-5 found and closed: the PATH_VALUE shape that matched base64 secrets starting with / (7765db8: no path exemption), the fs.existsSync bypass (7765db8), the ok-verdict-without-launch-file gap (d4f9424), the unregistered result code (3866c30), the kept-verdict deletion (3866c30, 870c626), the normalized allowlist/placeholder blind spot (3e58c96, 9c8f7cf). Cycle 6: no Critical/High/Medium, one Low (open, below); Maintainability specialist NO FINDINGS.
Open INFO findings (non-advisory, not fixed): lib/redact-engine.ts placeholder check runs on live values (:528); suffix set is a fixed list beyond the extension (:515); tests depend on process.env (:474); shell/JSON-escaped renderings of a leaked value are not matched (:478); bin/gstack-capy-install evaluates verdict_kept twice per failing run (concurrent-run race, investigate); test/gstack-capy-install.test.ts:145 and test/launch-env-echo-ratchet.test.ts:187 testing notes; capy/skill/gstack/SKILL.md:25 instruction copies outside the repo (the Drive skill folder and CREW.md rule 22 still say "export the GSTACK_LAUNCH assignments" — owner action).
Gate edits: 16 listed, 6 read, 0 findings — 0 kept, 0 restored, 0 open (every eligible hunk a test-file hunk; the one budget widen is the parent's c33c796 2s second-attempt budget, recorded in the CHANGELOG).
Outside review: unavailable — Codex not installed (codex_reviews unset); listed as missing coverage. Each adversarial pass ran as an in-host Claude subagent instead; pass 6 at 870c626 converged.

Exploratory QA

Surfaces: the installer CLI (bin/gstack-capy-install, --check, --for review-voice), the redaction engine's env.value path, the shard sandbox. Probes (cycle 1: 5 smoke probes pass; cycle 2: write_launch_file own-tmp cleanup under a failing mv with a sibling file surviving, env.value end-to-end through redactFindingSpans; cycle 4: launch file absent after a failing run, kept-verdict path). Reproducers that became regressions with red/green proof: the sibling-temp deletion (87796fe → 93b793c), the base64 path-shape bypass (7765db8), ok-without-launch-file (d4f9424), kept-verdict deletion (3866c30 → 870c626). Not run: macOS/Windows launchers (requires-remote lanes uncleared, listed above).

Design Review

No frontend files changed — design review skipped.

Eval Results

  • LLM judges (bun test test/skill-llm-eval.test.ts, EVALS=1, ship/SKILL.md + document-release/SKILL.md): 24/24 passed, $1.44, 704s — reused at 6343fd0, both prompts byte-identical since 2318d02.
  • Paid case docsync-spawned: first launch failed before any model call ($0.00, launcher fault: EVALS_RUN_ID unset); relaunch PASS 1/1 ($0.61); rerun at 6343fd0 because ship/sections/documentation.md changed: PASS 1/1 ($0.49, 20 turns, 61s).
  • Paid case document-release: PASS 1/1 ($0.55), reused (inputs identical).
  • Total /ship spend: $3.21 (two remote free-tier runs $0.06 each, judges $1.44, docsync $0.61 + $0.49, document-release $0.55).

Greptile Review

No Greptile comments.

Plan Completion

Plan completion audit not run: no plan bound (no Plan: in the PR body, no docs/designs match). cross_project_learnings unset → PENDING.

Issues

Refs #3425
reference #3425 ← commit : During GSTA-96's unattended /ship on #3425, the Step 14.5 docs-audit child (promote: fix #3425)

Verification Results

No Step 8.1 obligations were recorded for this run (no plan bound). Review-cycle reproducers: 4 PASS (red at the finding's HEAD, green after its fix, listed under Exploratory QA), 0 FAIL, 0 BLOCKED. Not run: the 4 requires-remote lanes above (macOS/Windows), accepted as pending for the train, not as passing.

TODOS

No TODO items completed in this PR.

Documentation

Status: updated — three authored docs corrected to match the launch-file contract and the env.value redaction rule; no blockers.

Scope. Base 8d9501373b55897447ae30f1d281c4dbc8a1369e to head 870c6268c1b0fd02b9979edfed593edc2fdd1292 on gsta-104-launch-env-never-echoed: 26 committed files, nothing staged, unstaged or untracked. Audited the candidate's declared docs roots, the Capy skill source, the diff-authored templates and the source that defines the changed contracts (bin/gstack-capy-install, lib/redact-engine.ts, lib/result-codes-capy.ts, scripts/lib/shard-engine.ts, test-setup.ts). Banned terms: none.

Documentation health

  • docs/state-root.md — Updated: the Ephemeral-machines paragraph no longer says to prefix or export the GSTACK_LAUNCH assignments; it shows GSTACK_LAUNCH_FILE:, says to apply it with . <that file>, names the banned forms and links capy-install.md#the-launch-line.
  • docs/CONTRIBUTOR_REFERENCE.md — Updated: the redaction-engine bullet no longer calls scan() pure; it names the ambient process.env input read by value for the env.value HIGH finding and the ScanOptions.processEnv override.
  • docs/capy-install.md — Updated: the bun-shim bullet says sourcing the launch file (not a GSTACK_LAUNCH prefix) reaches the certified Bun; the exit-code table's row 1 names gstack: fail launch-file … with its LAUNCH_FILE_UNWRITABLE anchor.
  • docs/troubleshooting.md, docs/unattended.md, docs/OPENCLAW.md, docs/PROJECT_STRUCTURE.md, CLAUDE.md, AGENTS.md, README.md, CONTRIBUTING.md, capy/skill/gstack/SKILL.md, capy/skill/gstack/captain.md, the three diff-authored templates — Current.
  • CHANGELOG.md, TODOS.md — not touched (ship-owned mode).

Coverage debt. GSTACK_LAUNCH_FILE, LAUNCH_FILE_UNWRITABLE and env.value have reference, how-to and explanation coverage (no tutorial). CAPY_LAUNCH_MARKERS and the shard-sandbox/test-preload stripping of the launch markers are documented only in the CHANGELOG and code comments; docs/TESTING_INTERNALS.md is silent (critical gap, contributor-internal). test/launch-env-echo-ratchet.test.ts and test/redact-env-value.test.ts are not in CONTRIBUTING.md's test catalog (common gap). Diagram drift: none. Owner action outside the repo: recopy capy/skill/gstack/ to the Drive skill folder (only the launch paragraph differs). Product prose to weigh: bin/gstack-doctor-check.sh:267 still offers 'prefix commands with the GSTACK_LAUNCH line' as a fix.

Test plan

  • gstack-pregate --stage tests --remote --spend-cap 2 --timeout 2700 --allow-repo-commands at 2318d02 (tree 926e7b32711e): 18129 tests, 0 failed, $0.06
  • gstack-pregate --stage tests --remote --spend-cap 2 --timeout 2700 --allow-repo-commands at 6343fd0 (tree 315a72e3ef91): PREGATE_REMOTE: tests=22513 failed=0 spent=0.06
  • gstack-pregate run preflight at 6343fd0: PREGATE: warn tree=315a72e3ef91 head=6343fd012d04 checks=6 (secrets warn: 2 MEDIUM pii.phone.e164, a CI run number read as a phone; no credential)
  • bun test test/redact-env-value.test.ts test/gstack-capy-install.test.ts test/launch-env-echo-ratchet.test.ts test/shard-engine.test.ts test/parity-suite.test.ts test/spawnsync-timeout-tripwire.test.ts: pass (42 install, 6 ratchet, parity 22/22; ship union 313,279 of the 313,281-byte cap)
  • bun run typecheck and bun run typecheck:test: zero errors; 819 known diagnostics, none new
  • EVALS=1 bun test test/skill-llm-eval.test.ts (ship + document-release judges): 24/24, $1.44
  • paid docsync-spawned: PASS (relaunch $0.61) and PASS (rerun at 6343fd0 $0.49); paid document-release: PASS $0.55
  • requires-remote lanes (free-tests.yml cso-macos-launcher, macos-named-regressions, cso-windows-launcher; windows-free-tests.yml windows-free-shard): run by CI on push; uncleared from this machine

🤖 Generated with Claude Code

…skill fence may print the environment (GSTA-104)

During GSTA-96's unattended /ship on #3425, the Step 14.5 docs-audit child
re-typed the GSTACK_LAUNCH assignments as `export $(...)`; the substitution
came back empty, the bare `export` printed the whole environment, and three
API key values landed in its tool output.

- bin/gstack-capy-install writes the assignments to <verdict>.env (mode 0600,
  idempotent PATH prepend) and prints GSTACK_LAUNCH_FILE: <path>.
- ship Step 14.5 prompt, document-release's spawned note, autoplan/DRIVER.md
  and gstack-skill-start's capy-asks block say: source the file; never
  export $(...), env, printenv or bare set in a tool fence.
- test/launch-env-echo-ratchet.test.ts greps every generated SKILL.md,
  sections, DRIVER.md, the Capy skill and bin/ shell helpers, with negative
  controls under test/fixtures/launch-env-echo/.
- lib/redact-engine.ts: env.value (HIGH) finds the value of any *_KEY,
  *_TOKEN, *_SECRET, *_PASSWORD variable in the writer's environment, so a
  leaked value cannot reach a PR body, receipt, report or Drive file.
- scripts/lib/shard-engine.ts scrubs the Capy launch markers from shard
  environments (GSTA-99's finding).

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

trunk-io Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

😎 This pull request was merged.

garrytan and others added 24 commits October 26, 2026 03:19
…ioral at HARNESS_VERSION 6; verdict-count test lists .json only

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>
A credential-named assignment with an entropic literal on one line is what
the repo's own pregate secrets scan refuses in added lines, so the fixture
values move into plainly named constants and the scanned text is built from
them. The scan under test still sees the same values through processEnv.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…d attempt a 2s budget (run 40263984171)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
… match, hides the preview and skips PUBLIC names

/ship Step 9.4 review fixes for the GSTA-104 env-value scan:

- a value whose environment copy ends in a newline (a key read from a file)
  is searched for trimmed, so its leaked form still matches (the length
  check already trimmed; the search used the raw value);
- when one credential value is a prefix of another, the dedup key carries the
  span length, so the longer value is redacted whole in either order instead
  of leaving its tail in the text and dropping its finding;
- the env.value preview is a fixed mask instead of the first characters of a
  live credential;
- framework-public names (NEXT_PUBLIC_*_KEY, *_PUBLIC_KEY) are not scanned,
  since those values are committed on purpose;
- the header and the processEnv docstring state the name rule (KEY, TOKEN,
  SECRET, PASSWORD, PASSWD, any case) and that process.env is the engine's
  one ambient input.

Step 7 coverage extensions and a regression test for each fix in
test/redact-env-value.test.ts; docs/capy-install.md names the full rule.

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

Review finding: _sq duplicated shq() from the same file. The launch file's
assignments now go through shq, and the header comment describes the
GSTACK_LAUNCH_PATH and GSTACK_LAUNCH_FILE lines beside GSTACK_LAUNCH.

Step 7 coverage: the verdict test sources the launch file and runs --check;
the single-quote path test sources the file too; a new case makes the
launch-file directory unwritable and checks the run says so, prints no
GSTACK_LAUNCH_FILE line, leaves no temp file and keeps its exit code and
trailer (linux, non-root).

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

Red Team finding: the launch-marker scrub lived only in createShardSandbox,
so a direct `bun test <file>` run under an unattended Capy session inherited
GSTACK_SESSION_KIND, GSTACK_CAPY, GSTACK_EPHEMERAL and GSTACK_INSTALL_VERDICT
(GSTA-99's symptom). The preload now deletes the same four names, and
test/shard-engine.test.ts imports CAPY_LAUNCH_MARKERS instead of re-typing them.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…orts, typeset -p, env flags and a set in any segment

Review findings 11 and 12: export-subst also trips on `export \`...\`` and
an unquoted `export $VAR` (both splat a NAME=value file; `export "$name"` is
one word and stays allowed); the export rule adds `typeset -p`; env trips
with only flags (`env -0`) and as `/usr/bin/env`; set is judged per segment
and with redirections, allowed only when piped straight into an anchored
grep filter. Quoted strings are blanked offset-preserving so a `#` inside
quotes no longer hides the rest of the line. The negative control covers
each new form on both sides.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
The /document-release prompt line read `. <file>` with no word on what fills
it. It now says the placeholder is the GSTACK_LAUNCH_FILE: path the parent's
own install check printed. Worded to stay under the ship skill's pinned
parity size (313,279 of 313,281 union bytes).

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…skips path values and gstack's lock token

/ship Step 11 adversarial findings. The name rule also covers DB_PASS,
GITHUB_PAT, *_APIKEY and *_PWD (the shell's own PWD and OLDPWD stay out). A
credential-named variable whose value is a filesystem path (SSL_KEY=/etc/ssl/
private/x.key) names where the credential lives, so the path is no finding,
and GSTACK_BRAIN_LOCK_TOKEN (pid-random-epoch, written to the lock owner file)
is not a secret. Without these, an ordinary mention of that path or token in a
PR body, receipt or CSO report was a HIGH fail-closed blocker.

The adversarial pass also recommended an entropy floor so dev defaults such as
DB_PASSWORD=postgres stop matching prose; declined here on purpose, because the
scan's promise is to catch a leaked value whatever its shape, and a weak real
password is still a credential. Recorded as an open decision in the ship report.

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

The failure path ran rm -f "$LAUNCH_FILE".tmp.*, which also deleted the temp
file a concurrent installer run (two threads on one machine, same verdict
path) was about to mv, so that run lost its launch file too. write_launch_file
now cleans up its own $tmp and returns 1; the caller only reports. The file's
comment no longer embeds the state-root path (a newline in GSTACK_STATE_ROOT
could have ended the comment).

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…ns setup and scripts/*.sh

The preload imports CAPY_LAUNCH_MARKERS instead of re-typing the four names,
and the ratchet asserts the installer exports every name on that list, so a
fifth marker cannot be added to one place only. The shell scan also covers
./setup and the scripts/*.sh install scripts callers run first.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…ue rules, the ratchet forms and the one test-budget change

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…s instead of matching a shape

Second review cycle: a path-shaped rule also matched a base64 secret that
starts with "/" and holds another "/" (about 1 in 150 AWS-shaped keys), which
then went unscanned. The exemption now fires only when the value names a file
that exists on the scanning machine (SSL_KEY=/etc/ssl/private/x.key). The
module header names that stat as the engine's one filesystem read.
NON_SECRET_ENV_NAMES is exported so the test can prove bin/gstack-brain-lock.sh
still exports every name in it; the PWD/OLDPWD fixtures hold plain words so only
the name rule keeps them out.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…chet coverage test names setup and scripts

An mv shim first on PATH refuses only the launch-file target, so the temp
file exists when the move fails: the run removes that file alone (a sibling
from a concurrent run survives), says so, prints no GSTACK_LAUNCH_FILE line
and keeps the earlier file, exit code and trailer. The ratchet coverage test
asserts setup, scripts/build.sh and scripts/sandbox-doctor.sh are scanned.

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

Second adversarial pass: the existence check let the scanned agent exempt
any "/"- or "~/"-prefixed secret by creating a path of that name, a silent
bypass of the one guard this branch adds, so the exemption is gone; a
path-valued SSL_KEY that must appear in a text goes through the allowlist.
The engine is back to no I/O. The value is now normalized the way the text
is before indexOf, so a credential NFKC rewrites (fullwidth digits) still
finds its leaked ASCII form.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…the ratchet checks the marker list both ways

A gstack: fail run no longer writes or announces a sourceable file whose PATH
prepend points at an unverified Bun. The ratchet also asserts every variable
the launch file exports is a CAPY_LAUNCH_MARKERS entry or GSTACK_STATE_ROOT,
so a sixth export cannot reach fixture children unstripped. The Capy skill's
prose no longer offers re-typing the assignments as an alternative to sourcing.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Third adversarial pass: a passing run whose launch file could not be
written still said gstack: ok with exit 0 and printed only the GSTACK_LAUNCH
line, leaving a shell-evaluating caller with the re-typing path the branch
exists to remove. The file is now written before the verdict is recorded;
a write failure on a passing run turns the run into
"gstack: fail launch-file — could not write the launch file <path>; fix: …
(LAUNCH_FILE_UNWRITABLE)" with exit 1 and an ok:false verdict, and every
failing run removes the launch file an earlier passing run left beside the
verdict. The two failure tests assert the new contract, the doctor-FAIL
tests assert no launch file is announced or left, and the docs, Capy skill
and CHANGELOG say the same.

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

An allowlisted value in NFC did not suppress a match on its NFKC-composed
form, and a value that is a placeholder only after normalization was still
searched for. Fixture nits from the third review cycle: fixed directory
string instead of process.cwd(), the fullwidth assertion guards its own
vacuity, a zero-width-padded value under the floor is pinned, and the
ratchet comment names the one kept export and the PATH case line.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…; a kept profile verdict keeps its launch file

Fourth review cycle. The new trailer code now has its row in
lib/result-codes-capy.ts (the owner module is at its size cap) and its
docs/troubleshooting.md anchor, so the install-side code scan resolves it.
A failing profile check (--for review-voice) that keeps a fuller ok verdict
for this HEAD no longer deletes that verdict's launch file: the fail branch
removes the file only when the run rewrites the verdict, and setup_failed
removes it too. The docs say "a failing run that rewrites the verdict",
and that an unwritable directory keeps both the old file and the old
verdict. A new test runs a passing install, then a failing profile check,
and asserts the file and the ok verdict both survive.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…e an assertion that fails without them

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

Fifth review cycle: setup_failed's cleanup had no assertion. The setup
failure test now installs once (launch file present), commits a new HEAD so
setup runs again, fails that setup, and asserts the launch file is gone and
the verdict says ok:false before the next run sets up again and ends ok.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…aunch-file contract (Step 14.5 audit)

The /document-release audit (docs-3449-1792992068) corrected three authored
docs: docs/state-root.md shows the GSTACK_LAUNCH_FILE line and says to apply
it with ". <that file>" instead of prefixing or exporting the assignments;
docs/CONTRIBUTOR_REFERENCE.md names scan()'s one ambient input instead of
calling it pure; docs/capy-install.md's bun-shim bullet and exit table name
the launch file and the fail launch-file trailer.

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>
@github-actions github-actions Bot changed the title fix(capy): source the launch environment from a 0600 file; no skill fence may print the environment (GSTA-104) v1.91.243.0 fix(capy): source the launch environment from a 0600 file; no skill fence may print the environment (GSTA-104) Oct 26, 2026
@capy-ai
capy-ai Bot merged commit 8018ba5 into main Oct 26, 2026
62 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