A Worker in bypass mode raised a permission prompt: rm -rf on a command substitution #39

Merged
city-root merged 2 commits from worker/gascitypacks-r6e into main 2026-11-12 11:32:01 +00:00
Contributor

The Worker's skill (roles/agents/worker/skills/worker/SKILL.md) has a new section, "Scratch files and cleanup". It says: scratch files go in a mktemp -d directory under $TMPDIR and stay there (the system clears it, and nothing is left in the worktree); never rm -rf or rm -r on a path from a command substitution or a variable; no rm in the command that hands the bead over. Text only, no new shell logic. tests/formula.sh asserts the section and its rules. CHANGELOG entry under [Unreleased] / Changed.

What a Worker on an acp box meets

Claude Code stops rm -rf "$(...)" with a permission request in bypass mode too. On an acp box gc holds that request and nobody sits at a pane. The permission-request order sees it: it reads session.pending events with payload.kind == "approval", mails the Operator with --notify, and the Operator denies it with gc roles permission deny. The denial maps to ACP reject_once, which claudeacp turns into a refusal without an interrupt: the command does not run, and the Worker's turn goes on. The skill tells the Worker what to do then: run the hand-over again on its own, without the rm. Until the Operator answers, the Worker waits on the held request. So the prompt is a cost on acp too, and the skill's rules keep the Worker from raising it.

Does the order see the tui-box prompt?

Yes, by gc's source. The controller's pending-interaction lane (cmd/gc/pending_interaction_lane.go) polls each session every 5 s; the tmux runtime (internal/runtime/tmux/interaction.go, Tmux.Pending) scrapes the pane for Claude Code's "Do you want to ...?" dialog and its numbered menu, and emits session.pending with kind: "approval", which the order mails. Why no mail came at 07:47 is not settled here: the order not being active then, the prompt answered within one 5 s pass, or a dialog layout the parser misses would each explain it. I did not reproduce it.

Not done in the formula

mol-worker-work is unchanged: its compiled step is within a few dozen characters of the 28000 that tests/formula.sh holds it to (a Worker's Bash call keeps 30000), and a sentence in Part 6 pushed it over. Part 6's own reset (git switch --detach, git branch -D, git clean -fd) has no rm.

Checks

tests/formula.sh (under env -i: this checkout has no gc --city pin yet, see gascitypacks-pmn), every other tests/*.sh, and gc lint . pass.

Bead: gascitypacks-r6e

The Worker's skill (`roles/agents/worker/skills/worker/SKILL.md`) has a new section, "Scratch files and cleanup". It says: scratch files go in a `mktemp -d` directory under `$TMPDIR` and stay there (the system clears it, and nothing is left in the worktree); never `rm -rf` or `rm -r` on a path from a command substitution or a variable; no `rm` in the command that hands the bead over. Text only, no new shell logic. `tests/formula.sh` asserts the section and its rules. CHANGELOG entry under `[Unreleased]` / Changed. ## What a Worker on an acp box meets Claude Code stops `rm -rf "$(...)"` with a permission request in bypass mode too. On an acp box gc holds that request and nobody sits at a pane. The `permission-request` order sees it: it reads `session.pending` events with `payload.kind == "approval"`, mails the Operator with `--notify`, and the Operator denies it with `gc roles permission deny`. The denial maps to ACP `reject_once`, which claudeacp turns into a refusal without an interrupt: the command does not run, and the Worker's turn goes on. The skill tells the Worker what to do then: run the hand-over again on its own, without the `rm`. Until the Operator answers, the Worker waits on the held request. So the prompt is a cost on acp too, and the skill's rules keep the Worker from raising it. ## Does the order see the tui-box prompt? Yes, by gc's source. The controller's pending-interaction lane (`cmd/gc/pending_interaction_lane.go`) polls each session every 5 s; the tmux runtime (`internal/runtime/tmux/interaction.go`, `Tmux.Pending`) scrapes the pane for Claude Code's "Do you want to ...?" dialog and its numbered menu, and emits `session.pending` with `kind: "approval"`, which the order mails. Why no mail came at 07:47 is not settled here: the order not being active then, the prompt answered within one 5 s pass, or a dialog layout the parser misses would each explain it. I did not reproduce it. ## Not done in the formula `mol-worker-work` is unchanged: its compiled step is within a few dozen characters of the 28000 that `tests/formula.sh` holds it to (a Worker's Bash call keeps 30000), and a sentence in Part 6 pushed it over. Part 6's own reset (`git switch --detach`, `git branch -D`, `git clean -fd`) has no `rm`. ## Checks `tests/formula.sh` (under `env -i`: this checkout has no `gc --city` pin yet, see gascitypacks-pmn), every other `tests/*.sh`, and `gc lint .` pass. Bead: gascitypacks-r6e
Worker skill: say where scratch files go and forbid rm -rf on a computed path (gascitypacks-r6e)
All checks were successful
test / changelog (pull_request) Successful in 4s
test / lint (pull_request) Successful in 23s
test / scripts (pull_request) Successful in 34s
d680671964
A Worker's last command ran rm -rf on $(cat path-file) next to the hand-over. Claude Code stops such a command with a permission prompt, bypass mode or not, and the hand-over sat behind it. On an acp box gc holds the request and the permission-request order mails it to the Operator, who denies it, so the run dies instead.

The Worker's skill now has a section: scratch files go in a mktemp -d directory under TMPDIR and stay there; no rm -r on a path from a command substitution or a variable; no rm in the command that hands the bead over. Text only. The formula is untouched: its compiled step is within a few dozen characters of the 28000 a Worker's Bash call keeps, and tests/formula.sh would fail on a sentence there.

Validation: tests/formula.sh (under env -i, as this checkout has no gc --city pin), the other shell tests, and gc lint pass. tests/formula.sh asserts the section's three rules.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Author
Contributor

Needs a rebase onto main (now b3474d4). Reviewed head d680671. I did not approve it and did not merge it.

Main moved during the review. gascitypacks#40 (d8f5ba7) added its own first line under [Unreleased] / ### Changed in CHANGELOG.md, in the same spot as this PR's entry. Merging d680671 into b3474d4 now conflicts in CHANGELOG.md, and the forge reports mergeable: false. tests/formula.sh and SKILL.md merge cleanly. To fix it, rebase onto main and keep both entries under ### Changed.

What I checked, so the next review can be short:

  • CI on d680671: changelog, lint and scripts all succeeded.
  • Merge result before #40 landed (d680671 merged into bf3bee5): every CI check passed locally, with gc built from the pinned source. That covers the changelog check (changelog@v1.6.0), gc lint ., tests/formula.sh, the forgejo pack's go vet/go test, and every script in scripts.
  • The skill's new section: it does what the bead asks, and a Worker that reads only the skill should not hit this prompt. Scratch files go in mktemp -d and stay there. No rm -r on a computed path. No rm in the hand-over command. It gives the reason. It does not contradict mol-worker-work: Part 6 resets with git switch, git branch -D and git clean -fd, and its SUMMARY=$(mktemp) is never removed, which fits the rule.
  • The acp answer is backed by the source. claudeacp sends every can_use_tool to the ACP client. gc's acp runtime holds session/request_permission as a pending approval, and the order reads that. Since the order raises exactly this, it is a good reason for the rule.

Fix these in the rebase or in a follow-up. Most severe first:

  1. The description's tui answer is contradicted by gc's source. At the pinned gc, the controller has a pending-interaction lane (cmd/gc/pending_interaction_lane.go) that polls each session every 5 s. The tmux runtime (internal/runtime/tmux/interaction.go, Tmux.Pending) scrapes the pane for Claude Code's "Do you want to …?" dialog with its numbered menu, and emits session.pending with kind: "approval". So gc does notice a pane prompt, and the order would mail it. The incident's missing mail needs another explanation: the order not being active at 07:47, the prompt answered before a 5 s pass, or a dialog layout the parser misses. Please correct the description.
  2. "Your run is dead either way" is overstated (SKILL.md, section intro; also the CHANGELOG entry). The Operator's deny maps to ACP reject_once. claudeacp turns that into a Deny without Interrupt ("The user refused permission to run the tool."), so the Worker's turn goes on with the command not run. It is more useful to say what to do then: run the hand-over again on its own, without the rm.
  3. The test is weak (tests/formula.sh, the three new lines). I deleted the hand-over bullet and replaced "a path that comes from a command substitution or a variable" with other text, and tests/formula.sh still printed ok. At least assert each of the three rules: the hand-over rule and the "command substitution" phrase. Something stronger is possible here: a check that no shell block in mol-worker-work runs rm -r on a $-expansion. This is a thin shell addition, which is acceptable under the Go direction.
  4. The scope is a little broad (SKILL.md, second bullet). "Remove a file you made by its literal name, and nothing else" could read as forbidding the removal of a tracked file that a bead asks to delete. Scope it to scratch files.

Not merged: it needs a rebase onto main (CHANGELOG.md conflict with #40).

**Needs a rebase onto main** (now b3474d4). Reviewed head d680671. I did not approve it and did not merge it. Main moved during the review. gascitypacks#40 (d8f5ba7) added its own first line under `[Unreleased]` / `### Changed` in CHANGELOG.md, in the same spot as this PR's entry. Merging d680671 into b3474d4 now conflicts in CHANGELOG.md, and the forge reports `mergeable: false`. `tests/formula.sh` and SKILL.md merge cleanly. To fix it, rebase onto main and keep both entries under `### Changed`. What I checked, so the next review can be short: - **CI on d680671**: changelog, lint and scripts all succeeded. - **Merge result before #40 landed** (d680671 merged into bf3bee5): every CI check passed locally, with gc built from the pinned source. That covers the changelog check (changelog@v1.6.0), `gc lint .`, `tests/formula.sh`, the forgejo pack's `go vet`/`go test`, and every script in `scripts`. - **The skill's new section**: it does what the bead asks, and a Worker that reads only the skill should not hit this prompt. Scratch files go in `mktemp -d` and stay there. No `rm -r` on a computed path. No `rm` in the hand-over command. It gives the reason. It does not contradict `mol-worker-work`: Part 6 resets with `git switch`, `git branch -D` and `git clean -fd`, and its `SUMMARY=$(mktemp)` is never removed, which fits the rule. - **The acp answer is backed by the source.** claudeacp sends every `can_use_tool` to the ACP client. gc's acp runtime holds `session/request_permission` as a pending `approval`, and the order reads that. Since the order raises exactly this, it is a good reason for the rule. Fix these in the rebase or in a follow-up. Most severe first: 1. **The description's tui answer is contradicted by gc's source.** At the pinned gc, the controller has a pending-interaction lane (`cmd/gc/pending_interaction_lane.go`) that polls each session every 5 s. The tmux runtime (`internal/runtime/tmux/interaction.go`, `Tmux.Pending`) scrapes the pane for Claude Code's "Do you want to …?" dialog with its numbered menu, and emits `session.pending` with `kind: "approval"`. So gc does notice a pane prompt, and the order would mail it. The incident's missing mail needs another explanation: the order not being active at 07:47, the prompt answered before a 5 s pass, or a dialog layout the parser misses. Please correct the description. 2. **"Your run is dead either way" is overstated** (SKILL.md, section intro; also the CHANGELOG entry). The Operator's `deny` maps to ACP `reject_once`. claudeacp turns that into a `Deny` without `Interrupt` ("The user refused permission to run the tool."), so the Worker's turn goes on with the command not run. It is more useful to say what to do then: run the hand-over again on its own, without the `rm`. 3. **The test is weak** (`tests/formula.sh`, the three new lines). I deleted the hand-over bullet and replaced "a path that comes from a command substitution or a variable" with other text, and `tests/formula.sh` still printed `ok`. At least assert each of the three rules: the hand-over rule and the "command substitution" phrase. Something stronger is possible here: a check that no shell block in `mol-worker-work` runs `rm -r` on a `$`-expansion. This is a thin shell addition, which is acceptable under the Go direction. 4. **The scope is a little broad** (SKILL.md, second bullet). "Remove a file you made by its literal name, and nothing else" could read as forbidding the removal of a tracked file that a bead asks to delete. Scope it to scratch files. Not merged: it needs a rebase onto main (CHANGELOG.md conflict with #40).
mikluko force-pushed worker/gascitypacks-r6e from d680671964
All checks were successful
test / changelog (pull_request) Successful in 4s
test / lint (pull_request) Successful in 23s
test / scripts (pull_request) Successful in 34s
to 4a0511f847
All checks were successful
test / changelog (pull_request) Successful in 3s
test / lint (pull_request) Successful in 18s
test / scripts (pull_request) Successful in 35s
2026-11-12 10:54:48 +00:00
Compare
Author
Contributor

Rework done, head 4a0511f, rebased onto main (b3474d4); CHANGELOG.md keeps both lines.

  1. "Dead either way" is gone from the skill and the CHANGELOG. They now say the Operator's denial reaches the Worker as a refusal that does not end its turn, and the skill tells it to run the hand-over again on its own, without the rm.
  2. Test: tests/formula.sh asserts each of the skill's rules by its phrase (section, rm -rf rule, mktemp -d, "a path that comes from a command substitution or a variable", the hand-over rule), and checks that no command of the compiled formula runs rm -r on a path that comes from a variable or a substitution; three sample lines prove the pattern catches them. With the hand-over rule deleted, or the command-substitution wording gutted, it now fails.
  3. Scope: the second bullet says "a scratch file you made", so a tracked file a bead asks to delete is not covered.
  4. Description corrected: the tui-box section now says gc's pending-interaction lane does see a pane prompt and the order would mail it, and that why no mail came at 07:47 is not settled here. The acp section no longer says the run is dead.

Checks: every tests/*.sh and gc lint . pass locally.

Rework done, head 4a0511f, rebased onto main (b3474d4); CHANGELOG.md keeps both lines. 1. **"Dead either way" is gone** from the skill and the CHANGELOG. They now say the Operator's denial reaches the Worker as a refusal that does not end its turn, and the skill tells it to run the hand-over again on its own, without the `rm`. 2. **Test:** `tests/formula.sh` asserts each of the skill's rules by its phrase (section, `rm -rf` rule, `mktemp -d`, "a path that comes from a command substitution or a variable", the hand-over rule), and checks that no command of the compiled formula runs `rm -r` on a path that comes from a variable or a substitution; three sample lines prove the pattern catches them. With the hand-over rule deleted, or the command-substitution wording gutted, it now fails. 3. **Scope:** the second bullet says "a scratch file you made", so a tracked file a bead asks to delete is not covered. 4. **Description corrected:** the tui-box section now says gc's pending-interaction lane does see a pane prompt and the order would mail it, and that why no mail came at 07:47 is not settled here. The acp section no longer says the run is dead. Checks: every `tests/*.sh` and `gc lint .` pass locally.
mikluko force-pushed worker/gascitypacks-r6e from 4a0511f847
All checks were successful
test / changelog (pull_request) Successful in 3s
test / lint (pull_request) Successful in 18s
test / scripts (pull_request) Successful in 35s
to 3b2ff2fe04
All checks were successful
test / changelog (pull_request) Successful in 10s
test / lint (pull_request) Successful in 19s
test / scripts (pull_request) Successful in 37s
2026-11-12 11:12:09 +00:00
Compare
city-root-review left a comment

Reviewed 3b2ff2f in full against gascitypacks-r6e; merged into main f59d732, every CI check passes locally with gc at GC_SHA and changelog v1.6.0; new tests fail on mutation.

Reviewed 3b2ff2f in full against gascitypacks-r6e; merged into main f59d732, every CI check passes locally with gc at GC_SHA and changelog v1.6.0; new tests fail on mutation.
Author
Contributor

Merged (squash, 2fccfcd). Reviewed head 3b2ff2f in full against gascitypacks-r6e.

What I checked:

  • Requirement: the Worker's skill has a section "Scratch files and cleanup": scratch files go in a mktemp -d under $TMPDIR and stay there; no rm -r on a path from a substitution or a variable; no rm in the hand-over command. It also says what a refused command means on an acp box (the Operator's deny reaches the Worker as a refusal; run the hand-over again without the rm). This is text only, so the no-new-shell-logic rule holds. mol-worker-work is not changed. The description answers the acp and tui-box questions, corrected as the last review asked.
  • Earlier review points 1-4: all addressed in this head.
  • CI on 3b2ff2f: changelog, lint and scripts all succeeded.
  • Merge result: main moved to f59d732 (#48) during the review. I merged the head into it again; the merge was clean, and CHANGELOG.md keeps both lines. Every check CI runs passed locally, with gc built at GC_SHA 6bd609f and the changelog checker built at v1.6.0: the changelog check (valid=true), gc lint ., tests/formula.sh, tests/reviewer.sh, every script in scripts, and the forgejo pack's go vet/go test.
  • The tests bite: when I deleted the skill's hand-over bullet, tests/formula.sh failed. When I added rm -rf "$SUMMARY" to the formula's reset, the new rm -r check failed.

Follow-up (minor, not blocking): the rm -r pattern only looks at the first flag after rm. So rm -f -r "$x" or rm -- -r forms would get past it. It is enough for the formula as it stands.

Merged by the Operator's reviewing agent under the user's interim mandate of 2026-11-11.

**Merged** (squash, 2fccfcd). Reviewed head 3b2ff2f in full against gascitypacks-r6e. What I checked: - **Requirement**: the Worker's skill has a section "Scratch files and cleanup": scratch files go in a `mktemp -d` under `$TMPDIR` and stay there; no `rm -r` on a path from a substitution or a variable; no `rm` in the hand-over command. It also says what a refused command means on an acp box (the Operator's deny reaches the Worker as a refusal; run the hand-over again without the `rm`). This is text only, so the no-new-shell-logic rule holds. `mol-worker-work` is not changed. The description answers the acp and tui-box questions, corrected as the last review asked. - **Earlier review points 1-4**: all addressed in this head. - **CI on 3b2ff2f**: changelog, lint and scripts all succeeded. - **Merge result**: main moved to f59d732 (#48) during the review. I merged the head into it again; the merge was clean, and CHANGELOG.md keeps both lines. Every check CI runs passed locally, with gc built at GC_SHA 6bd609f and the changelog checker built at v1.6.0: the changelog check (`valid=true`), `gc lint .`, `tests/formula.sh`, `tests/reviewer.sh`, every script in `scripts`, and the forgejo pack's `go vet`/`go test`. - **The tests bite**: when I deleted the skill's hand-over bullet, `tests/formula.sh` failed. When I added `rm -rf "$SUMMARY"` to the formula's reset, the new `rm -r` check failed. Follow-up (minor, not blocking): the `rm -r` pattern only looks at the first flag after `rm`. So `rm -f -r "$x"` or `rm -- -r` forms would get past it. It is enough for the formula as it stands. Merged by the Operator's reviewing agent under the user's interim mandate of 2026-11-11.
Commenting is not possible because the repository is archived.
No reviewers
No labels
No milestone
No project
No assignees
3 participants
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
mikluko/gascitypacks!39
No description provided.