@tyroneross/build-loop 0.30.3 → 0.35.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 (171) hide show
  1. package/.agents/plugins/marketplace.json +2 -2
  2. package/.claude-plugin/marketplace.json +4 -4
  3. package/.claude-plugin/plugin.json +1 -1
  4. package/.codex-plugin/plugin.json +1 -1
  5. package/AGENTS.md +11 -2
  6. package/README.md +8 -7
  7. package/agents/advisor.md +111 -0
  8. package/agents/alignment-checker.md +11 -0
  9. package/agents/assessment-orchestrator.md +1 -1
  10. package/agents/build-orchestrator.md +28 -33
  11. package/agents/fact-checker.md +1 -1
  12. package/agents/fix-critique.md +1 -1
  13. package/agents/independent-auditor.md +1 -1
  14. package/agents/overfitting-reviewer.md +1 -1
  15. package/agents/plan-critic.md +8 -6
  16. package/agents/promotion-reviewer.md +1 -1
  17. package/agents/retrospective-synthesizer.md +20 -3
  18. package/agents/scope-auditor.md +1 -1
  19. package/agents/security-reviewer.md +1 -1
  20. package/agents/self-improvement-architect.md +1 -1
  21. package/commands/{handoff.md → compose-handoff.md} +4 -4
  22. package/commands/{optimize.md → optimize-run.md} +1 -1
  23. package/commands/{agent-rally-point.md → rally-point.md} +3 -3
  24. package/commands/{research.md → research-run.md} +1 -1
  25. package/commands/setup-memory.md +32 -0
  26. package/commands/{plan-verify.md → verify-plan.md} +1 -1
  27. package/docs/agent-surface-policy.md +38 -20
  28. package/docs/memory-setup.md +19 -14
  29. package/hooks/_resolve_python.sh +28 -0
  30. package/hooks/closeout.sh +58 -0
  31. package/hooks/git/pre-push +69 -6
  32. package/hooks/hooks.json +34 -13
  33. package/hooks/post-push-closeout.sh +73 -0
  34. package/hooks/session-start-closeout.sh +69 -0
  35. package/hooks/session-start-memory.sh +27 -0
  36. package/hooks/session-start-plugin-heal.sh +33 -0
  37. package/hooks/test_closeout.sh +124 -0
  38. package/package.json +7 -4
  39. package/plugin-artifacts/codex/.codex-plugin/plugin.json +41 -0
  40. package/plugin-artifacts/codex/AGENTS.md +507 -0
  41. package/plugin-artifacts/codex/BUILD-ARTIFACT.md +5 -0
  42. package/plugin-artifacts/codex/LICENSE +202 -0
  43. package/plugin-artifacts/codex/README.md +404 -0
  44. package/plugin-artifacts/codex/docs/agent-surface-policy.md +63 -0
  45. package/plugin-artifacts/codex/references/advisor-dispatch-ladder.md +62 -0
  46. package/plugin-artifacts/codex/references/agent-role-taxonomy.md +135 -0
  47. package/plugin-artifacts/codex/references/autonomous-and-per-commit-modes.md +161 -0
  48. package/plugin-artifacts/codex/references/autonomy-config.md +231 -0
  49. package/plugin-artifacts/codex/references/capability-routing.md +182 -0
  50. package/plugin-artifacts/codex/references/codex-subagents.md +106 -0
  51. package/plugin-artifacts/codex/references/coordination-file-template.md +181 -0
  52. package/plugin-artifacts/codex/references/coordination-rules.md +283 -0
  53. package/plugin-artifacts/codex/references/dogfood-reload-checkpoint.md +112 -0
  54. package/plugin-artifacts/codex/references/halt-and-ask-protocol.md +102 -0
  55. package/plugin-artifacts/codex/references/implementer-envelope-schema.md +302 -0
  56. package/plugin-artifacts/codex/references/intent-capability-pack.md +257 -0
  57. package/plugin-artifacts/codex/references/intent-exploration-prompts.md +96 -0
  58. package/plugin-artifacts/codex/references/leadership.md +72 -0
  59. package/plugin-artifacts/codex/references/memory-systems.md +238 -0
  60. package/plugin-artifacts/codex/references/memory.md +299 -0
  61. package/plugin-artifacts/codex/references/model-tier-mapping.md +257 -0
  62. package/plugin-artifacts/codex/references/modular-systems-pack.md +96 -0
  63. package/plugin-artifacts/codex/references/phase-1-assess.md +231 -0
  64. package/plugin-artifacts/codex/references/phase-2-plan.md +78 -0
  65. package/plugin-artifacts/codex/references/phase-3-execute.md +49 -0
  66. package/plugin-artifacts/codex/references/phase-4-review.md +322 -0
  67. package/plugin-artifacts/codex/references/phase-5-iterate.md +71 -0
  68. package/plugin-artifacts/codex/references/phase-6-learn.md +56 -0
  69. package/plugin-artifacts/codex/references/recent-design-structures.md +274 -0
  70. package/plugin-artifacts/codex/references/research-trigger-policy.md +140 -0
  71. package/plugin-artifacts/codex/references/runtime-smoke-triggers.md +42 -0
  72. package/plugin-artifacts/codex/references/self-review.md +234 -0
  73. package/plugin-artifacts/codex/references/single-writer-commit-protocol.md +90 -0
  74. package/plugin-artifacts/codex/references/task-capture-policy.md +68 -0
  75. package/plugin-artifacts/codex/references/ui-io-contract.md +116 -0
  76. package/plugin-artifacts/codex/references/ui-spotcheck-protocol.md +65 -0
  77. package/plugin-artifacts/codex/skills/build-loop/SKILL.md +372 -0
  78. package/plugin-artifacts/codex/skills/build-loop/detect-plugins.mjs +82 -0
  79. package/plugin-artifacts/codex/skills/build-loop/eval-guide.md +65 -0
  80. package/plugin-artifacts/codex/skills/build-loop/fallbacks.md +549 -0
  81. package/plugin-artifacts/codex/skills/build-loop/phases/fact-check.md +42 -0
  82. package/plugin-artifacts/codex/skills/build-loop/phases/ui-validation.md +267 -0
  83. package/plugin-artifacts/codex/skills/build-loop/references/advisor-dispatch-ladder.md +62 -0
  84. package/plugin-artifacts/codex/skills/build-loop/references/apple-native-planning.md +439 -0
  85. package/plugin-artifacts/codex/skills/build-loop/references/autonomous-and-per-commit-modes.md +161 -0
  86. package/plugin-artifacts/codex/skills/build-loop/references/capability-routing.md +182 -0
  87. package/plugin-artifacts/codex/skills/build-loop/references/codex-subagents.md +106 -0
  88. package/plugin-artifacts/codex/skills/build-loop/references/coordination.md +161 -0
  89. package/plugin-artifacts/codex/skills/build-loop/references/correction-aware-capture.md +177 -0
  90. package/plugin-artifacts/codex/skills/build-loop/references/independent-auditor.md +72 -0
  91. package/plugin-artifacts/codex/skills/build-loop/references/intent-capability-pack.md +257 -0
  92. package/plugin-artifacts/codex/skills/build-loop/references/intent-exploration-prompts.md +96 -0
  93. package/plugin-artifacts/codex/skills/build-loop/references/leadership.md +72 -0
  94. package/plugin-artifacts/codex/skills/build-loop/references/memory.md +299 -0
  95. package/plugin-artifacts/codex/skills/build-loop/references/modular-systems-pack.md +96 -0
  96. package/plugin-artifacts/codex/skills/build-loop/references/output-style.md +129 -0
  97. package/plugin-artifacts/codex/skills/build-loop/references/pay-it-forward-arch.md +98 -0
  98. package/plugin-artifacts/codex/skills/build-loop/references/phase-1-assess.md +231 -0
  99. package/plugin-artifacts/codex/skills/build-loop/references/phase-2-plan.md +78 -0
  100. package/plugin-artifacts/codex/skills/build-loop/references/phase-3-execute.md +49 -0
  101. package/plugin-artifacts/codex/skills/build-loop/references/phase-4-review.md +322 -0
  102. package/plugin-artifacts/codex/skills/build-loop/references/phase-5-iterate.md +71 -0
  103. package/plugin-artifacts/codex/skills/build-loop/references/phase-6-learn.md +56 -0
  104. package/plugin-artifacts/codex/skills/build-loop/references/recent-design-structures.md +274 -0
  105. package/plugin-artifacts/codex/skills/build-loop/references/refactor-history/ASSESSMENT.md +85 -0
  106. package/plugin-artifacts/codex/skills/build-loop/references/refactor-history/STANDALONE_TEST_RUN.md +149 -0
  107. package/plugin-artifacts/codex/skills/build-loop/references/refactor-history/scenarios/01-simple-bugfix.md +32 -0
  108. package/plugin-artifacts/codex/skills/build-loop/references/refactor-history/scenarios/02-ui-build-with-iteration.md +48 -0
  109. package/plugin-artifacts/codex/skills/build-loop/references/refactor-history/scenarios/03-multi-failure-escalation.md +60 -0
  110. package/plugin-artifacts/codex/skills/build-loop/references/refactor-history/scenarios/04-ui-build-ibr-absent.md +51 -0
  111. package/plugin-artifacts/codex/skills/build-loop/references/refactor-history/scenarios/05-refactor-navgator-absent.md +71 -0
  112. package/plugin-artifacts/codex/skills/build-loop/references/refactor-history/scenarios/06-recurring-bug-debugger-absent.md +52 -0
  113. package/plugin-artifacts/codex/skills/build-loop/references/refactor-history/trace-comparison.md +202 -0
  114. package/plugin-artifacts/codex/skills/build-loop/references/self-recursive-dev.md +77 -0
  115. package/plugin-artifacts/codex/skills/build-loop/references/self-review.md +234 -0
  116. package/plugin-artifacts/codex/skills/build-loop/references/ui-io-contract.md +116 -0
  117. package/plugin-artifacts/codex/skills/build-loop/scanners/audit-design-rules.mjs +476 -0
  118. package/plugin-artifacts/codex/skills/build-loop/scanners/require-visual-evidence.mjs +239 -0
  119. package/plugin-artifacts/codex/skills/build-loop/templates/backlog-item.md +35 -0
  120. package/plugin-artifacts/codex/skills/build-loop/templates/codex-worker-prompt.md +100 -0
  121. package/plugin-artifacts/codex/skills/build-loop/templates/ui-subagent-prompt.md +179 -0
  122. package/plugin-artifacts/codex/skills/build-loop/templates/ux-fix-plan.md +40 -0
  123. package/scripts/_paths.py +59 -13
  124. package/scripts/build_codex_plugin_artifact.py +314 -0
  125. package/scripts/check_cache_sync.py +1 -1
  126. package/scripts/install_memory.py +11 -3
  127. package/scripts/prune_plugin_cache.py +225 -11
  128. package/scripts/sync_navgator_lessons.py +25 -0
  129. package/scripts/sync_plugin_cache.py +66 -36
  130. package/skills/agent-rally-point/SKILL.md +1 -1
  131. package/skills/agent-rally-watcher/SKILL.md +1 -1
  132. package/skills/build-loop/SKILL.md +11 -155
  133. package/skills/build-loop/references/advisor-dispatch-ladder.md +62 -0
  134. package/skills/build-loop/references/autonomous-and-per-commit-modes.md +161 -0
  135. package/skills/build-loop/references/capability-routing.md +4 -3
  136. package/skills/build-loop/references/codex-subagents.md +8 -0
  137. package/skills/build-loop/references/coordination.md +1 -1
  138. package/skills/build-loop/references/intent-capability-pack.md +88 -1
  139. package/skills/build-loop/references/memory.md +17 -2
  140. package/skills/build-loop/references/phase-1-assess.md +13 -0
  141. package/skills/build-loop/references/phase-2-plan.md +2 -1
  142. package/skills/build-loop/references/phase-3-execute.md +4 -2
  143. package/skills/build-loop/references/phase-4-review.md +12 -0
  144. package/skills/build-loop/references/phase-6-learn.md +1 -1
  145. package/skills/build-loop/references/self-review.md +4 -2
  146. package/skills/build-loop/templates/codex-worker-prompt.md +45 -34
  147. package/skills/handoff/SKILL.md +3 -3
  148. package/skills/loop-builder/SKILL.md +98 -0
  149. package/skills/loop-builder/presets/active-project-evidence.yaml +97 -0
  150. package/skills/loop-builder/presets/generic-artifact-loop.yaml +95 -0
  151. package/skills/loop-builder/presets/presentation-audit.yaml +96 -0
  152. package/skills/loop-builder/presets/research-synthesis.yaml +96 -0
  153. package/skills/loop-builder/presets/source-ingestion-raw-data-audit.yaml +96 -0
  154. package/skills/loop-builder/references/spec-format.md +80 -0
  155. package/skills/loop-builder/scripts/loop_builder.py +346 -0
  156. package/skills/model-tiering/SKILL.md +65 -40
  157. package/skills/optimize/SKILL.md +2 -2
  158. package/skills/plan-verify/SKILL.md +1 -1
  159. package/skills/plugin-builder/references/distribution.md +8 -0
  160. package/skills/research/SKILL.md +33 -6
  161. package/skills/runtime-parity-verification/SKILL.md +51 -0
  162. package/skills/spec-writing/SKILL.md +19 -0
  163. package/templates/memory/README.md +65 -0
  164. package/templates/memory/charter.md.template +46 -0
  165. package/templates/memory/manifest.json +24 -4
  166. package/codex-skills/debug-loop/SKILL.md +0 -18
  167. package/codex-skills/handoff/SKILL.md +0 -22
  168. package/codex-skills/knowledge/SKILL.md +0 -21
  169. package/codex-skills/optimize/SKILL.md +0 -18
  170. package/codex-skills/research/SKILL.md +0 -18
  171. /package/commands/{knowledge-review.md → review-knowledge.md} +0 -0
@@ -0,0 +1,182 @@
1
+ <!-- SPDX-FileCopyrightText: 2025-2026 Tyrone Ross, Jr <46267523+tyroneross@users.noreply.github.com> | SPDX-License-Identifier: Apache-2.0 -->
2
+
3
+ # Capability Routing (full protocol)
4
+
5
+ > Loaded from `skills/build-loop/SKILL.md` summary. Contains the full capability routing table, trigger conditions, and plugin/hook/skill/agent mandatory routing rules.
6
+
7
+ ## Capability Routing
8
+
9
+ Build-loop prefers repo-owned agents and bundled skills for core loop decisions. External plugins are accelerators only when explicitly requested or when a row below names them as secondary. Each capability has three tiers: **preferred** (build-loop-owned surface) → **secondary** (another installed plugin or skill that can partially cover) → **inline fallback** (guidance text from `fallbacks.md`, injected verbatim into subagent prompts).
10
+
11
+ Phase 1 runs `node ${CLAUDE_PLUGIN_ROOT}/skills/build-loop/detect-plugins.mjs` and writes the result to `.build-loop/state.json` under `availablePlugins`. All routing consults that object.
12
+
13
+ ### Core loop skills/assets (always check)
14
+
15
+ | Skill | Used In | Fallback |
16
+ |-------|---------|----------|
17
+ | `writing-plans` | Phase 2 (Plan) | Write a structured plan directly: goal, tasks with exact file paths, dependency order, test commands |
18
+ | `subagent-driven-development` | Phase 3 (Execute) | Dispatch parallel agents manually using the host's available delegation tool for independent file groups |
19
+ | `verification-before-completion` | Phase 4 sub-step G (Report) | Run all test/build/lint commands and confirm output before claiming completion. For app/UI changes this is NOT sufficient alone — also run the runtime UI⇄source-of-truth parity check (`runtime-parity-verification`); compile-green and a screenshot do not prove the running flow works |
20
+ | `runtime-parity-verification` | Phase 4 Review-B + Phase 5 Iterate (any `uiTarget != null` or user-visible flow) | Cross-check the rendered/queryable UI against the authoritative backend (DB/API/daemon/tool-state), screen-independently, and keep a validated per-repo smoke. Catches the "action does nothing / not showing / shows empty despite real data / stale projection" class. Drivers: web `ui-validator`; macOS `native-ax-driver` / IBR `scan_macos`; iOS `idb`; agent = tool-result vs rendered output. Reference smoke: easy-terminal `tools/smoke_launch.py` |
21
+ | `simplify` (slash: `/simplify`) | Phase 4 sub-step E (Simplify) | Self-review the diff: remove scaffolding, inline single-use helpers, delete dead branches |
22
+ | `complexity_detector.py` (accelerator, not a gate) | Phase 4 sub-step E (Simplify) | Diff-scoped stdlib-AST hotspot detector for changed Python; surfaces high-severity hotspots for a simpler rewrite, apply-vs-advise via existing Review-B + independent-auditor. Optional Python aid — the default Simplify pass reasons over the diff language-agnostically (see `phase-4-review.md` §"Sub-step E: Simplify") |
23
+ | `build-loop:self-improve` | Phase 6 (Learn) | Scan recent runs for recurring patterns, auto-draft experimental skills/agents with A/B tracking, notify user for keep/remove decisions |
24
+ | Intent capability pack | Phases 1-4 | Read `references/intent-capability-pack.md`; write `.build-loop/intent.md`; pass the intent packet to every subagent |
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
+ | Codex subagent adapter | Phase 3 (Execute, Codex only) | Read `references/codex-subagents.md`; use `templates/codex-worker-prompt.md` for authorized Codex workers |
27
+
28
+ ### Phase quick reference
29
+
30
+ | # | Phase | Purpose | Sub-steps / key actions |
31
+ |---|---|---|---|
32
+ | 1 | **Assess** | Understand state + define goal & criteria | detect tools, map architecture, load memory, write `intent.md` + `goal.md` |
33
+ | 2 | **Plan** | Break work, identify parallel-safe, optimize | writing-plans skill → dependency graph |
34
+ | 3 | **Execute** | Build per plan | parallel subagents, Sonnet default, Opus escalation |
35
+ | 4 | **Review** | Critic → Validate → Optimize (opt-in) → Fact-Check → Simplify → Auto-Resolve → Report | sub-steps A-G; B-D can route to Iterate; F drains non-destructive items via autonomy_gate; G runs only on final pass |
36
+ | 5 | **Iterate** | Fix Review failures, loop back to Review | max 5x; orchestrator stuck-iteration cascade (evidence-gap repair → memory re-check → parallel assess at 2 fails → causal-tree at 3 fails) |
37
+ | 6 | **Learn** | Cross-build pattern detection + experimental skill drafting | optional; requires `runs[] >= 3`; auto-promote opt-in |
38
+
39
+ ### Capability routing table
40
+
41
+ | Capability | Preferred | Secondary | Inline fallback section |
42
+ |---|---|---|---|
43
+ | Web UI build | `build-loop:ui-design` + `build-loop:design-contract-specialist` (`trigger_point: phase2-design-direction`) + `calm-precision` + `templates/ui-subagent-prompt.md` | `frontend-design:frontend-design` only when explicitly requested | `fallbacks.md#web-ui` |
44
+ | Web UI validation | `ui-validator` agent + `audit-design-rules.mjs` + browser/screenshot artifact | `showcase:capture` for visual evidence | `fallbacks.md#web-ui` |
45
+ | Orchestrated UI build | `build-loop:ui-design` → build-loop-owned design direction → implementer fan-out → ui-validator/design-contract reconciliation | explicit user-invoked design tool artifacts passed to `design-contract-specialist` | `fallbacks.md#web-ui` |
46
+ | Mobile UI build (`uiTarget: "mobile"` — iOS/watchOS sim) | `build-loop:ui-design` + `build-loop:design-contract-specialist` + `calm-precision` + `apple-dev` | — | `fallbacks.md#mobile-ui` + `fallbacks.md#apple-dev` |
47
+ | Mobile UI validation (iOS sim) | `xcrun simctl io booted screenshot` for static; `idb ui tap` for interaction | `showcase:capture` | `fallbacks.md#mobile-ui` |
48
+ | macOS desktop UI build (`uiTarget: "macos"`) | `build-loop:ui-design` + `build-loop:design-contract-specialist` + `calm-precision` + `apple-dev` | — | `fallbacks.md#mobile-ui` + `fallbacks.md#apple-dev` |
49
+ | macOS desktop UI validation | IBR `scan_macos` when `availablePlugins.ibr == true`; else `native-ax-driver` against the running `.app` (pid-anchored). NEVER `xcrun simctl` (no macOS simulator). NEVER `nm`/`strings` as substitute. | `showcase:capture` for screenshot evidence | `fallbacks.md#mobile-ui` |
50
+ | Design system tokens | `design-contract-specialist` reads project token/theme/component files and records the source in `.build-loop/app-contract/ui.md` | — | `fallbacks.md#design-tokens` (reads consumer project's token files — never hardcodes) |
51
+ | Recent design structures | `design-contract-specialist` reads `references/recent-design-structures.md` and selects by product/workflow/data fit | explicit design-tool artifacts passed as evidence | `fallbacks.md#web-ui` |
52
+ | Screenshot / visual evidence | `showcase:capture`, `showcase:record` | `screenshot` MCP tool | `fallbacks.md#screenshot` |
53
+ | Web content fetching (low LLM) | `scraper-app:web-scraper` SDK | — | `fallbacks.md#web-fetch` (flags LLM cost in report) |
54
+ | Deep debugging | `build-loop:debug-loop` + `build-loop:debugging-memory` native search/store | standalone Coding Debugger only when explicitly installed for cross-project memory | `fallbacks.md#debug` |
55
+ | Bug-pattern memory | `build-loop:debugging-memory` | — | `fallbacks.md#bug-memory` (greps `.build-loop/issues/` + `.bookmark/`) |
56
+ | Agent authoring | `agent-builder:agent-builder-anthropic` | `plugin-dev:agent-development` (if plugin work) | `fallbacks.md#agent-authoring` |
57
+ | DeepAgents / local-LLM agent work | `build-loop:building-with-deepagents` (SubAgent API, middleware stack, per-agent tool scoping, anti-patterns) | — | Read installed `deepagents` source: `python3 -c 'import deepagents, os; print(os.path.dirname(deepagents.__file__))'` then `graph.py` + `middleware/subagents.py` |
58
+ | Structured reports / handoffs | `pyramid-principle:pyramid-short-form` (Review-F reports), `pyramid-long-form` (design docs) | — | `fallbacks.md#structured-writing` (SCQA + MECE skeleton) |
59
+ | Hosted-IDE migration (Replit / Lovable / Bolt / v0) | `replit-migrate:migration-scan`, `migrate-web`, `migrate-ios`; MCP tools `migrate_scan`, `migrate_plan_web`, `migrate_plan_native`, `migrate_map_apis`, `migrate_map_models`, `migrate_check_progress` | — | `fallbacks.md#migration` (manual inventory + stack-translation) |
60
+ | Prompt authoring / review / audit (system prompts, agent prompts, eval judges) | `prompt-builder:prompt-builder` skill; slash commands `/prompt-builder:optimize`, `/score`, `/compare`, `/save`, `/list`. Calibrates to model tier (T1/T2/T3) and deployment (interactive, backend, rag_pipeline, agent, plugin, eval_judge, personal_mobile). Returns 6-Part-Stack prompt + 5-dim score + diagnosis + `[ASSUMED:]` tags + `TEMPERATURE_HINT` | `prompt-builder` (personal skill, same name, loaded via Skill tool) | `fallbacks.md#prompt` |
61
+ | iOS / watchOS / macOS dev + deploy | `apple-dev` personal skill (via `Skill("apple-dev")`) | `replit-migrate:migrate-ios` (when migrating *to* native) | `fallbacks.md#apple-dev` |
62
+ | Web deploy verification (Vercel) | Vercel MCP (`mcp.vercel.com` remote OAuth, only if user adds it to `.mcp.json`) | Vercel CLI via `scripts/verify_deploy.py` | `fallbacks.md#web-deploy-verify` |
63
+ | Strategic frame / PRD grounding (Assess + Review) | `build-loop:prd-bridge` — reads `docs/prd-*.md` frontmatter (`core_principles`, `load_when`) + Navigation Map + Section Index in Phase 1; verifies diff doesn't violate principles in Phase 5 Fact-Check; recommends `prd-builder` skill if no PRD exists. Falls back to grep on principle keywords if frontmatter parser unavailable. | `prd-builder` skill direct invocation | Phase 1 captures north-star + intent fresh into `intent.md` (existing fallback) |
64
+ | Architecture scan / impact trace (Assess + Review) | `build-loop:architecture-scan` (Assess refresh), `build-loop:architecture-impact` (blast-radius), `build-loop:architecture-rules` (Review violation check), `build-loop:architecture-dead` (orphan scan) — read `.navgator/architecture/` JSON; native skills sourced from NavGator with provenance and drift-detection via `build-loop:sync-skills` | `gator:*` commands if installed | Read component → edit → re-read downstream |
65
+ | Debugger memory-first gate (Review + Iterate) | `build-loop:debugging-memory` — verdict gate (`KNOWN_FIX` / `LIKELY_MATCH` / `WEAK_SIGNAL` / `NO_MATCH`) with strict direct-apply triple-gate (file + version + secondary signal) and Review-F outcome feedback. Orchestrator owns the when-to-fire policy (Review-B + every Iterate attempt) and routes to this skill. | `build-loop:debug-loop` direct (when memory says enter the loop or 3 same-criterion failures) | `fallbacks.md#debug` |
66
+ | Runtime visibility / observability (Assess + reactive Review/Iterate) | `build-loop:logging-tracer` — generates stack-appropriate structured logging / OTel with ephemeral-by-default policy (Mechanism A: `DEBUG_TRACE=1` runtime gate; Mechanism B: `git-stash` throwaway). Invoked reactively when an Iterate attempt flags `evidence_gap: true`. Orchestrator runs the passive Assess scan inline (no skill call needed) and only loads this skill when instrumentation is actually being added. | — | `fallbacks.md#logging-fallback` (inline Tier-1 zero-dep JSON logger per stack) |
67
+ | Self-improvement / recurring pattern detection (Phase 6 Learn) | `build-loop:self-improve` — runs after every build; detects recurring failures and manual interventions; drafts experimental skills/agents to `.build-loop/skills/experimental/`. Auto-promote to `.build-loop/skills/active/` requires opt-in (`autoPromote: true`) plus effective non-confounded sample ≥ 8; regressions and inconclusive results write proposals to `.build-loop/proposals/` for user confirmation — never auto-remove. Cross-project promotion via `/build-loop:promote-experiment <name>` | — | Manual review of `.build-loop/state.json.runs[]` |
68
+ | Context recovery after compaction | `bookmark:*` commands | — | Re-read last plan file in `.build-loop/` |
69
+ | Claude Code plugin authoring / review | `plugin-builder` (personal skill), `plugin-dev:*` family | `build-loop:plugin-hygiene-lessons.md` enforces manifest/hook/marketplace rules in Review-D | Read `plugin-hygiene-lessons.md` verbatim |
70
+
71
+ ### Sub-routers (set during Phase 1)
72
+
73
+ **UI target**: prefer the most specific match — order matters.
74
+
75
+ 1. **macOS desktop (`uiTarget: "macos"`, `platform: "apple"`)** — `*.xcodeproj` or `Package.swift` is present AND any of: (a) project has NO `ios/` directory AND has `Sources/` / `App/` with `*.swift`; (b) Xcode project's `SUPPORTED_PLATFORMS` / deployment target indicates macOS; (c) repo grep shows `import AppKit` or `import SwiftUI` paired with `WindowGroup`/`Window` (macOS scene types) and no `UIKit` import. macOS has no simulator; validation routes to `native-ax-driver` or IBR `scan_macos`, never to `xcrun simctl`.
76
+ 2. **iOS/watchOS mobile (`uiTarget: "mobile"`, `platform: "apple"`)** — `ios/` directory present, OR `*.xcodeproj`/`Package.swift` with `UIKit` import / `iOS` deployment target. Validation uses the iOS simulator screenshot path.
77
+ 3. **React Native mobile (`uiTarget: "mobile"`, `platform: "react-native"`)** — `app.json` (Expo) or `App.tsx` with `react-native` import.
78
+ 4. **Web (`uiTarget: "web"`, `platform: "web"`)** — fallback for everything else with a UI surface.
79
+
80
+ Tie-breaker: if signals are mixed (an Apple project with both `ios/` and a macOS target), set `uiTarget: "mobile"` and surface a one-line note in Assess; the build can override via `state.json.uiTarget` if the goal targets the macOS surface.
81
+
82
+ **Migration source**: if `.replit` / `replit.nix` present → `migrationSource: "replit"`. Lovable / Bolt / v0 export markers (e.g. `lovable.config`, `bolt.config`, `v0.dev` in comments) → corresponding source. `replit-migrate` skills generalize — load `migration-scan` for any of the above, override hints as needed.
83
+
84
+ **Apple deploy**: when `platform: "apple"` AND goal includes "deploy", "TestFlight", or "App Store" → Phase 7/8 invoke `apple-dev` deploy flow using ASC creds from your harness memory store (e.g. `~/.claude/projects/<project-slug>/memory/reference_asc_credentials.md`). Apply deployment policy first: TestFlight/App Store Connect upload/export defaults to `auto`; App Store production release/submission defaults to `confirm`.
85
+
86
+ **Web deploy verify**: fires when `.vercel/project.json` or `vercel.json` is present AND the build performed a push/deploy → Phase 4 Review-B invokes `scripts/verify_deploy.py` (preferred-tier upgrade: Vercel MCP only if the user has added it to `.mcp.json`). Infra failures return `skipped`, never block the build.
87
+
88
+ ## Trigger Conditions
89
+
90
+ Some capabilities should fire proactively based on goal phrasing or files touched. Phase 1 ASSESS sets these flags in `.build-loop/state.json.triggers`, and Phase 4 EXECUTE consults them before dispatching each subagent.
91
+
92
+ **pyramid-principle** (structured writing)
93
+
94
+ Fires whenever the build produces user-visible prose or professional writing. Even small text should follow pyramid structure, and the logical ordering principle applies to design flow too.
95
+
96
+ Trigger if any of:
97
+
98
+ - Task touches user-visible text inside the app: copy, microcopy, empty-state messages, error messages, onboarding flow, help content, tooltips, toasts, form labels, email templates, notification text.
99
+ - Task creates or edits: `README.md`, `CHANGELOG.md`, `docs/**/*.md`, PR descriptions, release notes, design docs, status updates, exec summaries, handoff documents.
100
+ - Goal contains: "write", "draft", "summarize", "document", "one-pager", "brief", "memo", "deck", "slides", "presentation", "status update".
101
+ - Designing information architecture or section ordering: use the pyramid logic for top-down flow (governing thought, then MECE key lines, then support).
102
+
103
+ Action: load `pyramid-principle:pyramid-principle-core` first for ground rules, then the specific skill matching length and format. If absent, use `fallbacks.md#structured-writing`.
104
+
105
+ **prompt-builder** (prompt authoring or audit)
106
+
107
+ Fires when prompts are a core part of the product, not when prompts appear incidentally in code comments or test fixtures.
108
+
109
+ Trigger if any of:
110
+
111
+ - Building or editing prompts that the app sends to an LLM at runtime: document-generation prompts (Example App style), chat-with-user system prompts, voice-interaction prompts (example app style), reranker prompts, eval-judge prompts.
112
+ - Robust agent or prompt pipeline present in the product: multi-step prompts, RAG, tool-use flows.
113
+ - Semantic search over user queries: use `prompt-builder` to revise the query before embedding or retrieval.
114
+ - Authoring a new agent's instructions (the body of an `agents/*.md` file serving as LLM guidance).
115
+ - File signals: `prompts/`, `system-prompt.*`, strings passed to `messages[{role:"system"}]`, `anthropic.messages.create`, `openai.chat.completions.create`, prompt templates in `.prompt` or `.txt` held as product assets.
116
+ - Goal contains: "system prompt", "agent prompt", "prompt engineering", "rewrite this prompt", "improve this prompt", "audit prompts", "eval judge".
117
+
118
+ Existing prompt guardrail: if the task touches an **existing** in-product prompt (not a new one), pause and ask the user before running `prompt-builder`. Prompts are often tuned against real evals; silent rewrites can regress quality. Offer the option, do not auto-apply.
119
+
120
+ Action: load `prompt-builder:prompt-builder` (plugin) if installed, else the personal `prompt-builder` skill, else `fallbacks.md#prompt`. For existing-prompt edits, capture before-and-after in `.build-loop/prompts/` with version suffixes so regressions are detectable.
121
+
122
+ **building-with-deepagents** (DeepAgents / local-LLM agent work)
123
+
124
+ Fires whenever the project uses the open-source `deepagents` package. DeepAgents has subtle API shape (SubAgent dict, middleware stack, per-agent tool scoping) that makes hand-rolled focus modes and flat-tool-list designs silently wrong — small local models exhibit tool-call hallucinations in ways that scoping fixes and prompt injection doesn't.
125
+
126
+ Trigger if any of:
127
+
128
+ - Repo grep: `from deepagents` or `import deepagents` in any Python source file
129
+ - `deepagents` in `pyproject.toml`, `requirements*.txt`, `uv.lock`, or `poetry.lock`
130
+ - Goal mentions: "agent", "sub-agent", "subagent", "planner/researcher/writer", "focus mode", "tool-call hallucination", "LangGraph agent", "ChatOllama", "local LLM agent"
131
+ - File signals: `create_deep_agent`, `SubAgent`, `AGENT_ROLES`, `agent_focus_prompt`
132
+ - Pain symptoms in the conversation: "`<namespace>.<tool>` is not a valid tool", "silent thinking", "model loaded forever", "threads vanish on restart"
133
+
134
+ Existing-agent guardrail: treat agent definitions like existing prompts — pause before rewriting, capture before-and-after in `.build-loop/agents/` with version suffixes. Tool scoping changes downstream behavior for every query; regressions are expensive to spot.
135
+
136
+ Action: load `build-loop:building-with-deepagents` before any code edit involving agent construction, tool binding, or streaming. The skill's `references/anti-patterns.md` lists 12 concrete bugs we've hit — verify none of your planned changes reintroduce them.
137
+
138
+ **Judgment: prompt-builder vs inline prompt**
139
+
140
+ Not every prompt needs the full engine. Use `prompt-builder` when the prompt is load-bearing. Craft a simple inline prompt when it is throwaway.
141
+
142
+ Use `prompt-builder` when any of these are true:
143
+
144
+ - The prompt ships in the product and runs at scale.
145
+ - The prompt is sent to end users or generates user-visible output.
146
+ - The prompt is part of an agent, eval judge, RAG pipeline, or semantic-search query rewriter.
147
+ - Output correctness is measured (evals exist or are planned).
148
+ - The prompt will be reused across features, or maintained over time.
149
+ - Token cost matters because it runs millions of times.
150
+
151
+ Roll your own inline prompt when all of these are true:
152
+
153
+ - One-shot usage inside the current build loop (dispatching a subagent, asking Claude to transform a file, generating a migration script).
154
+ - Not persisted to the product codebase.
155
+ - Output is checked once by the orchestrator, not by an eval.
156
+ - A short direct instruction is clearer than a 6-Part Stack.
157
+
158
+ Default when uncertain: if the prompt text will exist in the repo after the build, use `prompt-builder`. If it only exists as a line in an orchestrator message during this build, inline is fine.
159
+
160
+ ### Plugin / hook / skill / agent work — mandatory
161
+
162
+ If Phase 1 detects that the task touches plugin components, Phase 3 must map each task to the authoritative skill below and Phase 4 must load that skill. **Do not infer plugin formats from memory or by reading another plugin's config.**
163
+
164
+ | Task surface | Skill (authoritative) | Fallback |
165
+ |---|---|---|
166
+ | `.claude-plugin/plugin.json` | `plugin-dev:plugin-structure` | Read `RossLabs-AI-Toolkit/LESSONS-LEARNED.md` — paths must start with `./` |
167
+ | `hooks/hooks.json` or hook scripts | `plugin-dev:hook-development` + run `plugin-dev/scripts/hook-linter.sh` | Command hooks default; Stop stdout must be valid JSON; advisory/non-blocking unless an explicit safety/security/integrity gate opts into blocking; NO prompt hooks on PostToolUse/Stop/SessionStart |
168
+ | Slash commands (`commands/*.md`) | `plugin-dev:command-development` | — |
169
+ | Subagents (`agents/*.md`) | `plugin-dev:agent-development` + `RossLabs-AI-Toolkit/agents/` | `fallbacks.md#agent-authoring` |
170
+ | MCP servers (`.mcp.json`) | `plugin-dev:mcp-integration` | `.mcp.json` must NOT wrap with `mcpServers` key (Method 1) |
171
+ | `~/.claude/settings.json` | `plugin-dev:plugin-settings` | — |
172
+ | New skill (SKILL.md) | `plugin-dev:skill-development` + `skill-builder` (personal) | Official skill format; SKILL.md ≤200 lines |
173
+ | New plugin end-to-end | `plugin-builder` (personal) → delegates into `plugin-dev:*` | — |
174
+
175
+ ### External knowledge — check before coding
176
+
177
+ | Source | When | How |
178
+ |---|---|---|
179
+ | `/cookbook` | Claude API patterns: tool calling, PTC, code execution, Agent SDK, RAG, thinking, structured output, batch, caching | Invoke `/cookbook` or read `reference_claude_cookbook.md` from your harness memory store (`~/.claude/projects/<project-slug>/memory/`) |
180
+ | `RossLabs-AI-Toolkit/LESSONS-LEARNED.md` | Any plugin work | Read during Phase 1 ASSESS |
181
+ | `context7` MCP | Any library/framework use | `query-docs` / `resolve-library-id` — do NOT code from training data |
182
+ | `research` skill | Factual claims, pricing, versions | Run `scripts/research_trigger.py` first; T1 official docs → T4 forums; 2-source minimum |
@@ -0,0 +1,106 @@
1
+ <!-- SPDX-FileCopyrightText: 2025-2026 Tyrone Ross, Jr <46267523+tyroneross@users.noreply.github.com> | SPDX-License-Identifier: Apache-2.0 -->
2
+
3
+ # Codex Subagent Adapter
4
+
5
+ Use this adapter when Build Loop runs inside Codex. It translates Build Loop's host-neutral "parallel subagents" concept into Codex-native delegation without changing Claude Code's `agents/*.md` runtime.
6
+
7
+ ## Core Rule
8
+
9
+ Codex may use subagents only when the user explicitly authorizes delegation or parallel agent work. Examples: "use subagents", "parallelize this", "delegate", "spin up workers", or `/build-loop --parallel ...`.
10
+
11
+ If authorization is absent, keep the work local in the lead Codex session. Still write the same MECE plan and ownership packets, but do not spawn workers.
12
+
13
+ ## Role Mapping
14
+
15
+ | Build Loop need | Codex role | Use when |
16
+ |---|---|---|
17
+ | Codebase question | `explorer` | The answer can be read-only, bounded, and returned as facts with file paths. |
18
+ | Implementation slice | `worker` | The write set is disjoint from other workers and the interface contract is clear. |
19
+ | Phase 4 review passes | lead session inline, or `explorer` if authorized | See the enumerated passes below — the lead owns these whether or not delegation is allowed. |
20
+ | Final integration | lead session | The lead must own merge, validation, and final judgment. |
21
+
22
+ **Phase 4 review is not one pass — it is a set.** Whether run inline (default) or via an authorized `explorer`, the lead must cover all of these every non-trivial build; do not skip a pass just because Codex lacks a dedicated agent file for it:
23
+
24
+ - **Adversarial audit (independent-auditor)** — read the diff against intent/goal/PRD/constitution; verdict `yay`/`nay`/`suggest_correction`/`look_again`. Advisory at chunk close, gating at build scope.
25
+ - **Fact-check** — trace every rendered metric (%, $, score, count) to its source; flag absolute claims. *Blocking* when a rendered number is unverifiable.
26
+ - **Mock-data scan** — production paths only; lorem/faker/hardcoded/`Math.random()`-in-display. *Blocking* when it renders to the user.
27
+ - **Security review** — only when Assess flagged a risk-surface change (auth, network, persistence, secrets, external input); OWASP LLM/Agentic/Web top-10. *Blocking* on critical/high (feeds the exit gate).
28
+
29
+ The first row's "read-only, does not block" applies to the adversarial-audit *critic* pass; the fact-check, mock-scan, and security passes CAN block and route to Iterate.
30
+
31
+ ## Permission Gate
32
+
33
+ Before spawning any Codex subagent:
34
+
35
+ 1. Confirm user authorization is explicit in the current request or command flags.
36
+ 2. Confirm the task is not on the immediate critical path.
37
+ 3. Confirm the subtask has a bounded write set or read-only question.
38
+ 4. Confirm the prompt includes a MECE ownership packet.
39
+
40
+ If any condition fails, do the work locally.
41
+
42
+ ## When Not To Delegate
43
+
44
+ - Ambiguous product decisions.
45
+ - Final integration or final report.
46
+ - Destructive git operations.
47
+ - Push/deploy confirmation.
48
+ - A task whose result is required before the lead can make the next local move.
49
+ - Files already owned by another active worker.
50
+ - Cross-file architecture decisions that were not settled in the plan.
51
+
52
+ ## Prompt Packet Required
53
+
54
+ Every Codex worker prompt must include:
55
+
56
+ - `task`: one concrete outcome.
57
+ - `owns`: exact files or directories the worker may edit.
58
+ - `does_not_own`: files, directories, or responsibilities the worker must avoid.
59
+ - `context`: condensed facts from Phase 1 and Phase 2.
60
+ - `interface_contract`: functions, routes, schemas, props, CLI flags, or docs the worker must preserve or expose.
61
+ - `integration_checkpoint`: what the lead will verify before merging the worker result.
62
+ - `validation`: commands the worker should run if feasible.
63
+ - `return_format`: changed files, summary, validation, unresolved risks, integration notes.
64
+
65
+ Tell every worker: "You are not alone in the codebase. Do not revert edits made by others; adapt around them and report conflicts."
66
+
67
+ ## Context Policy
68
+
69
+ Prefer explicit prompt packets over full context forks. Use full context only when the worker genuinely needs the thread history to avoid a wrong implementation.
70
+
71
+ Shared reads should happen once in the lead session, then be condensed into worker prompts. This keeps workers focused and reduces contradictory interpretations.
72
+
73
+ ### Prompt Cache Discipline
74
+
75
+ OpenAI prompt caching is automatic, so Build Loop cannot call the cache directly from Codex. The lever the Codex adapter controls is prompt shape: keep the reusable prefix stable, and move volatile task state later.
76
+
77
+ For Codex CLI and Codex app runs, put reusable role rules, output contracts, validation expectations, and ownership schema before task-specific facts. Put Rally state, timestamps, command output, diffs, browser comments, thread IDs, worktree metadata, current claims, and task IDs after the stable contract.
78
+
79
+ Do not reorder stable sections between worker prompts. Monitoring cached-token counters only detects prefix churn; the improvement comes from preserving the prefix and reducing noisy context before dispatch.
80
+
81
+ ## Parallel Pattern
82
+
83
+ 1. Lead creates the plan and identifies parallel-safe groups.
84
+ 2. Lead spawns only independent sidecar work.
85
+ 3. Lead continues non-overlapping local work while workers run.
86
+ 4. Lead waits only when blocked on a worker result.
87
+ 5. Lead reviews changed files and integrates deliberately.
88
+ 6. Lead runs final validation locally.
89
+
90
+ ## Return Format
91
+
92
+ Workers should finish with:
93
+
94
+ ```text
95
+ Changed files:
96
+ - <path>: <what changed>
97
+
98
+ Validation:
99
+ - <command or "not run">: <result or reason>
100
+
101
+ Integration notes:
102
+ - <contract, migration, or ordering notes>
103
+
104
+ Unresolved risks:
105
+ - <risk or "none known">
106
+ ```
@@ -0,0 +1,161 @@
1
+ <!-- SPDX-FileCopyrightText: 2025-2026 Tyrone Ross, Jr <46267523+tyroneross@users.noreply.github.com> | SPDX-License-Identifier: Apache-2.0 -->
2
+
3
+ # Coordination — How build-loop consumes agent-rally
4
+
5
+ Build-loop is a **consumer** of the agent-rally architecture, but it currently
6
+ vendors native embedded copies of the substrate and watcher while the standalone
7
+ repos mature. Treat `agent-rally-point` and `agent-rally-watcher` as
8
+ mini-plugins inside build-loop: grouped scripts, skills, docs, tests, and thin
9
+ build-loop adapters first; full spin-out later. Cross-reference the upstream
10
+ architecture docs before changing how build-loop reads or writes events, but do
11
+ not make build-loop depend on those external repos at runtime yet.
12
+
13
+ > **Binding constitution** (verdict-gating, MECE briefs, Phase D closeout, peer-no-mutate, release-surface verification) lives in [`references/coordination-rules.md`](../../../references/coordination-rules.md). This file documents the **integration shape**, not the rules of engagement.
14
+
15
+ ## Build-loop's position in the three-layer model
16
+
17
+ ```
18
+ Layer 3 — CONSUMERS (build-loop, codex, claude_code, ...)
19
+
20
+ │ build-loop is one of many
21
+
22
+ Layer 2 — agent-rally-watcher (embedded watcher namespace; optional listener)
23
+
24
+ │ build-loop CAN subscribe, OR poll Layer 1 directly
25
+
26
+ Layer 1 — agent-rally-point (embedded substrate; channel, schema, post API)
27
+ ```
28
+
29
+ Build-loop **always** uses Layer 1 (it posts events and calls `checkpoint_read`). It uses Layer 2 **opportunistically** — when a peer session is detected via Rally Point presence, the coordination polling gate spins up a `coordination_watch.py` loop or installs a watcher subscription so chunk-close, commit, and feedback events surface within seconds rather than at the next phase boundary.
30
+
31
+ Native skill entrypoints:
32
+
33
+ - `skills/agent-rally-point/SKILL.md` — substrate workflow, CLI, boundary,
34
+ run identity, and spin-out rules.
35
+ - `skills/agent-rally-watcher/SKILL.md` — watcher workflow, JSONL sensor
36
+ behavior, closeout, and spin-out rules.
37
+
38
+ The machine-readable boundary is `scripts/rally_point/plugin_boundary.json`.
39
+
40
+ ## What build-loop posts
41
+
42
+ Every cross-session signal goes through `scripts/rally_point/post.py::post()` (the canonical writer that bumps revision *before* appending — see [`agent-rally-point/docs/SCHEMA.md`](https://github.com/tyroneross/agent-rally-point/blob/main/docs/SCHEMA.md) for the field-by-field record format). Raw `append_change(...)` without a subsequent `bump_revision(...)` is a silent-no-op for peers (`feedback_codex_pass_is_gate_not_comment`).
43
+
44
+ | When | `kind` | `payload` shape | Triggered by |
45
+ |---------------------------------------|--------------|------------------------------------------------------------------|------------------------------------|
46
+ | Chunk closes and lands on the branch | `phase` | `{phase: "chunk-close", chunk_id, commit_sha, files_changed}` | Phase 3 commit step |
47
+ | Phase boundary (Phase 1, 4, 5) | `phase` | `{phase: "<phase-name>", summary, ...}` | Orchestrator phase entry |
48
+ | Build run closes (Phase D) | `phase` | `{phase: "run-closeout", session_id, coord_file, outcomes}` | Phase D closeout sequence |
49
+ | Peer hands off work to a verifier | `handoff` | `{from_tool, to_tool, work_item, deadline_ts}` | Sub-step F when a peer is present |
50
+ | Verifier returns a verdict | `feedback` | `{step, verdict: PASS|VARIANCE|BLOCKED, rationale, evidence}` | After verifier runs on a step |
51
+ | Architecture scan completes | `arch-scan-complete` | `{digest_path, files_scanned}` | Phase 1 architecture baseline |
52
+ | Dependency manifest changed | `dep-change` | `{manifest, added, removed, session_id}` | Phase 3 commit step on manifest |
53
+ | Coordination announcement / take-over | `phase` | `{phase: "leadership", role, scope}` | Multi-orchestrator handoff |
54
+
55
+ All writes are fire-and-forget — a coordination failure must never crash the build.
56
+
57
+ ## What build-loop reads
58
+
59
+ ### Phase 1 Assess — inbox pickup + presence check
60
+
61
+ At Phase 1 entry, the orchestrator (see `agents/build-orchestrator.md` §"Phase 1: Assess") runs:
62
+
63
+ ```bash
64
+ python3 scripts/coordination_status.py --workdir "$PWD" --session-id "$SESSION_ID" --json
65
+ ```
66
+
67
+ The status reports: active peers (live sessions in the channel's `sessions/`), session-ack-aware unread inbox messages (`inbox/<my-tool>.jsonl`, `inbox/all.jsonl`), task-heartbeat health when `--task-ref` is set, and any active coordination file. If `active_peers > 0` OR `inbox_unread_count > 0`, the orchestrator MUST drain the inbox before dispatching any chunk; otherwise the peer's last verdict/handoff is invisible to the new run. After acting on the inbox payload, run `python3 scripts/agent_rally.py ack-inbox --workdir "$PWD" --session-id "$SESSION_ID" --tool "$TOOL_ID" --json` so stale notes stop ringing the doorbell.
68
+
69
+ ### Coordination polling gate — watcher install when a peer is present
70
+
71
+ When the Phase 1 status returns peers, build-loop installs a cheap continuous watcher:
72
+
73
+ ```bash
74
+ python3 scripts/coordination_watch.py --workdir "$PWD" --session-id "$SESSION_ID" --tool claude_code --task-ref "$TASK_REF" --interval 5 --jsonl --baseline-current
75
+ ```
76
+
77
+ The watcher reports revision changes, inbox deltas, and task-heartbeat health as line-delimited JSON. The orchestrator polls it before commits, before final responses, and after any 30-second work interval. When a peer posts (e.g. a verifier returns a `feedback` verdict), the orchestrator routes the response into the active coordination file's "Codex feedback log" section rather than asking the user to paste it.
78
+
79
+ For long-running work, write `agent_rally.py heartbeat --task-ref "$TASK_REF"`
80
+ at task start and at least every 10 minutes. Presence says the session is live;
81
+ task heartbeat says it is still on the claimed task.
82
+
83
+ The watcher process is OPTIONAL — if the daemon process can't start (no FS-watch support, sandboxed environment), the orchestrator falls back to per-checkpoint `coordination_status.py` polls. The same flow works; latency is higher.
84
+
85
+ ### Chunk-close — checkpoint read for downstream chunks
86
+
87
+ After each chunk's commit step closes, the orchestrator runs `checkpoint_read` against this session's cursor to surface any peer events that landed during the chunk. Reactions (`reinstall`, `re-baseline`, `soft-claim`) are documented in [`agent-rally-point/docs/SCHEMA.md`](https://github.com/tyroneross/agent-rally-point/blob/main/docs/SCHEMA.md). Reactions are **awareness only** — `soft-claim` warns when a peer touched files this session also plans to touch; the orchestrator decides whether to wait, rebase, or proceed.
88
+
89
+ ## Peer-no-mutate rule
90
+
91
+ When a peer presence record indicates active work AND that work isn't already merged (`branch_merge_status: unmerged` AND files differ from `origin/main`), build-loop's orchestrator MUST NOT modify the same files. The rule and the merge-status pre-check are in [`references/coordination-rules.md`](../../../references/coordination-rules.md) §"Peer-no-mutate" and `feedback_verify_peer_merged_before_blocking`.
92
+
93
+ Read-only operations (Phase 1 architecture baseline, plan drafting, fact-check) are always safe and do not invoke the rule.
94
+
95
+ ## Embedded mini-plugin boundary
96
+
97
+ For now, the Rally Point substrate and watcher still ship inside the
98
+ build-loop plugin, but they are treated as embedded mini-plugins with
99
+ explicit extraction edges:
100
+
101
+ | Future plugin | Embedded namespace | Build-loop compatibility entrypoints |
102
+ |---|---|---|
103
+ | `agent-rally-point` | `scripts/rally_point/**` | `scripts/agent_rally.py`, `commands/rally-point.md`, `hooks/*rally-point.sh`, `scripts/coordination_status.py`, `scripts/coordination_rally.py`, `scripts/coordination_bootstrap.py` |
104
+ | `agent-rally-watcher` | `scripts/agent_rally_watcher/**` | `scripts/coordination_watch.py` |
105
+
106
+ The machine-readable contract lives at
107
+ `scripts/rally_point/plugin_boundary.json` and is validated by:
108
+
109
+ ```bash
110
+ python3 scripts/rally_point/boundary.py --repo "$PWD" --check --json
111
+ python3 scripts/agent_rally.py boundary --workdir "$PWD" --check --json
112
+ ```
113
+
114
+ Boundary rule: put substrate behavior in `scripts/rally_point/**`, watcher
115
+ behavior in `scripts/agent_rally_watcher/**`, and leave build-loop files as
116
+ thin adapters. Do not import build-loop memory-store or orchestration internals
117
+ from those namespaces unless the dependency is explicitly isolated as an
118
+ adapter in the boundary manifest.
119
+
120
+ ## Discovery integration (current)
121
+
122
+ Build-loop uses `scripts/rally_point/discovery_bridge.py` as the shared
123
+ channel resolver. It prefers the standalone `agent-rally-point` discovery
124
+ surface when installed and falls back to build-loop's embedded resolver only
125
+ when needed. Both native discovery and the embedded fallback default to
126
+ `~/.agent-rally-point/apps/...`; the fallback uses the local worktree-aware
127
+ `<slug>` when no native `<repo-id>` is available.
128
+
129
+ The discovery layer (see
130
+ [`agent-rally-point/docs/DISCOVERY.md`](https://github.com/tyroneross/agent-rally-point/blob/main/docs/DISCOVERY.md))
131
+ provides:
132
+
133
+ ```python
134
+ from agent_rally_point.discover import discover
135
+ info = discover() # returns dict with channel_dir, channel_layout, active_revision, active_peers, ...
136
+ channel_dir = info["channel_dir"] # canonical OR legacy-fallback path
137
+ ```
138
+
139
+ Current build-loop callers route through the bridge:
140
+
141
+ 1. `scripts/agent_rally.py` resolves `where`, `presence`, `handoff`, `lead`,
142
+ and `boundary` through the shared namespace.
143
+ 2. `scripts/coordination_status.py` reads status from the resolved channel
144
+ instead of deriving a parallel channel path.
145
+ 3. `scripts/rally_point/session_probe.py` and `scripts/rally_point/hooks.py`
146
+ use the resolved channel for session-start and pre-edit hook behavior.
147
+ 4. `scripts/coordination_watch.py` remains a compatibility wrapper; watcher
148
+ behavior lives under `scripts/agent_rally_watcher/`.
149
+
150
+ ## Cross-references
151
+
152
+ - **Substrate (channel format, post API, presence, lifecycle)** — [`agent-rally-point/ARCHITECTURE.md`](https://github.com/tyroneross/agent-rally-point/blob/main/ARCHITECTURE.md)
153
+ - **Record schema (all 6 kinds + payloads)** — [`agent-rally-point/docs/SCHEMA.md`](https://github.com/tyroneross/agent-rally-point/blob/main/docs/SCHEMA.md)
154
+ - **Discovery protocol (manifest, CLI, `discover()`)** — [`agent-rally-point/docs/DISCOVERY.md`](https://github.com/tyroneross/agent-rally-point/blob/main/docs/DISCOVERY.md)
155
+ - **Push-based daemon (consumers.toml, sinks)** — [`agent-rally-watcher/ARCHITECTURE.md`](https://github.com/tyroneross/agent-rally-watcher/blob/main/ARCHITECTURE.md)
156
+ - **Binding constitution (verdicts gating, MECE briefs, Phase D closeout)** — [`references/coordination-rules.md`](../../../references/coordination-rules.md)
157
+ - **Per-run coordination file template** — [`references/coordination-file-template.md`](../../../references/coordination-file-template.md)
158
+
159
+ ## Why a separate doc
160
+
161
+ `coordination-rules.md` is the binding *constitution* — operating rule, verdict gating, MECE field list, closeout sequence. This file is the *integration map* — where build-loop sits in the three-layer architecture, what it posts, what it reads, where the path-hardcoding lives, and what the discovery migration looks like. Conceptually distinct audiences: the rules file is for any participant; this file is for build-loop's orchestrator and anyone modifying how build-loop talks to rally-point.
@@ -0,0 +1,177 @@
1
+ <!-- SPDX-FileCopyrightText: 2025-2026 Tyrone Ross, Jr <46267523+tyroneross@users.noreply.github.com> | SPDX-License-Identifier: Apache-2.0 -->
2
+
3
+ # Correction-aware lesson capture — three-tier design
4
+
5
+ ## Why
6
+
7
+ Two gaps in the prior capture stack:
8
+
9
+ 1. **`scan_transcript_for_decisions.py` no-ops entirely without Ollama.**
10
+ The script gates on `shutil.which("ollama")`; absent the binary, an
11
+ entire session's worth of decisions is silently dropped.
12
+ 2. **No lessons / feedback lane from live conversation.** The decisions
13
+ scanner captures decisions only. A user correcting the assistant's
14
+ just-taken action — the highest-signal lesson event in a session —
15
+ had no trigger and no destination.
16
+
17
+ The three-tier design closes both gaps without disrupting the existing
18
+ decisions pipeline.
19
+
20
+ ## Three tiers
21
+
22
+ ### Tier 1 — Deterministic Stop-hook (always runs, no LLM)
23
+
24
+ **Script:** `scripts/scan_corrections/`
25
+ **Hook:** `hooks/hooks.json` Stop entry, fires alongside (not instead of)
26
+ the decisions scanner.
27
+
28
+ Detects three classes of high-signal patterns in USER turns:
29
+
30
+ | Class | Patterns | Confidence |
31
+ |---|---|---|
32
+ | Correction | `revert that`, `don't X`, `undo`, `stop X`, `back that out`, `wrong approach` | `confirmed` (extra: `prior_assistant_acted: true` when assistant just used tools) |
33
+ | Preference | `always X`, `never X`, `must X`, `default to X`, `we use X for Y`, `prefer X` | `confirmed` |
34
+ | Tradeoff | `X instead of Y`, `actually X not Y`, `X over Y because Z` | `confirmed` |
35
+
36
+ Scope routing: keywords like `across projects`, `globally`, `for all projects`,
37
+ `as a rule`, `standing rule` flag the candidate as `scope: global` (otherwise
38
+ `project`). Anti-false-positive: wh-question turns ending in `?` are skipped
39
+ by hard-skip patterns; greetings/thanks/ok are skipped.
40
+
41
+ Writes one `.build-loop/pending-lessons/<ts>-<kind>-<id>.md` per candidate
42
+ with YAML frontmatter:
43
+
44
+ ```yaml
45
+ ---
46
+ id: <16-char sha1>
47
+ kind: correction|preference|tradeoff
48
+ signal_type: <named pattern>
49
+ confidence: confirmed
50
+ scope: project|global
51
+ turn_index: <int>
52
+ captured_chars: <int>
53
+ tier: 1-deterministic
54
+ source: stop-hook
55
+ captured_at: <iso8601>
56
+ extras:
57
+ prior_assistant_acted: true|false
58
+ ---
59
+
60
+ ## Quote
61
+ > <verbatim user span>
62
+
63
+ ## Context (±200 chars)
64
+ ```
65
+
66
+ Idempotent: `id_hash` is a SHA-1 of (kind, signal_type, normalized quote),
67
+ so re-running the scanner on the same transcript does not duplicate files.
68
+ Promoted/discarded subdirs are also checked for dedup.
69
+
70
+ Fail-open contract: any exception logs to stderr and exits 0. The
71
+ `.build-loop/.no-capture` opt-out short-circuits before any work.
72
+ `SCAN_CORRECTIONS_BUDGET_S` (default 10s) caps wall-clock.
73
+
74
+ ### Tier 2 — Optional Ollama accelerator (existing path, unchanged)
75
+
76
+ **Script:** `scripts/scan_transcript_for_decisions.py` (the existing
77
+ decisions scanner, untouched). When Ollama is installed AND the
78
+ transcript is large enough to benefit from clustering, this path
79
+ distills/dedups decisions and writes to
80
+ `build-loop-memory/projects/<slug>/decisions/` (or `_review/` for
81
+ quarantine).
82
+
83
+ Tier 2 is **strictly optional**. The user installed Ollama on this
84
+ machine, so it runs; on a fresh machine without Ollama, tier 1 alone
85
+ guarantees capture and the session continues uninterrupted.
86
+
87
+ ### Tier 3 — Host-agent refinement (the primary intelligence)
88
+
89
+ **Script:** `scripts/surface_pending_lessons.py`
90
+ **Consumed by:** the host coding agent (Claude Code in this build,
91
+ Codex on a Codex host, etc.) at SessionStart.
92
+
93
+ Per the user's standing "host-agent-is-the-LLM" rule, the host coding
94
+ agent is the primary refinement layer. Each session, the host reads
95
+ `.build-loop/pending-lessons/` (and optionally
96
+ `build-loop-memory/projects/<slug>/decisions/_review/`), classifies each
97
+ candidate, and promotes via:
98
+
99
+ - `scripts/memory_writer.py` — for `kind=lesson|feedback|preference`
100
+ (routes to `build-loop-memory/lessons/` for `scope=global` or
101
+ `build-loop-memory/projects/<slug>/lessons/` for `scope=project`)
102
+ - `scripts/write_decision/__main__.py` — for `kind=decision`
103
+
104
+ Discarded candidates move into
105
+ `.build-loop/pending-lessons/discarded/` (any file there is silently
106
+ skipped on re-runs, so the discard is durable).
107
+
108
+ The same surface also exposes the existing Ollama `_review/` quarantine
109
+ when `--include-decisions-review` is set, so the host agent has one
110
+ queue to drain.
111
+
112
+ ## Store bridge (harness ↔ build-loop-memory)
113
+
114
+ **Script:** `scripts/bridge_lesson_to_harness.py`
115
+
116
+ Once a lesson lands in build-loop-memory (via tier-3 promotion or any
117
+ other path), it can be mirrored into the harness auto-memory store the
118
+ host coding agent auto-loads at session start
119
+ (`~/.claude/projects/-Users-<u>/memory/`). The bridge:
120
+
121
+ - Resolves a deterministic target basename `<kind>_<slug>.md` matching
122
+ the harness convention
123
+ - Augments the bridged copy's frontmatter with `bridged_from`,
124
+ `bridged_at`, `source_store: build-loop-memory`
125
+ - Appends a one-line entry to harness `MEMORY.md` under
126
+ `## Bridged from build-loop-memory` (creates the section if absent;
127
+ preserves other sections; dedup'd on target basename)
128
+
129
+ Idempotent and reversible. Only `lesson | feedback | preference | convention | gotcha`
130
+ types bridge; decisions stay in their own canonical store.
131
+
132
+ ## Triggers — what fires when
133
+
134
+ | Event | Tier | Effect |
135
+ |---|---|---|
136
+ | Session ends (Stop hook) | 1 | tier-1 scanner writes raw candidates to `.build-loop/pending-lessons/` |
137
+ | Session ends (Stop hook) | 2 | tier-2 scanner (Ollama, if present) writes distilled decisions |
138
+ | Session starts (host agent reads context-bootstrap) | 3 | pending-lessons queue count surfaces in queue summary; host agent runs `surface_pending_lessons.py` to refine |
139
+ | Lesson promoted to build-loop-memory | — | `bridge_lesson_to_harness.py` mirrors to harness auto-memory |
140
+
141
+ ## File layout summary
142
+
143
+ ```
144
+ scripts/
145
+ scan_corrections/
146
+ __init__.py
147
+ detect.py — patterns + Candidate dataclass + JSONL parser
148
+ __main__.py — Stop-hook CLI (tier 1)
149
+ test_detect.py — 26 unit tests
150
+ test_cli.py — 8 CLI integration tests
151
+ surface_pending_lessons.py — tier 3 host-agent surface
152
+ test_surface_pending_lessons.py — 10 tests
153
+ bridge_lesson_to_harness.py — store bridge
154
+ test_bridge_lesson_to_harness.py — 11 tests
155
+ scan_transcript_for_decisions.py — UNCHANGED (tier 2)
156
+
157
+ hooks/hooks.json — Stop hook now runs both scanners in parallel
158
+
159
+ scripts/context_bootstrap.py — QUEUE_NAMES extended with "pending-lessons"
160
+
161
+ .build-loop/pending-lessons/ — tier-1 candidate queue (this run)
162
+ /promoted/ — host-agent promoted (silenced)
163
+ /discarded/ — host-agent discarded (silenced)
164
+ ```
165
+
166
+ ## Non-goals + tradeoffs
167
+
168
+ - **Not a replacement for `auto-decision-capture`.** That skill is for
169
+ the host agent's in-session reasoning — explicit captures during the
170
+ conversation. Tier-1 + tier-3 fire at session boundaries; the skill
171
+ fires inline. They compose.
172
+ - **Tier 1 is intentionally narrow.** Adding fuzzy patterns would
173
+ produce false positives. The host agent (tier 3) is where ambiguous
174
+ cases get judged — that's the design intent of "host-agent-is-the-LLM."
175
+ - **Bridge runs on demand, not automatically.** A future enhancement
176
+ could fire it via a post-promotion hook; the durable lesson lives in
177
+ build-loop-memory either way, and the bridge is reversible.