chore(pm): close-cards.mjs — one named script for the three-step card closure, and the allow rules that let seats run it (ruling 「B(治本)」) - #19479
Conversation
… closure The three-step closure (comment · label · close) had no named spelling, so a seat's batch ran as a bash loop and the session's write classifier judged it act by act — non-deterministically, which is how a 90-card sweep stopped after one card rather than risk a comment landing without its label write. `scripts/pm/close-cards.mjs` is that spelling: it re-reads every card live, applies the skip matrix, drives post-stamped (child process, its documented flags) and label-write's exported `runLabelWrite`, closes with the reason and reads the answer back, and STOPS at the first card left half-written, naming it and which of the three writes landed. Stamping and the four-step label write are imported, never re-implemented. `.claude/settings.json` gains the four allow rules that let a seat run it and its two helpers as typed, from the repo root. Claude-Session: https://claude.ai/code/session_012GcsUbuqFGBibkEDMRC1eE Co-authored-by: Claude <noreply@anthropic.com>
Measured while dry-running the first batch this script was written for: of those 90 cards, #13799 carries more than 100 timeline events, so the single `?per_page=100` read returned a truncated history at HTTP 200 with nothing saying so — and a cross-reference on page 2 read exactly like no cross-reference at all, which is the open-PR skip answering "no" for a card that has one. `readTimeline` now pages by NUMBER until a short page (the spelling the channel table prescribes, cursor exhaustion having been measured to stop early), and a card still returning full pages at the 30-page cap STOPS the run rather than deciding on what it managed to read. The fake board pages for real, so the truncation case is driven rather than modelled. Claude-Session: https://claude.ai/code/session_012GcsUbuqFGBibkEDMRC1eE Co-authored-by: Claude <noreply@anthropic.com>
Contract reviewServed-tier: Isolated at-tier reviewer; reviewed 2026-09-21T02:45Z. Merge-base ① Derived judgments
② Semver levelNo released package is touched: the four paths are ③ Boundary flags
Implemented-by: VERDICT: PASS Generated by Claude Code |
|
Provenance — director seat, summon #25 ( One operational reading from the review, for whoever runs the closure over #19458 after this lands: the review's dry run reads 74 actionable / 16 skipped against the PR's 86 / 4 because this PR's own body enumerates twelve of the card numbers, so opening it cross-referenced them; once the PR is Generated by Claude Code |
Fixes #19469
Clause-②: no
The ruling this lands under, verbatim
「B(治本):给具名脚本加一条 Bash 允许规则进 .claude/settings.json(受管面,走 PR 您合),此后席位的批量关闭不再靠分类器掷硬币。分诊席的 #19292 加了 4 条规则但没覆盖这个形状。你负责派发」
A second ruled source touches the same file: batch #204 item 4, letter A (「204 同意」, recorded on #19362) authorises the objectui spellings of the two landing-endpoint allow rules. Those two entries are not in this diff — see Scope addition, refused mid-round below. #19362 is not addressed here and remains open.
The measured defect
Two seats, one wall, one day. A 90-card closing sweep spelled as a bash loop over
post-stamped.mjs→label-write.mjs→PATCH /issues/{n}was refused by the session runtime's write classifier before any request. The second seat took the same order (#19458, execution log 5753693136): 90 of 90 cards passed its live gate, 77 were actionable, one closed, and then a batch script, an inline three-card loop and a singlepost-stamped --comment=19243were each refused — the identical command shape that had just succeeded twice. It stopped rather than grind a coin-flip channel across 76 three-step acts, because a comment that lands without its label write is a half-state on the board.Why the existing rules did not cover it: the two seat-write rules carry
--use-env-proxyinside the prefix, and seats invokenode scripts/pm/post-stamped.mjs …(the tool re-execs itself with that flag), usually behind acd … &&compound. An allow rule is a prefix match against the command as typed, so neither matched and every call fell to the classifier. No rule named a batch shape at all.What lands
1.
scripts/pm/close-cards.mjs— the three-step closure (comment · label · close) as one named command, ⛔ no new gate.Per card, re-read live first, then SKIP and log on: not open · has an assignee · carries
pm:retriage· pm-state is not exactly the expected label (defaultpm:queue; no state, another state and two states all skip) · an open PR references it (--skip-pr-referenced, default on). Otherwise: post the comment, remove the state label, close with thestate_reason— and read the close back, because a 200 whose body does not sayclosed, or that records another reason, is not the close that was asked for.Stamping and the four-step label write are reused, never re-implemented: post-stamped's write path is module-private (
writeArtefact/main), so it is driven as a child process with its documented flags (--repo=,--comment=N,--file=,--json) and its exit code read before any pipe; its exported pure half (renderBody,claimKeyedLineRefusals) runs the comment pre-flight once, before card one, rather than ninety times. The label step calls label-write's exportedrunLabelWritein-process with options built by label-write's ownparseOptions. The pm-state vocabulary is imported fromcheck-half-states.mjs.A card whose comment landed and whose label write or close did not is a HALF-WRITE: the run stops at that card and exits 4 naming it and exactly which of the three writes landed. It does not continue and it does not retry — continuing turns one half-state into a page of them.
Exits:
0every non-skipped card landed all three writes ·2usage ·3PREREQUISITE NOT MET ·4HALF-WRITE, the card is named ·5the platform refused a write.Which PR reading —
GET /repos/{o}/{r}/issues/{n}/timeline,cross-referencedevents whosesource.issuecarries apull_requestand whosestateisopen. That endpoint is the onereferences/rest-channel.mdalready declares reachable for cross-references. ⛔ Not/search/issues(the egress proxy refuses/search/*by design, so the default skip would be unavailable on exactly the seats this tool is for) and ⛔ not aclosed_by_pull_requests-style signal, which answers "which PR would close this" — narrower than "an open PR references it", and it would pass a card an open PR merely mentions.2.
.claude/settings.json— fourpermissions.allowentries:Bash(node scripts/pm/close-cards.mjs *),Bash(node --use-env-proxy scripts/pm/close-cards.mjs *), and the no-flag spellings of the two existing seat-write rules,Bash(node scripts/pm/post-stamped.mjs *)andBash(node scripts/pm/label-write.mjs *).denyis untouched; key order and formatting unchanged.3. Usage — in the script header, with the reason: invoke it from the repo root with nothing in front of
node, nocd … &&compound, because the rule matches the command as typed.references/rest-channel.mdgets no line:pnpm check:pm-skill-ratchetreports that file at 82 lines against a ceiling of 82 — headroom 0 — so the header carries it alone, exactly as the card's item 3 provides for.Minimal registration, stated as the card asks:
check:pm-close-cardsin the rootpackage.jsonand one step inlint.yml, beside the identical pair for post-stamped and label-write. Without it the new self-test would ship unrun by CI, which is the statecheck:self-test-wiredexists to prevent — it now counts 220 scripts and this one is in the population.A defect this found in its own first reading
The first dry run over the 90 cards exposed a truncation in the script's own timeline read. Measured: of those 90 cards, #13799 carries more than 100 timeline events, so a single
?per_page=100request returned a truncated history at HTTP 200 with nothing saying so — and a cross-reference on page 2 reads exactly like no cross-reference at all, i.e. the open-PR skip answering "no" for a card that has one.Fixed in the second commit:
readTimelinewalks by page number until a short page (the spellingreferences/rest-channel.mdprescribes, cursor exhaustion having been measured on this platform to stop early), and a card still returning full pages at the 30-page cap stops the run rather than deciding on what it managed to read. The fake board pages for real, so the truncation case is driven rather than modelled.Verification
--self-test—node scripts/pm/close-cards.mjs --self-test, exit 0:OK close-cards self-test: 102 cases pass across 11 batteries — offline, no network, no token.Battery roster, per-battery floor and the verdict handshake all copied from the landed shape inlabel-write.mjs.Three ablations, each with the mutation proved on disk and the restore proved byte-identical (
scripts/ablation-replace.mjs, bloba04f59d49673before and after every leg,git diff HEADempty):pm:retriageskipa04f59d49673→f455f723528c; self-test RED, 1 of 102, naming that casereturn 0before the verdict44141e535b3c; dispatch refuses, exit 1, "selfTest() returned without reaching its verdict"d0d6a6169a2b; RED with 0 case failures and 1 floor problem, naming the battery that fell 8 → 7--dry-runover #19458's 90 numbers (a READ; it wrote nothing, on any card), re-run at901b26eaafter the pagination fix:86 actionable / 4 skipped, against the card's 77/13 read at 00:01Z. The card provides for the move; the move is measured rather than assumed. Probing every cross-referenced PR on the 86: 11 of those cards had their referencing PR close after 2026-09-21T00:00Z — #19440, #19404, #19396, #19395, #19390, #19343, #19336, #19319, #19309, #19179 and #18375, ten of them on PR #19456 alone, closed 00:34:28Z. Of the remaining two, #19325 is the one card the triage seat closed before it stopped, and #19146 has since gained an assignee. The matrices agree; the board moved.
Gates — derived with
node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstackagainst the diff (68 commands, the list identical before and after the second commit), each exit code captured before any pipe. Green includescheck:pm-settings-deny-roster,check:pm-widening-tells(and the real diff judged with--declaration no --diff: no tell, "no declared surface covers it (4)"),check:pm-skill-ratchet,check:self-test-wired,check:self-test-workflow-commands,check:pm-dispatch-gates,check:nul-bytesandcheck:pm-close-cards.pnpm lint(eslint . --no-inline-config) is green over the whole repo at exit 0 — no narrowing, so no narrowing to justify.Six derived families answer PREREQUISITE NOT MET — a built tree is required and are NOT MEASURED locally:
check:dts-closure,check:dual-build-cjs-loads,check:lean-entry-closure,check:sourcemap-no-sources-content,check:type-check-debtand the lint package'scheck:doc-formula-expressions. Each readsdist/; this diff contains no package source and produces nodist/byte, so it cannot move any of them, and CI runs them on a built tree. ⛔ Recorded as not measured, not as green.Scope addition, refused mid-round
A mid-round scope addition asked for two further
permissions.allowentries — the objectui spellings of the two landing-endpoint rules that already exist for objectstack (.../objectui/pulls/*/ccr/ready_for_reviewand.../objectui/pulls/*/ccr/auto_merge), placed after their objectstack twins.They are not in this diff. Both attempts to write them were refused by this session's own permission classifier with reason
[Self-Modification]— once through a scripted edit, once through the editor tool — and a third route was not attempted. The working tree is clean and nothing partial landed. This is the same classifier, on the same file, that had permitted the four entries above earlier in the same round: a third observation of the non-determinism this card was filed for, now on a file surface rather than a write channel. A seat with a channel adds those two lines, or the maintainer adds them at merge.Tier and landing
Tier S by the register (
GOVERNED_SURFACESinscripts/pm/check-governed-merges.mjs): the diff touches.claude/**. Per the maintainer's directive above (「受管面,走 PR 您合」) the maintainer merges this by hand. ⛔ This PR is not flipped to ready, not queued, and auto-merge is not armed.Check Changesetwantsskip-changeset: no released package is touched. The four paths are.claude/settings.json,scripts/pm/close-cards.mjs,.github/workflows/lint.ymland the rootpackage.json(private,@objectstack/spec-monorepo, ascriptsentry only) — every one of them on the non-publishing fast track. The label is the seat's to apply.Acceptance notes
Noted, not filed:
references/rest-channel.mdhas headroom 0 (82 lines, ceiling 82), and so does every other ceilinged file in that ratchet. The channel table therefore cannot gain a row for this script without a ruled raise or an equal deletion. Carrier: the next PR that raises that ceiling. Observation, not a defect.--dry-runbuys one card read per card and a timeline walk only for a card that would otherwise be acted on. A future batch larger than this one may want a--jsonsummary for the completion comment; nothing needs it today. Carrier: none.维护者速读(草稿)
改了什么 — 新增一个具名脚本
scripts/pm/close-cards.mjs,把「评论 · 摘标签 · 关卡」这三步合成一条可被允许规则整条命中的命令;并在.claude/settings.json的permissions.allow里加了 4 条规则(这个脚本两种拼写,加上两个既有工具的无 flag 拼写)。deny一个字没动。为什么改 — 批量关卡以前是 shell 循环,每一步都由会话的写分类器逐条判,判得不稳:同一条命令刚成功两次就被拒,90 张卡关到第 1 张就停了。停是对的——评论落了标签没落就是半状态——但代价是这批清理走不动。一条具名脚本 = 一条前缀,分类器不再掷硬币。
风险与代价(含回滚) — 风险最集中的一点是「半写」:脚本在第一张半写的卡上立刻停,退出码 4,并点名是哪张卡、哪几步落了,⛔ 不继续、⛔ 不重试。回滚代价为零:删掉这个文件和那 4 行规则即回到今天,没有任何其它代码读它。另一项要请您留意的是,允许规则本身是放宽面——它放宽的是「跑本仓自己的三个 PM 脚本」,不是任何网络写端点。本轮还有 2 条 objectui 的规则被会话分类器当场拒写(见上节),不在这个 diff 里。
席位意见 — (留空,待席位复审填写)
你要做的 — 读一眼那 4 行允许规则是不是您想给的面,然后手工合。⛔ 本 PR 不翻 ready、不入队、不挂 auto-merge。合完之后,这批 90 张卡的关闭由分诊席跑一次
--dry-run再跑一次实关,日志回贴 #19458。Generated by Claude Code