@cluesmith/codev 3.0.6 → 3.1.1

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 (118) hide show
  1. package/dashboard-dist/assets/{index-CR-uu485.js → index-CM6A5r59.js} +39 -39
  2. package/dashboard-dist/assets/index-CM6A5r59.js.map +1 -0
  3. package/dashboard-dist/assets/index-Cl5tt1AP.css +32 -0
  4. package/dashboard-dist/index.html +2 -2
  5. package/dist/agent-farm/cli.d.ts.map +1 -1
  6. package/dist/agent-farm/cli.js +14 -0
  7. package/dist/agent-farm/cli.js.map +1 -1
  8. package/dist/agent-farm/commands/send.d.ts +13 -2
  9. package/dist/agent-farm/commands/send.d.ts.map +1 -1
  10. package/dist/agent-farm/commands/send.js +49 -14
  11. package/dist/agent-farm/commands/send.js.map +1 -1
  12. package/dist/agent-farm/commands/status.d.ts.map +1 -1
  13. package/dist/agent-farm/commands/status.js +41 -13
  14. package/dist/agent-farm/commands/status.js.map +1 -1
  15. package/dist/agent-farm/commands/stop.d.ts.map +1 -1
  16. package/dist/agent-farm/commands/stop.js +9 -5
  17. package/dist/agent-farm/commands/stop.js.map +1 -1
  18. package/dist/agent-farm/commands/workspace-remove-architect.d.ts +16 -0
  19. package/dist/agent-farm/commands/workspace-remove-architect.d.ts.map +1 -0
  20. package/dist/agent-farm/commands/workspace-remove-architect.js +40 -0
  21. package/dist/agent-farm/commands/workspace-remove-architect.js.map +1 -0
  22. package/dist/agent-farm/servers/overview.d.ts +26 -0
  23. package/dist/agent-farm/servers/overview.d.ts.map +1 -1
  24. package/dist/agent-farm/servers/overview.js +31 -12
  25. package/dist/agent-farm/servers/overview.js.map +1 -1
  26. package/dist/agent-farm/servers/tower-instances.d.ts +25 -0
  27. package/dist/agent-farm/servers/tower-instances.d.ts.map +1 -1
  28. package/dist/agent-farm/servers/tower-instances.js +298 -45
  29. package/dist/agent-farm/servers/tower-instances.js.map +1 -1
  30. package/dist/agent-farm/servers/tower-routes.d.ts.map +1 -1
  31. package/dist/agent-farm/servers/tower-routes.js +240 -6
  32. package/dist/agent-farm/servers/tower-routes.js.map +1 -1
  33. package/dist/agent-farm/servers/tower-server.js +8 -0
  34. package/dist/agent-farm/servers/tower-server.js.map +1 -1
  35. package/dist/agent-farm/servers/tower-terminals.d.ts.map +1 -1
  36. package/dist/agent-farm/servers/tower-terminals.js +76 -12
  37. package/dist/agent-farm/servers/tower-terminals.js.map +1 -1
  38. package/dist/agent-farm/servers/tower-types.d.ts +24 -0
  39. package/dist/agent-farm/servers/tower-types.d.ts.map +1 -1
  40. package/dist/agent-farm/servers/worktree-config-watcher.d.ts +36 -0
  41. package/dist/agent-farm/servers/worktree-config-watcher.d.ts.map +1 -0
  42. package/dist/agent-farm/servers/worktree-config-watcher.js +80 -0
  43. package/dist/agent-farm/servers/worktree-config-watcher.js.map +1 -0
  44. package/dist/agent-farm/state.d.ts +29 -5
  45. package/dist/agent-farm/state.d.ts.map +1 -1
  46. package/dist/agent-farm/state.js +54 -12
  47. package/dist/agent-farm/state.js.map +1 -1
  48. package/dist/agent-farm/types.d.ts +23 -0
  49. package/dist/agent-farm/types.d.ts.map +1 -1
  50. package/dist/agent-farm/utils/architect-name.d.ts +5 -0
  51. package/dist/agent-farm/utils/architect-name.d.ts.map +1 -1
  52. package/dist/agent-farm/utils/architect-name.js +8 -0
  53. package/dist/agent-farm/utils/architect-name.js.map +1 -1
  54. package/dist/agent-farm/utils/config.d.ts +2 -12
  55. package/dist/agent-farm/utils/config.d.ts.map +1 -1
  56. package/dist/agent-farm/utils/config.js +20 -0
  57. package/dist/agent-farm/utils/config.js.map +1 -1
  58. package/dist/cli.d.ts.map +1 -1
  59. package/dist/cli.js +2 -0
  60. package/dist/cli.js.map +1 -1
  61. package/dist/commands/consult/index.d.ts +4 -0
  62. package/dist/commands/consult/index.d.ts.map +1 -1
  63. package/dist/commands/consult/index.js +160 -31
  64. package/dist/commands/consult/index.js.map +1 -1
  65. package/dist/commands/porch/artifacts.d.ts +32 -0
  66. package/dist/commands/porch/artifacts.d.ts.map +1 -1
  67. package/dist/commands/porch/artifacts.js +129 -0
  68. package/dist/commands/porch/artifacts.js.map +1 -1
  69. package/dist/lib/config.d.ts +17 -2
  70. package/dist/lib/config.d.ts.map +1 -1
  71. package/dist/lib/config.js +30 -2
  72. package/dist/lib/config.js.map +1 -1
  73. package/dist/lib/default-branch.d.ts +11 -0
  74. package/dist/lib/default-branch.d.ts.map +1 -0
  75. package/dist/lib/default-branch.js +23 -0
  76. package/dist/lib/default-branch.js.map +1 -0
  77. package/dist/lib/github.d.ts +1 -1
  78. package/dist/lib/github.d.ts.map +1 -1
  79. package/dist/lib/github.js +5 -1
  80. package/dist/lib/github.js.map +1 -1
  81. package/dist/terminal/pty-session.d.ts.map +1 -1
  82. package/dist/terminal/pty-session.js +5 -0
  83. package/dist/terminal/pty-session.js.map +1 -1
  84. package/dist/terminal/shellper-client.d.ts +15 -0
  85. package/dist/terminal/shellper-client.d.ts.map +1 -1
  86. package/dist/terminal/shellper-client.js +37 -0
  87. package/dist/terminal/shellper-client.js.map +1 -1
  88. package/dist/terminal/shellper-process.d.ts +1 -0
  89. package/dist/terminal/shellper-process.d.ts.map +1 -1
  90. package/dist/terminal/shellper-process.js +8 -0
  91. package/dist/terminal/shellper-process.js.map +1 -1
  92. package/dist/terminal/shellper-protocol.d.ts +12 -0
  93. package/dist/terminal/shellper-protocol.d.ts.map +1 -1
  94. package/dist/terminal/shellper-protocol.js.map +1 -1
  95. package/package.json +3 -3
  96. package/scripts/forge/gitea/issue-list.sh +24 -1
  97. package/scripts/forge/gitea/pr-list.sh +21 -1
  98. package/scripts/forge/gitea/recently-closed.sh +19 -1
  99. package/scripts/forge/gitea/recently-merged.sh +25 -1
  100. package/scripts/forge/github/pr-search.sh +2 -2
  101. package/skeleton/protocols/air/consult-types/pr-review.md +5 -1
  102. package/skeleton/protocols/aspir/builder-prompt.md +3 -3
  103. package/skeleton/protocols/aspir/consult-types/pr-review.md +5 -1
  104. package/skeleton/protocols/bugfix/consult-types/pr-review.md +2 -1
  105. package/skeleton/protocols/maintain/consult-types/pr-review.md +5 -1
  106. package/skeleton/protocols/pir/builder-prompt.md +2 -2
  107. package/skeleton/protocols/pir/consult-types/pr-review.md +3 -2
  108. package/skeleton/protocols/pir/prompts/implement.md +15 -7
  109. package/skeleton/protocols/pir/prompts/review.md +27 -21
  110. package/skeleton/protocols/pir/protocol.json +1 -1
  111. package/skeleton/protocols/pir/protocol.md +4 -6
  112. package/skeleton/protocols/spir/builder-prompt.md +3 -3
  113. package/skeleton/protocols/spir/consult-types/pr-review.md +5 -1
  114. package/skeleton/roles/builder.md +21 -0
  115. package/skeleton/templates/AGENTS.md +20 -0
  116. package/skeleton/templates/CLAUDE.md +20 -0
  117. package/dashboard-dist/assets/index-CR-uu485.js.map +0 -1
  118. package/dashboard-dist/assets/index-nCeIzV_d.css +0 -32
@@ -4,7 +4,7 @@ You are executing the **REVIEW** phase of the PIR protocol.
4
4
 
5
5
  ## Your Goal
6
6
 
7
- Write a retrospective at `codev/reviews/{{artifact_name}}.md` including **Summary**, **Architecture Updates**, and **Lessons Learned Updates** sections. Push, open a PR using the review file as the PR body, record the PR with porch, then signal completion — **porch runs CMAP-2 (Gemini + Codex) once** via the verify block. CMAP is a *single advisory pass* (`max_iterations: 1`): its verdicts are surfaced to the human at the `pr` gate, **not** an iterate-until-APPROVE loop. After the single pass the `pr` gate fires regardless of verdict; you notify the architect (leading with any REQUEST_CHANGES) and wait at the gate while the human merges on GitHub.
7
+ Write a retrospective at `codev/reviews/{{artifact_name}}.md` including **Summary**, **Architecture Updates**, and **Lessons Learned Updates** sections. Push, open a PR using the review file as the PR body, record the PR with porch, then signal completion — **porch runs 3-way consultation (Gemini, Codex, Claude) once** via the verify block. The consultation is a *single advisory pass* (`max_iterations: 1`): its verdicts are surfaced to the human at the `pr` gate, **not** an iterate-until-APPROVE loop. After the single pass the `pr` gate fires regardless of verdict; you notify the architect (leading with any REQUEST_CHANGES) and wait at the gate while the human merges on GitHub.
8
8
 
9
9
  The retrospective ships with the merged PR — it's durable team knowledge, searchable in `codev/reviews/` on `main`.
10
10
 
@@ -38,7 +38,7 @@ Fixes #{{issue.number}}
38
38
 
39
39
  ## Files Changed
40
40
 
41
- Output of `git diff --stat main`, formatted as a list:
41
+ Output of `git diff --stat "$MERGE_BASE"`, formatted as a list (resolve once: `DEFAULT_BRANCH=$(git symbolic-ref --short refs/remotes/origin/HEAD 2>/dev/null | sed 's|^origin/||'); DEFAULT_BRANCH=${DEFAULT_BRANCH:-main}; MERGE_BASE=$(git merge-base "$DEFAULT_BRANCH" HEAD)`. Anchoring at the merge-base keeps the file list scoped to *your* changes, not commits the base branch absorbed after you branched.):
42
42
 
43
43
  - `path/to/file.ts` (+12 / -3)
44
44
  - `path/to/new-file.ts` (+45 / -0)
@@ -123,7 +123,7 @@ gh pr edit <PR-number> --body-file codev/reviews/{{artifact_name}}.md
123
123
 
124
124
  ### 4a. Record the PR with Porch
125
125
 
126
- Immediately after creating the PR, tell porch about it so `status.yaml` carries the PR number and branch. This is a metadata-only call — it does NOT advance the phase or trigger CMAP:
126
+ Immediately after creating the PR, tell porch about it so `status.yaml` carries the PR number and branch. This is a metadata-only call — it does NOT advance the phase or trigger the consultation:
127
127
 
128
128
  ```bash
129
129
  porch done {{project_id}} --pr <PR-number> --branch "$(git branch --show-current)"
@@ -131,7 +131,7 @@ porch done {{project_id}} --pr <PR-number> --branch "$(git branch --show-current
131
131
 
132
132
  Without this, porch's `history:` for the project stays empty and downstream tooling (status views, analytics, audit trails) can't link the porch project to its GitHub PR.
133
133
 
134
- ### 5. Signal Completion to Porch (porch runs CMAP-2)
134
+ ### 5. Signal Completion to Porch (porch runs 3-way consultation)
135
135
 
136
136
  ```bash
137
137
  porch done {{project_id}}
@@ -139,14 +139,14 @@ porch done {{project_id}}
139
139
 
140
140
  Porch will:
141
141
  1. Run the `pr_exists` / `review_has_arch_updates` / `review_has_lessons_updates` checks.
142
- 2. **Execute CMAP-2 (Gemini + Codex) automatically** via the protocol's `verify` block. Outputs land in `codev/projects/{{project_id}}-<slug>/{{project_id}}-gemini.txt` and `<id>-codex.txt`.
143
- 3. CMAP runs **exactly once** (`max_iterations: 1`). Whatever the verdicts, porch records them in `status.yaml` and advances to the `pr` gate — there is **no automated re-review pass and no "stays in the review phase" loop**. `APPROVE` and `REQUEST_CHANGES` differ only in what you must surface to the human (steps 6–7), not in whether the gate fires. The output of `porch done` surfaces the verdicts.
142
+ 2. **Run 3-way consultation (Gemini, Codex, Claude) automatically** via the protocol's `verify` block. Outputs land in `codev/projects/{{project_id}}-<slug>/{{project_id}}-gemini.txt`, `<id>-codex.txt`, and `<id>-claude.txt`.
143
+ 3. The consultation runs **exactly once** (`max_iterations: 1`). Whatever the verdicts, porch records them in `status.yaml` and advances to the `pr` gate — there is **no automated re-review pass and no "stays in the review phase" loop**. `APPROVE` and `REQUEST_CHANGES` differ only in what you must surface to the human (steps 6–7), not in whether the gate fires. The output of `porch done` surfaces the verdicts.
144
144
 
145
- > **Why CMAP-2, not CMAP-3?** PIR's design parallels BUGFIX/AIR's consult footprint. The human already approved the *running* implementation at the `dev-approval` gate; CMAP at PR is a pre-merge hygiene + code-quality pass, not a functional review.
145
+ > **Why consult after the human already approved the running code?** The human approved the *running* implementation at the `dev-approval` gate; the 3-way consultation at the PR is a pre-merge hygiene + code-quality pass, not a functional review.
146
146
 
147
147
  ### 6. Handle a REQUEST_CHANGES Verdict (single-pass — no automated re-review)
148
148
 
149
- PIR's CMAP is one advisory pass (`max_iterations: 1`). If a reviewer returns `REQUEST_CHANGES`, porch does **not** loop or re-run CMAP — it records the verdict and proceeds to the `pr` gate. There is no iter-2. The correctness backstop for a CMAP-flagged issue is therefore **(a)** your fix + a regression test and **(b)** the human's `pr`-gate review — *not* an independent model re-review. Treat that as load-bearing: a substantive finding you "address and rebut" gets no second AI opinion.
149
+ PIR's consultation is one advisory pass (`max_iterations: 1`). If a reviewer returns `REQUEST_CHANGES`, porch does **not** loop or re-run it — it records the verdict and proceeds to the `pr` gate. There is no iter-2. The correctness backstop for a consultation-flagged issue is therefore **(a)** your fix + a regression test and **(b)** the human's `pr`-gate review — *not* an independent model re-review. Treat that as load-bearing: a substantive finding you "address and rebut" gets no second AI opinion.
150
150
 
151
151
  For any `REQUEST_CHANGES`:
152
152
 
@@ -154,22 +154,23 @@ For any `REQUEST_CHANGES`:
154
154
  2. **Assess it honestly:**
155
155
  - **Real defect** (correctness / cancellation / security / data-loss): fix it in code, add a regression test that fails without the fix, commit + push (the PR updates automatically — no new `gh pr create`). Then document the finding, your fix, and the pinning test in the review file's **"Things to Look At During PR Review"** section.
156
156
  - **False positive / out of scope**: write a brief rebuttal in that same section explaining why no change is warranted.
157
- 3. Do **not** re-run `porch done` expecting another CMAP — `max_iterations: 1` means it will not re-review. Proceed to step 7.
157
+ 3. Do **not** re-run `porch done` expecting another consultation pass — `max_iterations: 1` means it will not re-review. Proceed to step 7.
158
158
 
159
159
  Whether you fixed it or rebutted it, a `REQUEST_CHANGES` that PIR will never re-check **must be escalated to the human at the `pr` gate** (step 7) — they are the only remaining reviewer of that decision.
160
160
 
161
- ### 7. Notify the Architect (after the single CMAP pass — gate is now pending)
161
+ ### 7. Notify the Architect (after the single consultation pass — gate is now pending)
162
162
 
163
- After the one CMAP pass + structural checks, porch fires the **`pr` gate** (pending) **regardless of the verdicts**. Read the verdicts from porch state and notify — and if any verdict is `REQUEST_CHANGES`, **lead with it and state the disposition**, because PIR will not re-review it and the human at the `pr` gate is the only remaining check:
163
+ After the one consultation pass + structural checks, porch fires the **`pr` gate** (pending) **regardless of the verdicts**. Read the verdicts from porch state and notify — and if any verdict is `REQUEST_CHANGES`, **lead with it and state the disposition**, because PIR will not re-review it and the human at the `pr` gate is the only remaining check:
164
164
 
165
165
  ```bash
166
166
  GEMINI_VERDICT=$(grep -m1 -i '^\(approve\|request_changes\|comment\)' "codev/projects/{{project_id}}-"*/"{{project_id}}-gemini.txt" || echo UNKNOWN)
167
167
  CODEX_VERDICT=$(grep -m1 -i '^\(approve\|request_changes\|comment\)' "codev/projects/{{project_id}}-"*/"{{project_id}}-codex.txt" || echo UNKNOWN)
168
+ CLAUDE_VERDICT=$(grep -m1 -i '^\(approve\|request_changes\|comment\)' "codev/projects/{{project_id}}-"*/"{{project_id}}-claude.txt" || echo UNKNOWN)
168
169
 
169
- if echo "$GEMINI_VERDICT $CODEX_VERDICT" | grep -qi request_changes; then
170
- afx send architect "⚠️ PR #<M> (PIR #{{issue.number}}): CMAP returned REQUEST_CHANGES (gemini=$GEMINI_VERDICT, codex=$CODEX_VERDICT). Disposition: <one line — fixed in <sha> + regression test | rebutted, see review 'Things to Look At'>. PIR is single-pass — this was NOT independently re-reviewed; please verify the fix/rebuttal at the pr gate before approving. Full verdicts in codev/projects/{{project_id}}-*/."
170
+ if echo "$GEMINI_VERDICT $CODEX_VERDICT $CLAUDE_VERDICT" | grep -qi request_changes; then
171
+ afx send architect "⚠️ PR #<M> (PIR #{{issue.number}}): 3-way consultation returned REQUEST_CHANGES (gemini=$GEMINI_VERDICT, codex=$CODEX_VERDICT, claude=$CLAUDE_VERDICT). Disposition: <one line — fixed in <sha> + regression test | rebutted, see review 'Things to Look At'>. PIR is single-pass — this was NOT independently re-reviewed; please verify the fix/rebuttal at the pr gate before approving. Full verdicts in codev/projects/{{project_id}}-*/."
171
172
  else
172
- afx send architect "PR #<M> ready for review (PIR #{{issue.number}}). CMAP all clear: gemini=$GEMINI_VERDICT, codex=$CODEX_VERDICT. Awaiting human merge + pr gate approval. Full verdicts in codev/projects/{{project_id}}-*/."
173
+ afx send architect "PR #<M> ready for review (PIR #{{issue.number}}). 3-way consultation all clear: gemini=$GEMINI_VERDICT, codex=$CODEX_VERDICT, claude=$CLAUDE_VERDICT. Awaiting human merge + pr gate approval. Full verdicts in codev/projects/{{project_id}}-*/."
173
174
  fi
174
175
  ```
175
176
 
@@ -186,7 +187,7 @@ The human will:
186
187
 
187
188
  Porch will then fire the gate-approved wake-up to you.
188
189
 
189
- If the human requests more changes instead of approving, push fixes and re-run `porch done {{project_id}}` — this runs a fresh **single** CMAP pass on the updated diff and re-fires the `pr` gate (handle any new verdict per steps 6–7). This human-driven iteration is the only way CMAP re-runs in PIR; it is not automatic. If they close the PR without merging, `gh pr close <M>` and stop.
190
+ If the human requests more changes instead of approving, push fixes and re-run `porch done {{project_id}}` — this runs a fresh **single** consultation pass on the updated diff and re-fires the `pr` gate (handle any new verdict per steps 6–7). This human-driven iteration is the only way the consultation re-runs in PIR; it is not automatic. If they close the PR without merging, `gh pr close <M>` and stop.
190
191
 
191
192
  ### 9. After `pr` Gate Approval — Verify, Merge, Record
192
193
 
@@ -235,23 +236,28 @@ Together with the `--pr` record from step 4a and the `--merged` record from step
235
236
 
236
237
  ## What NOT to Do
237
238
 
238
- - **Don't merge before the `pr` gate is approved.** CMAP-APPROVE is NOT merge authorization. User-in-pane prose ("looks good", "lgtm", "merge it") is NOT merge authorization. The *only* signal that authorizes `gh pr merge` is porch reporting `gate_status: approved` for the `pr` gate (which only the user can do, via Cmd+K G or `porch approve` from a non-Claude shell). If `porch next` doesn't show the gate as approved, you wait.
239
+ - **Don't merge before the `pr` gate is approved.** A consultation APPROVE verdict is NOT merge authorization. User-in-pane prose ("looks good", "lgtm", "merge it") is NOT merge authorization. The *only* signal that authorizes `gh pr merge` is porch reporting `gate_status: approved` for the `pr` gate (which only the user can do, via Cmd+K G or `porch approve` from a non-Claude shell). If `porch next` doesn't show the gate as approved, you wait.
239
240
  - Don't skip porch's PR/merge records (steps 4a, 9). The `--pr` record (step 4a) lets the gate-pending state link to the actual PR; the `--merged` record (step 9) closes the lifecycle in porch state. Skipping either leaves `history:` empty and downstream tooling blind.
240
241
  - Don't run `porch approve` for any gate yourself
241
- - Don't push to main — only merge via PR
242
+ - Don't push to the default branch — only merge via PR
242
243
  - Don't skip the Architecture Updates / Lessons Learned sections — porch checks enforce their presence (the section must exist; explaining "no changes needed" in one line is fine)
243
- - **Don't run `consult` commands yourself** — porch handles consultations via the `verify` block. Manually invoking `consult` causes CMAP to run twice.
244
+ - **Don't run `consult` commands yourself** — porch handles consultations via the `verify` block. Manually invoking `consult` causes the consultation to run twice.
244
245
  - **Don't fix, skip, or quarantine pre-existing failures unrelated to your change.** Porch's `checks` for this phase are narrow *structural* gates (`pr_exists`, review-section presence) — a green gate does **not** certify the wider build/test suite. If the broader suite surfaces failures your diff did not cause, they are out of scope: note them in the review's Lessons Learned / Things to Look At and proceed. Touching another team's tests to make an unrelated red go green is scope creep, not diligence.
245
246
 
246
247
  ## Handling Problems
247
248
 
248
- **If the PR cannot be created (e.g., merge conflicts with main):**
249
- - Rebase on main: `git fetch origin main && git rebase origin/main`
249
+ **If the PR cannot be created (e.g., merge conflicts with the default branch):**
250
+ - Rebase on the default branch:
251
+ ```bash
252
+ DEFAULT_BRANCH=$(git symbolic-ref --short refs/remotes/origin/HEAD 2>/dev/null | sed 's|^origin/||')
253
+ DEFAULT_BRANCH=${DEFAULT_BRANCH:-main}
254
+ git fetch origin "$DEFAULT_BRANCH" && git rebase "origin/$DEFAULT_BRANCH"
255
+ ```
250
256
  - Resolve conflicts (do NOT use destructive shortcuts)
251
257
  - Force-push with lease: `git push --force-with-lease`
252
258
  - Re-run `gh pr create`
253
259
 
254
- **If porch's CMAP consults fail (e.g., model unavailable):**
260
+ **If porch's consultation fails (e.g., model unavailable):**
255
261
  - `porch done` will report the failure. Inspect `codev/projects/{{project_id}}-*/{{project_id}}-<model>.txt` for the failure details.
256
262
  - Re-run `porch done {{project_id}}` once — porch will retry the consult.
257
263
  - If the model is persistently unavailable, notify the architect and ask whether to proceed without that model's verdict. They may direct you to skip via a manual override.
@@ -70,7 +70,7 @@
70
70
  {
71
71
  "id": "review",
72
72
  "name": "Review",
73
- "description": "Write retrospective (arch + lessons), push, open PR with review as body, run CMAP, then wait at pr gate while the human merges on GitHub",
73
+ "description": "Write retrospective (arch + lessons), push, open PR with review as body, run 3-way consultation, then wait at pr gate while the human merges on GitHub",
74
74
  "type": "build_verify",
75
75
  "build": {
76
76
  "prompt": "review.md",
@@ -101,7 +101,7 @@ The builder:
101
101
  2. Updates `codev/resources/arch.md` and/or `codev/resources/lessons-learned.md` if real changes need recording. If not, the review file's sections state "no changes needed" with a one-line explanation (the porch `checks` block enforces section presence, not content).
102
102
  3. Commits the review file (and arch / lessons updates if any) and pushes
103
103
  4. Opens a PR with `gh pr create`; PR body is the review file content + `Fixes #<N>`. Records the PR with `porch done <id> --pr <M> --branch <name>`.
104
- 5. Runs `porch done <id>` — porch's `verify` block runs CMAP-2 (Gemini + Codex, type=impl) as a **single advisory pass** (`max_iterations: 1`); CMAP outputs land in `codev/projects/<id>-*/`. There is no iterate-until-APPROVE loop: whatever the verdicts, porch records them and advances to the `pr` gate. A `REQUEST_CHANGES` is not auto-re-reviewed — the builder addresses or rebuts it, adds a regression test if it's a real defect, and escalates it in the architect notification so the human verifies it at the `pr` gate. Outcomes are not auto-appended to the PR body; reviewers with the worktree read them from the projects dir.
104
+ 5. Runs `porch done <id>` — porch's `verify` block runs 3-way consultation (Gemini, Codex, Claude; type=impl) as a **single advisory pass** (`max_iterations: 1`); consultation outputs land in `codev/projects/<id>-*/`. There is no iterate-until-APPROVE loop: whatever the verdicts, porch records them and advances to the `pr` gate. A `REQUEST_CHANGES` is not auto-re-reviewed — the builder addresses or rebuts it, adds a regression test if it's a real defect, and escalates it in the architect notification so the human verifies it at the `pr` gate. Outcomes are not auto-appended to the PR body; reviewers with the worktree read them from the projects dir.
105
105
  6. The `pr` gate fires (pending) regardless of verdict. Builder notifies the architect once — leading with any `REQUEST_CHANGES` and its disposition (since PIR will not re-review it) rather than burying it in a flat status line.
106
106
  7. Builder waits at the `pr` gate. The human reviews the PR on GitHub, then approves the `pr` gate (Cmd+K G or `porch approve <id> pr --a-human-explicitly-approved-this`). Porch wakes the builder.
107
107
  8. Builder verifies the gate is genuinely approved via `porch next` (defensive — typed prose can't trigger this branch, only real porch state does), then runs `gh pr merge --merge`, records via `porch done --merged <M>`, and sends the cleanup-ready notification. Protocol complete (`next: null`).
@@ -152,13 +152,11 @@ Without `worktree.devCommand`, `afx dev` won't work and the `dev-approval` gate
152
152
 
153
153
  - **plan**: human-only review. No AI consultation.
154
154
  - **implement**: no AI consult — the human at the `dev-approval` gate is the sole reviewer of the running code.
155
- - **review**: CMAP-2 (Gemini + Codex, type=impl) after the PR is opened, as a **single advisory pass** (`max_iterations: 1`). Same pattern as BUGFIX / AIR's PR-creation consult.
155
+ - **review**: 3-way consultation (Gemini, Codex, Claude; type=impl) after the PR is opened, as a **single advisory pass** (`max_iterations: 1`). Same consult type (`impl`) as BUGFIX / AIR's PR-creation consult.
156
156
 
157
- CMAP at the PR is a single pass — there is **no iterate-until-APPROVE loop**. A `REQUEST_CHANGES` does not block or re-trigger CMAP; the builder addresses or rebuts it and escalates it to the human at the `pr` gate, who is the sole remaining reviewer of any resulting fix (CMAP does not re-check it).
157
+ The consultation at the PR is a single pass — there is **no iterate-until-APPROVE loop**. A `REQUEST_CHANGES` does not block or re-trigger it; the builder addresses or rebuts it and escalates it to the human at the `pr` gate, who is the sole remaining reviewer of any resulting fix (the consultation does not re-check it).
158
158
 
159
- Net: PIR runs **two model calls per protocol run**, matching its BUGFIX/AIR peers — its distinguishing features are the two human gates (`plan-approval`, `dev-approval`), not AI-consult density.
160
-
161
- **The 2-model footprint is a design invariant.** porch's model precedence is *config > protocol* (`porch.consultation.models` in `.codev/config.json` overrides a protocol's declared `verify.models`). A project-wide setting tuned for SPIR (gemini + codex + claude) will silently inflate PIR to a 3-model pass, breaking the BUGFIX/AIR-parity cost story. To keep PIR at CMAP-2, leave `porch.consultation.models` unset or scope it per-protocol.
159
+ Net: PIR's distinguishing features are the two human gates (`plan-approval`, `dev-approval`), not AI-consult density.
162
160
 
163
161
  To disable consultation entirely, say "without multi-agent consultation" when starting work.
164
162
 
@@ -74,11 +74,11 @@ The architect MAY request a PR at any point — for spec review, mid-implementat
74
74
  Your worktree is persistent — it survives across PR merges. When the architect asks for sequential PRs (e.g., to slice a large spec into shippable pieces), use this loop:
75
75
 
76
76
  1. Cut a branch, open a PR, wait for merge
77
- 2. After merge: `git fetch origin main && git checkout -b <next-branch> origin/main`
77
+ 2. After merge: `git fetch origin <integration-branch> && git checkout -b <next-branch> origin/<integration-branch>` — where `<integration-branch>` is the branch the architect targets PRs at (usually `main`; check the open PR's `baseRefName` if unsure)
78
78
  3. Continue to the next slice, open another PR
79
79
  4. Repeat
80
80
 
81
- **Important**: Do NOT run `git checkout main` — git worktrees cannot check out a branch that's checked out elsewhere. Always branch off `origin/main` via fetch.
81
+ **Important**: Do NOT run `git checkout <integration-branch>` — git worktrees cannot check out a branch that's checked out elsewhere. Always branch off `origin/<integration-branch>` via fetch.
82
82
 
83
83
  Record PRs in status.yaml: `porch done {{project_id}} --pr <N> --branch <name>`
84
84
  Record merges: `porch done {{project_id}} --merged <N>`
@@ -86,7 +86,7 @@ Record merges: `porch done {{project_id}} --merged <N>`
86
86
  ## Verify Phase
87
87
 
88
88
  After the final PR merges, the project enters the **verify** phase. You stay alive through verify:
89
- 1. Pull main into your worktree
89
+ 1. Pull the integration branch into your worktree
90
90
  2. Run `porch done {{project_id}}` to signal verification is ready
91
91
  3. The architect approves `verify-approval` when satisfied
92
92
 
@@ -28,10 +28,14 @@ You are performing a final self-check during the Review phase. The builder has c
28
28
  - Are any new APIs documented?
29
29
 
30
30
  5. **PR Readiness**
31
- - Is the branch up to date with main?
31
+ - Is the branch up to date with its base (the integration branch the PR targets)?
32
32
  - Are commits atomic and well-described?
33
33
  - Is the change diff reasonable in size?
34
34
 
35
+ ## Scope
36
+
37
+ - **DO NOT** flag the syntax of `git diff` examples that appear in review-file prose (e.g., `git diff ci..HEAD` inside a "Files Changed" caption or "How to Test Locally" section). Quoted diff syntax is documentation, not a command. Apply two-dot/three-dot scrutiny only to diffs you compute yourself.
38
+
35
39
  ## Verdict Format
36
40
 
37
41
  After your review, provide your verdict in exactly this format:
@@ -140,6 +140,27 @@ porch status # (strict mode) Your project status
140
140
  afx status # All builders
141
141
  ```
142
142
 
143
+ ## Thread file
144
+
145
+ You maintain a free-text markdown log at `codev/state/<builder-id>_thread.md` (relative to your worktree). This is the cohort's collective situational-awareness surface — architects and sibling builders can read it via plain file I/O.
146
+
147
+ **Path resolution**: `<builder-id>` is the basename of your worktree path. Resolve it once with `basename "$(pwd)"`. Example: if your worktree is `.builders/spir-823/`, the path is `codev/state/spir-823_thread.md`.
148
+
149
+ **Directory creation**: `codev/state/` likely doesn't exist when you start (it's greenfield). Your first write creates it — the Write tool's `mkdir -p` semantics handle this transparently. No need to pre-create the directory.
150
+
151
+ **What to write**: phase transitions, decisions, blockers, anything worth recording for the cohort. Trust your own judgement about what's useful. There is no required schema, no required sections, no timestamp format. The thread is yours.
152
+
153
+ **When to write**: at phase boundaries and at any other moment you think a future reader would want to know what happened. Don't over-engineer cadence — append when there's something to say.
154
+
155
+ **Discovery**:
156
+ - **In-flight** (while you're active): your thread lives in your worktree at `.builders/<builder-id>/codev/state/<builder-id>_thread.md` (from the main workspace root). Architects read it with `cat .builders/<id>/codev/state/<id>_thread.md`; they discover threads with `ls .builders/*/codev/state/*.md`.
157
+ - **Sibling builders**: read each other's threads via `cat ../<sibling-id>/codev/state/<sibling-id>_thread.md` from your own worktree (the parent `.builders/` directory is shared between all builders in the workspace).
158
+ - **Post-merge**: after your PR merges, your thread lands in `codev/state/` on `main` (parallel to `codev/reviews/`) and becomes part of the historical review record.
159
+
160
+ **Commit/retention rule**: **the default disposition is COMMIT.** Stage and commit your thread file as part of your PR. The rare exception — when your thread turned out to be noise rather than useful narrative — is an explicit decision to strip it before PR (via gitignore for the PR or by not staging the file). Silently leaving the thread uncommitted by accident is a bug, not an exercise of the exception. The cohort's situational-awareness goal depends on threads surviving to `main`.
161
+
162
+ **Scope reminder**: this is for the cohort's situational awareness, not porch's tracking. Porch does not read this file. There are no hooks, no validation, no enforcement.
163
+
143
164
  ## Notifications
144
165
 
145
166
  **ALWAYS notify the architect** via `afx send` at these key moments:
@@ -85,6 +85,26 @@ For complete reference, see `codev/resources/commands/`:
85
85
  - `codev/resources/commands/agent-farm.md` - Agent Farm commands
86
86
  - `codev/resources/commands/consult.md` - Consultation commands
87
87
 
88
+ ## Inter-agent messaging
89
+
90
+ Agents within a workspace communicate through `afx send`. Four addressing forms are supported:
91
+
92
+ | Form | Meaning | Allowed from |
93
+ |---|---|---|
94
+ | `afx send <builder-id> "msg"` | Send to a specific builder (e.g. `afx send 0042 "..."`). | Any sender. |
95
+ | `afx send architect "msg"` | From a builder: routes to the spawning architect via affinity. From an architect (or any non-builder sender): routes to the architect named `main` if present, else the first registered architect. | Any sender. |
96
+ | `afx send architect:<name> "msg"` | Explicit per-architect addressing. **Architects (including `main`)**: open address grammar — any architect can address any other architect (sibling-architect messaging). **Builders**: allowed ONLY when `<name>` matches the builder's own spawning architect; mismatches are rejected by Tower's spoofing check. From a builder, this is an explicit form of the affinity routing, NOT an override. | Any sender (with the spoofing constraint above for builders). |
97
+ | `afx send <workspace>:architect "msg"` | Cross-workspace addressing (e.g. `afx send marketmaker:architect "..."`). | Any sender. |
98
+
99
+ **Sibling-architect messaging**: when a workspace hosts more than one architect (added via `afx workspace add-architect --name <name>`), sibling architects message each other via the `architect:<name>` form. Example: `main` running `afx send architect:ob-refine "PR-iter-2 feedback ready"` lands on the `ob-refine` architect's terminal. This works because sender = architect bypasses the spoofing check.
100
+
101
+ **Builder spoofing-check**: a builder may only address its own spawning architect via `architect:<name>`. The spoofing check is enforced by Tower's message router; attempts to address a different architect from a builder are rejected.
102
+
103
+ **Discovering active agents**:
104
+
105
+ - `afx status` lists all architects alongside builders, with names, terminal IDs, and PIDs where available.
106
+ - Each active builder maintains a free-text narrative log at `codev/state/<builder-id>_thread.md` (relative to its worktree). **In-flight discovery**: `ls .builders/*/codev/state/*.md` and `cat .builders/<id>/codev/state/<id>_thread.md`. **Post-merge discovery**: after a builder's PR merges, its thread lands in `codev/state/` on `main` — list with `ls codev/state/` and read with `cat codev/state/<builder-id>_thread.md` from the main checkout.
107
+
88
108
  ## Configuration
89
109
 
90
110
  Agent Farm is configured via `.codev/config.json` at the project root. Created during `codev init` or `codev adopt`. Override via CLI flags: `--architect-cmd`, `--builder-cmd`, `--shell-cmd`.
@@ -83,6 +83,26 @@ For complete reference, see `codev/resources/commands/`:
83
83
  - `codev/resources/commands/agent-farm.md` - Agent Farm commands
84
84
  - `codev/resources/commands/consult.md` - Consultation commands
85
85
 
86
+ ## Inter-agent messaging
87
+
88
+ Agents within a workspace communicate through `afx send`. Four addressing forms are supported:
89
+
90
+ | Form | Meaning | Allowed from |
91
+ |---|---|---|
92
+ | `afx send <builder-id> "msg"` | Send to a specific builder (e.g. `afx send 0042 "..."`). | Any sender. |
93
+ | `afx send architect "msg"` | From a builder: routes to the spawning architect via affinity. From an architect (or any non-builder sender): routes to the architect named `main` if present, else the first registered architect. | Any sender. |
94
+ | `afx send architect:<name> "msg"` | Explicit per-architect addressing. **Architects (including `main`)**: open address grammar — any architect can address any other architect (sibling-architect messaging). **Builders**: allowed ONLY when `<name>` matches the builder's own spawning architect; mismatches are rejected by Tower's spoofing check. From a builder, this is an explicit form of the affinity routing, NOT an override. | Any sender (with the spoofing constraint above for builders). |
95
+ | `afx send <workspace>:architect "msg"` | Cross-workspace addressing (e.g. `afx send marketmaker:architect "..."`). | Any sender. |
96
+
97
+ **Sibling-architect messaging**: when a workspace hosts more than one architect (added via `afx workspace add-architect --name <name>`), sibling architects message each other via the `architect:<name>` form. Example: `main` running `afx send architect:ob-refine "PR-iter-2 feedback ready"` lands on the `ob-refine` architect's terminal. This works because sender = architect bypasses the spoofing check.
98
+
99
+ **Builder spoofing-check**: a builder may only address its own spawning architect via `architect:<name>`. The spoofing check is enforced by Tower's message router; attempts to address a different architect from a builder are rejected.
100
+
101
+ **Discovering active agents**:
102
+
103
+ - `afx status` lists all architects alongside builders, with names, terminal IDs, and PIDs where available.
104
+ - Each active builder maintains a free-text narrative log at `codev/state/<builder-id>_thread.md` (relative to its worktree). **In-flight discovery**: `ls .builders/*/codev/state/*.md` and `cat .builders/<id>/codev/state/<id>_thread.md`. **Post-merge discovery**: after a builder's PR merges, its thread lands in `codev/state/` on `main` — list with `ls codev/state/` and read with `cat codev/state/<builder-id>_thread.md` from the main checkout.
105
+
86
106
  ## Configuration
87
107
 
88
108
  Agent Farm is configured via `.codev/config.json` at the project root. Created during `codev init` or `codev adopt`. Override via CLI flags: `--architect-cmd`, `--builder-cmd`, `--shell-cmd`.