@tacuchi/agent-workflow-cli 20.22.0 → 20.24.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 (168) hide show
  1. package/dist/adapters/git-cli.js +42 -0
  2. package/dist/adapters/git-cli.js.map +1 -1
  3. package/dist/application/artifacts-service.js +5 -5
  4. package/dist/application/artifacts-service.js.map +1 -1
  5. package/dist/application/checkpoint-service.js +60 -55
  6. package/dist/application/checkpoint-service.js.map +1 -1
  7. package/dist/application/checkpoint-write-service.js +61 -66
  8. package/dist/application/checkpoint-write-service.js.map +1 -1
  9. package/dist/application/context/budget-service.js +128 -0
  10. package/dist/application/context/budget-service.js.map +1 -0
  11. package/dist/application/context/bundle-root.js +41 -0
  12. package/dist/application/context/bundle-root.js.map +1 -0
  13. package/dist/application/context/manifest.js +150 -0
  14. package/dist/application/context/manifest.js.map +1 -0
  15. package/dist/application/context/measure.js +227 -0
  16. package/dist/application/context/measure.js.map +1 -0
  17. package/dist/application/context/plan-service.js +177 -0
  18. package/dist/application/context/plan-service.js.map +1 -0
  19. package/dist/application/decisiones-service.js +5 -5
  20. package/dist/application/decisiones-service.js.map +1 -1
  21. package/dist/application/export-service.js +250 -0
  22. package/dist/application/export-service.js.map +1 -0
  23. package/dist/application/fix-git-service.js +244 -0
  24. package/dist/application/fix-git-service.js.map +1 -0
  25. package/dist/application/history-update-service.js +35 -24
  26. package/dist/application/history-update-service.js.map +1 -1
  27. package/dist/application/lifecycle-target.js +39 -0
  28. package/dist/application/lifecycle-target.js.map +1 -0
  29. package/dist/application/parsers/spec-relation.js +80 -0
  30. package/dist/application/parsers/spec-relation.js.map +1 -0
  31. package/dist/application/paths-service.js +8 -0
  32. package/dist/application/paths-service.js.map +1 -1
  33. package/dist/application/persist-service.js +285 -0
  34. package/dist/application/persist-service.js.map +1 -0
  35. package/dist/application/release-data/artifacts.js +17 -21
  36. package/dist/application/release-data/artifacts.js.map +1 -1
  37. package/dist/application/resume-service.js +184 -0
  38. package/dist/application/resume-service.js.map +1 -0
  39. package/dist/application/semantic-operation/protocol.js +247 -0
  40. package/dist/application/semantic-operation/protocol.js.map +1 -0
  41. package/dist/application/semantic-operation/publish.js +80 -0
  42. package/dist/application/semantic-operation/publish.js.map +1 -0
  43. package/dist/application/session-binding-service.js +125 -0
  44. package/dist/application/session-binding-service.js.map +1 -0
  45. package/dist/application/session-close-service.js +60 -39
  46. package/dist/application/session-close-service.js.map +1 -1
  47. package/dist/application/session-create-service.js +45 -19
  48. package/dist/application/session-create-service.js.map +1 -1
  49. package/dist/application/session-resolver.js +180 -44
  50. package/dist/application/session-resolver.js.map +1 -1
  51. package/dist/application/session-resume-service.js +39 -9
  52. package/dist/application/session-resume-service.js.map +1 -1
  53. package/dist/application/sessions-service.js +0 -2
  54. package/dist/application/sessions-service.js.map +1 -1
  55. package/dist/application/status-service.js +24 -388
  56. package/dist/application/status-service.js.map +1 -1
  57. package/dist/application/tasks-service.js +5 -5
  58. package/dist/application/tasks-service.js.map +1 -1
  59. package/dist/application/workline-index-service.js +510 -0
  60. package/dist/application/workline-index-service.js.map +1 -0
  61. package/dist/cli/commands/checkpoint-read.js +10 -6
  62. package/dist/cli/commands/checkpoint-read.js.map +1 -1
  63. package/dist/cli/commands/checkpoint-write.js +38 -11
  64. package/dist/cli/commands/checkpoint-write.js.map +1 -1
  65. package/dist/cli/commands/context-budget.js +79 -0
  66. package/dist/cli/commands/context-budget.js.map +1 -0
  67. package/dist/cli/commands/context-plan.js +75 -0
  68. package/dist/cli/commands/context-plan.js.map +1 -0
  69. package/dist/cli/commands/export.js +117 -0
  70. package/dist/cli/commands/export.js.map +1 -0
  71. package/dist/cli/commands/fix-git.js +109 -0
  72. package/dist/cli/commands/fix-git.js.map +1 -0
  73. package/dist/cli/commands/generate-launch.js +35 -3
  74. package/dist/cli/commands/generate-launch.js.map +1 -1
  75. package/dist/cli/commands/history-update.js +1 -1
  76. package/dist/cli/commands/history-update.js.map +1 -1
  77. package/dist/cli/commands/index.js +15 -0
  78. package/dist/cli/commands/index.js.map +1 -1
  79. package/dist/cli/commands/persist.js +67 -0
  80. package/dist/cli/commands/persist.js.map +1 -0
  81. package/dist/cli/commands/resume-summary.js +14 -3
  82. package/dist/cli/commands/resume-summary.js.map +1 -1
  83. package/dist/cli/commands/resume.js +73 -0
  84. package/dist/cli/commands/resume.js.map +1 -0
  85. package/dist/cli/commands/session-artifacts.js +12 -11
  86. package/dist/cli/commands/session-artifacts.js.map +1 -1
  87. package/dist/cli/commands/session-close.js +8 -7
  88. package/dist/cli/commands/session-close.js.map +1 -1
  89. package/dist/cli/commands/session-create.js +5 -1
  90. package/dist/cli/commands/session-create.js.map +1 -1
  91. package/dist/cli/commands/session-resume.js +16 -10
  92. package/dist/cli/commands/session-resume.js.map +1 -1
  93. package/dist/cli/commands/status.js +66 -2
  94. package/dist/cli/commands/status.js.map +1 -1
  95. package/dist/cli/commands/workspace-init.js +21 -2
  96. package/dist/cli/commands/workspace-init.js.map +1 -1
  97. package/dist/cli/context-id.js +133 -0
  98. package/dist/cli/context-id.js.map +1 -0
  99. package/dist/cli/help-groups.js +20 -1
  100. package/dist/cli/help-groups.js.map +1 -1
  101. package/dist/cli/main.js +44 -16
  102. package/dist/cli/main.js.map +1 -1
  103. package/dist/cli/output-mode.js +41 -0
  104. package/dist/cli/output-mode.js.map +1 -0
  105. package/dist/cli/parser.js +10 -0
  106. package/dist/cli/parser.js.map +1 -1
  107. package/dist/cli/registry.js.map +1 -1
  108. package/dist/cli/render.js +53 -0
  109. package/dist/cli/render.js.map +1 -1
  110. package/package.json +1 -1
  111. package/skills/w/SKILL.md +2 -2
  112. package/skills/w/commands/export-diagrams.md +13 -21
  113. package/skills/w/commands/export-manuals.md +15 -21
  114. package/skills/w/commands/export-reports.md +14 -21
  115. package/skills/w/commands/export-scripts.md +14 -21
  116. package/skills/w/commands/fix-git.md +24 -16
  117. package/skills/w/commands/generate-launch.md +13 -32
  118. package/skills/w/commands/persist.md +21 -77
  119. package/skills/w/commands/plan-exec.md +14 -30
  120. package/skills/w/commands/plan-new.md +11 -38
  121. package/skills/w/commands/plan-refine.md +13 -41
  122. package/skills/w/commands/quick.md +13 -20
  123. package/skills/w/commands/resume.md +19 -56
  124. package/skills/w/commands/spec-new.md +28 -69
  125. package/skills/w/commands/spec-refine.md +12 -37
  126. package/skills/w/commands/status.md +12 -55
  127. package/skills/w/commands/workspace-init.md +14 -21
  128. package/skills/w/context/MANIFEST.json +486 -0
  129. package/skills/w/harness/HARNESS.md +1 -1
  130. package/skills/w/hooks/README.md +21 -2
  131. package/skills/w/hooks/hooks.template.json +2 -2
  132. package/skills/w/loops/CHASSIS.md +53 -104
  133. package/skills/w/loops/CODE-POLICIES.md +4 -9
  134. package/skills/w/loops/plan-exec-loop/LOOP.md +5 -12
  135. package/skills/w/loops/plan-new-loop/LOOP.md +8 -32
  136. package/skills/w/loops/plan-refine-loop/LOOP.md +8 -36
  137. package/skills/w/loops/quick-loop/LOOP.md +4 -10
  138. package/skills/w/loops/spec-refine-loop/LOOP.md +7 -49
  139. package/skills/w/modules/ADOPTED-CONTEXT.md +10 -0
  140. package/skills/w/modules/COMPACTION.md +13 -0
  141. package/skills/w/modules/DB-RESEARCH-RULE.md +11 -0
  142. package/skills/w/modules/DB-SCRIPTS-ONLY.md +12 -0
  143. package/skills/w/modules/EXEC-DB-POLICY.md +7 -0
  144. package/skills/w/modules/EXEC-PROBE-TASKS.md +11 -0
  145. package/skills/w/modules/IDEATION-GATE.md +16 -0
  146. package/skills/w/modules/INCREMENTAL-STRATEGY.md +7 -0
  147. package/skills/w/modules/LAUNCH-DETECTION.md +26 -0
  148. package/skills/w/modules/PERSIST-ROUTING.md +16 -0
  149. package/skills/w/modules/PLAN-DESIGN-SPECS.md +12 -0
  150. package/skills/w/modules/PLAN-INPUT.md +26 -0
  151. package/skills/w/modules/PLAN-MODE.md +26 -0
  152. package/skills/w/modules/PLAN-PROBE-TASKS.md +10 -0
  153. package/skills/w/modules/PLAN-REFINE-DESIGN-SPECS.md +7 -0
  154. package/skills/w/modules/PLAN-REFINE-KEYS.md +9 -0
  155. package/skills/w/modules/PLAN-REFINE-SPLIT.md +12 -0
  156. package/skills/w/modules/PLAN-SPLIT-GATE.md +14 -0
  157. package/skills/w/modules/PROBE.md +12 -0
  158. package/skills/w/modules/PROMPT-CONTINUITY.md +13 -0
  159. package/skills/w/modules/RECONNAISSANCE.md +48 -0
  160. package/skills/w/modules/REPLANNING.md +12 -0
  161. package/skills/w/modules/SESSION-NUMBERING.md +19 -0
  162. package/skills/w/modules/SIMULATION-LIFECYCLE.md +11 -0
  163. package/skills/w/modules/SPEC-CHANGE-SHAPE.md +37 -0
  164. package/skills/w/modules/SPEC-REFINE-KEYS.md +14 -0
  165. package/skills/w/modules/SPLIT-GATE.md +42 -0
  166. package/skills/w/modules/WORKSPACE-SCAFFOLD.md +28 -0
  167. package/skills/w/roles/git/ROLE.md +7 -8
  168. package/skills/w/roles/ui-spec/ROLE.md +1 -1
@@ -6,27 +6,27 @@ This document is the **common engine** of the Workline loops: the doctrine every
6
6
 
7
7
  The **5 loops** run this engine; each adds only its deltas:
8
8
 
9
- - [`spec-refine-loop`](spec-refine-loop/LOOP.md) — refines the **spec** in place; deltas: spec gap taxonomy, analyze gate, `## UI spec` via the `ui-design` capability.
10
- - [`plan-new-loop`](plan-new-loop/LOOP.md) — generates the **plan** from the spec; deltas: rich plan + plan gap taxonomy (+ per-screen design SPECs when the plan includes UI).
11
- - [`plan-refine-loop`](plan-refine-loop/LOOP.md) — refines the **plan** in place (auxiliary, not mandatory); reuses the gap taxonomy + coherence gate of `plan-new-loop`. It is to `plan-new` what `spec-refine` is to `spec-new`.
12
- - [`plan-exec-loop`](plan-exec-loop/LOOP.md) — **executes** the plan: code/DB/git, a single session per run, per-phase progress in the plan-doc, no auto-export. Applies the policies in [`CODE-POLICIES.md`](CODE-POLICIES.md).
13
- - [`quick-loop`](quick-loop/LOOP.md) — the engine with **minimal ceremony** (the prompt *is* the objective); also applies [`CODE-POLICIES.md`](CODE-POLICIES.md) (proportional gate).
9
+ - [`spec-refine-loop`](spec-refine-loop/LOOP.md) — refines the **spec** in place.
10
+ - [`plan-new-loop`](plan-new-loop/LOOP.md) — generates the **plan** from the spec.
11
+ - [`plan-refine-loop`](plan-refine-loop/LOOP.md) — refines the **plan** in place (auxiliary).
12
+ - [`plan-exec-loop`](plan-exec-loop/LOOP.md) — **executes** the plan: code, DB and git.
13
+ - [`quick-loop`](quick-loop/LOOP.md) — **minimal ceremony** (the prompt *is* the objective).
14
14
 
15
- ## Persistent objective
15
+ The two that edit code also apply [`CODE-POLICIES.md`](CODE-POLICIES.md).
16
16
 
17
- A loop **is a persistent objective**: it exists to fulfill the `SESSION.Objective` declared at start, and **it is not finished until the convergence gate confirms the objective was met**. Gap-driven iteration is the *method*; the artifacts are the *record*; the persistent objective is the *frame* that governs them.
17
+ ## Persistent objective
18
18
 
19
- This is **harness-agnostic doctrine**, not a host dependency: "don't stop until convergence" is sustained by the loop itself (its `repeat:` + the convergence gate), not by a host hook and it **leaves a durable record** (artifact-first) that survives compaction and resume. *(Rationale and the `/goal` analogy: see the design, `workflow-loops/chassis.md`.)*
19
+ A loop **is a persistent objective**: it exists to fulfill the `SESSION.Objective` declared at start, and **it is not finished until the convergence gate confirms the objective was met**. Gap-driven iteration is the *method*; the artifacts are the *record*; the objective is the *frame*.
20
20
 
21
- > Each heir instantiates the frame: `spec-refine` pursues the spec; `plan-new`/`plan-refine` pursue the plan up to their gate; `plan-exec` pursues the plan up to its final validation; `quick-loop` is the most direct embodiment (the prompt *is* the objective).
21
+ "Don't stop until convergence" is sustained by the loop itself — its `repeat:` plus the convergence gate — never by a host hook, which is what makes it harness-agnostic. Each heir instantiates the frame: `spec-refine` pursues the spec; the plan loops pursue the plan up to their gate; `plan-exec` up to its final validation; `quick-loop` most directly of all (the prompt *is* the objective).
22
22
 
23
- > **Inter-turn continuity.** The same `CHECKPOINT`+resume also governs the **next prompt**: the objective persists **across turns**, not only within a run. The canonical rules (command = new work line · re-run = `create_or_resume` · bare prompt = continue the most recent session · reopening closed sessions · consented escalation) live in [`../SKILL.md`](../SKILL.md) § *Operating context* — **single source**; this engine executes them via *Compact / resume* (case 3).
23
+ > **Inter-turn continuity.** The same `CHECKPOINT`+resume governs the **next prompt**: the objective persists **across turns**, not only within a run. The canonical rules (command = new work line · re-run = `create_or_resume` · bare prompt = continue the most recent session · reopening closed sessions · consented escalation) live in [`../SKILL.md`](../SKILL.md) § *Operating context* — **single source**; this engine executes them via *Compact / resume* (case 3).
24
24
 
25
25
  ## Verification-first
26
26
 
27
27
  The persistent objective needs a **checkable done-condition** — otherwise the loop cannot know when it is done (or chases a target it invented). That condition is **seeded BEFORE executing**, never improvised at the end: it is **generalized TDD**. Together with artifact-first (next section) these are the **two seeds** of every gap/phase: *how will I know it worked* + *what am I about to do*.
28
28
 
29
- **Where it lives:** in `SESSION.Success criteria` (see [`../artifacts/artifacts-core/SESSION.md`](../artifacts/artifacts-core/SESSION.md)) — a `[ ]` checklist of **falsifiable** criteria (that *can* fail). `CHECKPOINT.Pending/Completed` tracks the **red→green** progress. Two forms, by deliverable:
29
+ **Where it lives:** in `SESSION.Success criteria` — a `[ ]` checklist of **falsifiable** criteria (that *can* fail). `CHECKPOINT.Pending/Completed` tracks the **red→green** progress. Two forms, by deliverable:
30
30
 
31
31
  | Deliverable | Criterion = | Cycle |
32
32
  |---|---|---|
@@ -35,18 +35,13 @@ The persistent objective needs a **checkable done-condition** — otherwise the
35
35
  | spec / plan | **rubric** = the document's acceptance criteria (referenced, not duplicated) | rubric |
36
36
  | analysis / design | **rubric falsifiable by inspection** (e.g. "every affected site with `file:line`"; "each decision: rationale + ≥1 alternative") | rubric |
37
37
 
38
- - **Form and weight scale** (quick's minimal ceremony preserved): a chore = "existing tests/build stay green" (one line); a feature = real acceptance tests. The rule is "**always declare the check before**", not "always write new tests".
39
- - **Subjective deliverable** (analysis/design): the AI **proposes** the rubric and the **human ratifies** it (structured-choice) before pursuing it.
40
- - **Unresolvable criterion** (no evidence, DB unavailable): closes as `inconclusive` and the loop **degrades** (asks the human, or defers to `Open questions`/`BACKLOG`) — **never iterates against a fake target**.
41
-
42
- > The **convergence gate** (section *Convergence / exit*) is, operationally, **"all `Success criteria` green"**. The per-heir gates (analyze gate; plan coherence — plan-new and plan-refine; final validation; proportional spot validation) are **instances** of it, with the criteria seeded at start.
38
+ - **Form and weight scale**: a chore = "existing tests/build stay green" (one line); a feature = real acceptance tests. The rule is "**always declare the check before**", not "always write new tests".
39
+ - **Subjective deliverable** (analysis/design): the AI **proposes** the rubric and the **human ratifies** it before pursuing it.
40
+ - **Unresolvable criterion** (no evidence, DB unavailable): closes as `inconclusive` and the loop **degrades** — **never iterates against a fake target**.
43
41
 
44
- **Gate integrity (anti-gaming + independent verification).** The gate only counts if it is not gamed to pass. The loop does **not**:
42
+ > The **convergence gate** is, operationally, **"all `Success criteria` green"**. The per-heir gates are **instances** of it, with the criteria seeded at start.
45
43
 
46
- - modify the check or loosen a `Success criterion` to force green;
47
- - weaken, delete or skip tests/validations;
48
- - use trivial or tautological asserts that always pass (the expected value comes from an independent source, never from the output itself);
49
- - patch the test instead of fixing the cause (prefer fixing production code).
44
+ **Gate integrity (anti-gaming + independent verification).** The gate only counts if it is not gamed to pass. The loop does **not**: modify the check or loosen a `Success criterion` to force green; weaken, delete or skip tests/validations; use trivial or tautological asserts that always pass (the expected value comes from an independent source, never from the output itself); patch the test instead of fixing the cause (prefer fixing production code).
50
45
 
51
46
  Facing a real blocker it **stops and reports it** (→ `Open questions`/`BACKLOG`) instead of gaming the metric. The verdict counts **only the check's output, never the implementer's self-declaration**: when the deliverable warrants it, the final verification is an **independent** pass (subagent or clean re-read) that does not assume the implementation is correct — *only command output counts*.
52
47
 
@@ -66,9 +61,9 @@ The loop works **artifact-first**: the artifact is **seeded before** executing a
66
61
  2. **EXECUTE.** Resolve the gap / run the phase / edit the code.
67
62
  3. **AFTER — bring to actual state.** `CHECKPOINT.Pending → Completed`; `DECISION` records the non-obvious **as it is decided**; `BACKLOG` **only if** something is deferred/follow-up (`session-close` no longer fabricates an empty BACKLOG).
68
63
 
69
- > The artifact expresses the **intent** (Pending/Next, before) and then the **result** (Completed/DECISION, after), at **every** gap/phase boundary — not only on `Compactar`/`Cerrar`. Session artifacts are the run's live log; the spec/plan is the **guiding base**.
64
+ > The artifact expresses the **intent** (before) and then the **result** (after), at **every** gap/phase boundary — not only on `Compactar`/`Cerrar`. Session artifacts are the run's live log; the spec/plan is the **guiding base**.
70
65
 
71
- > **Fixed form (hard rule):** an artifact keeps its template's `##` headings **exactly** and is updated **in place** — appending a **duplicate heading** is a contract violation. When a scaffolded section is filled, its `<!-- … -->` guidance comment is **replaced** by the real content. Canonical headings per artifact: its template under [`../artifacts/`](../artifacts/) (CHECKPOINT contract: `Completed` · `Pending / Next`; `Open questions` only while live doubts exist).
66
+ > **Fixed form (hard rule):** an artifact keeps its template's `##` headings **exactly** and is updated **in place** — appending a **duplicate heading** is a contract violation. A filled section **replaces** its `<!-- … -->` guidance comment. Canonical headings per artifact: its template under [`../artifacts/`](../artifacts/) (CHECKPOINT: `Completed` · `Pending / Next`; `Open questions` only while live doubts exist).
72
67
 
73
68
  ## Gap-driven convergent engine
74
69
 
@@ -82,126 +77,80 @@ The common cycle — each heir instantiates it in its `## Sequence` with its own
82
77
 
83
78
  ## Internal sessions (managed) — one session per run
84
79
 
85
- The loop creates and manages its session under `.workflow/sessions/`. **The user never creates it.** **A single session per run**, owning the run: it keeps progress live (`CHECKPOINT`) and enables resume. Artifacts: `SESSION.md` · `CHECKPOINT.md` (· `BACKLOG.md` only if something is deferred; code-editing loops add `DECISION` and `SCRIPTS.sql`). Each heir declares its descriptor and `Type` in its own `## Internal sessions`.
86
-
87
- > **INLINE research** — investigation is **not** a separate session: it is an activity **inside the current session** that writes its artifacts (`ANALYSIS-FILE`/`CONCLUSIONS`, + read-only `SCRIPTS.sql` if it queries DB) **into the run's own session folder**. See *Research: autonomy, scope & failure*.
88
-
89
- > The flow's input document (spec/plan) **never** goes inside a session; it lives in `docs/`.
80
+ The loop creates and manages its session under `.workflow/sessions/`; **the user never creates it**. **A single session per run**: it keeps progress live (`CHECKPOINT`) and enables resume. Artifacts: `SESSION.md` · `CHECKPOINT.md` (· `BACKLOG.md` only if something is deferred; code-editing loops add `DECISION` and `SCRIPTS.sql`). Each heir declares its descriptor and `Type` in its own `## Internal sessions`.
90
81
 
91
- ### Session numbering (hard rule)
82
+ > Research is **inline** — an activity inside this same session, never a session of its own — and the flow's input document (spec/plan) **never** goes inside a session; it lives in `docs/`.
92
83
 
93
- The **CLI owns the number**: `aw session-create` prepends a **global, sequential** `NNN` by scanning **all** sessions under `.workflow/sessions/` (any type). The caller passes **only the descriptor** via `--name` **never** a number. Numbering neither restarts per type nor collides, and every folder is **self-describing**: `NNN-<slug>-<flow>` (e.g. `002-correo-otp-spec-refine`, `003-correo-otp-plan-new`, `004-correo-otp-plan-exec`, `005-validacion-correo-quick`).
84
+ **CLI**: `aw session-create --type <type> --name <slug>-<flow> --objetivo "<one-line objective>"` opens it · `aw checkpoint-write` / `aw checkpoint-read` keep it resumable · `aw session-close` closes it and upserts its HISTORY.md row.
94
85
 
95
- > `<run>` = the session's **descriptor** (no number), always shaped **`<slug>-<flow>`**: `<slug>-spec-refine`, `<slug>-plan-new`, `<slug>-plan-refine`, `<slug>-plan-exec`, `<slug>-quick`. The `<slug>` is **descriptive** and comes from the flow's input doc `docs/specs/NNN-spec-<slug>.md` for spec-refine/plan-new; `docs/plans/PPP-plan-<slug>.md` for plan-refine/plan-exec; the prompt for quick so the folder says at a glance what it is about, not just which flow created it. Research being **inline** in this same session, there are no child `*-research-*` sessions to number (compat: old ones are historical).
96
- >
97
- > **Resume**: locate the existing session by **scanning** `.workflow/sessions/` for descriptor + `## Origin` (which spec/plan), **not** by reconstructing the number (global, not derivable from the artifact). `aw session-resume --code <NNN | folder>` resolves both forms.
98
-
99
- **CLI**:
100
-
101
- - `aw session-create --type <type> --name <slug>-<flow> --objetivo "<one-line objective>"` → creates `NNN-<slug>-<flow>` / `aw session-resume --code <…>` (detects `CHECKPOINT`).
102
- - `aw checkpoint-write` / `aw checkpoint-read` for resume.
103
- - `aw session-close` on close — also upserts the session's HISTORY.md row (the durable record; sessions/ is gitignored). Non-fatal: on `history_error` in its output, re-run `aw history-update --code <NNN> --state closed`. `aw session-artifacts` to inspect.
104
- - **Reopen to continue** (operating context, row 2): `aw session-resume --code <NNN> --reopen` reactivates a **closed** session (removes `.closed` → active) to keep working in it; without `--reopen`, resume is read-only. To detect the most recent closed one: `aw resume-summary --include-recent-closed` (or `aw sessions --state all`).
86
+ > The caller passes **only the descriptor** via `--name` **never** a number; the CLI owns the global `NNN`. How it is assigned, how a session is located or reopened, and how a failed history upsert is repaired, are in the `sessions` module.
105
87
 
106
88
  ## Ask-vs-research rule (the discriminator)
107
89
 
108
90
  For every gap, a single question picks the resolver:
109
91
 
110
- > *"Was this already established in the current conversation?"* → **adopt it** (see *Adopted context*) — never re-ask or re-research settled conclusions.
92
+ > *"Was this already established in the current conversation?"* → **adopt it** (`adopted` module) — never re-ask or re-research settled conclusions.
111
93
  > *"Can I answer this by reading the repo/data?"* → **research** (autonomous).
112
- > *"Can I only answer it by RUNNING a small experiment?"* → **probe** (see *Proof of concept*).
94
+ > *"Can I only answer it by RUNNING a small experiment?"* → **probe** (`probe` module).
113
95
  > *"Does it depend on what the user wants?"* → **ask the human** (structured-choice).
114
96
 
115
- ## Adopted context (host as producer)
116
-
117
- The host is not only the loop's executor — it is a legitimate **producer** of input. Conclusions **already established in the current conversation** (a host-native analysis, answers the user already gave, a plan built with the host's planner) count as **completed research**: on entry, **adopt** them — seed `SESSION.Objective`/`Success criteria`, reference them in `CONCLUSIONS`, record provenance (`## Origin` = adopted from the host conversation) — never re-derive or re-ask them.
118
-
119
- - Adoption is **transcription, not trust**: the convergence gate still verifies adopted conclusions (*gate integrity*); anti-duplicate still applies.
120
- - Materialization pattern = the quick escalation's (single-pass, **NO RESEARCH**), inverted: **host → flow**.
121
- - Gap signals already resolved by adopted context do **not** fire (e.g. "ambiguous requirements" after a host pre-analysis).
122
- - To persist finished work without a loop: [`/w:persist`](../commands/persist.md) (transversal).
123
-
124
97
  ## Research: autonomy, scope & failure
125
98
 
126
- Investigation is **inline**: an activity **inside the run's current session**, never a separate session. It writes its artifacts (`ANALYSIS-FILE` → `CONCLUSIONS`, + read-only `SCRIPTS.sql` if it queries DB) into the **session's own folder**.
127
-
128
- - **Autonomous**: the AI investigates inline and reports **without asking permission**. The human learns of it at integration time (in the flow's decision record — each heir names its own) and keeps control via the `flow` control.
129
- - **Scope**: the current conversation (*adopted context* — settled conclusions are reused, never re-derived) + workspace + associated repos (sources) + DB MCPs.
130
- - **DB rule** (the single exception to autonomy):
131
- 1. **MCP choice**: if the gap needs DB and there is **>1 candidate MCP with no configured default**, the AI asks which one to use. That question goes through the **same structured-choice** as a **content question** (counts inside the ≤3 + `flow` limit), **before** running queries. A single MCP or a default → no question.
132
- 2. Write the queries **first** into the session's `SCRIPTS.sql`.
133
- 3. Execute them **read-only** via MCP (respect `sql-mutation-guard`: never DML/DDL).
134
- - **Inconclusive research** (DB unavailable, insufficient evidence, unresolvable factual gap):
135
- - The investigation closes with status **`inconclusive`** in `CONCLUSIONS` and reports why.
136
- - The loop **degrades** the gap: to a **human question** (next batch → the flow's decision record) or, failing that, **defers** it to the flow doc's `## Open questions` (spec/plan) — or the session's `BACKLOG` when the flow has no doc (quick).
137
- - The gap is marked **"already tried via research"** (`attempts[gap]++`, `MAX` cap) so `detect_gaps` does **not** re-fire it in a loop → guarantees convergence.
138
-
139
- ## Proof of concept (probe)
99
+ Investigation is **inline**: an activity **inside the run's current session**, never a separate session. It writes its artifacts (`ANALYSIS-FILE` → `CONCLUSIONS`, + read-only `SCRIPTS.sql` if it queries DB) **into the session's own folder**.
140
100
 
141
- A **probe** (PoC / spike) is the resolver for **executable doubt**: research *reads*, a probe *runs* — an **atomic, throwaway-by-default** experiment answering **one falsifiable question** (does this connection / SDK / UI behavior work as assumed?). De-risk atomic parts **early**, never everything at the end.
142
-
143
- - **When**: risky assumption + not answerable by reading + failure would invalidate downstream work. Proposed via **structured-choice**.
144
- - **Lifecycle** (verification-first applies to the probe): seed question + pass/fail check **BEFORE** run minimal verdict in `CONCLUSIONS` (consequences `DECISION`) **discard** or promote to a real task/test.
145
- - **Isolation**: probe code lives in the **session folder** (gitignored) — never the source tree, **never committed**; DB probes are read-only (never DDL/DML).
146
- - A **failed probe is a finding, not a failure** — report it; the human decides if the plan reshapes.
101
+ - **Autonomous**: the AI investigates inline and reports **without asking permission**. The human learns of it at integration time and keeps control via the `flow` control.
102
+ - **Scope**: the current conversation (settled conclusions are reused, never re-derived) + workspace + associated repos + DB MCPs.
103
+ - **DB rule** the single exception to autonomy: it lives in the `db` module and is loaded **before** any query runs.
104
+ - **Inconclusive research** (DB unavailable, insufficient evidence, unresolvable factual gap): the investigation closes with status **`inconclusive`** in `CONCLUSIONS` and reports why. The loop **degrades** the gap to a human question, or failing that to the flow doc's `## Open questions` (the session's `BACKLOG` when the flow has no doc) and marks it **"already tried via research"** (`attempts[gap]++`, `MAX` cap) so `detect_gaps` does **not** re-fire it in a loop. That is what guarantees convergence.
147
105
 
148
106
  ## Structured-choice (design & batching)
149
107
 
150
108
  **Canonical rule (single source — the rest of the corpus only references it):** *structured-choice* = **≤3 content questions + 1 `flow` control**, always. Per-harness binding in [`../harness/HARNESS.md`](../harness/HARNESS.md) (Claude Code: `AskUserQuestion`, max 4 questions/call; without structured choice it degrades to **numbered markdown**).
151
109
 
152
- - Since the `flow` control is **always** present **≤3 content questions + 1 `flow` control**.
153
- - **`flow` control** (lifecycle, always present): `Compactar` | `Cerrar`. Answering only the content questions (not touching `flow`) = keep iterating.
154
- - **Proactive raise**: under context pressure the loop does not wait for the next content batch — it raises the structured-choice itself, with `Compactar` as the recommended action (see *Compact / resume* *Self-regulation (proactive compaction)*).
155
- - **Content questions** can be:
156
- - human doubts (non-factual gaps);
157
- - MCP choice (DB rule) — before running queries;
158
- - at **convergence**, the loop's own closing action — **each heir defines it in its *Convergence / exit*** (e.g. `Guardar especificación refinada` · `Cerrar tarea`) — | `Preguntar algo más`.
159
- - **Batching**: group up to 3 human gaps in one call. With more than 3 pending, prioritize (the ones that unblock other gaps first) and defer the rest to the next round.
160
- - **Recommended answer per question**: every content question **always** carries the AI's recommended answer — as the first option (marked *recommended*) in `AskUserQuestion`, or flagged in the numbered-markdown fallback. Never ask "cold": the human ratifies or corrects a proposal, never starts from zero. The AI recommends based on what it researched (ask-vs-research rule), never on an empty default.
110
+ - **`flow` control** (lifecycle, always present): `Compactar` | `Cerrar`. Answering only the content questions = keep iterating. Under context pressure the loop **raises the choice itself**, with `Compactar` recommended.
111
+ - **Content questions** are: human doubts (non-factual gaps) · MCP choice (DB rule), before running queries · at **convergence**, the loop's own closing action — each heir defines it in its *Convergence / exit* (e.g. `Guardar especificación refinada` · `Cerrar tarea`) | `Preguntar algo más`.
112
+ - **Batching**: up to 3 human gaps per call; with more pending, prioritize the ones that unblock others and defer the rest.
113
+ - **Recommended answer per question**: every content question **always** carries the AI's recommended answer — the first option, marked *recommended*. Never ask "cold": the human ratifies or corrects a proposal, never starts from zero. The recommendation comes from what was researched (ask-vs-research rule), never from an empty default.
161
114
 
162
- > **Label language:** the literal option labels (`Compactar`, `Cerrar`, `Guardar plan`, …) are **canonical product strings** — present them **verbatim**; they are user-facing, authored in the product's user language (Spanish). All other user-facing output follows [`../SKILL.md`](../SKILL.md) § *Language policy*.
115
+ > **Label language:** the literal option labels (`Compactar`, `Cerrar`, `Guardar plan`, …) are **canonical product strings** — present them **verbatim**. All other user-facing output follows [`../SKILL.md`](../SKILL.md) § *Language policy*.
163
116
 
164
117
  ## Compact / resume
165
118
 
166
119
  Resume **keys off the `CHECKPOINT`** of the run's session, not the existence of a separate file. Three cases when the flow's command runs over an input:
167
120
 
168
121
  1. **In progress** (a `CHECKPOINT.md` exists in the session) → resume from the recorded progress (resolved gaps, Q&A, `attempts`, in-flight inline research).
169
- 2. **No progress** (no CHECKPOINT and the input doc does **not** have the flow's prior-work mark) → start from zero reading the input doc (plus any *adopted context* — settled in-conversation conclusions are input, not something to re-derive).
170
- 3. **Already converged / re-run on demand** (no open CHECKPOINT but the doc **already has** the mark) → **first-class operation**: while the flow stays in its stage, re-running the command over the same input **as many times as needed** is supported. `create_or_resume` finds the existing session — typically **closed** after convergence — by descriptor + `## Origin` and **reopens** it (see *Internal sessions*: detection via `aw sessions --state all` / `aw resume-summary --include-recent-closed`, reopening via `aw session-resume --code <NNN> --reopen`); incremental work reading the **doc itself**.
171
-
172
- > Each heir defines its **prior-work mark** and its own legacy tolerances: spec-refine keys off the spec's frontmatter `status`; plan-refine off `## Refinement decisions` in the plan; plan-exec off the plan-doc's `- [x]` checkboxes; quick has no doc (resume by CHECKPOINT only).
122
+ 2. **No progress** (no CHECKPOINT and the input doc does **not** have the flow's prior-work mark) → start from zero reading the input doc (plus any settled in-conversation conclusions, which are input, not something to re-derive).
123
+ 3. **Already converged / re-run on demand** (no open CHECKPOINT but the doc **already has** the mark) → **first-class operation**: while the flow stays in its stage, re-running the command over the same input **as many times as needed** is supported. `create_or_resume` finds the existing session — typically **closed** after convergence — by descriptor + `## Origin` and **reopens** it; incremental work reading the **doc itself**.
173
124
 
174
- > **`Compactar`** (the `flow` control, across all 3 cases) write `CHECKPOINT.md` in the session (in-flight progress, remaining gaps, Q&A, `attempts`) trigger the harness **compaction** (Claude Code: `/compact`; see [`../harness/HARNESS.md`](../harness/HARNESS.md)) → resume by reading the checkpoint.
125
+ > Each heir defines its **prior-work mark**: spec-refine the spec's frontmatter `status`; plan-refine `## Refinement decisions`; plan-exec the plan-doc's `- [x]` checkboxes; quick has no doc (CHECKPOINT only).
175
126
 
176
- ### Self-regulation (proactive compaction)
177
-
178
- `Compactar` is not only reactive: the loop **watches its own context pressure** and raises compaction itself.
179
-
180
- - **Signal**: the host's context-pressure signal when it exists (see the *compaction* capability in [`../harness/HARNESS.md`](../harness/HARNESS.md)); with no signal the fallback is **qualitative** — at batch/phase boundaries of an already-long run, ask *"would a fresh reader need the CHECKPOINT to continue?"*. Doctrine fixes **no numeric thresholds** (harness-agnostic).
181
- - **Modes** — config `[compaction]` table in `.workflow/skills.toml`, key `mode` (values `confirm` | `auto`):
182
- - **`confirm`** (default, also with no config): raise a **proactive structured-choice** whose `flow` control carries `Compactar` as the recommended action — the human ratifies; consent is never skipped.
183
- - **`auto`** (opt-in): write `CHECKPOINT.md`, then trigger the host's compaction binding **without asking**. Viable only where the host has a **non-interactive** mechanism (see the *Harness binding matrix*); otherwise it **degrades to `confirm`**.
184
- - **Invariant — CHECKPOINT before compacting**: in every mode, `CHECKPOINT.md` is written (or verified fresh) **before** any compaction fires; resume keys off it (the 3 cases above).
127
+ > **`Compactar`** (the `flow` control, across all 3 cases) → write `CHECKPOINT.md` in the session → trigger the harness compaction → resume by reading the checkpoint. **CHECKPOINT before compacting** is invariant. The proactive raise, its two modes and their host binding live in the `compaction` module.
185
128
 
186
129
  ## Convergence / exit
187
130
 
188
- - **No material gaps** → **convergence gate** (read-only) = **`Success criteria` green** (*verification-first*). Whatever fails **comes back as a gap**; if it passes → the loop **flips the green criteria** in `SESSION.md` (`- [ ]` → `- [x]`) and offers its closing action. The checklist must reflect the real final state: a criterion left unchecked at `finalize` needs an explicit reason (`Open questions`/`BACKLOG`). The heirs are **instances** of the same gate: `spec-refine` = analyze gate, `plan-new` and `plan-refine` = plan coherence, `plan-exec` = final validation, `quick` = proportional spot validation.
189
- - `Cerrar` (the `flow` control, at any time) → `finalize`. **`finalize` always persists `CHECKPOINT.md`** (resumable) and, **only if something was deferred/follow-up**, writes `BACKLOG.md` (close reason + the deferred items); closes the session and reports. Progress survives even without a prior `Compactar`.
131
+ - **No material gaps** → **convergence gate** (read-only) = **`Success criteria` green** (*verification-first*). Whatever fails **comes back as a gap**; if it passes → the loop **flips the green criteria** in `SESSION.md` (`- [ ]` → `- [x]`) and offers its closing action. The checklist must reflect the real final state: a criterion left unchecked at `finalize` needs an explicit reason. Each heir names its own instance of this gate.
132
+ - `Cerrar` (the `flow` control, at any time) → `finalize`. **`finalize` always persists `CHECKPOINT.md`** (resumable) and, **only if** something was deferred, writes `BACKLOG.md` (close reason + the deferred items); closes the session and reports. Progress survives even without a prior `Compactar`.
190
133
 
191
134
  ## docs/ boundary — no auto-export (hard rule)
192
135
 
193
- A loop writes into `docs/` **only** its own flow's doc (spec-refine: `docs/specs` · plan-new/plan-refine/plan-exec: `docs/plans` · quick: **none** — it never touches `docs/`). No loop **graduates/promotes artifacts** into `docs/`: everything else (migrations → `docs/scripts`, manuals → `docs/manuals`, diagrams → `docs/diagrams`, …) is done by the separate **`export-*`** skills, as an explicit later step. Artifacts stay in their sessions until then. If a task creates a tool/utility, the ambient skill `creating-tools` documents it in `docs/tools` (auto-discovered by its `description`; Workline is **indifferent** — it does not bind it).
136
+ A loop writes into `docs/` **only** its own flow's doc (spec-refine: `docs/specs` · the three plan flows: `docs/plans` · quick: **none** — it never touches `docs/`). No loop **graduates/promotes artifacts** into `docs/`: migrations → `docs/scripts`, manuals → `docs/manuals`, diagrams → `docs/diagrams` are done by the separate **`export-*`** skills, as an explicit later step; artifacts stay in their sessions until then. A task that creates a tool/utility has it documented in `docs/tools` by the ambient `creating-tools` skill (auto-discovered; Workline does not bind it).
194
137
 
195
- ## Code-editing loop policies → CODE-POLICIES.md
138
+ ## Conditional modules
196
139
 
197
- The loops that **edit code** (`plan-exec-loop`, `quick-loop`) additionally run the policies in [`CODE-POLICIES.md`](CODE-POLICIES.md) **safe git** (verified branch + proposed commits) · **DB scripts-only** · **closing review gate** (proportional in quick). They order it read from their `## Inherits` **together with this chassis**; the document loops (spec-refine, plan-new, plan-refine) do **not** load it that is why it lives in a separate doc.
140
+ The engine above is what every run needs. The branches below apply only under their signal, and `aw context-plan` returns them exactly thennever just in case:
141
+
142
+ - `adopted` → [`../modules/ADOPTED-CONTEXT.md`](../modules/ADOPTED-CONTEXT.md) · `probe` → [`../modules/PROBE.md`](../modules/PROBE.md) · `db` → [`../modules/DB-RESEARCH-RULE.md`](../modules/DB-RESEARCH-RULE.md)
143
+ - `compaction` → [`../modules/COMPACTION.md`](../modules/COMPACTION.md) · `sessions` → [`../modules/SESSION-NUMBERING.md`](../modules/SESSION-NUMBERING.md)
144
+ - `code` → [`CODE-POLICIES.md`](CODE-POLICIES.md), which the two code-editing loops order read from their `## Inherits`
198
145
 
199
146
  ## Reference resolution (global layout rule) — and what the chassis is NOT
200
147
 
201
148
  Applies to **every** relative reference in the doctrine — never repeated per link:
202
149
 
203
- 1. **Normal install** (the `w/` tree): the relative path resolves as-is (`../CHASSIS.md`, `../../commands/spec-new.md`).
204
- 2. **Synthesized command skills** (hosts without a commands dir — Codex/Warp/Oz): each command installs as a **sibling** skill `w-<command>/` with its references rewritten into the bundle (`../loops/…` → `../w/loops/…`); the `w/` tree stays intact, so loop-to-loop references resolve as a normal install.
205
- 3. A reference that does not resolve = **optional deep-dive** — this engine's doctrine is self-contained.
150
+ 1. **Normal install** (the `w/` tree): the relative path resolves as-is.
151
+ 2. **Synthesized command skills** (hosts without a commands dir): each command installs as a sibling skill `w-<command>/` with its references rewritten into the bundle (`../loops/…` → `../w/loops/…`).
152
+ 3. A reference that does not resolve = **optional deep-dive** — this engine is self-contained.
153
+
154
+ > `aw context-plan` hands back **absolute** paths, so a run that asks the CLI for its read-set resolves no relative reference at all. This rule is the fallback for one that does not ask.
206
155
 
207
- The chassis **is not a skill** (no frontmatter; never invoked nor bound via `.workflow/skills.toml`): it enters the context only because a loop orders it read from its `## Inherits`. It does not define flow, deliverable or gap taxonomy — that belongs to each heir.
156
+ The chassis **is not a skill** (no frontmatter; never invoked nor bound): it enters the context only because a loop orders it read from its `## Inherits`. It does not define flow, deliverable or gap taxonomy — that belongs to each heir.
@@ -9,15 +9,6 @@ They apply to **`plan-exec-loop`** (per plan phase) and **`quick-loop`** (the si
9
9
  - **Rejected commit**: the changes **stay in the working tree** (never reverted). Re-proposing / editing the message is allowed. Record in `CHECKPOINT` + `BACKLOG` that the phase/task remained **uncommitted** (resumable).
10
10
  - **Between-phase precondition** (plan-exec): `branch-check` validates branch *identity*, **not** working-tree *cleanliness*. Before starting the next phase, each source's working tree must be **clean** (committed) or explicitly **acknowledged** as "uncommitted changes from phase N" — so two phases never co-mingle in one commit.
11
11
 
12
- ## DB scripts-only — the AI never executes DML/DDL
13
-
14
- Distinguished by **execution**, not by file (see the [`SCRIPTS.sql`](../artifacts/artifacts-core/SCRIPTS.sql) schema):
15
-
16
- - **Read-only queries** (diagnosis/validation) → `SCRIPTS.sql` (session artifact); the AI **does** execute them read-only via MCP (`sql-mutation-guard`).
17
- - **DDL/DML migrations** (schema/data changes) → the AI **drafts them in `SCRIPTS.sql`** (session artifact) but **NEVER executes them**.
18
-
19
- > Mutating SQL **stays in the session**; it is never moved to `docs/`. Its promotion to `docs/scripts/` (forward + rollback) is done by a separate `export-*`, never by the loop.
20
-
21
12
  ## Closing review gate (conventions, pre-commit)
22
13
 
23
14
  After validation (of the phase in plan-exec; of the task in quick, proportional) and **before proposing its commits** (also on an early `Cerrar`, before proposing the pending commits), the diff passes a **closing review gate**:
@@ -36,3 +27,7 @@ Only with the gate green are the commits proposed.
36
27
  ## Location
37
28
 
38
29
  Same as the chassis: code-editing loops reference it as `../CODE-POLICIES.md` — the `w/loops/` tree is installed intact on every host (chassis § *Reference resolution*).
30
+
31
+ ## Conditional modules
32
+
33
+ - `db` — the DB scripts-only rule → `../modules/DB-SCRIPTS-ONLY.md`
@@ -110,10 +110,6 @@ On either return path: `CHECKPOINT` records the state reached and the trigger, t
110
110
 
111
111
  Full policy in [`../CODE-POLICIES.md`](../CODE-POLICIES.md) (§ *Safe git*: branch-check before editing, rejected commit — changes stay + get recorded —, working-tree precondition between phases). **Inline:** before editing, verify each source's expected branch (`aw check-branch --source <alias>`; on mismatch → pause and resolve with the human); at each phase close and **after the review gate** (Delta 5), **proposed commits per source** (approve first) — never `push`/`--amend`/`--no-verify`.
112
112
 
113
- ## Delta 3 — DB policy: **the AI never executes DML**
114
-
115
- Full policy in [`../CODE-POLICIES.md`](../CODE-POLICIES.md) (§ *DB scripts-only*). **Inline:** read-only queries → the session's `SCRIPTS.sql`, executed via MCP (`sql-mutation-guard`); DDL/DML migrations → the AI **drafts them in `SCRIPTS.sql` but NEVER executes them** — their promotion to `docs/scripts/` is done by a separate `export-*`, never this loop.
116
-
117
113
  ## Delta 4 — Validation: phase proof + progressive tests
118
114
 
119
115
  - The phase's **primary proof** is its `Validación de fase`: it demonstrates the **state reached**, not the structure written. Three levels, and the loop never descends one automatically:
@@ -142,14 +138,6 @@ Full gate in [`../CODE-POLICIES.md`](../CODE-POLICIES.md) (§ *Closing review ga
142
138
  - **Legacy status line, migrated on write.** A plan carrying the old single-line form (`> Estado: done — YYYY-MM-DD · sesión NNN`) is still **read** as closed; the first time this loop legitimately writes that document, it is rewritten to the two-line form. Compatibility is for reading old plans — every new write uses the normalized contract.
143
139
  - **No automatic export**: the artifacts (`SCRIPTS.sql`, `DECISION`, …) stay in the session. Promoting them to `docs/` (scripts, manuals, …) is a separate step via `export-*`.
144
140
 
145
- ## Delta 7 — Probe (PoC) tasks
146
-
147
- Chassis § *Proof of concept (probe)*, instantiated for execution — for a plan's explicit probe task or a runnable doubt inside a task:
148
-
149
- - Seed the question + pass/fail check → run **throwaway code in the session folder** (never the source tree, never committed; DB probe = read-only) → verdict in `CONCLUSIONS`, consequences in `DECISION` (tagged by task) → mark the task with its verdict.
150
- - A **failed probe does not fail the phase** — it de-risked it: surface it (structured-choice); reshaping the plan goes to `Open questions` + `BACKLOG` (or `/w:plan-refine`).
151
- - **Promotion**: probe code reaches the sources only as a normal task edit (branch-check + review gate) — never by committing the probe.
152
-
153
141
  ## Sequence
154
142
 
155
143
  ```
@@ -210,3 +198,8 @@ finalize: CHECKPOINT (+ BACKLOG if something is deferred) + close session + repo
210
198
  - A **structural deviation** or a **functional change** exits this loop without converging (§ *Deviation gate*): `CHECKPOINT` + `finalize`, and the work continues in `plan-refine` / `spec-refine`. Same exit when the entry gate finds a structural gap.
211
199
  - `Cerrar` (`flow` control, at any time) → `finalize` persists `CHECKPOINT` (and `BACKLOG` only if something remained unexecuted / uncommitted / unapplied), closes the session, reports.
212
200
  - Promoting artifacts to `docs/` (via `export-*`) is **always** a later, explicit step outside this loop.
201
+
202
+ ## Conditional modules
203
+
204
+ - `probe` — probe (PoC) tasks → `../../modules/EXEC-PROBE-TASKS.md`
205
+ - `db` — the DB policy → `../../modules/EXEC-DB-POLICY.md`
@@ -33,7 +33,7 @@ PLAN
33
33
 
34
34
  > **slug**: short kebab-case derived from the spec's Requirement — only `[a-z0-9-]`, ≤ ~5 words / ≤ 40 chars. `aw next-number docs/plans` returns JSON (field `next` = `PPP`); the loop builds the full name. To locate plans, glob `docs/plans/PPP-plan-*.md`.
35
35
 
36
- > **Adoption (command mode 4):** an **externally-built plan** (host plan mode, hand-written, another agent) is materialized by the **command** in a single pass — this loop does not run: transcribe + normalize into the Delta 1 schema, `## Origin` = "adopted from <source>" + attribution; then `plan-refine` closes schema gaps (its coherence gate degrades for spec-less plans). See `../../commands/plan-new.md` § *Input resolution*.
36
+ > **Adoption (command mode 4):** an **externally-built plan** (host plan mode, hand-written, another agent) is materialized by the **command** in a single pass — this loop does not run: transcribe + normalize into the Delta 1 schema, `## Origin` = "adopted from <source>" + attribution; then `plan-refine` closes schema gaps (its coherence gate degrades for spec-less plans). See `../../modules/PLAN-INPUT.md` (the command's `input` module).
37
37
 
38
38
  ## Inherits
39
39
 
@@ -124,10 +124,6 @@ A `### Fn` block is a **verifiable state of the system**, never a list of layers
124
124
 
125
125
  **Granularity is semantic, not mechanical.** A phase earns its place when it leaves a demonstrable state, can be reviewed as a unit, and — when the change carries temporary behavior — moves or retires a simulation. A task is a **coherent unit of purpose** and may touch several files. Naming an edit operation — "create class X", "add method Y", "update the import" — describes a **micro step**: internal to execution, recorded in `CHECKPOINT` when a resume needs it, never a plan entry. `XS–S` stays an orientation of risk and scope; it never mandates splitting a semantic task into mechanical operations.
126
126
 
127
- ## Incremental strategy (reference, never a template)
128
-
129
- A change spread over consumer, service and data often lands well as: consumer shell → minimal real integration → vertical skeleton → real implementation from the source outwards → hardening → finish. **Reference to adapt, never a mandatory shape.** Backend-only, CLI, batch, library and database-only changes have their own journey, and inserting a layer the project does not have fails the minimality lens. A small change may be **one phase**, when that phase already is a coherent verifiable state.
130
-
131
127
  ## Delta 2 — Gap taxonomy (of "plan")
132
128
 
133
129
  Replaces the spec gap taxonomy with a planning-oriented one:
@@ -156,33 +152,6 @@ Replaces the spec gap taxonomy with a planning-oriented one:
156
152
 
157
153
  The chassis' **inline** research specializes: mapping **code/impact** — affected FE/BE/DB components, AS-IS wiring, dependencies. It feeds `Solution` (its AS-IS → TO-BE delta) and `Impacted`. The chassis DB rule applies unchanged (read-only queries into `SCRIPTS.sql`, MCP chosen via a content question when >1 without default).
158
154
 
159
- ## Delta 4 — Design SPECs (when the plan includes UI)
160
-
161
- The **UI without design SPEC** gap is resolved by **composing** the **`ui-design`** capability (built-in default [`ui-spec`](../../roles/ui-spec/ROLE.md); rebindable via `.workflow/skills.toml`; `off` → degrades to human / `Open questions`):
162
-
163
- - It authors **one design SPEC per screen** as a session artifact: `NNN-SPEC-<SLUG>.md` (numbering local to the session — see [`SPEC.md`](../../artifacts/artifacts-design/SPEC.md)).
164
- - It **derives** from the spec's `## UI spec` section when present (splits it per screen and raises it to executable detail); otherwise it authors from the `Requirement` (design system/theme/ambiguities via *structured-choice*, counts in the batch).
165
- - The plan's **UI Tasks reference** their SPEC's path — that reference is the **source of truth** — and `plan-exec-loop` reads them as the design reference.
166
- - It is the chassis' composed-capability resolution mode (next to *research*, *probe* and *human*).
167
-
168
- ## Delta 5 — Probe (PoC) tasks — de-risk early
169
-
170
- Chassis § *Proof of concept (probe)*, instantiated for planning. Two placements:
171
-
172
- - **Plan-shaping unknown** (the `Solution` itself depends on the answer) → run the probe **inline now**; the verdict (`CONCLUSIONS`) feeds `Solution` / `Risks / impact`.
173
- - **Execution-time risk** (a task will build on a risky, runnable assumption) → encode an explicit **probe task**, placed **early** — before the tasks that depend on its verdict; the matching `Risks / impact` entry references it.
174
-
175
- ## Split gate (multi-plan)
176
-
177
- Resolves the **Plan splittable** gap (Delta 2) — the canonical definition for **both** plan loops (`plan-refine-loop` references it, never redefines it). It fires **only on clear signals** (≥2 of: tranches independently executable/deliverable · no shared deps/risk between tranches · different requested moments/priorities · the plan far exceeds S-complexity phases · the user asked for staging); borderline → **one plan, no question**. It can be assessed during decomposition or at the coherence gate, always **before** `Guardar`.
178
-
179
- - **The offer** enters the batch as a **content question** (counts in the ≤3): the body shows the proposed cut in the **user's language** — per sibling, a name + slug, a 1-line scope, the phase mapping and the order. Labels: `Dividir en varios planes` (recommended when the signals hold) | `Un solo plan`. Declining marks the gap **exhausted** (no re-offer this run); a free-form answer adjusts the cut. The accepted cut is seeded into `CHECKPOINT` — a resume does **not** re-ask.
180
- - **Anti-duplicate** (the `create_or_resume` spirit): if sibling plans whose `## Origin` references this same spec/split already exist, the recommended option becomes resuming them (`/w:plan-refine` / `/w:plan-exec` semantics) — never a second set.
181
- - **On acceptance** — same run, same session (one session per run, one HISTORY row): **all N siblings are elaborated complete** in this run — each gets the full Delta 1 schema and is immediately executable (`plan-exec` runs any plan; a seed without `## Tasks` would break that contract). Context pressure is absorbed by self-regulation (chassis § *Compact / resume*). Numbering: `aw next-number docs/plans` **immediately before each write** — numbers come out consecutive, so every sibling path is known after the first mint.
182
- - **Sibling contract**: each `## Origin` records the shared source spec + `split (part i/N)` + the **siblings by path** + the order; `## Dependencies` (the existing optional section) carries the inter-plan order — **acyclic and advisory** (`plan-exec` does not enforce it; it only orients what to attack first).
183
- - **Coherence gate, re-framed**: every spec acceptance criterion traces to **exactly one** sibling — a **complete, disjoint partition**; each sibling's Final behavior block (in `## Solution`) covers its subset; the union covers the spec. Spec-less plans anchor the partition to their own Final behavior block / `Validations`.
184
- - **Closing action** on the split branch: `Guardar planes` (the single-plan branch keeps `Guardar plan`).
185
-
186
155
  ## Sequence
187
156
 
188
157
  ```
@@ -229,3 +198,10 @@ finalize: CHECKPOINT persisted (+ BACKLOG only if something is deferred) + close
229
198
  - `Cerrar` at any time → `finalize` (persists `CHECKPOINT`; `BACKLOG` only if something is deferred; closes the session, reports).
230
199
 
231
200
  > **After generating:** the plan can go straight to `plan-exec`, or — if changes arise before executing (new requirements, scope adjustments) — pass through [`plan-refine-loop`](../plan-refine-loop/LOOP.md) (`/w:plan-refine`, auxiliary and **not mandatory**), which refines it in place.
201
+
202
+ ## Conditional modules
203
+
204
+ - `split` — the canonical multi-plan gate → `../../modules/PLAN-SPLIT-GATE.md`
205
+ - `split` — the incremental journey shape → `../../modules/INCREMENTAL-STRATEGY.md`
206
+ - `ui` — per-screen design SPECs → `../../modules/PLAN-DESIGN-SPECS.md`
207
+ - `probe` — probe (PoC) tasks → `../../modules/PLAN-PROBE-TASKS.md`
@@ -91,10 +91,6 @@ Reuses plan-new-loop's gap taxonomy **in full** ([`plan-new-loop`](../plan-new-l
91
91
 
92
92
  Same as plan-new (maps code/impact: FE/BE/DB components, AS-IS wiring, deps), but **scoped to the delta**: it re-verifies only what the change touches (never re-maps the whole plan). Chassis DB rule unchanged (read-only into `SCRIPTS.sql`, MCP via a question when >1 without default).
93
93
 
94
- ## Delta 4 — Design SPECs (when the refine touches UI)
95
-
96
- Same mechanism as [`plan-new-loop`](../plan-new-loop/LOOP.md) (§ *Delta 4*: the **`ui-design`** capability → per-screen `NNN-SPEC-<SLUG>.md`, see [`SPEC.md`](../../artifacts/artifacts-design/SPEC.md)), **scoped to the delta**: only the screens **new or changed** by the refine get a design SPEC. The updated SPEC is written in **plan-refine's own session** (each loop manages ITS session's artifacts — it never edits plan-new's) and the plan **re-points** the UI Task reference to the current SPEC. Untouched screens keep their original SPEC.
97
-
98
94
  ## Functional journey map
99
95
 
100
96
  Before re-shaping phases, the plan must answer what execution would otherwise have to invent. The answers land **inside the existing sections** (`## Solution`, `## Impacted`, the `### Fn` blocks) — this loop adds no plan section beyond its trace:
@@ -106,14 +102,6 @@ Before re-shaping phases, the plan must answer what execution would otherwise ha
106
102
 
107
103
  > **Bounded research** (Delta 3, sharpened): investigate **only** what is needed to order the phases — journey, boundaries, existing contracts, where the simulation can live, risks that change the plan's design. What `plan-exec` resolves locally is **not** pre-investigated here.
108
104
 
109
- ## Simulation lifecycle
110
-
111
- **This section applies only when the journey introduces temporary behavior** — a stub, fake, in-memory adapter, controlled fixture or temporary response. None in the change → no `Límite de simulación`, and no artificial phase invented to retire one. When there is, it is planned, never improvised: every simulation declares **purpose · location · the contract it stands for · the phase where it appears · the phase where it moves or disappears · what prevents its accidental selection in a production runtime · the minimum proof needed while it exists**.
112
-
113
- - **Explicit over hidden**: `Stub…` / `Fake…`, in-memory adapter, temporary provider or controlled fixture — never a hardcode buried inside production code.
114
- - **Displacement rule**: each affected phase writes its `Límite de simulación` as normalized prose — `antes <where it is>` → `después <where it lands, or removed>` — never as an implicit assumption.
115
- - **Removal gate**: the change is not complete while a main-path simulation stays active, a configuration can still select it, the plan does not explain why it remains, or its removal was never validated. Test doubles isolated from the production runtime may stay.
116
-
117
105
  ## Evidence by behavior
118
106
 
119
107
  Each phase carries proof of behavior, not of structure. Three levels, **chosen** — never descended automatically:
@@ -137,30 +125,6 @@ This loop's instance of the chassis convergence gate — the same one `plan-exec
137
125
  - **Evidence** — every phase declares its primary proof, per-layer tests are justified, the same scenario is not duplicated by default, declared risks have evidence or an explicit deferral.
138
126
  - **Resumability** — tasks legible enough for a `CHECKPOINT`, intermediate states stable, pending work distinguishable from work already `validada`.
139
127
 
140
- ## Replanning executed work
141
-
142
- A partially executed plan is replanned **forward**, never rewritten backwards:
143
-
144
- - Phases already `validada` **stay as they are**, and their result becomes the initial state of what follows. Completed tasks are not re-written as if they had never happened.
145
- - Only pending work is re-designed. A `validada` phase that the new shape invalidates gets a **compensating correction** as a new phase — never a silent edit of the closed one.
146
- - **Return from `plan-exec`** (structural deviation — [`plan-exec-loop`](../plan-exec-loop/LOOP.md) § *Deviation gate*): the deviation enters as a **material gap** of this run. Changed input or output, observable state, public contract, participating components, phase order, simulation boundary or integration strategy — all land in `## Refinement decisions` with what execution already proved.
147
- - **Legacy plans** (no phase state, micro-task shape) are migrated to the phase contract when this round touches them: completed tasks preserved, micro-tasks grouped by purpose, results and exit conditions derived from the spec and from the plan itself. Functional evidence that neither backs is **not invented** — it becomes an `## Open questions` entry.
148
-
149
- ## Split gate — refine semantics
150
-
151
- The gate itself — signals, offer, anti-duplicate, sibling contract, partition — is defined **once** in [`plan-new-loop`](../plan-new-loop/LOOP.md) § *Split gate (multi-plan)* (this flow's guaranteed load already includes that file); this loop only adds the **in-place semantics** of splitting an existing plan:
152
-
153
- - The original plan **keeps its number/path**: it is rewritten **reduced** to its remaining tranche (in place, with confirmation). The extracted tranches become newly minted sibling plans (`aw next-number docs/plans` immediately before each write); their `## Origin` records "split from `docs/plans/PPP-plan-<slug>.md`" + the source spec + the siblings by path.
154
- - The gate also fires on **partially executed** plans. **Completed tasks (`- [x]`) never move to a sibling** — execution history stays anchored to the original path (plan-exec sessions' `## Origin` keep resolving); only pending work is extracted.
155
- - The split is recorded in `## Refinement decisions` (what moved where + why); original + siblings together keep the **complete, disjoint partition** of the spec criteria (spec-less: the Delta 2 degradation applies).
156
- - **Closing action** on the split branch: `Guardar planes` (edit the original reduced + write the extracted siblings); the normal branch keeps `Guardar plan refinado`.
157
-
158
- ## Compact / resume — PLAN-refine keys
159
-
160
- Full mechanism (3 cases, `Compactar`, re-run with `--reopen`) in the chassis (§ *Compact / resume*). PLAN-refine keys: prior-work mark = `## Refinement decisions` **in the plan** (legacy plans may also carry `## Q&A traceability`); re-refine on demand is **first-class** as many times as needed while the flow stays in PLAN.
161
-
162
- > **Inter-turn continuity** (chassis, row 2): a flow command opens a "new work line" (new session) — **except re-running the same flow over the same input** (same plan), which does `create_or_resume` (resumes/reopens instead of duplicating).
163
-
164
128
  ## Sequence
165
129
 
166
130
  ```
@@ -202,3 +166,11 @@ finalize: CHECKPOINT persisted (+ BACKLOG only if something is deferred) + close
202
166
  - `Cerrar` at any time → `finalize` (persists `CHECKPOINT`; `BACKLOG` only if something is deferred; closes the session, reports).
203
167
 
204
168
  > **After refining:** the plan goes to `plan-exec`, which re-checks this same gate on entry — a plan saved here should never bounce back for its structure.
169
+
170
+ ## Conditional modules
171
+
172
+ - `ui` — design SPECs for changed screens → `../../modules/PLAN-REFINE-DESIGN-SPECS.md`
173
+ - `simulation` — the life of temporary behavior → `../../modules/SIMULATION-LIFECYCLE.md`
174
+ - `replan` — replanning executed work → `../../modules/REPLANNING.md`
175
+ - `split` — splitting a plan in place → `../../modules/PLAN-REFINE-SPLIT.md`
176
+ - `resume` — this loop's compact / resume keys → `../../modules/PLAN-REFINE-KEYS.md`
@@ -67,16 +67,6 @@ Read **[`../CHASSIS.md`](../CHASSIS.md)** — the loop's **full engine** — **a
67
67
  3. The artifacts (`DECISION`, `SCRIPTS.sql`) **stay in the quick session** as referenceable context for the new session (never migrated).
68
68
  4. **SPEC enters live**: after `finalize`, run the *Live transition to SPEC* (draft **only if no spec exists** for this objective; then the loop). **Asymmetry** intact: PLAN can **absorb** the progress (plan-exec picks up the existing working tree); SPEC **restarts** the design cycle and treats the half-done code as context/reference, never as ingested work.
69
69
 
70
- ## Continuity across prompts (operating context)
71
-
72
- `quick` is where the **continuity rule** ([`../../SKILL.md`](../../SKILL.md) § *Operating context*) shows most clearly. Inside a workspace:
73
-
74
- 1. `/w:quick "first prompt"` (**command**) → creates session `NNN-<slug>-quick`, starts the loop. Scripts go to **its** `SCRIPTS.sql`.
75
- 2. `"second prompt"` (**no command**, related work) → does **not** create another session: **continues/reopens the most recent one** (from step 1) and appends the new scripts to **that same** `SCRIPTS.sql`.
76
- 3. `/w:quick "third prompt"` (**command** again) → **new** session, new loop.
77
-
78
- > The **command** signals "new work line"; a **bare prompt** means "same line" → by default continue/reopen the most recent session (the *last started*). Clearly unrelated → offer choosing (`continuar NNN` | `trabajo nuevo`) or fall to the **no-flow** branch (write into `docs/` by convention + numbering). No workspace → **vanilla** behavior.
79
-
80
70
  ## Sequence
81
71
 
82
72
  ```
@@ -123,3 +113,7 @@ finalize: CHECKPOINT (AFTER: Pending→Completed) + BACKLOG (only if something i
123
113
  - **No export**: nothing goes to `docs/`. Anything worth preserving → promoted separately via `export-*`, or escalated (to SPEC **live** — the line continues in spec-refine already as SPEC flow; to PLAN **deferred**, seed + pointer).
124
114
 
125
115
  > QUICK's *convergence gate* is **proportional verification-first**: a **short** `Success criteria` seeded at start (not the *absence* of a checklist — its minimal version) — for code, "the change does what the prompt asked + tests/build green"; for analysis/design, a short ratified rubric. Minimal ceremony by design, but **always with the check declared first**.
116
+
117
+ ## Conditional modules
118
+
119
+ - `resume` — continuity across prompts → `../../modules/PROMPT-CONTINUITY.md`