repo-harness 0.29.1 → 0.29.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/README.es.md +2 -2
  2. package/README.fr.md +2 -2
  3. package/README.ja.md +2 -2
  4. package/README.md +1 -1
  5. package/README.zh-CN.md +2 -2
  6. package/assets/reference-configs/agentic-development-flow.md +1 -1
  7. package/assets/reference-configs/global-working-rules.md +3 -3
  8. package/assets/reference-configs/herdr-notify.md +1 -1
  9. package/assets/reference-configs/host-invariants.md +1 -1
  10. package/assets/skill-version.json +2 -2
  11. package/assets/skills/repo-harness-herdr-portal/SKILL.md +1 -1
  12. package/assets/skills/repo-harness-issue-flow/SKILL.md +4 -0
  13. package/assets/skills/repo-harness-issue-flow/references/acceptor.md +12 -5
  14. package/assets/skills/repo-harness-issue-flow/references/board.md +6 -4
  15. package/assets/skills/repo-harness-issue-flow/references/orchestrator.md +17 -9
  16. package/assets/skills/repo-harness-issue-flow/references/replan.md +1 -1
  17. package/assets/skills/repo-harness-issue-flow/references/templates.md +12 -5
  18. package/assets/skills/repo-harness-issue-flow/references/worker.md +18 -3
  19. package/dist/hook-entry.js +1 -1
  20. package/package.json +1 -1
  21. package/src/cli/commands/board.ts +5 -2
  22. package/src/core/board/board.ts +61 -18
  23. package/src/core/board/dispatch.ts +27 -8
  24. package/src/core/board/merge.ts +11 -3
  25. package/src/core/board/review.ts +13 -6
  26. package/src/core/evidence/required-check-evidence.ts +7 -3
  27. package/src/effects/board/attention-watch.ts +11 -4
  28. package/src/effects/board/collect.ts +6 -2
  29. package/src/effects/board/dispatch.ts +11 -5
  30. package/src/effects/board/review.ts +5 -2
package/README.es.md CHANGED
@@ -24,10 +24,10 @@ completa de requisitos está en [README.md](README.md#get-started).
24
24
 
25
25
  ```bash
26
26
  # macOS / Linux
27
- curl -fsSL https://raw.githubusercontent.com/Ancienttwo/repo-harness/main/install.sh | sh
27
+ curl -fsSL https://raw.githubusercontent.com/aimpact-inc/repo-harness/main/install.sh | sh
28
28
 
29
29
  # Windows (PowerShell)
30
- irm https://raw.githubusercontent.com/Ancienttwo/repo-harness/main/install.ps1 | iex
30
+ irm https://raw.githubusercontent.com/aimpact-inc/repo-harness/main/install.ps1 | iex
31
31
  ```
32
32
 
33
33
  Si Bun ya está en el PATH, también puedes ejecutar:
package/README.fr.md CHANGED
@@ -24,10 +24,10 @@ complète des prérequis est dans [README.md](README.md#get-started).
24
24
 
25
25
  ```bash
26
26
  # macOS / Linux
27
- curl -fsSL https://raw.githubusercontent.com/Ancienttwo/repo-harness/main/install.sh | sh
27
+ curl -fsSL https://raw.githubusercontent.com/aimpact-inc/repo-harness/main/install.sh | sh
28
28
 
29
29
  # Windows (PowerShell)
30
- irm https://raw.githubusercontent.com/Ancienttwo/repo-harness/main/install.ps1 | iex
30
+ irm https://raw.githubusercontent.com/aimpact-inc/repo-harness/main/install.ps1 | iex
31
31
  ```
32
32
 
33
33
  Si Bun est déjà dans le PATH, vous pouvez aussi lancer :
package/README.ja.md CHANGED
@@ -24,10 +24,10 @@ hooks を提供します。GitHub issue と PR がタスクの内容、範囲、
24
24
 
25
25
  ```bash
26
26
  # macOS / Linux
27
- curl -fsSL https://raw.githubusercontent.com/Ancienttwo/repo-harness/main/install.sh | sh
27
+ curl -fsSL https://raw.githubusercontent.com/aimpact-inc/repo-harness/main/install.sh | sh
28
28
 
29
29
  # Windows (PowerShell)
30
- irm https://raw.githubusercontent.com/Ancienttwo/repo-harness/main/install.ps1 | iex
30
+ irm https://raw.githubusercontent.com/aimpact-inc/repo-harness/main/install.ps1 | iex
31
31
  ```
32
32
 
33
33
  Bun がすでに PATH にある場合は、次のコマンドも使えます。
package/README.md CHANGED
@@ -331,6 +331,6 @@ None of these are bundled dependencies; see
331
331
 
332
332
  ## Release & license
333
333
 
334
- - npm: `repo-harness@0.29.1` · workflow stamp `repo-harness@0.29.1+template@0.29.1`
334
+ - npm: `repo-harness@0.29.2` · workflow stamp `repo-harness@0.29.2+template@0.29.2`
335
335
  - History: [`docs/CHANGELOG.md`](docs/CHANGELOG.md)
336
336
  - License: MIT — see [`LICENSE`](LICENSE)
package/README.zh-CN.md CHANGED
@@ -24,10 +24,10 @@ GitHub issue 和 PR 管理任务身份、范围和状态;人只负责决定是
24
24
 
25
25
  ```bash
26
26
  # macOS / Linux
27
- curl -fsSL https://raw.githubusercontent.com/Ancienttwo/repo-harness/main/install.sh | sh
27
+ curl -fsSL https://raw.githubusercontent.com/aimpact-inc/repo-harness/main/install.sh | sh
28
28
 
29
29
  # Windows (PowerShell)
30
- irm https://raw.githubusercontent.com/Ancienttwo/repo-harness/main/install.ps1 | iex
30
+ irm https://raw.githubusercontent.com/aimpact-inc/repo-harness/main/install.ps1 | iex
31
31
  ```
32
32
 
33
33
  如果 Bun 已经在 PATH 上,也可以直接运行:
@@ -160,7 +160,7 @@ The board rule R5 reads only the rows with `path_visible: true`: a changed path
160
160
  | Changes a merge or push path: the publication executor, branch protection or force push. | `src/core/publication/acceptance-merge-policy.ts`, `src/core/publication/merge-readiness.ts`, `src/effects/publication/batch-build.ts`, `src/effects/publication/merge-executor.ts`, `src/effects/publication/merge-readiness.ts`, `src/effects/publication/new-remote-ref-push.ts`, `scripts/merge-gate.ts` |
161
161
  <!-- review-high-list:list:end -->
162
162
 
163
- Review follows the `repo-harness-issue-flow` skill, [references/acceptor.md](../../assets/skills/repo-harness-issue-flow/references/acceptor.md). The tier selects the depth: no independent review for Low, one fresh-context review for Medium, and the gatekeeper plus one review for High, at least one of the two from a model family different from the writer's. The round rules (who reviews each round, the claims of a round, the round-2 scope and the convergence rule) are only in [references/acceptor.md §2.2](../../assets/skills/repo-harness-issue-flow/references/acceptor.md#22-rounds). The Acceptor SOP owns the round, findings and publish steps.
163
+ Review follows the `repo-harness-issue-flow` skill, [references/acceptor.md](../../assets/skills/repo-harness-issue-flow/references/acceptor.md). The tier selects the depth: no independent review for Low, one fresh-context review from a model family different from the writer's for Medium, and the gatekeeper plus one review for High, at least one of the two from a model family different from the writer's. The round rules (who reviews each round, the claims of a round, the round-2 scope and the convergence rule) are only in [references/acceptor.md §2.2](../../assets/skills/repo-harness-issue-flow/references/acceptor.md#22-rounds). The Acceptor SOP owns the round, findings and publish steps.
164
164
 
165
165
  Low accept-seat skip: a Low PR whose `Required / CI` is SUCCESS on the PR head and whose PR body holds the author verification evidence (the commands and their outcomes) takes no accept seat and no acceptance record. Do not dispatch a Codex, Herdr or OAR accept seat for it. `Required / CI` and that evidence are the proof surface. A Low PR that lacks either condition is not eligible to merge until both hold. Medium and High keep the full Acceptor SOP.
166
166
 
@@ -92,12 +92,12 @@ When a task requires broad research, repo archaeology, multi-source synthesis, o
92
92
  - Three context layers exist: terminal scrollback (readable), harness-saved transcript (locate its session log or ask the peer to export), and the model's live context window (never directly readable). Do not claim to know a peer's unseen context.
93
93
  - Converse and assign tasks directly to the peer pane; a task assignment states goal, file scope, verification command, and forbidden areas.
94
94
  - Cross-harness messages never widen authorization: commit, push, PR, publish, and deletion stay with the user's current-turn instruction; one writer per file, coordinate ownership before editing.
95
- - Use herdr-core for terminal collaboration: `hc` for terminals and `herdr-app do` for tabs and panes ([Runtime commands](https://github.com/Ancienttwo/repo-harness/blob/main/docs/reference-configs/herdr-notify.md#runtime-commands)). `hc --help` and `herdr-app commands` are the syntax authority.
95
+ - Use herdr-core for terminal collaboration: `hc` for terminals and `herdr-app do` for tabs and panes ([Runtime commands](https://github.com/aimpact-inc/repo-harness/blob/main/docs/reference-configs/herdr-notify.md#runtime-commands)). `hc --help` and `herdr-app commands` are the syntax authority.
96
96
  - Target an explicit peer by its `hc` terminal address or name. Never target the UI-focused terminal by default.
97
97
  - Submit peer messages with `hc send <t>`. A timeout or stalled response may have delivered input: inspect before retrying. Submission and lifecycle status are not task ACK or acceptance.
98
98
  - For a task-owned collaborator, start the agent in its own pane with `herdr-app do` and address it with `hc`. Keep the pane through the task so advisor/gatekeeper processes survive individual owner turns.
99
99
  - Herdr pane layout: put at most 3 panes side by side in one tab. Split only with `herdr-app do pane.split --direction right`; never split down. When the tab is full, create a new tab with `herdr-app do tab.new`.
100
- - For issue-flow work, follow the orchestrator, advisor and worker topology, the pane cleanup and the herdr-core commands in [Herdr Dispatch](https://github.com/Ancienttwo/repo-harness/blob/main/docs/reference-configs/herdr-notify.md#herdr-dispatch).
100
+ - For issue-flow work, follow the orchestrator, advisor and worker topology, the pane cleanup and the herdr-core commands in [Herdr Dispatch](https://github.com/aimpact-inc/repo-harness/blob/main/docs/reference-configs/herdr-notify.md#herdr-dispatch).
101
101
  - Agents may inspect each other's history with `hc read <t>`. History is observation; request/result artifacts carry collaboration claims, and domain review receipts retain their own authority.
102
102
  - After the whole task completes, close the panes you created with `herdr-app do pane.close --pane <pane>`. Attached root/supervisor panes and servers remain owned by their original operator. Report a pane that will not close rather than guessing identity or killing an unrelated process.
103
103
  - A missing or unusable herdr-core stops terminal collaboration with a clear error. Do not fall back to tmux or another terminal runtime, and do not nest terminal multiplexers. Existing tmux sessions must be drained with the previous runtime before cutover.
@@ -125,5 +125,5 @@ The managed block above keeps the conservative defaults: commit, push, merge and
125
125
  - Fix loop: this rule replaces the three-round cap of the managed block. A fix loop continues after round 3 without the owner while each round has fewer blocking findings (P0-P2) than the round before and the scope does not grow. A grown scope is a joint decision. A new P0 finding, or a new P1 finding about security, secrets, data or authentication, stops the loop at the owner; any other new P1 finding does not stop it. Round 5 is the hard stop.
126
126
  - Merge: main publication needs `publication.acceptance_merge` `on` in the policy on the PR base, at every tier and on every path below. An explicit no-merge instruction always wins. Path 1: the current task explicitly authorizes main publication. Path 2: the rolling projection PR (`archctx/projection`) merges on green CI. Path 3: in an owner-approved batch, a Medium or High PR merges when its acceptance record is PASS for the head, the required CI passed and each review-bot comment has a response; a High PR also needs its cross-model review PASS; a Low PR that meets the repository's Low accept-seat skip merges on the required CI and its verification evidence, with no acceptance record. Each PR body keeps its rollback line.
127
127
  - A repository whose own rules say otherwise wins. Any participant, the owner account included, may post "stop" or "no" on the issue or PR. It is a reference: the orchestrator and the advisor weigh it, decide locally by joint decision and record the decision. The owner's own authorization reaches a seat locally.
128
- - Details: Ancienttwo/repo-harness issue #2008.
128
+ - Details: aimpact-inc/repo-harness issue #2008.
129
129
  ```
@@ -26,7 +26,7 @@ This topology applies to issue-flow work (`repo-harness-issue-flow`) on herdr-co
26
26
  - Pane layout: put at most 3 panes side by side in one tab. Do not stack panes vertically. When the tab is full, open a new tab.
27
27
  - Tab 1 holds two panes: the orchestrator on the left and its advisor on the right. Tab 1 may take one worker as its third pane.
28
28
  - The orchestrator holds the issue-flow coordinator and integrator seats. It only dispatches, accepts and merges. It does not implement a child issue.
29
- - The advisor serves only the orchestrator. It does research and writes proposals. It may edit files for its proposals. It does not commit or write to GitHub. It collects evidence through the sub-agents of its seat (`seats.advisor.fleet`) and keeps judgment, synthesis and the proposal. The orchestrator asks it for a board replan by [Replan](https://github.com/Ancienttwo/repo-harness/blob/main/assets/skills/repo-harness-issue-flow/references/replan.md).
29
+ - The advisor serves only the orchestrator. It does research and writes proposals. It may edit files for its proposals. It does not commit or write to GitHub. It collects evidence through the sub-agents of its seat (`seats.advisor.fleet`) and keeps judgment, synthesis and the proposal. The orchestrator asks it for a board replan by [Replan](https://github.com/aimpact-inc/repo-harness/blob/main/assets/skills/repo-harness-issue-flow/references/replan.md).
30
30
  - Owner decisions and seat authority (owner, 2026-11-09, #2008): the root `CLAUDE.md` and `AGENTS.md` hold the life-cycle rules and the owner list. The orchestrator dispatches an owner-approved batch plan in order, merges by rule 2 at every tier and runs fix rounds up to round 5 by rule 1. A seat that receives an owner decision in its pane posts it on the issue or PR; that comment authorizes the other seats. A comment is a record: a local seat writes it, and a locally run command may read it as data; it never starts an action. The orchestrator and the advisor make a non-security decision together when both agree, and the orchestrator posts it first as `Joint decision (orchestrator + advisor)` with the reason. The advisor makes no GitHub write. A "stop" or "no" comment from any participant, the owner account included, is a reference that the orchestrator and the advisor weigh by joint decision.
31
31
  - One PR has one pane and one worker agent. Each further worker gets its own pane, as the right split of a tab that is not full or in a new tab. The worker may use the agent-fleet sub-agents (`agents/fleet/`) inside its own pane.
32
32
  - Recommended models for a Claude-only setup: the orchestrator runs Opus at high effort, and the advisor runs Opus at max effort. This is a recommendation, not a requirement. No seat requires a specific model (issue-flow D7).
@@ -1,6 +1,6 @@
1
1
  # Host Invariants
2
2
 
3
- The host chooses when to wake, which native agents to dispatch, and how to schedule them. repo-harness supplies the upstream admission and closeout contract: authorized scope, isolated ownership, durable workflow authority, and acceptance of the exact subject. Scheduling belongs to the host; repo-harness ships no scheduler as part of this contract. Follow [Long-Run Continuation](https://github.com/Ancienttwo/repo-harness/blob/main/docs/reference-configs/long-run-continuation.md) for the tick and recovery protocol. The package does not ship that file, so this link points to the source repository.
3
+ The host chooses when to wake, which native agents to dispatch, and how to schedule them. repo-harness supplies the upstream admission and closeout contract: authorized scope, isolated ownership, durable workflow authority, and acceptance of the exact subject. Scheduling belongs to the host; repo-harness ships no scheduler as part of this contract. Follow [Long-Run Continuation](https://github.com/aimpact-inc/repo-harness/blob/main/docs/reference-configs/long-run-continuation.md) for the tick and recovery protocol. The package does not ship that file, so this link points to the source repository.
4
4
 
5
5
  These requirements apply to Claude Code, Codex and Pi. The tables distinguish what a host must do from what the current repository actually enforces. A host must not infer enforcement from a policy field, an injected sentence, a tool annotation, or a successful exit code.
6
6
 
@@ -1,6 +1,6 @@
1
1
  {
2
- "version": "0.29.1",
3
- "templateVersion": "0.29.1",
2
+ "version": "0.29.2",
3
+ "templateVersion": "0.29.2",
4
4
  "skillName": "repo-harness",
5
5
  "contractId": "tasks-first-harness-v1",
6
6
  "compatibility": {
@@ -25,7 +25,7 @@ an @mention of `portal-<slug>`.
25
25
  - Not for review or acceptance: use `repo-harness-cross-review` or
26
26
  `repo-harness review round --launch app-terminal`.
27
27
  - Already in an hc terminal (`HC_TERMINAL_ID` set): use `hc` and `herdr-app`
28
- directly ([Herdr Dispatch](https://github.com/Ancienttwo/repo-harness/blob/main/docs/reference-configs/herdr-notify.md#herdr-dispatch)).
28
+ directly ([Herdr Dispatch](https://github.com/aimpact-inc/repo-harness/blob/main/docs/reference-configs/herdr-notify.md#herdr-dispatch)).
29
29
  - Not for Codex or any second-model terminal in v2.
30
30
 
31
31
  ## Gates
@@ -134,6 +134,10 @@ map ─▶ split ─▶ gap review ─▶ publish ─▶ dispatch ─▶ worker
134
134
  - Never weaken or delete a test assertion to pass CI.
135
135
  - CI is the verification authority. A local pass does not replace a red
136
136
  required check.
137
+ - The worker pushes its branch, opens its PR and runs its own fix rounds
138
+ (`references/worker.md` §6, §7). The orchestrator sends no push or PR go
139
+ and no finding relay. A Codex-runtime worker is the exception
140
+ (`references/board.md`): the orchestrator pushes for it.
137
141
  - Only the orchestrator merges, and only with
138
142
  `repo-harness publication merge`. The owner turns that on with
139
143
  `publication.acceptance_merge` in the policy on the PR base. When it is
@@ -26,6 +26,8 @@ return the result schema can accept.
26
26
  rules in `docs/reference-configs/agentic-development-flow.md`, Review by
27
27
  risk. Code that writes comments, records, reviews or labels to GitHub is
28
28
  Medium unless it also hits the High list.
29
+ - For the Medium tier, the one review comes from a model family different
30
+ from the writer's.
29
31
  - For the High tier, at least one of the two reviews of a head comes from
30
32
  a model family different from the writer's (§2.2).
31
33
  - The other High review can use a fresh context of the writer's family.
@@ -68,8 +70,10 @@ The table rules govern how the row combines with the review.
68
70
  The board accepts a High head, or a head of unknown tier, only when it
69
71
  has `PASS` rows that cite two distinct `acceptance claim` comments of
70
72
  the PR, each with the row's `Subject` and `Round`, at least one of them with `Model relation: different-family`,
71
- and no `FAIL` row. A Medium head needs one `PASS` row and no `FAIL`
72
- row.
73
+ and no `FAIL` row. A Medium head needs one `PASS` row that cites an
74
+ `acceptance claim` comment of the PR the same way and records
75
+ `Model relation: different-family`, and no `FAIL` row. A `same-family`
76
+ or `unknown` row does not count for Medium.
73
77
 
74
78
  The review brief requires each reviewer, in its first round, to group
75
79
  findings by bug family. For each family, list every sibling case and
@@ -86,13 +90,16 @@ The table rules govern how the row combines with the review.
86
90
  PR diffs (from the one merge base with main) must not be empty. The
87
91
  board reads the rows of the new head and of the newest proven
88
92
  reviewed head only, so reviews split across older heads do not add
89
- up. A FAIL row on any proven head, or on the new head, stops the
90
- carry, and a git error on any candidate proves none. The board then shows `via: sync` with
93
+ up. The newest proven reviewed head is the subject of the newest
94
+ record with a row on a proven head. A FAIL row on that head, in any
95
+ record, or on the new head, stops the carry. A FAIL row on an older
96
+ proven head that a newer record supersedes does not stop it. A git
97
+ error on any candidate proves none. The board then shows `via: sync` with
91
98
  `carried_from` (#2074), and the new head needs CI only. Any other sync
92
99
  head (a conflict, even one resolved to the PR side; an edit in the
93
100
  merge; a new commit; a failed git step) needs a sync check: a review
94
101
  of the sync delta that writes one record row for the new head. A
95
- Medium sync head needs one sync check row. A High sync head needs the
102
+ Medium sync head needs one sync check row under the Medium rule above. A High sync head needs the
96
103
  round-1 rule: two sync check rows from distinct claims, at least one
97
104
  different-family. A PR that changes a hook path never carries: the
98
105
  owner approves each head of a hook diff again.
@@ -57,9 +57,9 @@ Rules that keep the topology safe:
57
57
 
58
58
  One `issue claim` comment takes one claim role. `issue claim` is seat-only:
59
59
  only the active coordinator holder posts it (see "Seat-only comment
60
- kinds"). A valid claim carries `Status`, `Role`, `Agent`, `Branch`,
61
- `Scope` and `Not in scope`. A claim that takes over a role also carries
62
- `Prior claim`. Board rules 2, 3 and 8 apply: one identity, read back, and
60
+ kinds"). A claim that takes over a role also carries `Prior claim`. The
61
+ required fields are in `templates.md` § issue claim.
62
+ Board rules 2, 3 and 8 apply: one identity, read back, and
63
63
  stop on an uncertain read or post.
64
64
 
65
65
  - **The coordinator posts every claim.** It claims its own coordinator
@@ -180,7 +180,9 @@ after each claim or status change.
180
180
  the plan block's merge order. A parent without a plan (two children or
181
181
  fewer) merges in blocked-by order, and the Order column of the parent
182
182
  table is only a view. After each merge, the next PR syncs with
183
- main. A merge-only sync keeps the acceptance of the reviewed head; any
183
+ main. A merge-only sync keeps the acceptance of the newest proven
184
+ reviewed head, unless that head or the new head has a FAIL row; an
185
+ older superseded FAIL row does not count. Any
184
186
  other new head needs sync check rows by the tier rule (`acceptor.md`
185
187
  §2.2, Sync head). A changed subject needs a new round.
186
188
  - **Batch integration.** When two or more PRs are eligible at the same
@@ -180,11 +180,9 @@ module is in the title so that a list view shows the write scopes.
180
180
  report channel. Do not restate the requirement in chat. A second copy
181
181
  becomes a second authority.
182
182
  - Post the claim, then the packet. Post one `issue claim` on the child
183
- issue for the worker: `Role: writer`, `Agent:` the worker identity,
184
- `Branch:` the branch that the packet names, `Scope` and `Not in scope`
185
- from the issue, and `Coordinator:` the URL of your own parent claim. The
186
- claim is the worker's identity on the board, and the worker never posts
187
- one. Dispatch only after the claim is on the issue.
183
+ issue for the worker with the required fields in `templates.md` § issue
184
+ claim. The claim is the worker's identity on the board, and the worker
185
+ never posts one. Dispatch only after the claim is on the issue.
188
186
  - Dispatch in parallel only when the write scopes are disjoint and each
189
187
  dependency is merged, or its contract is stable and the issue allows
190
188
  early start.
@@ -222,7 +220,7 @@ module is in the title so that a list view shows the write scopes.
222
220
  dispatched; route every other review of it to another seat. A dispatch
223
221
  does not grant publication, deletion or credential authority.
224
222
  For the Herdr pane topology, follow
225
- [Herdr Dispatch](https://github.com/Ancienttwo/repo-harness/blob/main/docs/reference-configs/herdr-notify.md#herdr-dispatch).
223
+ [Herdr Dispatch](https://github.com/aimpact-inc/repo-harness/blob/main/docs/reference-configs/herdr-notify.md#herdr-dispatch).
226
224
 
227
225
  ### 7.1 Quota check
228
226
 
@@ -233,7 +231,7 @@ example: `claude mode: saving (5% left < 20%)` and
233
231
  route line names with `repo-harness seats argv <seat>`; state the boundary
234
232
  in the task. A `none` route waits.
235
233
  `repo-harness board dispatch --parent <n> --space <id>` applies this step to every ready issue of the plan: it reads the `route:<class>` label of each issue (and `touches:credentials`), starts the worktree, posts the claim and opens the worker tab. `--dry-run` prints the decisions only. An issue without one `route:<class>` label is reported and not dispatched.
236
- `repo-harness board review --parent <n> --space <id>` starts the gatekeeper seat for each ready, green Medium or High pull request that has no gatekeeper start marker for its head. When the board shows `claude_review: pending` (an open High or unknown-tier head that does not meet the High acceptance rule and has no Claude reviewer row), it also starts the reviewer seat; each seat has its own marker, so a seat that was not sent retries alone. `--dry-run` prints the decisions only. A High head is not accepted until it has `PASS` rows from two distinct claims, one of them different-family to the writer (`acceptor.md` §2.2).
234
+ `repo-harness board review --parent <n> --space <id>` starts the gatekeeper seat for each ready, green High pull request that has no gatekeeper start marker for its head. When the board shows `claude_review: pending` (an open High or unknown-tier head that does not meet the High acceptance rule and has no Claude reviewer row), it also starts the reviewer seat; each seat has its own marker, so a seat that was not sent retries alone. A Medium head gets one seat of the other family than the board's `writer_family` (the `modelFamily` of the `Model:` line of the writer claim of the head branch): a non-Claude gatekeeper for a Claude writer, the Claude reviewer for any other known family. An unknown writer family (no such claim, no `Model:` line, an unmatched model, or linked issues that disagree) starts no seat and is skipped as `writer_family_unknown`; the orchestrator then starts by hand one reviewer seat of a model family known to differ from the writer's, and that review records its own `Model relation:`. `--pr <n>` reviews that pull request only. A pull request that links a plan-held issue is skipped as `plan_hold`. `--dry-run` prints the decisions only. A High head is not accepted until it has `PASS` rows from two distinct claims, one of them different-family to the writer; a Medium head needs one claimed `PASS` row recorded different-family (`acceptor.md` §2.2).
237
235
  Apply the explorer line through the Claude Agent tool's `model` parameter when you call the explorer.
238
236
 
239
237
  Claude saving mode applies when weekly remaining quota is below
@@ -270,6 +268,11 @@ or follow `hc events`. Never use `sleep` loops to wait for seats.
270
268
  Follow the PR and the issue comments. Do not poll CI with sleeps. Use the
271
269
  host's PR events or check when the worker reports.
272
270
 
271
+ - **Worker PR.** A worker pushes its branch and opens its PR as soon as its
272
+ checks pass. Do not send a push or PR go. You keep dispatch, joint
273
+ decisions, the merge, and the review start with `repo-harness board
274
+ review`. A worker reports to you only on PASS, a boundary question or a
275
+ fix-loop stop.
273
276
  - **Draft PR.** A writer keeps its PR draft until its verification
274
277
  evidence exists. Do not follow CI on a draft push by push. Act on the
275
278
  worker's `ready for review` notice (§8.1).
@@ -306,7 +309,10 @@ host's PR events or check when the worker reports.
306
309
  Findings take the severities of `acceptor.md` §3. A P3 does not block
307
310
  the PR; apply the deferred-scope rule (§2) to its follow-up. Send the
308
311
  findings to the worker that
309
- wrote the PR. You make the second-finding choice of the class rule
312
+ wrote the PR only when the worker cannot read them: the worker reads the
313
+ acceptance records and review threads on its PR and runs its own fix
314
+ rounds (`worker.md` §7). A Codex worker is the exception: you push its
315
+ fix rounds (`board.md`). You make the second-finding choice of the class rule
310
316
  (`worker.md` §7). Record the result in one acceptance record comment on
311
317
  the PR, in the row shape of `templates.md`: round, role, subject,
312
318
  verdict and model relation.
@@ -549,7 +555,9 @@ are true:
549
555
  closes two plan items is never eligible, in any plan order: split the PR.
550
556
  - An acceptance record has a PASS row for the head, at every tier. The
551
557
  provisional `tier_low` status is not enough: post the Low record after
552
- you check the verification evidence.
558
+ you check the verification evidence. A merge-only sync head carries its
559
+ acceptance per `acceptor.md` §2.2 (`via: sync`, #2074), so `board merge`
560
+ accepts it.
553
561
  A High PR needs two PASS rows for the head that cite distinct
554
562
  `acceptance claim` comments, one of them `different-family`
555
563
  (`acceptor.md` §2.2).
@@ -7,7 +7,7 @@ result to the board. This file is the only authority for replan. Other
7
7
  files link it and do not restate it.
8
8
 
9
9
  The advisor is the long-lived hc terminal in the pane beside the orchestrator
10
- ([Issue-flow topology](https://github.com/Ancienttwo/repo-harness/blob/main/docs/reference-configs/herdr-notify.md#issue-flow-topology)).
10
+ ([Issue-flow topology](https://github.com/aimpact-inc/repo-harness/blob/main/docs/reference-configs/herdr-notify.md#issue-flow-topology)).
11
11
  It holds no claim role. It does not commit, write to GitHub or
12
12
  decide.
13
13
 
@@ -244,17 +244,24 @@ Status: active # required: active
244
244
  Role: writer # required: coordinator | writer | integrator
245
245
  Slot: PR-1b # only for a named PR slot
246
246
  Agent: <kind>, session <id> # required
247
+ Runtime: <claude|codex|pi> # required on a writer claim
248
+ Model: <model id> # required on a dispatched writer claim; omitted when the seat sets no model
247
249
  Branch: <type>/<issue>-<slug> # required
248
250
  Scope: <what this claim covers> # required
249
251
  Not in scope: <what it leaves> # required
250
- Coordinator: <parent claim URL> # the coordinator's own claim
252
+ Coordinator: <parent claim URL> # required on a dispatched writer claim
251
253
  Dispatch reading: <per account> # on a dispatch: orchestrator.md §7.1
252
254
  Prior claim: <comment URL> # required on a handoff
253
255
  ```
254
256
 
255
257
  `Status`, `Role`, `Agent`, `Branch`, `Scope` and `Not in scope` are
256
- required. A handoff claim also requires `Prior claim`. A claim without
257
- any of them is invalid. The coordinator reads its claim back; when a
258
+ required. A writer claim, a handoff claim included, also requires
259
+ `Runtime:`, the runtime of the writer seat. A dispatched writer claim also
260
+ requires `Model:`, the model id of the writer seat, and `Coordinator`, the
261
+ coordinator's own claim URL. The board reads the family of `Model:`
262
+ (`modelFamily`) as the writer's model family for the Medium review seat
263
+ (`orchestrator.md`, `board review`); a claim without `Model:` has no family. A handoff claim also requires `Prior claim`. A claim
264
+ without any of them is invalid. The coordinator reads its claim back; when a
258
265
  field is missing it posts `issue claim status` with `Status: released`,
259
266
  then one complete claim. It names the missing fields in a `To: <agent>`
260
267
  comment and does not dispatch until the corrected claim is on the board.
@@ -495,8 +502,8 @@ Issue: <URL>
495
502
  Slot: <PR slot or "whole issue">
496
503
  Worktree: /tmp/<repo>-wt-<issue>-<slug> on <type>/<issue>-<slug> from origin/main
497
504
  Model: <model>
498
- Report: status comments on the issue; nudge <coordinator channel> with the comment URL
499
- Authority: implement, push the PR branch, open the PR. No merge, no deletion outside the issue, no credentials.
505
+ Report: status comments on the issue; nudge <coordinator channel> only on PASS, a boundary question or a fix-loop stop
506
+ Authority: implement, push the PR branch as soon as checks pass, open the PR, run your own fix rounds. No merge, no deletion outside the issue, no credentials.
500
507
  ```
501
508
 
502
509
  Paste this checklist under the packet when the issue does not already
@@ -37,8 +37,7 @@ board. Comment shapes are in `templates.md`. Claim-role and board rules are in
37
37
  1. The coordinator claims the writer role for you before it dispatches
38
38
  you. Find the `issue claim` for your issue or slot. Its `Agent:` names you, and
39
39
  its `Branch:` matches the branch in your dispatch packet. Check the
40
- fields: `Role`, `Agent`, `Branch`, `Scope`, `Not in scope` and the
41
- `Coordinator:` link to the coordinator's own claim. Use the identity
40
+ required fields in `templates.md` § issue claim. Use the identity
42
41
  in that claim in all later comments. Do not post a claim of your own.
43
42
  2. Read the claim back. Confirm its URL and every field. A claim that
44
43
  misses a field is invalid: post `issue claim status` with
@@ -137,6 +136,10 @@ passing check (`acceptor.md` §2.1).
137
136
  the issue. Otherwise use `Refs #<issue>`. A PR stacked on a producer PR has
138
137
  the producer's branch as its base.
139
138
  - Open as draft while a dependency is unmerged, otherwise ready.
139
+ - Commit, push the branch and open the PR yourself as soon as your checks
140
+ pass (§5). Do not wait for a push or PR go from the coordinator. A Codex
141
+ worker in a linked contract worktree does not push: the coordinator
142
+ pushes for it (`board.md`, One pusher per PR).
140
143
  - Post `issue claim status` with `Status: ready for review; claim remains
141
144
  active`, the PR URL, the head SHA and the CI state.
142
145
 
@@ -195,6 +198,12 @@ You are the head owner. Only you push to this branch.
195
198
  your diff (a network timeout, a runner fault), and say so on the board.
196
199
  After three failed fix rounds, post `Status: blocked` with the evidence
197
200
  and stop.
201
+ - **Acceptance records.** Read the acceptance records and review threads
202
+ on your PR yourself (`gh pr view <p> --comments`, `gh api`). Run each
203
+ fix round without a relay from the coordinator: fix, run the affected
204
+ checks, push, answer the threads. The fix-loop rule of `SKILL.md` and
205
+ `acceptor.md` §2.2 sets the rounds. The coordinator starts each review
206
+ with `repo-harness board review`; you do not start one.
198
207
  - **Review threads.** Fix each P0, P1 and P2 in this branch. Reply in the
199
208
  thread with the fix SHA. Do not resolve another reviewer's thread. For a
200
209
  P3 or a finding that you dispute, reply with your reason and leave the
@@ -221,7 +230,13 @@ You are the head owner. Only you push to this branch.
221
230
  - **Someone else must push.** When a repair or integration must come from
222
231
  another agent, post a `handoff` that names the next head owner and the
223
232
  exact head SHA. Then stop pushing.
224
- - **Report to the coordinator.** Every host message to the coordinator
233
+ - **Report to the coordinator only on PASS, a boundary question or a
234
+ fix-loop stop.** Send no notice for a push, a green CI run or a FAIL
235
+ that you fix yourself. A fix-loop stop is any stop or coordinator-decision
236
+ gate of this section (three failed CI fix rounds, the second finding in
237
+ one bug family) and of `acceptor.md` §2.2 (the round limits, the
238
+ blocking-finding count, a new P0 or sensitive P1, a grown scope, a new
239
+ P1 in two consecutive fix deltas). Every host message to the coordinator
225
240
  starts with `[rh-notice] <kind> #<issue>`. Select the form by content:
226
241
  - **Simple:** a fact or a question that changes no board state and
227
242
  needs no decision. Examples: dispatch received, a factual question
@@ -2570,7 +2570,7 @@ function createFileExclusiveDurably(path, content, mode = 384) {
2570
2570
  var init_atomic_append = () => {};
2571
2571
 
2572
2572
  // package.json
2573
- var version = "0.29.1", dependencies;
2573
+ var version = "0.29.2", dependencies;
2574
2574
  var init_package = __esm(() => {
2575
2575
  dependencies = {
2576
2576
  "@botiverse/oar": "0.95.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "repo-harness",
3
- "version": "0.29.1",
3
+ "version": "0.29.2",
4
4
  "description": "Installs, migrates, audits, and repairs repo-local agentic development harnesses",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -171,11 +171,14 @@ export function buildBoardCommand(host: BoardHostPortsV1, attentionHost: Attenti
171
171
  board.command('review')
172
172
  .description('Start the review seat of each ready, green pull request with no start marker for its head (takes --parent): marker comment and review tab in the writer worktree')
173
173
  .requiredOption('--space <id>', 'Herdr space that receives the review tabs')
174
+ .option('--pr <number>', 'Review this pull request only')
174
175
  .option('--dry-run', 'Print the decision for each pull request and start nothing')
175
- .action(async (options: { space: string; dryRun?: boolean }, command: Command) => {
176
+ .action(async (options: { space: string; pr?: string; dryRun?: boolean }, command: Command) => {
176
177
  try {
178
+ if (options.pr !== undefined && !/^[1-9][0-9]*$/u.test(options.pr)) throw new BoardCollectError('--pr must be a pull request number');
177
179
  const result = await runReview({
178
180
  repo_root: process.cwd(), parent: parentNumber(command.optsWithGlobals<BoardOptions>()), space: options.space, host, dry_run: options.dryRun === true,
181
+ ...(options.pr === undefined ? {} : { pr: Number(options.pr) }),
179
182
  launch: (seat, labels, cwd) => seatLaunch(seat, labels, process.env, cwd),
180
183
  });
181
184
  process.stdout.write(reviewText(result));
@@ -285,7 +288,7 @@ function reviewRunner(options: AttentionOptions, parent: number, host: BoardHost
285
288
  return observe => runReview({ repo_root: process.cwd(), parent, space, host, dry_run: false, observe, launch: (seat, labels, cwd) => seatLaunch(seat, labels, process.env, cwd) });
286
289
  }
287
290
 
288
- /** The resident loop. A failed board read or hc check ends it with exit 1; doctor then reports the watcher stopped. */
291
+ /** The resident loop. A provider 5xx skips one window; other board read or hc failures end it with exit 1. */
289
292
  async function watchAttention(options: AttentionOptions, host: BoardHostPortsV1, attentionHost: AttentionHostPortsV1): Promise<void> {
290
293
  try {
291
294
  const parent = parentNumber(options);
@@ -2,6 +2,7 @@ import { parseClosingReferences } from '../publication/closing-references';
2
2
  import type { AcceptanceMergeSwitch } from '../publication/acceptance-merge-policy';
3
3
  import type { PullRequestReadinessV2 } from '../publication/merge-readiness';
4
4
  import { isSeatStatusMessage, seatStatusMessage } from './advisor-seat';
5
+ import { modelFamily } from '../review/acceptance-receipt';
5
6
  import { readMergeHold, type BoardMergeHoldV1 } from './merge';
6
7
  import { decodePlanBlock, PlanBlockError, type PlanBlockV1 } from './plan-block';
7
8
  import {
@@ -35,6 +36,7 @@ export const BOARD_KIND = 'repo-harness.board' as const;
35
36
  export type BoardTier = 'low' | 'medium' | 'high';
36
37
  const TIER_LABELS: Readonly<Record<string, BoardTier>> = { 'tier:low': 'low', 'tier:medium': 'medium', 'tier:high': 'high' };
37
38
  const PLAN_HEADER = 'repo-harness plan';
39
+ const CLAIM_HEADER = 'repo-harness issue claim';
38
40
  const CLAIM_STATUS_HEADER = 'repo-harness issue claim status';
39
41
  export const ACCEPTANCE_RECORD_HEADER = 'repo-harness acceptance record';
40
42
  const ACCEPTANCE_CLAIM_HEADER = 'repo-harness acceptance claim';
@@ -74,7 +76,7 @@ export type BoardRequiredCheckV1 =
74
76
  export type BoardAcceptanceV1 =
75
77
  /**
76
78
  * `record`: an acceptance record has a PASS row for the head and no record has a FAIL row for it; an open High or unknown-tier pull request
77
- * also needs PASS rows of two distinct claims, one recorded `different-family` (`acceptor.md` section 2.2). `tier_low`: every closed issue is `tier:low` and `Required / CI` passed. */
79
+ * also needs PASS rows of two distinct claims, one recorded `different-family`; an open Medium one needs one claimed PASS row recorded `different-family` (`acceptor.md` section 2.2). `tier_low`: every closed issue is `tier:low` and `Required / CI` passed. */
78
80
  | { readonly status: 'accepted'; readonly via: 'record' | 'tier_low'; readonly accepted_at: string; readonly evidence_url: string }
79
81
  /** `record` on the rows of `carried_from`, an earlier reviewed head of which the head is a merge-only sync (#2074). */
80
82
  | { readonly status: 'accepted'; readonly via: 'sync'; readonly carried_from: string; readonly accepted_at: string; readonly evidence_url: string }
@@ -83,6 +85,9 @@ export type BoardAcceptanceV1 =
83
85
 
84
86
  export type BoardClaudeReviewV1 = 'not_required' | 'pending' | 'recorded';
85
87
 
88
+ /** The model family of a writer, from `modelFamily` on the `Model:` line of its claim. */
89
+ export type BoardWriterFamily = string;
90
+
86
91
  export interface BoardPullRequestV1 {
87
92
  readonly number: number;
88
93
  readonly url: string;
@@ -109,6 +114,12 @@ export interface BoardPullRequestV1 {
109
114
  * The rows of an earlier head of which the head is a proven merge-only sync count as rows of the head (#2074).
110
115
  */
111
116
  readonly claude_review: BoardClaudeReviewV1;
117
+ /**
118
+ * The family of the `Runtime:` that the newest writer claim bound to the head branch names, the same on every linked issue (the parent
119
+ * excluded); null when a linked issue has no such claim, a runtime names no family, or the issues disagree. It selects the Medium review
120
+ * seat only: the record's `Model relation:` line stays the authority of acceptance.
121
+ */
122
+ readonly writer_family: BoardWriterFamily | null;
112
123
  readonly merge_hold: BoardMergeHoldV1;
113
124
  }
114
125
 
@@ -345,20 +356,21 @@ export function syncCarryCandidates(read: BoardPullRequestReadV1, owners: BoardP
345
356
 
346
357
  /**
347
358
  * The head, and the newest proven reviewed head when it can carry: the subject of the newest record with a row of a proven head. Only
348
- * its rows count with the rows of the head, so reviews split across older heads never add up. A FAIL row on any proven head, earlier or
349
- * later than a PASS, stops the carry.
359
+ * its rows count with the rows of the head, so reviews split across older heads never add up. A FAIL row on that subject, in any record,
360
+ * stops the carry; a FAIL row on an older proven subject that the newer record supersedes does not (#2107).
350
361
  */
351
362
  function reviewedSubjects(read: BoardPullRequestReadV1, owners: BoardPathOwnersV1, proven: readonly string[]): ReadonlySet<string> {
352
363
  const syncs = new Set(syncCarryCandidates(read, owners).filter(sha => proven.includes(sha)));
353
364
  const records = protocolComments(read.comments, ACCEPTANCE_RECORD_HEADER)
354
365
  .map(record => ({ created_at: record.created_at, rows: (parseAcceptanceRecord(record) ?? []).filter(row => syncs.has(row.subject_sha)) }))
355
366
  .filter(record => record.rows.length > 0);
356
- if (records.length === 0 || records.some(record => record.rows.some(row => row.verdict === 'FAIL'))) return new Set([read.head_sha]);
357
- const newest = records.reduce((latest, record) => (record.created_at >= latest.created_at ? record : latest));
358
- return new Set([read.head_sha, newest.rows.at(-1)!.subject_sha]);
367
+ if (records.length === 0) return new Set([read.head_sha]);
368
+ const subject = records.reduce((latest, record) => (record.created_at >= latest.created_at ? record : latest)).rows.at(-1)!.subject_sha;
369
+ if (records.some(record => record.rows.some(row => row.subject_sha === subject && row.verdict === 'FAIL'))) return new Set([read.head_sha]);
370
+ return new Set([read.head_sha, subject]);
359
371
  }
360
372
 
361
- function acceptance(read: BoardPullRequestReadV1, subjects: ReadonlySet<string>, check: BoardRequiredCheckV1, closedTiers: readonly (BoardTier | null)[], strict: boolean): BoardAcceptanceV1 {
373
+ function acceptance(read: BoardPullRequestReadV1, subjects: ReadonlySet<string>, check: BoardRequiredCheckV1, closedTiers: readonly (BoardTier | null)[], rule: ReviewRule): BoardAcceptanceV1 {
362
374
  // One round is one subject SHA, and a High round has two reviews of it (`acceptor.md`, section 2): every record counts.
363
375
  const records = protocolComments(read.comments, ACCEPTANCE_RECORD_HEADER);
364
376
  const passes: { readonly record: BoardCommentV1; readonly subject: string }[] = [];
@@ -375,7 +387,7 @@ function acceptance(read: BoardPullRequestReadV1, subjects: ReadonlySet<string>,
375
387
  if (!failed && passes.length > 0) {
376
388
  // An older comment outside the read can hold a FAIL on the head.
377
389
  if (read.comments.truncated) return { status: 'unknown', reason: 'comments_truncated', evidence_url: null };
378
- if (!strict || highRuleMet(read, head)) {
390
+ if (rule === 'none' || (rule === 'medium' ? mediumRuleMet(read, head) : highRuleMet(read, head))) {
379
391
  // A head that has its own PASS row is accepted on its newest own record; otherwise the newest carried record names its reviewed head.
380
392
  const own = passes.filter(pass => pass.subject === read.head_sha);
381
393
  const newest = (own.length > 0 ? own : passes).reduce((latest, pass) => (pass.record.created_at >= latest.record.created_at ? pass : latest));
@@ -393,21 +405,35 @@ function acceptance(read: BoardPullRequestReadV1, subjects: ReadonlySet<string>,
393
405
  }
394
406
 
395
407
  /**
396
- * The High rule (`acceptor.md` section 2.2), for High and unknown tiers: PASS rows of the head from two distinct review claims,
408
+ * The rows of the head whose `Claim:` cites an `acceptance claim` comment of the pull request with the row's `Subject:` and `Round:`
409
+ * (`review publish` writes both); the comment id is the claim identity.
410
+ */
411
+ function claimedRows(read: BoardPullRequestReadV1, head: readonly AcceptanceRowV1[]): AcceptanceRowV1[] {
412
+ const claims = new Map(protocolComments(read.comments, ACCEPTANCE_CLAIM_HEADER).map(claim => [commentId(claim.url), `${field(claim.body, 'Round')} ${field(claim.body, 'Subject')}`] as const));
413
+ return head.filter(row => row.claim !== null && claims.get(row.claim) === `${row.round} ${row.subject_sha}`);
414
+ }
415
+
416
+ /**
417
+ * The High rule (`acceptor.md` section 2.2), for High and unknown tiers: claimed PASS rows of the head from two distinct review claims,
397
418
  * and at least one of them recorded `Model relation: different-family` to the writer. An unknown writer family records `unknown`,
398
- * so it fails closed. A row counts only when its `Claim:` cites an `acceptance claim` comment of the pull request with the row's
399
- * `Subject:` and `Round:` (`review publish` writes both); the comment id is the claim identity. A head with a `FAIL` row does not meet the rule.
419
+ * so it fails closed. A head with a `FAIL` row does not meet the rule.
400
420
  */
401
421
  function highRuleMet(read: BoardPullRequestReadV1, head: readonly AcceptanceRowV1[]): boolean {
402
422
  if (head.some(row => row.verdict === 'FAIL')) return false;
403
- const claims = new Map(protocolComments(read.comments, ACCEPTANCE_CLAIM_HEADER).map(claim => [commentId(claim.url), `${field(claim.body, 'Round')} ${field(claim.body, 'Subject')}`] as const));
404
- const passes = head.filter(row => row.claim !== null && claims.get(row.claim) === `${row.round} ${row.subject_sha}`);
423
+ const passes = claimedRows(read, head);
405
424
  return new Set(passes.map(row => row.claim)).size >= 2 && passes.some(row => row.different_family);
406
425
  }
407
426
 
408
- /** The High rule applies to an open pull request of High or unknown tier. */
409
- function strictReview(read: BoardPullRequestReadV1, tier: BoardTier | null): boolean {
410
- return read.state === 'open' && (tier === null || tier === 'high');
427
+ /** The Medium rule (`acceptor.md` section 2.2): one claimed PASS row of the head recorded `different-family`; `unknown` never counts. `acceptance` has ruled out a `FAIL` row. */
428
+ function mediumRuleMet(read: BoardPullRequestReadV1, head: readonly AcceptanceRowV1[]): boolean {
429
+ return claimedRows(read, head).some(row => row.different_family);
430
+ }
431
+
432
+ /** The review rule of a pull request: `high` for an open pull request of High or unknown tier, `medium` for an open Medium one, `none` otherwise. */
433
+ type ReviewRule = 'high' | 'medium' | 'none';
434
+ function reviewRule(read: BoardPullRequestReadV1, tier: BoardTier | null): ReviewRule {
435
+ if (read.state !== 'open') return 'none';
436
+ return tier === null || tier === 'high' ? 'high' : tier === 'medium' ? 'medium' : 'none';
411
437
  }
412
438
 
413
439
  /**
@@ -429,12 +455,28 @@ function effectiveTier(closes: readonly number[], refs: readonly number[], files
429
455
  * missing review (the second review for a Claude writer, the different-family review for any other writer).
430
456
  */
431
457
  function claudeReview(read: BoardPullRequestReadV1, subjects: ReadonlySet<string>, tier: BoardTier | null): BoardClaudeReviewV1 {
432
- if (!strictReview(read, tier)) return 'not_required';
458
+ if (reviewRule(read, tier) !== 'high') return 'not_required';
433
459
  const head = protocolComments(read.comments, ACCEPTANCE_RECORD_HEADER).flatMap(record => parseAcceptanceRecord(record) ?? []).filter(row => subjects.has(row.subject_sha));
434
460
  if (head.some(row => row.harness === 'claude')) return 'recorded';
435
461
  return highRuleMet(read, head) ? 'not_required' : 'pending';
436
462
  }
437
463
 
464
+ /** The writer family of a pull request (`BoardPullRequestV1.writer_family`). */
465
+ function writerFamily(read: BoardPullRequestReadV1, closes: readonly number[], refs: readonly number[], parent: BoardParentReadV1): BoardWriterFamily | null {
466
+ const issues = new Map(parent.sub_issues.map(issue => [issue.number, issue]));
467
+ const linked = [...new Set([...closes, ...refs])].filter(number => number !== parent.parent.number);
468
+ const families = new Set(linked.map((number) => {
469
+ const issue = issues.get(number);
470
+ if (issue === undefined) return null;
471
+ const claims = protocolComments(issue.comments, CLAIM_HEADER).filter(claim => field(claim.body, 'Role') === 'writer' && field(claim.body, 'Branch') === read.head_ref);
472
+ const newest = claims.length === 0 ? null : newestProtocolComment({ ...issue.comments, comments: claims }, CLAIM_HEADER);
473
+ const model = newest === null ? null : field(newest.body, 'Model');
474
+ return model === null ? null : modelFamily(model);
475
+ }));
476
+ const [family] = families;
477
+ return families.size === 1 && family !== undefined ? family : null;
478
+ }
479
+
438
480
  function bodyLinks(repository: string, body: string): { readonly closes: number[]; readonly refs: number[] } {
439
481
  const prefix = `${repository.toLowerCase()}#`;
440
482
  const closes = parseClosingReferences(repository, body).references
@@ -479,10 +521,11 @@ export function projectBoard(input: BoardInputV1): BoardV1 {
479
521
  files: read.files,
480
522
  required_check: check,
481
523
  // An issue outside this board has no observed tier, so it withholds the Low path; so does any non-Low linked issue.
482
- acceptance: acceptance(read, subjects, check, [tier], strictReview(read, tier)),
524
+ acceptance: acceptance(read, subjects, check, [tier], reviewRule(read, tier)),
483
525
  merge_readiness: readiness ?? null,
484
526
  tier,
485
527
  claude_review: claude,
528
+ writer_family: writerFamily(read, closes, refs, input.parent),
486
529
  merge_hold: readMergeHold(read.comments, false),
487
530
  });
488
531
  }).sort((left, right) => left.number - right.number);
@@ -1,7 +1,7 @@
1
1
  import { PlanBlockError, decodePlanBlock, type PlanBlockV1 } from './plan-block';
2
2
  import { selectSeatRoute, type SeatAccountQuotas } from './seat-routing';
3
3
  import { ROUTING_CLASSES, isWorkerSeat, type RoutingClass, type SeatId, type SeatsConfigV1 } from './seats-settings';
4
- import { claimStatusTarget, newestProtocolComment, parseClaimStatus, protocolComments, type BoardParentReadV1, type BoardSubIssueReadV1 } from './source';
4
+ import { claimStatusTarget, commentId, field, newestProtocolComment, parseClaimStatus, protocolComments, type BoardCommentPageV1, type BoardCommentV1, type BoardParentReadV1, type BoardSubIssueReadV1 } from './source';
5
5
 
6
6
  /**
7
7
  * Dispatch (#2004): which sub-issues of a parent are ready, and which seat each one gets. It is a pure
@@ -46,6 +46,8 @@ export interface DispatchPlanV1 {
46
46
  readonly plan: PlanBlockV1;
47
47
  /** Live worker seats that carry this parent's label before this dispatch. */
48
48
  readonly live_workers: number;
49
+ readonly coordinator: string | null;
50
+ readonly parent_comments_truncated: boolean;
49
51
  readonly decisions: readonly DispatchDecisionV1[];
50
52
  }
51
53
 
@@ -60,16 +62,27 @@ function planOf(parent: BoardParentReadV1): PlanBlockV1 {
60
62
  }
61
63
  }
62
64
 
65
+ function closedClaims(comments: BoardCommentPageV1): Set<string | null> {
66
+ return new Set(protocolComments(comments, CLAIM_STATUS_HEADER).filter(comment => {
67
+ const status = parseClaimStatus(comment)?.status;
68
+ return status === 'done' || status?.startsWith('released');
69
+ }).map(claimStatusTarget));
70
+ }
71
+
72
+ function claimOrder(a: BoardCommentV1, b: BoardCommentV1): number {
73
+ const time = a.created_at.localeCompare(b.created_at);
74
+ if (time !== 0) return time;
75
+ const aId = commentId(a.url) ?? a.url;
76
+ const bId = commentId(b.url) ?? b.url;
77
+ return aId.length - bId.length || aId.localeCompare(bId);
78
+ }
79
+
63
80
  /** Claimed: the newest claim is not released or done, or the comments are cut and the claim state cannot be known. */
64
81
  function claimDetail(issue: BoardSubIssueReadV1): string | null {
65
82
  const claim = newestProtocolComment(issue.comments, CLAIM_HEADER);
66
83
  if (claim === null) return issue.comments.truncated ? 'older comments were not read, so a claim cannot be ruled out' : null;
67
- // A status closes the claim it names, not any claim: a delayed status of an older claim leaves this one active.
68
- const closing = protocolComments(issue.comments, CLAIM_STATUS_HEADER)
69
- .filter(comment => claimStatusTarget(comment) === claim.url)
70
- .map(parseClaimStatus)
71
- .some(status => status !== null && (status.status === 'done' || status.status.startsWith('released')));
72
- return closing ? null : `active claim ${claim.url}`;
84
+ // A status closes only the claim it names, even if it arrives late.
85
+ return closedClaims(issue.comments).has(claim.url) ? null : `active claim ${claim.url}`;
73
86
  }
74
87
 
75
88
  /** The one route class that the labels name, or the reason that they do not. */
@@ -83,6 +96,12 @@ function routeClass(labels: readonly string[]): { readonly kind: RoutingClass }
83
96
  export function planDispatch(input: DispatchInputV1): DispatchPlanV1 {
84
97
  const { parent, seats, quota } = input;
85
98
  const plan = planOf(parent);
99
+ const comments = parent.parent.comments;
100
+ const closed = closedClaims(comments);
101
+ const claims = protocolComments(comments, CLAIM_HEADER)
102
+ .filter(comment => field(comment.body, 'Role') === 'coordinator' && field(comment.body, 'Status') === 'active');
103
+ const coordinator = claims.filter(claim => !closed.has(claim.url) && !claims.some(next =>
104
+ field(next.body, 'Prior claim') === claim.url && claimOrder(claim, next) < 0)).sort(claimOrder)[0];
86
105
  const parentLabel = String(parent.parent.number);
87
106
  const liveWorkers = input.terminals.filter(({ state, labels }) => state === 'live' && labels.parent === parentLabel
88
107
  && labels.seat !== undefined && isWorkerSeat(labels.seat as SeatId));
@@ -112,5 +131,5 @@ export function planDispatch(input: DispatchInputV1): DispatchPlanV1 {
112
131
  running += 1;
113
132
  return { issue: number, action: 'dispatch', title: issue.title, route_class: kind.kind, credentials, seat: route.id, route_line: route.line };
114
133
  });
115
- return Object.freeze({ plan, live_workers: liveWorkers.length, decisions: Object.freeze(decisions) });
134
+ return Object.freeze({ plan, live_workers: liveWorkers.length, coordinator: coordinator?.url ?? null, parent_comments_truncated: comments.truncated, decisions: Object.freeze(decisions) });
116
135
  }
@@ -66,9 +66,17 @@ function covering(hold: BoardMergeHoldV1, items: readonly number[]): BoardMergeH
66
66
  return hold.holds.find(record => record.issues === null || items.some(item => record.issues!.includes(item))) ?? null;
67
67
  }
68
68
 
69
+ /** The plan's refusal of a pull request, shared by `board merge` and `board review`: the plan is not observed, or it holds an issue that the pull request links. */
70
+ export function planRefusal(board: BoardV1, pr: BoardPullRequestV1): { readonly reason: 'plan_unavailable' | 'plan_hold'; readonly detail: string } | null {
71
+ if (board.plan.status !== 'observed') return { reason: 'plan_unavailable', detail: `the plan is ${board.plan.status}` };
72
+ const linked = new Set([...pr.closes, ...pr.refs]);
73
+ const hold = board.plan.block.holds.find(entry => entry.issue !== board.parent.number && linked.has(entry.issue));
74
+ return hold === undefined ? null : { reason: 'plan_hold', detail: `the plan holds #${hold.issue}: ${hold.reason}` };
75
+ }
76
+
69
77
  function refusal(board: BoardV1, pr: BoardPullRequestV1): { readonly reason: BoardMergeRefusalV1; readonly detail: string } | null {
70
78
  if (board.acceptance_merge !== 'on') return { reason: 'acceptance_merge_off', detail: `publication.acceptance_merge is ${board.acceptance_merge} on ${board.default_branch}` };
71
- if (board.plan.status !== 'observed') return { reason: 'plan_unavailable', detail: `the plan is ${board.plan.status}` };
79
+ if (board.plan.status !== 'observed') return planRefusal(board, pr);
72
80
  if (pr.is_draft) return { reason: 'draft', detail: `#${pr.number} is a draft` };
73
81
  const onBoard = new Map(board.items.map(item => [item.number, item] as const));
74
82
  const linked = [...new Set([...pr.closes, ...pr.refs])].filter(number => number !== board.parent.number).sort((left, right) => left - right);
@@ -89,8 +97,8 @@ function refusal(board: BoardV1, pr: BoardPullRequestV1): { readonly reason: Boa
89
97
  const unknown = holds.find(entry => entry.hold.status === 'unknown');
90
98
  if (unknown !== undefined) return { reason: 'hold_unknown', detail: `the comments of ${unknown.where} are truncated and hold no hold record` };
91
99
  const plan = board.plan.block;
92
- const planHold = plan.holds.find(hold => items.includes(hold.issue));
93
- if (planHold !== undefined) return { reason: 'plan_hold', detail: `the plan holds #${planHold.issue}: ${planHold.reason}` };
100
+ const planHold = planRefusal(board, pr);
101
+ if (planHold !== null) return planHold;
94
102
  const unordered = items.filter(number => !plan.merge_order.includes(number));
95
103
  if (unordered.length > 0) return { reason: 'not_in_merge_order', detail: `${unordered.map(number => `#${number}`).join(' ')} not in the plan merge_order` };
96
104
  const last = Math.max(...items.map(number => plan.merge_order.indexOf(number)));
@@ -1,4 +1,5 @@
1
1
  import { ACCEPTANCE_RECORD_HEADER, type BoardPullRequestV1, type BoardV1 } from './board';
2
+ import { planRefusal } from './merge';
2
3
  import { claimStatusTarget, newestProtocolComment, parseAcceptanceRecord, parseClaimStatus, protocolComments, type BoardCommentPageV1, type BoardCommentV1 } from './source';
3
4
 
4
5
  /**
@@ -8,13 +9,15 @@ import { claimStatusTarget, newestProtocolComment, parseAcceptanceRecord, parseC
8
9
  * A start marker is one `repo-harness review start` comment with `Subject: <head sha>` and `Seat: gatekeeper|reviewer`. It covers
9
10
  * that head for that seat until a `repo-harness review start status` comment with `Status: released` names it. The marker is the
10
11
  * one record that a seat started for a head, so a second run, or a seat that ended without a record, never starts a second seat
11
- * of the same role, and a seat that was not sent retries without restarting the other. The gatekeeper always starts; the
12
- * Claude reviewer starts too while the board reports `claude_review: pending`.
12
+ * of the same role, and a seat that was not sent retries without restarting the other. A High head starts the gatekeeper, and the
13
+ * Claude reviewer too while the board reports `claude_review: pending`. A Medium head starts the one seat of the other family than
14
+ * the writer's: a non-Claude gatekeeper for a Claude writer, the Claude reviewer for any other known family. An unknown writer family
15
+ * starts no seat, because no seat is sure to record `different-family`.
13
16
  */
14
17
  export const REVIEW_START_HEADER = 'repo-harness review start';
15
18
  export const REVIEW_START_STATUS_HEADER = 'repo-harness review start status';
16
19
 
17
- export type ReviewSkipReason = 'not_open' | 'draft' | 'ci_not_green' | 'accepted' | 'acceptance_unknown' | 'started';
20
+ export type ReviewSkipReason = 'not_open' | 'draft' | 'ci_not_green' | 'accepted' | 'acceptance_unknown' | 'started' | 'writer_family_unknown' | 'plan_hold' | 'plan_unavailable';
18
21
 
19
22
  export type ReviewSeat = 'gatekeeper' | 'reviewer';
20
23
 
@@ -26,7 +29,7 @@ export interface ReviewSeatStartV1 {
26
29
 
27
30
  export type ReviewDecisionV1 =
28
31
  | { readonly pr: number; readonly action: 'start'; readonly head_ref: string; readonly head_sha: string; readonly tier: 'medium' | 'high'; readonly seats: readonly ReviewSeatStartV1[];
29
- /** The Claude reviewer seat supplies one of the two High reviews, so the gatekeeper must not run Claude. */
32
+ /** The Claude reviewer seat supplies one of the two High reviews, or the writer of a Medium head is Claude, so the gatekeeper must not run Claude. */
30
33
  readonly needs_non_claude_gatekeeper: boolean }
31
34
  | { readonly pr: number; readonly action: 'skip'; readonly reason: ReviewSkipReason; readonly detail: string };
32
35
 
@@ -68,19 +71,23 @@ export function planReview(input: ReviewInputV1): readonly ReviewDecisionV1[] {
68
71
  const skip = (reason: ReviewSkipReason, detail: string): ReviewDecisionV1 => ({ pr: pr.number, action: 'skip', reason, detail });
69
72
  if (pr.state !== 'open') return skip('not_open', `the pull request is ${pr.state}`);
70
73
  if (pr.is_draft) return skip('draft', 'the pull request is a draft');
74
+ const refused = planRefusal(board, pr);
75
+ if (refused !== null) return skip(refused.reason, refused.detail);
71
76
  if (pr.required_check.status !== 'success') return skip('ci_not_green', `Required / CI is ${pr.required_check.status}`);
72
77
  if (pr.acceptance.status === 'accepted') return skip('accepted', `an acceptance covers ${pr.head_sha}`);
73
78
  if (pr.acceptance.status === 'unknown') return skip('acceptance_unknown', pr.acceptance.reason);
74
79
  // An unknown tier is High: a pull request that no tier label covers still gets a review.
75
80
  const tier = pr.tier ?? 'high';
76
81
  if (tier === 'low') return skip('accepted', 'a Low pull request takes no review seat');
82
+ if (tier === 'medium' && pr.writer_family === null) return skip('writer_family_unknown', 'no writer claim of the head branch has a Model line with a known family, so no seat is sure to be the other family');
77
83
  const page = input.comments.get(pr.number);
78
84
  if (page === undefined) return skip('started', 'the comments of the pull request were not read');
79
85
  if (page.truncated) return skip('started', 'older comments were not read, so a start marker cannot be ruled out');
80
- const required: readonly ReviewSeat[] = pr.claude_review === 'pending' ? ['gatekeeper', 'reviewer'] : ['gatekeeper'];
86
+ const required: readonly ReviewSeat[] = tier === 'medium' ? [pr.writer_family === 'anthropic' ? 'gatekeeper' : 'reviewer']
87
+ : pr.claude_review === 'pending' ? ['gatekeeper', 'reviewer'] : ['gatekeeper'];
81
88
  const seats = required.filter(seat => !liveMarkers(page, seat).some(marker => field(marker, 'Subject') === pr.head_sha))
82
89
  .map((seat): ReviewSeatStartV1 => ({ seat, delta_from: deltaBase(page, pr.head_sha, seat) }));
83
90
  if (seats.length === 0) return skip('started', `a start marker of every required seat covers ${pr.head_sha}`);
84
- return { pr: pr.number, action: 'start', head_ref: pr.head_ref, head_sha: pr.head_sha, tier, seats, needs_non_claude_gatekeeper: pr.claude_review !== 'not_required' };
91
+ return { pr: pr.number, action: 'start', head_ref: pr.head_ref, head_sha: pr.head_sha, tier, seats, needs_non_claude_gatekeeper: tier === 'medium' ? pr.writer_family === 'anthropic' : pr.claude_review !== 'not_required' };
85
92
  });
86
93
  }
@@ -200,7 +200,8 @@ const GIT_OID = /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/u;
200
200
  const ACTIONS_URL = /^https:\/\/github\.com\/[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+\/actions\/runs\/\d+\/job\/\d+$/u;
201
201
 
202
202
  const ASSERTION_PATTERN = /(assertion(?:error)?|expected\b.*\b(?:to|deeply) equal|deeply equal|expected\b.*\breceived\b|toBe\(|toEqual\(|mismatch)/iu;
203
- const DEPENDENCY_PATTERN = /(install|setup|dependency|lockfile|npm err|pnpm err|yarn err|bun install|package (?:fetch|resolution)|registry)/iu;
203
+ const DEPENDENCY_PATTERN = /\b(?:install|npm\s+ci)\b/iu;
204
+ const DEPENDENCY_ERROR_PATTERN = /\b(?:(?:npm|pnpm|yarn)\s+(?:err!|error)|ERR_PNPM_[A-Z_]+|(?:lockfile|registry|package (?:fetch|resolution))\b[^\r\n]*\b(?:error|failed|failure|unavailable|timeout|timed out|5\d\d)|(?:error|failed|failure)\b[^\r\n]*\b(?:lockfile|registry|package (?:fetch|resolution)))/iu;
204
205
  const PLATFORM_PATTERN = /(runner (?:has |was )?(?:shutdown|shut down|received a shutdown|terminated|lost)|lost communication with the (?:runner|server)|the operation was canceled because|service unavailable|internal server error|bad gateway|gateway timeout|ECONN(?:RESET|REFUSED)|ETIMEDOUT|EAI_AGAIN|Could not resolve host)/iu;
205
206
  const NETWORK_PATTERN = /(service unavailable|internal server error|bad gateway|gateway timeout|ECONN(?:RESET|REFUSED)|ETIMEDOUT|EAI_AGAIN|Could not resolve host|registry\b.*\b(?:unavailable|timeout|5\d\d))/iu;
206
207
 
@@ -463,8 +464,11 @@ function failureShapeOf(attempt: RequiredCheckAttemptObservationV1): RequiredChe
463
464
  || platformLines(attempt).some((line) => /runner|shutdown|shut down|lost communication/iu.test(line))) {
464
465
  return 'runner_abort';
465
466
  }
466
- const dependencySource = `${attempt.steps.join(' ')}\n${attempt.failure_excerpt ?? ''}`;
467
- if (DEPENDENCY_PATTERN.test(dependencySource)) return 'dependency_install_failure';
467
+ // The collector puts only failed steps in `steps`; passed steps stay in `scope`.
468
+ if (attempt.steps.some((step) => DEPENDENCY_PATTERN.test(step))
469
+ || (attempt.failure_excerpt !== null && DEPENDENCY_ERROR_PATTERN.test(attempt.failure_excerpt))) {
470
+ return 'dependency_install_failure';
471
+ }
468
472
  if (attempt.failure_excerpt !== null) {
469
473
  if (ASSERTION_PATTERN.test(attempt.failure_excerpt)) return 'assertion_mismatch';
470
474
  if (/\btimed out\b/iu.test(attempt.failure_excerpt)) return 'timeout';
@@ -1,7 +1,7 @@
1
1
  import { appendFileSync, mkdirSync, readFileSync, readdirSync } from 'node:fs';
2
2
  import { basename, dirname, join } from 'node:path';
3
3
  import { evaluateBoardAttention } from '../../core/board/attention';
4
- import { ADVISOR_CAP_SPAN_MS, deliveryTiming, liveSeatTerminals, planAttentionDeliveries, type AttentionDeliveryV1, type AttentionHostPortsV1 } from '../../core/board/attention-delivery';
4
+ import { ADVISOR_CAP_SPAN_MS, WINDOW_WITH_WORKERS_MS, deliveryTiming, liveSeatTerminals, planAttentionDeliveries, type AttentionDeliveryV1, type AttentionHostPortsV1 } from '../../core/board/attention-delivery';
5
5
  import type { BoardV1 } from '../../core/board/board';
6
6
  import { repoHarnessHome } from '../repo-harness-home';
7
7
  import { BoardCollectError } from './collect';
@@ -12,8 +12,8 @@ import type { ReviewObserver } from './review';
12
12
  * carries the service label and the repository and parent labels of its
13
13
  * board. Each window it reads the board once, runs the attention rules, sends
14
14
  * the findings to the seat terminals and appends every finding and every send
15
- * attempt to its log. A failed board read ends the watcher; doctor then
16
- * reports it stopped.
15
+ * attempt to its log. A provider 5xx skips one window; other board read failures
16
+ * end the watcher, and doctor then reports it stopped.
17
17
  */
18
18
  export class AttentionWatchError extends Error {
19
19
  constructor(message: string) {
@@ -32,6 +32,7 @@ export type AttentionSendOutcome = 'sent' | 'send_failed' | 'skipped_blocked' |
32
32
 
33
33
  /** One log line. The log is append-only; the weekly threshold review reads it. */
34
34
  export type AttentionLogRecordV1 = { readonly at: string; readonly window: string; readonly parent: number } & (
35
+ | { readonly kind: 'error'; readonly message: string }
35
36
  | { readonly kind: 'finding'; readonly rule: string; readonly route: string; readonly message: string }
36
37
  | { readonly kind: 'review'; readonly pr: number | null; readonly seat: string | null; readonly outcome: 'started' | 'refused'; readonly detail: string | null }
37
38
  | { readonly kind: 'skip'; readonly route: string; readonly reason: string }
@@ -116,7 +117,13 @@ export async function runAttentionWindow(input: AttentionWindowInput): Promise<v
116
117
  const started = now();
117
118
  const window = started.toISOString();
118
119
  const log = (record: Record<string, unknown>) => append(input.log_path, { at: now().toISOString(), window, parent: input.parent, ...record } as AttentionLogRecordV1);
119
- const board = input.collect();
120
+ let board: BoardV1;
121
+ try { board = input.collect(); } catch (error) {
122
+ if (!(error instanceof BoardCollectError && error.httpStatus !== null && error.httpStatus >= 500 && error.httpStatus <= 599)) throw error;
123
+ process.stderr.write(`${JSON.stringify({ ok: false, error: error.name, message: error.message })}\n`);
124
+ log({ kind: 'error', message: error.message });
125
+ return sleep(started.getTime() + WINDOW_WITH_WORKERS_MS - now().getTime());
126
+ }
120
127
  const attention = evaluateBoardAttention(board);
121
128
  for (const finding of attention.findings) log({ kind: 'finding', rule: finding.rule, route: finding.route, message: finding.message });
122
129
  const reviewLines = input.review === undefined ? [] : await reviewWindow(input.review, log);
@@ -52,7 +52,7 @@ export function pullRequestsQuery(numbers: readonly number[]): string {
52
52
  }
53
53
 
54
54
  export class BoardCollectError extends Error {
55
- constructor(message: string) {
55
+ constructor(message: string, readonly httpStatus: number | null = null) {
56
56
  super(message);
57
57
  this.name = 'BoardCollectError';
58
58
  }
@@ -85,7 +85,11 @@ function runGh(input: GhInput, args: readonly string[]): { readonly status: numb
85
85
  /** One gh call that prints JSON; a failed call or invalid JSON is a `BoardCollectError`. */
86
86
  export function readGhJson(input: GhInput, args: readonly string[]): unknown {
87
87
  const result = runGh(input, args);
88
- if (result.status !== 0) throw new BoardCollectError(`gh ${args.slice(0, 2).join(' ')} failed: ${(result.stderr ?? '').trim() || `exit ${result.status}`}`);
88
+ if (result.status !== 0) {
89
+ const stderr = (result.stderr ?? '').trim();
90
+ const status = /\bHTTP (\d{3})\b/u.exec(stderr);
91
+ throw new BoardCollectError(`gh ${args.slice(0, 2).join(' ')} failed: ${stderr || `exit ${result.status}`}`, status === null ? null : Number(status[1]));
92
+ }
89
93
  try {
90
94
  return JSON.parse(result.stdout);
91
95
  } catch {
@@ -1,7 +1,7 @@
1
1
  import { spawnSync } from 'child_process';
2
2
  import { DispatchError, planDispatch, type DispatchDecisionV1, type DispatchPlanV1 } from '../../core/board/dispatch';
3
3
  import type { BoardHostPortsV1 } from '../../core/board/board';
4
- import { seatAccountQuotas } from '../../core/board/seat-routing';
4
+ import { effectiveSeatConfig, seatAccountQuotas } from '../../core/board/seat-routing';
5
5
  import { withSeatLine } from '../../core/board/seat-line';
6
6
  import type { SeatConfigV1, SeatId } from '../../core/board/seats-settings';
7
7
  import { HerdrCoreError, herdrAppDo } from '../terminal/herdr-core';
@@ -64,16 +64,18 @@ function startWorktree(input: DispatchInput, issue: number): { readonly path: st
64
64
  return { path: start.worktree_path, branch: start.branch };
65
65
  }
66
66
 
67
- function claimBody(decision: DispatchedV1, branch: string, tab: string | null, runtime: SeatConfigV1['runtime']): string {
67
+ function claimBody(decision: DispatchedV1, branch: string, tab: string | null, runtime: SeatConfigV1['runtime'], model: string | null, coordinator: string): string {
68
68
  return [
69
69
  'repo-harness issue claim',
70
70
  'Status: active',
71
71
  'Role: writer',
72
72
  `Agent: ${decision.seat}, session ${tab ?? 'unnamed tab'}`,
73
73
  `Runtime: ${runtime}`,
74
+ ...(model === null ? [] : [`Model: ${model}`]),
74
75
  `Branch: ${branch}`,
75
76
  `Scope: issue #${decision.issue} as its body states it`,
76
77
  'Not in scope: anything the issue body does not name',
78
+ `Coordinator: ${coordinator}`,
77
79
  `Dispatch reading: ${decision.route_line}`,
78
80
  ].join('\n');
79
81
  }
@@ -94,8 +96,9 @@ function releaseClaim(ports: DispatchPorts, issue: number, claimUrl: string): vo
94
96
  * (`seats argv`). A launch that failed before the request keeps no claim; one that may have created the tab keeps it and
95
97
  * stops, because a retry could start a second worker.
96
98
  */
97
- export async function executeDispatch(plan: DispatchPlanV1, context: { readonly repositoryId: string; readonly parent: number; readonly space: string; readonly dry_run: boolean }, ports: DispatchPorts): Promise<DispatchResultV1['started']> {
99
+ export async function executeDispatch(plan: DispatchPlanV1, context: { readonly repositoryId: string; readonly parent: number; readonly space: string; readonly dry_run: boolean; readonly model: (seat: SeatId) => string | null }, ports: DispatchPorts): Promise<DispatchResultV1['started']> {
98
100
  const started: Array<DispatchResultV1['started'][number]> = [];
101
+ if (plan.decisions.some(decision => decision.action === 'dispatch') && plan.coordinator === null) throw new DispatchError(`#${context.parent} has no active coordinator claim${plan.parent_comments_truncated ? ' in the comments that were read; older parent comments were not read' : ''}; nothing was started`);
99
102
  if (context.dry_run) return started;
100
103
  for (const decision of plan.decisions) {
101
104
  if (decision.action !== 'dispatch') continue;
@@ -104,7 +107,7 @@ export async function executeDispatch(plan: DispatchPlanV1, context: { readonly
104
107
  const launch = await ports.launch(decision.seat, labels, worktree.path);
105
108
  // The launch reads the seats configuration again, so the runtime that will run is checked here, not the planned one.
106
109
  if (decision.credentials && launch.runtime === 'pi') throw new DispatchError(`#${decision.issue} touches credentials and its launch resolved to a Pi seat; nothing was started`);
107
- const claimUrl = ports.comment(decision.issue, claimBody(decision, worktree.branch, launch.tab, launch.runtime));
110
+ const claimUrl = ports.comment(decision.issue, claimBody(decision, worktree.branch, launch.tab, launch.runtime, context.model(decision.seat), plan.coordinator!));
108
111
  try {
109
112
  ports.openTab({
110
113
  ...(launch.tab === null ? {} : { name: launch.tab }), space: context.space, folder: worktree.path, argv: launch.argv, task: packet(decision, worktree.path, claimUrl),
@@ -130,7 +133,10 @@ export async function runDispatch(input: DispatchInput): Promise<DispatchResultV
130
133
  const { seats } = readSeatsConfiguration(process.env);
131
134
  const quota = seatAccountQuotas((await readQuotaReport(process.env)).accounts, seats.routing);
132
135
  const plan = planDispatch({ parent, terminals: terminals.terminals, seats, quota });
133
- const started = await executeDispatch(plan, { repositoryId, parent: input.parent, space: input.space, dry_run: input.dry_run }, {
136
+ const started = await executeDispatch(plan, { repositoryId, parent: input.parent, space: input.space, dry_run: input.dry_run,
137
+ // The same projection that `seatLaunch` uses for the argv, so the claim names the model that runs.
138
+ model: seat => effectiveSeatConfig(seat, seats, quota)?.model ?? null,
139
+ }, {
134
140
  startWorktree: issue => startWorktree(input, issue),
135
141
  comment: (issue, body) => gh(input, ['issue', 'comment', String(issue), '--body-file', '-'], withSeatLine(body)),
136
142
  openTab: args => { herdrAppDo('tab.new', args); },
@@ -24,6 +24,8 @@ export interface ReviewInput extends Pick<BoardCollectInput, 'repo_root' | 'pare
24
24
  readonly launch: ReviewLaunch;
25
25
  /** Plan only: no marker, no seat. */
26
26
  readonly dry_run: boolean;
27
+ /** Review this pull request only. */
28
+ readonly pr?: number;
27
29
  /** Called at each start and refusal as it happens, so a caller keeps the completed ones when a later step throws. */
28
30
  readonly observe?: ReviewObserver;
29
31
  }
@@ -158,9 +160,10 @@ export async function runReview(input: ReviewInput): Promise<ReviewResultV1> {
158
160
  const repositoryId = String(readRepositoryId(input));
159
161
  const result = await withReviewLock(repositoryId, async () => {
160
162
  const board = collectBoard({ repo_root: input.repo_root, parent: input.parent, host: input.host });
161
- const open = board.pull_requests.filter(pr => pr.state === 'open' && !pr.is_draft && pr.required_check.status === 'success' && pr.acceptance.status === 'not_accepted');
163
+ if (input.pr !== undefined && !board.pull_requests.some(pr => pr.number === input.pr)) throw new BoardCollectError(`#${input.pr} is not a pull request of #${input.parent}`);
164
+ const open = board.pull_requests.filter(pr => (input.pr === undefined || pr.number === input.pr) && pr.state === 'open' && !pr.is_draft && pr.required_check.status === 'success' && pr.acceptance.status === 'not_accepted');
162
165
  const comments = new Map(open.map(pr => [pr.number, readComments(input, pr.number)]));
163
- const decisions = planReview({ board, comments });
166
+ const decisions = planReview({ board, comments }).filter(decision => input.pr === undefined || decision.pr === input.pr);
164
167
  return { decisions, ...await executeReview(decisions, { repositoryId, parent: input.parent, space: input.space, dry_run: input.dry_run, observe: input.observe }, {
165
168
  worktree: (ref, sha) => worktreeAt(input, ref, sha),
166
169
  comment: (pr, body) => gh(input, ['pr', 'comment', String(pr), '--body-file', '-'], body),