Skip to content

Destructive-command check closes the parsing gaps found after #4513 and blocks wipefs -a in every spelling (GST-3190) - #4525

Merged
capy-ai[bot] merged 5 commits into
mainfrom
careful-wipefs-every-spelling
Nov 19, 2026
Merged

capy-ai[bot] merged 5 commits into
mainfrom
careful-wipefs-every-spelling

Conversation

@garrytan

@garrytan garrytan commented Nov 19, 2026 •

Copy link
Copy Markdown
Owner

The destructive-command check now blocks force-pushes to main written with --repo=, after a cd, or with --all, and asks again for the other shapes that slipped past it after #4513.
wipefs -a is blocked in every spelling, including targets fed by xargs; only existing image files it names outside /dev are exempt. Dry runs and greps for SQL text stop over-blocking.
Nothing to do: the check runs in every session already.

What changed, by shape

Steps back from main, fixed first:

  • git push --repo=origin +refs/heads/main and git push --repo=origin --force main are denied. With --repo, every operand is read as a possible refspec (git itself reads the first one as the repository, so this is the cautious reading).
  • A cd inside a pipeline (cd /tmp | true && rm -rf dir) no longer counts as moving into scratch: bash runs each pipeline part in a subshell. A subshell now gives back the exact outer state, so cd /tmp && (pwd) && rm -rf dir no longer asks.
  • git reset --hard "$REV" asks again.
  • printf x >> f && git reset --hard on a clean tree stays allowed: the only work it can lose is what the same command wrote. git stash pop earlier in the same command does make a later discard ask, because pop drops the stash, the same loss stash drop always asks about.

Gaps in the catches #4513 added:

  • git clean -q / --quiet no longer hides the dry-run listing.
  • --work-tree, --git-dir, GIT_DIR= and GIT_WORK_TREE= forms of checkout -f, switch -f and clean -f ask.
  • find -L <dir> -delete (leading find options) is read correctly.
  • rm dir -rf with flags at the end asks when rm is the command; docker rm web -f and aws s3 rm stay those tools' subcommands.
  • A mktemp variable assigned again in the same command is no longer scratch.
  • .. beats the /proc and /dev exemptions, a cd through .. is never scratch, and rm -rf ../build no longer rides the build-output allow.
  • A cloud delete's dry run counts only from the delete itself to the end of its statement, so a dry run on the line before never excuses it, and plan counts only as a whole word.
  • A cd after if, while, until or time still counts, so if cd B; then git clean -fdx; fi asks.
  • GSTACK_SESSION_KIND=interactive outranks CI=1 in the every-session guard hook (claude -p stays headless).

wipefs:

  • wipefs is back in the whole-command disk-wipe deny for -a, any short-option group holding a (-fa), and the abbreviations --a and --al that getopt accepts for --all. That deny sees targets the word scan cannot: ls /dev/sd* | xargs wipefs -a and echo /dev/sdb | xargs wipefs --all are denied again.
  • The one exemption sits on top of that deny: every statement in the command must be a wipefs that leads its statement (after sudo or NAME=value), and every target, with options read the way getopt reads them, must be a plain literal path outside /dev with a disk-image suffix (.img, .iso, .raw, .qcow2, .vhd, .vhdx, .vmdk, .dmg) that already exists as a regular file, not a symlink, in a folder the check knows. A redirect into /dev other than /dev/null, /dev/stdout or /dev/stderr breaks the exemption. A short group stops at t, o or O, whose value is the rest of the word, or the next word when nothing follows, so wipefs -a -tvfat /dev/sdb no longer hides its device. wipefs -a demo.img, wipefs -t ext4 -a demo.img and wipefs --all disk.qcow2 build/b.iso are allowed.
  • Still denied, on purpose: ls *.img | xargs wipefs -a (targets not spelled out), ln -sf /dev/sdb d.img; wipefs -a d.img and a symlinked alias.img, wipefs -a demo.img > /dev/mmcblk0, wipefs -a demo.img; wi''pefs -a /dev/sdb, an image created earlier in the same command, a wipefs beside any other statement or inside bash -c '…', wipefs -tvfat /dev/sdb without -a (the deny reads the a in vfat), and quoted image names with spaces.

Other over-catches removed:

  • git push -nf is a dry run (letters after o in a short-option group are a push-option value, not flags).
  • The bare SQL shape (TRUNCATE x;) is ignored inside grep, rg, ag, ack and git grep, and in echo/printf text when nothing after it pipes or redirects (|| is not a pipe); ./psql/ in a path is a folder, not a client.

Force-pushes that only asked:

  • cd . && git push -f origin on main is denied: git now reads the folder a cd chain leads to for the force-push lookups (discard checks still ask after any cd).
  • git push --force --all, --branches and --mirror are denied when main, master or the default branch exists locally.

Speed: the statement loop no longer indexes a bash array, which is linear per read on bash 3.2, so a 200 KB command takes about a third of the time on bash 3.2. Everyday commands against 55aaa6c on the same machine (interleaved, the 102 GEVA-560 commands in turn, n=400 each): bash 5.2 p50 99.6 ms vs 95.1 ms, bash 3.2.57 p50 94.3 ms vs 90.6 ms; p90 is lower on the branch in both. Process start dominates, and the base p50 itself moved by 20 ms between passes on this machine, so the 4 ms gap is within run-to-run drift.

Tests

test/careful-replay.test.ts gains 63 rows (PARSER_CASES), one or more per shape above. The 8 wipefs rows (xargs, stdin, --a, --al, an attached -t value alone and in a group, --al on /dev/sdb.img, image names from xargs) each fail at f7dd58d and are denied at 944b41e. 4 more (a symlinked image, a symlink made in the same command, a redirect into /dev/mmcblk0, a quoted spelling) fail at 05b36ee; three are controls. The test trees now hold real demo.img, disk.qcow2 and build/b.iso files and an alias.img symlink. test/destructive-guard-hook.test.ts gains the CI=1 case. Replay plus hook tests: 270 pass, 0 fail on bash 5.2.21 and on bash 3.2.57.

Not in this PR (outside its scope, none a step back from main): a quoted scratch path with a space, denying a literal home path, a failure while reading input before the safety trap, a backtick revision in reset --hard, and the extra /tmp asks GEVA-560 measured (a relative rm -rf after a second cd, a subshell, a loop or an unresolved $VAR).

Open notes from #4521's review, left for a follow-up:

  • The SQL-text exemption still allows grep 'truncate users;' a.sql | sh, the same through <( ) process substitution and git grep -O, and echo "$(dbtool exec 'TRUNCATE TABLE users')".
  • LC_ALL=C cd /tmp && rm -rf dir asks, and printed SQL text followed by a pipe in a later statement asks.
  • Quoted parentheses can restore an earlier cd into scratch, and echo cd /tmp still counts as a cd.
  • grep 'a; truncate demo;' (a quoted ;) still asks, and sudo -u root rm dir -rf is still allowed, as on main.

Open notes from this PR's second-model review, ruled not to block because each needs quote tricks or contradictory flags and main already allows an equivalent shape:

  • wipefs -a demo.img >'/dev'/sdb: a quoted /dev redirect target isn't seen as /dev (main already allows echo hi >'/dev'/sdb).
  • wipefs -a demo.img" #" /dev/sda: a quoted # is read as a comment, so the later target is never seen (it only reaches the disk if a file named demo.img # exists).
  • git push -fn --no-dry-run origin main: --no-dry-run after an n in a short group isn't read as undoing the dry run (main already allows git push --force -n --no-dry-run origin main).
  • git push --mirror in a checkout without a local default branch still only asks, as on main.
  • git grep -h 'TRUNCATE TABLE' | dbwrap prod: search output piped to an unlisted client, the same class as the SQL-text note above.
  • A folder that is already a symlink into /dev can get a redirect past the image exemption (wipefs -a demo.img > d/sdb with d -> /dev): the /dev checks read the path as text. Main already allows echo hi > d/sdb through the same folder.
  • Over-catch: _RX_WIPEFS also matches a longer word, so echo wipefs-archive now denies.
Agent notes

Ruled note: careful/bin/check-careful.sh:391:outside-voice at b8293b8 ruled by Captain GStack Minder (GSTA-36) at 2026-11-19T13:45:15.524Z: a quoted /dev redirect target needs a quote trick; main already allows echo hi >'/dev'/sdb (approval a-1dc0735f73d8)
Ruled note: careful/bin/check-careful.sh:515:outside-voice at b8293b8 ruled by Captain GStack Minder (GSTA-36) at 2026-11-19T13:45:16.536Z: git push -fn --no-dry-run needs contradictory flags; main already allows git push --force -n --no-dry-run (approval a-c289674fc5e4)
Ruled note: careful/bin/check-careful.sh:472:outside-voice at b8293b8 ruled by Captain GStack Minder (GSTA-36) at 2026-11-19T13:45:17.464Z: git push --mirror asks at every head; not a regression from main (approval a-153c82a0c35a)
Ruled note: careful/bin/check-careful.sh:985:outside-voice at b8293b8 ruled by Captain GStack Minder (GSTA-36) at 2026-11-19T13:45:19.502Z: search output piped to an unlisted client is the ruled SQL-text class; main asks only on the word, never the file (approval a-5041355f66fd)
Ruled note: careful/bin/check-careful.sh:741:adversarial-native at b8293b8 ruled by Captain GStack Minder (GSTA-36) at 2026-11-19T13:45:21.224Z: a quoted # hiding a later wipefs target needs a quote trick and a file named with it (approval a-5654b7908015)

{
  "schema_version": 1,
  "pr": 4525,
  "head": "b8293b8bc9f495d59afb5b4a2383dee864d7a29c",
  "version": "1.101.0.0",
  "base": "main",
  "gate": {
    "free": {
      "pass": 1707,
      "fail": 0,
      "skip": 0
    },
    "careful": {
      "pass": 270,
      "fail": 0,
      "skip": 0
    }
  },
  "ci_carried": [
    {
      "lane": "free",
      "run": 44536261050,
      "attempt": 1,
      "tree": "018b06ada44445d51fce6487f887175d09a06fd2"
    }
  ],
  "calls": 23,
  "session_kind": "unattended",
  "run": "ship-4525-b8293b8",
  "head_tree": "018b06ada44445d51fce6487f887175d09a06fd2",
  "product_patch_id": "5c063815f161a8158824cfe3760908c3f64c4b4f",
  "gstack_version": "1.101.0.0",
  "review_depth": {
    "depth": "light",
    "class": "code",
    "runtime_lines": 326,
    "rules": "1afa38a4be3b5eef",
    "base": "b23e1b01a783eb1c439aa728826aa441e5baba80",
    "registry": "b23e1b01a783eb1c439aa728826aa441e5baba80",
    "gate_scan": {
      "tagged": 0,
      "head": "b8293b8bc9f495d59afb5b4a2383dee864d7a29c"
    },
    "reasons": [
      "runtime=326"
    ],
    "risk": [],
    "mode": "panel"
  },
  "pregate": "requires-remote cleared @018b06ada444 (8 checks, current for b8293b8bc9f4)",
  "requires_remote": [
    "free-tests.yml/cso-macos-launcher: https://github.com/garrytan/gstack/actions/runs/44531246336/attempts/2",
    "free-tests.yml/macos-named-regressions: https://github.com/garrytan/gstack/actions/runs/44531246336/attempts/2",
    "windows-smoke.yml/windows-smoke: https://github.com/garrytan/gstack/actions/runs/44531246191/attempts/1",
    "pregate.json/remote_gate: remote-gate tree=018b06ada444 tests=38225 skipped=104 runs=44536261050/1 profiles=ci-reuse/free-tests heads=b8293b8bc9f4 verified=2026-11-19T13:53:54.378Z"
  ],
  "issues": {
    "fixes": [],
    "refs": [],
    "flakes": []
  },
  "docs": {
    "status": "current",
    "scope": "docs/ and README.md, plus careful/SKILL.md.tmpl and guard/SKILL.md.tmpl reviewed"
  },
  "review_loop": {
    "passes": 1,
    "blocking_found": 4,
    "deferred": 0,
    "noted": 8,
    "fixed": 0,
    "scope": "frozen",
    "rounds": 1,
    "ledgers_read": 2,
    "unbound": 1
  },
  "ruled_notes": [
    {
      "finding": "careful/bin/check-careful.sh:391:outside-voice",
      "head": "b8293b8bc9f495d59afb5b4a2383dee864d7a29c",
      "by": "Captain GStack Minder (GSTA-36)",
      "reason": "a quoted /dev redirect target needs a quote trick; main already allows echo hi >'/dev'/sdb",
      "at": "2026-11-19T13:45:15.524Z",
      "approval": "a-1dc0735f73d8"
    },
    {
      "finding": "careful/bin/check-careful.sh:515:outside-voice",
      "head": "b8293b8bc9f495d59afb5b4a2383dee864d7a29c",
      "by": "Captain GStack Minder (GSTA-36)",
      "reason": "git push -fn --no-dry-run needs contradictory flags; main already allows git push --force -n --no-dry-run",
      "at": "2026-11-19T13:45:16.536Z",
      "approval": "a-c289674fc5e4"
    },
    {
      "finding": "careful/bin/check-careful.sh:472:outside-voice",
      "head": "b8293b8bc9f495d59afb5b4a2383dee864d7a29c",
      "by": "Captain GStack Minder (GSTA-36)",
      "reason": "git push --mirror asks at every head; not a regression from main",
      "at": "2026-11-19T13:45:17.464Z",
      "approval": "a-153c82a0c35a"
    },
    {
      "finding": "careful/bin/check-careful.sh:985:outside-voice",
      "head": "b8293b8bc9f495d59afb5b4a2383dee864d7a29c",
      "by": "Captain GStack Minder (GSTA-36)",
      "reason": "search output piped to an unlisted client is the ruled SQL-text class; main asks only on the word, never the file",
      "at": "2026-11-19T13:45:19.502Z",
      "approval": "a-5041355f66fd"
    },
    {
      "finding": "careful/bin/check-careful.sh:741:adversarial-native",
      "head": "b8293b8bc9f495d59afb5b4a2383dee864d7a29c",
      "by": "Captain GStack Minder (GSTA-36)",
      "reason": "a quoted # hiding a later wipefs target needs a quote trick and a file named with it",
      "at": "2026-11-19T13:45:21.224Z",
      "approval": "a-5654b7908015"
    }
  ],
  "gate_dispositions": []
}

Open in Capy

garrytan and others added 4 commits November 19, 2026 11:16
… the last release (GST-3190)

Force-pushes to main written with --repo=, after a cd or with --all are blocked again; pipeline cds, $ reset revisions, quiet git clean, alternate git trees, find -L, trailing rm flags, reassigned mktemp variables, .. paths and same-line dry runs ask again; dry-run pushes, wipefs on files and SQL text in greps no longer trip it; GSTACK_SESSION_KIND=interactive outranks CI=1.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…atement, and six review fixes (GST-3190)

A dry run on the line before no longer excuses a real aws delete. SQL text that is printed into a pipe or file still asks, push-option values are not read as flags, wipefs stays blocked unless every target is a disk image, cd counts only as a command, and || is not a pipe.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
… and wipefs reads /dev and option values correctly (GST-3190)

Puts back the earlier cd handling, so a discard after if cd, while cd or time cd asks again. wipefs stays blocked for any /dev/ target, and the values of -t, -o and -O are not read as targets.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…ncluding targets from xargs or stdin (GST-3190)

wipefs goes back into the whole-command disk-wipe deny for -a, a short
group holding a, --a, --al or --all. The only exemption is a command whose
every wipefs leads its statement and names only image files outside /dev.

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

trunk-io Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

😎 This pull request was merged.

…isting regular files in a command of plain wipefs statements (GST-3190)

The image exemption now also needs every target to exist as a regular
file that is not a symlink, every statement in the command to be a proven
wipefs, and no redirect into /dev other than null, stdout or stderr.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@capy-ai
capy-ai Bot merged commit 1730386 into main Nov 19, 2026
110 of 113 checks passed
capy-ai Bot added a commit that referenced this pull request Nov 19, 2026
- `gstack-artifact validate` no longer passes a run.json that gstack-autoplan never wrote. (#4494)
- /ship's changed-number check no longer stops on tests that only share a word with the change (#4478). (#4496)
- On Capy, /ship no longer edits or comments on pull requests as you. (#4518)
- The destructive-command check stops asking about scratch deletes and catches the real damage it used to miss. (#4513)
- The destructive-command check reads commands more carefully, closing gaps found after the last release. (#4525)
- The Codex readiness check and the second-model review now pick the same model for a custom Codex provider (GST-3089). (#4491)
- gstack's Codex hooks work when your Codex folder's path has a `(`, `&` or other shell character in it. (#4528)
- Uninstalling gstack keeps your own Codex hooks trusted. (#4528)
- Codex hook setup matches Codex more closely. (#4528)
- On Windows, setup copies the Claude Code hook code that gstack's Codex hooks import (#4528)
- /review's checklist on Codex reads shell commands more carefully. (#4528)
- On Codex, gstack now suggests the right skill for a prompt and stops destructive commands before they run. (#4512)
- On Codex, /review is now held once when it tries to finish without its adversarial pass or its report, as it already is on Claude Code. (#4522)
- On Codex, gstack's skill suggestion now names the skill the way Codex lists it. (#4523)
- On Codex, gstack's suggested prompts and docs now name skills the way Codex lists them. (#4524)
- /review on Codex with gpt-6.1-sol is no longer held back for a second-model pass it already ran. (#4526)
- On Codex, office-hours, plan-design-review and gstack-upgrade work again when you name them. (#4510)
- gstack knows when Codex is running unattended. (#4510)
- Codex reviewers start with a clean context. (#4510)
- Docs no longer say Codex has no hook support. (#4510)
- A command whose output was cut off no longer counts as a finished read. (#4492)
- A folder marked as published data can no longer hide source code or agent files from /ship's review. (#4516)
- Correction to the on-by-default helper hooks entry: the hook still routes only to /review, /qa and /verify, so skills you've installed yourself aren't suggested yet. With gstack's skills it routes 14 of 60 real bug reports (was 17), and long prompts are no longer skipped. (#4505)
- /sync-gbrain's read check now works when the first page in your code source is over 64 KB. (#4497)
- Free-suite CI no longer fails before any test runs when Ubuntu's package mirror is slow. (#4530)
- Syncing a second repo no longer makes the first one ask for /sync-gbrain again. (#4532)
- gstack's helper hooks are now on by default in Claude Code, OpenClaw and Hermes, and the prompt-routing hook fires on real bug reports. (#4503)
- `gstack-pregate clear --receipt` accepts a remote gate run from before a merged release when the release only regenerated a declared release output. (#4483)
- The second-model review now keeps the reviewer's own result, and reports a used-up budget as a budget stop. (#4515)
- When the reviewer wrote its review to the result file it was asked for, Codex then replaced that file with its short closing message ("Done, I wrote the review"), so the review was thrown away and reported as missing its markers. (#4515)
- When the provider refuses the call with HTTP 402 Payment Required (usually a metering proxy that hit its allowance, or an account out of credits or quota), gstack used to record only "exit 1". (#4515)
- The pre-commit /verify check now fails a check that times out, and its checks share one time budget (GST-3201). (#4527)
- /ship's review collector no longer reads a reviewer's own scope list or list of passed checks as findings (GST-3201). (#4527)
- Merge-queue stack tests fail when git cannot list a PR's added test files (GST-3201). (#4527)
- /ship can now review results PRs that publish raw session data. (#4511)
- /ship's review pass works when the checkout you ship isn't the project's default checkout. (#4507)
- A second review round no longer reports done when nothing was reviewed. (#4520)
- The prompt-routing hook now suggests skills you install yourself, and no longer sends ordinary bug reports to /qa (GST-3123). (#4506)
- gstack's script runner and merge-queue checks now also refuse cut-off output. (#4502)
- A failed second-model review reports the cause that actually stopped it, and the runner never deletes its own prompt. (#4519)
- `gstack-ship-queue ready` now fills in the trial merges and the second-model trail read instead of printing lines to fill. (#4529)
- Five small ship-tool fixes. (#4529)
- A ruling the owner gives while a `/ship` run is open can be relayed. (#4529)
- /ship no longer kills a working test run as stalled when the test command starts its workers in their own session. (#4533)
- /ship no longer stops a review because the state-machine reader started its reply the way its instructions say. (#4504)
- When Claude Code runs /verify right before a commit, it now gets a quick check instead of the full fix loop (GST-3150). (#4508)

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.

1 participant