@tyroneross/build-loop 0.34.0 → 0.36.0

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 (155) hide show
  1. package/.agents/plugins/marketplace.json +1 -1
  2. package/.claude-plugin/marketplace.json +3 -3
  3. package/.claude-plugin/plugin.json +2 -2
  4. package/.codex-plugin/plugin.json +1 -1
  5. package/AGENTS.md +71 -18
  6. package/README.md +208 -299
  7. package/agents/advisor.md +2 -0
  8. package/agents/alignment-checker.md +2 -0
  9. package/agents/api-assessor.md +3 -1
  10. package/agents/architecture-scout.md +2 -0
  11. package/agents/assessment-orchestrator.md +2 -0
  12. package/agents/build-orchestrator.md +13 -8
  13. package/agents/database-assessor.md +107 -3
  14. package/agents/design-contract-specialist.md +2 -0
  15. package/agents/fact-checker.md +2 -0
  16. package/agents/fix-critique.md +26 -5
  17. package/agents/frontend-assessor.md +3 -1
  18. package/agents/implementer.md +2 -0
  19. package/agents/independent-auditor.md +2 -0
  20. package/agents/mock-scanner.md +2 -0
  21. package/agents/optimize-runner.md +2 -0
  22. package/agents/overfitting-reviewer.md +2 -0
  23. package/agents/performance-assessor.md +3 -1
  24. package/agents/plan-critic.md +5 -2
  25. package/agents/promotion-reviewer.md +2 -0
  26. package/agents/recurring-pattern-detector.md +4 -1
  27. package/agents/retrospective-synthesizer.md +14 -0
  28. package/agents/root-cause-investigator.md +39 -2
  29. package/agents/scope-auditor.md +2 -0
  30. package/agents/security-reviewer.md +3 -0
  31. package/agents/self-improvement-architect.md +2 -0
  32. package/agents/synthesis-critic.md +2 -0
  33. package/agents/transcript-pattern-miner.md +2 -0
  34. package/agents/ui-validator.md +2 -0
  35. package/assets/build-loop-plugin-icon.png +0 -0
  36. package/bin/build-loop-install.js +234 -0
  37. package/commands/run.md +1 -1
  38. package/hooks/git/pre-commit +40 -0
  39. package/hooks/git/pre-push +35 -10
  40. package/hooks/hooks.json +42 -5
  41. package/hooks/pre-edit-architecture.sh +2 -2
  42. package/hooks/route-guard.sh +15 -0
  43. package/hooks/route_guard.py +221 -0
  44. package/hooks/session-start-extensions.sh +10 -0
  45. package/hooks/session-start-git-hooks.sh +6 -1
  46. package/hooks/session-start-rally-point.sh +23 -1
  47. package/hooks/test_session_start_rally_version.sh +123 -0
  48. package/package.json +7 -2
  49. package/plugin-artifacts/codex/.codex-plugin/plugin.json +1 -1
  50. package/plugin-artifacts/codex/AGENTS.md +77 -16
  51. package/plugin-artifacts/codex/README.md +208 -299
  52. package/plugin-artifacts/codex/assets/build-loop-plugin-icon.png +0 -0
  53. package/plugin-artifacts/codex/references/agent-role-taxonomy.md +34 -0
  54. package/plugin-artifacts/codex/references/backlog-system.md +285 -0
  55. package/plugin-artifacts/codex/references/capability-routing.md +49 -0
  56. package/plugin-artifacts/codex/references/coordination-file-template.md +2 -2
  57. package/plugin-artifacts/codex/references/coordination-rules.md +275 -6
  58. package/plugin-artifacts/codex/references/memory-systems.md +25 -2
  59. package/plugin-artifacts/codex/references/memory.md +16 -0
  60. package/plugin-artifacts/codex/references/model-tier-mapping.md +45 -6
  61. package/plugin-artifacts/codex/references/phase-1-assess.md +19 -1
  62. package/plugin-artifacts/codex/references/phase-2-plan.md +10 -1
  63. package/plugin-artifacts/codex/references/phase-3-execute.md +5 -3
  64. package/plugin-artifacts/codex/references/phase-4-review.md +22 -1
  65. package/plugin-artifacts/codex/references/phase-5-iterate.md +4 -3
  66. package/plugin-artifacts/codex/references/phase-6-learn.md +3 -1
  67. package/plugin-artifacts/codex/references/verify-dispatch.md +85 -0
  68. package/plugin-artifacts/codex/skills/build-loop/SKILL.md +19 -10
  69. package/plugin-artifacts/codex/skills/build-loop/fallbacks.md +1 -1
  70. package/plugin-artifacts/codex/skills/build-loop/references/capability-routing.md +49 -0
  71. package/plugin-artifacts/codex/skills/build-loop/references/experiment-results-template.md +101 -0
  72. package/plugin-artifacts/codex/skills/build-loop/references/memory.md +16 -0
  73. package/plugin-artifacts/codex/skills/build-loop/references/output-style.md +98 -5
  74. package/plugin-artifacts/codex/skills/build-loop/references/phase-1-assess.md +19 -1
  75. package/plugin-artifacts/codex/skills/build-loop/references/phase-2-plan.md +10 -1
  76. package/plugin-artifacts/codex/skills/build-loop/references/phase-3-execute.md +5 -3
  77. package/plugin-artifacts/codex/skills/build-loop/references/phase-4-review.md +22 -1
  78. package/plugin-artifacts/codex/skills/build-loop/references/phase-5-iterate.md +4 -3
  79. package/plugin-artifacts/codex/skills/build-loop/references/phase-6-learn.md +3 -1
  80. package/plugin-artifacts/codex/skills/build-loop/references/verify-dispatch.md +85 -0
  81. package/plugin-artifacts/codex/skills/build-loop/templates/codex-worker-prompt.md +4 -0
  82. package/scripts/build_codex_plugin_artifact.py +7 -0
  83. package/scripts/embed_backend.py +17 -13
  84. package/scripts/lessons_index/query.py +1 -1
  85. package/scripts/memory_graph/__init__.py +2 -2
  86. package/scripts/sync_navgator_lessons.py +4 -4
  87. package/skills/api-registry-bridge/SKILL.md +1 -1
  88. package/skills/auto-decision-capture/SKILL.md +4 -3
  89. package/skills/auto-finding-capture/SKILL.md +119 -0
  90. package/skills/build-loop/SKILL.md +19 -10
  91. package/skills/build-loop/fallbacks.md +1 -1
  92. package/skills/build-loop/references/capability-routing.md +49 -0
  93. package/skills/build-loop/references/experiment-results-template.md +101 -0
  94. package/skills/build-loop/references/memory.md +14 -0
  95. package/skills/build-loop/references/output-style.md +98 -5
  96. package/skills/build-loop/references/phase-1-assess.md +19 -1
  97. package/skills/build-loop/references/phase-2-plan.md +10 -1
  98. package/skills/build-loop/references/phase-3-execute.md +5 -3
  99. package/skills/build-loop/references/phase-4-review.md +20 -1
  100. package/skills/build-loop/references/phase-5-iterate.md +4 -3
  101. package/skills/build-loop/references/phase-6-learn.md +2 -0
  102. package/skills/build-loop/references/verify-dispatch.md +85 -0
  103. package/skills/build-loop/templates/codex-worker-prompt.md +4 -0
  104. package/skills/debug-loop/SKILL.md +4 -2
  105. package/skills/debugging-memory/SKILL.md +24 -12
  106. package/skills/{debugging/assess/SKILL.md → debugging-memory/references/assess.md} +6 -13
  107. package/skills/{debugging/memory/SKILL.md → debugging-memory/references/search.md} +10 -17
  108. package/skills/{debugging/store/SKILL.md → debugging-memory/references/store.md} +5 -13
  109. package/skills/debugging-memory/references/subagent-integration.md +3 -3
  110. package/skills/defenseclaw-bridge/SKILL.md +1 -1
  111. package/skills/{loop-builder → focused-loop-builder}/SKILL.md +6 -6
  112. package/skills/ibr-bridge/SKILL.md +1 -1
  113. package/skills/knowledge/SKILL.md +13 -2
  114. package/skills/{knowledge-review/SKILL.md → knowledge/references/review-mode.md} +8 -20
  115. package/skills/logging-tracer/SKILL.md +20 -4
  116. package/skills/model-bakeoff/SKILL.md +44 -0
  117. package/skills/model-tiering/SKILL.md +55 -20
  118. package/skills/optimize/SKILL.md +2 -2
  119. package/skills/prd-bridge/SKILL.md +1 -1
  120. package/skills/recursive-retrospective/SKILL.md +46 -0
  121. package/skills/recursive-retrospective/references/01-retrospective.md +136 -0
  122. package/skills/recursive-retrospective/references/02-learning-capture.md +72 -0
  123. package/skills/recursive-retrospective/references/03-judge.md +45 -0
  124. package/skills/research/SKILL.md +1 -1
  125. package/skills/root-cause-analysis/SKILL.md +42 -0
  126. package/skills/security-methodology/SKILL.md +10 -1
  127. package/skills/security-scan/SKILL.md +55 -0
  128. package/skills/spec-writing/SKILL.md +42 -1
  129. package/skills/sync-skills/SKILL.md +8 -7
  130. package/commands/assess.md +0 -41
  131. package/commands/compose-handoff.md +0 -113
  132. package/commands/debug.md +0 -20
  133. package/commands/debugger-detail.md +0 -34
  134. package/commands/debugger-scan.md +0 -15
  135. package/commands/debugger-status.md +0 -20
  136. package/commands/debugger.md +0 -32
  137. package/commands/optimize-run.md +0 -31
  138. package/commands/promote-experiment.md +0 -129
  139. package/commands/rally-point.md +0 -301
  140. package/commands/research-run.md +0 -22
  141. package/commands/review-knowledge.md +0 -16
  142. package/commands/self-review.md +0 -51
  143. package/commands/setup-memory.md +0 -32
  144. package/commands/start-prd.md +0 -57
  145. package/commands/test.md +0 -34
  146. package/commands/verify-plan.md +0 -39
  147. package/skills/debugging/debug-loop/SKILL.md +0 -231
  148. package/skills/logging-tracer-bridge/SKILL.md +0 -70
  149. /package/skills/{loop-builder → focused-loop-builder}/presets/active-project-evidence.yaml +0 -0
  150. /package/skills/{loop-builder → focused-loop-builder}/presets/generic-artifact-loop.yaml +0 -0
  151. /package/skills/{loop-builder → focused-loop-builder}/presets/presentation-audit.yaml +0 -0
  152. /package/skills/{loop-builder → focused-loop-builder}/presets/research-synthesis.yaml +0 -0
  153. /package/skills/{loop-builder → focused-loop-builder}/presets/source-ingestion-raw-data-audit.yaml +0 -0
  154. /package/skills/{loop-builder → focused-loop-builder}/references/spec-format.md +0 -0
  155. /package/skills/{loop-builder → focused-loop-builder}/scripts/loop_builder.py +0 -0
@@ -86,6 +86,40 @@ Every peer host/session must:
86
86
  - Use `heartbeat --task-ref` during long-running tasks so other sessions can
87
87
  distinguish "process alive" from "still on task".
88
88
 
89
+ ## Core vs Sub-Agent — the classification rule
90
+
91
+ External analyses tend to classify by model tier ("`model: fable` ⇒ core") or by
92
+ blocking power ("core agents halt the loop"). Both are wrong as definitions:
93
+
94
+ - **Core = produces a verdict some pipeline step is contingent on.** The
95
+ independent-auditor's `nay`, plan-verify's blocking findings, and
96
+ `judgment_gate`'s `fail` gate specific steps; that contingency is what makes
97
+ the role core. Most Frontier critics are advisory by charter
98
+ (synthesis-critic is WARN-only, alignment-checker never blocks) — high tier,
99
+ not core. "Can halt the loop" misclassifies: build-loop verdicts gate steps;
100
+ they never hard-halt the loop outside the defined stop conditions.
101
+ - **Tier follows role, never the reverse.** The role's responsibility row
102
+ (above) plus `references/model-tier-mapping.md` selects the tier. A future
103
+ re-tiering (e.g., a cheaper model clearing the Frontier contract) must not
104
+ reclassify an agent's authority.
105
+
106
+ ## Delegation depth is a security property
107
+
108
+ The no-sub-sub-agents rule (subagents never dispatch agents) is not just
109
+ context hygiene: it caps the delegation chain at depth 2
110
+ (orchestrator → worker). Enterprise NHI guidance flags 3–5-hop delegation
111
+ chains as the silent-privilege-escalation surface; build-loop designs that
112
+ class out structurally. Treat any proposal to let a subagent dispatch
113
+ (including "just this once" orchestration conveniences) as a security-surface
114
+ change → `triggers.riskSurfaceChange: true`, security-reviewer in scope.
115
+
116
+ The one sanctioned agent-initiated escalation is `status: blocked` +
117
+ `novel_decisions[]` (the C5 backstop) — build-loop's handoff *detection phase*.
118
+ A worker that detects out-of-scope work returns it for routing; it never
119
+ self-routes. Keep C5 healthy instead of adding peer-to-peer routing fabric;
120
+ recovery from failed handoffs likewise stays centralized in the orchestrator's
121
+ status-routing + stuck-cascade, never per-worker.
122
+
89
123
  ## When To Add A New Agent
90
124
 
91
125
  Add a new agent only when all are true:
@@ -0,0 +1,285 @@
1
+ <!-- SPDX-FileCopyrightText: 2025-2026 Tyrone Ross, Jr <46267523+tyroneross@users.noreply.github.com> | SPDX-License-Identifier: Apache-2.0 -->
2
+
3
+ # Backlog System — host-agnostic, multi-repo deferred-work tracker
4
+
5
+ A backlog is the durable list of wanted-but-not-now work for a repo: deferred
6
+ debt, blocked infra, known fixes, pending decisions. This system makes that list
7
+ **host-neutral** (any coding agent — Claude, Codex, or other — reads and writes
8
+ it the same way), **filesystem-first** (grep + frontmatter, no DB/vector/graph),
9
+ and **aggregatable** across all of one user's repos via their personal memory.
10
+
11
+ ## Why it is shaped this way
12
+
13
+ Five research-grounded principles drive the design (from the memory-architecture
14
+ guide; Letta filesystem-memory benchmark; "don't over-engineer"):
15
+
16
+ 1. **Canonical truth vs derived index.** The items in `items/` are the truth.
17
+ `INDEX.md` is a *generated, rebuildable* view — never hand-edited.
18
+ 2. **Metadata-rich items.** Each item carries provenance, evidence,
19
+ supersession links, and a TTL (`review_by`) so it can be audited and aged.
20
+ 3. **Filesystem-first retrieval.** Reading = `cat BACKLOG.md` → `INDEX.md`, then
21
+ `grep` over `items/*.md` frontmatter. No index server, no embeddings.
22
+ 4. **Lifecycle ops.** Formation (`new`) → consolidation (`sync` archives
23
+ done/dropped, flags stale) → retrieval (`list`, grep) → forgetting
24
+ (archive, never delete).
25
+ 5. **Governance Level 3.** Every write is logged, timestamped, attributable —
26
+ git history + `created`/`updated` stamps + archive-not-delete provide it.
27
+
28
+ ## Two scopes (do not conflate)
29
+
30
+ | Scope | Path | Lifetime | Shared? |
31
+ |---|---|---|---|
32
+ | **Per-repo backlog** | `<repo>/.build-loop/backlog/` | Travels with the repo; committed | Team-shareable (in the repo) |
33
+ | **Personal memory mirror** | `build-loop-memory/projects/<slug>/backlog/` | Per-user, aggregated across ALL the user's repos | Private to the user |
34
+
35
+ The sync is **one-way**: per-repo backlog → personal memory. The per-repo store
36
+ is the source of truth; the memory mirror is a cross-repo read view for the user
37
+ who downloaded build-loop.
38
+
39
+ ## Structure
40
+
41
+ ```
42
+ <repo>/
43
+ ├── BACKLOG.md # repo-root pointer → .build-loop/backlog/INDEX.md
44
+ └── .build-loop/backlog/
45
+ ├── README.md # what this dir is + how to use it
46
+ ├── .gitattributes # INDEX.md merge=ours (resolve by regeneration)
47
+ ├── INDEX.md # DERIVED — regenerated by `sync`; do not edit
48
+ ├── items/<ID>.md # CANONICAL truth — one file per item
49
+ └── archive/<ID>.md # done/dropped items (never deleted)
50
+ ```
51
+
52
+ `<ID>` = `<PROJSLUG>-<AREA>-<token>` — e.g. `ATOM-SEARCH-mt3k9p7q`. The prefix is
53
+ derived from the repo basename; the **token** is a coordination-free,
54
+ collision-resistant suffix: 8 Crockford-base32 digits of millisecond time
55
+ (so `ls items/` still roughly sorts by creation) followed by 5 digits of
56
+ `os.urandom` entropy (so the ID is unique across agents, machines, branches, and
57
+ clones with **no shared counter**). Lowercase throughout.
58
+
59
+ **Why not the old sequential `-NNN`?** A per-area zero-padded counter is a
60
+ single-writer assumption. Two agents in independent worktrees/clones (Claude on
61
+ branch A, Codex on branch B) each read their OWN highest-NNN and both minted the
62
+ SAME `...-001/002/003` for DIFFERENT items — on `git merge` the identical
63
+ filenames/IDs collided or silently lost an item. The token removes the shared
64
+ counter entirely. The readability trade-off (IDs gain a ~13-char token suffix
65
+ instead of `-001`) is paid back by `INDEX.md`, which is the human-ordered
66
+ navigation view; the items themselves are addressed by token.
67
+
68
+ **Legacy `-NNN` items still read.** Items minted before this change (and any
69
+ hand-authored `-NNN`) remain valid: the ID-shape regex accepts BOTH a token
70
+ suffix and a legacy `\d{3,}` suffix, and no parser assumes a numeric tail.
71
+ Existing IDs are never rewritten — only NEW items get tokens.
72
+
73
+ ## Item schema (frontmatter on every `items/<ID>.md`)
74
+
75
+ ```yaml
76
+ id: ATOM-SEARCH-001
77
+ title: <one line>
78
+ status: open # open | in-progress | blocked | deferred | done | dropped
79
+ priority: P2 # P0..P3
80
+ type: debt # feature | fix | debt | infra | decision | cleanup | research
81
+ area: search # free-ish tag; the grep + filter routing key
82
+ entities: [pg_trgm, keyword-leg]
83
+ gated: db-migration # none | prod-deploy | db-migration | infra | product-decision
84
+ provenance: { source: followup, ref: <path/commit/PR#/chat-date> }
85
+ evidence: [<commit/PR/retro/followup paths>]
86
+ supersedes: null
87
+ superseded_by: null
88
+ created: 2026-06-16
89
+ updated: 2026-06-16
90
+ review_by: 2026-07-16 # TTL — surfaced by `sync` when passed
91
+ owner: unassigned
92
+ ```
93
+
94
+ Body sections: `## Context`, `## Acceptance`, `## Notes`.
95
+
96
+ Dates are caller-stamped (`--today YYYY-MM-DD` or the `BACKLOG_TODAY` env var,
97
+ falling back to the system clock) so the tool runs in harnesses where the clock
98
+ is not callable.
99
+
100
+ ## Lifecycle / sync contract
101
+
102
+ `scripts/backlog.py sync --repo <path>` does three things, in order:
103
+
104
+ 1. **Consolidate.** Move every `status: done` / `status: dropped` item from
105
+ `items/` to `archive/`. Never deletes. Flags items whose `review_by` has
106
+ passed as stale. Warns about `.build-loop/{followup,issues,proposals}` files
107
+ not yet referenced by any item's `evidence`/`provenance.ref` (scattered work
108
+ not yet triaged into the backlog).
109
+ 2. **Regenerate INDEX.** Rebuild `INDEX.md` deterministically from the remaining
110
+ items' frontmatter — grouped status → area → priority, with a compact table,
111
+ a summary (active count, open P0/P1, stale count, gated count), and a stale
112
+ call-out. For a FIXED item set re-rendering is **byte-identical** (no
113
+ wall-clock in the body), so `sync` is safe to re-run and diff-clean. The INDEX
114
+ write is atomic (temp file + `os.replace`), so a concurrent `sync` by two
115
+ agents never leaves a torn file for a reader. **Duplicate-ID guard
116
+ (defense in depth):** if two items ever share an `id` (a bad merge, a
117
+ hand-edit), `sync` surfaces them LOUDLY in a `## ⚠ Duplicate IDs` section
118
+ (id, count, all titles, all paths) instead of silently rendering one — so a
119
+ collision that did happen is visible.
120
+ 3. **Mirror to personal memory.** Copy active item files (+ a mirror INDEX) into
121
+ `build-loop-memory/projects/<slug>/backlog/`. Each mirror file is written
122
+ atomically (temp file + `os.replace`), so a parallel session never observes a
123
+ half-written file; last-writer-wins (the per-repo backlog is the truth).
124
+ Best-effort: if the memory root is absent or unwritable, sync still succeeds
125
+ and reports `mirror.skipped`.
126
+
127
+ ### INDEX.md merge handling
128
+
129
+ `INDEX.md` is fully derived, so two agents that both regenerate it WILL conflict
130
+ on `git merge`. The scaffold (via `adopt` AND any backlog materialisation by
131
+ `new`/`sync`) drops a `.build-loop/backlog/.gitattributes` with:
132
+
133
+ ```gitattributes
134
+ INDEX.md merge=ours
135
+ ```
136
+
137
+ so git resolves the conflict by keeping one side instead of inserting conflict
138
+ markers. **On an `INDEX.md` conflict, run `backlog.py sync` — `items/` is the
139
+ truth and the INDEX regenerates deterministically.** Item files in `items/`
140
+ don't conflict once IDs are unique (token suffix → separate paths), so both
141
+ branches' new items survive a merge.
142
+
143
+ ## How ANY agent uses it (host-neutral)
144
+
145
+ **Read** (no tools required — just the filesystem):
146
+ 1. `cat <repo>/BACKLOG.md` → follow the pointer to `INDEX.md`.
147
+ 2. `cat <repo>/.build-loop/backlog/INDEX.md` for the grouped view.
148
+ 3. `grep -l 'area: search' <repo>/.build-loop/backlog/items/*.md` to find items
149
+ by any frontmatter field; read the matching item bodies.
150
+
151
+ **Write** (via the pure-stdlib CLI — works under bare `python3`, no host SDK):
152
+ ```bash
153
+ # create
154
+ python3 scripts/backlog.py new --repo <path> --area search --type debt \
155
+ --title "pg_trgm for keyword leg" --priority P1 --gated db-migration \
156
+ --provenance-source followup --provenance-ref .build-loop/followup/x.md \
157
+ --today 2026-06-16
158
+ # edit the item body / frontmatter by hand in items/<ID>.md
159
+ # then regenerate + mirror
160
+ python3 scripts/backlog.py sync --repo <path> --today 2026-06-16
161
+ # read
162
+ python3 scripts/backlog.py list --repo <path> --status open
163
+ ```
164
+
165
+ The CLI emits structured JSON (machine-readable) on `new`/`sync`; `list` prints
166
+ a text table (or JSON with `--json`). The host LLM reasons over the structured
167
+ data + the convention — it never calls a vendor API.
168
+
169
+ ## Relationship to existing build-loop surfaces
170
+
171
+ - `.build-loop/issues/` — current-run bugs (short-lived). A persistent issue is
172
+ triaged INTO the backlog (`new`), then the issue file is referenced as
173
+ `evidence`/`provenance.ref` so `sync` stops warning about it.
174
+ - `.build-loop/followup/` — iterate-cap overflow. Same triage path.
175
+ - `templates/backlog-item.md` + `build-loop-memory/projects/<slug>/backlog.md`
176
+ (the legacy single-table durable backlog) remain valid for build-loop's own
177
+ self-work tracking; this per-item system is the general, multi-repo surface
178
+ and writes its mirror to the `backlog/` *subdir* (no clobber of `backlog.md`).
179
+
180
+ ## Phase 1 Assess integration
181
+
182
+ `scripts/context_bootstrap.py` surfaces a compact backlog line at Phase 1 Assess
183
+ when `.build-loop/backlog/INDEX.md` exists: open P0/P1 count, past-`review_by`
184
+ stale count, and gated count. Cheap (reads the generated INDEX summary only) and
185
+ non-fatal when the file is absent.
186
+
187
+ It also surfaces a one-time **discoverability nudge** (`backlog_discoverability`)
188
+ when there's something to act on:
189
+
190
+ - **Adoptable** — the repo has scattered work in `.build-loop/{followup,issues}`
191
+ but no `INDEX.md` yet → *"Backlog available — run `backlog.py adopt
192
+ --dry-run --repo .`"*.
193
+ - **Won't travel** — `.build-loop/backlog/` exists but is gitignored → *"Backlog
194
+ won't travel — run `adopt --apply` to fix `.gitignore`"*.
195
+
196
+ Both are silent when there's nothing to surface, and neither ever raises.
197
+
198
+ ## Download & upgrade safety
199
+
200
+ This is the contract that makes the backlog safe to **download** with a fresh
201
+ build-loop and **upgrade** in place over an existing one. The guiding rule:
202
+ *every adoption/upgrade step is additive and reversible; nothing the user
203
+ already had is moved, deleted, or rewritten in a lossy way.*
204
+
205
+ **1. Additive / never-destructive.** Adoption never touches the existing work
206
+ surfaces. `.build-loop/followup/`, `.build-loop/issues/`, `.build-loop/proposals/`,
207
+ and the personal `build-loop-memory` store are read-only inputs to `adopt` — an
208
+ imported item *links* to its source (`provenance.ref` + `evidence[]` +
209
+ `imported_from`); the source file stays exactly where it was as the inbox /
210
+ provenance record. `sync` likewise only ever archives (`done`/`dropped` →
211
+ `archive/`) and regenerates the derived `INDEX.md`; it never deletes a live item.
212
+
213
+ **2. Lazy / opt-in scaffolding.** A repo gets backlog dirs and pointer files
214
+ *only* when the user runs `adopt` (or `new`). A downloaded build-loop does not
215
+ litter every repo with an empty `backlog/` on first run — the structure
216
+ materialises on demand. `adopt --dry-run` (the default) reports exactly what it
217
+ *would* create without writing anything, so the user previews before opting in.
218
+
219
+ **3. The `.gitignore` dependency — and how `adopt` fixes it.** `.build-loop/` is
220
+ gitignored by default (confirmed in both `build-loop` and `sample-app`). That is
221
+ correct for transient run state — but it means the backlog would **not commit
222
+ and therefore would not travel** with the repo (no team-sharing, lost on a fresh
223
+ clone). `adopt` detects this by inspecting `.gitignore` (pure text, no git call)
224
+ and, on `--apply`, appends un-ignore rules so the durable backlog escapes the
225
+ broad ignore:
226
+
227
+ ```gitignore
228
+ # build-loop backlog (added by `backlog.py adopt` — keep so the backlog travels)
229
+ !.build-loop/backlog/
230
+ !.build-loop/backlog/**
231
+ !BACKLOG.md
232
+ ```
233
+
234
+ It reports this loudly (`gitignore.was_ignored: true`, `added: [...]`) and is
235
+ idempotent — re-running never appends the block twice. If `.build-loop/` is not
236
+ ignored, `adopt` leaves `.gitignore` untouched.
237
+
238
+ **4. Idempotent, dry-run-first migration.** `adopt` defaults to a read-only
239
+ dry-run; `--apply` executes. Re-running `--apply` is a no-op: each imported item
240
+ records `imported_from: <source path>`, and a re-run reads that field across
241
+ `items/` **and** `archive/` and skips any source already imported. No duplicate
242
+ items, no churned `.gitignore`. Verified contract: `adopt --apply` twice → the
243
+ second run's diff (items + `.gitignore`) is empty.
244
+
245
+ **5. Schema-version tolerance (forward/back compatible).** Every item carries
246
+ `schema_version` (current = `1`). The reader (`read_item`) is deliberately
247
+ tolerant: it **defaults missing known fields** and **preserves unknown fields**.
248
+ An item written by an *older* build-loop (no `schema_version`) reads back with
249
+ defaults filled in; an item written by a *newer* build-loop (carrying fields
250
+ this version doesn't know) reads back without error and with those fields intact.
251
+ So a backlog written by one build-loop version always reads on another — neither
252
+ a downgrade nor an upgrade corrupts or rejects it. Bump `SCHEMA_VERSION` only for
253
+ a contract change a reader must actively know about; the tolerant reader absorbs
254
+ purely-additive field changes without a bump.
255
+
256
+ **6. `build-loop-memory` is the per-user cross-repo long-term store.** The
257
+ per-repo backlog travels *with the repo* (committed, team-shareable). `sync`
258
+ additionally mirrors active items one-way into
259
+ `build-loop-memory/projects/<slug>/backlog/` — the user's private, cross-repo
260
+ aggregate view. The mirror writes to the `backlog/` **subdir**, so it never
261
+ collides with the legacy single-table `backlog.md`, with `lessons/`, or with
262
+ `decisions/` in that project's memory lane. The mirror is additive: its only
263
+ delete path is pruning orphaned item mirrors (ID-shaped stems whose source item
264
+ was removed), and it never touches a hand-dropped note. If the memory root is
265
+ absent or unwritable, `sync` still succeeds and reports `mirror.skipped`.
266
+
267
+ **Concurrency note (multi-agent) — two distinct collision classes.**
268
+
269
+ 1. **Distributed (cross-worktree/clone/machine).** Independent checkouts share no
270
+ filesystem and no counter, so IDs must be collision-free *with zero
271
+ coordination*. The token suffix (time-ordered + `os.urandom`) provides exactly
272
+ that: two agents in separate worktrees minting in the same area produce
273
+ DISJOINT ID sets, so a `git merge` of their `items/` trees lands every item
274
+ with nothing clobbered. This is the bug the token scheme fixes — the retired
275
+ sequential counter collided here.
276
+ 2. **Same-filesystem concurrent processes.** N `new`/`adopt` processes on ONE
277
+ filesystem still race on the create. That is handled (kept from the prior fix)
278
+ by the `O_EXCL` atomic create: exactly one process can create a given path;
279
+ the rest re-mint a fresh token and retry, bounded. So 8 parallel `new` calls
280
+ in one area yield 8 distinct files, zero loss.
281
+
282
+ Together these make the backlog safe as a shared multi-agent work surface across
283
+ both separate checkouts AND concurrent processes — not just a single-writer file.
284
+ The INDEX and memory-mirror writes are atomic (temp + `os.replace`) so a reader
285
+ never sees a torn derived file.
@@ -25,6 +25,55 @@ Phase 1 runs `node ${CLAUDE_PLUGIN_ROOT}/skills/build-loop/detect-plugins.mjs` a
25
25
  | Modular systems pack | Phases 1-4 | Read `references/modular-systems-pack.md`; partition files/tasks MECE; prefer modular scalable boundaries unless an exception is documented |
26
26
  | Codex subagent adapter | Phase 3 (Execute, Codex only) | Read `references/codex-subagents.md`; use `templates/codex-worker-prompt.md` for authorized Codex workers |
27
27
 
28
+ ### Spec/Plan author router (intent-driven, ordered)
29
+
30
+ This router selects the single skill that AUTHORS the plan/spec/task graph for this run. It is a recommendation that DRIVES Phase 2 — recorded into `state.json.intent.spec_router`, consumed by Phase 2 Plan, never a hard block.
31
+
32
+ **Scope — author selection only.** `prd-bridge` is NOT in this router. It is mandatory in Phase 1 step 10 and only *consumes* an existing PRD (`docs/prd-*.md` → `state.json.prd`); it never authors. PRD-context is orthogonal to author selection — keep them separate.
33
+
34
+ **Governing rule**: select on intent + goal + context, not on a trigger-word match. A skill's word-overlap activation is not enough to call it (this is why `prd-builder` over-fired during build-loop runs). The router is the intent-side selection; it pairs with the activation-side guard (prd-builder's negative-trigger scope, which excludes in-flight changes and active build-loop runs).
35
+
36
+ Signals (all set during Phase 1 Assess):
37
+
38
+ - `run_active` — is a build-loop run active? (`true` for any `/build-loop:run` or build-orchestrator dispatch.)
39
+ - `plan_status` — `no-plan` | `plan-valid`, from the Phase 2 plan-exists gate (`.build-loop/plan.md` absent/empty + last `plan-verify` result).
40
+ - `intent_kind` — `PRD-author` | `build-plan` | `task-graph` | `none`, the LLM's read of what this run needs authored.
41
+ - `code_exists` — does the repo have substantive existing code? (Assess maps architecture: new/empty repo → false, existing repo → true.)
42
+ - `goal_scope` — `new-app` | `existing-app-change` | `in-build-task-breakdown`.
43
+
44
+ The rows are ORDERED — first match wins, so exactly one author is selected and no case matches two. The final default row makes the table exhaustive: every `(run_active, plan_status, intent_kind)` combination matches exactly one row, so nothing falls through.
45
+
46
+ | # | Match condition (first true wins) | route_type / action | Author selected | Why |
47
+ |---|---|---|---|---|
48
+ | 1 | `intent_kind == none` — nothing to author (Q&A, status, trivial, read-only, or advisory-context-only) | `noop` (call nothing) | — (`skill: null`) | no plan/spec/task graph needed |
49
+ | 2 | `run_active == false` AND greenfield PRD authoring is explicitly intended (new app with no code, OR `/start-prd` requested for a project) | `call` (or `recommend` outside an interactive session) | `prd-builder` | greenfield authoring + interactive intake; honors prd-builder's negative trigger — never fires inside an active run |
50
+ | 3 | `run_active == true` AND `plan_status == no-plan` | `call` | `build-loop:spec-writing` | author the in-build, non-interactive, gated plan for the orchestrator |
51
+ | 4 | `run_active == true` AND `plan_status == plan-valid` | `call` | `build-loop:writing-plans` (external) | turn the accepted plan into the task / dependency graph |
52
+ | 5 (default) | else (no earlier row matched) — the canonical case is `run_active == false` AND `intent_kind` is `build-plan` or `task-graph`: a direct, out-of-run invocation of plan authoring on an existing repo | `recommend` | `build-loop:spec-writing` | recommend, not auto-call: there is no active run to drive, so surface the author for the lead to run if it chooses |
53
+
54
+ The order is the contract: row 1 short-circuits before any author runs; row 2 is the only PRD author and is fenced off from active runs; rows 3 and 4 are mutually exclusive on `plan_status`; row 5 is the exhaustive `else` default that catches every remaining combination — its canonical case is an out-of-run `build-plan`/`task-graph` intent, but as the final row it also absorbs any residual (e.g. an out-of-run non-greenfield `PRD-author`) so no signal combination ever falls through. The table extends to any future author skill — add a row at the right precedence above the default, key it on the same signals, and the system still selects exactly one and records why.
55
+
56
+ `build-loop:writing-plans` (row 4) is the **external** `writing-plans` skill from the superpowers plugin — it is not vendored in this repo (`skills/writing-plans/SKILL.md` does not exist here). When it is absent, fall back to the inline "write a structured plan directly" path in the §"Core loop skills/assets" table above.
57
+
58
+ > Future refinement (do not over-build now): for monorepos, a `target_code_exists` signal (does the *target sub-path* already have code, vs the repo as a whole) would refine row 2's greenfield test. Out of scope until a monorepo case demands it.
59
+
60
+ **Phase 1 record (the consumable contract)**. Phase 1 writes the matched decision into `state.json.intent.spec_router` so a Codex lead (no `Skill()` auto-activation) can consume it deterministically:
61
+
62
+ ```json
63
+ {
64
+ "route_type": "author",
65
+ "action": "call" | "recommend" | "noop",
66
+ "skill": "build-loop:spec-writing" | "build-loop:writing-plans" | "prd-builder" | null,
67
+ "fallback": "<fallbacks.md section or inline guidance> | null",
68
+ "matched_row": 1 | 2 | 3 | 4 | 5,
69
+ "signals": { "run_active": true, "plan_status": "no-plan", "intent_kind": "build-plan", "code_exists": true, "goal_scope": "existing-app-change" }
70
+ }
71
+ ```
72
+
73
+ `action: "noop"` → `skill: null`, Phase 2 authors nothing from the router (terminal). `action: "recommend"` → `skill` carries the recommended author name (so the lead knows what to run if it chooses); Phase 2 surfaces the recommendation in the report and does NOT auto-call. `action: "call"` → `skill` is non-null and Phase 2 calls it. The three actions are distinct: `call` auto-invokes, `recommend` surfaces-only, `noop` skips.
74
+
75
+ **Phase 2 read (the load-bearing wire)**. Phase 2 Plan READS `state.json.intent.spec_router` and acts on `action`/`skill` — it does NOT independently re-decide which author to call. See `references/phase-2-plan.md` step 0.
76
+
28
77
  ### Phase quick reference
29
78
 
30
79
  | # | Phase | Purpose | Sub-steps / key actions |
@@ -67,7 +67,7 @@ Per-run amendments: {{ANY_RUN_SPECIFIC_OPERATING_AMENDMENTS_OR_NONE}}
67
67
 
68
68
  ## MECE Ownership Packets per Piece
69
69
 
70
- <!-- TEMPLATE NOTE: Repeat this block once per piece. Every write-handoff requires all six. Skip ONLY for pure-read handoffs. -->
70
+ <!-- TEMPLATE NOTE: Repeat this block once per piece. Every write-handoff requires all seven. Skip ONLY for pure-read handoffs. -->
71
71
 
72
72
  ### {{PIECE_ID}} — {{PIECE_TITLE}}
73
73
 
@@ -165,7 +165,7 @@ Before committing your filled-in coord file:
165
165
 
166
166
  1. Every `{{PLACEHOLDER}}` replaced with a real value.
167
167
  2. Every `<!-- TEMPLATE NOTE: ... -->` block deleted.
168
- 3. Every piece has a MECE packet (all six elements: owns / does-not-own / interface-contract / integration-checkpoint / allowed-tools / denied-tools).
168
+ 3. Every piece has a MECE packet (all seven elements: owns / does-not-own / interface-contract / integration-checkpoint / allowed-tools / denied-tools / acceptance-criteria).
169
169
  4. Every piece has an acceptance-criteria sub-section.
170
170
  5. Step-status table rows match piece IDs in MECE packets.
171
171
  6. Run `python3 scripts/coordination_status.py --workdir . --session-id <id> --coordination-file <this-file> --json` — should report `status: clear` initially.