@ai-content-space/loopx 0.1.2 → 0.1.4

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 (69) hide show
  1. package/README.md +422 -57
  2. package/README.zh-CN.md +485 -0
  3. package/assets/logo.svg +89 -0
  4. package/package.json +5 -1
  5. package/plugins/loopx/.codex-plugin/plugin.json +1 -1
  6. package/plugins/loopx/scripts/plugin-install.test.mjs +14 -0
  7. package/plugins/loopx/skills/archive/SKILL.md +49 -0
  8. package/plugins/loopx/skills/build/SKILL.md +111 -9
  9. package/plugins/loopx/skills/clarify/SKILL.md +129 -8
  10. package/plugins/loopx/skills/debug/SKILL.md +296 -0
  11. package/plugins/loopx/skills/debug/condition-based-waiting.md +115 -0
  12. package/plugins/loopx/skills/debug/defense-in-depth.md +122 -0
  13. package/plugins/loopx/skills/debug/find-polluter.sh +63 -0
  14. package/plugins/loopx/skills/debug/root-cause-tracing.md +169 -0
  15. package/plugins/loopx/skills/go-style/SKILL.md +71 -0
  16. package/plugins/loopx/skills/kratos/SKILL.md +74 -0
  17. package/plugins/loopx/skills/kratos/references/advanced-features.md +314 -0
  18. package/plugins/loopx/skills/kratos/references/architecture.md +488 -0
  19. package/plugins/loopx/skills/kratos/references/configuration.md +399 -0
  20. package/plugins/loopx/skills/kratos/references/http-customization.md +512 -0
  21. package/plugins/loopx/skills/kratos/references/middleware-logging.md +400 -0
  22. package/plugins/loopx/skills/kratos/references/proto-api-design.md +432 -0
  23. package/plugins/loopx/skills/kratos/references/security-auth.md +411 -0
  24. package/plugins/loopx/skills/kratos/references/troubleshooting.md +385 -0
  25. package/plugins/loopx/skills/plan/SKILL.md +24 -3
  26. package/plugins/loopx/skills/review/SKILL.md +98 -1
  27. package/plugins/loopx/skills/tdd/SKILL.md +371 -0
  28. package/plugins/loopx/skills/tdd/testing-anti-patterns.md +299 -0
  29. package/plugins/loopx/skills/verify/SKILL.md +139 -0
  30. package/scripts/codex-stop-hook.mjs +71 -0
  31. package/scripts/codex-workflow-hook.mjs +248 -0
  32. package/skills/archive/SKILL.md +49 -0
  33. package/skills/build/SKILL.md +111 -9
  34. package/skills/clarify/SKILL.md +129 -8
  35. package/skills/debug/SKILL.md +296 -0
  36. package/skills/debug/condition-based-waiting.md +115 -0
  37. package/skills/debug/defense-in-depth.md +122 -0
  38. package/skills/debug/find-polluter.sh +63 -0
  39. package/skills/debug/root-cause-tracing.md +169 -0
  40. package/skills/go-style/SKILL.md +71 -0
  41. package/skills/kratos/SKILL.md +74 -0
  42. package/skills/kratos/references/advanced-features.md +314 -0
  43. package/skills/kratos/references/architecture.md +488 -0
  44. package/skills/kratos/references/configuration.md +399 -0
  45. package/skills/kratos/references/http-customization.md +512 -0
  46. package/skills/kratos/references/middleware-logging.md +400 -0
  47. package/skills/kratos/references/proto-api-design.md +432 -0
  48. package/skills/kratos/references/security-auth.md +411 -0
  49. package/skills/kratos/references/troubleshooting.md +385 -0
  50. package/skills/plan/SKILL.md +20 -3
  51. package/skills/review/SKILL.md +98 -1
  52. package/skills/tdd/SKILL.md +371 -0
  53. package/skills/tdd/testing-anti-patterns.md +299 -0
  54. package/skills/verify/SKILL.md +139 -0
  55. package/src/build-runtime.mjs +311 -26
  56. package/src/build-stop-gate.mjs +94 -0
  57. package/src/cli.mjs +57 -5
  58. package/src/codex-exec-runtime.mjs +105 -5
  59. package/src/context-manifest.mjs +172 -0
  60. package/src/html-views.mjs +316 -0
  61. package/src/install-discovery.mjs +352 -5
  62. package/src/next-skill.mjs +57 -5
  63. package/src/plan-runtime.mjs +102 -122
  64. package/src/review-runtime.mjs +558 -0
  65. package/src/runtime-maintenance.mjs +429 -14
  66. package/src/template-governance.mjs +223 -0
  67. package/src/workflow.mjs +2341 -120
  68. package/src/workspace-context.mjs +166 -0
  69. package/src/workspace-memory.mjs +69 -0
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: build
3
3
  description: Ralph-style loopx execution runtime under the public build stage.
4
- argument-hint: "[--no-deslop] <approved workflow slug>"
4
+ argument-hint: "[--no-deslop] <approved PRD path or workflow slug> | --from-review <review artifact path>"
5
5
  ---
6
6
 
7
7
  # loopx Build
@@ -14,6 +14,7 @@ By default, `build` is not a one-shot draft writer. It is a persistence loop wit
14
14
 
15
15
  <Use_When>
16
16
  - `plan -> build` has already been explicitly approved.
17
+ - `review -> build` was requested for implementation fixes and a review artifact is supplied with `--from-review`.
17
18
  - Canonical plan artifacts already exist and execution should now proceed.
18
19
  - The task needs execution persistence, verification evidence, and explicit pre-review quality gates.
19
20
  </Use_When>
@@ -29,34 +30,97 @@ By default, `build` is not a one-shot draft writer. It is a persistence loop wit
29
30
  - Execution may parallelize internally without exposing a public `team` stage.
30
31
  - `build` does not replace `review`.
31
32
  - `execution-record.md` remains the sole canonical execution and verification artifact.
33
+ - Feature work and bug fixes should use `tdd`: write a failing test, confirm it fails for the intended reason, then implement the smallest passing change.
34
+ - Bug, test-failure, build-failure, and unexpected-behavior work should use `debug` before proposing fixes.
35
+ - Completion and review-ready claims should use `verify` before they are stated.
36
+ - Go edits should use `go-style` and preserve local repository conventions.
37
+ - Go-Kratos work should use `kratos` when Kratos project signals or Kratos-specific tasks are present.
32
38
  - Fresh evidence is required before review handoff.
33
39
  - Deslop and regression re-verification are part of the default build path.
40
+ - `build` has one owner for persistence. Delegation may run in parallel, but the owner remains accountable for draining delegated work and proving completion before review handoff.
34
41
  </Core_Principles>
35
42
 
36
43
  <Preconditions>
37
- `build` starts only when all of the following are true:
44
+ For initial execution, `build` starts only when all of the following are true:
38
45
 
39
46
  - approved `plan -> build` transition exists
40
47
  - `.loopx/plans/prd-<slug>.md` exists
41
48
  - `.loopx/plans/test-spec-<slug>.md` exists
42
49
  - workflow-local planning artifacts required by the execution lane exist
50
+
51
+ For review-requested implementation fixes, `build` may instead start from:
52
+
53
+ - `$build --from-review .loopx/workflows/<slug>/review-report.md`
54
+ - or `$build --from-review .loopx/workflows/<slug>/review.md`
55
+
56
+ In that mode, the review artifact is the direct rework contract. The approved PRD, test spec, previous execution record, and workflow-local plan package remain required context, but they are not the primary user-facing argument.
43
57
  </Preconditions>
44
58
 
59
+ <Inputs>
60
+ Preferred skill input:
61
+
62
+ - `.loopx/plans/prd-<slug>.md`
63
+
64
+ Preferred review rework input:
65
+
66
+ - `--from-review .loopx/workflows/<slug>/review-report.md`
67
+
68
+ Compatible skill / CLI input:
69
+
70
+ - `<slug>`
71
+
72
+ When invoked with a PRD path, derive `<slug>` from `prd-<slug>.md` and still use the matching workflow-local plan package and test spec.
73
+
74
+ When invoked with `--from-review`, derive `<slug>` from the workflow directory, treat the review artifact as the implementation-fix contract, and load the matching PRD, test spec, previous `execution-record.md`, and workflow-local plan package as supporting context. This Codex skill invocation consumes the `review -> build` rework intent; users should not need a separate bash `loopx approve ... --from review --to build` step for the normal Codex-facing flow.
75
+ </Inputs>
76
+
45
77
  <Execution_Model>
46
78
  `build` should behave like a Ralph-style execution runtime:
47
79
 
48
80
  1. Initialize or resume build iteration state.
49
- 2. Run internal execution / evidence / verification lanes in parallel.
50
- 3. Aggregate lane results into canonical `execution-record.md`.
51
- 4. Run fresh verification and read actual output.
52
- 5. Run architect verification as a hard pre-review gate.
53
- 6. Run deslop on build-owned changes.
54
- 7. Re-run regression verification after deslop.
55
- 8. Stop only when review handoff gates are satisfied or a real blocker remains.
81
+ 2. If running from `--from-review`, load the review artifact first and constrain implementation work to the requested implementation fixes unless the review artifact exposes a real plan or clarify blocker.
82
+ 3. Run internal execution / evidence / verification lanes in parallel.
83
+ 4. For implementation work, apply `tdd` unless the approved plan explicitly classifies the change as non-behavioral or test-inapplicable.
84
+ 5. For failures discovered during execution or verification, apply `debug` before attempting fixes.
85
+ 6. For `.go` edits, apply `go-style`; for Kratos API/service/biz/data work, apply `kratos` before changing framework structure.
86
+ 7. Aggregate lane results into canonical `execution-record.md`.
87
+ 8. Run fresh verification and read actual output using `verify` discipline.
88
+ 9. Run architect verification as a hard pre-review gate.
89
+ 10. Run deslop on build-owned changes.
90
+ 11. Re-run regression verification after deslop.
91
+ 12. Write/update the build delegation ledger and ensure blocking delegated work is drained.
92
+ 13. Write/update the completion audit mapping approved plan, slices, and review rework inputs to evidence.
93
+ 14. Stop only when review handoff gates are satisfied or a real blocker remains.
56
94
 
57
95
  `build` may persist support artifacts for runtime inspection, but they must not replace `execution-record.md`.
58
96
  </Execution_Model>
59
97
 
98
+ <Continuation_Discipline>
99
+ `build` is a persistence loop, not a "one phase per invocation" runner.
100
+
101
+ If approved plan work remains, continue executing within the same `$build` invocation until either review handoff gates are satisfied or a real blocker prevents further progress.
102
+
103
+ The following are **not** real blockers by themselves:
104
+
105
+ - a planned phase is unfinished
106
+ - a runtime adapter is not fully migrated yet
107
+ - store-layer branches still need to be moved to the new service/client path
108
+ - more files remain in the approved implementation scope
109
+ - verification has not been rerun after the latest edits
110
+
111
+ Those are remaining execution work. Keep working them down.
112
+
113
+ A real blocker must identify why execution cannot safely continue now, such as:
114
+
115
+ - missing human product/architecture decision that is not specified by the approved plan
116
+ - unavailable credential, service, fixture, dependency, or environment that cannot be mocked or bypassed responsibly
117
+ - verification failure caused by a pre-existing repository condition that blocks evaluating this change and cannot be isolated
118
+ - repeated implementation failure after the build iteration budget is exhausted
119
+ - a conflict between the approved plan and current repository facts that requires re-planning
120
+
121
+ Do not end a build response with "continue in the next build" for unfinished approved work. If work remains and no real blocker exists, keep executing. If a real blocker exists, name the concrete blocker and record it in `execution-record.md`.
122
+ </Continuation_Discipline>
123
+
60
124
  <Runtime_State_Machine>
61
125
  `build` should track at minimum:
62
126
 
@@ -72,6 +136,14 @@ By default, `build` is not a one-shot draft writer. It is a persistence loop wit
72
136
  - `build_blockers`
73
137
  - `build_progress_artifact_paths`
74
138
  - `build_support_evidence_paths`
139
+ - `build_owner_id`
140
+ - `build_owner_session_id`
141
+ - `build_owner_status`
142
+ - `build_delegation_status`
143
+ - `build_delegation_ledger_path`
144
+ - `build_active_delegation_count`
145
+ - `build_completion_audit_status`
146
+ - `build_completion_audit_path`
75
147
  - `execution_record_status`
76
148
 
77
149
  `build -> review` is blocked until:
@@ -81,6 +153,8 @@ By default, `build` is not a one-shot draft writer. It is a persistence loop wit
81
153
  - architect verification is approved
82
154
  - deslop is complete, unless explicitly skipped
83
155
  - post-deslop regression passes
156
+ - blocking delegated build work is drained
157
+ - completion audit passes
84
158
  - `execution-record.md` is complete
85
159
  </Runtime_State_Machine>
86
160
 
@@ -89,6 +163,15 @@ Canonical artifact:
89
163
 
90
164
  - `execution-record.md`
91
165
 
166
+ `execution-record.md` must make the completion scope explicit when a plan is larger than the current implementation slice:
167
+
168
+ - `planned_scope`: the approved PRD/workflow scope being measured.
169
+ - `implemented_scope`: the scope actually completed in this build run.
170
+ - `remaining_scope`: empty only when the approved workflow scope is fully implemented.
171
+ - `completion_claim`: use `full` only when the whole approved workflow is complete; use `slice` or another non-full value for partial implementation.
172
+
173
+ If `remaining_scope` is non-empty or `completion_claim` is not `full`, build may still hand off for slice review, but review/archive must not treat that as full workflow completion.
174
+
92
175
  Support artifacts may exist for:
93
176
 
94
177
  - iteration progress
@@ -96,6 +179,8 @@ Support artifacts may exist for:
96
179
  - architect gate summaries
97
180
  - deslop summaries
98
181
  - regression summaries
182
+ - `build-support/delegation-ledger.json`
183
+ - `build-support/completion-audit.json`
99
184
 
100
185
  These support artifacts are runtime aids only. They must not become new canonical review inputs.
101
186
  </Artifact_Contract>
@@ -106,6 +191,23 @@ These support artifacts are runtime aids only. They must not become new canonica
106
191
  - review continues to own provenance checks, evidence completeness checks, completion/rollback decisions, and code-review
107
192
  </Review_Boundary>
108
193
 
194
+ <Final_Response_Contract>
195
+ When `build` reaches review handoff readiness, the final response must include an explicit next skill command using the execution record path:
196
+
197
+ ```text
198
+ Next:
199
+ $review .loopx/workflows/<slug>/execution-record.md
200
+ ```
201
+
202
+ If the user needs the CLI/runtime-debug form, use:
203
+
204
+ ```bash
205
+ loopx review <slug>
206
+ ```
207
+
208
+ Do not end with prose-only guidance such as "next step should enter review" when the workflow is ready for review. Do not emit `$review <slug>` as the primary skill handoff when the execution record path is known. If review handoff is blocked, state the blocker instead of emitting a `$review` command.
209
+ </Final_Response_Contract>
210
+
109
211
  <Flags>
110
212
  - `--no-deslop`: skip the deslop pass and the post-deslop regression loop, while still requiring the latest successful pre-deslop verification evidence
111
213
  </Flags>
@@ -23,7 +23,7 @@ Its job is not just to ask questions. Its job is to turn a vague or overloaded r
23
23
  - The request is broad, ambiguous, or mixes problem, solution, and implementation detail.
24
24
  - The user needs help defining scope, non-goals, acceptance criteria, or tradeoffs before planning.
25
25
  - A design direction exists only implicitly and would otherwise be invented during implementation.
26
- - The task will later be handed to `plan`, `build`, or `autopilot`, and you want a high-signal spec first.
26
+ - The task will later be handed to `plan`, and you want a high-signal spec first.
27
27
  </Use_When>
28
28
 
29
29
  <Do_Not_Use_When>
@@ -33,15 +33,17 @@ Its job is not just to ask questions. Its job is to turn a vague or overloaded r
33
33
  </Do_Not_Use_When>
34
34
 
35
35
  <Why_This_Exists>
36
- Most implementation drift happens before coding begins. Teams often think they need “more planning,” when the real problem is weaker intent clarity, hidden assumptions, fuzzy boundaries, or a design shape that was never made explicit. `clarify` exists to solve those upstream failures before `plan` or `build` magnifies them.
36
+ Most implementation drift happens before coding begins. Teams often think they need “more planning,” when the real problem is weaker intent clarity, hidden assumptions, fuzzy boundaries, or a design shape that was never made explicit. `clarify` exists to solve those upstream failures before `plan` turns the clarified intent into an execution contract.
37
37
  </Why_This_Exists>
38
38
 
39
39
  <Core_Principles>
40
40
  - Ask one question at a time.
41
+ - Prefer bounded multiple-choice questions when the option space is known; use open-ended questions only when the option space is genuinely unknown.
41
42
  - Prefer the highest-leverage unresolved question, not broad coverage.
42
43
  - Keep digging on the same thread until one assumption, one boundary, or one tradeoff becomes clearer.
43
44
  - Treat every answer as a claim to pressure-test, not a final truth to copy down.
44
45
  - Make `Non-goals` and `Decision Boundaries` mandatory gates.
46
+ - Default to YAGNI: shrink speculative scope unless the user gives a concrete reason it belongs in the first pass.
45
47
  - Do not stop at “requirements”; shape the solution enough that the next stage has a coherent starting design.
46
48
  </Core_Principles>
47
49
 
@@ -80,10 +82,20 @@ Do not mark a clarify spec handoff-ready by prose alone. Update the frontmatter
80
82
  </Runtime_State_Machine>
81
83
 
82
84
  <Execution_Policy>
85
+ - Always run a preflight context intake before the first interview question.
86
+ - If supplied context is too large for safe prompt use, first request or create a concise prompt-safe summary that preserves goals, constraints, success criteria, non-goals, decision boundaries, and source references.
83
87
  - Explore repo context before asking the user about internals.
84
88
  - Prefer evidence-backed clarification in brownfield work:
85
89
  - “I found X in Y. Should this clarify spec preserve that pattern?”
90
+ - Route facts before judgment:
91
+ - discoverable codebase facts should be inspected directly
92
+ - evidence-backed inferences should be confirmed with the user
93
+ - product intent, tradeoffs, scope, non-goals, and decision boundaries must be treated as human decisions
86
94
  - Ask about intent and boundaries before implementation detail.
95
+ - Respect stage priority:
96
+ 1. intent, outcome, scope, non-goals, decision boundaries
97
+ 2. constraints and success criteria
98
+ 3. brownfield grounding and integration details
87
99
  - Stay on the same thread when the answer is still weak instead of rotating dimensions just for coverage.
88
100
  - Revisit at least one earlier answer with an explicit assumption, evidence, or tradeoff follow-up before crystallizing.
89
101
  - If the task is too large for one coherent spec, decompose it before pretending it is ready.
@@ -111,6 +123,45 @@ When an answer is still weak, prefer one of these next:
111
123
  4. If the answer is still describing symptoms, reframe toward root cause.
112
124
  </Pressure_Patterns>
113
125
 
126
+ <Socratic_Questioning>
127
+ `clarify` should be Socratic without being vague.
128
+
129
+ - Ask one focused round at a time.
130
+ - Prefer bounded choices when they reduce user effort:
131
+ - use single-choice when one answer should drive the next branch
132
+ - use multi-choice when several constraints, non-goals, or success checks may all apply
133
+ - include `Other` only when the known options are likely incomplete
134
+ - Lead with the recommended option when repo evidence or prior answers support it, but make the tradeoff visible.
135
+ - Do not hide a branching interview tree inside one overloaded question. If an option would require a follow-up, ask that follow-up next.
136
+ - After each answer, decide whether the next highest-value move is:
137
+ - deeper pressure on the same thread
138
+ - zooming out to another unresolved breadth track
139
+ - crystallizing the spec
140
+ </Socratic_Questioning>
141
+
142
+ <Breadth_Ledger>
143
+ Maintain a lightweight breadth ledger across independent ambiguity tracks:
144
+
145
+ - scope
146
+ - constraints
147
+ - outputs / deliverables
148
+ - verification and success criteria
149
+ - brownfield integration
150
+ - user-mentioned workstreams or stakeholder requirements
151
+
152
+ The ledger is a guard, not a rotation rule. Stay deep on the current thread until it has been pressure-tested, then zoom out only when another material track remains unresolved and would change downstream execution.
153
+ </Breadth_Ledger>
154
+
155
+ <Challenge_Modes>
156
+ Use these assumption stress tests when applicable:
157
+
158
+ - **Contrarian**: challenge a core assumption when an answer rests on an untested belief.
159
+ - **Simplifier**: probe the smallest viable first pass when scope expands faster than outcome clarity.
160
+ - **Ontologist**: reframe toward essence/root cause when the user keeps describing symptoms or when ambiguity stalls.
161
+
162
+ Track which challenge modes have been used in the ambiguity register. Do not repeat a mode mechanically.
163
+ </Challenge_Modes>
164
+
114
165
  <Design_Shaping>
115
166
  `clarify` should not stop at “what do you want?” Once the intent is understandable, it should also shape the task enough that the downstream plan is not starting from zero.
116
167
 
@@ -120,10 +171,51 @@ When there is a real design choice:
120
171
  - lead with the recommended one
121
172
  - explain tradeoffs briefly
122
173
  - right-size the design to the task
174
+ - identify likely component boundaries, data flow, or user-facing flow when that would materially affect planning
175
+ - reject speculative features unless they are necessary for the stated outcome
123
176
 
124
177
  The goal is not to produce a full architecture doc here. The goal is to make the clarify spec design-ready.
125
178
  </Design_Shaping>
126
179
 
180
+ <Incremental_Validation>
181
+ For non-trivial designs, validate the design in small sections before writing the final clarify spec.
182
+
183
+ Present a compact design summary and ask whether it matches the user's intent. When relevant, validate these sections separately:
184
+
185
+ - user-facing behavior or workflow
186
+ - component boundaries / ownership
187
+ - data flow or API contract
188
+ - error handling and edge cases
189
+ - test and verification shape
190
+ - explicitly deferred work
191
+
192
+ If the user rejects a section, continue the interview loop instead of writing a handoff-ready spec.
193
+ </Incremental_Validation>
194
+
195
+ <Practical_Closure_Audit>
196
+ Treat a low ambiguity score as permission to audit closure, not as automatic permission to stop.
197
+
198
+ Before crystallizing, ask:
199
+
200
+ - Would one more question materially change implementation, test strategy, or scope?
201
+ - Are non-goals and decision boundaries explicit enough for downstream agents?
202
+ - Has at least one assumption or tradeoff been pressure-tested?
203
+ - Is remaining uncertainty residual risk rather than actionable ambiguity?
204
+
205
+ If remaining uncertainty would not change execution, crystallize the spec and preserve it as residual risk instead of opening a low-value branch.
206
+ </Practical_Closure_Audit>
207
+
208
+ <Spec_Self_Review>
209
+ Before marking a clarify spec handoff-ready, perform a self-review pass:
210
+
211
+ - remove placeholders such as `TBD`, `TODO`, `REPLACE_ME`, or vague “etc.”
212
+ - check for internal contradictions
213
+ - check whether the scope is still too broad for one coherent execution package
214
+ - check whether any requirement can be interpreted two materially different ways
215
+ - verify that non-goals, decision boundaries, acceptance criteria, and residual risks are explicit
216
+ - verify that brownfield evidence is labeled separately from inference
217
+ </Spec_Self_Review>
218
+
127
219
  <Process>
128
220
 
129
221
  ## 1. Explore Context
@@ -131,12 +223,22 @@ The goal is not to produce a full architecture doc here. The goal is to make the
131
223
  - Read relevant files, docs, and current patterns first.
132
224
  - Classify the work as brownfield or greenfield.
133
225
  - For brownfield work, collect concrete evidence before questioning.
226
+ - Create or update a compact context snapshot for the task when the conversation, source docs, or repo evidence would otherwise be too large to carry safely.
134
227
 
135
228
  ## 2. Interview
136
229
 
137
230
  - Ask one question per round.
231
+ - Prefer bounded choices for known option spaces; use open-ended questions only when the valid answers cannot be enumerated.
232
+ - Before asking each question, show a compact status line with:
233
+ - `round`: current round and max rounds
234
+ - `ambiguity_score`: current score
235
+ - `target`: selected profile threshold
236
+ - `open_items`: unresolved ambiguity count
237
+ - Also state the current focus dimension and whether the round is fact confirmation or human judgment.
238
+ - After the user answers and the round is updated, show the revised `ambiguity_score`, whether it moved up/down/unchanged, and the main reason for that change before asking the next question.
138
239
  - After each answered round, update `current_round`, the ambiguity register, and `ambiguity_score`.
139
- - Target the weakest unresolved dimension.
240
+ - Target the weakest unresolved dimension within the stage-priority order.
241
+ - Maintain the breadth ledger; do not rotate dimensions just for coverage.
140
242
  - Keep `Non-goals` and `Decision Boundaries` explicit from early in the process.
141
243
  - Respect the selected profile:
142
244
  - `standard`: stop only when the clarify spec is handoff-ready or `15` rounds are exhausted
@@ -154,12 +256,19 @@ The goal is not to produce a full architecture doc here. The goal is to make the
154
256
  - Where needed, propose a small set of options.
155
257
  - Recommend one approach.
156
258
  - Clarify what that approach implies for scope and downstream execution.
259
+ - Apply incremental validation for non-trivial designs before finalizing the spec.
260
+
261
+ ## 4.5. Closure and Self-Review
262
+
263
+ - Run the practical closure audit.
264
+ - Run the spec self-review checklist before marking handoff-ready.
265
+ - If the round cap is reached or the user chooses to proceed despite ambiguity, preserve an explicit residual-risk warning in the spec and handoff recommendation.
157
266
 
158
267
  ## 5. Write the Clarify Spec
159
268
 
160
269
  Write the output to the loopx runtime namespace:
161
270
 
162
- - `.loopx/specs/clarify-<slug>-<timestamp>.md`
271
+ - `.loopx/intake/clarify-<slug>-<timestamp>.md`
163
272
 
164
273
  The clarify spec should include:
165
274
 
@@ -179,19 +288,28 @@ The clarify spec should include:
179
288
  - constraints
180
289
  - success criteria
181
290
  - assumptions exposed and resolved
291
+ - pressure-pass findings
182
292
  - brownfield evidence vs inference
293
+ - breadth ledger / unresolved tracks, if any
183
294
  - design direction / preferred approach
295
+ - residual risks
184
296
  - explicit next handoff recommendation
185
297
 
186
298
  ## 6. Handoff
187
299
 
188
300
  After the clarify spec is ready:
189
301
 
190
- - hand off to `plan` by default
191
- - hand off to `build` only if the user explicitly wants direct execution and the task is already concrete enough
192
- - hand off to `autopilot` only when the scope is sufficiently tight for a bounded end-to-end run
302
+ - hand off to `plan`; do not start implementation, TDD, `build`, or `autopilot` from `clarify`
303
+ - if the user asks to execute immediately, explain that loopx requires the `plan` gate first and provide the plan invocation
304
+ - if a task is too small to justify planning, do not use `clarify`; handle that request outside the clarify workflow from the start
305
+
306
+ Preferred explicit handoff contract:
307
+
308
+ - Recommended invocation: `$plan <slug>`
309
+ - Artifact-pinned invocation when needed: `$plan --direct .loopx/intake/clarify-<slug>-<timestamp>.md`
310
+ - Consumer behavior: treat the clarify spec as the source of truth for intent, non-goals, decision boundaries, constraints, and design direction; do not reopen clarification by default
193
311
 
194
- `clarify` itself does not implement the feature.
312
+ `clarify` itself does not implement the feature. The handoff recommendation must name `plan` as the next workflow step.
195
313
 
196
314
  </Process>
197
315
 
@@ -199,6 +317,8 @@ After the clarify spec is ready:
199
317
  - `Non-goals` are explicit
200
318
  - `Decision Boundaries` are explicit
201
319
  - At least one pressure-pass follow-up has revisited an earlier answer
320
+ - The practical closure audit has passed
321
+ - The spec self-review pass has removed placeholders, contradictions, and material ambiguity
202
322
  - A written clarify spec exists
203
323
  - The task is small enough and clear enough for real downstream handoff
204
324
  - The selected profile threshold is met:
@@ -208,6 +328,7 @@ After the clarify spec is ready:
208
328
 
209
329
  <Must_Not_Decide_Automatically>
210
330
  - approval to move from clarify into plan
331
+ - skipping `plan` after producing a clarify spec
211
332
  - implementation details that were never clarified or grounded
212
333
  - widening the task because a broader redesign sounds cleaner
213
334
  </Must_Not_Decide_Automatically>