Repository navigation
Commit ff69bca
chore(claude): allow a cloud seat to create and push its mailbox branch (#38077)
Closes #38074
Clause-②: no
Metadata-protocol: none
Rule-change: ruled
Ruling-ref: the maintainer, verbatim in the security#2 session on
2026-11-28 (recorded on the card's Source line): 「在仓库的
.claude/settings.json 里加一条允许规则再提交。立卡」, then 「立卡并派发」. The `:**` spelling
of both `src:dst` guards, including the card-branch guard from #35443,
is the maintainer's ruling 「38077 一起修」 of 2026-11-28T10:03Z, recorded in
comment 7237654867 on #38074. The six ask rows for a literal-`*` branch
and for xargs-fed arguments, and this Reach section, are the
maintainer's ruling 「按建议」 of 2026-11-28T14:55Z on the delta review
7238071861, recorded in comment 7241046206 on #38074.
## 维护者速读
- 用户无感:云端值班席位开信箱时,自建信箱分支的提交与推送在自动模式下不再弹审批。
- 为什么做:让每个云端值班席位在自动模式下自己就能坐席,不必等账号主人切模式。
-
出错会怎样:免审批的范围比四条裸写法略宽(带前缀包装、重定向、两条放行命令串联),下文逐项列明;分支名里的通配符仍未拦,另开一张卡处理;撤回即删这几行。
- 要你做什么:审阅后亲自合并这个草稿 PR。
## What changes
`.claude/settings.json`:
- `permissions.allow` gains two entries:
```
"Bash(git commit --allow-empty -F *)",
"Bash(git push -u origin claude/mailbox-*)"
```
- `permissions.ask` gains three entries scoped to those two rules. Ask
takes precedence over allow.
```
"Bash(git commit --allow-empty -F * *)",
"Bash(git push -u origin claude/mailbox-* *)",
"Bash(git push -u origin claude/mailbox-*:**)"
```
- `permissions.ask`: the existing card-branch guard from #35443,
`Bash(git push -u origin claude/issue-*:*)`, becomes `Bash(git push -u
origin claude/issue-*:**)`. A rule ending in `:*` is the legacy
literal-prefix syntax, so its inner `*` was not expanded and neither
guard ever matched a `src:dst` refspec. Ending in `:**` makes each a
wildcard with a literal colon. The CLI's settings validator still prints
a warning on the two `:**` rows; the end-to-end measurement below shows
they match as wildcards.
- `permissions.ask` gains six more rows (this round, per the 14:55Z
ruling):
```
"Bash(git push -u origin claude/issue-*\\**)",
"Bash(git push -u origin claude/mailbox-*\\**)",
"Bash(xargs git push -u origin claude/issue-*)",
"Bash(xargs git push -u origin claude/mailbox-*)",
"Bash(xargs git commit -F *)",
"Bash(xargs git commit --allow-empty -F *)"
```
The first two restore the ask for a branch argument containing a literal
`*`, on both branch families; the old literal-prefix guard caught that
case by accident. The other four make arguments fed through a pipe into
the four allowed forms ask, the card-branch pair from #35443 included.
`scripts/pm/mailbox-open.mjs`:
- The refusal printed when the default branch's push is refused (a cloud
seat) moves into a pure exported `pushRefusedMessage(plan, status)`. It
now names the switch, the empty commit and the push, one per line, then
keeps the `--head` re-run:
```
git switch -c claude/mailbox-SLUG origin/main
git commit --allow-empty -F FILE
git push -u origin claude/mailbox-SLUG
then pass --head claude/mailbox-SLUG (--close deletes that name) ...
```
The commit and push lines match the allow rules above. The switch
matches no rule.
- The self-test pins it: one new case in the open-plan battery (floor 13
to 14) asserts the five lines, the three commands verbatim for seat
`domain:ui#4`, the `--head` line and the exit status.
## Why
The relay has no ref-creating op, so a cloud seat must create one empty
commit on `origin/main` and push it to `claude/mailbox-SLUG` itself. In
an auto-mode cloud session no allow rule covered that commit or push. On
2026-11-28 the classifier denied the push from the security#2 seat three
times, once after the maintainer had approved it in chat. The seat could
sit only after the session was switched out of Auto mode. The
card-branch forms already had this shape (#35443); mailbox branches had
no equivalent. The maintainer merges this PR himself.
## Reach
Measured end to end: the CLI binary, driven against a mocked model
endpoint in throwaway sandbox repos, default mode unless stated (table
under Verification). Precedence is deny, then ask, then allow.
**Runs without approval:**
- the four bare forms: `git commit --allow-empty -F FILE` and `git push
-u origin claude/mailbox-SLUG` (both new), and the existing `git commit
-F FILE` and `git push -u origin claude/issue-N-SLUG` (#35443);
- the same forms behind a wrapper the CLI strips before matching, such
as `timeout 30` or `nohup`;
- the same forms with output redirected to the null device or with
stderr folded into stdout, or piped into a read-only command such as
`tail`; in acceptEdits mode, also a redirect to a file in the working
directory;
- a chain of two individually allowed commands, for example the empty
commit followed by the mailbox push with `&&` or `;`, or two allowed
pushes;
- a few branch spellings the allow wildcard accepts that create no new
ref here: `claude/mailbox-x/../main`, `claude/mailbox-SLUG@{u}`, a
trailing `#` comment.
**Not guarded here:** shell-glob characters other than `*` in the branch
argument (`?`, `[...]`). The shell expands these against files in the
working directory before git runs, so a crafted file name can turn them
into a `src:dst` refspec. The same hole exists on `main` for the
card-branch rule. It is carded separately: #38356. A message-file
argument with a glob (`-F m*`) also still runs.
**An ask rule prompts for:**
- anything after the branch: a second refspec, a tag, `--force`,
`--delete`, `--force-with-lease`, `-o`;
- a `src:dst` refspec on either branch family, for example
`claude/mailbox-SLUG:main`, `claude/mailbox-SLUG:refs/tags/v1` or
`claude/issue-N-SLUG:main`, also behind `timeout` or `nohup` and in a
chain;
- a branch argument containing a literal `*`, on either family (new this
round);
- arguments fed through `xargs` into any of the four allowed forms, from
a pipe or a file on stdin (new this round), or a here-string (already
asked before this round). A piped `xargs` line is reported as a
subcommand prompt; a bare `xargs` line as a rule prompt. Both come from
these rows;
- anything after the commit's message file: `-a`, `--amend`, `-n`,
`--no-verify`, a pathspec, or a message file path containing a space;
- a line piping an allowed form into a command that is not read-only,
such as `sh` or a local script.
**Prompts for another reason:**
- a chain or newline-separated line where one part is not allowed, such
as `&& git push origin main`: the CLI checks each subcommand and prompts
for the one no rule allows;
- expansions the CLI cannot check before running: command substitution
with `$(...)` or backticks, process substitution, `${IFS}`, a variable,
ANSI-C quoting, brace expansion with more than one branch;
- a redirect outside the working directory or into `.git/hooks` (the
CLI's own path safety check).
**Matches no rule**, so it falls to the permission prompt or, in Auto
mode, to the classifier: a push or commit spelt any other way, such as
`git push --force -u origin ...`, `git push -uf origin ...`,
`+claude/mailbox-SLUG`, `:claude/mailbox-SLUG`, `git push origin
claude/mailbox-SLUG` without `-u`, a bare `git push`, `--allow-empty`
after `-F` or after `--amend`/`-a`, `-Fmsg`, `-m`, `env git push ...`,
and `git switch -c claude/mailbox-SLUG origin/main` (the card names no
rule for the switch, which only creates a local branch).
**Other sessions:** every rule starts with the allowed command's own
prefix, or `xargs` and that prefix, so no other push or commit changes
behaviour. The existing `git commit -F *` allow does not match `git
commit --allow-empty -F ...`, since the prefix differs.
**Unchanged:** `main`'s ruleset, the `deny` roster (17 GitHub
content-write tools) and the hooks, including
`check:commit-card-trailers`, which still judges the mailbox commit's
trailer pair.
## Verification
- `node scripts/pm/check-settings-deny-roster.mjs` passes locally.
- The file parses as JSON.
- `node scripts/pm/mailbox-open.mjs --self-test` passes.
- End to end, at 92724d0 against d0abe2c, 196 command shapes: 22
that ran without approval now ask, and nothing else changes.
<details><summary>Readings at 92724d0</summary>
```
node scripts/pm/check-settings-deny-roster.mjs EXIT=0
check-settings-deny-roster: 17 content-write tool(s) declared = enforced in .claude/settings.json (17 mcp__github__ deny entr(ies), 0 outside this gate's population and ignored).
JSON.parse(.claude/settings.json) EXIT=0
node scripts/pm/mailbox-open.mjs --self-test EXIT=0
mailbox-open self-test: 93 cases in 10 batteries pass.
node scripts/check-nul-bytes.mjs EXIT=0
```
This round adds six strings to `.claude/settings.json` and nothing else.
NOT MEASURED locally: the derived gate families, reason: this worktree
has no install and sits 150 commits behind `origin/main`. CI runs every
family on this head.
</details>
<details><summary>End to end, before (d0abe2c) and after
(92724d0)</summary>
Each shape is one fresh CLI session in its own sandbox repo with a bare
`origin`, a mocked model endpoint that emits the one Bash call, and the
head's `permissions` block as project settings. Every prompt was
answered "deny". RAN = executed with no prompt. ASK(rule) = an ask rule
matched the line. PROMPT(subcommandResults) = a prompt raised by a part
of the line. Both heads were run in this session, same binary.
Totals over 196 shapes (main 116, xargs/wrapper/chain 41,
glob/continuation 29, acceptEdits 10):
```
before after
RAN 68 46
ASK(rule) 55 62
PROMPT(subcommandResults) 18 33
PROMPT(other) 45 45
PROMPT(safetyCheck) 4 4
PROMPT(unclassified) 6 6
```
Every row that changed:
```
id before after command
p17 RAN ASK(rule) git push -u origin claude/mailbox-*
y02 RAN ASK(rule) git push -u origin claude/mailbox-ui-4*
y03 RAN ASK(rule) git push -u origin claude/mailbox-*
i07 RAN ASK(rule) git push -u origin claude/issue-*
y05 RAN ASK(rule) git push -u origin claude/issue-*
p47 RAN ASK(rule) xargs git push -u origin claude/mailbox-ui-4
x14 RAN ASK(rule) xargs git push -u origin claude/mailbox-ui-4, stdin from a file
p46 RAN PROMPT(subcommandResults) echo main | xargs git push -u origin claude/mailbox-ui-4
i06 RAN PROMPT(subcommandResults) echo main | xargs git push -u origin claude/issue-1-x
c37 RAN PROMPT(subcommandResults) echo --amend | xargs git commit --allow-empty -F msg
x07 RAN PROMPT(subcommandResults) echo main:refs/heads/pwned-xargs | xargs git push -u origin claude/mailbox-ui-4
x08 RAN PROMPT(subcommandResults) echo --force | xargs git push -u origin claude/mailbox-ui-4
x09 RAN PROMPT(subcommandResults) echo claude/mailbox-ui-4:refs/tags/v99 | xargs git push -u origin claude/issue-1-x
x10 RAN PROMPT(subcommandResults) echo --no-verify | xargs git commit --allow-empty -F msg
x11 RAN PROMPT(subcommandResults) echo --amend | xargs git commit -F msg
x12 RAN PROMPT(subcommandResults) printf main | xargs git push -u origin claude/mailbox-ui-4
x20 RAN PROMPT(subcommandResults) echo main | timeout 30 xargs git push -u origin claude/mailbox-ui-4
x21 RAN PROMPT(subcommandResults) cat msg | xargs git push -u origin claude/mailbox-ui-4
x22 RAN PROMPT(subcommandResults) git branch --list 'claude/*' | xargs git push -u origin claude/mailbox-ui-4
x39 RAN PROMPT(subcommandResults) echo main:refs/heads/pwned-xargs | xargs git push -u origin claude/issue-1-x
y14 RAN PROMPT(subcommandResults) echo main | nice xargs git push -u origin claude/mailbox-ui-4
y17 RAN PROMPT(subcommandResults) echo --amend | xargs git commit --allow-empty -F msg 2>&1
```
Held at both heads: the four bare forms RAN (p01, i01, c01, c18); the 20
direct `src:dst` spellings on both families ASK(rule) (p02 to p06, p18,
p28 to p30, p56, i02, i04, x05, x15, x17, y04, y24 to y27); every xargs
shape in the run asks or prompts after; no shape that asked or prompted
before runs after. Still RAN after, and listed under Reach: the wrapper,
redirect and chain shapes, and the `?` glob pushes y01 and y06, which
created `refs/heads/pwned-glob` on the sandbox origin (carded
separately).
</details>
Files to read first: `.claude/settings.json` (the ask block, the six new
rows last), then `scripts/pm/mailbox-open.mjs` (the `pushRefusedMessage`
hunk and its self-test case).
Two-minute check: `node scripts/pm/mailbox-open.mjs --self-test` prints
`93 cases in 10 batteries pass`.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_017xRBcW9L8Noz9BxEwjwiov
<!-- signed: security#2 · sunhaolin · session_017xRBcW9L8Noz9BxEwjwiov
-->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 3d1de0b commit ff69bca
2 files changed
Lines changed: 33 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
90 | | - | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
91 | 93 | | |
92 | 94 | | |
93 | 95 | | |
94 | 96 | | |
95 | | - | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
96 | 107 | | |
97 | 108 | | |
98 | 109 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
333 | 333 | | |
334 | 334 | | |
335 | 335 | | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
336 | 353 | | |
337 | 354 | | |
338 | 355 | | |
| |||
467 | 484 | | |
468 | 485 | | |
469 | 486 | | |
470 | | - | |
| 487 | + | |
471 | 488 | | |
472 | 489 | | |
473 | 490 | | |
| |||
554 | 571 | | |
555 | 572 | | |
556 | 573 | | |
557 | | - | |
| 574 | + | |
558 | 575 | | |
559 | 576 | | |
560 | 577 | | |
| |||
637 | 654 | | |
638 | 655 | | |
639 | 656 | | |
| 657 | + | |
640 | 658 | | |
641 | 659 | | |
642 | 660 | | |
| |||
0 commit comments