Repository navigation
Commit bc6b7ff
feat(pm): close the mailboxes to outsiders — lock each mailbox PR and count a knock only from the fleet or a maintainer (#33972)
<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi99Z1mjGd2zxMaR5rH5Z1Ada)_
Part of #33789
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:信箱 PR 开出后立刻锁定讨论(只有有写权限的账号能评论),旧信箱可用 `--lock N`
补锁;每次锁定后中继立即在信箱发一条自检评论,发不出就自动解锁并报错;读敲门的工具只认车队机器人与维护者账号,其余作者一律忽略、正文不读。
- 为什么改:仓库公开,任何 GitHub 用户都能在信箱下留一条伪造的敲门,白白进入座位会话、耗
token;本卡把「作者决定性质」从规则变成硬闸。
- 风险与回滚:锁定后车队机器人能否继续评论尚未实测,但每次锁定都由自检评论当场实测,失败即解锁,不会留下收不到敲门的信箱;中继只对带
pm:mailbox 的开放 PR 加锁或解锁。回滚 = revert 本 PR。
- 先看:`scripts/pm/mailbox-open.mjs` 的 `lockStroke` /
`canaryStroke`;`scripts/pm/fleet-write/execute.mjs` 的
`mailboxLockPreflight`;`scripts/pm/record-recognisers.mjs` 的
`readMailboxComment`。
- 两分钟验证:`node scripts/pm/mailbox-open.mjs --repo
objectstack-ai/objectstack --lock 32588 --dry-run`,应看到一个
`conversation_lock` 动作、不发任何请求。
- 需要你做的:受管面(`.claude/**`)PR,等 GOVERNED_APPROVERS
批准或席位达档复核;合并后由席位跑一次补锁所有已开信箱的中继扫射。
## What changes
Items 1 and 2 of the card land here; item 3 (the knock's session must
match the named seat's post or mailbox opening) is left open, so this PR
is `Part of` the card. What item 3 needs is under Acceptance notes.
**Item 1 — the mailbox conversation is locked.**
- `scripts/pm/fleet-write/ops.mjs`: two new relay rows.
- `conversation_lock` takes `issue` alone and becomes ONE `PUT
/repos/{o}/{r}/issues/{n}/lock` whose body is the table's one reason, `{
lock_reason: 'resolved' }` (`CONVERSATION_LOCK_REASON`). The caller
cannot send a reason.
- `conversation_unlock` takes `issue` alone and becomes ONE `DELETE` of
the same path, with no body. It exists so that a lock is never one-way
(see the canary below).
- GitHub's server-to-server permission ledger (`github/docs`
`src/github-apps/data/fpt-2022-11-28/server-to-server-permissions.json`,
read 2026-11-15) lists the endpoint under `issues: write` and again
under `pull_requests: write`. Both are literal grants on every stroke,
so both rows spend `issues` and `.github/workflows/fleet-write.yml` is
untouched.
- `scripts/pm/fleet-write/execute.mjs` (review S2): the executor fences
both rows on its own `GET` of the pull, the last read before the write,
as it fences `mailbox_branch_delete`. It refuses with nothing sent
unless the number is a pull request (an issue's number answers 404 on
the pulls path), the pull is open, and it carries `pm:mailbox`. Each row
lands only when the issue reads back with `locked` as asked. A write the
platform refused whose conversation already reads that way is an
idempotent landing; any other read is FAILED.
- `scripts/pm/mailbox-open.mjs`:
- The open gains step ⑤. Once ④ has read the new pull's number back, a
second relay stroke sends `conversation_lock` on that number, and the
pull is then read back `locked: true`. The lock cannot ride the
`pr_create` stroke because an action names its pull by number, and the
number exists only after the create answers.
- A lock that fails leaves the mailbox open and unlocked. The open then
exits non-zero and names the one re-send.
- The canary (review S1). Once the pull reads back locked, a third relay
stroke posts ONE comment on it: `MAILBOX_LOCK_CANARY` above the bare
footer. The relay reads it back byte for byte. If the canary is refused,
a fourth stroke sends `conversation_unlock`, the pull is read back
unlocked, and the run exits 3 with a loud line: the lock was taken back,
and no other mailbox is locked until the refusal is understood. If the
unlock fails too, the line says the mailbox may stay locked and names
the maintainer's "Unlock conversation".
- Shape chosen: the canary is a fixed line, not a doorbell key (it opens
with no `To:`). Its time stamp is the comment's own `created_at`, so the
line carries no clock of its own. It rides its own stroke rather than
the lock's, so a refusal is read as the canary's alone and the unlock is
sent only for a lock that read back.
- `--lock N` locks a mailbox opened before this change, with the same
canary. It is the one spelling the post-merge sweep uses. It reads the
pull first and refuses (exit 4) unless the pull is an open `pm:mailbox`
PR, the same read `--close` makes. A pull that already reads `locked`
costs zero writes and gets no canary.
**Item 2 — a knock counts only from the fleet bot or a maintainer.**
- `scripts/pm/record-recognisers.mjs`: `readMailboxComment(row)` fences
the doorbell on the comment's author. A knock is read only when
`user.login` is in `MAILBOX_KNOCK_AUTHORS`, which is
`[RELAY_COMMENT_AUTHOR, ...GOVERNED_APPROVERS]`. It is judged by the
queue guard's own predicate `recordAuthorTrusted`, and no login is typed
here. Any other row reads exactly `{ state: 'ignored', reason: 'ignored:
not a fleet or maintainer author' }`, and its body is never handed to
the parser, so no line, key or seat of it can be echoed.
- `mailboxEvents` lists ignored rows apart, as `ignored` with comment
id, time and author only. They are never an event or a half-state, so
check-half-states H72 does not list them (pinned end to end).
- `--mailbox-keys` prints who may ring.
- The relay's lock canary (the line alone above footer lines, one
leading signature line allowed) reads `{ state: 'canary' }`. It is never
an event and never a half-state, so H72 does not list it;
`mailboxEvents` lists it apart as `canaries`. The same line from a
maintainer, with a second line, or under a `To:` line reads as before.
- Import edge: `check-governed-queue-guard.mjs` imports nothing of this
graph at module scope, so the new static edge adds no cycle. Measured:
the queue guard, post-stamped and recognisers self-tests pass, and
`check-half-states.mjs` and `check-handover.mjs` load.
**Skill text (governed, `.claude/**`)**: one line each. The pm-dispatch
ratchet is paid by deletions in the same files:
| File | Line added | Line deleted | Where the deleted rule still lives
| Lines before → after |
|:---|:---|:---|:---|:---|
| `references/untrusted-text.md` | mailboxes are locked; a knock counts
only from `objectstack-fleet[bot]` and `GOVERNED_APPROVERS` | the
pointer that an adopted fork diff's internal PR waits for the
maintainer's own approval | `references/external-contributions.md` ③
(lines 13–14, the rule itself) | 54 → 54 |
| `references/seat-post-protocol.md` | knocks are judged on the author
field like audit and claim comments (`readMailboxComment`) | the
back-pointer sentence "见 seat-lifecycle.md 〈座位贴协议〉…" and the blank line
under it | `references/seat-lifecycle.md:23` points to this file itself;
other references name it by purpose | 88 → 87 |
## Tests
Every number below was read at head 5fca76d, after the last commit
(round 1, review S1 and S2).
- `node scripts/pm/mailbox-open.mjs --self-test`: 103 cases in 11
batteries pass (was 90 in 10 before this PR). The battery "the lock"
pins the one `conversation_lock` action the relay validator accepts, ⭐
the PUT the relay sends from it with the pull handed to the relay's
fence, the open-mailbox read it runs behind, the `--lock` arguments, the
re-send line and the open plan's step ⑤. Round 1 adds: ⭐ the canary is
ONE relay comment, its first line `MAILBOX_LOCK_CANARY`, then the bare
footer, accepted by the validator; ⛔ it is no doorbell key; ⭐ the unlock
is one `conversation_unlock` and the DELETE the relay sends from it; the
canary-failure line in both variants (taken back, or a maintainer's
hand); and the `--lock` plan's canary step. The CLI battery has the
`--lock` dry run with no gh or git on PATH.
- `node scripts/pm/fleet-write/validate.mjs --self-test`: 435 cases
across 23 batteries pass (was 428 across 22). The lock battery now
covers both rows: closed keys (a caller-sent `lock_reason` refused), ⭐
the action shape each sends, issues write as a literal grant, and
exactly two ops naming a lock, each request carrying the executor's
fence.
- `node scripts/pm/fleet-write/execute.mjs --self-test`: 423 cases
across 31 batteries pass (was 415 across 30). New battery "the mailbox
conversation lock": ⭐ lock and unlock each read the pull, send one write
under the App token and read the issue back. ⛔ An issue's number, a
closed pull, an unlabelled pull and an unread pull are each refused with
nothing sent, for the lock and for the unlock. A 204 that does not read
back as asked is FAILED. A refused write already in the asked state is
idempotent. mailbox-open's lock, unlock and canary plans run through the
executor.
- `node scripts/pm/record-recognisers.mjs --self-test`: 400 cases pass
(was 389); the doorbell battery floor is 44 → 55. ⭐ A fleet knock is
read and a maintainer's knock is read. ⛔ A drive-by knock, spelled
perfectly, reads only the ignored verdict, with the body marker absent
from the result. Look-alike or missing authors are ignored, ignored rows
are listed apart, the printout names who may ring, and H72 never lists a
drive-by row. Round 1 adds: ⭐ the relay's canary reads `canary` (with or
without a signature line); ⛔ the same line from a maintainer, with a
second line or under `To:` reads as before, and an outsider's is
ignored; `mailboxEvents` lists it apart; H72 does not list it.
- `dispatch.mjs` (418), `check-governed-queue-guard.mjs` (530) and
`post-stamped.mjs` (787) `--self-test` all pass unchanged, and
`check-half-states.mjs` and `check-handover.mjs` load.
**Forced test edits (named):** in the recognisers' doorbell battery, the
fixture row author `DB_ROW` changed from `os-bill` to the relay's
identity, because a knock arrives as the relay's comment. Under the new
fence an `os-bill` row is ignored. The one case asserting `by ===
'os-bill'` now asserts the relay's login. The H72 end-to-end case is
otherwise unchanged and still lists the same three comments. In round 1,
two pins changed because the rows changed: the lock's request shape now
carries the `mailboxLock` fence descriptor (mailbox-open and validate),
and validate's "no unlock row" case became "exactly two ops name a
lock". In execute.mjs the row text for an idempotent landing is now
taken from the confirming function when it names one (`idempotentText`);
the branch delete's text is unchanged.
## Acceptance notes
- The relay App commenting on a locked conversation is still not
measured by hand, but no lock this code makes can leave a deaf mailbox:
every lock is followed by the canary, and a refused canary takes the
lock back. The sweep's first `--lock N` is that measurement. If its
canary is refused, the sweep stops there.
- The one-off sweep over every open mailbox is a relay run for the seat
after merge (`mailbox-open.mjs --lock N` per open `pm:mailbox` PR). It
is not run here. Each lock posts one canary, so each subscribed seat
gets one PR-activity event, which its doorbell reader names a canary.
- The relay fence is a label fence: it stops a mistyped or injected
number, not a hostile seat, which could add the label first.
- Item 3, what it needs:
- A reader of the named seat's sessions, from its `pm:seat` post stub
(session ID, `Successor-of:`) and its mailbox opening (the body footer's
session URL).
- A predicate over `readSignatureLine` that compares the knock's
signature session with that set and reports "unverified seat signature".
- A consumer that reads it, the receiving seat's knock read. That
consumer is a board read, which this PR's pure reader does not do.
- `seat-post-protocol.md` now stands at 87 lines under a ceiling of 88
(headroom 1). The pin lives in
`scripts/pm/check-skill-line-ratchet.mjs`, outside this card's file
surface, so review nit N2 is not taken here.
- `execute.mjs` joined the file surface in round 1 (claim amendment
6896718263). PR #33975 touches its self-test fixture too; a later lander
resolves the conflict.
## Verification
<details><summary>Local gates at 5fca76d (round 1)</summary>
`node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` derived 47 commands at 5fca76d (46 at
5039a67, plus `pnpm check:pm-write-pace` for `execute.mjs`); each was
run and its exit code captured before any pipe:
```text
0 10s node scripts/check-closing-keyword-parity.mjs
0 3s node scripts/check-closing-keyword-parity.mjs --self-test
0 191s node scripts/check-comment-mask-corpus.mjs
0 0s node scripts/check-declaration-mirrors.mjs
0 1s node scripts/check-declaration-mirrors.mjs --self-test
0 1s node scripts/check-self-test-wired.mjs
0 6s node scripts/check-self-test-wired.mjs --self-test
0 139s node scripts/check-self-test-workflow-commands.mjs
0 5s node scripts/check-self-test-workflow-commands.mjs --self-test
0 2s node scripts/check-whole-set-label-write.mjs
0 0s node scripts/check-whole-set-label-write.mjs --self-test
0 0s node scripts/ci/plan-test-core-shards.mjs --self-test
0 30s node scripts/pm/bare-root-worklist.mjs --self-test
0 5s node scripts/pm/check-harness-current.mjs --self-test
0 10s pnpm --filter @objectstack/lint run check:doc-formula-expressions
0 3s pnpm check:agent-test-spelling
0 1s pnpm check:bash32-floor
0 3s pnpm check:ci-filter-parity
0 15s pnpm check:cli-command-ids
0 33s pnpm check:cross-package-test-inputs
0 6s pnpm check:doc-authoring
0 3s pnpm check:driver-memory-census
0 33s pnpm check:entry-guard
0 1s pnpm check:gitlink-declared
0 4s pnpm check:nul-bytes
0 3s pnpm check:parse-guard
0 1s pnpm check:pm-close-cards
0 369s pnpm check:pm-dispatch-gates
0 5s pnpm check:pm-fleet-write-dispatch
0 4s pnpm check:pm-fleet-write-execute
0 1s pnpm check:pm-fleet-write-validate
0 7s pnpm check:pm-governed-merges
0 1s pnpm check:pm-issue-create
0 1s pnpm check:pm-issue-transfer
0 1s pnpm check:pm-label-write
0 2s pnpm check:pm-post-stamped
0 5s pnpm check:pm-record-recognisers
0 1s pnpm check:pm-skill-id-lint
0 0s pnpm check:pm-skill-ratchet
0 4s pnpm check:pm-write-pace
0 2s pnpm check:pnpm-filter-targets
0 5s pnpm check:pnpm-flag-spellings
0 3s pnpm check:ratchet-remedy-authority
0 23s pnpm check:refd-timer-probe
0 7s pnpm check:scripts-symbol-anchors
0 1s pnpm check:skill-frame-sync
0 5s pnpm check:watch-hint-literal
```
`--ran` reconciliation: `✓ dispatch-gates --ran: 47 derived famil(ies)
accounted for — 47 run, 0 NOT-MEASURED (a DERIVED zero — all 47 recorded
an exit code and none of them is 3).`
Round 0 (5039a67): 46 of 46 exit 0. Its first commit 8e20953 had
`check:pm-dispatch-gates` red (1 of 2205): the census pins
`scripts/pm/record-recognisers.mjs:77 self-test-reads` by line, and a
header line had moved the marker to 78. That was fixed by folding the
header entry into the line above; round 1 adds no line above 77.
`check:doc-formula-expressions` exited 3 (prerequisite:
`@objectstack/formula` and `@objectstack/lint` unbuilt) until those two
were built under the lock (`VERDICT command-exit 0`).
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01ADHkmPAZjatd5E4EVfAi5F)_
<!-- signed: domain:skills#1 · os-steve ·
session_01ADHkmPAZjatd5E4EVfAi5F -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 03b4d2d commit bc6b7ff
7 files changed
Lines changed: 452 additions & 46 deletions
File tree
- .claude/skills/pm-dispatch/references
- scripts/pm
- fleet-write
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
5 | 3 | | |
6 | 4 | | |
7 | 5 | | |
| |||
13 | 11 | | |
14 | 12 | | |
15 | 13 | | |
| 14 | + | |
16 | 15 | | |
17 | 16 | | |
18 | 17 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
47 | 48 | | |
48 | 49 | | |
49 | 50 | | |
50 | | - | |
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| |||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
39 | | - | |
| 38 | + | |
| 39 | + | |
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
80 | 111 | | |
81 | 112 | | |
82 | 113 | | |
| |||
2867 | 2898 | | |
2868 | 2899 | | |
2869 | 2900 | | |
| 2901 | + | |
| 2902 | + | |
2870 | 2903 | | |
2871 | 2904 | | |
2872 | 2905 | | |
| |||
3203 | 3236 | | |
3204 | 3237 | | |
3205 | 3238 | | |
3206 | | - | |
| 3239 | + | |
| 3240 | + | |
| 3241 | + | |
| 3242 | + | |
| 3243 | + | |
3207 | 3244 | | |
3208 | 3245 | | |
3209 | 3246 | | |
| |||
3372 | 3409 | | |
3373 | 3410 | | |
3374 | 3411 | | |
| 3412 | + | |
| 3413 | + | |
| 3414 | + | |
| 3415 | + | |
| 3416 | + | |
| 3417 | + | |
| 3418 | + | |
| 3419 | + | |
| 3420 | + | |
| 3421 | + | |
| 3422 | + | |
| 3423 | + | |
| 3424 | + | |
| 3425 | + | |
| 3426 | + | |
3375 | 3427 | | |
3376 | 3428 | | |
3377 | 3429 | | |
| |||
0 commit comments