Repository navigation
Commit 68ecc79
fix(pm): let the seat rewrite a pull request body signed on its last line (#29225)
<!-- claude-projects-attribution: {"github_login":"marchtian"} -->
_Requested by **田騏** · [project
thread](https://claude.ai/code/project/chan_01VmuUhXU9SSUzqJYyXSmYSi?thread=cmsg_01VmuUhXU9SSUzqJYyXSmYSi9paTx1Lu8ENYwwssthfK3h)_
Fixes #29145
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:席位现在可以在第一轮之后改写 PR 正文。条件是把署名放在正文最后一个非空行的 HTML 注释里,并且中继读平台确认目标确实是
PR;issue 正文仍按原规则,首行必须是署名。
- 为什么改:开发者只在开 PR 时写一次正文,席位改正文又必须首行署名,这会挤掉 `Fixes #n`。结果评审要求"落地前把正文更新到新
head"时没人能做到,已经在三个 PR 上出现过。
- 风险与回滚:只改了 `scripts/pm/fleet-write/dispatch.mjs`
这一个客户端脚本,不发布任何包。新增的一次平台 GET 读不到就拒发(退出码 3),不会放行。回滚只需 revert 这个 PR。
- 先看:`scripts/pm/fleet-write/dispatch.mjs` 里的 `main()`:平台读放在打包之后、dry-run
退出之前;然后看 `readPullRequestTargets`,它分三档判定:pull、issue、unread。
- 两分钟验证:运行 `node scripts/pm/fleet-write/dispatch.mjs --self-test`,应看到
`284 cases pass across 25 batteries`。
- 需要你做的:无,席位落地。
## What changes
`scripts/pm/fleet-write/dispatch.mjs` only. The seat-edit signature rule
now has one more door, for the pull request body:
- An `issue_patch` body whose first non-empty line is the seat's
signature passes exactly as before, whatever it targets. No read is
made.
- An `issue_patch` body that carries neither the signature line nor the
trailer is refused as usage (2) before any read. Its refusal now names
both shapes.
- An `issue_patch` body that carries only the trailer is judged by
reading the platform: `GET /repos/{repo}/issues/{n}`, the same locator
the read-back uses for this op. A 200 with a `pull_request` key passes.
A 200 without that key is an issue, refused as usage (2). Any other
answer, or none, is PREREQUISITE NOT MET (3), so an unread target never
passes. The read runs after the packer and before the dry-run exit, so a
dry run refuses what the send would. It re-execs through the egress
proxy the way the send does.
- The trailer is an HTML comment on the body's last non-empty line,
spelled as the comment opener, then `signed: LANE#N · ACCOUNT ·
SESSION`, then the comment closer (`PR_BODY_TRAILER_SHAPE`). Its inside
is parsed by the existing `readSignatureLine` from
`check-half-states.mjs`. That file is not changed, and the signature
shape is not changed.
- `comment_edit` takes no trailer: a comment is a post, never a pull
request body. `pr_create` keeps its exemption.
The header section, the exit-code table and the usage text say the same.
The server side (`validate.mjs`, `execute.mjs`, `fleet-write.yml`) needs
no change: it holds no signature rule (grep: zero hits for signature in
all three).
## Tests
New self-test battery, "the pull request body at the seat's door", with
19 cases pinned in `SELF_TEST_BATTERIES`. The battery floor was raised
from 24 to 25.
- A signed PR body passes on a dry run. The target is read once, the
command exits 0, and the body is sent byte for byte.
- An unsigned PR body is refused with usage (2), its refusal names the
trailer shape, and zero reads are made.
- An issue body that carries only the trailer is still refused with
usage (2).
- An unreadable target (503) and a missing token are both refused with
exit 3. The reader treats 404, a 200 that is not an issue object, and no
answer at all as `unread`.
- The trailer must be on the last non-empty line. A bare signature
there, or a near miss inside the comment, is not a trailer.
- `comment_edit` with a trailer is still refused.
- A structural pin checks that the read sits after `packRequest(` and
before `if (opts.dryRun)`.
The existing battery, "the signature at the seat's door", is unchanged:
13 cases, all green.
Live dry runs on this branch, reads only:
- A trailer-signed body on `#29083`, a pull request, exits 0. The reason
line reads "answered 200 with a pull_request key".
- The same body aimed at this card exits 2. The reason line reads "is an
issue".
- An unsigned body exits 2 and names both shapes.
## Acceptance notes
- The platform appends a bare footer block when a pull request body is
edited (`platform-readings.md`, edit side). The stored body's last
non-empty line is therefore the platform's footer, and the trailer sits
just above it. The seat should send no footer of its own. The header
says this.
- Not measured: whether an edit through `PATCH /issues/{n}` on a pull
request keeps an HTML comment byte for byte. A create keeps one, because
line 1 of every PR body is the attribution comment. The relay's
read-back is the backstop on the first live use: a stripped trailer
would read back as NOT STORED (exit 4).
- Skill and agent text are out of scope (`.claude/**` is governed). The
seat should be told about two places. `seat-post-protocol.md` line 30
says a post's and a card's body opens with the signature. The
pm-dispatch SKILL.md claim template has the seat rewrite `owed — FILES`
to `#N` before ACCEPT. That template step is executable through this
door, but nothing there names the trailer. Today only the refusal text
does.
- `skip-changeset` applies: `scripts/pm/**` publishes no package.
## Verification
Head `e3d142f68d` (origin/main merged once, at `104cd1a58d`).
<details><summary>Derived gates: 38 commands, each exit captured before
any pipe, all 0; <code>--ran</code> reconciliation</summary>
`node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` derived 38 commands (1 path, merge base
0d15f89). All 38 ran on the head above and each exited 0. `pnpm
check:pm-dispatch-gates` ran under nohup: "1937 cases pass" (fast tier,
398.6s on a shared box).
`--ran`: "38 derived famil(ies) accounted for — 38 run, 0 NOT-MEASURED
(a DERIVED zero — all 38 recorded an exit code and none of them is 3)".
</details>
<details><summary>Self-tests of every script that imports the changed
file</summary>
- fleet-write/dispatch: 284 cases across 25 batteries (base: 265 across
24)
- post-stamped: 753 / 26
- issue-create: 56 / 8
- label-write: 136 / 11
- close-cards: 227 / 20
- issue-transfer: 76 / 9
- rerun-failed: 31 / 5
- mailbox-open: 81 / 10
- fleet-roster: 104 / 9
- with-fleet: 32
- check-half-states: 5185
- fleet-write/execute: 209 / 20
- fleet-write/validate: 216 / 13
- write-pace: 113 / 12
- `pnpm check:doc-authoring`: exit 0
</details>
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- signed: domain:devx#2 · marchtian ·
session_017ihL2gLghEqeDKTbDTC7Zd -->
Co-authored-by: Claude <noreply@anthropic.com>1 parent 391216f commit 68ecc79
1 file changed
Lines changed: 260 additions & 13 deletions
0 commit comments