Skip to content

Commit ff69bca

Browse files
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

File tree

‎.claude/settings.json‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,23 @@
8787
"Bash(curl -sS -X PATCH https://api.github.com/repos/objectstack-ai/hotcrm/issues/* *)",
8888
"Bash(curl -sS -X PATCH https://api.github.com/repos/objectstack-ai/mobile/issues/* *)",
8989
"Bash(git commit -F *)",
90-
"Bash(git push -u origin claude/issue-*)"
90+
"Bash(git push -u origin claude/issue-*)",
91+
"Bash(git commit --allow-empty -F *)",
92+
"Bash(git push -u origin claude/mailbox-*)"
9193
],
9294
"ask": [
9395
"Bash(git commit -F * *)",
9496
"Bash(git push -u origin claude/issue-* *)",
95-
"Bash(git push -u origin claude/issue-*:*)"
97+
"Bash(git push -u origin claude/issue-*:**)",
98+
"Bash(git commit --allow-empty -F * *)",
99+
"Bash(git push -u origin claude/mailbox-* *)",
100+
"Bash(git push -u origin claude/mailbox-*:**)",
101+
"Bash(git push -u origin claude/issue-*\\**)",
102+
"Bash(git push -u origin claude/mailbox-*\\**)",
103+
"Bash(xargs git push -u origin claude/issue-*)",
104+
"Bash(xargs git push -u origin claude/mailbox-*)",
105+
"Bash(xargs git commit -F *)",
106+
"Bash(xargs git commit --allow-empty -F *)"
96107
],
97108
"deny": [
98109
"mcp__github__issue_write",

‎scripts/pm/mailbox-open.mjs‎

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,23 @@ export function headLeftWarning(plan) {
333333
return `⚠️ mailbox-open: --head ${plan.branch} is not a claude/mailbox-* branch, so --close will LEAVE it behind for a person to delete — the relay deletes only that shape. Name the head claude/mailbox-${plan.seat.slug} to have --close delete it.`;
334334
}
335335

336+
/**
337+
* The refusal an open prints when the push of its default branch is refused (with-fleet exit `status`). A cloud seat
338+
* cannot push it, so the message names the three commands that create and push `claude/mailbox-<slug>`, one per
339+
* line and spelt exactly as `.claude/settings.json`'s allow rules for a mailbox branch, so a seat in Auto mode runs
340+
* them without a mode switch; then the `--head` re-run. Pure.
341+
*/
342+
export function pushRefusedMessage(plan, status) {
343+
const head = `claude/mailbox-${plan.seat.slug}`;
344+
return [
345+
`✗ mailbox-open: the push of ${plan.branch} was refused (with-fleet exit ${status}). A cloud seat cannot push it — create and push ${head} itself, each command on its own line:`,
346+
` git switch -c ${head} origin/${plan.base}`,
347+
' git commit --allow-empty -F FILE',
348+
` git push -u origin ${head}`,
349+
` then pass --head ${head} (--close deletes that name). A legacy branch ${MAILBOX_BRANCH_PREFIX}${plan.login} refuses it too: git nests no ref under an existing one, so delete that branch once its mailbox is closed. No PR was opened.`,
350+
].join('\n');
351+
}
352+
336353
/** `head` is the pull's head as read live; a `claude/mailbox-*` one is deleted in the same stroke, after the close (header). */
337354
export function planClose({ repo, pull, head = null }) {
338355
const branch = typeof head === 'string' && MAILBOX_BRANCH_SHAPE.test(head) ? head : null;
@@ -467,7 +484,7 @@ async function openLive(plan, opts) {
467484
}
468485
const pushed = run('bash', [join(PM_DIR, 'with-fleet.sh'), '--kind', 'git push', '--', 'git', 'push', 'origin', `${sha.out}:refs/heads/${plan.branch}`]);
469486
if (!pushed.ok) {
470-
console.error(`✗ mailbox-open: the push of ${plan.branch} was refused (with-fleet exit ${pushed.status}). A cloud seat cannot push it — push claude/mailbox-${plan.seat.slug} itself and pass --head claude/mailbox-${plan.seat.slug} (--close deletes that name). A legacy branch ${MAILBOX_BRANCH_PREFIX}${plan.login} refuses it too: git nests no ref under an existing one, so delete that branch once its mailbox is closed. No PR was opened.`);
487+
console.error(pushRefusedMessage(plan, pushed.status));
471488
return EXIT_PREREQUISITE;
472489
}
473490
} else {
@@ -554,7 +571,7 @@ let selfTestReachedVerdict = false;
554571
const SELF_TEST_BATTERIES = Object.freeze({
555572
'arguments: the two modes and every refusal': 14,
556573
'the seat: canonical key, ref slug, and the per-seat branch': 11,
557-
'the open plan: branch, labels, body, and the relay validator': 13,
574+
'the open plan: branch, labels, body, and the relay validator': 14,
558575
'the close plan: comment then close, then the delete of a claude/mailbox-* head, judged by the validator': 7,
559576
'whose mailbox a pull is: the seat on the body line or the head, a legacy login, neither': 8,
560577
"finding a seat's open mailbox: by seat, never by login": 10,
@@ -637,6 +654,7 @@ async function selfTest() {
637654
t('--head names the branch and skips the push; the body still names the seat', [ph.branch, ph.push, ph.actions[0].head, ph.actions[0].body.split('\n')[0]], ['claude/project-thread-x', false, 'claude/project-thread-x', 'Mailbox-of: triage#1 · os-bill']);
638655
t('no draft key is sent — the relay forces draft itself', 'draft' in p.actions[0], false);
639656
t('⭐ a --head --close will leave warns, naming the claude/mailbox-<slug> spelling; a claude/mailbox-* head, the pushed default and a close do not', [/--head claude\/project-thread-x is not a claude\/mailbox-\* branch, so --close will LEAVE it/.test(headLeftWarning(ph)), headLeftWarning(ph).includes('claude/mailbox-triage-1'), headLeftWarning(planOpen({ repo: 'o/r', seat: 'triage', login: 'os-bill', head: 'claude/mailbox-triage-1' })), headLeftWarning(p), headLeftWarning(planClose({ repo: 'o/r', pull: 1 }))], [true, true, null, null, null]);
657+
t('⭐ a refused push names the three commands one per line, spelt as the settings allow rules, then the --head re-run', (() => { const m = pushRefusedMessage(p, 1).split('\n'); return [m.length, m[1].trim(), m[2].trim(), m[3].trim(), m[4].includes('then pass --head claude/mailbox-ui-4'), m[0].includes('with-fleet exit 1'), m[4].includes('mailbox/os-bill')]; })(), [5, 'git switch -c claude/mailbox-ui-4 origin/main', 'git commit --allow-empty -F FILE', 'git push -u origin claude/mailbox-ui-4', true, true, true]);
640658
const pe = planOpen({ repo: 'objectstack-ai/objectstack', seat: 'Epic:#27293#1', login: 'sunhaolin' });
641659
t('⭐ an epic seat\'s plan: its branch, its Mailbox-of line, its To: line, and the validator accepts it', [pe.branch, pe.actions[0].title, pe.actions[0].body.split('\n')[0], pe.actions[0].body.includes('the line `To: epic:#27293#1`'), pe.errors], ['mailbox/sunhaolin/epic-27293-1', 'pm:mailbox — epic:#27293#1 · sunhaolin', 'Mailbox-of: epic:#27293#1 · sunhaolin', true, []]);
642660

0 commit comments

Comments
 (0)