@tyroneross/build-loop 0.30.3 → 0.34.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 (170) hide show
  1. package/.agents/plugins/marketplace.json +2 -2
  2. package/.claude-plugin/marketplace.json +4 -4
  3. package/.claude-plugin/plugin.json +1 -1
  4. package/.codex-plugin/plugin.json +1 -1
  5. package/AGENTS.md +9 -0
  6. package/README.md +8 -7
  7. package/agents/advisor.md +111 -0
  8. package/agents/alignment-checker.md +11 -0
  9. package/agents/assessment-orchestrator.md +1 -1
  10. package/agents/build-orchestrator.md +28 -33
  11. package/agents/fact-checker.md +1 -1
  12. package/agents/fix-critique.md +1 -1
  13. package/agents/independent-auditor.md +1 -1
  14. package/agents/overfitting-reviewer.md +1 -1
  15. package/agents/plan-critic.md +5 -4
  16. package/agents/promotion-reviewer.md +1 -1
  17. package/agents/retrospective-synthesizer.md +20 -3
  18. package/agents/scope-auditor.md +1 -1
  19. package/agents/security-reviewer.md +1 -1
  20. package/agents/self-improvement-architect.md +1 -1
  21. package/commands/{handoff.md → compose-handoff.md} +4 -4
  22. package/commands/{optimize.md → optimize-run.md} +1 -1
  23. package/commands/{agent-rally-point.md → rally-point.md} +3 -3
  24. package/commands/{research.md → research-run.md} +1 -1
  25. package/commands/setup-memory.md +32 -0
  26. package/commands/{plan-verify.md → verify-plan.md} +1 -1
  27. package/docs/agent-surface-policy.md +38 -20
  28. package/docs/memory-setup.md +19 -14
  29. package/hooks/_resolve_python.sh +28 -0
  30. package/hooks/closeout.sh +58 -0
  31. package/hooks/git/pre-push +69 -6
  32. package/hooks/hooks.json +34 -13
  33. package/hooks/post-push-closeout.sh +73 -0
  34. package/hooks/session-start-closeout.sh +69 -0
  35. package/hooks/session-start-memory.sh +27 -0
  36. package/hooks/session-start-plugin-heal.sh +33 -0
  37. package/hooks/test_closeout.sh +124 -0
  38. package/package.json +7 -4
  39. package/plugin-artifacts/codex/.codex-plugin/plugin.json +41 -0
  40. package/plugin-artifacts/codex/AGENTS.md +499 -0
  41. package/plugin-artifacts/codex/BUILD-ARTIFACT.md +5 -0
  42. package/plugin-artifacts/codex/LICENSE +202 -0
  43. package/plugin-artifacts/codex/README.md +404 -0
  44. package/plugin-artifacts/codex/docs/agent-surface-policy.md +63 -0
  45. package/plugin-artifacts/codex/references/advisor-dispatch-ladder.md +62 -0
  46. package/plugin-artifacts/codex/references/agent-role-taxonomy.md +101 -0
  47. package/plugin-artifacts/codex/references/autonomous-and-per-commit-modes.md +161 -0
  48. package/plugin-artifacts/codex/references/autonomy-config.md +231 -0
  49. package/plugin-artifacts/codex/references/capability-routing.md +182 -0
  50. package/plugin-artifacts/codex/references/codex-subagents.md +106 -0
  51. package/plugin-artifacts/codex/references/coordination-file-template.md +181 -0
  52. package/plugin-artifacts/codex/references/coordination-rules.md +283 -0
  53. package/plugin-artifacts/codex/references/dogfood-reload-checkpoint.md +112 -0
  54. package/plugin-artifacts/codex/references/halt-and-ask-protocol.md +102 -0
  55. package/plugin-artifacts/codex/references/implementer-envelope-schema.md +302 -0
  56. package/plugin-artifacts/codex/references/intent-capability-pack.md +257 -0
  57. package/plugin-artifacts/codex/references/intent-exploration-prompts.md +96 -0
  58. package/plugin-artifacts/codex/references/leadership.md +72 -0
  59. package/plugin-artifacts/codex/references/memory-systems.md +238 -0
  60. package/plugin-artifacts/codex/references/memory.md +297 -0
  61. package/plugin-artifacts/codex/references/model-tier-mapping.md +257 -0
  62. package/plugin-artifacts/codex/references/modular-systems-pack.md +96 -0
  63. package/plugin-artifacts/codex/references/phase-1-assess.md +231 -0
  64. package/plugin-artifacts/codex/references/phase-2-plan.md +77 -0
  65. package/plugin-artifacts/codex/references/phase-3-execute.md +47 -0
  66. package/plugin-artifacts/codex/references/phase-4-review.md +320 -0
  67. package/plugin-artifacts/codex/references/phase-5-iterate.md +71 -0
  68. package/plugin-artifacts/codex/references/phase-6-learn.md +56 -0
  69. package/plugin-artifacts/codex/references/recent-design-structures.md +274 -0
  70. package/plugin-artifacts/codex/references/research-trigger-policy.md +140 -0
  71. package/plugin-artifacts/codex/references/runtime-smoke-triggers.md +42 -0
  72. package/plugin-artifacts/codex/references/self-review.md +234 -0
  73. package/plugin-artifacts/codex/references/single-writer-commit-protocol.md +90 -0
  74. package/plugin-artifacts/codex/references/task-capture-policy.md +68 -0
  75. package/plugin-artifacts/codex/references/ui-io-contract.md +116 -0
  76. package/plugin-artifacts/codex/references/ui-spotcheck-protocol.md +65 -0
  77. package/plugin-artifacts/codex/skills/build-loop/SKILL.md +372 -0
  78. package/plugin-artifacts/codex/skills/build-loop/detect-plugins.mjs +82 -0
  79. package/plugin-artifacts/codex/skills/build-loop/eval-guide.md +65 -0
  80. package/plugin-artifacts/codex/skills/build-loop/fallbacks.md +549 -0
  81. package/plugin-artifacts/codex/skills/build-loop/phases/fact-check.md +42 -0
  82. package/plugin-artifacts/codex/skills/build-loop/phases/ui-validation.md +267 -0
  83. package/plugin-artifacts/codex/skills/build-loop/references/advisor-dispatch-ladder.md +62 -0
  84. package/plugin-artifacts/codex/skills/build-loop/references/apple-native-planning.md +439 -0
  85. package/plugin-artifacts/codex/skills/build-loop/references/autonomous-and-per-commit-modes.md +161 -0
  86. package/plugin-artifacts/codex/skills/build-loop/references/capability-routing.md +182 -0
  87. package/plugin-artifacts/codex/skills/build-loop/references/codex-subagents.md +106 -0
  88. package/plugin-artifacts/codex/skills/build-loop/references/coordination.md +161 -0
  89. package/plugin-artifacts/codex/skills/build-loop/references/correction-aware-capture.md +177 -0
  90. package/plugin-artifacts/codex/skills/build-loop/references/independent-auditor.md +72 -0
  91. package/plugin-artifacts/codex/skills/build-loop/references/intent-capability-pack.md +257 -0
  92. package/plugin-artifacts/codex/skills/build-loop/references/intent-exploration-prompts.md +96 -0
  93. package/plugin-artifacts/codex/skills/build-loop/references/leadership.md +72 -0
  94. package/plugin-artifacts/codex/skills/build-loop/references/memory.md +297 -0
  95. package/plugin-artifacts/codex/skills/build-loop/references/modular-systems-pack.md +96 -0
  96. package/plugin-artifacts/codex/skills/build-loop/references/output-style.md +129 -0
  97. package/plugin-artifacts/codex/skills/build-loop/references/pay-it-forward-arch.md +98 -0
  98. package/plugin-artifacts/codex/skills/build-loop/references/phase-1-assess.md +231 -0
  99. package/plugin-artifacts/codex/skills/build-loop/references/phase-2-plan.md +77 -0
  100. package/plugin-artifacts/codex/skills/build-loop/references/phase-3-execute.md +47 -0
  101. package/plugin-artifacts/codex/skills/build-loop/references/phase-4-review.md +320 -0
  102. package/plugin-artifacts/codex/skills/build-loop/references/phase-5-iterate.md +71 -0
  103. package/plugin-artifacts/codex/skills/build-loop/references/phase-6-learn.md +56 -0
  104. package/plugin-artifacts/codex/skills/build-loop/references/recent-design-structures.md +274 -0
  105. package/plugin-artifacts/codex/skills/build-loop/references/refactor-history/ASSESSMENT.md +85 -0
  106. package/plugin-artifacts/codex/skills/build-loop/references/refactor-history/STANDALONE_TEST_RUN.md +149 -0
  107. package/plugin-artifacts/codex/skills/build-loop/references/refactor-history/scenarios/01-simple-bugfix.md +32 -0
  108. package/plugin-artifacts/codex/skills/build-loop/references/refactor-history/scenarios/02-ui-build-with-iteration.md +48 -0
  109. package/plugin-artifacts/codex/skills/build-loop/references/refactor-history/scenarios/03-multi-failure-escalation.md +60 -0
  110. package/plugin-artifacts/codex/skills/build-loop/references/refactor-history/scenarios/04-ui-build-ibr-absent.md +51 -0
  111. package/plugin-artifacts/codex/skills/build-loop/references/refactor-history/scenarios/05-refactor-navgator-absent.md +71 -0
  112. package/plugin-artifacts/codex/skills/build-loop/references/refactor-history/scenarios/06-recurring-bug-debugger-absent.md +52 -0
  113. package/plugin-artifacts/codex/skills/build-loop/references/refactor-history/trace-comparison.md +202 -0
  114. package/plugin-artifacts/codex/skills/build-loop/references/self-recursive-dev.md +77 -0
  115. package/plugin-artifacts/codex/skills/build-loop/references/self-review.md +234 -0
  116. package/plugin-artifacts/codex/skills/build-loop/references/ui-io-contract.md +116 -0
  117. package/plugin-artifacts/codex/skills/build-loop/scanners/audit-design-rules.mjs +476 -0
  118. package/plugin-artifacts/codex/skills/build-loop/scanners/require-visual-evidence.mjs +239 -0
  119. package/plugin-artifacts/codex/skills/build-loop/templates/backlog-item.md +35 -0
  120. package/plugin-artifacts/codex/skills/build-loop/templates/codex-worker-prompt.md +96 -0
  121. package/plugin-artifacts/codex/skills/build-loop/templates/ui-subagent-prompt.md +179 -0
  122. package/plugin-artifacts/codex/skills/build-loop/templates/ux-fix-plan.md +40 -0
  123. package/scripts/_paths.py +59 -13
  124. package/scripts/build_codex_plugin_artifact.py +314 -0
  125. package/scripts/check_cache_sync.py +1 -1
  126. package/scripts/install_memory.py +11 -3
  127. package/scripts/prune_plugin_cache.py +225 -11
  128. package/scripts/sync_navgator_lessons.py +25 -0
  129. package/scripts/sync_plugin_cache.py +66 -36
  130. package/skills/agent-rally-point/SKILL.md +1 -1
  131. package/skills/agent-rally-watcher/SKILL.md +1 -1
  132. package/skills/build-loop/SKILL.md +11 -155
  133. package/skills/build-loop/references/advisor-dispatch-ladder.md +62 -0
  134. package/skills/build-loop/references/autonomous-and-per-commit-modes.md +161 -0
  135. package/skills/build-loop/references/capability-routing.md +4 -3
  136. package/skills/build-loop/references/codex-subagents.md +8 -0
  137. package/skills/build-loop/references/coordination.md +1 -1
  138. package/skills/build-loop/references/intent-capability-pack.md +88 -1
  139. package/skills/build-loop/references/memory.md +17 -2
  140. package/skills/build-loop/references/phase-1-assess.md +13 -0
  141. package/skills/build-loop/references/phase-2-plan.md +1 -1
  142. package/skills/build-loop/references/phase-4-review.md +12 -0
  143. package/skills/build-loop/references/phase-6-learn.md +1 -1
  144. package/skills/build-loop/references/self-review.md +4 -2
  145. package/skills/build-loop/templates/codex-worker-prompt.md +41 -34
  146. package/skills/handoff/SKILL.md +3 -3
  147. package/skills/loop-builder/SKILL.md +98 -0
  148. package/skills/loop-builder/presets/active-project-evidence.yaml +97 -0
  149. package/skills/loop-builder/presets/generic-artifact-loop.yaml +95 -0
  150. package/skills/loop-builder/presets/presentation-audit.yaml +96 -0
  151. package/skills/loop-builder/presets/research-synthesis.yaml +96 -0
  152. package/skills/loop-builder/presets/source-ingestion-raw-data-audit.yaml +96 -0
  153. package/skills/loop-builder/references/spec-format.md +80 -0
  154. package/skills/loop-builder/scripts/loop_builder.py +346 -0
  155. package/skills/model-tiering/SKILL.md +65 -40
  156. package/skills/optimize/SKILL.md +2 -2
  157. package/skills/plan-verify/SKILL.md +1 -1
  158. package/skills/plugin-builder/references/distribution.md +8 -0
  159. package/skills/research/SKILL.md +33 -6
  160. package/skills/runtime-parity-verification/SKILL.md +51 -0
  161. package/skills/spec-writing/SKILL.md +19 -0
  162. package/templates/memory/README.md +65 -0
  163. package/templates/memory/charter.md.template +46 -0
  164. package/templates/memory/manifest.json +24 -4
  165. package/codex-skills/debug-loop/SKILL.md +0 -18
  166. package/codex-skills/handoff/SKILL.md +0 -22
  167. package/codex-skills/knowledge/SKILL.md +0 -21
  168. package/codex-skills/optimize/SKILL.md +0 -18
  169. package/codex-skills/research/SKILL.md +0 -18
  170. /package/commands/{knowledge-review.md → review-knowledge.md} +0 -0
@@ -0,0 +1,302 @@
1
+ <!-- SPDX-FileCopyrightText: 2025-2026 Tyrone Ross, Jr <46267523+tyroneross@users.noreply.github.com> | SPDX-License-Identifier: Apache-2.0 -->
2
+
3
+ # Implementer Envelope Schema — Canonical Contract
4
+
5
+ This document defines the **canonical return envelope** every build-loop implementer (Mode A fan-out subagent or Mode B inline self-call) MUST populate. The orchestrator and `scope-auditor` parse implementer output against this schema; missing required fields cause the orchestrator to mark the commit as **malformed** and either request a revision or quarantine the diff.
6
+
7
+ Per-brief envelope shapes (round-1 through round-3) are deprecated. New briefs reference this schema by path; legacy shapes are accepted by the orchestrator only when the brief was written before this schema landed.
8
+
9
+ ## Required top-level fields
10
+
11
+ | Field | Type | Description |
12
+ |---|---|---|
13
+ | `branch` | string | Git branch the implementer worked on. |
14
+ | `commit_sha` | string | SHA of the implementer's commit, OR the literal `"pending"` if the implementer didn't commit (canonical case under Hard rule 4 — orchestrator commits). |
15
+ | `files_changed` | array of paths | Authoritative list of paths the orchestrator should stage and commit. Absolute or repo-relative; be consistent. |
16
+ | `loc_added` | integer | Lines added across `files_changed`. `0` when none. |
17
+ | `loc_removed` | integer | Lines removed across `files_changed`. `0` when none. |
18
+ | `f_criteria` | object | Map of F-criterion ID → `"pass"` or `"fail"`. Every F-criterion named in the brief MUST appear. |
19
+ | `synthesis_attestation` | object | For each dimension named in the plan's `synthesis_dimensions` block, value is `"applied"`, `"deviated"`, or `"n/a"`. If `"deviated"`, the value MUST be an object `{"status": "deviated", "deviation_reason": "<why>"}`. **Empty object `{}` is allowed when the plan has no `synthesis_dimensions` block** (e.g. methodology commits, infra-only commits). |
20
+ | `novel_decisions` | array | Array of decision objects (schema below). Empty array `[]` is OK, **but the field MUST be present**. Implementers add an entry whenever they make a synthesis-class decision NOT enumerated in the plan's `synthesis_dimensions`. When the novel decision is **architectural-class** (where a phase lives, defensive contract shape, error-propagation policy, persistence boundary, etc.), the implementer MUST halt and set `status: "blocked"` (see below) rather than guess. **Each entry MUST include `recommended_default` and `confidence`** so the orchestrator can auto-pick in long-mode and surface trade-offs to the operator in normal-mode. See "novel_decisions[] entry schema" below. |
21
+ | `decision_ledger` | array | **Required when the plan has a `synthesis_dimensions` block.** Empty array `[]` is permitted only when the plan has no `synthesis_dimensions` block. Each entry MUST contain all six fields: `dimension` (string — matches a key in `synthesis_attestation`), `owner` (`"plan"` or `"implementer"`), `locked_value` (string — concrete value chosen), `alternatives_rejected` (array of strings, or `["none considered"]`), `evidence_file` (repo-relative path, or `null` when `owner == "implementer"` AND the decision is non-code), `on_new_decision` (enum: `"block" \| "flag" \| "absorb"`; default `"block"` for `risk_reason`-tagged chunks, `"flag"` otherwise). See `## decision_ledger in detail` below. |
22
+ | `notes` | string | Free-text. ≤200 words. Judgment calls, surprises, deferred concerns. |
23
+ | `wall_clock_seconds` | number | End-to-end implementer wall-clock duration. Orchestrator uses this for tier-mix telemetry. |
24
+ | `task_id` | string | Per-dispatch unique identifier echoed from the orchestrator's `[TASK_ID: <id>]` prompt prefix. Format: `t-<8-hex-chars>`. The orchestrator generates this before dispatch and writes one row per dispatch to `~/.bookmark/cost-ledger.jsonl` via `scripts/write_cost_ledger_row.py`. The implementer MUST echo it back unmodified so the row's completed-at update can be correlated against its dispatched-at row. Missing field = malformed envelope. If the brief omits the `[TASK_ID: …]` prefix (legacy briefs), return `task_id: "unknown"`. |
25
+ | `status` | string | Optional for routine Phase 3 Execute commits (legacy). REQUIRED when the implementer halts on an architectural-class novel decision: set `status: "blocked"` and return early without committing. See "status enum" below. |
26
+ | `capabilities_used` | array of strings | **Additive (Step 7 / audit §5.E).** IDs of `available_capabilities[]` entries from the brief that the implementer actually invoked during this chunk. Empty array `[]` when none were used. The orchestrator joins this against the cost-ledger row and surfaces credit-assignment telemetry in Phase 4 Report. Backward-compat: legacy envelopes that omit the field are accepted; the parser treats absence as `[]`. |
27
+ | `capabilities_rejected` | array of objects | **Additive (Step 7 / audit §5.E).** Capabilities from `available_capabilities[]` the implementer considered but did NOT use, with a short reason. Shape per entry: `{"id": "<capability_id>", "reason": "<one-sentence why-not>"}`. Empty array `[]` when none were considered-and-rejected. Powers the self-improvement-architect's Phase 6 credit-assignment pattern detector: a capability rejected with the same reason across N chunks is a signal the registry entry needs revision. |
28
+ | `downstream_iterate_outcome` | string or null | **Additive (Step 7 / audit §5.E).** Set by the orchestrator AFTER this commit's downstream Phase 5 Iterate cycle closes (the implementer leaves this `null`; the orchestrator backfills via `write_run_entry.py`). Enum: `"clean"` (no Iterate needed), `"resolved-on-pass-1"`, `"resolved-on-pass-2-or-later"`, `"overflow-to-followup"`, `"abandoned"`. Used by Phase 6 Learn to attribute commit-time decisions to their downstream verification outcomes. Backward-compat: legacy envelopes omit this; the parser treats absence as `null`. |
29
+ | `merge_plan` | object or null | **Additive (R2 Wave 1).** Required by the orchestrator's final report when 2+ chunks/worktrees are in flight; optional in per-implementer envelopes as a merge suggestion. Shape: `{"clean_against": ["<sha-or-branch>"], "conflicts_with": ["<chunk-id>"], "suggested_order": ["<chunk-id>", "..."], "merge_rationale": "<one sentence>"}`. The report writer lint blocks missing `clean_against`, `conflicts_with`, or `suggested_order` on multi-chunk reports. |
30
+
31
+ **Contract:** missing required fields = malformed envelope. Use empty/null sentinels (`""`, `0`, `[]`, `{}`) for absent data; **do not omit keys**. The orchestrator's parser distinguishes "field absent" (malformed) from "field present but empty" (legitimate).
32
+
33
+ ## Optional fields (legacy compatibility)
34
+
35
+ The following round-1/round-3 fields remain accepted but are no longer required. When the orchestrator commits on the implementer's behalf, it populates these fields itself:
36
+
37
+ - `commit_subject`, `commit_body` — used by Mode A orchestrator-commits flow.
38
+ - `verifications` — `{typecheck, lint, adjacent_tests, re_grep}` map; recommended but not required.
39
+ - `intentional_non_fixes` — list of in-scope items the implementer chose not to fix; recommended for v2-pattern briefs.
40
+ - `status` — enum: `fixed | partial | blocked | scope_breach | deferred_architecture | plan_malformed | evidence_stale | needs_dependency | failed | concurrent_modification_detected | completed`. Required for Phase 5 Iterate fix-plan implementers and for the **halt-and-ask** Phase 3 path (see "status enum" below). Optional for routine Phase 3 Execute commits (the orchestrator infers `completed` from a clean envelope with no `blocked` signal).
41
+
42
+ ## status enum — full contract
43
+
44
+ | Value | When | Implementer behavior | Orchestrator routing |
45
+ |---|---|---|---|
46
+ | `completed` / `fixed` | Routine success — all `f_criteria` either pass or are honestly marked fail | Modify working tree, return envelope with `commit_subject` + `commit_body`. Do NOT commit. | Orchestrator commits per Phase 3 commit step. |
47
+ | `partial` | Fixed M of N evidence lines; remainder needs human judgment | Same as `fixed`; document remainder in `notes`. | Commit and route remainder to Iterate. |
48
+ | `blocked` | **Halt-and-ask: encountered an architectural-class synthesis decision NOT in plan's `synthesis_dimensions`** | Add the decision(s) to `novel_decisions[]` with full reasoning. **Do NOT commit. Do NOT make the decision.** Return early with `status: "blocked"`. `commit_sha: ""`, `files_changed: []` (or partial set if work was done before the block was hit — orchestrator will reset). | Orchestrator dispatches each `novel_decisions[]` entry to the configured **Thinking-tier** resolver (per `references/model-tier-mapping.md`). Resolutions stored in `state.json.novelDecisionResolutions[]`; implementer is re-dispatched with resolutions appended to its brief. Hard-fail counter N=3 per chunk. |
49
+ | `scope_breach` | Fix needs a file outside `files_touched` | Return with `needed_file` + `why`. | Orchestrator decides whether to extend scope. |
50
+ | `deferred_architecture` | Plan's `architecture_impact: true` flag set | Refuse implementation; return immediately. | Routes to user confirmation in Review-F. |
51
+ | `plan_malformed` / `evidence_stale` / `needs_dependency` / `failed` | See `agents/implementer.md` "Failure modes" table | Return with the diagnostic field(s) named there. | Re-plan, retry, or escalate per protocol. |
52
+ | `concurrent_modification_detected` | A `files_touched` file was modified by something other than this implementer | Return immediately. | Indicates MECE-partition bug; orchestrator investigates. |
53
+
54
+ **`blocked` is distinct from `scope_breach`.** Scope breach is a file-system question ("the fix needs a file I don't own"). Blocked is a synthesis question ("the fix needs an architectural decision the plan didn't make"). Both halt the implementer; they route to different resolvers.
55
+
56
+ ### When `blocked` is the right call (vs. logging a `novel_decisions` entry and proceeding)
57
+
58
+ The C3 attestation lint catches deterministic synthesis drift; the C4 synthesis-critic catches subjective UI-tone drift. Together they cover most synthesis-class decisions. **Architectural-class decisions** fall outside both — `attestation_lint.py` has nothing to grep for, and `synthesis-critic` only fires on UI files. C5 catches those.
59
+
60
+ Block when the missing decision is one of:
61
+
62
+ - **Where a phase or responsibility lives** (orchestrator vs. implementer; client vs. server; sync vs. async). E.g. "the plan says route the resolved decisions back to the implementer, but doesn't say whether the orchestrator stores resolutions before or after the re-dispatch."
63
+ - **Defensive contract shape.** Whether to fail-closed or fail-open on a backend outage; whether a missing field is a malformed envelope or a legitimate empty.
64
+ - **Error-propagation policy.** Re-throw vs. swallow vs. wrap in a domain error; route to Iterate vs. mark as ❓ Unfixed.
65
+ - **Persistence boundary.** Where new state lives (state.json vs. a new file vs. memory-only); whether it survives a process restart.
66
+ - **Hard-fail counter or retry limit.** When to give up.
67
+
68
+ Do NOT block on routine synthesis decisions the lint/critic already cover (placement, cta_tier, visual_weight, copy_tone, empty_state) — log them in `novel_decisions[]` and proceed; the orchestrator + scope-auditor will route them appropriately at commit time.
69
+
70
+ When in doubt: block. A wasted Thinking-tier resolution is cheaper than a wrong architectural decision shipped to the diff.
71
+
72
+ ## synthesis_attestation in detail
73
+
74
+ The `synthesis_dimensions` block was added in C1 (`feat(spec-writing): synthesis_dimensions checklist item`). Plans now enumerate the synthesis-class decisions an implementer is expected to apply (e.g. "uses repo's existing pagination convention", "reuses Toast component for error states", "matches existing API error shape"). The implementer attests against each named dimension:
75
+
76
+ - `"applied"` — implementer made the synthesis decision exactly as the plan named it.
77
+ - `"deviated"` — implementer deviated from the named synthesis call, with a reason. Use the object form `{"status": "deviated", "deviation_reason": "<one sentence>"}`.
78
+ - `"n/a"` — the dimension wasn't reachable from this commit's scope (e.g. a UI-only commit attesting to a backend pagination dimension).
79
+
80
+ If the implementer finds itself making a synthesis-class decision that the plan didn't name, the implementer MUST halt that decision path and add the decision to `novel_decisions` instead of attesting silently. The orchestrator and `scope-auditor` then decide whether to extend the plan's `synthesis_dimensions` (route to plan-revise) or accept the novel decision (route to commit).
81
+
82
+ ## decision_ledger in detail
83
+
84
+ The `decision_ledger` array was added in C5 (`feat(envelope): require decision_ledger when synthesis_dimensions present`). While `synthesis_attestation` records *what the implementer claimed* about each dimension, `decision_ledger` records *why each value was chosen* — creating an audit trail that survives the commit log.
85
+
86
+ **Required when:** the originating plan contains a `synthesis_dimensions:` block. Every dimension listed in `synthesis_attestation` must have a corresponding `decision_ledger` entry (matched by the `dimension` field).
87
+
88
+ **Permitted absent:** when the plan has no `synthesis_dimensions:` block. In that case, omit the field entirely OR provide an empty array `[]`. Both are valid.
89
+
90
+ **Per-entry fields (all six required):**
91
+
92
+ | Field | Type | Rule |
93
+ |---|---|---|
94
+ | `dimension` | string | Must match a key in `synthesis_attestation` for this envelope. |
95
+ | `owner` | `"plan"` or `"implementer"` | `"plan"` = the value was prescribed by the plan's `synthesis_dimensions` block. `"implementer"` = discovered or chosen during execution. |
96
+ | `locked_value` | string | The concrete value chosen (e.g. `"secondary"`, `"after '<SummaryRow>' in path/to/file"`). Never a status word like `"applied"`. |
97
+ | `alternatives_rejected` | array of strings | At least one alternative considered. Use `["none considered"]` only when there was genuinely a single viable option and documenting that is itself informative. |
98
+ | `evidence_file` | string or `null` | Repo-relative path to the file where the decision manifests in code. `null` is allowed only when `owner == "implementer"` AND the decision is non-code (e.g. a copy-tone choice with no diff file). For `owner == "plan"` decisions, `null` triggers a WARN from the attestation lint. |
99
+ | `on_new_decision` | enum string | One of `"block" \| "flag" \| "absorb"`. Controls what happens if a *new* undeclared decision of the same class is encountered during a future re-dispatch. Default: `"block"` for chunks tagged `risk_reason`; `"flag"` otherwise. |
100
+
101
+ **Lint behavior (`--check-ledger`):** the attestation lint enforces that (a) every `synthesis_attestation` dimension has a ledger entry, (b) all six fields are present and non-empty (except `evidence_file` per the `null` rule above), and (c) `on_new_decision` is one of the three enum values. See `scripts/attestation_lint.py` `--check-ledger` flag.
102
+
103
+ ## novel_decisions[] entry schema
104
+
105
+ Each entry in `novel_decisions[]` is a decision the implementer surfaced to the orchestrator. The orchestrator routes the decision per `references/halt-and-ask-protocol.md` (mode-aware: auto-pick in long-mode, surface trade-offs in normal-mode).
106
+
107
+ **Required fields per entry:**
108
+
109
+ | Field | Type | Rule |
110
+ |---|---|---|
111
+ | `decision_id` | string | Stable identifier within the chunk (e.g. `"d1"`, `"cache_strategy"`). Used as the dedupe key in `state.json.runs[].autonomousDefaults[]`. |
112
+ | `decision` | string | One-sentence statement of the question. Plain language. |
113
+ | `options` | array of objects | At least one option. Each option has the option-object schema below. |
114
+ | `recommended_default` | string | The `id` of the option the implementer recommends. Must be present and match one of the `options[].id` values. Cannot be omitted — if the implementer cannot recommend, set `confidence: "low"` and pick its best guess; the orchestrator will escalate. |
115
+ | `confidence` | `"high" \| "med" \| "low"` | How sure the implementer is about `recommended_default`. **`low` always escalates**, even in long-mode — the implementer is saying "I cannot pick well." |
116
+ | `reasoning` | string | Why the implementer recommends `recommended_default`. Cite plan rubric IDs or constitution rules where applicable. |
117
+
118
+ **Option-object schema (each entry in `options[]`):**
119
+
120
+ | Field | Type | Rule |
121
+ |---|---|---|
122
+ | `id` | string | Short identifier (e.g. `"A"`, `"cache"`, `"fetch"`). Used as the value of `recommended_default` and `state.json.runs[].autonomousDefaults[].chosen`. |
123
+ | `summary` | string | One-line description of what this option does. |
124
+ | `user_impact` | string | What end users see if this option ships. Cannot be `""` or `"n/a"`. If the option has no user-visible impact, write `"none — internal-only change"`. |
125
+ | `performance` | string | Quantitative or qualitative perf delta (e.g. `"p95 60ms vs 220ms"`, `"~2× faster on warm cache"`, `"no measurable change"`). |
126
+ | `speed` | string | Time-to-ship estimate (e.g. `"~30 min"`, `"~half a day if migration succeeds"`, `"unknown — depends on schema migration"`). |
127
+ | `cost` | string | Dollar/quota impact at expected volume (e.g. `"$0"`, `"~$12/mo at 10k req/day"`, `"unknown — depends on caching hit rate"`). |
128
+
129
+ **Why user-visible-impact fields are required.** The trade-off table is what the operator sees in normal-mode prompts. If the fields are missing or filled with `"n/a"`, the operator can't make an informed choice — they see a list of opaque options. Schema validation rejects entries where `user_impact` is empty or `"n/a"` (use `"none — internal-only change"` for legitimately invisible work).
130
+
131
+ **Example entry:**
132
+
133
+ ```yaml
134
+ novel_decisions:
135
+ - decision_id: "classification_provider"
136
+ decision: "Which LLM provider for article classification?"
137
+ options:
138
+ - id: "A"
139
+ summary: "OpenAI gpt-4o-mini for classification"
140
+ user_impact: "Higher classification accuracy; users see fewer mis-categorized articles in feed"
141
+ performance: "p95 ~800ms per classify call"
142
+ speed: "~20 min to wire — existing OpenAI client"
143
+ cost: "~$3/mo at 10k articles/day"
144
+ - id: "B"
145
+ summary: "Groq llama-3-70b for classification"
146
+ user_impact: "Comparable accuracy; faster feed refresh — users see new articles ~3× sooner"
147
+ performance: "p95 ~250ms per classify call"
148
+ speed: "~45 min to wire — new SDK"
149
+ cost: "~$0.50/mo at 10k articles/day"
150
+ - id: "C"
151
+ summary: "Local classifier rules (no LLM)"
152
+ user_impact: "Lower accuracy; users see more 'Other' bucketing"
153
+ performance: "p95 ~5ms"
154
+ speed: "~3 hours to build + tune"
155
+ cost: "$0"
156
+ recommended_default: "B"
157
+ confidence: "med"
158
+ reasoning: "Plan rubric r2 prioritizes feed-refresh latency; Groq's 3× speed advantage matters more than accuracy delta. Confidence med because we haven't benchmarked Groq's accuracy on this taxonomy."
159
+ ```
160
+
161
+ **Routing summary** (see `references/halt-and-ask-protocol.md` for full protocol):
162
+
163
+ | Confidence | Long-mode (budget ≥4h or `--long` or `overnight` keyword) | Normal-mode |
164
+ |---|---|---|
165
+ | `high` | Auto-pick `recommended_default`, log to `autonomousDefaults[]` | Surface trade-off table, wait for operator |
166
+ | `med` | Auto-pick, log, flag `confidence: "med"` for judge review | Surface trade-off table, wait |
167
+ | `low` | **Escalate** — surface trade-off table even in long-mode | Surface trade-off table, wait |
168
+
169
+ ## Examples
170
+
171
+ ### Example 1 — Minimal (non-UI commit, no synthesis_dimensions)
172
+
173
+ A C2 methodology commit with no UI surface and no `synthesis_dimensions` block in the plan. No ledger required; `decision_ledger` is omitted (equivalent to `[]`).
174
+
175
+ ```yaml
176
+ envelope:
177
+ branch: "exp/synth-decisions-opus-only"
178
+ commit_sha: "pending"
179
+ files_changed:
180
+ - "references/implementer-envelope-schema.md"
181
+ - "agents/implementer.md"
182
+ - "references/implementer-brief-template.md"
183
+ loc_added: 142
184
+ loc_removed: 6
185
+ f_criteria:
186
+ F1: pass
187
+ F2: pass
188
+ F3: pass
189
+ F4: pass
190
+ F5: pass
191
+ synthesis_attestation: {}
192
+ decision_ledger: []
193
+ novel_decisions: []
194
+ notes: "All three files updated in one commit. Schema doc landed under references/ alongside implementer-brief-template.md per existing convention."
195
+ wall_clock_seconds: 184
196
+ ```
197
+
198
+ ### Example 2 — Rich (UI commit with one deviation + one novel decision)
199
+
200
+ A C5 commit adding a settings panel. Plan named four synthesis dimensions: `error_state_pattern`, `loading_state_pattern`, `save_on_change_pattern`, `form_field_layout`. Implementer applied three; deviated on one; surfaced one novel decision the plan hadn't enumerated.
201
+
202
+ ```yaml
203
+ envelope:
204
+ branch: "feat/news-preferences-panel"
205
+ commit_sha: "pending"
206
+ files_changed:
207
+ - "components/settings/NewsPreferencesPanel.tsx"
208
+ - "components/settings/NewsPreferencesPanel.test.tsx"
209
+ - "app/settings/news/page.tsx"
210
+ loc_added: 287
211
+ loc_removed: 14
212
+ f_criteria:
213
+ F1: pass
214
+ F2: pass
215
+ F3: pass
216
+ F4: fail
217
+ F5: pass
218
+ synthesis_attestation:
219
+ error_state_pattern: applied
220
+ loading_state_pattern: applied
221
+ save_on_change_pattern: applied
222
+ form_field_layout:
223
+ status: deviated
224
+ deviation_reason: "Plan specified two-column grid; existing settings pages all use single-column stacked. Followed in-repo precedent over plan."
225
+ novel_decisions:
226
+ - decision: "Debounced save-on-change at 400ms instead of immediate."
227
+ reasoning: "Toggling 5+ topic checkboxes triggered 5 sequential POSTs in tests; debounce coalesces. Plan didn't address rate-of-change."
228
+ notes: "F4 fails because the optimistic-UI test is flaky against the local API mock; tracking as known-flake. Real backend confirms shape is correct."
229
+ wall_clock_seconds: 612
230
+ ```
231
+
232
+ ### Example 3 — Populated ledger (UI commit with placement + cta_tier dimensions)
233
+
234
+ A UI commit adding a MetricCard to the dashboard. The plan named two synthesis dimensions; both are attested and each has a full ledger entry.
235
+
236
+ ```yaml
237
+ envelope:
238
+ branch: "feat/dashboard-metric-card"
239
+ commit_sha: "pending"
240
+ files_changed:
241
+ - "components/dashboard/MetricCard.tsx"
242
+ - "components/dashboard/MetricCard.test.tsx"
243
+ loc_added: 84
244
+ loc_removed: 12
245
+ f_criteria:
246
+ F1: pass
247
+ F2: pass
248
+ synthesis_attestation:
249
+ placement_MetricCard: applied
250
+ cta_tier_export_button: applied
251
+ decision_ledger:
252
+ - dimension: "placement_MetricCard"
253
+ owner: "plan"
254
+ locked_value: "after `<SummaryRow>` in components/dashboard/MetricCard.tsx"
255
+ alternatives_rejected:
256
+ - "before `<SummaryRow>` — plan specified after; reversing would change visual grouping"
257
+ - "inside `<DashboardGrid>` — would require grid-slot refactor outside this chunk's scope"
258
+ evidence_file: "components/dashboard/MetricCard.tsx"
259
+ on_new_decision: "flag"
260
+ - dimension: "cta_tier_export_button"
261
+ owner: "plan"
262
+ locked_value: "secondary"
263
+ alternatives_rejected:
264
+ - "primary — too visually dominant for a utility data-export action"
265
+ - "tertiary — insufficient affordance for a trigger users must discover"
266
+ evidence_file: "components/dashboard/MetricCard.tsx"
267
+ on_new_decision: "flag"
268
+ novel_decisions: []
269
+ notes: "Both dimensions applied as specified. Ledger entries document why alternatives were rejected."
270
+ wall_clock_seconds: 142
271
+ ```
272
+
273
+ ## Brief-construction: input_filter pattern (Step 7 / audit §5.E)
274
+
275
+ The orchestrator constructs each implementer brief from a superset of context (intent, plan, MECE packet, architecture slice, capability shortlist, memory recall, prior chunk envelopes). Without scoping, this can balloon — particularly when many prior chunks have closed.
276
+
277
+ OpenAI Agents SDK ships an `input_filter` primitive on its `handoff(...)` call: a function that receives the full `HandoffInputData` (with `input_history`, `pre_handoff_items`, `new_items`) and returns a filtered subset for the downstream agent. Build-loop's structure is **agent-as-tools** (not handoff per Microsoft's distinction — control returns to the orchestrator after each dispatch), so build-loop does not adopt the OpenAI runtime. It DOES adopt the `input_filter` pattern at the brief-construction layer.
278
+
279
+ **Pattern adoption (internal, build-loop-native):**
280
+
281
+ 1. Each Phase 3 dispatch site in `agents/build-orchestrator.md` builds a candidate brief from the full context superset.
282
+ 2. Before dispatching, the orchestrator MAY apply a per-chunk `filter` callable to the brief's context blocks (architecture slice, memory recall, prior envelopes). The callable returns a scoped subset — e.g. only memory entries whose `domain` matches `files_owned`, or only prior envelopes from chunks the current chunk has a dependency edge to.
283
+ 3. The implementer brief carries an `applied_filter` annotation (one line: `applied_filter: <name>; dropped: <N entries>`) so commit-auditor knows what was suppressed.
284
+ 4. Default behavior is the identity filter (no scoping); filters are opt-in per-chunk in the plan via `chunk[*].brief_filter:` field. The orchestrator's catalogue of built-in filters lives in `references/brief-filters.md` (TBD; not required for this step).
285
+
286
+ **Why this matters for the envelope schema**: `capabilities_used[]` / `capabilities_rejected[]` are the implementer's view of brief utility. `applied_filter` is the orchestrator's view. Together they let Phase 6 Learn answer "did we send the right context?" without the implementer having to enumerate everything it ignored.
287
+
288
+ **Sources** (full citations in `~/dev/research/topics/agentic-systems/agentic-systems.build-loop-agent-audit-2026-05-20.md` §5):
289
+ - OpenAI Agents SDK — `handoff(input_type, on_handoff, input_filter)` primitive (Bucket 1 §5.A core)
290
+ - Microsoft Agent Framework — handoff vs agent-as-tools distinction (§5.C)
291
+
292
+ ## Parser behavior
293
+
294
+ The orchestrator parses envelopes via `scripts/parse_implementer_envelope.py` (TBD; not yet landed). Until then, the build-orchestrator agent reads the envelope inline. Either way, the parsing rules are:
295
+
296
+ 1. Strict required-field check. Missing key → malformed.
297
+ 2. `synthesis_attestation` cross-check against the plan's `synthesis_dimensions` block — every named dimension must have an attestation entry; extra entries are accepted (forward-compat).
298
+ 3. `novel_decisions` non-empty + plan had `synthesis_dimensions` block + `status != "blocked"` → orchestrator routes the diff to `scope-auditor` for synthesis-scope review before committing.
299
+ 4. **`status: "blocked"` + `novel_decisions` non-empty** → orchestrator does NOT commit. Each `novel_decisions[]` entry is dispatched to the configured Thinking-tier resolver (see `agents/build-orchestrator.md` §"Phase 3 halt-and-ask branch"). Resolutions are stored in `state.json.novelDecisionResolutions[]`, then the implementer is re-dispatched with resolutions appended to its brief. Loop until `status: "completed"` (or equivalent success) or the hard-fail counter (N=3) is exhausted.
300
+ 5. `status: "blocked"` + `novel_decisions: []` → malformed. The block has no payload to resolve. Orchestrator treats as `failed` and routes to Iterate.
301
+ 6. Any `f_criteria` value of `"fail"` → orchestrator routes to Iterate (Phase 5) with the failing F-criterion as the entry point.
302
+ 7. **`novel_decisions[i]` schema check** (do/branch/surface policy): each entry must include `decision_id`, `options` (non-empty), `recommended_default` (matching one of `options[].id`), and `confidence` (`high|med|low`). Each option must include non-empty `user_impact`, `performance`, `speed`, `cost` fields. Missing or `"n/a"`-valued trade-off fields → orchestrator routes to Iterate with the implementer asked to fill them in. Once the schema is clean, `classify_action.py` returns `DECISION` and the orchestrator routes per `references/halt-and-ask-protocol.md`.
@@ -0,0 +1,257 @@
1
+ <!-- SPDX-FileCopyrightText: 2025-2026 Tyrone Ross, Jr <46267523+tyroneross@users.noreply.github.com> | SPDX-License-Identifier: Apache-2.0 -->
2
+
3
+ # Intent Capability Pack
4
+
5
+ Use this pack on every build. It keeps decentralized subagent work aligned to the app's purpose, the user's actual job, and the update's intent.
6
+
7
+ ## North Star
8
+
9
+ Every build starts by capturing:
10
+
11
+ - **App/repo purpose**: what this product is for and who it serves.
12
+ - **Primary users**: the people or roles affected by this change.
13
+ - **Core jobs**: the tasks users perform most often or rely on most.
14
+ - **Update intent**: why this change matters now.
15
+ - **User value**: how the change makes the product faster, clearer, more accurate, more trustworthy, more useful, or easier to navigate.
16
+ - **Non-goals**: what this build should not add, expose, or complicate.
17
+
18
+ Write the result to `.build-loop/intent.md` and mirror the compact version into `.build-loop/state.json.intent`.
19
+
20
+ ### Commander's-intent posture (WP-F, all OPTIONAL — LLM-inferred, confirm-on-ambiguity)
21
+
22
+ North Star captures who/what; **posture** captures the tradeoff stance that drives
23
+ autonomous forks when the agent loses comms (the Marine-Corps commander's-intent
24
+ analog: purpose + key tasks + end state, so a subordinate who can't ask still
25
+ chooses correctly). A walkie-talkie app for generals-on-ops, for kids, and for
26
+ traders share North Star *fields* but differ entirely in *what to optimize when
27
+ forced to choose*. All fields are OPTIONAL and LLM-inferred from the ask; confirm
28
+ only on genuine ambiguity (reuse the restatement protocol — never `AskUserQuestion`,
29
+ never a gate). Mirror into `state.json.intent.posture`.
30
+
31
+ - **audience** + **stakes** — one line each (who the change serves; what a failure
32
+ costs). `stakes` ∈ {low, medium, high}.
33
+ - **priority_order** — the ranked tie-breaker the agent applies when two viable
34
+ paths conflict. FIXED VOCAB (ordered subset of
35
+ `security / reliability / speed / cost / simplicity / polish`) plus a free-text
36
+ `notes` escape for expressiveness. The fixed vocab aids weak-LLM recall; `notes`
37
+ carries anything the vocab can't.
38
+ - **acceptable_tradeoffs** — what is OK to cut under pressure.
39
+ - **non_goals** — what is never cut. At `stakes: high`, a `non_goals` entry that
40
+ names a REAL risk is a candidate to **graduate to a constitution invariant** — but
41
+ only once it is **promoted into the project constitution** (`projects/<slug>/constitution.md`),
42
+ where the LLM enforces it as a hard line. Until promoted, it stays advisory like the
43
+ rest of the posture. There is no separate deterministic gate that reads `non_goals`
44
+ directly (`grep non_goals scripts/` is intentionally empty); enforcement rides the
45
+ constitution, not a parallel mechanism. See the tiered charter below.
46
+
47
+ `priority_order` wires into the `alignment-checker` as the Phase-2-fork and
48
+ Phase-5-queue-drain tie-breaker: not just "matches intent?" but "which viable path
49
+ does THIS user's priority order prefer?" — advisory data the LLM weighs, never a gate.
50
+
51
+ ### Tiered intent — `stakes` is the depth dial (WP-F/F2)
52
+
53
+ - **Per-run intent** (ephemeral, `.build-loop/intent.md`): restated ask + this
54
+ change's posture. Unchanged lifecycle.
55
+ - **Project charter** (persistent): stable North Star + posture + invariants + key
56
+ architecture decisions. ACCRETES via promotion — a fact promotes to durable when
57
+ user-confirmed OR stable/unchallenged across N runs; stays `inferred` until then;
58
+ carries the falsifier that would unseat it (doctrine rule 8). Storage + sync:
59
+ `scripts/charter.py` (canonical `build-loop-memory/projects/<slug>/charter.md`;
60
+ repo mirror `.build-loop/charter.md` with a `canonical:` pointer + content hash;
61
+ one writer = the run, from canonical; user hand-edit of the mirror promotes to
62
+ canonical `authored_by: user` on next run via hash-mismatch detection).
63
+ - **Depth scales by `stakes`**: low → intent line only (skills/agents/toys — do NOT
64
+ force a charter, that's the anti-pattern); medium → thin charter (web/mobile);
65
+ high → full charter, and risk-naming `non_goals` become candidates to promote into
66
+ the constitution as invariants (where the LLM enforces them). The promotion is the
67
+ enforcement; no `non_goals`-specific gate exists outside the constitution.
68
+ - **PRD stance**: opt-in upfront via `start-prd`; accretion is the default; never
69
+ required. A PRD, when present, PREFILLS the charter richer — input, not a gate.
70
+
71
+ Enforcement philosophy (binding): all advisory. The one stronger-than-advisory path
72
+ is **constitution promotion** — a risk-naming `non_goals` at `stakes: high` graduates
73
+ to a hard invariant only when it is written into `projects/<slug>/constitution.md`,
74
+ which the LLM treats as a binding line. Per `feedback_deterministic_only_for_known_risks` —
75
+ posture/charter depth is the dial; the LLM weighs, never a gate. The constitution, not
76
+ a `non_goals`-specific script, carries any graduated invariant (no dormant determinism
77
+ claim — there is no `non_goals` enforcement code to wire up).
78
+
79
+ ## Intent restatement protocol (always-on)
80
+
81
+ Run this protocol on every build, judged by the orchestrator LLM — never a regex, never a detector script, never a binary gate. Depth scales with ambiguity, not a threshold. The behavior is intrinsic to Phase 1; no separate skill, script, or routing step gates it.
82
+
83
+ ### Step A — One-line concrete restatement (always)
84
+
85
+ Read the user's goal text and the surrounding context. Write a single sentence restating the most likely concrete interpretation to `.build-loop/intent.md` under a `## Restated intent` heading. For a concrete unambiguous goal, this is the entire protocol — write the line and move on. No options, no assumption-tagging, no exploration detour. The auto-execute fast path is unaffected.
86
+
87
+ Heuristics the LLM uses (judgment, not a checklist):
88
+
89
+ - Does the goal name a file path, function, schema field, route, command, or other concrete deliverable? → restate once and proceed.
90
+ - Could two reasonable readers infer materially different work? → continue to Step B.
91
+ - Does the goal use investigative or hedging language ("explore", "look into", "something like", "brainstorm", "design from scratch") without a concrete target? → continue to Step B.
92
+
93
+ The judgment is one pass, fast, and does not block. When in doubt about whether ambiguity is "real," do the lighter version (Step A only) and tag assumptions inline so downstream work can correct.
94
+
95
+ ### Step B — Options + tradeoffs when ambiguity is genuine
96
+
97
+ When the LLM judges genuine ambiguity (Step A heuristics fail), extend `.build-loop/intent.md` with:
98
+
99
+ ```md
100
+ ## Approach options
101
+ 1. **<short label>** — <≤2 sentences on what + tradeoff>
102
+ 2. **<short label>** — <≤2 sentences on what + tradeoff>
103
+ 3. **<short label>** — (optional third — stop at 3)
104
+
105
+ ## Recommended path
106
+ <one sentence naming option 1/2/3 and the reason>
107
+
108
+ ## Scope cuts considered
109
+ - <thing the orchestrator believes can be cut without losing user value>
110
+ - <second if present>
111
+ ```
112
+
113
+ Lead with the recommended option. Avoid speculative "we could also" lists. Keep to 1–3 options — the goal is to narrow, not to enumerate.
114
+
115
+ The reference file `skills/build-loop/references/intent-exploration-prompts.md` carries four template patterns (vague-verb, branching-or, creative-open, hedge-phrase) the LLM can consult when shaping options for common ambiguity shapes. Load on demand only when the goal matches one of those shapes.
116
+
117
+ ### Step C — Tagged assumptions (always when Step B fires; optional in Step A)
118
+
119
+ For every leap the restatement made that isn't grounded in the repo or the user's prompt, append a `TAG:ASSUMED` line under a `## Open assumptions (TAG:ASSUMED)` heading naming the assumption + the evidence that would close it. Examples:
120
+
121
+ - `TAG:ASSUMED — user wants the smallest concrete restatement; would close by user pinning a specific deliverable.`
122
+ - `TAG:ASSUMED — "explore" means "survey + recommend"; would close by repo showing prior similar work pattern.`
123
+
124
+ Tagged assumptions are the audit trail. The user reads them in the run report and can override on the next dispatch.
125
+
126
+ ### Step D — Mirror compact summary to state.json
127
+
128
+ Mirror the result to `.build-loop/state.json.intent`:
129
+
130
+ ```json
131
+ {
132
+ "restated_intent": "<one sentence>",
133
+ "approach_options": ["<label>", "<label>"], // optional; empty when Step A alone fired
134
+ "assumptions": ["<line>", "<line>"], // optional; empty when no leaps were made
135
+ "confidence": "high" | "medium" | "low", // LLM judgment, not a script
136
+ "run_id": "<current run_id>" // Step E: the run this intent was written for
137
+ }
138
+ ```
139
+
140
+ ### Step E — Run-id freshness stamp (per-run staleness guard)
141
+
142
+ `intent.md` lives in `.build-loop/` and survives across runs in the same workdir, so a
143
+ resumed or back-to-back run finds the PRIOR run's intent on disk. The "auto-execute fast
144
+ path" (Step A: "write the line and move on" for a concrete goal) can be misread as
145
+ "the present file already satisfies the protocol", so the rewrite gets skipped and the
146
+ stale intent describes prior work — the exact bl-intent-refresh-per-run failure (the
147
+ A–H consolidation run listed as a non-goal what WP-A shipped).
148
+
149
+ Two cheap, deterministic moves close it:
150
+
151
+ 1. **Stamp on write.** Whenever Phase 1 (re)writes `intent.md`, embed the current
152
+ `run_id` as an HTML comment so the prose never has to carry it:
153
+ `<!-- intent_run_id: <run_id> -->` (helper: `intent_freshness.stamp_marker(run_id)`).
154
+ Mirror `run_id` into `state.json.intent.run_id`.
155
+ 2. **Check at Phase 1 start.** Run
156
+ `python3 ${CLAUDE_PLUGIN_ROOT}/scripts/intent_freshness.py --workdir "$PWD" --json`.
157
+ A `stale` (stamp ≠ current run) or `unstamped` verdict means the on-disk intent is
158
+ from a prior run — re-run Steps A–D and re-stamp. The check is **advisory** and exit-0
159
+ always: a run-id *mismatch* is an objective structural fact (equality, not a content
160
+ judgment), so detecting it respects "never a content gate" — only the refresh (the LLM
161
+ rewriting the prose) is judgment. Surface the verdict line in the run report; never
162
+ `AskUserQuestion`, never `## Held`, never block.
163
+
164
+ This is detection-by-structure + refresh-by-LLM: it does not re-introduce the retired
165
+ regex that judged intent *content*; it only answers "does this file belong to this run?".
166
+
167
+ ### Hard guarantees (non-negotiable)
168
+
169
+ - **Never `AskUserQuestion`.** Intent capture is autonomous. The user reads the restatement + assumptions in the run report and can correct on the next dispatch.
170
+ - **Never `## Held`.** Advisory output only. Phase 2 Plan proceeds with whatever Step A or A+B produced.
171
+ - **Never blocks Phase 1.** A goal that is too ambiguous to restate concretely still gets restated as the best-effort interpretation + assumptions tagged. The flow proceeds.
172
+ - **Fail-safe.** Any error in this protocol (file write fails, intent.md missing) is logged as one line and the build continues. No exit-non-zero path exists here.
173
+ - **Auto-execute fast path preserved.** A concrete unambiguous goal produces the one-line restatement only. Zero added cost for Step B/C. No skill dispatch, no script call, no detection layer.
174
+ - **Fork-on-uncertainty consumes the output.** When Step B fired AND `confidence == "medium"|"low"` AND Phase 2 surfaces 2+ viable approaches differing only on implementation tradeoffs, the orchestrator's existing fork-on-uncertainty rule fans out worktrees per approach. The protocol provides the options; the existing rule consumes them.
175
+
176
+ ### Why intrinsic, not gated
177
+
178
+ The prior shape used a regex script to decide whether to run an exploration skill. That regex false-fired on ordinary prose ("auth fails or times out", "returns 200 or 404") and forced exploration detours on concrete goals — violating the no-friction fast-path contract. The LLM judges ambiguity better than a regex can. This protocol is the application of the "host agent is the LLM" principle to intent capture.
179
+
180
+ ## Intent Packet
181
+
182
+ Every subagent prompt must include this packet:
183
+
184
+ ```md
185
+ North star: <one sentence>
186
+ Update intent: <one sentence>
187
+ Primary user/workflow: <who does what>
188
+ This task fits by: <how this subtask advances the build>
189
+ User-value rule: <speed | accuracy | trust | navigation | scalability | reduced choice burden | other>
190
+ Decision constraints:
191
+ - No fake data or mock responses in production/user decision paths.
192
+ - No dead controls, dead navigation, decorative options, or UI promises without working behavior.
193
+ - Prefer the simplest approach that preserves user value and long-term scalability.
194
+ - Use a more complex approach only when the simpler approach harms user experience, correctness, extensibility, or performance.
195
+ Evidence required: <tests, build, visual check, data trace, performance check, etc.>
196
+ ```
197
+
198
+ ## Decision Rules
199
+
200
+ - **Real value beats apparent progress**. A UI that looks complete but hides mock data is worse than an honest incomplete state.
201
+ - **Basics must be excellent**. Core flows, data accuracy, loading, empty states, error states, navigation, and primary actions matter more than secondary features.
202
+ - **Every visible element needs intent**. Each button, label, option, nav item, chart, and message must help the user act, understand, decide, or recover.
203
+ - **One clear primary action by default**. Multiple hero or primary buttons need a strong reason. If choices create confusion, reduce them.
204
+ - **No non-working promises**. Do not ship listed options, nav items, filters, actions, charts, or integrations that do nothing or return placeholders.
205
+ - **Simplicity is not shortcutting**. Prefer the smallest durable solution. Choose additional complexity only when it materially improves user value, reliability, scalability, or future optionality.
206
+ - **End-to-end data integrity matters**. If users make decisions from search, charts, metrics, recommendations, or summaries, trace those outputs to real sources.
207
+
208
+ ## UI Standard: Beauty in the Basics
209
+
210
+ For UI work, the baseline is intentional, useful, and polished:
211
+
212
+ - **Hierarchy**: the screen makes the next best action obvious.
213
+ - **Copy**: text is specific, truthful, and necessary. Remove generic filler.
214
+ - **Controls**: controls have working behavior, appropriate affordance, and accessible labels.
215
+ - **Navigation**: navigation reflects real destinations and common workflows.
216
+ - **Choices**: option count is constrained to what users can meaningfully use.
217
+ - **States**: loading, empty, error, success, disabled, and permission states are designed, not incidental.
218
+ - **Data displays**: charts, tables, search results, and metrics show real data or a clear unavailable state.
219
+ - **Performance**: avoid visual or data-flow choices that make common tasks slower without clear value.
220
+ - **Scalability**: layouts and data models should tolerate realistic growth without immediate redesign.
221
+
222
+ ## User-Impact Issue Rule
223
+
224
+ When build-loop discovers a bug or issue while working:
225
+
226
+ 1. Ask whether it impacts users by checking:
227
+ - Does it make the app slower or faster?
228
+ - Does it make information less or more accurate?
229
+ - Does it affect trust, data integrity, security, or recovery from failure?
230
+ - Does it make core workflows easier or harder to navigate?
231
+ - Does it add unnecessary choices or remove useful optionality?
232
+ - Does it create short-term code that blocks scalable future work?
233
+ 2. If yes and the fix is local to the current build, add it to the plan and fix it automatically.
234
+ 3. If yes but the fix is too large or risky, log it to `.build-loop/issues/` with user impact, proposed fix, and why it was deferred.
235
+ 4. If no, log only when it is likely to affect future maintenance.
236
+
237
+ ## Review Gates
238
+
239
+ Review must check:
240
+
241
+ - **Intent fidelity**: the implementation advances the north star and update intent.
242
+ - **User value**: the result improves at least one declared user-value rule.
243
+ - **UI intentionality**: visible elements are meaningful, working, and not excessive.
244
+ - **Data integrity**: production/user decision paths do not use fake, random, or placeholder data.
245
+ - **Simplicity and scalability**: the solution is the simplest durable approach that protects user experience.
246
+
247
+ ## Source Basis
248
+
249
+ This pack operationalizes human-centered design and usability principles from:
250
+
251
+ - [ISO 9241-210:2019](https://www.iso.org/standard/77520.html): human-centered design across the interactive-system life cycle.
252
+ - [NIST summary of ISO human-centered design](https://www.nist.gov/itl/iad/visualization-and-usability-group/human-factors-human-centered-design): explicit users/tasks/environments, iterative evaluation, whole user experience, and multidisciplinary perspective.
253
+ - [GOV.UK Service Manual: understand users and their needs](https://www.gov.uk/service-manual/service-standard/point-1-understand-user-needs): understand full context, validate assumptions, and avoid building the wrong thing.
254
+ - [GOV.UK Service Manual: learning about users and their needs](https://www.gov.uk/service-manual/user-centred-design/user-needs): design around real user needs and keep needs traceable to user stories.
255
+ - [W3C WCAG 2.2 Understanding](https://www.w3.org/WAI/WCAG22/understanding/): accessible interfaces should be perceivable, operable, understandable, and robust.
256
+ - [Apple Human Interface Guidelines](https://developer.apple.com/design/human-interface-guidelines/): hierarchy, harmony, consistency, accessibility, platform patterns, and common components.
257
+ - [Nielsen Norman Group usability heuristics](https://www.nngroup.com/articles/ten-usability-heuristics/): visibility, match to real world, user control, consistency, error prevention, recognition, flexibility, minimalist design, recovery, and help.