Skip to content

Destructive-command check catches more force pushes and outside deletes, and stops asking about quoted spellings - #4604

Merged
capy-ai[bot] merged 6 commits into
mainfrom
careful-guard-fixes-v2
Nov 22, 2026
Merged

capy-ai[bot] merged 6 commits into
mainfrom
careful-guard-fixes-v2

Conversation

@garrytan

@garrytan garrytan commented Nov 21, 2026 •

Copy link
Copy Markdown
Owner

The destructive-command check now catches force pushes to main hidden behind abbreviated or misplaced dry-run flags, and asks before deletes that reach a system folder through a cd (including cd ../../etc) or a device node under /dev.
Quoting no longer changes its decision: a quoted build-folder delete or a quoted gh title or body gets the same answer as its unquoted spelling, which was already allowed. Fixes #4628, fixes #4601.
Nothing to do; no command that main asks about or blocks becomes allowed except those same-command spellings.

Changes, with the commands they cover

careful/bin/check-careful.sh, toward asking or blocking more:

  • git push -fn --no-dry origin main: any unambiguous prefix of --no-dry-run undoes -n.
  • git push -f -o -n origin main, -fo -n, --push -n: the value of -o/--push-option keeps the dry-run state before it and never takes a value itself.
  • git push -f4, -4f, -fo-n: a short flag group with a digit still forces. -fn4 and -4fn stay dry runs, as main reads them.
  • git push -f -o ci.skip origin on main: the push is read both with and without the push-option value as an operand, so it is blocked like git push -f origin.
  • cd /etc/nginx && rm -f sites-enabled/default, cd ../../../etc && rm -f hosts, cd /dev && rm -f sda: a relative delete after a cd into a system folder asks; .. is folded the way cd reads it.
  • rm -f /dev/loop0, /dev/sg0, /dev/zram0, /dev/ram0, /dev/mtd0, /dev/ubi0, /dev//sdb1: removing a device node asks.

Spelling-independent decisions, each with negative controls in test/careful-replay.test.ts:

  • rm -rf "/home/me/app/dist" is allowed like rm -rf /home/me/app/dist when nothing in the quotes differs from the unquoted spelling (no $, backtick, glob, ~, space or ..).
  • gh issue create --title "… git push … -f" and the quoted --title/--body (-t/-b) of gh issue/gh pr create, comment and edit are masked like a commit message, matching their backslashed spelling. A double-quoted value with $( or a backtick, a later statement, a pipe, echo, bash -c and other gh subcommands are still read.
  • git push -fn > -o --no-dry-run origin main, git push -n -f --receive-pack -o --no-dry-run origin main: a push-option value never makes a push safer. It can't start a dry run, and a --no-dry-run after -o still undoes -n, since a redirect or another option can take -o itself.
  • git push -fn4 --no-dry-run origin main: a later --no-dry-run undoes the -n in a digit group.

test/helpers/native-auto-decide.ts: a skill load whose output holds the loader's own SKILL_START: line is not credited as the session's start.

Main-vs-head comparison

5,920 push, redirect and cd-then-delete commands: 5,281 same, 639 stricter, 0 looser.

18,346 more commands covering quoted deletes, gh titles and bodies, cd .., /dev nodes and push flag groups: 17,411 same, 467 stricter, 468 looser (unchanged by the last two commits, which only add asks or denies). Of the 468, 216 were asks on main and 252 were blocks (quoted gh text such as --title 'git push -f origin main'); main allows the backslashed spelling of every one. Every looser one is a quoted build-folder delete or a quoted gh title or body, and each one's unquoted or backslashed spelling is allowed by main (checked by running main on all 468). None is a double-quoted command substitution.

Issues

Fixes #4628
Fixes #4601

Agent notes

Lane GSTA-685 / GST-3357. Revives #4604 after its first /ship stopped on four findings (second-model #1 -fn4, adversarial #1 .. in cd, #2 push-option value as operand, #4 /dev list), all fixed here. Spelling ruling (GStack Minder, 2026-11-22): a guard change may allow a command main asks about only when it is the same command in a different spelling (quoting or escaping) that main already allows; negative controls included. Successor to #4599 (closed unmerged). 7(d) (/dev/shm and /dev/fd redirects) and the redactor stay deferred. Known, same on main: ;/|| clear the cd folder; rm -f /dev/[l]oop0 allows; git push -f --receive-pack -n origin main allows; git push -o --repo -f origin main allows; cd ~ && rm -f .ssh/id_rsa is unchecked; git push -n4 -f origin main denies though git runs a dry run (kept as main reads it). #4628 and #4601 credited to TayTaySwizzle with Co-authored-by.
Plan: exempt: bug fix

Test coverage gap (no regression owed): the gh masking has replay rows only for long --title/--body with create and comment; -t/-b, --title=/--body= and edit are covered by the 18,346-command addendum, not by careful-replay rows.

Open notes, misses main shares, tracked in GST-3510: cd ../../etc && rm -f hosts when the session folder is itself under /opt or /root; find /etc -delete on a system folder itself; cd ~/.ssh && rm -f id_rsa. Also allowed because main allows the unquoted spelling: rm -rf "/usr/lib/build".

{
  "schema_version": 1,
  "pr": 4604,
  "head": "032ccf6c8d863b540a13bdedc09b1ef5edf2fd5d",
  "version": "1.102.2.0",
  "base": "main",
  "gate": {
    "tests": {
      "pass": 1743,
      "fail": 0,
      "skip": 7
    }
  },
  "ci_carried": [
    {
      "lane": "tests",
      "run": 44999976524,
      "attempt": 1,
      "tree": "36951a8f41e8c408793ba44938e1c1e76cb0f7b6"
    }
  ],
  "calls": 52,
  "session_kind": "unattended",
  "run": "run",
  "head_tree": "36951a8f41e8c408793ba44938e1c1e76cb0f7b6",
  "product_patch_id": "602e4ba5255e33f9d2b85622ee9cb5516adbd857",
  "gstack_version": "1.102.2.0",
  "review_depth": {
    "depth": "full",
    "class": "code",
    "runtime_lines": 113,
    "rules": "630fd3101899e28e",
    "base": "0b4f0ceeec19fef62480db6c8eb00c4015380a39",
    "registry": "0b4f0ceeec19fef62480db6c8eb00c4015380a39",
    "gate_scan": {
      "tagged": 0,
      "head": "032ccf6c8d863b540a13bdedc09b1ef5edf2fd5d"
    },
    "reasons": [
      "risk:security",
      "runtime=113"
    ],
    "risk": [
      "security"
    ],
    "mode": "panel",
    "declared": [
      "security"
    ],
    "detected": [
      "security"
    ]
  },
  "pregate": "requires-remote cleared @36951a8f41e8 (8 checks, current for 032ccf6c8d86)",
  "requires_remote": [
    "free-tests.yml/macos-named-regressions: https://github.com/garrytan/gstack/actions/runs/44999976524/attempts/1",
    "pregate.json/remote_gate: remote-gate tree=36951a8f41e8 tests=38928 skipped=89 runs=44999976524/1 profiles=ci-reuse/free-tests heads=032ccf6c8d86 verified=2026-11-22T08:19:37.542Z"
  ],
  "issues": {
    "fixes": [
      4601,
      4628
    ],
    "refs": [],
    "flakes": []
  },
  "docs": {
    "status": "current",
    "scope": "careful/, docs/ and README.md against the branch diff c2b4f0d..4da55a1 plus the changelog fragment"
  },
  "review_loop": {
    "passes": 1,
    "blocking_found": 3,
    "deferred": 0,
    "noted": 3,
    "fixed": 4,
    "scope": "frozen",
    "fix_checks": 2,
    "rounds": 1,
    "ledgers_read": 4,
    "dispatches": {
      "specialist": 1,
      "red-team": 1
    }
  },
  "review_round_grants": [
    {
      "kind": "fix-check",
      "head": "e55c9aaf17cfed7ca17144f3e4f2e94522d344c5",
      "pr": 4604,
      "by": "GSTA-36",
      "reason": "One scoped fix-check of 369cbd9 and 4da55a1 for the Step 11 blockers",
      "at": "2026-11-22T07:16:05.266Z",
      "approval": "a-f1d0d122dbbe",
      "stop_run": "run",
      "findings": [
        "p1/adversarial-native#1",
        "p1/outside-voice#1",
        "p1/outside-voice#2"
      ]
    }
  ],
  "gate_dispositions": []
}
{"head":"a54ffcb7ef6bda7c06dbf684303d50e9637fe696","run":"run","mark":"stop","tree":"e394ef201d0383e9c63bda17bf01e298d9db1273"}
{"head":"e55c9aaf17cfed7ca17144f3e4f2e94522d344c5","run":"run","mark":"grant","grant":"a-f1d0d122dbbe"}

Open in Capy

…es, and stops reading a push-option value as undoing a dry run

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

trunk-io Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

😎 This pull request was merged.

garrytan and others added 2 commits November 22, 2026 05:31
…out quoted spellings

A short push flag group with its own -n is a dry run again, as main reads it.
A push-option value is no longer read as the remote. A cd that climbs with ..
into a system folder, and more /dev device nodes (sg, zram, ram, mtd, ubi),
now ask before a delete. A quoted build-folder delete and the quoted title or
body of gh issue and gh pr create, comment and edit get the decision main
gives their unquoted or backslashed spelling (#4628, #4601).

Co-authored-by: TayTaySwizzle <[email protected]>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@capy-ai capy-ai Bot changed the title Destructive-command check catches more force pushes to main and deletes outside the project Destructive-command check catches more force pushes and outside deletes, and stops asking about quoted spellings Nov 22, 2026
garrytan and others added 3 commits November 22, 2026 06:29
…ort flag group with a digit

Review-Finding: p1/red-team#1 reader=red-team
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…er, and quoted build folders need a gap between them

Removes the exemption that let a --no-dry-run read as an -o value leave -n
standing: an option or redirect before -o can take -o itself, so git may run
--no-dry-run after all. A later --no-dry-run also undoes the -n in a short
group with a digit. Build-folder targets in a quick-allowed rm now need
whitespace between them.

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant