Skip to content

Commit 107d2e8

Browse files
pm-dispatch: a merge-tree overlap check replaces "hot file, one writer" at claim and push time (#34512)
<!-- claude-projects-attribution: {"github_login":"os-steve"} --> _Requested by **Steve** · [project thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9NQgBevLnvWc2PiVm5MsaJE)_ Fixes #33941 Clause-②: no Metadata-protocol: none ## 维护者速读 - 改了什么:新增 `scripts/pm/overlap-check.mjs`,对一个分支与 origin/main 及每个共享文件的 open PR 跑 `git merge-tree`,列出冲突文件;area-lease.md 改为认领前、推前跑它,只有真文本重叠才排队。 - 为什么改:您 2026-11-15 在热文件串行决策卡上选了「今天改规则,并立全部 6 张卡」,本卡是卡 A——同文件不再一律一人写,减少车队无谓排队。 - 风险与回滚:只动仓内 PM 工具与 .claude 文本,不发布、不进 CI;回滚即 revert 本 PR。脚本答不出(浅克隆、API 读不到)一律 exit 3,不会误报「无重叠」。 - 先看:`scripts/pm/overlap-check.mjs` 的 `runOnce()`(哪些冲突算你的)与 `mergeTree()`(为何用空 attr-source);`.claude/skills/pm-dispatch/references/area-lease.md` 新增三行。 - 两分钟验证:`node scripts/pm/overlap-check.mjs --self-test`,应见「26 cases in 7 batteries pass」。 - 需要你做的:无,席位落地(.claude/** 为 Tier S,达档 L2 PASS 后由席位落地)。 ## What changes **1. `scripts/pm/overlap-check.mjs` (new, dependency-free).** For a branch (default `HEAD`) it runs `git merge-tree --write-tree --name-only` against the base (default `origin/main`) and against the head of every open PR whose files meet the branch's own change set, and lists the conflicting files per side. - Exit codes: `0` no textual overlap · `1` overlap (files listed) · `2` usage · `3` cannot answer (no merge base in a shallow clone, an unreadable PR list, a PR head that will not fetch). Exit 3 is an addition to the card's three codes: without it, "could not look" would have to share a code with an answer. Its remedy line names the fix (`git fetch --deepen=1500 origin main`). - Candidates: `GET /repos/{repo}/pulls?state=open` plus each PR's `/files` (renames count by both names), paged through the existing `gh-pages.mjs` reader; the branch's own PR (same head ref or sha) and `--exclude-pr` are skipped. `--pr=N[,N]` names the candidates instead and reads nothing from the API. - PR heads are fetched into a namespace the tool owns: `+refs/pull/N/head:refs/overlap-check/pull/N`. - Which PR-head conflicts count is decided by evidence, not by path name. A conflict on a file the branch changed is the branch's own. A conflict on any other path is "not yours" only when the base merged with that PR head conflicts on the same path: a PR built on an older main meets that conflict whatever this branch does. Everything else counts. So a PR that renames the file the branch edits counts, though git reports its conflict under the new name, outside the branch's change set. When in doubt the tool answers overlap. - Exit 1 lines name whom to queue behind. A base conflict is no queue: merge the base. A PR-head conflict queues the branch behind that PR until it lands. Before a claim with no commits, the change set is empty and the answer is 0 by construction; the header says so and points at `--branch=`. - Fetched PR heads under `refs/overlap-check/pull/` are deleted again before the run returns (self-test pins it). - **Every merge-tree runs as `git --attr-source=EMPTY_TREE merge-tree …`.** `.gitattributes` routes generated artifacts to the `os-regen` merge driver, which exits 0 and leaves no marker. The self-test measures the trap: with a driver that resolves everything registered for the file, a plain `git merge-tree` exits 0 on a real two-branch conflict, while the tool still reports it. The empty attribute source gives the plain three-way text merge the merge queue performs, and writes no `os-regen-pending` into the shared `.git/`. It differs from AGENTS.md §11's mergeability probe (a throwaway bare clone with no driver) on purpose: the question here is only which paths conflict, answered in place without a second clone, and the self-test holds it to a driver-ON control leg. **2. `.claude/skills/pm-dispatch/references/area-lease.md`** — three lines in, three out (71 lines, ceiling 71, headroom 0; the ratchet row is unchanged): - `Pre-claim deps:` no longer serializes on a hot file; it points to the new overlap-check line: run the tool before a claim and before every push, on exit 1 queue behind the PR it lists, and on exit 3 meet the prerequisite and re-run. - A card in the same series may start on the previous card's branch, in the AGENTS.md Multi-agent discipline §2 trunk form, with no stacked PR. AGENTS.md rules a stacked series out, and AGENTS.md wins over this file. - New tests go in a new file named by card. The exception is the AGENTS.md shared-harness rule (ruling record 6583487846); when it applies, the overlap check decides the queueing. This wording follows the scope note on the card (comment 6896403681). Lines paid, each with its surviving home: | removed line | surviving home | |:---|:---| | `dev 开 PR 前自查申报:os-dev.md〈Definition of done〉,BREAKING/ADR-0087 照 AGENTS.md Post-Task 第 3 条。` (a pointer) | `.claude/agents/os-dev.md` 〈Definition of done〉 binds every dev unconditionally; AGENTS.md Post-Task Checklist item 3 | | `关卡照 execution-duties.md:⛔ 不凭本区读数自关。` | `execution-duties.md:62` (已修交分诊或维护者关,⛔ 不自关); the W0 list itself is acted on only after the maintainer's pass (`area-lease.md` W0 sub-line) | | `旧号移座照 seat-lifecycle.md 移座行。` (a pointer) | `seat-lifecycle.md:43` (移座) | No ceiling was raised: the maintainer's hot-file ruling has no GitHub ruling-record id this PR could quote, so every new line is paid by a deletion. ## Tests - `node scripts/pm/overlap-check.mjs --self-test` → `✓ overlap-check self-test: 26 cases in 7 batteries pass.` It builds real git repositories in a temp dir: a bare remote carrying `refs/pull/7/head` (a real conflict on `a.txt` line 2), `refs/pull/8/head` (same file, another hunk: clean) and `refs/pull/9/head` (disjoint file: clean), `refs/pull/10/head` (renames `a.txt` to `moved.txt` and edits the same line), a moved main, and a branch on the moved main. Batteries: argv; a real two-branch conflict; no conflict (same file other hunk, disjoint files); a registered merge driver does not hide the conflict (with a control leg showing plain merge-tree exits 0); candidate selection (shared files only, own PR skipped by ref and by sha, renames); paged open-PR reads with a failed read refused; CLI end to end (exit 1 on #7, 0 on #8 and #9, 1 on a base conflict, 1 on the rename #10 with `moved.txt` counted as yours, 0 when the only conflict is one #7 has with the moved main itself, no fetched ref left behind, 2 on usage, 3 with no merge base). It follows the AGENTS.md self-test shape: a literal battery roster with per-battery floors, a roster-size pin, and a verdict handshake. - Ablation at `9908d7eda`, mutation landed and checked by `scripts/ablation-replace.mjs`: replacing `const notYours = elsewhere.filter((f) => theirs.includes(f));` with `const notYours = elsewhere;` (path-name classification, the shape the L2 review found) turns the self-test red on exactly one case, the rename one (`exit 1`, `1 failure(s)`). Restored: blob equals HEAD and `git diff HEAD` is empty; the re-run is `26 cases … pass`. - A fixture bug in the first run (the root commit) made every battery register 0 cases, and the floor refused all seven by name. That shows the floor fails when nothing runs. - Live, on this checkout: `node scripts/pm/overlap-check.mjs --branch=refs/overlap-check/pull/34110 --exclude-pr=34110` read all 52 open PRs and found one candidate (#34266, which shares `triage-duties.md`), which merges cleanly, so the run exited 0 in 35 s. The same run before `git fetch --deepen=1500 origin main` answered exit 3 with the deepen remedy, not a verdict. ## Acceptance notes - Not wired to CI — a new gate defaults to no and the maintainer has not named one; the self-test is local only: `dispatch-gates --commands` on this branch does not derive `overlap-check.mjs --self-test` (measured at `5d8e2161d`, 36 commands, none of them this file). - Accepted as written (L2 nit N2): the same-series line already says `⛔ 不叠 PR` beside the AGENTS.md §2 trunk form; the line has no bytes left to say more. - The serial wording elsewhere is not on this card's file surface and still stands (`execution-duties.md`, `SKILL.md`, the 热文件串行队 in `seat-post-protocol.md` and `seat-lifecycle.md`); the follow-up is #34527. The new rule binds area-lease mode only. - Uncommitted work is not seen: the tool reads commits. Its header says to commit before asking. ## Verification Derived gates at the final head `5d8e2161d` (round 2, after merging `origin/main`): `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack` listed 36, and all 36 exited 0. `--ran` reconciliation: `36 derived, 36 run, 0 NOT-MEASURED, 0 UNRUN`. `check:doc-formula-expressions` ran on `turbo run build --filter=@objectstack/formula --filter=@objectstack/lint` output built under the verify lock (VERDICT command-exit 0); the merge touched neither package. `area-lease.md` stays 71/71 and its reworded line is 118 bytes. <details><summary>gates run at 5d8e216 (36)</summary> ```text node scripts/check-closing-keyword-parity.mjs (+ --self-test) node scripts/check-comment-mask-corpus.mjs node scripts/check-declaration-mirrors.mjs (+ --self-test) node scripts/check-self-test-wired.mjs (+ --self-test) node scripts/check-self-test-workflow-commands.mjs (+ --self-test) node scripts/check-whole-set-label-write.mjs (+ --self-test) node scripts/ci/plan-test-core-shards.mjs --self-test node scripts/pm/check-harness-current.mjs --self-test pnpm --filter @objectstack/lint run check:doc-formula-expressions pnpm check:adr-anchors / agent-test-spelling / bash32-floor / ci-filter-parity / cli-command-ids / cross-package-test-inputs / doc-authoring / driver-memory-census / entry-guard / gitlink-declared / nul-bytes / parse-guard / pm-governed-merges / pm-skill-id-lint / pm-skill-ratchet / pnpm-filter-targets / pnpm-flag-spellings / ratchet-remedy-authority / refd-timer-probe / scripts-symbol-anchors / skill-frame-sync / watch-hint-literal every one :: exit 0 ``` </details> ## Human Minimum - [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic. (not touched) - [x] 2. Every name I added uses the casing for its kind. - [x] 3. No formatter ran; `pnpm lint` passes. (CI owns the repo-wide lint run) - [x] 4. One issue, one branch off an up-to-date `main`, one pull request. - [x] 5. A change that publishes carries a changeset — nothing publishes here (`scripts/pm/**`, `.claude/**`): `skip-changeset`. - [x] 6. `packages/spec` touched: n/a. - [x] 7. No hand edits to `content/docs/references/`, `packages/*/CHANGELOG.md` or `content/docs/releases/`. - [x] 8. Title, body and comments are in English. - [x] The *Before Submitting* list in CONTRIBUTING.md is done. --- _Generated by [Claude Code](https://claude.ai/code/session_01ADHkmS8jC8KEkmtNMppust)_ <!-- signed: repo:objectstack#2 · os-steve · session_01ADHkmSXPDB46NVRepWVrL3 --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent d0348cf commit 107d2e8

2 files changed

Lines changed: 545 additions & 4 deletions

File tree

‎.claude/skills/pm-dispatch/references/area-lease.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,22 @@
2424
- 授权行只解 auto mode 的拦截,⛔ 不改 AGENTS.md 第 14 条的落地档;区线程无授权行。
2525
4. W0:各区首小时交席位一份关/并/改级/呈裁清单,同时即开首张 p1。
2626
- 清单经维护者过目后落笔:定级照 SKILL.md 域车道(自分诊例外住 `triage-duties.md`)。
27-
- 关卡照 `execution-duties.md`:⛔ 不凭本区读数自关。
2827

2928
## 区内规则
3029

3130
- 区会话署本席签名,签名第三位与 `Session:` 皆填区会话 ID;开轮互斥读法照 `seat-lifecycle.md`。
3231
- 认领前重读标签、assignee 与末条评论:他人 assignee、他人 `Claim:` 或他区 `lease:*` ⇒ 不碰。
3332
- 认领前三查必过,各写认领评论一行;任一不过或遇大卡 ⇒ 不认领、不派 dev,当即交席位:
3433
- `Pre-claim lane:` 修复所改路径属哪条车道,点名依据路径(碰他道路径照下文留道行)。
35-
- `Pre-claim deps:` 卡点名的 `Blocked-by:`、「after #N」与热文件,逐个已合或空闲。
34+
- `Pre-claim deps:` 卡点名的 `Blocked-by:`、「after #N」逐个已合;热文件照下文重叠检查。
3635
- `Prior rulings read:` 照 `decision-analysis.md`;grep `docs/adr/**`、链卡(⛔ 行在内)与反向 pin
3736
测试;记录冲突,或路线改门的可见行为超出本卡裁决,同作不过。
37+
- 重叠检查:认领前与每次推前跑 `scripts/pm/overlap-check.mjs`;exit 1 排所列 PR 后,3 补前提重跑。
3838
- 认领照 `execution-duties.md` 派发原子对,同笔加 `lease:<区>`;`Branch:` 照 AGENTS.md 命名。
3939
- 认领后回读标签(SKILL.md 标签写四步):缺 `lease:` 或 `pm:dispatched` 即重挂;首推即开 draft PR。
4040
- 写码与开发期读码全经 `os-dev` 等子代理(一卡或一组耦合卡,文件面不相交)。
41-
- dev 开 PR 前自查申报:os-dev.md〈Definition of done〉,BREAKING/ADR-0087 照 AGENTS.md Post-Task 第 3 条。
41+
- 同系列卡可从前卡分支起步(AGENTS.md §2 主干形,⛔ 不叠 PR);新测试建按卡命名的新文件,
42+
AGENTS.md 共享 harness 规则适用时除外,由重叠检查定排队。
4243
- 席线程只协调,⛔ 不读 diff 与日志;ACCEPT 欠的自读(`contract-review.md`、〈路径分叉〉)除外。
4344
所落 PR 欠的红检查读日志(`platform-readings.md`)派子代理读,一读兼守本条与该文。
4445
- 每区恒 2 dev,空即补;逐位上张 PR 入合并队列才领下张,此前跑修复轮;Tier H 或待裁 PR 让位。
@@ -68,4 +69,3 @@
6869
- 用量近 80% 即交接:停派任何级;在途推完,每条分支留 draft PR;余照 `seat-post-protocol.md` 清单。
6970
- 交接与各区现状落座位贴评论:所有权、open PR、下一步、待批、坑;⛔ 不只留项目或记忆。
7071
- 新旧账号重叠时座位贴写所有权切分:旧号持有的 PR 清单与新号可取集;新号只取后者。
71-
- 旧号移座照 `seat-lifecycle.md` 移座行。

0 commit comments

Comments
 (0)