@tyroneross/build-loop 0.30.3

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 (389) hide show
  1. package/.agents/plugins/marketplace.json +10 -0
  2. package/.claude-plugin/marketplace.json +38 -0
  3. package/.claude-plugin/plugin.json +30 -0
  4. package/.codex-plugin/plugin.json +41 -0
  5. package/.cursor/rules/build-loop-surface.mdc +22 -0
  6. package/AGENTS.md +498 -0
  7. package/LICENSE +202 -0
  8. package/README.md +403 -0
  9. package/agents/alignment-checker.md +124 -0
  10. package/agents/api-assessor.md +136 -0
  11. package/agents/architecture-scout.md +185 -0
  12. package/agents/assessment-orchestrator.md +163 -0
  13. package/agents/build-orchestrator.md +198 -0
  14. package/agents/database-assessor.md +133 -0
  15. package/agents/design-contract-specialist.md +239 -0
  16. package/agents/fact-checker.md +69 -0
  17. package/agents/fix-critique.md +161 -0
  18. package/agents/frontend-assessor.md +136 -0
  19. package/agents/implementer.md +185 -0
  20. package/agents/independent-auditor.md +143 -0
  21. package/agents/mock-scanner.md +78 -0
  22. package/agents/optimize-runner.md +112 -0
  23. package/agents/overfitting-reviewer.md +96 -0
  24. package/agents/performance-assessor.md +159 -0
  25. package/agents/plan-critic.md +85 -0
  26. package/agents/promotion-reviewer.md +121 -0
  27. package/agents/recurring-pattern-detector.md +248 -0
  28. package/agents/retrospective-synthesizer.md +109 -0
  29. package/agents/root-cause-investigator.md +285 -0
  30. package/agents/scope-auditor.md +121 -0
  31. package/agents/security-reviewer.md +151 -0
  32. package/agents/self-improvement-architect.md +125 -0
  33. package/agents/synthesis-critic.md +99 -0
  34. package/agents/transcript-pattern-miner.md +165 -0
  35. package/agents/ui-validator.md +193 -0
  36. package/codex-skills/build-loop/SKILL.md +20 -0
  37. package/codex-skills/debug-loop/SKILL.md +18 -0
  38. package/codex-skills/handoff/SKILL.md +22 -0
  39. package/codex-skills/knowledge/SKILL.md +21 -0
  40. package/codex-skills/optimize/SKILL.md +18 -0
  41. package/codex-skills/research/SKILL.md +18 -0
  42. package/commands/agent-rally-point.md +301 -0
  43. package/commands/assess.md +41 -0
  44. package/commands/debug.md +20 -0
  45. package/commands/debugger-detail.md +34 -0
  46. package/commands/debugger-scan.md +15 -0
  47. package/commands/debugger-status.md +20 -0
  48. package/commands/debugger.md +32 -0
  49. package/commands/handoff.md +113 -0
  50. package/commands/knowledge-review.md +16 -0
  51. package/commands/optimize.md +31 -0
  52. package/commands/plan-verify.md +39 -0
  53. package/commands/promote-experiment.md +129 -0
  54. package/commands/research.md +22 -0
  55. package/commands/run.md +12 -0
  56. package/commands/self-review.md +51 -0
  57. package/commands/start-prd.md +57 -0
  58. package/commands/test.md +34 -0
  59. package/dist/src/assessment-orchestrator.d.ts +78 -0
  60. package/dist/src/assessment-orchestrator.d.ts.map +1 -0
  61. package/dist/src/assessment-orchestrator.js +304 -0
  62. package/dist/src/assessment-orchestrator.js.map +1 -0
  63. package/dist/src/audit-miner.d.ts +21 -0
  64. package/dist/src/audit-miner.d.ts.map +1 -0
  65. package/dist/src/audit-miner.js +421 -0
  66. package/dist/src/audit-miner.js.map +1 -0
  67. package/dist/src/batch-operations.d.ts +30 -0
  68. package/dist/src/batch-operations.d.ts.map +1 -0
  69. package/dist/src/batch-operations.js +339 -0
  70. package/dist/src/batch-operations.js.map +1 -0
  71. package/dist/src/config.d.ts +83 -0
  72. package/dist/src/config.d.ts.map +1 -0
  73. package/dist/src/config.js +176 -0
  74. package/dist/src/config.js.map +1 -0
  75. package/dist/src/context-engine.d.ts +45 -0
  76. package/dist/src/context-engine.d.ts.map +1 -0
  77. package/dist/src/context-engine.js +135 -0
  78. package/dist/src/context-engine.js.map +1 -0
  79. package/dist/src/debug-wrapper.d.ts +58 -0
  80. package/dist/src/debug-wrapper.d.ts.map +1 -0
  81. package/dist/src/debug-wrapper.js +285 -0
  82. package/dist/src/debug-wrapper.js.map +1 -0
  83. package/dist/src/index.d.ts +31 -0
  84. package/dist/src/index.d.ts.map +1 -0
  85. package/dist/src/index.js +149 -0
  86. package/dist/src/index.js.map +1 -0
  87. package/dist/src/interactive-verifier.d.ts +26 -0
  88. package/dist/src/interactive-verifier.d.ts.map +1 -0
  89. package/dist/src/interactive-verifier.js +435 -0
  90. package/dist/src/interactive-verifier.js.map +1 -0
  91. package/dist/src/lessons.d.ts +59 -0
  92. package/dist/src/lessons.d.ts.map +1 -0
  93. package/dist/src/lessons.js +172 -0
  94. package/dist/src/lessons.js.map +1 -0
  95. package/dist/src/log-reader.d.ts +39 -0
  96. package/dist/src/log-reader.d.ts.map +1 -0
  97. package/dist/src/log-reader.js +291 -0
  98. package/dist/src/log-reader.js.map +1 -0
  99. package/dist/src/logger.d.ts +59 -0
  100. package/dist/src/logger.d.ts.map +1 -0
  101. package/dist/src/logger.js +328 -0
  102. package/dist/src/logger.js.map +1 -0
  103. package/dist/src/parallel-retrieval.d.ts +52 -0
  104. package/dist/src/parallel-retrieval.d.ts.map +1 -0
  105. package/dist/src/parallel-retrieval.js +309 -0
  106. package/dist/src/parallel-retrieval.js.map +1 -0
  107. package/dist/src/pattern-extractor.d.ts +30 -0
  108. package/dist/src/pattern-extractor.d.ts.map +1 -0
  109. package/dist/src/pattern-extractor.js +386 -0
  110. package/dist/src/pattern-extractor.js.map +1 -0
  111. package/dist/src/result-aggregator.d.ts +44 -0
  112. package/dist/src/result-aggregator.d.ts.map +1 -0
  113. package/dist/src/result-aggregator.js +315 -0
  114. package/dist/src/result-aggregator.js.map +1 -0
  115. package/dist/src/retrieval.d.ts +139 -0
  116. package/dist/src/retrieval.d.ts.map +1 -0
  117. package/dist/src/retrieval.js +724 -0
  118. package/dist/src/retrieval.js.map +1 -0
  119. package/dist/src/setup/auto-setup.d.ts +15 -0
  120. package/dist/src/setup/auto-setup.d.ts.map +1 -0
  121. package/dist/src/setup/auto-setup.js +157 -0
  122. package/dist/src/setup/auto-setup.js.map +1 -0
  123. package/dist/src/setup/configure-hooks.d.ts +8 -0
  124. package/dist/src/setup/configure-hooks.d.ts.map +1 -0
  125. package/dist/src/setup/configure-hooks.js +16 -0
  126. package/dist/src/setup/configure-hooks.js.map +1 -0
  127. package/dist/src/setup/create-slash-commands.d.ts +8 -0
  128. package/dist/src/setup/create-slash-commands.d.ts.map +1 -0
  129. package/dist/src/setup/create-slash-commands.js +101 -0
  130. package/dist/src/setup/create-slash-commands.js.map +1 -0
  131. package/dist/src/setup/index.d.ts +8 -0
  132. package/dist/src/setup/index.d.ts.map +1 -0
  133. package/dist/src/setup/index.js +17 -0
  134. package/dist/src/setup/index.js.map +1 -0
  135. package/dist/src/setup/inject-claude-md.d.ts +10 -0
  136. package/dist/src/setup/inject-claude-md.d.ts.map +1 -0
  137. package/dist/src/setup/inject-claude-md.js +150 -0
  138. package/dist/src/setup/inject-claude-md.js.map +1 -0
  139. package/dist/src/setup/uninstall.d.ts +22 -0
  140. package/dist/src/setup/uninstall.d.ts.map +1 -0
  141. package/dist/src/setup/uninstall.js +235 -0
  142. package/dist/src/setup/uninstall.js.map +1 -0
  143. package/dist/src/storage.d.ts +192 -0
  144. package/dist/src/storage.d.ts.map +1 -0
  145. package/dist/src/storage.js +1037 -0
  146. package/dist/src/storage.js.map +1 -0
  147. package/dist/src/string-similarity.d.ts +8 -0
  148. package/dist/src/string-similarity.d.ts.map +1 -0
  149. package/dist/src/string-similarity.js +57 -0
  150. package/dist/src/string-similarity.js.map +1 -0
  151. package/dist/src/traces/adapters/browser.d.ts +69 -0
  152. package/dist/src/traces/adapters/browser.d.ts.map +1 -0
  153. package/dist/src/traces/adapters/browser.js +280 -0
  154. package/dist/src/traces/adapters/browser.js.map +1 -0
  155. package/dist/src/traces/adapters/index.d.ts +23 -0
  156. package/dist/src/traces/adapters/index.d.ts.map +1 -0
  157. package/dist/src/traces/adapters/index.js +67 -0
  158. package/dist/src/traces/adapters/index.js.map +1 -0
  159. package/dist/src/traces/adapters/langchain.d.ts +42 -0
  160. package/dist/src/traces/adapters/langchain.d.ts.map +1 -0
  161. package/dist/src/traces/adapters/langchain.js +151 -0
  162. package/dist/src/traces/adapters/langchain.js.map +1 -0
  163. package/dist/src/traces/adapters/opentelemetry.d.ts +46 -0
  164. package/dist/src/traces/adapters/opentelemetry.d.ts.map +1 -0
  165. package/dist/src/traces/adapters/opentelemetry.js +164 -0
  166. package/dist/src/traces/adapters/opentelemetry.js.map +1 -0
  167. package/dist/src/traces/adapters/sentry.d.ts +58 -0
  168. package/dist/src/traces/adapters/sentry.d.ts.map +1 -0
  169. package/dist/src/traces/adapters/sentry.js +212 -0
  170. package/dist/src/traces/adapters/sentry.js.map +1 -0
  171. package/dist/src/traces/index.d.ts +10 -0
  172. package/dist/src/traces/index.d.ts.map +1 -0
  173. package/dist/src/traces/index.js +45 -0
  174. package/dist/src/traces/index.js.map +1 -0
  175. package/dist/src/traces/storage.d.ts +78 -0
  176. package/dist/src/traces/storage.d.ts.map +1 -0
  177. package/dist/src/traces/storage.js +399 -0
  178. package/dist/src/traces/storage.js.map +1 -0
  179. package/dist/src/traces/summarizer.d.ts +83 -0
  180. package/dist/src/traces/summarizer.d.ts.map +1 -0
  181. package/dist/src/traces/summarizer.js +247 -0
  182. package/dist/src/traces/summarizer.js.map +1 -0
  183. package/dist/src/traces/types.d.ts +365 -0
  184. package/dist/src/traces/types.d.ts.map +1 -0
  185. package/dist/src/traces/types.js +14 -0
  186. package/dist/src/traces/types.js.map +1 -0
  187. package/dist/src/types.d.ts +495 -0
  188. package/dist/src/types.d.ts.map +1 -0
  189. package/dist/src/types.js +27 -0
  190. package/dist/src/types.js.map +1 -0
  191. package/docs/agent-surface-policy.md +45 -0
  192. package/docs/memory-setup.md +226 -0
  193. package/hooks/_arch_scan_bg.py +88 -0
  194. package/hooks/_plugin_drift_check_bg.py +85 -0
  195. package/hooks/_session_start_lib.sh +42 -0
  196. package/hooks/git/pre-push +141 -0
  197. package/hooks/hooks.json +126 -0
  198. package/hooks/post-commit +30 -0
  199. package/hooks/pre-commit +29 -0
  200. package/hooks/pre-edit-apppulse.sh +6 -0
  201. package/hooks/pre-edit-architecture.sh +106 -0
  202. package/hooks/pre-edit-rally-point.sh +92 -0
  203. package/hooks/session-start-apppulse.sh +6 -0
  204. package/hooks/session-start-architecture.sh +10 -0
  205. package/hooks/session-start-git-hooks.sh +12 -0
  206. package/hooks/session-start-plugin-drift.sh +27 -0
  207. package/hooks/session-start-rally-point.sh +44 -0
  208. package/hooks/session-start-retrieval.sh +24 -0
  209. package/hooks/session-start-worktree-gc.sh +105 -0
  210. package/hooks/test_apppulse_hooks.sh +6 -0
  211. package/hooks/test_rally_point_hooks.sh +388 -0
  212. package/hooks/test_sec008_hooks.sh +66 -0
  213. package/package.json +111 -0
  214. package/scripts/README.md +301 -0
  215. package/scripts/_db_url.py +61 -0
  216. package/scripts/_paths.py +445 -0
  217. package/scripts/blm.py +162 -0
  218. package/scripts/blm_api.py +263 -0
  219. package/scripts/check_cache_sync.py +490 -0
  220. package/scripts/embed_backend.py +475 -0
  221. package/scripts/install_memory.py +556 -0
  222. package/scripts/lessons_index/__init__.py +77 -0
  223. package/scripts/lessons_index/__main__.py +135 -0
  224. package/scripts/lessons_index/ingest.py +288 -0
  225. package/scripts/lessons_index/query.py +285 -0
  226. package/scripts/lessons_index/schema.py +114 -0
  227. package/scripts/memory_context/__init__.py +610 -0
  228. package/scripts/memory_graph/__init__.py +393 -0
  229. package/scripts/project_resolver.py +172 -0
  230. package/scripts/prune_codex_plugin_cache.py +23 -0
  231. package/scripts/prune_plugin_cache.py +359 -0
  232. package/scripts/semantic_index/__init__.py +482 -0
  233. package/scripts/semantic_index/_bench_hybrid.py +175 -0
  234. package/scripts/semantic_index/backfill.py +263 -0
  235. package/scripts/semantic_index/hybrid.py +174 -0
  236. package/scripts/semantic_index/test_backfill.py +292 -0
  237. package/scripts/semantic_index/test_hybrid.py +541 -0
  238. package/scripts/sync_navgator_lessons.py +666 -0
  239. package/scripts/sync_plugin_cache.py +388 -0
  240. package/skills/agent-rally-point/SKILL.md +165 -0
  241. package/skills/agent-rally-watcher/SKILL.md +83 -0
  242. package/skills/api-registry-bridge/SKILL.md +59 -0
  243. package/skills/architecture/dead/SKILL.md +56 -0
  244. package/skills/architecture/impact/SKILL.md +88 -0
  245. package/skills/architecture/review/SKILL.md +227 -0
  246. package/skills/architecture/rules/SKILL.md +72 -0
  247. package/skills/architecture/scan/SKILL.md +79 -0
  248. package/skills/architecture/trace/SKILL.md +65 -0
  249. package/skills/attribution-standard/SKILL.md +122 -0
  250. package/skills/authentication/SKILL.md +81 -0
  251. package/skills/authentication/references/better-auth-magic-link.md +135 -0
  252. package/skills/authentication/references/better-auth-setup.md +224 -0
  253. package/skills/authentication/references/google-calendar-sync.md +278 -0
  254. package/skills/authentication/references/google-cloud-console.md +159 -0
  255. package/skills/authentication/references/google-geocoding-directions.md +126 -0
  256. package/skills/authentication/references/google-lessons-example-web-app.md +177 -0
  257. package/skills/authentication/references/google-maps.md +162 -0
  258. package/skills/authentication/references/google-oauth-setup.md +343 -0
  259. package/skills/authentication/references/google-places.md +173 -0
  260. package/skills/authentication/references/lessons-example-web-app-better-auth.md +126 -0
  261. package/skills/authentication/references/resend-email.md +227 -0
  262. package/skills/authentication/references/resend-otp-magic-link.md +153 -0
  263. package/skills/authentication/references/supabase-auth.md +172 -0
  264. package/skills/auto-decision-capture/SKILL.md +419 -0
  265. package/skills/build-loop/SKILL.md +516 -0
  266. package/skills/build-loop/detect-plugins.mjs +82 -0
  267. package/skills/build-loop/eval-guide.md +65 -0
  268. package/skills/build-loop/fallbacks.md +549 -0
  269. package/skills/build-loop/phases/fact-check.md +42 -0
  270. package/skills/build-loop/phases/ui-validation.md +267 -0
  271. package/skills/build-loop/references/apple-native-planning.md +439 -0
  272. package/skills/build-loop/references/capability-routing.md +181 -0
  273. package/skills/build-loop/references/codex-subagents.md +98 -0
  274. package/skills/build-loop/references/coordination.md +161 -0
  275. package/skills/build-loop/references/correction-aware-capture.md +177 -0
  276. package/skills/build-loop/references/independent-auditor.md +72 -0
  277. package/skills/build-loop/references/intent-capability-pack.md +170 -0
  278. package/skills/build-loop/references/intent-exploration-prompts.md +96 -0
  279. package/skills/build-loop/references/leadership.md +72 -0
  280. package/skills/build-loop/references/memory.md +284 -0
  281. package/skills/build-loop/references/modular-systems-pack.md +96 -0
  282. package/skills/build-loop/references/output-style.md +129 -0
  283. package/skills/build-loop/references/pay-it-forward-arch.md +98 -0
  284. package/skills/build-loop/references/phase-1-assess.md +218 -0
  285. package/skills/build-loop/references/phase-2-plan.md +77 -0
  286. package/skills/build-loop/references/phase-3-execute.md +47 -0
  287. package/skills/build-loop/references/phase-4-review.md +310 -0
  288. package/skills/build-loop/references/phase-5-iterate.md +71 -0
  289. package/skills/build-loop/references/phase-6-learn.md +56 -0
  290. package/skills/build-loop/references/recent-design-structures.md +274 -0
  291. package/skills/build-loop/references/refactor-history/ASSESSMENT.md +85 -0
  292. package/skills/build-loop/references/refactor-history/STANDALONE_TEST_RUN.md +149 -0
  293. package/skills/build-loop/references/refactor-history/scenarios/01-simple-bugfix.md +32 -0
  294. package/skills/build-loop/references/refactor-history/scenarios/02-ui-build-with-iteration.md +48 -0
  295. package/skills/build-loop/references/refactor-history/scenarios/03-multi-failure-escalation.md +60 -0
  296. package/skills/build-loop/references/refactor-history/scenarios/04-ui-build-ibr-absent.md +51 -0
  297. package/skills/build-loop/references/refactor-history/scenarios/05-refactor-navgator-absent.md +71 -0
  298. package/skills/build-loop/references/refactor-history/scenarios/06-recurring-bug-debugger-absent.md +52 -0
  299. package/skills/build-loop/references/refactor-history/trace-comparison.md +202 -0
  300. package/skills/build-loop/references/self-recursive-dev.md +77 -0
  301. package/skills/build-loop/references/self-review.md +232 -0
  302. package/skills/build-loop/references/ui-io-contract.md +116 -0
  303. package/skills/build-loop/scanners/audit-design-rules.mjs +476 -0
  304. package/skills/build-loop/scanners/require-visual-evidence.mjs +239 -0
  305. package/skills/build-loop/templates/backlog-item.md +35 -0
  306. package/skills/build-loop/templates/codex-worker-prompt.md +89 -0
  307. package/skills/build-loop/templates/ui-subagent-prompt.md +179 -0
  308. package/skills/build-loop/templates/ux-fix-plan.md +40 -0
  309. package/skills/building-with-deepagents/SKILL.md +195 -0
  310. package/skills/building-with-deepagents/references/anti-patterns.md +141 -0
  311. package/skills/building-with-deepagents/references/api-quick-reference.md +184 -0
  312. package/skills/capabilities/SKILL.md +91 -0
  313. package/skills/debug-loop/SKILL.md +278 -0
  314. package/skills/debug-loop/references/convergence-rules.md +145 -0
  315. package/skills/debug-loop/references/swiftui-macos-clunky-ui-debugger.html +823 -0
  316. package/skills/debugging/assess/SKILL.md +111 -0
  317. package/skills/debugging/debug-loop/SKILL.md +231 -0
  318. package/skills/debugging/memory/SKILL.md +147 -0
  319. package/skills/debugging/store/SKILL.md +153 -0
  320. package/skills/debugging-memory/SKILL.md +440 -0
  321. package/skills/debugging-memory/examples/incident-example.json +67 -0
  322. package/skills/debugging-memory/references/incident-documentation.md +280 -0
  323. package/skills/debugging-memory/references/ios-notification-alarm-playbook.md +300 -0
  324. package/skills/debugging-memory/references/pattern-extraction.md +163 -0
  325. package/skills/debugging-memory/references/subagent-integration.md +312 -0
  326. package/skills/defenseclaw-bridge/SKILL.md +156 -0
  327. package/skills/defenseclaw-bridge/references/dc-config-mapping.md +162 -0
  328. package/skills/defenseclaw-bridge/references/output-format.md +108 -0
  329. package/skills/handoff/SKILL.md +94 -0
  330. package/skills/ibr-bridge/SKILL.md +68 -0
  331. package/skills/knowledge/SKILL.md +127 -0
  332. package/skills/knowledge/references/recall-integration.md +83 -0
  333. package/skills/knowledge/templates/madr-minimal.md +56 -0
  334. package/skills/knowledge-review/SKILL.md +112 -0
  335. package/skills/logging-tracer/SKILL.md +202 -0
  336. package/skills/logging-tracer/references/log-analysis.md +128 -0
  337. package/skills/logging-tracer/references/stack-templates.md +274 -0
  338. package/skills/logging-tracer-bridge/SKILL.md +70 -0
  339. package/skills/mcp-builder/SKILL.md +278 -0
  340. package/skills/mcp-builder/references/mcp-security.md +106 -0
  341. package/skills/model-tiering/SKILL.md +216 -0
  342. package/skills/native-ax-driver/SKILL.md +220 -0
  343. package/skills/native-ax-driver/scripts/layout_fill.py +222 -0
  344. package/skills/native-ax-driver/scripts/native_driver.py +495 -0
  345. package/skills/native-ax-driver/swift/bl-ax-driver/Package.swift +20 -0
  346. package/skills/native-ax-driver/swift/bl-ax-driver/Sources/main.swift +542 -0
  347. package/skills/optimize/SKILL.md +202 -0
  348. package/skills/optimize/profiles.md +61 -0
  349. package/skills/plan-verify/SKILL.md +115 -0
  350. package/skills/plan-verify/test-fixtures/example-app-v20-findings.json +27 -0
  351. package/skills/plan-verify/test-fixtures/example-app-v20.md +42 -0
  352. package/skills/plan-verify/test-fixtures/example-app-v22-findings.json +15 -0
  353. package/skills/plan-verify/test-fixtures/example-app-v22.md +1608 -0
  354. package/skills/plan-verify/test-fixtures/unrelated-good-plan-findings.json +15 -0
  355. package/skills/plan-verify/test-fixtures/unrelated-good-plan.md +55 -0
  356. package/skills/plugin-builder/SKILL.md +329 -0
  357. package/skills/plugin-builder/references/authoritative-sources.md +104 -0
  358. package/skills/plugin-builder/references/build-loop-phase-guidance.md +94 -0
  359. package/skills/plugin-builder/references/components-guide.md +221 -0
  360. package/skills/plugin-builder/references/distribution.md +317 -0
  361. package/skills/plugin-builder/references/dual-host-claude-codex.md +220 -0
  362. package/skills/plugin-builder/references/hooks-reference.md +210 -0
  363. package/skills/plugin-builder/references/manifest-schema.md +111 -0
  364. package/skills/plugin-builder/references/plugin-hygiene-lessons.md +307 -0
  365. package/skills/plugin-tests/SKILL.md +94 -0
  366. package/skills/prd-bridge/SKILL.md +135 -0
  367. package/skills/research/SKILL.md +80 -0
  368. package/skills/security-methodology/SKILL.md +105 -0
  369. package/skills/security-methodology/references/cross-source-matrix.md +77 -0
  370. package/skills/security-methodology/references/mitre-atlas-starter.md +83 -0
  371. package/skills/security-methodology/references/nist-600-1-mapping.md +119 -0
  372. package/skills/security-methodology/references/owasp-agentic-top-10.md +157 -0
  373. package/skills/security-methodology/references/owasp-llm-top-10.md +144 -0
  374. package/skills/security-methodology/references/owasp-web-top-10.md +65 -0
  375. package/skills/self-improve/SKILL.md +298 -0
  376. package/skills/spec-writing/SKILL.md +548 -0
  377. package/skills/spec-writing/scripts/check_checklist.py +478 -0
  378. package/skills/sync-skills/SKILL.md +132 -0
  379. package/skills/telemetry/SKILL.md +66 -0
  380. package/skills/ui-design/SKILL.md +75 -0
  381. package/skills/ui-design/references/design-patterns-multi.md +165 -0
  382. package/skills/ui-design/references/design-preferences-from-owned-apps.md +150 -0
  383. package/skills/ui-design/references/evidence-capture-policy.md +55 -0
  384. package/skills/ui-design/references/ui-guidance-sources.md +330 -0
  385. package/skills/ui-design/references/universal-design-principles.alt.md +182 -0
  386. package/skills/ui-design/references/universal-design-principles.md +419 -0
  387. package/templates/memory/MEMORY.md.template +55 -0
  388. package/templates/memory/constitution.md.template +64 -0
  389. package/templates/memory/manifest.json +47 -0
package/AGENTS.md ADDED
@@ -0,0 +1,498 @@
1
+ # Build Loop
2
+
3
+ Orchestrated 5-phase development loop with a mandatory Phase 6 Learn, for significant multi-step code changes. Use this methodology when changes span multiple files, require planning, and benefit from structured validation.
4
+
5
+ **Skip this loop for:** single-file edits, config changes, quick fixes under ~20 lines.
6
+
7
+ ## Autonomy gate — the three things that confirm (governing rule, highest priority)
8
+
9
+ Once a plan is accepted, the loop does not stop to ask. Exactly three actions require human confirmation; everything else auto-executes:
10
+
11
+ 1. **Production push** — a deploy/publish/migration that reaches live users (production deploy, `npm publish`, `gh release`, prod DB migration). Preview/testflight/staging deploys are auto.
12
+ 2. **Destructive delete** — archive is auto (reversible); an irreversible purge/drop requires confirmation. Prefer archiving over deleting. Build artifacts (node_modules, dist, caches) are regenerable and delete freely.
13
+ 3. **Major user-impacting decision** — a product/platform-direction choice the plan marks `user_impact: major`. Implementation-tradeoff DECISIONs do NOT surface.
14
+
15
+ Action classification: SAFE → execute on main; RISKY → isolate to branch + log + continue main; DECISION → auto-pick `recommended_default` and log (unless `user_impact: major`); PRODUCTION → confirm (gate 1). Catastrophic-never commands (`rm -rf /`, `rm -rf ~`, force-push to a protected branch) are auto-refused — the loop logs and continues, does not ask.
16
+
17
+ There is NO gate for code size or complexity. Genuine inability to proceed (missing credential, external blocker) is logged, worked around with available tasks, and reported in the readback — not a stop-and-ask. Oversight is the end-of-run readback, not a mid-run halt.
18
+
19
+ ## Session-start preflight
20
+
21
+ Run this once at the start of every session, **before any other action**, to learn the coordination state of this repo (active peers, pending ACKs addressed to you, north-star paths, memory locations, guardrails) and to write a presence record so other tools can see you. Output tells you whether to `proceed_solo` or `join_active` (handle pending ACKs first).
22
+
23
+ ```bash
24
+ rally codex --human
25
+ ```
26
+
27
+ The command is **host-neutral** — the same binary works for every coding tool. Substitute the `--tool` value for your host: `codex`, `cursor`, `gemini`, `claude_code`, or `other`. The JSON form (omit `--human`) is the machine-readable envelope.
28
+
29
+ When you know your intent or files at session start, include them so peers can see the work immediately:
30
+
31
+ ```bash
32
+ rally start codex --intent "<what you are doing>" --path "<file-or-dir>" --json
33
+ ```
34
+
35
+ When you finish or hand off, close the loop:
36
+
37
+ ```bash
38
+ rally stop codex --session-id "<session-id>" --reason "done" --json
39
+ ```
40
+
41
+ `rally stop` removes live presence, marks the agent stopped, and releases active file claims unless `--keep-claims` is passed.
42
+ Peers read active work from `active_peers[]` and last-known active/stopped session state from `peer_states[]`.
43
+
44
+ **Fallback:** if `rally` is not on PATH, proceed without preflight — do **not** crash, do **not** block on it. The Phase 1 Rally Point presence write below covers the minimum coordination contract.
45
+
46
+ ## Output style
47
+
48
+ Concise output — say only what the user needs to decide or act; cut narration, restated context, filler; no jargon.
49
+
50
+ Lead each point with the finding. Progressive disclosure: headline first, files/detail below. Number points as standalone **bold-number** paragraphs with a blank line between (plain `1.` list syntax renders compressed). Never use the contrastive-pivot construction ("not X — it's Y", "isn't X, it's Y", "not just X but Y"); state the point directly. Style only, never a gate.
51
+
52
+ ## Phases
53
+
54
+ | # | Phase | Purpose | Output |
55
+ |---|-------|---------|--------|
56
+ | 1 | **Assess** | Understand state (project type, architecture, tools, prior state) AND define goal + 3-5 scoring criteria with pass/fail conditions | State summary + `.build-loop/goal.md` |
57
+ | 2 | **Plan** | Break work into tasks with dependency order, identify parallel-safe groups | Plan with dependency graph |
58
+ | 3 | **Execute** | Build it — dispatch parallel work for independent file groups | Working implementation |
59
+ | 4 | **Review** | Critic → Validate → Optimize (opt-in) → Fact-Check → Simplify → Auto-Resolve → Report — seven ordered sub-steps, single exit point | Scorecard + evidence; routes to Iterate on failure |
60
+ | 5 | **Iterate** | Fix Review failures, loop back to Review (max 5x) | Updated scorecard |
61
+ | 6 | **Learn** (mandatory) | Always runs after Review-G; emits a `## Learn` outcome line (accruing / deferred / full). Detects recurring patterns across runs (incl. retro enforce-candidates as a second signal source), auto-drafts experimental skills/agents with A/B tracking; promotion to `active/` still requires explicit `/build-loop:promote-experiment` | Experimental artifacts + synthesis |
62
+
63
+ ## Run Modes
64
+
65
+ These run parameters apply on any host — pass them on the invocation (`--flag`) or honor the equivalent intent when the user states it in prose. Default is autonomous, 2h budget.
66
+
67
+ | Mode / flag | Effect |
68
+ |---|---|
69
+ | default | Autonomous queue-drain loop: Phase 5 Iterate self-replenishes from `.build-loop/{ux-queue,issues,followup}/`, alignment-checks each item against intent, executes the aligned subset, batches commits. 2h wall-clock budget. |
70
+ | `--long` (or goal keywords `overnight`, `long-running`, `large-scale`, `multi-day`) | Same loop, 8h budget. |
71
+ | `--budget 30m \| 4h \| 30s` | Custom wall-clock budget; overrides `--long`. `budget_check.py` routes `continue \| checkin \| finalize_and_stop` at each iterate entry, commit, and phase boundary. |
72
+ | `--autonomous=false` | Classic single pass — run Phases 1–6 once; queue items become `followup/` instead of being drained. |
73
+ | `--resume <run-id \| latest>` | Re-enter a crashed/killed build mid-flight. Reuses the original `deadline_at` (a 2h budget that died at 1h59m does NOT get a fresh 2h — `resume_resolver.py` owns this). Reads existing `intent.md`/`plan.md`; jumps to remaining chunks. On a normal dispatch with an incomplete prior run detected, offer resume vs fresh before Phase 1. |
74
+
75
+ **Iteration caps:** classic = 5 per build; autonomous = 25 per build (3 same-verdict per item). Stop conditions: cap reached, budget exhausted, a drained item classifying `confirm`/`block`, 5 consecutive same-criterion failures, or an item whose intent anchor no longer resolves.
76
+
77
+ **Per-commit mode** (self-recursive builds — when the working dir IS the runtime, e.g. editing build-loop itself): plan once, then run one orchestrator pass per commit so each commit reviews and lands cleanly before the next starts. Auto-on for self-recursive; force with `--per-commit` / `--no-per-commit`.
78
+
79
+ **Budget-aware behavior is host-neutral** — without programmatic budget tracking, treat the budget as a soft wall-clock target: check in at ~50%, finalize before the deadline rather than starting new chunks.
80
+
81
+ ## Core Principles
82
+
83
+ - **KISS + DRY — code and output (governing).** Before adding a rule, gate, schema, script, agent, or report section, first try to (a) delete something, (b) extend something that exists, or (c) do nothing. A new mechanism must earn its place against a *named, observed* failure in this repo — not a cited statistic. Prefer one rule covering many cases over many narrow rules; one source of truth over duplicated logic. For output: say it once in the fewest words that keep the evidence; omit empty sections; headline first. Fewer rules and fewer lines is the default; growth is the justified exception. When this tensions with the principles below, simplify. **Every issue is a systems issue:** when something doesn't work, debugging finishes only when the *system* is updated so the class can't recur (durable guidance/check/simplification/restructure addressing root cause + meta-point, never a surface patch). Default corrective move is to reduce complexity (fewer lines/deps/steps) or, when size is irreducible, better structure (split large files, progressive disclosure) to minimize cognitive load. Scalable means simple over compact — every node (rule, script, agent, step, dep) is a failure site.
84
+ - **Tools on demand.** Detect what's available, use what's needed. Don't assume any tool exists. Native debugging skills are bundled inside build-loop; `/build-loop:debug <symptom>` is always available, and the orchestrator auto-invokes `Skill("build-loop:debug-loop")` on Review-B Validate failures and Iterate attempts 2 and 3. Standalone Coding Debugger is optional for cross-project incident memory.
85
+ - **North star first.** Understand the app/repo purpose, primary users, core workflows, and update intent before planning. Every subtask should explain how it contributes to that purpose.
86
+ - **Beauty in the basics.** Core flows, real data, clear hierarchy, useful states, working controls, and accurate information matter more than extra surface area.
87
+ - **Modular by default, not by dogma.** Prefer high cohesion, loose coupling, stable interfaces, and scalable boundaries unless a simpler or integrated approach better serves the use case. Document `MODULARITY EXCEPTION: <reason>` when taking that path.
88
+ - **Two-lens recommendations.** Do not let current tech debt, prior architecture, existing dependencies, or earlier decisions silently define "best." For non-trivial architecture, workflow, dependency, or product decisions, assess the clean-sheet best approach for the use case first, then assess the best current-constraints approach given the repo's debt, tools, dependencies, migration cost, and risk. Prior decisions are evidence, not axioms.
89
+ - **MECE work ownership.** Partition files, agents, and task groups so ownership is mutually exclusive and collectively exhaustive: no overlapping file owners, no unowned responsibilities, and one clear grouping dimension per level.
90
+ - **Guidelines for creation, guardrails for output.** Be flexible during building. Be strict about what reaches users.
91
+ - **No false data.** No mock data in production. No hardcoded metrics pretending to be real. No unverified claims.
92
+ - **Name every UI input and output.** For UI work, every affected surface must have an input/output contract before component choices are locked: data taxonomy, CRUD/domain operation, component mapping, states, modality fallback, validation/security, and traceability.
93
+ - **Diagnose before fixing.** Root-cause analysis before code changes. Many errors sharing a pattern = one system problem.
94
+ - **C-RCA / root_cause_before_done — investigate every open issue to root cause before "done," verified by a second subagent.** Before any completion claim, investigate EVERY open issue — failed tests, loose ends, errors, warnings, minor issues — none left unaddressed. For each, reach the ROOT CAUSE, not a surface patch. Use debugging skills (debug-loop / root-cause-investigator / systematic-debugging) and/or a 5-whys / causal-tree analysis to find the true cause AND its full span (does the same root cause affect other sites? fix all of them). The fix MUST address the root cause — a surface/symptom patch is a violation. The root-cause identification, fix, and non-regression MUST be verified by an independent subagent before "done." Pairs with C-HEAL (reactive self-heal) and the verify-every-subagent rule.
95
+ - **Research persistent problems, don't just retry.** When a fix doesn't hold, the same Iterate criterion fails 2+ times, or behavior contradicts your model, stop guessing and do internet research from trusted sources (T1 official docs and issue trackers first) before another attempt. `root-cause-investigator` carries WebSearch for exactly this. A documented upstream bug or library/terminal behavior often explains an "impossible" intermittent failure faster than another local loop — and prevents shipping a layered workaround over a known root cause. Mark confidence on what you find (✅ T1 cited / ⚠️ inferred).
96
+ - **Hook policy.** Hooks are advisory and non-blocking by default. Stop hooks must emit valid JSON on stdout when they emit anything, must exit 0, and must not stop work for reminders such as dirty worktrees, coordination notes, missing optional telemetry, or cache maintenance. Blocking is reserved for explicit safety/security/integrity gates: destructive actions, secret exposure, protected push/deploy/publish/release gates, or the self-modification safety gate. If a Stop hook needs blocking behavior, it must be behind an explicit opt-in and explain the exact safety boundary.
97
+ - **Converge or escalate.** If iteration isn't improving scores, stop and surface the blocker. Don't burn cycles.
98
+ - **Keep going until done.** Once the user accepts the plan, every phase is authorized scope. Do not ask the user to confirm each phase. Issues found mid-build route to Iterate. Status updates are fine; permission requests are not. Completed, validated, authorized work commits automatically — asking "should I commit?" or "want me to commit this?" is a workflow violation. `git commit` is classified `auto` by the autonomy gate (exit 0); it is never a permission-gated action. The only commit-adjacent stops are autonomy-gate `confirm`/`block` verdicts on a *push or deploy* command. The only valid stops are: a destructive action not in the plan, a missing credential, externally-blocked work, an explicit hand-off point in the plan, a genuine scope branch the plan does not resolve, or 8 hours wall-clock without a Review pass / 5 consecutive Iterate failures on the same criterion. **NOT stops:** posting a coordination handoff to a peer is *fire-and-continue* (work your owned lane in parallel; only a verifier verdict gating the *next* step is a wait); output volume / turn length is never a stop; "continue or hold?" on authorized, lane-isolated, determinate remaining work is a manufactured fork — finish it. A multi-step prune/refactor/migration with a defined item list runs to completion across that list.
99
+ - **Commit authorship stays human.** When build-loop manages a commit or push, do not set the official git author, committer, GitHub author, push actor, release actor, or equivalent platform actor to `Claude Code`, `Codex`, or any agent identity. Use the repo's configured human or service identity for official authorship. Agent involvement may be recorded in commit-body notes, run notes, `.build-loop` context, judge decisions, or auxiliary metadata; it must not replace the official author or actor field.
100
+ - **Self-heal SAFE issues — reactive fix AND proactive self-simplification (C-HEAL / self_heal_safe_issues).** Self-heal has two arms, both active. **Reactive:** when build-loop encounters (a) an error or crash from its own tooling, a hook, a script, a Bash command, or a build/test/lint failure; OR (b) a quality or performance issue from any Review sub-step, self-review, fact-check, simplify, or efficiency scan — ROOT-CAUSE and FIX it, then continue. Classify via `scripts/classify_action.py`: SAFE → apply, verify, commit, continue — no surface, no ask; RISKY → isolate to worktree-branch + log + continue main + surface in report; DECISION/PRODUCTION → surface/escalate. **Proactive:** during deep self-review (and any self-recursive build), the self-review/self-heal loop ALSO proactively simplifies build-loop's own code — reducing complexity, splitting oversized files, removing dead/duplicated logic, adding missing tests — driven by `self_review.py`'s `self_simplification[]` findings. The loop MAY also author new skills and new scripts (new scripts require a colocated `test_<name>.py`). Any change to build-loop's own code MUST pass the SELF-MODIFICATION SAFETY GATE (`self_mod_verify.py --scope auto --auto-revert`, `verdict: pass` required) before commit; on fail the gate auto-reverts and the change is not committed. **Self-modifications execute — they do not stop the loop.** A self-modification that is part of the accepted plan (including edits to the gate, tests, or the self-improvement loop) executes behind the test-suite gate. Build-loop never halts a planned self-modification for human approval. Oversight is post-hoc: (a) self-modifying runs trigger an ADDITIONAL adversarial review (independent-auditor at build scope; the periodic deep self-review re-audits recent self-modifications) — non-blocking; (b) the end-of-run readback reports every self-modification and the additional-review findings. The loop stays on task and reports once, at the end. Structural/architectural self-modifications surface as DECISION, never auto-apply. Full gate in `skills/build-loop/references/self-review.md` §"Self-modification of the restricted repo". **Banned anti-pattern:** bypassing a fixable error — `--no-verify`, xfail-ing a test, commenting out failing code, `|| true` on a real failure — when a SAFE fix exists. Workarounds allowed only when the fix classifies RISKY/DECISION/PRODUCTION or is genuinely infeasible; record both.
101
+
102
+ ## Phase Details
103
+
104
+ ### Phase 1: Assess
105
+
106
+ Combines situational awareness with goal definition so Plan has everything it needs.
107
+
108
+ **Understand state:**
109
+ - Detect project type and tooling (language, framework, test runner, linter, build system)
110
+ - Read deployment policy from `.build-loop/config.json.deploymentPolicy` when present. Default: `preview: auto`, `testflight: auto`, `production: confirm`, `unknown: confirm`.
111
+ - **Credential preflight** (fail-soft, names only — no values): scan referenced env keys against `.env`/`env` and surface each gap as `[CREDENTIAL REQUIRED] <name>` in the Assess summary and end-of-run readback. A missing credential is logged, worked around with available tasks, and reported — never a stop-and-ask.
112
+ - **Stale-context triage** (fail-soft): check handoff/orchestration/continuation docs against git history. Flag each drifted doc as `[STALE CONTEXT] <path>` so the agent does not plan from stale state.
113
+ - **Memory-staleness triage** (fail-soft): compare the project's milestone log against HEAD. When stale, surface `[MEMORY STALE] <slug> N commits behind HEAD` and continue — do not stop.
114
+ - Capture app/repo north star and update intent in `.build-loop/intent.md`: purpose, primary users, core jobs, user value, and non-goals.
115
+ - Capture modular structure in `.build-loop/state.json.structure`: current module boundaries, stable interfaces, coupling risks, likely MECE work partitions, and any justified modularity exception.
116
+ - Capture approach lenses in `.build-loop/state.json.approachLenses` for non-trivial recommendations: clean-sheet best approach, current-constraints best approach, constraints/debt that change the answer, and the bridge/backcast path from current state toward the clean-sheet target.
117
+ - Map relevant architecture (only what the goal touches)
118
+ - Check for prior state (`.build-loop/state.json` from interrupted builds)
119
+ - If goal involves external frameworks or APIs: research current docs before planning
120
+ - If web/mobile UI: capture current visual state for before/after comparison, then load `skills/build-loop/references/ui-io-contract.md` and inventory the affected user inputs and system outputs before planning
121
+ - **Supply-chain dependency cooldown**: if a JS project (`package.json`), run `scripts/inject_dependency_cooldown.py --workdir <repo>` to idempotently write the 7-day publish-age config using each PM's native key: npm ≥ 11.10.0 → `.npmrc` `min-release-age` (DAYS); pnpm → `pnpm-workspace.yaml` `minimumReleaseAge` (MINUTES) + `.npmrc` `minimum-release-age` for 10.x; yarn ≥ 4.10 → `.yarnrc.yml` `npmMinimalAgeGate` (numeric MINUTES). npm has no native exclude (npm/cli#8994), so on npm the user-authored allowlist (`.build-loop/config.json` → `dependencyCooldown.allowlist`, default `["@tyroneross/*"]`) is enforced by the PreToolUse hook (`scripts/hooks/pre_bash_dependency_cooldown.sh`), which stays engaged even with native config; pnpm/yarn carry the exclude natively so the hook stands down once enforced. `--check` verifies the PM actually recognizes the key (no false `enforced:true`). Constitution rule: `C-SUPPLY/dependency_cooldown`. Older npm (< 11.10.0) falls back to the hook's `--before=<7d ago>` date-pin. pip/cargo not covered in v1.
122
+
123
+ **Memory bootstrap + queue surfacing (session start — before planning):**
124
+
125
+ Run once at the Phase 1 preamble, immediately after `run_id` is known and before the architecture baseline or any planning:
126
+
127
+ 1. **Identify the repo**: `project_resolver.resolve_project(Path("$PWD"))` → project slug (git remote or dir name).
128
+ 2. **Run bootstrap**:
129
+ ```bash
130
+ python3 ${CLAUDE_PLUGIN_ROOT}/scripts/context_bootstrap.py \
131
+ --workdir "$PWD" --query "<goal-keywords>" \
132
+ --output "$PWD/.build-loop/context-bootstrap.json" --json
133
+ ```
134
+ The packet covers: canonical `build-loop-memory` root/project `MEMORY.md` + `constitution.md`, indexed recall via `memory_facade.py`, repo-local `.build-loop/{feedback,state,goal,intent,plan}` files, Codex memory registry `~/.codex/memories/MEMORY.md` plus linked rollout summaries, best-effort Rally/coordination state, **queue counts + top items** (`queues.{issues,backlog,ux-queue,followup,proposals}.{count,top[]}`), **progressive lessons** (`lessons_progressive[]` — SQLite FTS5, scoped to current work, zero external deps; degrades gracefully when DB absent), and `session_prefs`.
135
+ 3. **Surface + ask once** (immediately after reading the packet):
136
+ - Read `packet.agent_brief` for the one-liner summary, then check each queue: if any `queues.*.count > 0`, emit `#issues=N #backlog=M …` plus the top item titles from `queues.*.top[0].title`.
137
+ - Surface `lessons_progressive[].name` (up to 3) as ambient context so planning reflects recent learnings.
138
+ - Check `session_prefs.continue_from_queues`:
139
+ - `"always"` → include queue work in the plan without asking.
140
+ - `"never"` → skip queue work without asking.
141
+ - `"ask"` (default) AND first Assess of this run AND any queue count > 0 → ask the user ONCE: *"Tackle queue items now / after current task / not this session?"* Persist their answer: call `write_session_prefs(workdir, value, source="asked")` from `scripts/context_bootstrap.py` — this writes `state.json.session_prefs.{continue_from_queues, set_at, source}`.
142
+ - When `session_prefs.source == "config"` (set in `.build-loop/config.json` → `sessionPrefs.continueFromQueues`), do NOT ask — the repo has a standing preference.
143
+ - User task instructions always take priority over queue work.
144
+
145
+ **End-of-run continuation gate (after followup drain, before closing):**
146
+
147
+ After the main build's followup drain completes (or `.build-loop/followup/` was empty), run:
148
+
149
+ ```python
150
+ from scripts.context_bootstrap import should_continue_into_queues, pending_queue_items
151
+ should_continue = should_continue_into_queues(workdir) # True iff session_prefs == "always"
152
+ pending = pending_queue_items(workdir) # {"issues": N, "backlog": M}
153
+ ```
154
+
155
+ Proceed only when BOTH `should_continue is True` AND `pending["issues"] + pending["backlog"] > 0`. When both are true, enter one additional Phase 5 iterate cycle targeting `.build-loop/issues/` then `.build-loop/backlog/` (issues first). Use the same iterate machinery: alignment-checker per item, scope-auditor, independent-auditor post-fix; same iterate-cap and stop conditions. Items classified `PRODUCTION` or `DECISION` → surface in report, do not auto-execute. When either condition is false, the run ends — do NOT ask again (the preference was already captured at session start).
156
+
157
+ **Multi-session presence (Rally Point — cross-host: Claude Code, Codex, Gemini CLI, others):**
158
+
159
+ Multiple build-loop sessions can run concurrently against the same project across terminals and coding hosts. Rally Point presence is the single concurrent-presence source of truth — an awareness layer (never a lock), host-neutral, invoked from any host. (The legacy `session_registry.py` / `~/.build-loop/sessions/` collision mechanism was documented-dead and removed 2026-05-18 — see `KNOWN-ISSUES.md` §M4.)
160
+
161
+ 1. **Write presence and intent at the Phase 1 preamble** (immediately after `run_id` is known), and refresh it at each phase-start. Preferred Rust path:
162
+ ```bash
163
+ rally start codex --session-id "<sid>" --intent "phase=assess" --json
164
+ ```
165
+ When files are owned, include one `--path` per file or directory so Rally creates explicit file claims:
166
+ ```bash
167
+ rally start codex --session-id "<sid>" --intent "phase=execute" --path "src/app.ts" --json
168
+ ```
169
+ Embedded fallback path when the Rust `rally` binary is unavailable:
170
+ ```python
171
+ from pathlib import Path
172
+ from scripts.rally_point import presence
173
+ from scripts.rally_point.discovery_bridge import resolve
174
+ envelope = resolve(Path("$PWD"))
175
+ slug = envelope.app_slug
176
+ channel = Path(envelope.channel_dir)
177
+ presence.write_presence(channel, session_id="<sid>", tool="codex",
178
+ model="<model>", run_id="$RUN_ID", app_slug=slug,
179
+ phase="assess", files_in_flight=[])
180
+ ```
181
+ `tool` values: `claude_code | codex | gemini | other`. Resolve the channel through `discovery_bridge.resolve(...)` before every direct write. Rust-backed channels use `rally start` / `rally stop`; embedded fallback writes one file per live session at `<resolved-channel>/sessions/<session-id>.json` (session_id, tool, model, run_id, app_slug, phase, files_in_flight, heartbeat_ts, read cursor). Fire-and-forget — never raises, never blocks.
182
+ 2. **Read active peers** at the preamble and each phase-start:
183
+ ```python
184
+ peers = presence.read_active_presence(channel, exclude_session="<sid>")
185
+ ```
186
+ This reaps stale presence (heartbeat older than the channel's `heartbeat_minutes`, default 15) as a side effect — no daemon, no cleanup step.
187
+ 3. **Peer routing** (awareness only — never a hard block, D4; identical across hosts):
188
+ - No peers / no `files_in_flight` overlap → log one line per peer (tool, run_id, phase); proceed.
189
+ - Overlap with a peer's `files_in_flight` → surface a `soft-claim` **WARNING** (peer, overlapping files, peer phase); proceed with awareness. Interactive hosts MAY additionally ask the user to coordinate; headless hosts (Codex / cron) log + proceed. There is no SAFE-STOP sentinel and no non-zero exit.
190
+ 4. **Refresh presence** at every phase-start and whenever the phase's owned files change — re-call `write_presence` with the new `phase` + `files_in_flight` (the per-session read cursor is preserved across refreshes).
191
+ 5. **Stop explicitly.** On Rust-backed channels, run `rally stop <tool> --session-id <sid> --reason "<done|handoff|blocked>" --json` when the session ends or file ownership changes materially. This clears presence, marks the session stopped in `peer_states[]`, and releases active claims. Embedded fallback still self-heals with `reap_stale` when a host exits without unregistering.
192
+ 6. **Memory writes (M5 — separate concern)** — use `scripts/memory_writer.py write` instead of writing memory files directly. The writer adds provenance frontmatter (source_repo, source_workdir, source_run_id, source_host, cross_repo_validated, applied_in_repos, created_at, last_updated_at), then atomically appends a row to `INDEX.jsonl` for sibling discovery:
193
+ ```
194
+ python3 ${CLAUDE_PLUGIN_ROOT}/scripts/memory_writer.py write \
195
+ --file "<rel-path>" --name "<slug>" --description "<one-line>" \
196
+ --type feedback --run-id "$RUN_ID" --workdir "$PWD" --host codex \
197
+ --body-file /tmp/memory-body.md
198
+ ```
199
+ 7. **Memory reads (cross-session discovery)** — between phases, tail the index for new peer learnings:
200
+ ```
201
+ python3 ${CLAUDE_PLUGIN_ROOT}/scripts/memory_index.py tail \
202
+ --since "$LAST_INDEX_CHECK_TS" --exclude-run-id "$RUN_ID" --json
203
+ ```
204
+ For each returned row, read the memory file. Tag with `[CROSS-REPO — requires scrutiny]` when `source_workdir` ≠ current `$PWD` AND `source_repo` ≠ this repo's git remote. Tag with `[VALIDATED — applied in N repos]` when `cross_repo_validated: true` AND `len(applied_in_repos) >= 2`.
205
+ 8. **Memory mark-applied** — when a cross-repo memory is successfully applied here, record the application:
206
+ ```
207
+ python3 ${CLAUDE_PLUGIN_ROOT}/scripts/memory_writer.py mark-applied \
208
+ --file "<rel-path>" --applying-repo "$THIS_REPO_REMOTE" \
209
+ --applying-workdir "$PWD" --applying-run-id "$RUN_ID"
210
+ ```
211
+ Flips `cross_repo_validated: true` once a different repo confirms the lesson.
212
+ 10. **One-time migration** — on the first build after installing this version, run:
213
+ ```
214
+ python3 ${CLAUDE_PLUGIN_ROOT}/scripts/memory_writer.py migrate \
215
+ --run-id "$RUN_ID" --workdir "$PWD" --host codex
216
+ ```
217
+ Idempotent backfill of provenance frontmatter onto pre-existing memory files. Safe to re-run.
218
+
219
+ All three scripts are stdlib-only Python 3.11+ with atomic writes (`tmpfile + os.replace`) and `fcntl.flock` on append. They work identically in Claude Code and Codex; the only difference is which `--host` value the session passes.
220
+
221
+
222
+ **Define goal + criteria:**
223
+ - State the goal in one concrete sentence — what will be true when this succeeds?
224
+ - Design 3-5 scoring criteria. Each criterion must have:
225
+ - A clear pass condition
226
+ - A grading method: code-based (preferred) or LLM-as-judge (for nuance)
227
+ - Write goal to `.build-loop/goal.md`
228
+
229
+ **Synthesis-density routing (4-priority resolution):** if a plan exists at this point, count its `synthesis_dimensions:` entries (see Phase 2) and resolve the implementer tier in this priority order:
230
+
231
+ 1. **Explicit override** — if the host config sets a `thinking-tier` override OR the plan/chunk frontmatter declares `tier: thinking` → route to thinking-tier.
232
+ 2. **Auto-escalate on density** — `count > 5` (6 or more entries) → `tier: thinking` (synthesis-dense at the commit level; fan-out loses cross-dimension coherence here).
233
+ 3. **Default — fan-out for speed** — count 0–5 → fan out to code-tier implementers; backstops in Phase 4.5 catch the residual recall gap.
234
+ 4. **Per-chunk override** — individual chunks may declare `tier: thinking` even when the plan-level decision was fan-out (mixed-density plans).
235
+
236
+ Write the verdict to `.build-loop/state.json.synthesisDensity` as `{count, escalated, reason}`. Routing target is `tier: thinking` (provider-agnostic), never a hardcoded model name.
237
+
238
+ The `> 5` threshold matches the empirical inflection point measured in the synthesis-decision A/B experiment (2026-05-07): below that, code-tier implementer recall is poor but non-zero and the Phase 4.5 backstops materially help; at 6+ dimensions, depth dominates.
239
+
240
+ **Dynamic tier assignment (guide, not a fixed rule):** the orchestrator judges each subtask's complexity at dispatch time and assigns the tier that fits. Both escalation directions are active on every dispatch decision.
241
+
242
+ **Priority order: accuracy > speed > cost.** Pick the tier that does the work CORRECTLY first — never trade accuracy for a cheaper or faster model. Among accuracy-equivalent options, prefer the faster path (spawn Thinking-tier subagents to accelerate complex work; fan out in parallel where the host supports it). Optimize cost only after accuracy and speed are both satisfied.
243
+
244
+ **Prefer the Code tier** (the workhorse: Sonnet on Claude, GPT-5 Codex on Codex, Gemini 2.5 Flash on Gemini) for the bulk of work. Down-tier to **Pattern** (Haiku / GPT-5 Mini / Flash Lite) only for genuinely trivial mechanical/recognition tasks — pure pattern-match, no judgment, no gradient. When in doubt, use Code tier.
245
+
246
+ **Thinking-tier subagents are allowed to accelerate complex subtasks** — cross-file reasoning, novel design, ambiguous spec, hard refactor. Thinking tier is not reserved for the top-level orchestrator. On Codex this maps to GPT-5 Thinking workers; spawn them only under the existing Codex permission gate (explicit `--parallel` / delegation authorization).
247
+
248
+ **Verify every subagent's output before accepting it.** The cheaper the tier, the stronger the check. This per-subagent verification is the safety net that makes dynamic (and occasionally cheaper) assignment safe. Verification ties to build-loop's existing surfaces: verify-scope / verify-landed (Phase 3 commit step), independent-auditor (Phase 4 Review-A), and the implementer return envelope (`status: blocked | partial` routes to Iterate before output is accepted). No subagent output is trusted unchecked.
249
+
250
+ Full provider substitution table (Thinking / Code / Pattern → each host's models): `references/model-tier-mapping.md` §"Dynamic tier assignment".
251
+
252
+ **Eval methodology:**
253
+ - Binary pass/fail only. No Likert scales, no partial credit.
254
+ - One evaluator per dimension. No multi-dimension "God Evaluator."
255
+ - Code-based graders first (test pass/fail, lint clean, build succeeds, type check passes).
256
+ - LLM-as-judge only for criteria code can't evaluate (UX quality, naming clarity, etc.).
257
+
258
+ ### Phase 2: Plan
259
+
260
+ - Break work into tasks with exact file paths
261
+ - Identify dependency order — what must complete before what?
262
+ - Flag parallel-safe groups: files that don't import each other can be written simultaneously
263
+ - Partition files and agents MECE: every changed file has exactly one owner, every required responsibility has an owner, and each group declares `owns`, `does not own`, `interface contract`, and `integration checkpoint`
264
+ - Define checkpoints where work should be verified before continuing
265
+ - Optimize: remove unnecessary steps, combine related changes, eliminate redundant work
266
+ - **Two-lens approach gate**: for non-trivial architecture, workflow, dependency, UI/product, or long-lived interface decisions, add a `## Approach Lenses` section before implementation tasks. It must include:
267
+ - **Clean-sheet best approach:** what would be recommended if prior repo decisions, tech debt, and current implementation constraints did not exist.
268
+ - **Current-constraints approach:** what is best given existing code, debt, dependencies, tools, team/runtime constraints, migration risk, and delivery horizon.
269
+ - **Bridge/backcast:** the smallest credible path from the current-constraints approach toward the clean-sheet target, including debt retired, dependencies added/removed, and decision points.
270
+ - **Recommendation:** which path to execute now and why. If the recommendation follows current constraints instead of the clean-sheet approach, name the constraint that justifies the compromise.
271
+ - **UI input/output contract gate**: if `uiTarget != null`, add a `## UI Input/Output Contract` section before mockups or implementation. It must name every changed surface's inputs, outputs, data taxonomy, operation/domain verb, component mapping, state matrix, modality fallback, validation/security layer, and schema/API/design-system traceability.
272
+ - **Recent design structures gate**: if `uiTarget != null`, pass `skills/build-loop/references/recent-design-structures.md` to `design-contract-specialist` after the UI input/output contract exists. The specialist chooses the structure based on product/workflow/data/platform fit; recent structures are options, not requirements.
273
+ - **Enumerate synthesis dimensions** for any commit that involves design judgment (UI placement, copy tone, CTA tier, schema shape, dispatch contracts, etc.). Add a `synthesis_dimensions:` block to the plan listing each named decision with a concrete claimed value:
274
+ ```yaml
275
+ synthesis_dimensions:
276
+ placement_NewsBanner: "after `<NewsCard>` in app/components/Feed.tsx"
277
+ cta_tier_save_button: "primary"
278
+ copy_tone_settings: "second person, calm-precision, no exclamation marks"
279
+ empty_state_feed: "icon + one-line explanation + primary CTA"
280
+ ```
281
+ Vague values (`"appropriate"`, `"as needed"`, `"sensible"`) fail the deterministic plan-verify rule — every entry must name a specific choice or write `n/a` with a reason. The block is the contract the implementer attests to applying; Phase 4.5 lints diff-vs-claim.
282
+ - **Mockup-first gate for major UI work**: if the plan introduces a new page/screen or makes a major redesign (changes navigation graph, primary user flow, or replaces ≥40% of an existing screen), pause and use a mockup-drafting tool to produce black-and-white mockups before any UI is written. Wait for user feedback; carry the selected mockup into Execute as a reference. Skip for cosmetic tweaks, copy edits, or single-component swaps. This is the documented exception to the "actions/functions only, no plugin UI surfaces" bridging policy — mockup drafting IS the action.
283
+ - **Pay-it-forward architectural gate**: when a chunk touches a typed protocol / interface boundary / schema / multi-surface-capable behavior, the plan MUST include a `Path A vs Path B` comparison per `skills/build-loop/references/pay-it-forward-arch.md`. Default recommendation is **Path B** (typed-contract extension). Gates that justify Path A: time-budget >2×, missing dep/infra, missing design decision, or empty foreclosed-future-capability list. Named-future-capability list must cite the roadmap / PRD / `intent.md` — flexibility-for-its-own-sake (plugin systems, abstract factories with no current second consumer) is the explicit anti-pattern. Skip when the chunk fires none of the signals. Path A/B section template:
284
+ ```markdown
285
+ ### Path A vs Path B — <chunk name>
286
+ **Path A (minimum-viable):** <what / where / time / foreclosed>
287
+ **Path B (typed-contract extension):** <what / where / time delta / NAMED capabilities unlocked>
288
+ **Gates check:** time-budget? missing dep? missing decision? empty foreclosed-future-list?
289
+ **Recommendation:** Path B (default) / Path A (because <named gate>)
290
+ ```
291
+
292
+ **Plan acceptance gate** — required before Phase 3 begins:
293
+
294
+ 1. **`plan-verify` (deterministic, Python stdlib)** — run grep-checkable rules over the plan:
295
+ ```bash
296
+ python3 <build-loop>/scripts/plan_verify.py <plan-file> --repo "$PWD" --json
297
+ ```
298
+ Catches: deletes/orphans contradicted by repo grep, internal numeric drift, route changes without evidence, package-state contradictions, missing markers, scope-split breadth.
299
+ - Exit 0 → continue to step 2.
300
+ - Exit 1 → revise the plan to clear each BLOCKER (or document an explicit override with rationale).
301
+ - Exit 2 → verifier error; log and continue with step 2 only.
302
+ 2. **`plan-critic` (non-deterministic)** — invoke the equivalent reviewer in your tool of choice with the plan + the JSON from step 1. Looks for: less-invasive alternatives considered, MECE quality of phase splits, marker adequacy across long passages, headline drift across sections. Findings cap at WARN — surface but do not auto-block.
303
+ 3. **Gaps readback (mandatory)** — run both steps above BEFORE presenting any plan. Prepend `✓ Plan gaps-checked: none` when both pass clean, or `⚠ Plan gaps: <N> — <each finding, marked resolved/surfaced>` when findings exist. The host is never asked "anything missing?" — the gaps-check result is always shown first.
304
+
305
+ Wire all three surfaces (`skills/build-loop/SKILL.md`, `agents/build-orchestrator.md`, this file) together when the gate evolves — phase-asymmetric updates have caused silent skips before.
306
+
307
+ ### Phase 3: Execute
308
+
309
+ - Dispatch parallel work for independent file groups
310
+ - Each worker gets minimal context + integration contract (what interfaces to implement) + an intent packet explaining how the subtask fits the north star + a MECE ownership packet defining owned files, non-owned files, interface contracts, and integration checkpoints
311
+ - If the host supports typed subagents, map read-only codebase questions to explorer-style agents and disjoint implementation slices to worker-style agents. If the host requires explicit user authorization for subagents, identify parallel-safe groups but execute locally unless the user asked for delegation, parallelization, workers, or a `--parallel` mode.
312
+ - **Single-entry routing (host-neutral):** every coding task enters through one build-loop invocation; the runtime auto-classifies intent (build / optimize / research / debug / test) and routes accordingly. The host does not pick a mode — classification is internal. This applies equally across coding hosts (Claude Code, Codex, Cursor, Gemini CLI, others).
313
+ - **Subagent scaling (host-neutral):** when the host supports parallel delegation (e.g. Codex with `--parallel` authorization), dispatch up to `scripts/parallelism.py effective_max_implementers()` workers — machine-aware cap, default 8, ceiling 12 — decomposing work into the maximum number of independent MECE chunks. The permission gate still applies: workers only on explicit `--parallel` / delegation authorization. When parallel delegation is unavailable, execute sequentially without asking.
314
+ - Do not delegate ambiguous product decisions, final integration, destructive git operations, push/deploy confirmation, or tasks whose result blocks the immediate next lead-session step.
315
+ - For UI work: follow established design system or sensible defaults (44px touch targets, 4.5:1 contrast). Every visible element must have meaning, working behavior, a clear user purpose, and a matching entry in the UI input/output contract.
316
+ - Surface pre-existing issues separately from new work. If an issue impacts users and is local to the current build, plan and fix it automatically; if too large/risky, log user impact and defer.
317
+ - Checkpoint after major integration points
318
+
319
+ **Implementer return contract (envelope):** every implementer subagent returns a structured envelope, not freeform prose. Required fields:
320
+
321
+ ```json
322
+ {
323
+ "status": "completed" | "blocked" | "failed",
324
+ "files_modified": ["path/to/file.ts", "..."],
325
+ "synthesis_attestation": {
326
+ "<dimension_name>": "applied" | "deviated" | "n/a",
327
+ "<dimension_name>": {"status": "applied", "claim": "<concrete value>"}
328
+ },
329
+ "novel_decisions": [
330
+ {"decision": "<one line>", "reasoning": "<why and what alternative>"}
331
+ ],
332
+ "commit_sha": "<sha or null>"
333
+ }
334
+ ```
335
+
336
+ The `synthesis_attestation` map MUST have one entry per dimension named in the plan's `synthesis_dimensions` block. `novel_decisions` is the recall-test field — synthesis-class decisions the implementer faced that weren't enumerated in the plan. Be honest; silent decisions defeat the purpose.
337
+
338
+ **Halt-and-ask backstop (`status: blocked`):** if an implementer encounters a synthesis-class decision NOT in the plan's `synthesis_dimensions` block, it returns `status: blocked` with the decision in `novel_decisions[]` instead of committing. The orchestrator routes each blocked decision to a thinking-tier resolver, stores resolutions in `state.json.novelDecisionResolutions[]`, and re-dispatches the implementer with resolutions appended to the brief. Hard-fail counter: 3 attempts. No new dependency required — this is a status-branch addition, not a state-machine framework.
339
+
340
+ ### Phase 4: Review
341
+
342
+ Seven ordered sub-steps; intermediate failures route to Iterate, final pass writes Report artifacts.
343
+
344
+ **Sub-step A — Critic (adversarial read-only)**: perform a read-only adversarial review of the diff — inline in the lead session, or via an authorized explorer when delegation is permitted. This is the independent-auditor pass: render one of four verdicts (`yay` approve / `nay` reject / `suggest_correction` / `look_again`) gathering context from intent, goal, PRD, constitution. Catch scope drift, missed edge cases, rubric violations before spending tokens on full validation. **When Assess flagged a risk-surface change** (new auth, network, persistence, secrets, or external-input surface), also run a security review in this sub-step against OWASP LLM/Agentic/Web top-10 — its critical/high findings feed the no-critical/high exit gate and are blocking. Strong-checkpoint findings route back to Execute (no iteration burn); guidance findings are logged.
345
+
346
+ **Sub-step A.5 — Synthesis-decision backstops (post-implementer-commit, runs before B):**
347
+
348
+ Two checkpoints fire automatically after every implementer commit on plans that declared a `synthesis_dimensions` block:
349
+
350
+ - **Phase 4.5a — `attestation_lint`** (deterministic): compares the implementer's `synthesis_attestation` envelope against the actual git diff for verifiable dimensions (placement, cta_tier, visual_weight). Catches silent drift between claim and code. Exit 1 escalates to user; exit 2 logs warning and proceeds; exit 0 silent. Subjective dimensions (copy_tone, empty_state) return `unverifiable` and route to 4.5b. Reference implementation: `scripts/attestation_lint.py` (Python stdlib, accepts strict α-style and permissive β-style claim shapes; `--strict-mode` reverts to α-only).
351
+ - **Phase 4.5b — `synthesis-critic`** (subjective, read-only critic): a code-tier critic agent reviews the diff against the plan's subjective synthesis dimensions (copy_tone, empty_state). Severity capped at WARN — never blocks. Output: `{verdict: "pass" | "flag", flagged: [{dimension, claimed, observed, reasoning}], notes}`. Skips when the diff touches no UI files (`*.tsx`/`*.jsx`/`*.vue`/`*.svelte`).
352
+
353
+ Both backstops are first-class on the code-tier (fan-out) implementer path where they catch some of the recall gap, and defense-in-depth on the thinking-tier path where they rarely fire.
354
+
355
+ **Sub-step B — Validate**: when the build touches UI, run build-loop's `ui-validator` first, then check the UI input/output contract for changed surfaces, code-based graders (test, lint, type, build), design-rule scanner, visual evidence capture, and LLM-as-judge for nuanced criteria. Every pass/fail has evidence. Use only headless/programmatic surfaces — never auto-open a viewer/dashboard. IBR's interactive viewer / persistent browser sessions stay explicit-only; **UI visual-verification** (BL-3) routes through `build-loop:ibr-bridge` as the primary verifier when the IBR plugin is installed (headless scan is a programmatic action), with `native-ax-driver` / `ui-validator` as fallback. Symbol-only checks (`nm`, `strings`, `otool`) are never a substitute for visual/AX verification on a UI chunk. Scorecard format:
356
+
357
+ | # | Criterion | Method | Result | Evidence |
358
+ |---|-----------|--------|--------|----------|
359
+ | 1 | Tests pass | code | PASS | exit 0, 47/47 |
360
+ | 2 | No lint errors | code | FAIL | 3 errors in auth.ts |
361
+
362
+ **Sub-step C — Optimize (opt-in)**: runs only when a mechanical metric exists and the user hasn't disabled it. 3-5 iterations polish. Uses autoresearch pattern: constrained scope + metric + atomic changes + commit-or-revert.
363
+
364
+ **Sub-step D — Fact-Check, Mock Scan, UX Triage, Coverage**: gates run in parallel.
365
+
366
+ - *Fact Check*: trace every rendered metric (%, $, score, count) to source. For UI work, walk the full rendered surface, not just changed files. Flag "always", "never", "100%", "guaranteed" — replace unless genuinely absolute.
367
+ - *UI Input/Output Contract Scan*: for UI work, trace every changed user input and system output to the plan contract. New gaps in component mapping, states, modality fallback, validation/security, or source traceability are blocking.
368
+ - *Mock Data Scan*: production paths only. Detect lorem ipsum, faker, hardcoded fake values, `Math.random()` in display, placeholder text. Classify blocking (renders to user) vs warning.
369
+ - *Architectural Violations* (if available): `navgator rules --json`. Blocking: circular-dependency, layer-violation, database-isolation, frontend-direct-db. Warning: hotspot, high-fan-out, orphan.
370
+ - *Plugin Cache Sync* (plugin work): resync the local cache when diverged. Defer version bumps until the feature batch is declared complete (see Version Advisor).
371
+ - *Version Advisor* (plugin work): `scripts/version_advisor.py` reads plugin manifest and last-bump SHA, counts commits since via Conventional Commits to propose semver. Default state is `hold` — a one-line note in Report. State `suggest` only when the user creates `.build-loop/release-pending.md`. Never auto-bumps; never blocks.
372
+ - *UX Triage* (UI work): `scripts/ux_triage.py` static-scans interactability, performance, data-accuracy, and usability across the full project. Each blocker/major finding becomes a queue entry in `.build-loop/ux-queue/<id>.md` with a complete fix plan. Agent-driven augmentation (performance, fact-check on broader surface) merges into the same queue.
373
+ - *Coverage Gap* (UI work): for each changed critical surface lacking render/interaction coverage, add a repo-native test-coverage queue entry with a proposed test plan. Do not auto-draft `.ibr-test.json` files.
374
+
375
+ Blocking gates route to Iterate. Queue entries flow into Phase 5's prioritized work list. Warnings land in Report.
376
+
377
+ **Sub-step E — Simplify**: trim the diff — inline single-use helpers, delete dead branches, remove validation for upstream-guaranteed invariants. Preserve public API, tests, observability, and modular boundaries that protect user value, scalability, accuracy, security, testability, or stable interfaces. If an integrated simplification is better, document `MODULARITY EXCEPTION`.
378
+
379
+ The default Simplify pass covers both dead-code removal and logic/architecture simplification: flatten deep nesting, apply DRY, eliminate accidental O(n²) patterns, remove redundant multi-pass sequences, and cut needless indirection — wherever the result is a clear behavior-preserving win. `scripts/complexity_detector.py` is a Python-specific AST accelerator that emits ranked hotspots (high complexity, deep nesting, accidental O(n²), redundant multi-pass, needless single-call-site indirection); the running agent reasons over the diff language-agnostically and applies the same logic to any file type without it. APPLY a simplification only when all three hold: it is a clear win, the existing test subset for the touched files still passes, and public signatures + observable behavior are unchanged (reuse the existing Validate + independent-auditor gates — no new safety machinery, no perf gate, no benchmark). Ambiguous or uncertain rewrites are emitted as advisory variances, never applied.
380
+
381
+ **Sub-step F — Auto-Resolve**: before writing the report, drain non-destructive open items instead of listing them as questions. Classify each remaining item with `scripts/autonomy_gate.py` (or the action classifier) and route by verdict: `auto` → fix now and continue; `warn` → apply and note (exit 0, never blocks); `confirm` → surface once to the user (production/irreversible only); `block` → do not run. Same-shape, same-intent follow-ups go to `.build-loop/followup/` and re-enter Iterate, not into the report as "should I keep going?" prose. The report lists only genuinely held (`confirm`/`block`) items.
382
+
383
+ **Sub-step G — Report** (only on final Review pass):
384
+ - **Scorecard** with final pass/fail per criterion + evidence
385
+ - **Verified** (working with evidence), **Unknown** (untested), **Unfixed** (post-cap)
386
+ - **Discovered issues**: pre-existing problems from assessment
387
+ - **Fact check results**: warnings from sub-step D
388
+ - **`## Self-modifications (readback)`** (self-recursive runs only, omit otherwise): one row per self-modification attempted this run — file, what/why, gate verdict, additional-review finding. This is how the human stays informed without the loop stopping. Full spec in `agents/build-orchestrator.md` §G.
389
+
390
+ Write scorecard to `.build-loop/evals/YYYY-MM-DD-<topic>-scorecard.md`. Append run entry to `.build-loop/state.json.runs[]` with `run_id`, phase statuses, files touched, diagnostic commands, manual interventions, active experimental artifacts.
391
+
392
+ **Milestone append (every run, append-only)**: immediately after the run entry is written, append a milestone record to `build-loop-memory/projects/<slug>/milestones.jsonl` — one line: what shipped + commit. This log is never rewritten; it is the permanent progress record. Phase 1's memory-staleness triage compares the latest milestone against HEAD and flags gaps before planning begins. Principle: append-only log + a pointer, never full-state rewritten in place.
393
+
394
+ **Steering-decision capture (mandatory bridge)**: immediately after any host equivalent of a steering confirmation (architecture direction, library/dependency choice, platform, product direction, license, or any `user_impact: major` decision), append the answer as a DECISION record to `build-loop-memory/projects/<slug>/decisions/`. Root cause closed: steering answers that live only in context are lost when the session ends; every such answer is a durable decision and must be persisted immediately.
395
+
396
+ Before any push/deploy, classify the exact command with `scripts/deployment_policy.py` when available. Follow the returned action: `auto` may run after Review passes; `confirm` requires explicit user confirmation in chat; `block` must not run. Defaults allow preview deploys and Xcode/App Store Connect/TestFlight upload/export flows, while production deploys, releases, publishes, protected-branch pushes, and unknown targets require confirmation.
397
+
398
+ ### Phase 5: Iterate
399
+
400
+ Build a prioritized work list per pass: (1) blocking Validate failures, (2) blocker UX queue entries with `architecture_impact: false`, (3) major UX queue entries with `architecture_impact: false`, (4) optimization findings, (5) UI coverage-gap queue entries. Entries with `architecture_impact: true` are deferred to Report for explicit user confirmation, NOT picked up here. Do not defer based on patch size — the only deferral signal is architecture impact.
401
+
402
+ Partition the list by disjoint `files_touched` and dispatch up to 4 parallel implementer subagents per pass (the standard cap). Sequential groups process after the parallel batch.
403
+
404
+ When the build touches UI files, after each implementer reports back AND before re-entering Sub-step B, run the build-loop UI re-validate hook against the affected route or screen. Catches new visual/interaction regressions cheaply.
405
+
406
+ For each fix:
407
+ 1. Diagnose root cause (not just symptoms)
408
+ 2. Use the queue entry's `proposed_fix` plan as the prompt (or, for Validate failures, create a targeted fix plan)
409
+ 3. Execute fix
410
+ 4. Loop back to Review sub-step B (Validate). Sub-step A usually skipped unless the fix touched new files.
411
+
412
+ **Followup overflow**: when iteration cap is reached and queue entries remain, write them to `.build-loop/followup/<topic>.md` for a subsequent build invocation. The followup build skips its own Plan phase for these entries (plans are already complete).
413
+
414
+ **Convergence rules:**
415
+ - If a criterion fails 3 times with the same root cause: escalate to user
416
+ - If fixing one criterion breaks another: stop, reassess approach
417
+ - If score doesn't improve after 2 consecutive iterations: change strategy, don't repeat
418
+ - **Hard stop at 5 iterations.** Proceed to Review sub-step G (Report) with remaining ❓ Unfixed.
419
+
420
+ Log iteration state to `.build-loop/state.json`.
421
+
422
+ ### Phase 6: Learn (mandatory; always runs and always reports)
423
+
424
+ Runs after Review sub-step G (Report) on **every** build. Cheap detector + `consolidate_memory.py` + `procedural_governance.py --mode detect-patterns` always fire. A `## Learn` outcome line is always emitted. Three outcome states:
425
+
426
+ - **Accruing** (`runs[] < 3`): cheap detector + consolidation only; report `Learn: accruing (N/3 runs)`.
427
+ - **Deferred** (debug-only `closeout: false` in dispatch envelope OR budget-exhausted `budget_check.py` envelope `action == "finalize_and_stop"` at Phase 6 entry): cheap detector + consolidation; write `.build-loop/proposals/learn-deferred-<run-id>.md` marker with `{reason, runs_count, budget_action}`; skip Sonnet draft + Opus signoff so Learn never blows the budget ceiling. Report `Learn: deferred — <reason>`.
428
+ - **Full** (`runs[] >= 3` AND pattern crossing threshold AND not-deferred): full flow below.
429
+
430
+ Full-flow steps:
431
+
432
+ - **Detect**: pattern detector scans (a) `state.json.runs[]` for recurring `phase_failure` + `manual_intervention` + `security_finding` signals, (b) `.build-loop/proposals/enforce-from-retro/*.md` for `enforce_recurrence` patterns (the same normalized candidate signature across ≥ 2 distinct run-ids — wires the post-push retrospective's enforce-candidates into Learn's cross-run detector).
433
+ - **Draft**: for each kept pattern, architect agent writes experimental SKILL.md with A/B Experiment section (sample target 8 non-confounded runs).
434
+ - **Signoff**: Opus reviews each draft; APPROVE / REVISE (1 retry) / DISCARD.
435
+ - **Sample sweep**: for existing experimental artifacts with sample complete, eligible for promotion (only when `autoPromote: true` config is set AND effective non-confounded sample ≥ 8 AND non-regression). Promotion to `active/` still requires explicit `/build-loop:promote-experiment <name>` user confirmation. Regressions and inconclusive results write proposals, never auto-delete.
436
+
437
+ User controls: `rm -rf .build-loop/skills/experimental/<name>/`, `.build-loop/skills/.demoted` blocklist. The prior `autoSelfImprove: false` opt-out is deprecated to a migration no-op — old configs do not error, but the value is logged as a one-line `state.json.warnings[]` entry and ignored.
438
+
439
+ ## Project Data
440
+
441
+ Build loop stores state in `.build-loop/` within the project directory:
442
+
443
+ ```
444
+ .build-loop/
445
+ ├── goal.md # Current build goal
446
+ ├── intent.md # North star, update intent, user value, non-goals
447
+ ├── config.json # Optional repo flags, including deploymentPolicy
448
+ ├── state.json # Iteration state, phase progress, structure summary
449
+ ├── feedback.md # Post-build lessons (one line per build)
450
+ ├── release-pending.md # User-created marker: "feature batch complete, advise version bump"
451
+ ├── ux-queue/ # UX-impacting findings with full fix plans (drained by Iterate)
452
+ │ └── <id>.md
453
+ ├── followup/ # Overflow when iteration cap hit; input to subsequent build
454
+ │ └── <topic>.md
455
+ ├── backlog/ # Deferred-but-wanted work (drained by end-of-run continuation)
456
+ │ └── <id>.md # frontmatter: title, created, classify, effort, status
457
+ ├── evals/ # Scorecard archives
458
+ │ └── YYYY-MM-DD-*.md
459
+ └── issues/ # Discovered issues (drained by end-of-run continuation)
460
+ ```
461
+
462
+ This directory is created on first use. Add `.build-loop/` to your project's `.gitignore`.
463
+
464
+ ### Phase D: Closeout
465
+
466
+ Runs by default at the end of every run (after Phase 6 Learn if it ran, otherwise immediately after Review sub-step G Report). Automated, not operator-discipline-dependent — skipping it leaves ghost-peer signals and locked worktrees that mislead the next run.
467
+
468
+ **Mandatory sequence:**
469
+
470
+ 1. Reap this session's presence: `scripts/rally_point/lifecycle.reap_my_sessions(channel_dir, my_session_id)`.
471
+ 2. Stop coordination watchers: SIGTERM any `coordination_watch.py --interval N` processes started during this run (PIDs tracked in `state.json.runs[N].watcherPids[]`).
472
+ 3. **Collapse branches and worktrees (merge winner first, then collapse):** for solo-on-main runs the work is already on `main` — nothing to merge. For multi-worktree runs, merge the winning/validated line(s) to `main` via the normal single-writer commit flow before calling collapse. Then run:
473
+ ```bash
474
+ python3 ${RUNTIME_PLUGIN_ROOT}/scripts/collapse_run.py --workdir "$PWD" --run-id latest --json
475
+ ```
476
+ The script normalizes `dispatchedWorktrees[]` + `riskyBranches[]` + `createdRefs[]` into one ref list, creates a `git bundle ... --all` under `.build-loop/bundles/` (reversibility), then per ref: MERGED → delete branch + remove worktree folder; UNMERGED+`review_hold` → keep branch ref, remove worktree folder (→ `kept_for_review`); UNMERGED+no-hold → keep branch ref, remove worktree folder (→ `surfaced_unmerged`). Output: `{run_id, bundle_path, deleted[], kept_for_review[], surfaced_unmerged[], errors[], dry_run}`. Fail-soft — errors logged, closeout continues.
477
+ 4. Archive the coordination file: move `.build-loop/coordination/<this-coord-file>.md` to `.build-loop/coordination/archived/`.
478
+ 5. Optional `changes.jsonl` rotation: `scripts/rally_point/lifecycle.rotate_changes_log(channel_dir, max_mb=1, max_entries=500)`.
479
+ 6. Final post: `post(kind="phase", payload={"phase": "run-closeout", ...})` signals to the channel that this run is done.
480
+ 7. Write `state.json.runs[N].closeout_status`.
481
+
482
+ **`## Branch hygiene` report block** — every run's final report includes:
483
+ ```
484
+ ## Branch hygiene
485
+ created N · merged-to-main M (deleted) · kept-for-review R: [<branch-name>, ...]
486
+ · surfaced-unmerged U: [<branch-name>, ...] (ask keep/discard) · bundle: <path>
487
+ ```
488
+ When a run created zero refs: `Branch hygiene: clean — no run-created branches/worktrees; on main.`
489
+
490
+ ## Post-Build
491
+
492
+ After every build, if something surprising happened, append one line to `.build-loop/feedback.md`:
493
+
494
+ ```
495
+ YYYY-MM-DD | what happened | what to do differently
496
+ ```
497
+
498
+ These entries are loaded during Phase 1 (Assess) of future builds to prevent repeating mistakes.