A Reviewer in bypass mode raised a permission prompt: rm on a path from a variable #54

Merged
city-root merged 2 commits from worker/gascitypacks-mkr into main 2026-11-12 16:56:36 +00:00
Contributor

A Reviewer of claudeacp, in bypass mode, raised a permission prompt on 2026-11-12: its scratch script ran rm -f on a path built from a variable. Claude Code asks before an rm on a path it cannot resolve, bypass mode or not, and nobody sits at a Reviewer's session, so the request was held until the Operator denied it. The Worker's skill got the rules against this in #39; the Reviewer has no skill, and its formula said only "you remove nothing with rm -rf".

What changed

  • forgejo/formulas/mol-forgejo-review.toml: the rules of the step now carry, in the Reviewer's terms, where scratch files go (the clone under its own directory and the $CLONE.body.md and $CLONE.diff files the step names beside it; anything else in a mktemp -d directory under $TMPDIR; all left where they are), that it never runs rm, with or without -r, whatever its path: not on a path from a variable or a command substitution, and not inside a script passed to bash -c or env -i ... bash -c (a test that needs a file gone makes a new mktemp -d per case, checks the file out from a commit that lacks it, or overwrites it with >), that no rm shares a command with a hand-over, and that a refusal does not end its turn, so it goes on without the rm. This replaces the old "you remove nothing with rm -rf". The rules sit in the formula and not in a skill because the Reviewer has none (inject_assigned_skills = false) and follows the formula; the step stays under the 28000-character limit its test keeps.
  • tests/reviewer.sh: holds each rule by its phrase (read from the rules section joined to one line, so the formula can wrap), and fails if any code block of the step runs an rm, inside a bash -c string or not; the pattern is checked against eight forms that must match (the rm -f "$R/CHANGELOG.md" of the first incident and the rm .changelog/bad.md inside env -i bash -c of the second) and three that must not.
  • .changelog/reviewer-scratch-and-rm.md: the fragment. No shell logic is added.

Round 1

The Reviewer found the first head too narrow. The Operator's note of 13:46 records a second prompt, from rexcity/forgejo.reviewer at 13:43: rm .changelog/bad.md, a literal path, inside an env -i bash -c script. Claude Code cannot resolve a path in such a script either, and this formula sends every test command through that wrapper. The rule now forbids rm whatever its path, on the command line and inside bash -c, with the alternatives above, and the test holds the new phrases and scans for any rm. The Reviewer's minor finding is mended too: the scratch rule no longer contradicts the $CLONE.* files the step writes. The branch is rebased onto origin/main (739c65a).

Why the order reported "Bead: unknown"

permission-request.sh finds the bead by listing the rig's in-progress beads assigned to the requester's alias or template. A Reviewer's session holds none:

  • Its claim is the step bead of its workflow. Step beads have the gcg- prefix and live in the infra binding, which gc bd list does not read (it answers with an empty list, not an error).
  • The review bead (a service bead) is open and unassigned, routed to the Reviewer by gc.routed_to; nothing marks it with the session that works it.

This is not special to the Reviewer: since #39 a rig Worker's work bead is in progress with no assignee too (marked by worker_session), so the order finds none for it either, as gascitypacks-n04 found for a city-scoped Worker. I did not mend it here. A mend is not small: the order would look up by --metadata-field worker_session=<session name>, and the Reviewer's Part 1 would have to write a matching mark on the review bead, which is a formula change with a test, in an order that has no lookup test and is to move to Go (docs/shell.md, plan item 2). I added the finding to gascitypacks-n04, which is the same gap.

Verification

  • tests/*.sh all pass under env -i, tests/reviewer.sh included, and gc lint . passes. Removing one phrase from the formula makes the test fail, and so does inserting an rm in a bash -c string of the step.
  • The changelog v2 check, run from a plain clone with -base main, reports valid=true.
  • A review bead poured before the release keeps the old text, since the formula is poured into the workflow at the sling.

Bead: gascitypacks-mkr

A Reviewer of `claudeacp`, in bypass mode, raised a permission prompt on 2026-11-12: its scratch script ran `rm -f` on a path built from a variable. Claude Code asks before an `rm` on a path it cannot resolve, bypass mode or not, and nobody sits at a Reviewer's session, so the request was held until the Operator denied it. The Worker's skill got the rules against this in #39; the Reviewer has no skill, and its formula said only "you remove nothing with `rm -rf`". ## What changed - `forgejo/formulas/mol-forgejo-review.toml`: the rules of the step now carry, in the Reviewer's terms, where scratch files go (the clone under its own directory and the `$CLONE.body.md` and `$CLONE.diff` files the step names beside it; anything else in a `mktemp -d` directory under `$TMPDIR`; all left where they are), that it never runs `rm`, with or without `-r`, whatever its path: not on a path from a variable or a command substitution, and not inside a script passed to `bash -c` or `env -i ... bash -c` (a test that needs a file gone makes a new `mktemp -d` per case, checks the file out from a commit that lacks it, or overwrites it with `>`), that no `rm` shares a command with a hand-over, and that a refusal does not end its turn, so it goes on without the `rm`. This replaces the old "you remove nothing with `rm -rf`". The rules sit in the formula and not in a skill because the Reviewer has none (`inject_assigned_skills = false`) and follows the formula; the step stays under the 28000-character limit its test keeps. - `tests/reviewer.sh`: holds each rule by its phrase (read from the rules section joined to one line, so the formula can wrap), and fails if any code block of the step runs an `rm`, inside a `bash -c` string or not; the pattern is checked against eight forms that must match (the `rm -f "$R/CHANGELOG.md"` of the first incident and the `rm .changelog/bad.md` inside `env -i bash -c` of the second) and three that must not. - `.changelog/reviewer-scratch-and-rm.md`: the fragment. No shell logic is added. ## Round 1 The Reviewer found the first head too narrow. The Operator's note of 13:46 records a second prompt, from `rexcity/forgejo.reviewer` at 13:43: `rm .changelog/bad.md`, a literal path, inside an `env -i bash -c` script. Claude Code cannot resolve a path in such a script either, and this formula sends every test command through that wrapper. The rule now forbids `rm` whatever its path, on the command line and inside `bash -c`, with the alternatives above, and the test holds the new phrases and scans for any `rm`. The Reviewer's minor finding is mended too: the scratch rule no longer contradicts the `$CLONE.*` files the step writes. The branch is rebased onto origin/main (739c65a). ## Why the order reported "Bead: unknown" `permission-request.sh` finds the bead by listing the rig's in-progress beads assigned to the requester's alias or template. A Reviewer's session holds none: - Its claim is the step bead of its workflow. Step beads have the `gcg-` prefix and live in the infra binding, which `gc bd list` does not read (it answers with an empty list, not an error). - The review bead (a `service` bead) is open and unassigned, routed to the Reviewer by `gc.routed_to`; nothing marks it with the session that works it. This is not special to the Reviewer: since #39 a rig Worker's work bead is in progress with no assignee too (marked by `worker_session`), so the order finds none for it either, as `gascitypacks-n04` found for a city-scoped Worker. I did not mend it here. A mend is not small: the order would look up by `--metadata-field worker_session=<session name>`, and the Reviewer's Part 1 would have to write a matching mark on the review bead, which is a formula change with a test, in an order that has no lookup test and is to move to Go (`docs/shell.md`, plan item 2). I added the finding to `gascitypacks-n04`, which is the same gap. ## Verification - `tests/*.sh` all pass under `env -i`, `tests/reviewer.sh` included, and `gc lint .` passes. Removing one phrase from the formula makes the test fail, and so does inserting an `rm` in a `bash -c` string of the step. - The changelog v2 check, run from a plain clone with `-base main`, reports `valid=true`. - A review bead poured before the release keeps the old text, since the formula is poured into the workflow at the sling. Bead: gascitypacks-mkr
fix: the Reviewer's formula forbids rm on a computed path and says where scratch files go (gascitypacks-mkr)
All checks were successful
test / changelog (pull_request) Successful in 5s
test / lint (pull_request) Successful in 24s
test / scripts (pull_request) Successful in 33s
393376e164
A Reviewer of claudeacp, in bypass mode, raised a permission prompt on 2026-11-12: its scratch script ran rm -f on a path built from a variable. Claude Code asks for a permission before an rm on a path it cannot resolve, bypass mode or not, and nobody sits at a Reviewer's session; the permission-request order mailed the Operator, who denied it. The Worker's skill got the rules against this in #39; the Reviewer has no skill, and its formula said only "you remove nothing with rm -rf".

The formula's rules now say where scratch files go (the clone under the Reviewer's directory, anything else in a mktemp -d directory under TMPDIR, both left where they are), forbid rm with or without -r on a path from a variable or a command substitution, keep an rm out of the hand-over command, and say a refusal does not end the turn. tests/reviewer.sh holds each rule by its phrase and checks that no command of the step is such an rm; the check was tried against the five forms in the test, and by removing a phrase from the formula.

Validation: tests/*.sh all pass, tests/reviewer.sh included (the step stays under the 28000-character limit).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
city-root-review requested changes 2026-11-12 13:04:27 +00:00
Dismissed
city-root-review left a comment

Review of 393376e164 for gascitypacks-mkr. Checks of the head: success.

Verdict

fail

Findings

  • [blocking] forgejo/formulas/mol-forgejo-review.toml:74: the rule does not cover the second incident in the work bead's notes. The Operator's note of 13:46 (after this head was pushed at 13:37, so the Worker could not have seen it) records a second prompt, from rexcity/forgejo.reviewer at 13:43: a script run through env -i bash -c '...' that did rm .changelog/bad.md in a scratch worktree. That path is literal, and the note says: "the rule has to cover an rm inside a script passed to bash -c, not only one on the command line." The rule as written forbids only an rm "on a path that comes from a variable or a command substitution", which reads as if a literal-path rm were fine. Yet the formula itself sends every test command through env -i ... bash -c (line 207), where Claude Code cannot resolve any path. Fix: say that no rm is run inside a script passed to bash -c (or env -i ... bash -c) whatever its path, or forbid rm outright, since the rule already says "you remove nothing". Give the same alternative for a case that needs a file gone (a new mktemp -d worktree per case, or git rm --cached/a checkout without the file), hold the new phrase in tests/reviewer.sh, and widen the scan at tests/reviewer.sh:183 or add a second one so it also fails on an rm inside a bash -c string in the step's code blocks. Mention the note in the PR description.
  • [minor] forgejo/formulas/mol-forgejo-review.toml:71: "anything else you write ... goes in a directory you make with mktemp -d under $TMPDIR" contradicts the formula's own BODY="$CLONE.body.md" (line 105) and >"$CLONE.diff" (line 187). Both are files beside the clone in the agent's directory, not in the clone or in a mktemp directory. Either name those two as exceptions ("the clone, and the $CLONE.* files the step names") or move them; as it stands, a careful Reviewer is told two different things.

Verified

  • Read the work bead gascitypacks-mkr (description and notes), the PR description, and the whole diff (3 files, +36/−1). The target has no REVIEW.md, AGENTS.md or CLAUDE.md.
  • Merged the head into origin/main (739c65a): clean, mergeable.
  • Ran on the merge result with the city's variables removed (env -i, proved to leave 0 of them): gc lint . passes; tests/formula.sh, tests/reviewer.sh, worktree-setup, worktree, gnu-tools, merge, apply, upgrade, view-beads, view-mail, permission-deny and permission-request all exit 0; go vet ./... and go test -race ./... in forgejo/ pass.
  • Changelog v2 checker built from mikluko/changelog tag v2 (c19d67d) and run with -base=main on the merge result: valid=true.
  • Mutation-tested the new checks in tests/reviewer.sh. Changing "the denial does not end your turn" makes it fail on that rule. Inserting rm -f "$CLONE.diff" into Part 5's code block makes it fail with "a command of the step runs rm on a path that comes from a variable or a substitution". The test does what it claims for the rules it holds.
  • The account of "Bead: unknown" in the PR description is accurate, and leaving the mend to gascitypacks-n04 (where the Worker recorded the finding as a comment) is reasonable: the mend is not small and belongs with the Go port.
Review of 393376e164068eb2a587ecaef9cd5732906dabc4 for gascitypacks-mkr. Checks of the head: success. ### Verdict fail ### Findings - [blocking] forgejo/formulas/mol-forgejo-review.toml:74: the rule does not cover the second incident in the work bead's notes. The Operator's note of 13:46 (after this head was pushed at 13:37, so the Worker could not have seen it) records a second prompt, from `rexcity/forgejo.reviewer` at 13:43: a script run through `env -i bash -c '...'` that did `rm .changelog/bad.md` in a scratch worktree. That path is literal, and the note says: "the rule has to cover an rm inside a script passed to bash -c, not only one on the command line." The rule as written forbids only an `rm` "on a path that comes from a variable or a command substitution", which reads as if a literal-path `rm` were fine. Yet the formula itself sends every test command through `env -i ... bash -c` (line 207), where Claude Code cannot resolve any path. Fix: say that no `rm` is run inside a script passed to `bash -c` (or `env -i ... bash -c`) whatever its path, or forbid `rm` outright, since the rule already says "you remove nothing". Give the same alternative for a case that needs a file gone (a new `mktemp -d` worktree per case, or `git rm --cached`/a checkout without the file), hold the new phrase in tests/reviewer.sh, and widen the scan at tests/reviewer.sh:183 or add a second one so it also fails on an `rm` inside a `bash -c` string in the step's code blocks. Mention the note in the PR description. - [minor] forgejo/formulas/mol-forgejo-review.toml:71: "anything else you write ... goes in a directory you make with `mktemp -d` under `$TMPDIR`" contradicts the formula's own `BODY="$CLONE.body.md"` (line 105) and `>"$CLONE.diff"` (line 187). Both are files beside the clone in the agent's directory, not in the clone or in a mktemp directory. Either name those two as exceptions ("the clone, and the `$CLONE.*` files the step names") or move them; as it stands, a careful Reviewer is told two different things. ### Verified - Read the work bead gascitypacks-mkr (description and notes), the PR description, and the whole diff (3 files, +36/−1). The target has no REVIEW.md, AGENTS.md or CLAUDE.md. - Merged the head into origin/main (739c65a): clean, `mergeable`. - Ran on the merge result with the city's variables removed (`env -i`, proved to leave 0 of them): `gc lint .` passes; `tests/formula.sh`, `tests/reviewer.sh`, `worktree-setup`, `worktree`, `gnu-tools`, `merge`, `apply`, `upgrade`, `view-beads`, `view-mail`, `permission-deny` and `permission-request` all exit 0; `go vet ./...` and `go test -race ./...` in forgejo/ pass. - Changelog v2 checker built from mikluko/changelog tag v2 (c19d67d) and run with `-base=main` on the merge result: `valid=true`. - Mutation-tested the new checks in tests/reviewer.sh. Changing "the denial does not end your turn" makes it fail on that rule. Inserting `rm -f "$CLONE.diff"` into Part 5's code block makes it fail with "a command of the step runs rm on a path that comes from a variable or a substitution". The test does what it claims for the rules it holds. - The account of "Bead: unknown" in the PR description is accurate, and leaving the mend to gascitypacks-n04 (where the Worker recorded the finding as a comment) is reasonable: the mend is not small and belongs with the Go port.
mikluko force-pushed worker/gascitypacks-mkr from 393376e164
All checks were successful
test / changelog (pull_request) Successful in 5s
test / lint (pull_request) Successful in 24s
test / scripts (pull_request) Successful in 33s
to 7dcc0d3ade
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
2026-11-12 13:11:52 +00:00
Compare
city-root-review left a comment

Review of 7dcc0d3ade for gascitypacks-mkr. Checks of the head: success.

Verdict

pass

Findings

  • [minor] forgejo/formulas/mol-forgejo-review.toml:85: the parenthesis that lists the hand-overs (a gc bd update of the review bead, the one that closes the step, gc runtime drain-ack) was written before #80. #80 added the verdict mail to the Operator (gc mail send ... "REVIEW $WORK_BEAD: ...", line 344 of the merge result), which is a hand-over too and sits in the same Part 5 block. The rule still covers that block, because it names drain-ack, so nothing needs to change in this pull request. When the text is next touched, add "the verdict's mail" to the list.

Round 1

  • [blocking] fixed: the rule now forbids rm whatever its path, including a literal path inside a script passed to bash -c or env -i ... bash -c, and gives three alternatives (a new mktemp -d per case, a checkout from a commit that lacks the file, overwriting with >). tests/reviewer.sh holds each phrase. Its scan fails on any rm in the step's bash blocks, inside a bash -c string or not, and is itself checked against 8 forms it must catch and 3 it must not. The PR description cites the Operator's note of 13:46.
  • [minor] fixed: the scratch rule names $CLONE.body.md and $CLONE.diff as the step's own files beside the clone, so it no longer contradicts lines 113 and 206.

Verified

  • Read the work bead gascitypacks-mkr (description and all three notes), the PR description, the round-1 review and the whole diff (3 files, +49/−1). The target has no REVIEW.md, AGENTS.md or CLAUDE.md. I read its README.
  • main has moved since the rebase (739c65a → 4a39722: #80, #60 and the 0.7.0 release, which rewrote 96 lines of this formula). The head merges into origin/main 4a39722 cleanly, and the forge reports mergeable. I read the merged formula's rules section: the new item sits correctly beside #80's text, and the merged step names no other scratch file beside the clone.
  • Ran on the merge result with the city's variables removed (env -i, which I first checked leaves 0 of them): every tests/*.sh the workflow runs exits 0 (formula, reviewer, operator-overlay, worktree-setup, worktree, gnu-tools, merge, handover, apply, upgrade, view-beads, view-mail, permission-deny, permission-request). gc lint . reports 2 packs ok, and go vet ./... and go test -race ./... pass.
  • Built the changelog checker from mikluko/changelog tag v2 (087d7e8, v2.1.0) and ran it with -base=main on the merge result: valid=true.
  • Mutation-tested tests/reviewer.sh on copies of the merge result. Adding rm .changelog/bad.md inside the Part 3 bash -c string fails it with "a command of the step runs rm". Removing "check the file out from a commit that lacks it" fails it on that rule. The copy left unchanged passes.
  • Leaving the "Bead: unknown" mend to gascitypacks-n04 is reasonable, and the PR description explains why.
Review of 7dcc0d3aded1696f55df36e7b322dfa53551b6fe for gascitypacks-mkr. Checks of the head: success. ### Verdict pass ### Findings - [minor] forgejo/formulas/mol-forgejo-review.toml:85: the parenthesis that lists the hand-overs (a `gc bd update` of the review bead, the one that closes the step, `gc runtime drain-ack`) was written before #80. #80 added the verdict mail to the Operator (`gc mail send ... "REVIEW $WORK_BEAD: ..."`, line 344 of the merge result), which is a hand-over too and sits in the same Part 5 block. The rule still covers that block, because it names `drain-ack`, so nothing needs to change in this pull request. When the text is next touched, add "the verdict's mail" to the list. ### Round 1 - [blocking] fixed: the rule now forbids `rm` whatever its path, including a literal path inside a script passed to `bash -c` or `env -i ... bash -c`, and gives three alternatives (a new `mktemp -d` per case, a checkout from a commit that lacks the file, overwriting with `>`). `tests/reviewer.sh` holds each phrase. Its scan fails on any `rm` in the step's bash blocks, inside a `bash -c` string or not, and is itself checked against 8 forms it must catch and 3 it must not. The PR description cites the Operator's note of 13:46. - [minor] fixed: the scratch rule names `$CLONE.body.md` and `$CLONE.diff` as the step's own files beside the clone, so it no longer contradicts lines 113 and 206. ### Verified - Read the work bead gascitypacks-mkr (description and all three notes), the PR description, the round-1 review and the whole diff (3 files, +49/−1). The target has no REVIEW.md, AGENTS.md or CLAUDE.md. I read its README. - main has moved since the rebase (739c65a → 4a39722: #80, #60 and the 0.7.0 release, which rewrote 96 lines of this formula). The head merges into origin/main 4a39722 cleanly, and the forge reports `mergeable`. I read the merged formula's rules section: the new item sits correctly beside #80's text, and the merged step names no other scratch file beside the clone. - Ran on the merge result with the city's variables removed (`env -i`, which I first checked leaves 0 of them): every `tests/*.sh` the workflow runs exits 0 (formula, reviewer, operator-overlay, worktree-setup, worktree, gnu-tools, merge, handover, apply, upgrade, view-beads, view-mail, permission-deny, permission-request). `gc lint .` reports 2 packs ok, and `go vet ./...` and `go test -race ./...` pass. - Built the changelog checker from mikluko/changelog tag v2 (087d7e8, v2.1.0) and ran it with `-base=main` on the merge result: `valid=true`. - Mutation-tested `tests/reviewer.sh` on copies of the merge result. Adding `rm .changelog/bad.md` inside the Part 3 `bash -c` string fails it with "a command of the step runs rm". Removing "check the file out from a commit that lacks it" fails it on that rule. The copy left unchanged passes. - Leaving the "Bead: unknown" mend to gascitypacks-n04 is reasonable, and the PR description explains why.
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!54
No description provided.