Repository navigation
Commit 107d2e8
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
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
28 | 27 | | |
29 | 28 | | |
30 | 29 | | |
31 | 30 | | |
32 | 31 | | |
33 | 32 | | |
34 | 33 | | |
35 | | - | |
| 34 | + | |
36 | 35 | | |
37 | 36 | | |
| 37 | + | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
| 41 | + | |
| 42 | + | |
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
| |||
68 | 69 | | |
69 | 70 | | |
70 | 71 | | |
71 | | - | |
0 commit comments