@tacuchi/agent-workflow-cli 20.23.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 (76) hide show
  1. package/dist/application/context/budget-service.js +128 -0
  2. package/dist/application/context/budget-service.js.map +1 -0
  3. package/dist/application/context/bundle-root.js +41 -0
  4. package/dist/application/context/bundle-root.js.map +1 -0
  5. package/dist/application/context/manifest.js +150 -0
  6. package/dist/application/context/manifest.js.map +1 -0
  7. package/dist/application/context/measure.js +227 -0
  8. package/dist/application/context/measure.js.map +1 -0
  9. package/dist/application/context/plan-service.js +177 -0
  10. package/dist/application/context/plan-service.js.map +1 -0
  11. package/dist/cli/commands/context-budget.js +79 -0
  12. package/dist/cli/commands/context-budget.js.map +1 -0
  13. package/dist/cli/commands/context-plan.js +75 -0
  14. package/dist/cli/commands/context-plan.js.map +1 -0
  15. package/dist/cli/commands/index.js +4 -0
  16. package/dist/cli/commands/index.js.map +1 -1
  17. package/dist/cli/help-groups.js +4 -0
  18. package/dist/cli/help-groups.js.map +1 -1
  19. package/dist/cli/parser.js +4 -0
  20. package/dist/cli/parser.js.map +1 -1
  21. package/package.json +1 -1
  22. package/skills/w/SKILL.md +2 -2
  23. package/skills/w/commands/export-diagrams.md +10 -27
  24. package/skills/w/commands/export-manuals.md +13 -29
  25. package/skills/w/commands/export-reports.md +11 -27
  26. package/skills/w/commands/export-scripts.md +12 -29
  27. package/skills/w/commands/fix-git.md +21 -32
  28. package/skills/w/commands/generate-launch.md +13 -32
  29. package/skills/w/commands/persist.md +8 -29
  30. package/skills/w/commands/plan-exec.md +14 -30
  31. package/skills/w/commands/plan-new.md +11 -38
  32. package/skills/w/commands/plan-refine.md +13 -41
  33. package/skills/w/commands/quick.md +13 -20
  34. package/skills/w/commands/resume.md +17 -33
  35. package/skills/w/commands/spec-new.md +28 -69
  36. package/skills/w/commands/spec-refine.md +12 -37
  37. package/skills/w/commands/status.md +12 -19
  38. package/skills/w/commands/workspace-init.md +13 -20
  39. package/skills/w/context/MANIFEST.json +486 -0
  40. package/skills/w/harness/HARNESS.md +1 -1
  41. package/skills/w/loops/CHASSIS.md +53 -104
  42. package/skills/w/loops/CODE-POLICIES.md +4 -9
  43. package/skills/w/loops/plan-exec-loop/LOOP.md +5 -12
  44. package/skills/w/loops/plan-new-loop/LOOP.md +8 -32
  45. package/skills/w/loops/plan-refine-loop/LOOP.md +8 -36
  46. package/skills/w/loops/quick-loop/LOOP.md +4 -10
  47. package/skills/w/loops/spec-refine-loop/LOOP.md +7 -49
  48. package/skills/w/modules/ADOPTED-CONTEXT.md +10 -0
  49. package/skills/w/modules/COMPACTION.md +13 -0
  50. package/skills/w/modules/DB-RESEARCH-RULE.md +11 -0
  51. package/skills/w/modules/DB-SCRIPTS-ONLY.md +12 -0
  52. package/skills/w/modules/EXEC-DB-POLICY.md +7 -0
  53. package/skills/w/modules/EXEC-PROBE-TASKS.md +11 -0
  54. package/skills/w/modules/IDEATION-GATE.md +16 -0
  55. package/skills/w/modules/INCREMENTAL-STRATEGY.md +7 -0
  56. package/skills/w/modules/LAUNCH-DETECTION.md +26 -0
  57. package/skills/w/modules/PERSIST-ROUTING.md +16 -0
  58. package/skills/w/modules/PLAN-DESIGN-SPECS.md +12 -0
  59. package/skills/w/modules/PLAN-INPUT.md +26 -0
  60. package/skills/w/modules/PLAN-MODE.md +26 -0
  61. package/skills/w/modules/PLAN-PROBE-TASKS.md +10 -0
  62. package/skills/w/modules/PLAN-REFINE-DESIGN-SPECS.md +7 -0
  63. package/skills/w/modules/PLAN-REFINE-KEYS.md +9 -0
  64. package/skills/w/modules/PLAN-REFINE-SPLIT.md +12 -0
  65. package/skills/w/modules/PLAN-SPLIT-GATE.md +14 -0
  66. package/skills/w/modules/PROBE.md +12 -0
  67. package/skills/w/modules/PROMPT-CONTINUITY.md +13 -0
  68. package/skills/w/modules/RECONNAISSANCE.md +48 -0
  69. package/skills/w/modules/REPLANNING.md +12 -0
  70. package/skills/w/modules/SESSION-NUMBERING.md +19 -0
  71. package/skills/w/modules/SIMULATION-LIFECYCLE.md +11 -0
  72. package/skills/w/modules/SPEC-CHANGE-SHAPE.md +37 -0
  73. package/skills/w/modules/SPEC-REFINE-KEYS.md +14 -0
  74. package/skills/w/modules/SPLIT-GATE.md +42 -0
  75. package/skills/w/modules/WORKSPACE-SCAFFOLD.md +28 -0
  76. package/skills/w/roles/ui-spec/ROLE.md +1 -1
@@ -41,7 +41,7 @@ Closing *every* gap turns the spec into a premature plan. Close what changes **w
41
41
  ## Reads
42
42
  - `docs/specs/NNN-spec*.md` (glob — locates the spec by number; also catches the legacy `NNN-spec.md`), **or** the exact path passed as the command argument. **Always the spec itself**: this loop edits it in place; there is no separate "refined" file.
43
43
 
44
- > **Boundary with `spec-new`:** the draft arrives from a **bounded reconnaissance** of the surface ([`../../commands/spec-new.md`](../../commands/spec-new.md) § *Bounded reconnaissance*) — hypotheses, not verified facts. **Deep investigation is this loop's**: walk the dependencies, check those hypotheses, and close the doubts parked in `## Open questions`.
44
+ > **Boundary with `spec-new`:** the draft arrives from a **bounded reconnaissance** of the surface ([`../../modules/RECONNAISSANCE.md`](../../modules/RECONNAISSANCE.md), `spec-new`'s `reconnaissance` module) — hypotheses, not verified facts. **Deep investigation is this loop's**: walk the dependencies, check those hypotheses, and close the doubts parked in `## Open questions`.
45
45
 
46
46
  **Adopt, do not repeat.** `spec-new`'s **facts** are reused; its **assumptions** are re-validated **only when one blocks a gap**; its `Open questions` are re-classified by destination; its one-vs-many hypothesis is re-judged at the *Change-shape gate*. The shallow sweep is never re-run wholesale. Keep the labels distinct — a spec that blurs them cannot be gated: **fact** (backed by repo, data or docs) · **inference** (unproven) · **user decision** · **deferred decision** (owner declared) · **open question** (can still move the contract).
47
47
 
@@ -80,31 +80,6 @@ When the project already exists, establish the current behavior the change rests
80
80
 
81
81
  **Stop when the baseline is enough to state and accept the functional change** — not when the system is documented. Digging on to pick an architecture, anticipate tasks or map every dependency is `PLAN` work, and gold-plating here. Greenfield has no baseline: skip it — that is what makes `## Behavioral changes` earn its place or not.
82
82
 
83
- ## Change-shape gate
84
-
85
- Runs once the baseline exists and **before** closing details: the investigation can reveal the draft's shape was wrong. Does the spec still carry **one** functional outcome, did its purpose survive, can the delivery be accepted as a unit? The verdict is **one of three shapes** — `same` | `split` | `replace` — each with its own branch; only the last two ask anything.
86
-
87
- > **Resolved before the gap loop starts, never carried into it (hard rule).** A `split` or a `replace` is asked, answered and applied **immediately** — its own structured-choice, in its own step, between the baseline and the first gap batch. It never travels in `pending_human`: that collection is rebuilt on every iteration and is reserved for questions about functional, technical or scope **gaps**, so a shape decision parked there is erased by the next batch — or never asked at all, because a spec with no blocking gap breaks out of the loop before the batch is built. The resolution lands in `CHECKPOINT` **before** anything else runs, so a resume re-enters with the shape already decided and never re-asks it.
88
-
89
- - same outcome — more clarity, or more technical components → **`same`**: no shape question, keep refining this spec;
90
- - independent functional outcomes discovered → **`split`** (below);
91
- - purpose fundamentally changed → **`replace`** (below);
92
- - refactor indispensable to the outcome → a consideration for `PLAN`, never its own spec; refactor with no functional change → out of the contract;
93
- - evidence insufficient → **`same`** + the uncertainty recorded. Thin evidence never justifies a cut.
94
-
95
- **Split criterion** — the one `spec-new` already uses ([`../../commands/spec-new.md`](../../commands/spec-new.md) § *Split gate (multi-spec)*), never a different one: divide **only** when each part can be refined, accepted and planned on its own. Repos, technologies, layers or teams are **secondary evidence**, never the reason.
96
-
97
- **Split semantics (in place).** The offer enters the batch as a content question — `Dividir en varias specs` | `Una sola spec`; declining marks it **exhausted** for the run. On acceptance: the original **keeps its number/path**, rewritten reduced to its remaining outcome; each extracted outcome is minted with `aw next-number docs/specs` right before its write and is born **`status: draft`**. Siblings are **not** elaborated here — unlike the multi-plan gate, where `plan-exec` would break on a plan with no `## Tasks`; a draft spec is legitimate input to this very loop — so the run keeps refining the **reduced original** and reports `/w:spec-refine` as each sibling's next step. Every `## Origin` records "split from `docs/specs/NNN-spec-<slug>.md`" + the siblings **by path**. Closing action on this branch: `Guardar specs`.
98
-
99
- **Replace semantics.** Its offer is its own — `Crear una nueva spec` | `Reformular esta spec`, **never** the split labels: what gets decided is which identity carries the new purpose. Recommend **a new spec** when the main functional outcome or the actor/consumer changed; **reformulating** when the user confirms this file is still the same unit of work and wants to keep its identity.
100
-
101
- - **New spec:** this one is **preserved**, its purpose never silently rewritten; the new one is minted with `aw next-number docs/specs`, born **`status: draft`**, its `## Origin` recording the origin spec, the replaced purpose and the user's decision. Its path goes to the `CHECKPOINT`; the run closes reporting `/w:spec-refine <new path>` as the next step.
102
- - **Reformulate:** same number/path, the work treated as `refining` while rewritten; baseline, gap classification and the *ready-for-plan gate* run again over the new purpose; `status` is stamped only on the save that follows the passing gate, and the material decision lands in `## Decisions`.
103
-
104
- **Every branch has a way out that changes nothing.** The `flow` control present on every structured-choice (chassis) is that exit here: `Cerrar` closes the run **without applying the shape change** — no sibling minted, no spec reformulated, the document untouched and the decision recorded in `CHECKPOINT` as declined. And no branch writes a file without the user's confirmation: minting siblings and minting a replacement both go through the same confirm-before-write rule as an in-place save.
105
-
106
- Neither branch adds a `superseded` status or archives the replaced spec: a historical close needs its own runtime contract, out of scope here.
107
-
108
83
  ## Deliverable schema (the spec, edited in place)
109
84
 
110
85
  The spec is completed **in place**: the draft's sections get **completed**, a few are **added**, and the frontmatter `status` is stamped. NO separate file is created.
@@ -175,19 +150,6 @@ The choices a reader needs in order to interpret the contract, each with its why
175
150
 
176
151
  **Resolution order** — the chassis *ask-vs-research rule* with the destination step in front: settled in the conversation → **adopt** · provable by reading repos or data → **research inline** · depends on what the user wants → **ask** · defines the technical solution without changing behavior → **hand to `PLAN`** · answerable later without touching the contract → **defer explicitly**.
177
152
 
178
- ## Ideation gate (creativity)
179
-
180
- The loop's one **divergent** gate: every other resolver closes a gap; this one widens the option space before the spec hardens around its first idea. **Unexplored solution space is not a universal gap** — it stays shut unless a trigger fires, because exploring what is already decided burns context and invites gold-plating.
181
-
182
- **Triggers (≥1).** The user knows the problem but not the desired outcome · several functional directions carry materially different consequences · the spec adopted the first alternative prematurely · a choice can materially change scope · the alternatives change experience, rules or acceptance · the user asks to explore.
183
-
184
- **Not triggers.** More than one technical solution exists · no library is chosen yet · the system uses several technologies · every implementation admits alternatives · the request is already functionally clear. Purely technical alternatives belong to `PLAN`.
185
-
186
- 1. **Offer & consent.** The gap enters the batch as a content question — `Explorar ideas` vs `Seguir sin ideación` — carrying the AI's recommendation like any other. Declining marks the gap **exhausted** (never re-offered this run); an explicit user request for ideas at any point counts as an accepted offer (on-demand entry). Alternatives already weighed in the conversation are *adopted context* — the gap does not fire.
187
- 2. **Ideation round** (one per consent). Propose fresh ideas and **combinations** (the user's + found ones). If the host exposes **web-research** ([`../../harness/HARNESS.md`](../../harness/HARNESS.md)), the accepted offer also authorizes that round's web searches — no per-search consent; findings + sources land in the session's `CONCLUSIONS`, like inline research. Without the capability, ideate offline (own knowledge + workspace + repos) and **declare it** — never silently.
188
-
189
- **Verdicts (back to convergence).** Present the top ≤3 ideas via the same structured-choice, each with a recommended verdict: `Adoptar` → integrate into `Requirement`/`Scope`/criteria + record it in `## Decisions` (the choice and its why, with the source/URL when web-found) · `Descartar` → the reason goes to `CONCLUSIONS`, not to the spec · `Aparcar` → `## Open questions` with its destination. Ideas beyond the top 3 stay summarized in `CONCLUSIONS`. Divergence is bounded by *Minimality* (chassis): nothing enters the spec without an explicit `Adoptar`. This gate exists **only** in this loop — `spec-new` stays single-pass (bounded reconnaissance at most, no web) and the plan/quick loops inherit none of it.
190
-
191
153
  ## Sequence
192
154
 
193
155
  ```
@@ -254,16 +216,6 @@ finalize:
254
216
  close refine_session ; report
255
217
  ```
256
218
 
257
- ## Compact / resume — SPEC keys
258
-
259
- Full mechanism (3 cases, `Compactar`, re-run on demand with `--reopen`) in the chassis (§ *Compact / resume*). SPEC keys:
260
-
261
- - The **prior-work mark** is the frontmatter `status: ready-for-plan` (legacy specs: `## Refinement decisions`, older ones also `## Q&A traceability`).
262
- - The **shape decision survives a resume.** It is written to `CHECKPOINT` the moment it is taken, before anything acts on it, so a compact, a `Cerrar` or a crash between the gate and the save re-enters with the shape settled — the gate is not re-run and the question is not re-asked. Only a *new* run over a spec whose baseline changed re-opens it.
263
- - Re-refining on demand is a **first-class operation** while the flow stays in SPEC (new requirements, scope changes, after re-reading the spec): it always reads the **spec itself**, incremental re-refinement; on `Guardar`, edits in place with confirmation.
264
- - **Legacy migration happens only here.** A re-refined legacy spec runs the gate like any other; on `Guardar`, its `## Refinement decisions` is renamed `## Decisions` and pruned to the material decisions — **in the same write that stamps `status`**, so the spec is never left with no mark. Specs nobody re-refines are not migrated.
265
- - **`Cerrar` before converging leaves the spec untouched**: the progress lives in the `CHECKPOINT`, and `status` is neither invented nor downgraded. `refining` is understood **on read** (a hand-written spec may declare it) — this loop never writes a partial spec.
266
-
267
219
  ## Convergence / exit
268
220
 
269
221
  - **No blocking gaps** → **ready-for-plan gate** (read-only) = **`Success criteria` green** (*verification-first*; the SPEC instance of the chassis convergence gate). The checklist:
@@ -285,3 +237,9 @@ Full mechanism (3 cases, `Compactar`, re-run on demand with `--reopen`) in the c
285
237
  - **`ui-design` capability** (UI gap) → the spec's `## UI spec` section.
286
238
  - **Owned by `PLAN` or deferred** → `## Open questions` with its destination, and nothing else in the spec.
287
239
  - **Inconclusive or unresolved research** → `## Open questions` (deferred) + the refine session's `BACKLOG.md` (only if something is deferred).
240
+
241
+ ## Conditional modules
242
+
243
+ - `shape` — the change-shape gate and its split / replace branches → `../../modules/SPEC-CHANGE-SHAPE.md`
244
+ - `web` — the conditional ideation gate, its triggers and verdicts → `../../modules/IDEATION-GATE.md`
245
+ - `resume` — the SPEC keys of compact / resume → `../../modules/SPEC-REFINE-KEYS.md`
@@ -0,0 +1,10 @@
1
+ # ADOPTED-CONTEXT — the host as a producer of input
2
+
3
+ Loaded when the conversation already produced the analysis, plan or answers the run needs (signal `adopted`).
4
+
5
+ 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.
6
+
7
+ - Adoption is **transcription, not trust**: the convergence gate still verifies adopted conclusions (*gate integrity*); anti-duplicate still applies.
8
+ - Materialization pattern = the quick escalation's (single-pass, **NO RESEARCH**), inverted: **host → flow**.
9
+ - Gap signals already resolved by adopted context do **not** fire (e.g. "ambiguous requirements" after a host pre-analysis).
10
+ - To persist finished work without a loop: [`/w:persist`](../commands/persist.md) (transversal).
@@ -0,0 +1,13 @@
1
+ # COMPACTION — the loop watching its own context pressure
2
+
3
+ Loaded when the run is long enough that context pressure governs its pacing (signal `compaction`).
4
+
5
+ `Compactar` is not only reactive: the loop **watches its own context pressure** and raises compaction itself.
6
+
7
+ - **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).
8
+ - **Modes** — config `[compaction]` table in `.workflow/skills.toml`, key `mode` (values `confirm` | `auto`):
9
+ - **`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.
10
+ - **`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`**.
11
+ - **Invariant — CHECKPOINT before compacting**: in every mode, `CHECKPOINT.md` is written (or verified fresh) **before** any compaction fires; resume keys off it.
12
+
13
+ > **`Compactar`** (the `flow` control) → 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.
@@ -0,0 +1,11 @@
1
+ # DB-RESEARCH-RULE — the single exception to research autonomy
2
+
3
+ Loaded when the run reads or writes a database (signal `db`).
4
+
5
+ Investigation is otherwise autonomous: the AI investigates inline and reports without asking permission. A database is the one place where it asks first.
6
+
7
+ 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.
8
+ 2. Write the queries **first** into the session's `SCRIPTS.sql`.
9
+ 3. Execute them **read-only** via MCP (respect `sql-mutation-guard`: never DML/DDL).
10
+
11
+ > The AI **never executes DML/DDL**. A migration is drafted in the session's `SCRIPTS.sql` and handed off; promoting it to `docs/scripts/` is a separate `export-*`, never a loop.
@@ -0,0 +1,12 @@
1
+ # DB-SCRIPTS-ONLY — mutating SQL is drafted, never executed
2
+
3
+ Loaded when a code-editing run touches the database (signal `db`).
4
+
5
+ ## DB scripts-only — the AI never executes DML/DDL
6
+
7
+ Distinguished by **execution**, not by file (see the [`SCRIPTS.sql`](../artifacts/artifacts-core/SCRIPTS.sql) schema):
8
+
9
+ - **Read-only queries** (diagnosis/validation) → `SCRIPTS.sql` (session artifact); the AI **does** execute them read-only via MCP (`sql-mutation-guard`).
10
+ - **DDL/DML migrations** (schema/data changes) → the AI **drafts them in `SCRIPTS.sql`** (session artifact) but **NEVER executes them**.
11
+
12
+ > 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.
@@ -0,0 +1,7 @@
1
+ # EXEC-DB-POLICY — the DB rule inside execution
2
+
3
+ Loaded when a phase touches the database (signal `db`).
4
+
5
+ ## Delta 3 — DB policy: **the AI never executes DML**
6
+
7
+ Full policy in [`DB-SCRIPTS-ONLY.md`](DB-SCRIPTS-ONLY.md), the `db` module of [`../loops/CODE-POLICIES.md`](../loops/CODE-POLICIES.md). **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.
@@ -0,0 +1,11 @@
1
+ # EXEC-PROBE-TASKS — probe (PoC) tasks inside execution
2
+
3
+ Loaded when the run hits a probe task or a runnable doubt (signal `probe`).
4
+
5
+ ## Delta 7 — Probe (PoC) tasks
6
+
7
+ Chassis § *Proof of concept (probe)*, instantiated for execution — for a plan's explicit probe task or a runnable doubt inside a task:
8
+
9
+ - 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.
10
+ - 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`).
11
+ - **Promotion**: probe code reaches the sources only as a normal task edit (branch-check + review gate) — never by committing the probe.
@@ -0,0 +1,16 @@
1
+ # IDEATION-GATE — widen the option space before the spec hardens
2
+
3
+ Loaded when a trigger says the solution space is unexplored (signal `web`).
4
+
5
+ ## Ideation gate (creativity)
6
+
7
+ The loop's one **divergent** gate: every other resolver closes a gap; this one widens the option space before the spec hardens around its first idea. **Unexplored solution space is not a universal gap** — it stays shut unless a trigger fires, because exploring what is already decided burns context and invites gold-plating.
8
+
9
+ **Triggers (≥1).** The user knows the problem but not the desired outcome · several functional directions carry materially different consequences · the spec adopted the first alternative prematurely · a choice can materially change scope · the alternatives change experience, rules or acceptance · the user asks to explore.
10
+
11
+ **Not triggers.** More than one technical solution exists · no library is chosen yet · the system uses several technologies · every implementation admits alternatives · the request is already functionally clear. Purely technical alternatives belong to `PLAN`.
12
+
13
+ 1. **Offer & consent.** The gap enters the batch as a content question — `Explorar ideas` vs `Seguir sin ideación` — carrying the AI's recommendation like any other. Declining marks the gap **exhausted** (never re-offered this run); an explicit user request for ideas at any point counts as an accepted offer (on-demand entry). Alternatives already weighed in the conversation are *adopted context* — the gap does not fire.
14
+ 2. **Ideation round** (one per consent). Propose fresh ideas and **combinations** (the user's + found ones). If the host exposes **web-research** ([`../harness/HARNESS.md`](../harness/HARNESS.md)), the accepted offer also authorizes that round's web searches — no per-search consent; findings + sources land in the session's `CONCLUSIONS`, like inline research. Without the capability, ideate offline (own knowledge + workspace + repos) and **declare it** — never silently.
15
+
16
+ **Verdicts (back to convergence).** Present the top ≤3 ideas via the same structured-choice, each with a recommended verdict: `Adoptar` → integrate into `Requirement`/`Scope`/criteria + record it in `## Decisions` (the choice and its why, with the source/URL when web-found) · `Descartar` → the reason goes to `CONCLUSIONS`, not to the spec · `Aparcar` → `## Open questions` with its destination. Ideas beyond the top 3 stay summarized in `CONCLUSIONS`. Divergence is bounded by *Minimality* (chassis): nothing enters the spec without an explicit `Adoptar`. This gate exists **only** in this loop — `spec-new` stays single-pass (bounded reconnaissance at most, no web) and the plan/quick loops inherit none of it.
@@ -0,0 +1,7 @@
1
+ # INCREMENTAL-STRATEGY — the reference shape of an incremental change
2
+
3
+ Loaded when the work is being staged into tranches or phases (signal `split`).
4
+
5
+ ## Incremental strategy (reference, never a template)
6
+
7
+ 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.
@@ -0,0 +1,26 @@
1
+ # LAUNCH-DETECTION — how the run command and the launch mode are derived
2
+
3
+ Loaded when the CLI's detection is wrong, ambiguous or must be overridden (signal `detection`).
4
+
5
+ ## Detection (how "run the project locally" is derived)
6
+
7
+ - **npm** — a run script first (`dev` > `start` > `serve`, → `server`); else a CLI/app entry
8
+ (`bin` > `main`) run with `node`, **building first** (`npm run build`) when a `build` script
9
+ exists — a TypeScript CLI runs from its compiled output (→ `interactive`).
10
+ - **gradle** / **maven** — `./gradlew bootRun` / `./mvnw spring-boot:run` (`server`).
11
+ - **angular** — `npm start` (`server`).
12
+ - **Launch mode** governs how the TUI "Lanzar" (and the wrapper) run the app: `interactive` =
13
+ foreground, owns the TTY (the UI appears); `server` = backgrounded, output tee'd to the log.
14
+ The heuristic guesses it; `--mode` overrides. A `build` step, when present, runs before the
15
+ launch in both modes.
16
+
17
+ ## Behavior
18
+
19
+ - **Idempotent** — a pristine generated file is refreshed; a hand-edited one (its hash marker no
20
+ longer matches) is **preserved**. `--force` overwrites hand-edited files too (reported as
21
+ `overwritten`).
22
+ - **`--source <alias>`** (repeatable) restricts to the given sources; default = every declared source.
23
+ - **`--mode interactive|server`** overrides the detected mode for the selected source(s).
24
+ - **`--command "<cmd>"`** overrides the run command for a **single** selected source
25
+ (self-contained: it drops the auto build).
26
+ - **`--dry-run`** classifies every file and writes nothing.
@@ -0,0 +1,16 @@
1
+ # PERSIST-ROUTING — which shape goes where
2
+
3
+ Loaded when classifying what to persist (signal `classification`).
4
+
5
+ | Shape | Signals | Category → destination |
6
+ |---|---|---|
7
+ | **Analysis / conclusions / design notes** | findings, comparisons, diagnoses, adjudications, recommendations | `research` → `docs/research/NNN-research-<slug>.md` |
8
+ | **Requirement** | describes a *wish*: what should exist/change, acceptance criteria derivable | `spec` → `docs/specs/NNN-spec-<slug>.md`, born `status: draft`, `## Origin` = "adopted from host conversation" → offer `/w:spec-refine` |
9
+ | **Plan** | already answers the *how*: phases/tasks/solution — e.g. the host plan-mode output | `plan` → `docs/plans/NNN-plan-<slug>.md` (adoption) → offer `/w:plan-refine` / `/w:plan-exec` |
10
+ | Mixed / ambiguous | e.g. analysis that ends in a requirement | one `persist` per document, each confirmed; a research doc plus a spec draft that cites it is a valid split |
11
+
12
+ ## `docs/research/` — the analysis home (owned by this command)
13
+
14
+ `docs/research` hosts standalone analyses: neither spec nor plan, but worth keeping. Belongs to **no flow**; `export-*` never writes it; loops never read it implicitly (a flow uses it by **reference** — cited in a spec's `## Origin` or a quick prompt). It is git-shareable, unlike sessions (gitignored, machine-local, loop-owned), which makes it the exchange surface for **N agents analyzing the same situation**.
15
+
16
+ > **Anti-duplicate is a decision, not an accident.** The inventory carries each existing document's summary and digest. Same work already there → `mode: "update"` (proving you saw the current bytes via `target_digest`) or `state: "ambiguous"` so the user chooses between updating and writing a sibling perspective. A second near-identical document is never created silently.
@@ -0,0 +1,12 @@
1
+ # PLAN-DESIGN-SPECS — per-screen design SPECs when the plan includes UI
2
+
3
+ Loaded when the plan includes UI (signal `ui`).
4
+
5
+ ## Delta 4 — Design SPECs (when the plan includes UI)
6
+
7
+ 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`):
8
+
9
+ - 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)).
10
+ - 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).
11
+ - 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.
12
+ - It is the chassis' composed-capability resolution mode (next to *research*, *probe* and *human*).
@@ -0,0 +1,26 @@
1
+ # PLAN-INPUT — what the argument to a plan command actually is
2
+
3
+ Loaded when the input is not plainly a `ready-for-plan` spec (signal `input`).
4
+
5
+ ## plan-new — four modes
6
+
7
+ 1. **Ready spec** (`docs/specs/NNN-spec-<slug>.md` whose frontmatter declares `status: ready-for-plan`) → ideal. Proceed straight to the loop.
8
+ 2. **Spec not ready** (`status: draft` / `refining`, or no mark at all) → **soft-suggest** running `/w:spec-refine` first. It is a suggestion, **never a block**: the user may proceed. Questions the spec left with destination `PLAN` are this flow's **input**, not a reason to send it back.
9
+ 3. **Prompt** (no spec referenced) → propose the SPEC flow; **by default launch `/w:spec-new`** with that prompt and continue the natural flow from there.
10
+ 4. **External plan content** — the argument carries an **already-built plan** (host plan mode, hand-written, another agent's) → **adopt it**. Single pass, **NO RESEARCH**: materialize as `docs/plans/PPP-plan-<slug>.md` (`aw next-number docs/plans`), normalized to the rich-plan schema with only what the source provides. `## Origin` = "adopted from <source>" + attribution (host · model · date). Then offer `/w:plan-refine` or `/w:plan-exec`. Anti-duplicate: a plan whose `## Origin` matches this objective → recommend resuming it, never a second one. Adoption **never regenerates over** an existing plan-doc.
11
+
12
+ > **Mode 3 vs 4:** a prompt that *describes a wish* → SPEC (mode 3); content that *already is a plan* → adopt (mode 4).
13
+
14
+ > **Ready vs not** is read from the spec's frontmatter `status`, never from the filename. **Legacy compat:** a spec with no frontmatter that carries `## Refinement decisions` — or the older `## Q&A traceability` — counts as ready the same way.
15
+
16
+ ## plan-refine — three modes
17
+
18
+ 1. **Existing plan** (`docs/plans/PPP-plan-<slug>.md`) → proceed, **regardless of provenance**: generated, hand-written, or adopted. Existence is the only requirement.
19
+ 2. **No plan** → **soft-suggest** `/w:plan-new` first; the user decides.
20
+ 3. **Returned by `plan-exec`** (its entry check found the plan unexecutable, or execution stopped on a structural deviation) → proceed carrying that finding: phases already `validada` stay, only pending work is re-designed.
21
+
22
+ > **Spec-less plans are legitimate input.** The coherence gate **degrades gracefully**: criteria trace to the plan's own Final behavior block instead of spec criteria, and the "spec criteria uncovered" gap does not apply.
23
+
24
+ ## Numbering
25
+
26
+ The plan is named `docs/plans/PPP-plan-<slug>.md`. `aw next-number docs/plans` returns JSON (field `next` = `PPP`); the slug is short kebab-case from the Requirement (`[a-z0-9-]`, ≤ ~5 words / ≤ 40 chars). It does **not inherit the spec's `NNN`** — the link is established by reference in `## Origin`, never by number.
@@ -0,0 +1,26 @@
1
+ # PLAN-MODE — what every Workline command does when the host is planning
2
+
3
+ Loaded only when the host reports it is in plan mode (signal `plan-mode`). Sixteen commands
4
+ used to carry a paragraph of this each; the rule was the same in all of them, so it is stated
5
+ once here.
6
+
7
+ ## The rule
8
+
9
+ In plan mode a command **describes** and **writes nothing**. It resolves its input, states what
10
+ it would do and what it would touch, and stops:
11
+
12
+ - **Flow commands** (`spec-new`, `spec-refine`, `plan-new`, `plan-refine`, `plan-exec`, `quick`):
13
+ describe the loop actions they would run — the gaps they would close, the questions they would
14
+ ask, the phases they would execute, the files they would touch and the commits they would
15
+ propose. No session is created, no loop is started, no document is written.
16
+ - **Direct surfaces** (`status`, `resume`, `persist`, `fix-git`, `generate-launch`,
17
+ `workspace-init`, `export-*`): run their read-only `prepare` step if they have one and report
18
+ what it returned. Never `validate`, never `apply`.
19
+
20
+ ## Two things it does NOT change
21
+
22
+ 1. **A read-only command is already safe.** `status` and `resume` write nothing in any mode;
23
+ plan mode does not make them describe instead of answering.
24
+ 2. **The gates that would fire still get named.** A size gate that would escalate, a spec that
25
+ would be sent back to refine, a structural deviation that would stop execution — plan mode
26
+ reports them as part of the description instead of hiding them until the real run.
@@ -0,0 +1,10 @@
1
+ # PLAN-PROBE-TASKS — probes that de-risk a plan early
2
+
3
+ Loaded when the plan rests on a runnable assumption (signal `probe`).
4
+
5
+ ## Delta 5 — Probe (PoC) tasks — de-risk early
6
+
7
+ Chassis § *Proof of concept (probe)*, instantiated for planning. Two placements:
8
+
9
+ - **Plan-shaping unknown** (the `Solution` itself depends on the answer) → run the probe **inline now**; the verdict (`CONCLUSIONS`) feeds `Solution` / `Risks / impact`.
10
+ - **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.
@@ -0,0 +1,7 @@
1
+ # PLAN-REFINE-DESIGN-SPECS — design SPECs for the screens a refine touches
2
+
3
+ Loaded when the refine touches UI (signal `ui`).
4
+
5
+ ## Delta 4 — Design SPECs (when the refine touches UI)
6
+
7
+ Same mechanism as [`plan-new-loop`](../loops/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.
@@ -0,0 +1,9 @@
1
+ # PLAN-REFINE-KEYS — the compact / resume keys of a plan refinement
2
+
3
+ Loaded when the run resumes or re-runs a refinement of this plan (signal `resume`).
4
+
5
+ ## Compact / resume — PLAN-refine keys
6
+
7
+ 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.
8
+
9
+ > **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).
@@ -0,0 +1,12 @@
1
+ # PLAN-REFINE-SPLIT — splitting a plan that already exists
2
+
3
+ Loaded when an existing plan may have to be split in place (signal `split`).
4
+
5
+ ## Split gate — refine semantics
6
+
7
+ The gate itself — signals, offer, anti-duplicate, sibling contract, partition — is defined **once** in [`PLAN-SPLIT-GATE.md`](PLAN-SPLIT-GATE.md), `plan-new-loop`'s `split` module (this flow's guaranteed load already includes that file); this loop only adds the **in-place semantics** of splitting an existing plan:
8
+
9
+ - 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.
10
+ - 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.
11
+ - 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).
12
+ - **Closing action** on the split branch: `Guardar planes` (edit the original reduced + write the extracted siblings); the normal branch keeps `Guardar plan refinado`.
@@ -0,0 +1,14 @@
1
+ # PLAN-SPLIT-GATE — the canonical multi-plan split gate
2
+
3
+ Loaded when the plan may have to become more than one document (signal `split`).
4
+
5
+ ## Split gate (multi-plan)
6
+
7
+ 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`.
8
+
9
+ - **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.
10
+ - **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.
11
+ - **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.
12
+ - **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).
13
+ - **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`.
14
+ - **Closing action** on the split branch: `Guardar planes` (the single-plan branch keeps `Guardar plan`).
@@ -0,0 +1,12 @@
1
+ # PROBE — proof of concept, the resolver for executable doubt
2
+
3
+ Loaded when the run rests on a runnable assumption that reading cannot settle (signal `probe`).
4
+
5
+ ## Proof of concept (probe)
6
+
7
+ 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.
8
+
9
+ - **When**: risky assumption + not answerable by reading + failure would invalidate downstream work. Proposed via **structured-choice**.
10
+ - **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.
11
+ - **Isolation**: probe code lives in the **session folder** (gitignored) — never the source tree, **never committed**; DB probes are read-only (never DDL/DML).
12
+ - A **failed probe is a finding, not a failure** — report it; the human decides if the plan reshapes.
@@ -0,0 +1,13 @@
1
+ # PROMPT-CONTINUITY — one work line across several prompts
2
+
3
+ Loaded when a bare prompt continues an existing work line (signal `resume`).
4
+
5
+ ## Continuity across prompts (operating context)
6
+
7
+ `quick` is where the **continuity rule** ([`../../SKILL.md`](../../SKILL.md) § *Operating context*) shows most clearly. Inside a workspace:
8
+
9
+ 1. `/w:quick "first prompt"` (**command**) → creates session `NNN-<slug>-quick`, starts the loop. Scripts go to **its** `SCRIPTS.sql`.
10
+ 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`.
11
+ 3. `/w:quick "third prompt"` (**command** again) → **new** session, new loop.
12
+
13
+ > 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.
@@ -0,0 +1,48 @@
1
+ # RECONNAISSANCE — the bounded look that precedes a scope decision
2
+
3
+ Loaded when a draft is being cut from a raw prompt and the terrain is not yet known (signal
4
+ `reconnaissance`).
5
+
6
+ ## Bounded reconnaissance
7
+
8
+ A scope decision taken from the prompt alone mistakes **technical** boundaries for **functional**
9
+ ones. So, before deciding, take **one** shallow look at the terrain — enough to form a reasonable
10
+ hypothesis of the functional unit, never enough to answer how it will be built.
11
+
12
+ **Scope of the pass.** It runs **only on a raw user prompt** (direct invocation, or the `plan-new`
13
+ mode-3 handoff). The reuse entries skip it: the quick escalation and the `persist` adoption arrive
14
+ with their context **already established**, and adopting it is transcription, not reconnaissance
15
+ (**NO RESEARCH** — chassis section *Adopted context*).
16
+
17
+ One pass, in this order: **adopt** what the conversation already settled (never re-derive it),
18
+ **identify** the candidate sources, **look** at their surface, **stop**.
19
+
20
+ - **Sources allowed** (a permission, not an obligation to read them all):
21
+ - the workspace's registered sources — `aw sources --no-git`, or the `WORKSPACE` block.
22
+ - each candidate source's main instructions file, plus the head of its `README`.
23
+ - build manifests: `package.json`, `pom.xml`, `build.gradle`, `requirements.txt`, equivalents.
24
+ - a top-level directory listing per candidate source.
25
+ - one or two entry points the prompt itself names, plus a handful of search hits.
26
+ - **Budget: ≤5 reads + ≤3 searches.** Read a whole file only when a head or a search will not
27
+ do. The ceiling is a **cap, never a target**.
28
+ - **Stop at the first of these:**
29
+ - the evidence already decides one spec vs sibling specs.
30
+ - the next question needs a deep technical chain.
31
+ - it would need running code, tests or services.
32
+ - it would need an external source that is not available.
33
+ - the remaining uncertainty does not block a first draft.
34
+ - the digging starts answering *how it will be built* instead of *what functional unit was
35
+ asked for*.
36
+ - **Never:** follow a full import/call chain, run anything, query a database, search the web, or
37
+ open a source the prompt gives no reason to open.
38
+
39
+ **Scope hypothesis (internal).** The pass ends in a short judgement: functional outcome · likely
40
+ sources · apparent responsibility of each · coupling · independent acceptance · recommended shape
41
+ · confidence. It is **reasoning, not an artifact** — never persisted, never printed verbatim. It
42
+ exists so the cut is never intuitive but opaque; its only visible residue is what the filling
43
+ notes admit.
44
+
45
+ **Degrade safely.** A missing workspace, unreachable sources or contradictory evidence **never**
46
+ block the command and **never** justify a speculative cut. Keep **one spec**, declare the
47
+ assumption used, and record the uncertainty for `spec-refine`. Prefer the functional outcome the
48
+ user declared over any inference drawn from the code.
@@ -0,0 +1,12 @@
1
+ # REPLANNING — re-planning a plan that is already partly executed
2
+
3
+ Loaded when the plan is already partially executed (signal `replan`).
4
+
5
+ ## Replanning executed work
6
+
7
+ A partially executed plan is replanned **forward**, never rewritten backwards:
8
+
9
+ - 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.
10
+ - 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.
11
+ - **Return from `plan-exec`** (structural deviation — [`plan-exec-loop`](../loops/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.
12
+ - **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.
@@ -0,0 +1,19 @@
1
+ # SESSION-NUMBERING — who owns the NNN, and how a session is found again
2
+
3
+ Loaded when the run has to locate or name a session beyond creating its own (signal `sessions`).
4
+
5
+ ## The CLI owns the number (hard rule)
6
+
7
+ `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`).
8
+
9
+ > `<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).
10
+
11
+ ## Finding one again
12
+
13
+ **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.
14
+
15
+ **Reopen to continue**: `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`).
16
+
17
+ ## When the durable record fails to update
18
+
19
+ `aw session-close` also upserts the session's row in `.workflow/HISTORY.md` — the durable record, since `sessions/` is gitignored. That upsert is **non-fatal**: on `history_error` in its output, re-run `aw history-update --code <NNN> --state closed`. `aw session-artifacts` inspects what a session holds.
@@ -0,0 +1,11 @@
1
+ # SIMULATION-LIFECYCLE — the life of temporary behavior in a plan
2
+
3
+ Loaded when the journey introduces temporary behavior (signal `simulation`).
4
+
5
+ ## Simulation lifecycle
6
+
7
+ **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**.
8
+
9
+ - **Explicit over hidden**: `Stub…` / `Fake…`, in-memory adapter, temporary provider or controlled fixture — never a hardcode buried inside production code.
10
+ - **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.
11
+ - **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.
@@ -0,0 +1,37 @@
1
+ # SPEC-CHANGE-SHAPE — same, split or replace
2
+
3
+ Loaded when the investigation may have changed the spec shape (signal `shape`).
4
+
5
+ ## The two shape branches are not the same question
6
+
7
+ `split` and `replace` are different findings, so they ask different things and do different things — reusing one for the other asks about cardinality when what changed was purpose:
8
+
9
+ | Finding | What it asks | What it writes |
10
+ |---|---|---|
11
+ | **`split`** — independent functional outcomes discovered | `Dividir en varias specs` \| `Una sola spec` | the original, rewritten reduced, **plus** one new file per extracted outcome |
12
+ | **`replace`** — the purpose itself changed | `Crear una nueva spec` \| `Reformular esta spec` | `Crear` → one **new** file, this spec untouched · `Reformular` → **no new file**: this same file, same number, same path |
13
+
14
+ ## Change-shape gate
15
+
16
+ Runs once the baseline exists and **before** closing details: the investigation can reveal the draft's shape was wrong. Does the spec still carry **one** functional outcome, did its purpose survive, can the delivery be accepted as a unit? The verdict is **one of three shapes** — `same` | `split` | `replace` — each with its own branch; only the last two ask anything.
17
+
18
+ > **Resolved before the gap loop starts, never carried into it (hard rule).** A `split` or a `replace` is asked, answered and applied **immediately** — its own structured-choice, in its own step, between the baseline and the first gap batch. It never travels in `pending_human`: that collection is rebuilt on every iteration and is reserved for questions about functional, technical or scope **gaps**, so a shape decision parked there is erased by the next batch — or never asked at all, because a spec with no blocking gap breaks out of the loop before the batch is built. The resolution lands in `CHECKPOINT` **before** anything else runs, so a resume re-enters with the shape already decided and never re-asks it.
19
+
20
+ - same outcome — more clarity, or more technical components → **`same`**: no shape question, keep refining this spec;
21
+ - independent functional outcomes discovered → **`split`** (below);
22
+ - purpose fundamentally changed → **`replace`** (below);
23
+ - refactor indispensable to the outcome → a consideration for `PLAN`, never its own spec; refactor with no functional change → out of the contract;
24
+ - evidence insufficient → **`same`** + the uncertainty recorded. Thin evidence never justifies a cut.
25
+
26
+ **Split criterion** — the one `spec-new` already uses ([`SPLIT-GATE.md`](SPLIT-GATE.md), `spec-new`'s `split` module), never a different one: divide **only** when each part can be refined, accepted and planned on its own. Repos, technologies, layers or teams are **secondary evidence**, never the reason.
27
+
28
+ **Split semantics (in place).** The offer enters the batch as a content question — `Dividir en varias specs` | `Una sola spec`; declining marks it **exhausted** for the run. On acceptance: the original **keeps its number/path**, rewritten reduced to its remaining outcome; each extracted outcome is minted with `aw next-number docs/specs` right before its write and is born **`status: draft`**. Siblings are **not** elaborated here — unlike the multi-plan gate, where `plan-exec` would break on a plan with no `## Tasks`; a draft spec is legitimate input to this very loop — so the run keeps refining the **reduced original** and reports `/w:spec-refine` as each sibling's next step. Every `## Origin` records "split from `docs/specs/NNN-spec-<slug>.md`" + the siblings **by path**. Closing action on this branch: `Guardar specs`.
29
+
30
+ **Replace semantics.** Its offer is its own — `Crear una nueva spec` | `Reformular esta spec`, **never** the split labels: what gets decided is which identity carries the new purpose. Recommend **a new spec** when the main functional outcome or the actor/consumer changed; **reformulating** when the user confirms this file is still the same unit of work and wants to keep its identity.
31
+
32
+ - **New spec:** this one is **preserved**, its purpose never silently rewritten; the new one is minted with `aw next-number docs/specs`, born **`status: draft`**, its `## Origin` recording the origin spec, the replaced purpose and the user's decision. Its path goes to the `CHECKPOINT`; the run closes reporting `/w:spec-refine <new path>` as the next step.
33
+ - **Reformulate:** same number/path, the work treated as `refining` while rewritten; baseline, gap classification and the *ready-for-plan gate* run again over the new purpose; `status` is stamped only on the save that follows the passing gate, and the material decision lands in `## Decisions`.
34
+
35
+ **Every branch has a way out that changes nothing.** The `flow` control present on every structured-choice (chassis) is that exit here: `Cerrar` closes the run **without applying the shape change** — no sibling minted, no spec reformulated, the document untouched and the decision recorded in `CHECKPOINT` as declined. And no branch writes a file without the user's confirmation: minting siblings and minting a replacement both go through the same confirm-before-write rule as an in-place save.
36
+
37
+ Neither branch adds a `superseded` status or archives the replaced spec: a historical close needs its own runtime contract, out of scope here.
@@ -0,0 +1,14 @@
1
+ # SPEC-REFINE-KEYS — compact / resume keys for SPEC
2
+
3
+ Loaded when a refinement resumes or re-runs over the same spec (signal `resume`).
4
+
5
+ ## Compact / resume — SPEC keys
6
+
7
+ Full mechanism (3 cases, `Compactar`, re-run on demand with `--reopen`) in the chassis (§ *Compact / resume*). SPEC keys:
8
+
9
+ - The **prior-work mark** is the frontmatter `status: ready-for-plan` (legacy specs: `## Refinement decisions`, older ones also `## Q&A traceability`).
10
+ - The **shape decision survives a resume.** It is written to `CHECKPOINT` the moment it is taken, before anything acts on it, so a compact, a `Cerrar` or a crash between the gate and the save re-enters with the shape settled — the gate is not re-run and the question is not re-asked. Only a *new* run over a spec whose baseline changed re-opens it.
11
+ - Re-refining on demand is a **first-class operation** while the flow stays in SPEC (new requirements, scope changes, after re-reading the spec): it always reads the **spec itself**, incremental re-refinement; on `Guardar`, edits in place with confirmation.
12
+ - **Legacy migration happens only here.** A re-refined legacy spec runs the gate like any other; on `Guardar`, its `## Refinement decisions` is renamed `## Decisions` and pruned to the material decisions — **in the same write that stamps `status`**, so the spec is never left with no mark. Specs nobody re-refines are not migrated.
13
+ - **`Cerrar` before converging leaves the spec untouched**: the progress lives in the `CHECKPOINT`, and `status` is neither invented nor downgraded. `refining` is understood **on read** (a hand-written spec may declare it) — this loop never writes a partial spec.
14
+ - **The legacy glob still resolves.** `NNN-spec*.md` also catches old `NNN-spec.md` / `NNN-spec-refined.md` specs; re-running spec-refine edits them in place from then on.