@tyroneross/build-loop 0.35.0 → 0.36.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/.agents/plugins/marketplace.json +1 -1
  2. package/.claude-plugin/marketplace.json +3 -3
  3. package/.claude-plugin/plugin.json +2 -2
  4. package/.codex-plugin/plugin.json +1 -1
  5. package/AGENTS.md +67 -14
  6. package/README.md +208 -299
  7. package/agents/advisor.md +2 -0
  8. package/agents/alignment-checker.md +2 -0
  9. package/agents/api-assessor.md +3 -1
  10. package/agents/architecture-scout.md +2 -0
  11. package/agents/assessment-orchestrator.md +2 -0
  12. package/agents/build-orchestrator.md +13 -8
  13. package/agents/database-assessor.md +107 -3
  14. package/agents/design-contract-specialist.md +2 -0
  15. package/agents/fact-checker.md +2 -0
  16. package/agents/fix-critique.md +26 -5
  17. package/agents/frontend-assessor.md +3 -1
  18. package/agents/implementer.md +2 -0
  19. package/agents/independent-auditor.md +2 -0
  20. package/agents/mock-scanner.md +2 -0
  21. package/agents/optimize-runner.md +2 -0
  22. package/agents/overfitting-reviewer.md +2 -0
  23. package/agents/performance-assessor.md +3 -1
  24. package/agents/plan-critic.md +2 -0
  25. package/agents/promotion-reviewer.md +2 -0
  26. package/agents/recurring-pattern-detector.md +4 -1
  27. package/agents/retrospective-synthesizer.md +14 -0
  28. package/agents/root-cause-investigator.md +39 -2
  29. package/agents/scope-auditor.md +2 -0
  30. package/agents/security-reviewer.md +3 -0
  31. package/agents/self-improvement-architect.md +2 -0
  32. package/agents/synthesis-critic.md +2 -0
  33. package/agents/transcript-pattern-miner.md +2 -0
  34. package/agents/ui-validator.md +2 -0
  35. package/assets/build-loop-plugin-icon.png +0 -0
  36. package/bin/build-loop-install.js +234 -0
  37. package/commands/run.md +1 -1
  38. package/hooks/git/pre-commit +40 -0
  39. package/hooks/git/pre-push +35 -10
  40. package/hooks/hooks.json +42 -5
  41. package/hooks/pre-edit-architecture.sh +2 -2
  42. package/hooks/route-guard.sh +15 -0
  43. package/hooks/route_guard.py +221 -0
  44. package/hooks/session-start-extensions.sh +10 -0
  45. package/hooks/session-start-git-hooks.sh +6 -1
  46. package/hooks/session-start-rally-point.sh +23 -1
  47. package/hooks/test_session_start_rally_version.sh +123 -0
  48. package/package.json +7 -2
  49. package/plugin-artifacts/codex/.codex-plugin/plugin.json +1 -1
  50. package/plugin-artifacts/codex/AGENTS.md +67 -14
  51. package/plugin-artifacts/codex/README.md +208 -299
  52. package/plugin-artifacts/codex/assets/build-loop-plugin-icon.png +0 -0
  53. package/plugin-artifacts/codex/references/backlog-system.md +285 -0
  54. package/plugin-artifacts/codex/references/capability-routing.md +49 -0
  55. package/plugin-artifacts/codex/references/coordination-rules.md +271 -2
  56. package/plugin-artifacts/codex/references/memory-systems.md +25 -2
  57. package/plugin-artifacts/codex/references/memory.md +14 -0
  58. package/plugin-artifacts/codex/references/model-tier-mapping.md +45 -6
  59. package/plugin-artifacts/codex/references/phase-1-assess.md +19 -1
  60. package/plugin-artifacts/codex/references/phase-2-plan.md +9 -1
  61. package/plugin-artifacts/codex/references/phase-3-execute.md +1 -1
  62. package/plugin-artifacts/codex/references/phase-4-review.md +20 -1
  63. package/plugin-artifacts/codex/references/phase-5-iterate.md +4 -3
  64. package/plugin-artifacts/codex/references/phase-6-learn.md +2 -0
  65. package/plugin-artifacts/codex/references/verify-dispatch.md +85 -0
  66. package/plugin-artifacts/codex/skills/build-loop/SKILL.md +19 -10
  67. package/plugin-artifacts/codex/skills/build-loop/fallbacks.md +1 -1
  68. package/plugin-artifacts/codex/skills/build-loop/references/capability-routing.md +49 -0
  69. package/plugin-artifacts/codex/skills/build-loop/references/experiment-results-template.md +101 -0
  70. package/plugin-artifacts/codex/skills/build-loop/references/memory.md +14 -0
  71. package/plugin-artifacts/codex/skills/build-loop/references/output-style.md +98 -5
  72. package/plugin-artifacts/codex/skills/build-loop/references/phase-1-assess.md +19 -1
  73. package/plugin-artifacts/codex/skills/build-loop/references/phase-2-plan.md +9 -1
  74. package/plugin-artifacts/codex/skills/build-loop/references/phase-3-execute.md +1 -1
  75. package/plugin-artifacts/codex/skills/build-loop/references/phase-4-review.md +20 -1
  76. package/plugin-artifacts/codex/skills/build-loop/references/phase-5-iterate.md +4 -3
  77. package/plugin-artifacts/codex/skills/build-loop/references/phase-6-learn.md +2 -0
  78. package/plugin-artifacts/codex/skills/build-loop/references/verify-dispatch.md +85 -0
  79. package/scripts/build_codex_plugin_artifact.py +7 -0
  80. package/scripts/embed_backend.py +17 -13
  81. package/scripts/lessons_index/query.py +1 -1
  82. package/scripts/memory_graph/__init__.py +2 -2
  83. package/scripts/sync_navgator_lessons.py +4 -4
  84. package/skills/api-registry-bridge/SKILL.md +1 -1
  85. package/skills/auto-decision-capture/SKILL.md +4 -3
  86. package/skills/auto-finding-capture/SKILL.md +119 -0
  87. package/skills/build-loop/SKILL.md +19 -10
  88. package/skills/build-loop/fallbacks.md +1 -1
  89. package/skills/build-loop/references/capability-routing.md +49 -0
  90. package/skills/build-loop/references/experiment-results-template.md +101 -0
  91. package/skills/build-loop/references/memory.md +14 -0
  92. package/skills/build-loop/references/output-style.md +98 -5
  93. package/skills/build-loop/references/phase-1-assess.md +19 -1
  94. package/skills/build-loop/references/phase-2-plan.md +9 -1
  95. package/skills/build-loop/references/phase-3-execute.md +1 -1
  96. package/skills/build-loop/references/phase-4-review.md +20 -1
  97. package/skills/build-loop/references/phase-5-iterate.md +4 -3
  98. package/skills/build-loop/references/phase-6-learn.md +2 -0
  99. package/skills/build-loop/references/verify-dispatch.md +85 -0
  100. package/skills/debug-loop/SKILL.md +4 -2
  101. package/skills/debugging-memory/SKILL.md +24 -12
  102. package/skills/{debugging/assess/SKILL.md → debugging-memory/references/assess.md} +6 -13
  103. package/skills/{debugging/memory/SKILL.md → debugging-memory/references/search.md} +10 -17
  104. package/skills/{debugging/store/SKILL.md → debugging-memory/references/store.md} +5 -13
  105. package/skills/debugging-memory/references/subagent-integration.md +3 -3
  106. package/skills/defenseclaw-bridge/SKILL.md +1 -1
  107. package/skills/{loop-builder → focused-loop-builder}/SKILL.md +6 -6
  108. package/skills/ibr-bridge/SKILL.md +1 -1
  109. package/skills/knowledge/SKILL.md +13 -2
  110. package/skills/{knowledge-review/SKILL.md → knowledge/references/review-mode.md} +8 -20
  111. package/skills/logging-tracer/SKILL.md +20 -4
  112. package/skills/model-bakeoff/SKILL.md +44 -0
  113. package/skills/model-tiering/SKILL.md +55 -20
  114. package/skills/optimize/SKILL.md +2 -2
  115. package/skills/prd-bridge/SKILL.md +1 -1
  116. package/skills/recursive-retrospective/SKILL.md +46 -0
  117. package/skills/recursive-retrospective/references/01-retrospective.md +136 -0
  118. package/skills/recursive-retrospective/references/02-learning-capture.md +72 -0
  119. package/skills/recursive-retrospective/references/03-judge.md +45 -0
  120. package/skills/research/SKILL.md +1 -1
  121. package/skills/root-cause-analysis/SKILL.md +42 -0
  122. package/skills/security-methodology/SKILL.md +10 -1
  123. package/skills/security-scan/SKILL.md +55 -0
  124. package/skills/spec-writing/SKILL.md +42 -1
  125. package/skills/sync-skills/SKILL.md +8 -7
  126. package/commands/assess.md +0 -41
  127. package/commands/compose-handoff.md +0 -113
  128. package/commands/debug.md +0 -20
  129. package/commands/debugger-detail.md +0 -34
  130. package/commands/debugger-scan.md +0 -15
  131. package/commands/debugger-status.md +0 -20
  132. package/commands/debugger.md +0 -32
  133. package/commands/optimize-run.md +0 -31
  134. package/commands/promote-experiment.md +0 -129
  135. package/commands/rally-point.md +0 -301
  136. package/commands/research-run.md +0 -22
  137. package/commands/review-knowledge.md +0 -16
  138. package/commands/self-review.md +0 -51
  139. package/commands/setup-memory.md +0 -32
  140. package/commands/start-prd.md +0 -57
  141. package/commands/test.md +0 -34
  142. package/commands/verify-plan.md +0 -39
  143. package/skills/debugging/debug-loop/SKILL.md +0 -231
  144. package/skills/logging-tracer-bridge/SKILL.md +0 -70
  145. /package/skills/{loop-builder → focused-loop-builder}/presets/active-project-evidence.yaml +0 -0
  146. /package/skills/{loop-builder → focused-loop-builder}/presets/generic-artifact-loop.yaml +0 -0
  147. /package/skills/{loop-builder → focused-loop-builder}/presets/presentation-audit.yaml +0 -0
  148. /package/skills/{loop-builder → focused-loop-builder}/presets/research-synthesis.yaml +0 -0
  149. /package/skills/{loop-builder → focused-loop-builder}/presets/source-ingestion-raw-data-audit.yaml +0 -0
  150. /package/skills/{loop-builder → focused-loop-builder}/references/spec-format.md +0 -0
  151. /package/skills/{loop-builder → focused-loop-builder}/scripts/loop_builder.py +0 -0
package/agents/advisor.md CHANGED
@@ -23,6 +23,8 @@ description: |
23
23
  assistant: "Dispatching the advisor agent in re-plan mode. It reads the failure evidence + the diff vs the current plan, diagnoses planning-miss vs execution-miss, and (on planning-miss) emits corrected instructions: a diff against the prior plan plus the evidence that justifies the change."
24
24
  </example>
25
25
  model: fable
26
+ tier: frontier
27
+ segment: generative_reasoning
26
28
  color: gold
27
29
  tools: ["Read", "Grep", "Glob", "Skill", "Write"]
28
30
  ---
@@ -15,6 +15,8 @@ description: |
15
15
  assistant: "alignment-checker reads intent.md non-goals, matches 'incremental migration only' against the proposal's 'wholesale rewrite' framing, returns verdict: misaligned with violated_non_goals populated. Orchestrator moves it to followup/."
16
16
  </example>
17
17
  model: sonnet
18
+ tier: code
19
+ segment: governance_evaluation
18
20
  color: yellow
19
21
  tools: ["Read", "Grep", "Glob"]
20
22
  ---
@@ -2,6 +2,8 @@
2
2
  name: api-assessor
3
3
  description: Use this agent when the debugging symptom involves API endpoints, REST/GraphQL errors, request/response issues, authentication, rate limiting, or server-side route handlers. Examples - "500 error", "endpoint not found", "auth failed", "CORS error".
4
4
  model: sonnet
5
+ tier: code
6
+ segment: agentic_execution
5
7
  color: yellow
6
8
  tools: ["Read", "Grep", "Bash"]
7
9
  ---
@@ -38,7 +40,7 @@ Determine which type of API issue:
38
40
  Check for similar past incidents with native build-loop debugging memory:
39
41
 
40
42
  ```
41
- Skill("build-loop:debugging-memory-search") with input { symptom: "<symptom>", domain: "api" }
43
+ Skill("build-loop:debugging-memory") with input { op: "search", symptom: "<symptom>", domain: "api" }
42
44
  ```
43
45
 
44
46
  Filter results for API incidents using tags:
@@ -2,6 +2,8 @@
2
2
  name: build-loop:architecture-scout
3
3
  description: Read-only architecture analyst. Dispatched by build-loop orchestrator with a task type ('baseline', 'chunk-impact', 'review-rules', 'iterate-subgraph', 'learn-sync'). Decides native engine vs NavGator escalation per task. Returns ≤500-word structured JSON envelope. Owns architecture-related side effects (violation capture, lessons sync).
4
4
  model: sonnet
5
+ tier: code
6
+ segment: agentic_execution
5
7
  tools: ["Read", "Grep", "Glob", "Bash"]
6
8
  ---
7
9
 
@@ -2,6 +2,8 @@
2
2
  name: assessment-orchestrator
3
3
  description: Use this agent when debugging requires multi-domain analysis, when the symptom is unclear about which domain is affected, or when you need to coordinate parallel assessments across database, frontend, API, and performance domains.
4
4
  model: opus
5
+ tier: thinking
6
+ segment: agentic_execution
5
7
  color: magenta
6
8
  tools: ["Read", "Grep", "Bash", "Task"]
7
9
  ---
@@ -3,6 +3,8 @@ name: build-orchestrator
3
3
  description: |
4
4
  Coordinates the 5-phase development loop for significant multi-step code changes (Assess → Plan → Execute → Review → Iterate, with optional Learn). Review runs seven ordered sub-steps: Critic → Validate → Optimize (opt-in) → Fact-Check → Simplify → Auto-Resolve → Report; Iterate loops back to Review on failure.
5
5
  model: opus
6
+ tier: thinking
7
+ segment: agentic_execution
6
8
  color: magenta
7
9
  tools: ["Read", "Write", "Edit", "Bash", "Glob", "Grep", "Agent", "Skill", "TaskCreate", "TaskUpdate", "TaskList", "AskUserQuestion"]
8
10
  ---
@@ -26,7 +28,7 @@ When the prompt opens with `PER_COMMIT_DISPATCH:`, this orchestrator owns ONE co
26
28
  Classify before starting:
27
29
 
28
30
  - **BUILD** (default): "build", "implement", "add", "create", "fix", "refactor", "migrate", "update" → full 5-phase loop.
29
- - **OPTIMIZE**: "optimize", "speed up", "reduce", "improve", or any mechanical metric → load `build-loop:optimize` skill, skip Phases 1–4. Standalone: `/build-loop:optimize-run`.
31
+ - **OPTIMIZE**: "optimize", "speed up", "reduce", "improve", or any mechanical metric → load `build-loop:optimize` skill, skip Phases 1–4. (No separate command — reached via `/build-loop:run` + optimize language.)
30
32
  - **RESEARCH**: "research", "investigate", "evaluate", "compare", "should I" → load `build-loop:research` skill, run Phase 1 only, output a research packet, stop. Standalone: `/build-loop:research-run`.
31
33
  - **TEST**: "test plugin", "validate plugin", "lint plugin", "verify manifest" → load `build-loop:plugin-tests` skill, static-analysis only, skip Phases 2–5. Standalone: `/build-loop:test`.
32
34
 
@@ -109,7 +111,8 @@ Full protocol: `references/phase-3-execute.md` — load before executing. Highli
109
111
  - Dispatch one subagent per independent task. Record `parallel_batch:` or `parallel_skipped_reason:` (Review-G lint enforces). Each brief carries: task description, file paths, integration contract, fallback snippets, intent packet, MECE ownership packet, `architecture_context:` block read verbatim from the cached `architecture-scout` result (do NOT re-dispatch the scout in Phase 3), `available_capabilities:` block. Implementers flag any out-of-slice change.
110
112
  - **MECE-packet lint** (advisory) before peer-handoff dispatch — `python3 scripts/brief_mece_validator.py --brief-file <tmpfile> --json`. **Brief-discipline guardrail**: (1) tool reachability — every named verifier MUST appear in the subagent's `tools:` frontmatter; (2) no symbol-only fallback for UI verification (`nm`/`strings`/`otool`/"compiles cleanly" never substitute for visual/AX verification).
111
113
  - Briefs follow `references/implementer-brief-template.md`. UI briefs include the contract section + `templates/ui-subagent-prompt.md`. Consult `model-router` per dispatch (see `references/capability-routing.md`).
112
- - **M1/M2/M3 + cost-ledger Step 9**: write subagent envelopes atomically, heartbeat working state, generate `task_id` via `scripts/dispatch_identity.py`, resolve the concrete model via `scripts/model_overrides.py`, and emit dispatch + return rows via `scripts/write_cost_ledger_row.py` sharing the same `--task-id`. Full procedure in `references/m-series-protocol.md`.
114
+ - **M1/M2/M3 + cost-ledger Step 9**: write subagent envelopes atomically, heartbeat working state, generate `task_id` via `scripts/dispatch_identity.py`, resolve the concrete model via the front door `scripts/resolve_agent_model.py <agent-name> --workdir "$PWD" --plain` (reads the agent's `(segment, tier)` ROLE from its frontmatter — the durable KEY into the model index — and reuses `scripts/model_resolver.py`: availability + host-reachability + the floor-respecting walk; the agent's `model:` line is only the index-derived fallback, kept fresh by `scripts/sync_agent_model_defaults.py`). Pass the result as the Agent tool's `model` parameter to OVERRIDE the frontmatter; if it returns `inherit` (e.g. `root-cause-investigator`), pass NO `model` override. Then emit dispatch + return rows via `scripts/write_cost_ledger_row.py` sharing the same `--task-id`. Full procedure in `references/m-series-protocol.md` (§M2.5 tier-resolution + dispatch-fallback contract).
115
+ - **Dispatch-fallback on model unavailability (M2.5 contract, MANDATORY)**: every agent is resolved through the front door `scripts/resolve_agent_model.py` (which reuses `model_resolver.py`), never by reasoning over a model name. If the `Agent(...)` call ERRORS with an unavailability signal (the error names a model as unavailable / down / not currently available — e.g. "Claude Fable 5 is currently unavailable"), do NOT surface it: call `python3 scripts/dispatch_fallback.py --workdir "$PWD" --tier <tier> --unavailable-model <down-model> --plain` (records the outage to `model-availability.json`, persistent + idempotent; returns the next available model respecting the tier floor — frontier never drops below thinking/Opus), then RE-DISPATCH with the returned model. The persisted record means the next resolve of that tier already returns the fallback. Clear with `dispatch_fallback.py --clear <model>` when the model is back. This is the mechanization of the standing "Frontier-unavailable → Thinking-tier (Opus) fallback, never Code tier" policy.
113
116
  - **Subagent-return handling**: decision-quality doctrine rules 2, 3, 7 bind — solicited review is not independent validation; spot-check the 2-3 load-bearing claims of every condensed return (re-derive cheaply); match verification depth to blast radius. Full text `references/decision-quality.md`.
114
117
  - **Commit step (single-writer)**: full protocol in `references/single-writer-commit-protocol.md`. Implementers don't `git add` / `git commit`; the orchestrator owns `.git/`. Sequence per envelope: context-snapshot pre_commit → verify-no-staged-residue → verify-scope → stage → commit (pre-commit hook runs; no `--no-verify`) → verify-landed → context-snapshot post_commit → attestation-lint → synthesis-critic (UI only) → independent-auditor advisory. Commit executes unconditionally (no operator confirmation). For `status: blocked`, see `references/halt-and-ask-protocol.md`.
115
118
  - **Dogfood reload checkpoint**: after a validated self-recursive stage touches runtime surfaces, run `scripts/dogfood_reload_checkpoint.py detect/create`; do not dispatch the next stage until expected tools ACK with runtime identity or a fallback (`reassign|defer|continue_solo`) is recorded. Full protocol: `references/dogfood-reload-checkpoint.md`.
@@ -123,7 +126,7 @@ Routing detail extracted to `references/phase-4-review.md`. Sub-step procedural
123
126
  - **A. Critic** — Trigger 3 coordination check; dispatch `independent-auditor` at build scope (+ `security-reviewer` when `triggers.riskSurfaceChange`, + second-vendor reviewer when `cross_vendor_required` and a peer host is reachable). **Auditor dispatch ladder (GAP-1 — the LLM auditor is never silently skipped):** Agent tool present → dispatch (`auditor_status: ran:dispatched-agent`); no Agent tool but a peer host reachable (rally / `codex exec`) → run the auditor as a peer process, reconcile its verdict into `.build-loop/judge-decisions.json` as `judge_id: "independent-auditor"` (`ran:peer-host(<host>)`); neither → `not-run:parent-must-dispatch` and the dispatching parent owes the audit. NEVER label inline self-audit as the `independent-auditor` (inline self-audit is not the independent auditor), and never report a `scope=build` code-touching run as `pass` without a real auditor verdict — set `outcome: partial` (the `write_run_entry --scope build` `review_completeness_error` exit 3 is the structural backstop). Full ladder + parent-dispatch contract in `references/phase-4-review.md` §"Sub-step A". Then dispatch `design-contract-specialist` (`trigger_point: phase4-review-a`) once with aggregated `design_doc_delta` + `schema_delta`.
124
127
 
125
128
  **Parent owes Phase 6 Learn + retrospective (mirror of the auditor ladder — E3).** A stop-early dispatched `build-orchestrator` (or per-commit orchestrator) that does not reach Phase 4 Review-G CANNOT run Phase 6 Learn or the post-push retrospective. Therefore the DISPATCHING PARENT owes them at the close of the dispatch-orchestration: before declaring the multi-dispatch effort done, the parent runs Phase 6 Learn (or records `Learn: deferred — <reason>`) and dispatches the retrospective-synthesizer. Like GAP-1, this is not optional and not silently droppable — name the owner at dispatch time.
126
- - **B. Validate** — `ui-validator`-first when `uiTarget != null`; UI input/output contract check; code graders; runtime smoke gate (`scripts/runtime_smoke.py` + SSE contract gate); pytest-collection gate (`scripts/pytest_collect_gate.py`); LLM-as-judge; plugin-tests advisory; memory-first gate on every failure.
129
+ - **B. Validate** — `ui-validator`-first when `uiTarget != null`; UI input/output contract check; code graders; **acceptance-probe re-run gate** (`scripts/acceptance_probe.py rerun` — gate #1; re-runs each Assess probe, `blocked` = probe still at baseline → cannot mark passed, cannot inline-defer, deferral routes through `autonomy_gate.py` as DECISION → `## Held`; skips cleanly on `no_probes`); runtime smoke gate (`scripts/runtime_smoke.py` + SSE contract gate); pytest-collection gate (`scripts/pytest_collect_gate.py`); LLM-as-judge; plugin-tests advisory; memory-first gate on every failure.
127
130
  - **C. Optimize** (opt-in) — only when a mechanical metric exists.
128
131
  - **D. Fact-Check** — `fact-checker` + `mock-scanner` (mock + public-surface privacy scan) + `architecture-scout (review-rules)` in parallel; plus Gates 6/7/8.
129
132
  - **E. Simplify** — `/simplify` on changed files; preserve API/tests/observability/user value. Default = remove dead code AND restructure over-complex logic into clearer behavior-preserving forms. `complexity_detector.py` is a Python accelerator, not a gate.
@@ -137,11 +140,11 @@ Routing detail extracted to `references/phase-4-review.md`. Sub-step procedural
137
140
  ```
138
141
  python3 scripts/report_lint.py <draft.md> --json
139
142
  → total==0: emit as-is
140
- → total>0: revise the draft ONCE per skills/build-loop/references/output-style.md (translate jargon, fix headline, add validation line, remove contrastive-pivots), re-run, emit (append a one-line "[warn] style-lint findings remain" to ## Done if any persist)
143
+ → total>0: revise the draft ONCE per skills/build-loop/references/output-style.md (translate jargon, fix headline, add validation line, remove contrastive-pivots, rewrite a mechanism-only lead into an outcome-first one per §"Outcome framing", and apply §"Precision and Brevity — sentence architecture" — actor+strong-verb+outcome spine, concrete nouns/verbs, data over adjectives/adverbs, direct cause→effect with because/suggesting, no invented numbers), re-run, emit (append a one-line "[warn] style-lint findings remain" to ## Done if any persist)
141
144
  → script error: append "[warn] style-lint skipped" and continue
142
145
  ```
143
146
 
144
- The lint enforces `skills/build-loop/references/output-style.md` (concise headline + validation line + jargon blocklist) on user-facing output only; internal envelopes stay structured.
147
+ The lint enforces `skills/build-loop/references/output-style.md` (concise headline + validation line + jargon blocklist) on user-facing output only; internal envelopes stay structured. Outcome framing (lead with the user outcome, not the mechanism) and precision-and-brevity (shorter words, data over adjectives, direct cause→effect, no invented numbers) are part of the same contract — both judgment-graded via the one-pass self-heal, not by the lint.
145
148
 
146
149
  ### Phase 5: Iterate (up to 5x classic, up to 25 autonomous)
147
150
 
@@ -168,11 +171,13 @@ When a phase needs a capability, see `references/capability-routing.md`. Trigger
168
171
 
169
172
  ## Model Tiering & Escalation
170
173
 
171
- Defaults (consult `Skill("build-loop:model-tiering")` for the canonical table): **orchestrator** = `opus` (coordination tier; alias tracks latest Opus); **Phase 2 Plan synthesis** = `fable` (Frontier — frame goal, draft spec/ADRs, F-criteria, MECE partition) **reached via the stakes-gated Advisor dispatch ladder** (`advisor` agent / peer host / already-Fable session), with an honestly-labeled inline-Opus fallback when no trigger fires or no dispatch path is reachable — the floor equals today's behavior (`references/advisor-dispatch-ladder.md`); **implementer** (Execute) = `sonnet`, `effort: medium`; **verification surface (Review-A / Review-D / Plan→Execute boundary / Phase 6 promotion)** = `fable` `plan-critic`, `scope-auditor`, `independent-auditor` (at `scope: "build"`, single source of truth, consolidated 2026-05-23), `fix-critique`, `fact-checker`, `security-reviewer` (when `triggers.riskSurfaceChange`), `overfitting-reviewer`, `promotion-reviewer`; **mock-scanner** (Review-D) = `haiku`; **recurring-pattern detector** (Learn) = `haiku`; **self-improvement architect** (Learndrafts, Fable signs off via `promotion-reviewer`) = `sonnet`; **deliberate Sonnet exceptions on the verification surface** = `alignment-checker` (called per queue item during autonomous iterate) and `synthesis-critic` (per-UI-commit WARN-only) — both advisory, non-gating, high-frequency.
174
+ The agent `(segment, tier)` ROLE is the durable KEY into the model index (`references/model-taxonomy.json`); each agent's `model:` is the index-derived recommended fallback (regenerated by `scripts/sync_agent_model_defaults.py`), and dispatch resolves the role LIVE via `scripts/resolve_agent_model.py` and overrides it (M2.5). The index is **user-editable and chat-maintainable**: on model intent in chat ("check the models", "is there a newer model", "use X for <role>", "change the <tier> model"), follow `Skill("build-loop:model-tiering")` §"Chat-triggered index maintenance"read/edit the index, classify a new model via `classify_model_tier.py` if needed, then `sync_agent_model_defaults.py --apply`.
172
175
 
173
- **Escalate to Opus** (respawn the subagent) on: 2 consecutive failures on the same chunk after `effort=high`; ambiguous spec; cross-file architectural decision mid-execution; critic flagged `strong-checkpoint`; novel error pattern; user-visible prose where tone matters. Log to `.build-loop/state.json.escalations`. If the surfaced ambiguity is a **planning miss** (the plan itself no longer fits) rather than an execution problem, route back to Phase 2 Fable re-plans, then execution resumes on Sonnet/Opus.
176
+ Defaults (consult `Skill("build-loop:model-tiering")` for the canonical table): **orchestrator** = `opus` (coordination tier; alias tracks latest Opus); **Phase 2 Plan synthesis** = `fable` (Frontier — frame goal, draft spec/ADRs, F-criteria, MECE partition) **reached via the stakes-gated Advisor dispatch ladder** (`advisor` agent / peer host / already-Fable session), with an honestly-labeled inline-Opus fallback when no trigger fires or no dispatch path is reachable — the floor equals today's behavior (`references/advisor-dispatch-ladder.md`); **implementer** (Execute) = `sonnet`, `effort: high` (Sonnet 5's coding/agentic gains land at `high`/`xhigh` per claude-api T1; `xhigh` on hard or code-heavy chunks); **verification surface (Review-A / Review-D / Plan→Execute boundary / Phase 6 promotion)** = `fable` — `plan-critic`, `scope-auditor`, `independent-auditor` (at `scope: "build"`, single source of truth, consolidated 2026-05-23), `fix-critique`, `fact-checker`, `security-reviewer` (when `triggers.riskSurfaceChange`), `overfitting-reviewer`, `promotion-reviewer`; **mock-scanner** (Review-D) = `haiku`; **recurring-pattern detector** (Learn) = `haiku`; **self-improvement architect** (Learn drafts, Fable signs off via `promotion-reviewer`) = `sonnet`; **deliberate Sonnet exceptions on the verification surface** = `alignment-checker` (called per queue item during autonomous iterate) and `synthesis-critic` (per-UI-commit WARN-only) both advisory, non-gating, high-frequency.
174
177
 
175
- **Dynamic tier assignment** (guide): judge each subtask's complexity adaptively. Priority order: **accuracy > speed > cost** never trade accuracy for cheaper/faster; among accuracy-equals prefer the faster path; optimize cost last. Prefer Sonnet (default workhorse for execution). Down-tier to Haiku only for trivial mechanical tasks. Opus subagents may accelerate genuinely complex execution subtasks. Fable is the default for planning + verification verdicts (see surface list above). For `model: inherit` agents pass the tier explicitly. Full guide: `references/model-tier-mapping.md` §"Dynamic tier assignment". **Verify every subagent's output before accepting it** cheaper tier stronger check; enforced by verify-scope / verify-landed (Phase 3 commit step), independent-auditor (Review-A), and each subagent's return envelope (`status: blocked | partial` routes to Iterate).
178
+ **Intermediate rung retry Sonnet 5 at `effort=xhigh` before paying for Opus.** On the *first* chunk failure that is an execution problem (not one of the judgment triggers below), respawn the *same* Sonnet 5 implementer at `effort=xhigh` — its top coding setting, near-Opus on code-shaped work at lower cost. **Escalate to Opus** (respawn the subagent) on: a 2nd consecutive failure on the same chunk *after the `effort=xhigh` retry*; OR immediately on a judgment trigger ambiguous spec; cross-file architectural decision mid-execution; critic flagged `strong-checkpoint`; novel error pattern; user-visible prose where tone matters (these skip the xhigh rungthey are not effort-limited). Log the rung taken to `.build-loop/state.json.escalations`. If the surfaced ambiguity is a **planning miss** (the plan itself no longer fits) rather than an execution problem, route back to Phase 2 Fable re-plans, then execution resumes on Sonnet/Opus.
179
+
180
+ **Dynamic tier assignment** (guide): judge each subtask's complexity adaptively. Priority order: **accuracy > speed > cost** — never trade accuracy for cheaper/faster; among accuracy-equals prefer the faster path; optimize cost last. Prefer Sonnet (default workhorse for execution). Down-tier to Haiku only for trivial mechanical tasks. Opus subagents may accelerate genuinely complex execution subtasks. Fable is the default for planning + verification verdicts (see surface list above). For `model: inherit` agents pass the tier explicitly. Full guide: `references/model-tier-mapping.md` §"Dynamic tier assignment". **Verify every subagent's output before accepting it** — cheaper tier → stronger check; enforced by verify-scope / verify-landed (Phase 3 commit step), independent-auditor (Review-A), and each subagent's return envelope (`status: blocked | partial` routes to Iterate). **After any dispatched agent (incl. background/`run_in_background`/headless) claims commits landed and tests passed, walk `skills/build-loop/references/verify-dispatch.md`** — the 5-step git/test ground-truth checklist (a solicited peer agreeing is not independent verification; run the commands yourself).
176
181
 
177
182
  ### Escalation Triggers
178
183
 
@@ -1,7 +1,9 @@
1
1
  ---
2
2
  name: database-assessor
3
- description: Use this agent when the debugging symptom involves database issues, queries, migrations, schema problems, Prisma errors, PostgreSQL, connection pooling, or data integrity. Examples - "slow query", "migration failed", "constraint error", "Prisma error", "connection timeout".
3
+ description: Use this agent when the debugging symptom involves database issues, queries, migrations, schema problems, Prisma errors, PostgreSQL, connection pooling, vector/retrieval indexes, or data integrity. Examples - "slow query", "migration failed", "constraint error", "Prisma error", "connection timeout", "vector search is stale".
4
4
  model: sonnet
5
+ tier: code
6
+ segment: agentic_execution
5
7
  color: cyan
6
8
  tools: ["Read", "Grep", "Bash"]
7
9
  ---
@@ -18,6 +20,39 @@ You are a database debugging specialist with expertise in:
18
20
  - Connection pooling and timeout problems
19
21
  - Data integrity and constraint violations
20
22
  - Index optimization and query planning
23
+ - Vector/retrieval index and ingestion correctness
24
+
25
+ ## Constitution Reference
26
+
27
+ When the symptom or requested design touches query planning, storage layout,
28
+ writes, migrations, indexing, vector search, retrieval, or data integrity, read
29
+ `references/database-agent-constitution.md` before generating the assessment.
30
+ Apply it as a diagnostic lens and populate all eight `constitution_check`
31
+ fields the constitution's "Required Assessment Fields" section requires:
32
+ `invariants`, `reused_primitives`, `new_dependencies`, `tradeoffs`,
33
+ `failure_modes`, `tests`, `substrate_boundary`, and `governance`.
34
+ `substrate_boundary` is **mandatory** — always name which store is canonical
35
+ truth, which stores are derived indexes/caches, and which layer is memory
36
+ policy; never leave it blank. The other seven may be `"none"` only when
37
+ genuinely not applicable. Do not expand into implementation unless the
38
+ orchestrator explicitly assigns an implementation task.
39
+
40
+ When the symptom or requested design touches Supabase, RLS, exposed schemas,
41
+ Data API access, Supabase Auth, Storage policies, database functions, or
42
+ `service_role` usage, also apply the constitution's "Supabase And RLS Addendum"
43
+ and include a `supabase_security_check` object in the assessment. If current
44
+ Supabase docs or changelog access is available, check it before making
45
+ security-sensitive claims and cite that the recommendation was docs-verified.
46
+ If docs access is unavailable, say so and treat any remembered Supabase behavior
47
+ as needing verification.
48
+
49
+ An optional advisory accelerator exists: `scripts/db_substrate_lint.py
50
+ --workdir <target-repo> --json` greps a consumer repo for two clear,
51
+ low-false-positive patterns (version-less embedding/retrieval rows or cache
52
+ keys; AI-visible artifacts lacking a metadata record) and cites the
53
+ constitution rule + seeding evidence per finding. It is WARN-only and wired
54
+ into no blocking gate — use it to seed `substrate_boundary` and retrieval
55
+ findings, never as a substitute for the assessor's semantic judgment.
21
56
 
22
57
  ## Your Core Responsibilities
23
58
 
@@ -35,13 +70,23 @@ Determine which type of database issue:
35
70
  - **Schema/migration**: migration errors, constraint violations
36
71
  - **Connection**: pool exhaustion, timeouts, disconnects
37
72
  - **Data integrity**: duplicates, foreign key violations, corrupted data
73
+ - **Vector/retrieval**: stale indexes, ingestion replay errors, incorrect
74
+ top-k results, cache/index divergence, reranker/filter mismatch
75
+ - **Supabase/RLS security**: exposed schema access, missing or decorative RLS,
76
+ broad `anon`/`authenticated` grants, unsafe functions/views, default privilege
77
+ drift, service-role leakage, or Data API access that disagrees with the
78
+ intended authorization model
79
+
80
+ ### Step 1b: Required destructive-FK / data-integrity sweep (LO-5)
81
+
82
+ On any security-relevant or schema-touching pass, **enumerate destructive foreign-key actions** — grep the schema for `onDelete: Cascade` and `onDelete: SetNull`, plus merge/delete code paths that destroy rather than reassign rows, and missing FK indexes. A cascade that silently deletes user data is an integrity/security finding **even when every route is authed** — the access-control lens (`security-reviewer`) does not catch it, so this sweep is required, not optional. Pair with the `security-reviewer`'s route-auth enumeration; neither lens is a superset (proven both ways, atomize-ai 2026-06-30). Present findings blast-radius-first (see `Skill("build-loop:security-methodology")` §Required sweeps).
38
83
 
39
84
  ### Step 2: Search Memory
40
85
 
41
86
  Check for similar past incidents with native build-loop debugging memory:
42
87
 
43
88
  ```
44
- Skill("build-loop:debugging-memory-search") with input { symptom: "<symptom>", domain: "database" }
89
+ Skill("build-loop:debugging-memory") with input { op: "search", symptom: "<symptom>", domain: "database" }
45
90
  ```
46
91
 
47
92
  Filter results for database-related incidents using tags:
@@ -64,6 +109,23 @@ For connection issues:
64
109
  - Review timeout settings
65
110
  - Look for connection leaks
66
111
 
112
+ For Supabase/RLS security issues:
113
+ - Inventory exposed schemas and Data API settings when available.
114
+ - Verify RLS coverage for every exposed-schema table.
115
+ - Check schema usage and object privileges for `anon`, `authenticated`, and
116
+ `service_role`; do not treat RLS as a substitute for object access review.
117
+ - Check default privileges for all object-creating roles, including
118
+ `postgres`, `supabase_admin`, and migration roles.
119
+ - Search for `SECURITY DEFINER`, generic SQL executors, security-definer views,
120
+ materialized views exposed through the API, and functions with public
121
+ `EXECUTE`.
122
+ - Identify whether leaked `service_role`, database passwords, or provider keys
123
+ require rotation as part of containment.
124
+ - Require live verification evidence: catalog queries plus anonymous REST/API
125
+ probes against protected resources.
126
+ - Record residual actions separately when the connected role cannot change an
127
+ owner-only setting such as another role's default privileges.
128
+
67
129
  ### Step 4: Generate Assessment
68
130
 
69
131
  Return a structured JSON assessment:
@@ -76,7 +138,30 @@ Return a structured JSON assessment:
76
138
  "probable_causes": ["cause1", "cause2"],
77
139
  "recommended_actions": ["action1", "action2"],
78
140
  "related_incidents": ["INC_xxx", "INC_yyy"],
79
- "search_tags": ["tag1", "tag2"]
141
+ "search_tags": ["tag1", "tag2"],
142
+ "constitution_check": {
143
+ "invariants": ["invariant1"],
144
+ "reused_primitives": ["primitive1"],
145
+ "new_dependencies": ["dependency1 or none"],
146
+ "tradeoffs": ["read/write/space/ops/failure tradeoff"],
147
+ "failure_modes": ["failure mode and recovery path"],
148
+ "tests": ["invariant-level test"],
149
+ "substrate_boundary": "canonical: <store>; derived indexes/caches: <list>; memory policy: <layer> (MANDATORY — never blank)",
150
+ "governance": ["permission/lineage/retention/deletion/audit control, or none"]
151
+ },
152
+ "supabase_security_check": {
153
+ "applies": true,
154
+ "docs_checked": "yes | no | unavailable | not_applicable",
155
+ "exposed_schemas": ["schema1"],
156
+ "rls_coverage": "all_exposed_tables_enabled | gaps:<details> | unknown",
157
+ "object_grants": "anon/auth/service_role grant posture and gaps",
158
+ "default_privileges": "future object grant posture and owner-only residuals",
159
+ "privileged_functions_or_views": ["finding or none"],
160
+ "service_role_and_secret_rotation": "needed | not_needed | unknown, with reason",
161
+ "live_rest_probe_result": "protected resources deny anon/auth as expected, or gaps",
162
+ "advisor_findings": ["blocking/advisory findings or none"],
163
+ "residual_risks": ["owner/dashboard/manual action still required, or none"]
164
+ }
80
165
  }
81
166
  ```
82
167
 
@@ -102,12 +187,31 @@ Return a structured JSON assessment:
102
187
  - Incorrect constraint order
103
188
  - Missing rollback handling
104
189
 
190
+ ### Supabase/RLS Security Issues
191
+ - RLS enabled on tables but `anon`/`authenticated` still have unintended schema
192
+ or object access
193
+ - RLS policies that check only `TO authenticated` without row ownership
194
+ - `SECURITY DEFINER` functions or views in exposed schemas callable by broad
195
+ roles
196
+ - Default privileges that re-open future tables, sequences, or functions after
197
+ current objects are fixed
198
+ - Leaked `service_role` keys or database passwords treated as code-only fixes
199
+ instead of credential-rotation incidents
200
+ - REST/API probes skipped, leaving catalog-only verification unproven
201
+
105
202
  ### Connection Problems
106
203
  - Pool exhaustion from unclosed connections
107
204
  - Long-running transactions holding connections
108
205
  - Network timeouts to database server
109
206
  - Incorrect connection string
110
207
 
208
+ ### Vector/Retrieval Problems
209
+ - Derived index or cache diverged from the canonical store
210
+ - Non-idempotent ingestion duplicated or dropped records
211
+ - Filter, reranker, or top-k merge path disagrees with stored metadata
212
+ - Missing fallback when a hot cache or index is unavailable
213
+ - Manifest/version update is not atomic with segment/index writes
214
+
111
215
  ## Example Assessment
112
216
 
113
217
  For symptom: "Search API is taking 10+ seconds"
@@ -21,6 +21,8 @@ description: |
21
21
  assistant: "I'll dispatch design-contract-specialist with the architecture-scout `schema-map` envelope's `schema_delta`. It updates `.build-loop/app-contract/data.md` and refreshes the schema half of `traceability.json`."
22
22
  </example>
23
23
  model: sonnet
24
+ tier: code
25
+ segment: agentic_execution
24
26
  color: teal
25
27
  tools: ["Read", "Write", "Edit", "Grep", "Glob", "Bash", "Skill"]
26
28
  ---
@@ -15,6 +15,8 @@ description: |
15
15
  assistant: "I'll use the fact-checker agent to trace each metric to its source."
16
16
  </example>
17
17
  model: fable
18
+ tier: frontier
19
+ segment: governance_evaluation
18
20
  color: yellow
19
21
  tools: ["Read", "Grep", "Glob"]
20
22
  ---
@@ -2,6 +2,8 @@
2
2
  name: fix-critique
3
3
  description: Use this agent to pressure-test a proposed fix before declaring a bug resolved. Challenges whether the fix addresses the root cause or just a symptom, checks for potential regressions, and verifies evidence exists for the claimed fix. Run after a fix is implemented but before declaring it done.
4
4
  model: fable
5
+ tier: frontier
6
+ segment: governance_evaluation
5
7
  color: yellow
6
8
  tools: ["Read", "Grep", "Glob"]
7
9
  ---
@@ -12,23 +14,26 @@ You are a fix critique specialist. Your job is to pressure-test proposed bug fix
12
14
 
13
15
  ## Your Core Responsibilities
14
16
 
17
+ > **Durable post-failure RCA:** for the blameless durable-lever pass (creation+escape paths, action-strength hierarchy, lever+actuator, regression artifact, spread check), delegate to the shared `references/root-cause-analysis/` suite. This skill/agent finds and fixes the live issue; that suite is the post-failure prevention layer.
18
+
15
19
  1. Challenge whether the fix addresses the root cause or just a symptom
16
20
  2. Check for potential regressions and side effects
17
21
  3. Verify that evidence exists for the claimed fix
18
22
  4. Ensure the causal tree is consistent
19
23
  5. Deliver a clear verdict: APPROVED or CHALLENGED
20
24
 
21
- ## The 5 Checks
25
+ ## The 6 Checks
22
26
 
23
- Every fix must pass all 5 checks. Each check produces a PASS or FAIL with reasoning.
27
+ Every fix must pass all 6 checks. Each check produces a PASS or FAIL with reasoning.
24
28
 
25
- ### Check 1: Root Cause vs Symptom
29
+ ### Check 1: Root Cause vs Symptom (with counterfactual)
26
30
 
27
- **Question**: Does this fix address the root cause, or does it just suppress the symptom?
31
+ **Question**: Does this fix address the root cause, or does it just suppress the symptom — and would it have actually caught THIS failure?
28
32
 
29
33
  How to evaluate:
30
34
  - Read the fix diff — what code was actually changed?
31
35
  - Compare against the stated root cause — does the change directly address it?
36
+ - **Counterfactual test (FAIL if absent or fails):** confirm the fix carries a one-line counterfactual — "if this lever had existed, it would have prevented/detected/contained this failure" — and that the lever fires on the *real* reproduction, not a hand-constructed input. A fix whose control is "actionable" but dormant on the real signal (a rule/gate that exists yet never fires on the actual shape that triggered the bug) is a FAIL.
32
37
  - Watch for symptom-level fixes disguised as root cause fixes:
33
38
 
34
39
  | Symptom Fix (Bad) | Root Cause Fix (Good) |
@@ -90,11 +95,22 @@ How to evaluate:
90
95
  - Are there gaps in the chain where assumptions replace evidence?
91
96
  - If no causal tree exists, flag that the root cause wasn't systematically investigated
92
97
 
98
+ ### Check 6: Fix Strength
99
+
100
+ **Question**: Is this the strongest *feasible* control, or did it default to a weaker rung?
101
+
102
+ How to evaluate:
103
+ - Place the fix on the strength ladder (strongest first): **eliminate → impossible-state → automated-block → detect → contain → decision-support → docs**.
104
+ - A fix that "adds a detect-gate" when the invalid state could have been made unrepresentable at the writer (impossible-state) is weaker than feasible — FLAG it. PASS only if the chosen rung is the strongest feasible one, or a stronger rung is documented as infeasible.
105
+ - Reject any dependency-handling that reads as "ignore it" — it must be isolate / validate / monitor / degrade / escalate / accept-residual-risk-explicitly.
106
+
107
+ This check is advisory-strict: FAIL only when a clearly-stronger rung was both feasible and skipped without reason; otherwise PASS and note the suggested stronger control in `recommendations`.
108
+
93
109
  ## Verdict
94
110
 
95
111
  ### APPROVED
96
112
 
97
- All 5 checks pass. The fix:
113
+ All 6 checks pass. The fix:
98
114
  - Addresses the root cause directly
99
115
  - Covers related symptoms
100
116
  - Has low regression risk
@@ -141,6 +157,11 @@ One or more checks fail. Include:
141
157
  "check": "causal_tree_consistency",
142
158
  "result": "PASS | FAIL",
143
159
  "reasoning": "..."
160
+ },
161
+ {
162
+ "check": "fix_strength",
163
+ "result": "PASS | FAIL",
164
+ "reasoning": "Strongest feasible rung chosen, or weaker rung justified"
144
165
  }
145
166
  ],
146
167
  "concerns": [
@@ -2,6 +2,8 @@
2
2
  name: frontend-assessor
3
3
  description: Use this agent when the debugging symptom involves React, hooks, rendering, UI components, state management, hydration errors, or client-side performance. Examples - "useEffect infinite loop", "component not rendering", "hydration mismatch", "state not updating".
4
4
  model: sonnet
5
+ tier: code
6
+ segment: agentic_execution
5
7
  color: green
6
8
  tools: ["Read", "Grep", "Glob"]
7
9
  ---
@@ -38,7 +40,7 @@ Determine which type of frontend issue:
38
40
  Check for similar past incidents with native build-loop debugging memory:
39
41
 
40
42
  ```
41
- Skill("build-loop:debugging-memory-search") with input { symptom: "<symptom>", domain: "frontend" }
43
+ Skill("build-loop:debugging-memory") with input { op: "search", symptom: "<symptom>", domain: "frontend" }
42
44
  ```
43
45
 
44
46
  Filter results for frontend incidents using tags:
@@ -2,6 +2,8 @@
2
2
  name: implementer
3
3
  description: Apply a single ux-fix-plan.md (or per-criterion targeted fix plan) from the build-loop Phase 5 work list. One queue entry per invocation. Returns changed files + status. Designed for parallel fan-out (≤4 in flight per orchestrator pass).
4
4
  model: sonnet
5
+ tier: code
6
+ segment: agentic_execution
5
7
  tools: ["Read", "Write", "Edit", "Bash", "Glob", "Grep"]
6
8
  ---
7
9
 
@@ -15,6 +15,8 @@ description: |
15
15
  assistant: "Dispatching independent-auditor on HEAD~1..HEAD against the on-disk intent + PRD."
16
16
  </example>
17
17
  model: fable
18
+ tier: frontier
19
+ segment: governance_evaluation
18
20
  color: cyan
19
21
  tools: ["Read", "Grep", "Glob", "Bash"]
20
22
  ---
@@ -15,6 +15,8 @@ description: |
15
15
  assistant: "I'll use the mock-scanner agent to scan for residual mock data."
16
16
  </example>
17
17
  model: haiku
18
+ tier: pattern
19
+ segment: governance_evaluation
18
20
  color: cyan
19
21
  tools: ["Read", "Grep", "Glob"]
20
22
  ---
@@ -2,6 +2,8 @@
2
2
  name: optimize-runner
3
3
  description: Executes the optimization loop. Generates hypotheses, makes atomic changes within scope, measures metrics, keeps improvements or reverts regressions. Runs autonomously until convergence or budget exhaustion.
4
4
  model: sonnet
5
+ tier: code
6
+ segment: agentic_execution
5
7
  tools: ["Read", "Write", "Edit", "Bash", "Glob", "Grep"]
6
8
  ---
7
9
 
@@ -2,6 +2,8 @@
2
2
  name: overfitting-reviewer
3
3
  description: Reviews optimization results for overfitting, Goodhart violations, and test-gaming shortcuts. Read-only adversarial review.
4
4
  model: fable
5
+ tier: frontier
6
+ segment: governance_evaluation
5
7
  tools: ["Read", "Glob", "Grep"]
6
8
  ---
7
9
 
@@ -2,6 +2,8 @@
2
2
  name: performance-assessor
3
3
  description: Use this agent when the debugging symptom involves slowness, latency, timeouts, memory leaks, CPU usage, bottlenecks, or optimization needs. Examples - "app is slow", "memory keeps increasing", "timeout errors", "high CPU usage".
4
4
  model: sonnet
5
+ tier: code
6
+ segment: agentic_execution
5
7
  color: red
6
8
  tools: ["Read", "Grep", "Bash"]
7
9
  ---
@@ -39,7 +41,7 @@ Determine which type of performance issue:
39
41
  Check for similar past incidents with native build-loop debugging memory:
40
42
 
41
43
  ```
42
- Skill("build-loop:debugging-memory-search") with input { symptom: "<symptom>", domain: "performance" }
44
+ Skill("build-loop:debugging-memory") with input { op: "search", symptom: "<symptom>", domain: "performance" }
43
45
  ```
44
46
 
45
47
  Filter results for performance incidents using tags:
@@ -19,6 +19,8 @@ description: |
19
19
  assistant: "I'll dispatch plan-critic to surface scope-split overlaps, missing alternatives, and headline drift."
20
20
  </example>
21
21
  model: fable
22
+ tier: frontier
23
+ segment: governance_evaluation
22
24
  color: purple
23
25
  tools: ["Read", "Grep", "Glob"]
24
26
  ---
@@ -15,6 +15,8 @@ description: |
15
15
  assistant: "I'll run promotion-reviewer first to surface any policy variances, then present the verdict + diff for user confirmation."
16
16
  </example>
17
17
  model: fable
18
+ tier: frontier
19
+ segment: governance_evaluation
18
20
  color: purple
19
21
  tools: ["Read", "Grep", "Glob"]
20
22
  ---
@@ -15,6 +15,8 @@ description: |
15
15
  assistant: "I'll use the recurring-pattern-detector agent to produce a ranked candidate list."
16
16
  </example>
17
17
  model: haiku
18
+ tier: pattern
19
+ segment: generative_reasoning
18
20
  color: yellow
19
21
  tools: ["Read", "Glob", "Grep"]
20
22
  ---
@@ -36,7 +38,7 @@ Read `.build-loop/state.json`. The `runs` array contains entries like:
36
38
  "phases": {
37
39
  "1": { "status": "pass", "duration_s": 40 },
38
40
  "4": { "status": "pass", "duration_s": 300 },
39
- "5": { "status": "fail", "duration_s": 80, "root_cause": "type error in middleware", "attempts": 2 },
41
+ "5": { "status": "fail", "duration_s": 80, "root_cause": "type error in middleware", "root_cause_layer": "model-reasoning", "attempts": 2 },
40
42
  "6": { "status": "pass", "duration_s": 120 }
41
43
  },
42
44
  "diagnosticCommands": ["npm run type-check", "npm run lint --fix"],
@@ -89,6 +91,7 @@ Emit a pattern entry when ANY of these thresholds hit:
89
91
  | `phase_failure` | Same phase (1..8) fails ≥3 times across runs | phase id + top root_cause | Real rework signal: a repeatedly-failing phase costs iterations and model tokens. |
90
92
  | `manual_intervention` | Same note (or near-duplicate) at same phase ≥2 times | phase + canonical note | User time is the most expensive signal in the stack; two is sufficient. |
91
93
  | `security_finding` | Same OWASP/ASI/ATLAS risk ID appears in `security_findings[]` across ≥3 runs | mapped_risk ID + dominant severity | Recurring security risk class signals a project-shaped blind spot the implementer keeps re-introducing. A project-local rule catching it earlier is high-leverage. |
94
+ | `root_cause_layer` | Same `phases[].root_cause_layer` enum value appears across ≥3 DISTINCT runs | the layer enum + dominant phase | A layer recurring across runs (e.g. three `test-eval-gate` roots → fixtures are the systemic weak point) is a project-shaped blind spot that free-text `root_cause` cannot cluster. Same shape and bar as `security_finding`. Skip silently if no phase carries `root_cause_layer`. |
92
95
  | `enforce_recurrence` | Same normalized retro enforce-candidate signature appears across ≥2 DISTINCT run-ids in `.build-loop/proposals/enforce-from-retro/` | normalized candidate text (lowercased, whitespace-collapsed, first 120 chars) | The retro flagged it as worth enforcing in TWO separate runs — that is a real cross-session signal: anything prompted/needed repeatedly should become a default. Threshold matches `manual_intervention` (≥2) for the same "expensive signal" rationale. Confidence: high at ≥4 distinct run-ids; medium at 2–3. |
93
96
 
94
97
  ### Removed (were present in v0.1.0)
@@ -15,6 +15,8 @@ description: |
15
15
  assistant: "I'll use the retrospective-synthesizer agent with --run-id bl-20260604T213054Z-claude_code-827367 to regenerate the retro from the transcript + state.json."
16
16
  </example>
17
17
  model: sonnet
18
+ tier: code
19
+ segment: generative_reasoning
18
20
  color: green
19
21
  tools: ["Read", "Edit", "Bash", "Grep", "Glob"]
20
22
  ---
@@ -118,6 +120,18 @@ When you elaborate causal trees in section 9 during Step 2 enrichment:
118
120
  - Name the missing system control (a check, gate, default, schema constraint, contract).
119
121
  - Do NOT phrase the cause as agent error ("the agent should have caught this"). The agent IS the system; the missing control is the systems issue.
120
122
  - Cite the issue evidence (line in transcript, judge verdict, iterate-failure record).
123
+ - **Meta-cause synthesis.** When **≥3 issues share a suspected single root cause**, name the ONE meta-cause and recommend ONE preflight family — do not file N disconnected enforce-candidates. (Worked example: a placeholder secret nearly deployed, a gitignored CI config absent, and a subagent miscount all reduce to "trusted asserted state over actual state" → one verify-state preflight family.) The shared-root signal is also a "contested-meaning" trigger; see *Conditional depth* below.
124
+
125
+ # Conditional depth — recursive-learning lenses (opt-in, default OFF)
126
+
127
+ The 9 sections are the default and are sufficient for bounded execution / infra / audit runs. **Do NOT add sections.** Only when the run is **contested-meaning** — ANY of: (a) the product/feature is pre-public or at an architecture-direction decision point, (b) the run recommends redirect/reset on a major area, (c) ≥3 issues share a suspected single root cause — additionally apply these four lenses, each folded into an EXISTING section as enrichment bullets:
128
+
129
+ 1. **Project-maturity posture** → *Key takeaways*: one line — preserve / refine / redirect / reset — with the reason, and an explicit "from-scratch redesign NOT warranted" when the work is shipped/validated (guards against over-redesign).
130
+ 2. **Spec → current → desired gap** → *Lessons learned*: name any gap between intent, what shipped, and the desired end state that the pass/fail outcome hides (e.g. a v1 tradeoff with a deferred hardening successor).
131
+ 3. **Counterfactual intervention-savings** → *What could be done better*: quantify which tool-calls/questions a preflight would have removed — AND state which human gates would remain (never propose automating a production/irreversible gate away).
132
+ 4. **Emergent meta-cause** → *Issues §9*: the single root behind clustered near-misses (see the meta-cause rule above).
133
+
134
+ Evidence for keeping this gated rather than always-on: a head-to-head judge test (decision `0095` in build-loop-memory) found only 4 of the deep 16-section format's sections net-new-useful on a bounded run; the rest restated the standard 9. When the `recursive-retrospective` skill is available, invoke it for the FULL pipeline on contested-meaning runs instead of inlining these four lenses.
121
135
 
122
136
  # Output discipline
123
137