@tacuchi/agent-workflow-cli 20.17.0 → 20.22.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.
- package/README.md +35 -3
- package/dist/application/markdown.js +61 -16
- package/dist/application/markdown.js.map +1 -1
- package/dist/application/parsers/phases.js +128 -0
- package/dist/application/parsers/phases.js.map +1 -0
- package/dist/application/parsers/plan-status.js +75 -0
- package/dist/application/parsers/plan-status.js.map +1 -0
- package/dist/application/status-service.js +102 -2
- package/dist/application/status-service.js.map +1 -1
- package/package.json +1 -1
- package/skills/w/SKILL.md +11 -7
- package/skills/w/artifacts/artifacts-core/CHECKPOINT.md +3 -1
- package/skills/w/artifacts/artifacts-exec/DECISION.md +2 -0
- package/skills/w/commands/README.md +1 -1
- package/skills/w/commands/plan-exec.md +6 -3
- package/skills/w/commands/plan-new.md +7 -3
- package/skills/w/commands/plan-refine.md +5 -2
- package/skills/w/commands/resume.md +13 -6
- package/skills/w/commands/spec-new.md +53 -15
- package/skills/w/commands/spec-refine.md +19 -6
- package/skills/w/commands/status.md +20 -7
- package/skills/w/loops/CHASSIS.md +3 -3
- package/skills/w/loops/CODE-POLICIES.md +2 -0
- package/skills/w/loops/README.md +5 -3
- package/skills/w/loops/plan-exec-loop/LOOP.md +102 -36
- package/skills/w/loops/plan-new-loop/LOOP.md +72 -11
- package/skills/w/loops/plan-refine-loop/LOOP.md +91 -21
- package/skills/w/loops/quick-loop/LOOP.md +1 -1
- package/skills/w/loops/spec-refine-loop/LOOP.md +153 -60
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
name: plan-exec-loop
|
|
3
3
|
description: >-
|
|
4
4
|
Executes an implementation plan (docs/plans/PPP-plan-<slug>.md) as a living
|
|
5
|
-
doc:
|
|
6
|
-
managing DB and git. Heir of the chassis (loops/CHASSIS.md
|
|
7
|
-
CODE-POLICIES.md). Deltas:
|
|
8
|
-
|
|
9
|
-
scripts-only
|
|
5
|
+
doc: runs it phase by phase — each phase a verifiable state — while editing
|
|
6
|
+
the real code and managing DB and git. Heir of the chassis (loops/CHASSIS.md
|
|
7
|
+
+ CODE-POLICIES.md). Deltas: executability entry gate, deviation gate
|
|
8
|
+
(structural to plan-refine, functional to spec-refine), single resumable
|
|
9
|
+
session, safe git, DB scripts-only, phase proof plus progressive tests,
|
|
10
10
|
pre-commit closing review gate, no auto-export. Composes git and sql.
|
|
11
11
|
Started by /w:plan-exec. Invoke to implement an already generated plan.
|
|
12
12
|
---
|
|
@@ -22,10 +22,10 @@ PLAN
|
|
|
22
22
|
2 — the AI runs it end to end.
|
|
23
23
|
|
|
24
24
|
## Started by
|
|
25
|
-
`/w:plan-exec` — **resumable** (same chassis mechanism; here resume keys off the plan-doc checkboxes + CHECKPOINT, see Delta 1).
|
|
25
|
+
`/w:plan-exec` — **resumable** (same chassis mechanism; here resume keys off the plan-doc phase states + checkboxes + CHECKPOINT, see Delta 1).
|
|
26
26
|
|
|
27
27
|
## Reads
|
|
28
|
-
`docs/plans/PPP-plan-<slug>.md` (locate via the `docs/plans/PPP-plan-*.md` glob or the exact path from the command argument). It runs **any** plan, whether or not it passed through [`plan-refine-loop`](../plan-refine-loop/LOOP.md) — plan-refine is auxiliary, not mandatory; no gate requires it. If the plan includes UI, it also reads the **design SPECs** (`NNN-SPEC-<SLUG>.md`) its Tasks reference — artifacts of the plan-new/plan-refine session, read **read-only** as the design reference while implementing (see [`SPEC.md`](../../artifacts/artifacts-design/SPEC.md)).
|
|
28
|
+
`docs/plans/PPP-plan-<slug>.md` (locate via the `docs/plans/PPP-plan-*.md` glob or the exact path from the command argument) **and its source spec** (resolved through the plan's `## Origin`) — the entry gate reads both. It runs **any** plan, whether or not it passed through [`plan-refine-loop`](../plan-refine-loop/LOOP.md) — plan-refine is auxiliary, not mandatory; no gate requires it. What it does require is an **executable shape** (§ *Entry gate — executability*). If the plan includes UI, it also reads the **design SPECs** (`NNN-SPEC-<SLUG>.md`) its Tasks reference — artifacts of the plan-new/plan-refine session, read **read-only** as the design reference while implementing (see [`SPEC.md`](../../artifacts/artifacts-design/SPEC.md)).
|
|
29
29
|
|
|
30
30
|
## Writes
|
|
31
31
|
- `docs/plans/PPP-plan-<slug>.md` (**read/update**, living doc: phase/task state, `Open questions`).
|
|
@@ -54,16 +54,58 @@ Read **[`../CHASSIS.md`](../CHASSIS.md)** — the loop's **full engine** — **a
|
|
|
54
54
|
|
|
55
55
|
> **Compat (legacy):** old workspaces may hold `plan-exec-phase-*` sessions (one per phase) and `*-research-*` ones — historical, left as-is; new runs use a single session.
|
|
56
56
|
|
|
57
|
-
##
|
|
57
|
+
## Entry gate — executability
|
|
58
|
+
|
|
59
|
+
**Before touching code**, read the plan and its spec and check the shape execution depends on:
|
|
60
|
+
|
|
61
|
+
1. every phase declares its `Resultado`, its `Condición de salida` and its `Validación de fase`;
|
|
62
|
+
2. if temporary behavior exists, its current boundary and retirement phase are identifiable; otherwise the simulation check is not applicable;
|
|
63
|
+
3. the primary proof of the first `pendiente` phase is identifiable;
|
|
64
|
+
4. no structural contradiction is evident (a phase that undoes an earlier one, evidence nobody can produce).
|
|
65
|
+
|
|
66
|
+
Execution **no longer accepts in silence** a plan that would force it to invent its own structure. Two outcomes:
|
|
67
|
+
|
|
68
|
+
- **Minor gap** — the plan is all but executable: an exit condition derivable from what is already written, the obvious evidence unnamed, micro-tasks to group. `plan-exec` may **normalize it with consent** — one structured-choice content question, labels `Normalizar y ejecutar` (recommended) | `Ir a plan-refine`. Normalizing edits the `### Fn` blocks in place, **adds no scope and moves no boundary**, and is recorded in `DECISION` + `CHECKPOINT`.
|
|
69
|
+
- **Structural gap** — phases, contracts or journey are missing, or a change that **does** carry temporary behavior leaves its boundary undeclared. It does **not** improvise: record the finding in `CHECKPOINT`, hand off to [`plan-refine-loop`](../plan-refine-loop/LOOP.md) (`/w:plan-refine`) and resume execution over the refined plan.
|
|
70
|
+
|
|
71
|
+
> **A missing `Límite de simulación` is a gap only when there is something to simulate.** No task and no phase introduces temporary behavior → the block is legitimately absent and the gate passes; demanding it anyway pushes execution to invent a stub so the plan matches a template. The same holds for `Diferido` and every other conditional block.
|
|
72
|
+
|
|
73
|
+
> The gate reads the **canonical phase contract** from [`plan-new-loop`](../plan-new-loop/LOOP.md) § *Phase contract (canonical)* — required sections, the `> Estado:` vocabulary, semantic granularity. Execution references it; it never redefines it. The marker is a **line of its own** inside the `### Fn` block (`> Estado: <value>`); written any other way it reads as `pendiente`.
|
|
74
|
+
|
|
75
|
+
## Delta 1 — One session per run; the phase cycle in the plan-doc
|
|
58
76
|
|
|
59
77
|
- Walks the plan's `### Fn` blocks under `## Tasks` in order (respecting deps) **inside the run's single session** (no session-per-phase). *(Legacy plans: a separate `## Phases` table — walk it the same way.)*
|
|
60
|
-
- **
|
|
61
|
-
- Executes the phase's tasks; **skips** the ones already `- [x]` in the plan (the plan-doc is the per-task source of truth).
|
|
62
|
-
- **
|
|
63
|
-
-
|
|
64
|
-
-
|
|
78
|
+
- **Phase cycle** (artifact-first, one per `### Fn`): read `Resultado` + `Condición de salida` → confirm the initial state → flip `> Estado: en ejecución` and seed `CHECKPOINT.Next` → execute its tasks → run the phase proof plus the justified focused tests (Delta 4). Then: closing review gate over the phase's whole diff (Delta 5) → confirm the `Condición de salida` → flip `> Estado: validada` → update `CHECKPOINT` and propose commits (Delta 2).
|
|
79
|
+
- Executes the phase's tasks; **skips** the ones already `- [x]` in the plan (the plan-doc is the per-task source of truth). **Micro steps stay internal** (canonical contract): they reach `CHECKPOINT` only when a resume needs them, never the plan.
|
|
80
|
+
- **Marking order (hard rule):** a task is marked `- [x]` when its local work is finished. A phase reaches `validada` **only** when its primary proof **ran and passed**, the needed focused checks passed, its `Condición de salida` is true, the review gate is green and every remaining review finding is explicitly deferred — a blocker is never deferred into `validada`. **Never** because all its checkboxes are ticked.
|
|
81
|
+
- **Intermediate states:** `bloqueada` = the phase is stopped on a live blocker — recorded in `CHECKPOINT` + the plan's `## Open questions`, back to `en ejecución` when it clears; it counts as **not validated**. A phase whose work is complete but whose operative check the AI **cannot run** (an unapplied migration — Delta 3) **stays `bloqueada`**: its finished tasks keep their boxes ticked, and the reason goes on its own `> Bloqueo:` line, dropped when the blocker clears. It counts as **not validated** until the check runs and passes. Never a silent `validada`.
|
|
82
|
+
- **A blocker without a reason is not a blocker (hard rule).** Writing `> Estado: bloqueada` **always** writes its `> Bloqueo:` line in the same edit: a state that says "stopped" without saying on what is a dead end for whoever reads `aw status` next. The runtime tolerates a legacy block that states none (`blocker: null`) — this loop never produces one. `CHECKPOINT.Next` names **the action that unblocks it** ("apply migration 014, then re-run the persistence proof"), never the state it is in.
|
|
83
|
+
- **Plan-doc residue (hard rule):** execution writes into the plan-doc **only** five things — checkbox flips (`- [ ]` → `- [x]`), the phase's own `> Estado:` line, its `> Bloqueo:` line while blocked, deferrals appended to its `## Open questions`, and the plan's own status mark (its `> Estado:` line and, on close, its `> Cierre:` line — Delta 6). The declared-gap hatch is Deltas 4, 5 and 7. Per-phase results, review-gate findings and metrics go to the session's `DECISION`/`CHECKPOINT` — **never** into the plan-doc. Phase blocks are updated **in place — NEVER append a duplicate `### Fn` block** (same contract as CHECKPOINT sections). The entry gate's consented normalization is the single exception, and it lands before execution starts.
|
|
84
|
+
- **CHECKPOINT per phase:** on closing a phase record the **functional state reached**, the simulation boundary in force **only when the change carries one**, the tests run and their result, the non-obvious decisions, the deferrals and the next state being pursued. Enumerating every file touched is not required unless it helps a resume.
|
|
85
|
+
- Records in `DECISION` only the **non-obvious**, **as it is decided** (per-phase decisions accumulate in the SINGLE `DECISION`, tagged by phase/task — e.g. `Origin: T2 (F1)`). A structural deviation is **not** settled with an entry there (§ *Deviation gate*).
|
|
65
86
|
- The chassis **gap-driven** engine applies here **inside a task**: facing a non-obvious decision/doubt → inline research, a probe (Delta 7) OR structured-choice.
|
|
66
87
|
|
|
88
|
+
> **Legacy plans degrade safely.** `plan-exec` still runs plans with `### Fn` blocks, `- [ ]` tasks, legacy sections and **no** `> Estado:` line: a missing line reads `pendiente`, and nothing is back-filled. A plan with every box ticked is **not** validated by that fact — the session (`CHECKPOINT`, review gate) decides. What is genuinely missing is closed by the entry gate or by `plan-refine`, never assumed.
|
|
89
|
+
|
|
90
|
+
## Deviation gate
|
|
91
|
+
|
|
92
|
+
Execution resolves **detail**, never **redesign**. This gate lives **only** in this loop — the chassis does not carry it.
|
|
93
|
+
|
|
94
|
+
- **Local decision — `plan-exec` continues.** A class or method name; a local helper; internal code layout; imports; a choice between equivalent APIs already allowed; a fix needed to compile; a minor refactor that does not move the journey; one extra focused test for a risk found while implementing. Recorded in `DECISION` only when it is not obvious.
|
|
95
|
+
- **Structural deviation — stop and return to `plan-refine`.** Stop when the change touches: an input or output; an observable state; a relevant endpoint or public contract; the set of participating components or repositories; the phase order; the simulation boundary; the integration strategy; a material dependency; the main persistence mechanism; a phase already `validada`; the evidence needed to demonstrate the result. A decision that substantially expands or shrinks the work counts too.
|
|
96
|
+
- **Functional change — return to `spec-refine`.** Stop when the change touches: the expected result; the functional scope; a business rule; an acceptance criterion; the actor or consumer; or a product decision.
|
|
97
|
+
|
|
98
|
+
On either return path: `CHECKPOINT` records the state reached and the trigger, the phase keeps the state it really has (`en ejecución` or `bloqueada`, never `validada`), the working tree is left committed or acknowledged (Delta 2), and the human is told through a structured-choice which command to run. Resuming later over the corrected plan is a normal `create_or_resume`.
|
|
99
|
+
|
|
100
|
+
| Finding | `plan-exec` | `plan-refine` | `spec-refine` |
|
|
101
|
+
|---|---|---|---|
|
|
102
|
+
| Rename a helper · internal implementation · test for a local risk | continues | — | — |
|
|
103
|
+
| Change the public DTO | stops | yes | yes, if behavior changes |
|
|
104
|
+
| Add a participating repository | stops | yes | — |
|
|
105
|
+
| Move the simulation to another boundary | stops | yes | — |
|
|
106
|
+
| Change the phase order | stops | yes | — |
|
|
107
|
+
| Add a functional rule · change an acceptance criterion | stops | — | yes |
|
|
108
|
+
|
|
67
109
|
## Delta 2 — Git policy: **safe branch + proposed commits**
|
|
68
110
|
|
|
69
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`.
|
|
@@ -72,23 +114,32 @@ Full policy in [`../CODE-POLICIES.md`](../CODE-POLICIES.md) (§ *Safe git*: bran
|
|
|
72
114
|
|
|
73
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.
|
|
74
116
|
|
|
75
|
-
## Delta 4 — Validation
|
|
117
|
+
## Delta 4 — Validation: phase proof + progressive tests
|
|
76
118
|
|
|
77
|
-
-
|
|
78
|
-
|
|
79
|
-
|
|
119
|
+
- 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:
|
|
120
|
+
1. **phase proof** — component interaction, endpoint smoke test, vertical run down to the stub, persistence integration, or the main path end to end;
|
|
121
|
+
2. **focused tests** — added when the layer carries its own rules, a relevant transformation, error handling, persistence, transactions, temporal logic or external integration;
|
|
122
|
+
3. **risk tests** — security, concurrency, idempotency, retries, known regressions.
|
|
123
|
+
- **One vertical proof per operation while wiring** (request → controller → use case → repository → fake or stub → expected response): it demonstrates the path once instead of re-asserting the same happy path at every layer. Trivial mappers, plain DTOs and framework behavior get no dedicated test.
|
|
124
|
+
- Compatible with **TDD without a test per method**: the evidence may be written before, during or after the phase's code. What is mandatory is that the `Condición de salida` be demonstrated **before** the phase is flipped to `validada`.
|
|
125
|
+
- Each added test is re-weighed at the closing review gate ([`../CODE-POLICIES.md`](../CODE-POLICIES.md) § *Closing review gate* → *Test-value lens*, tag `overtest`): over-testing is a **finding to fix or justify**, never an automatic rejection.
|
|
126
|
+
- Also run the plan's `## Validations` (cross-cutting rules and constraints) + the Final behavior block of `## Solution` (legacy plans: the `## Final behavior` section) + the spec's acceptance/success criteria (its `## Scenarios`, if present, are ready-made test cases: GIVEN=arrange · WHEN=act · THEN=assert).
|
|
127
|
+
- A validation that **runs and fails** → back into the phase (gap): no advancing, no `validada`.
|
|
128
|
+
- **Validation depending on an unapplied migration**: since the AI never executes the DML, it **cannot run it read-only** → the check is **deferred** (handoff to a DBA) and the phase **stays `bloqueada`**. A phase whose implementation is finished but whose operative proof cannot run does not become `validada`: the work may be complete and its boxes ticked, but the state waits until the proof runs and passes. The reason goes on its `> Bloqueo:` line, in `CHECKPOINT`, in the plan's `## Open questions` and in `BACKLOG`, marked "verification pending until the SQL is applied". (Reuses the chassis degrade/defer pattern + `MAX` cap → avoids the "back to the task" loop.)
|
|
80
129
|
|
|
81
|
-
> The **final validation** is PLAN-exec's **convergence gate** = **`Success criteria` green** (*verification-first*; analogous to SPEC's *analyze gate* and plan-new's *coherence gate*): the plan is not marked *done* until it passes
|
|
130
|
+
> The **final validation** is PLAN-exec's **convergence gate** = **`Success criteria` green** (*verification-first*; analogous to SPEC's *analyze gate* and plan-new's *coherence gate*): the plan is not marked *done* until it passes. A deferred check never counts as a passed one — it keeps its phase `bloqueada` and the plan open. For code these are **runnable tests** (TDD); for non-executable DB migrations, a **rubric** (SCRIPTS.sql valid + reviewed).
|
|
82
131
|
|
|
83
132
|
## Delta 5 — Closing review gate (conventions, pre-commit)
|
|
84
133
|
|
|
85
|
-
Full gate in [`../CODE-POLICIES.md`](../CODE-POLICIES.md) (§ *Closing review gate*): **independent** diff re-read + installed ambient conventions; findings → fix (re-validating the phase) or defer justified. Here only the exec wiring: it runs **between the phase validation (Delta 4) and its commits (Delta 2)**; only with the gate green
|
|
134
|
+
Full gate in [`../CODE-POLICIES.md`](../CODE-POLICIES.md) (§ *Closing review gate*): **independent** diff re-read + installed ambient conventions + the floor lenses (minimality, **test value**, **temporary simulation**, tooling); findings → fix (re-validating the phase) or defer justified. Here only the exec wiring: it runs over the phase's **whole** diff, **between the phase validation (Delta 4) and its commits (Delta 2)**; only with the gate green is the phase flipped to `validada` and its commits proposed.
|
|
86
135
|
|
|
87
136
|
## Delta 6 — Completion / close
|
|
88
137
|
|
|
89
|
-
- A phase closes
|
|
90
|
-
-
|
|
91
|
-
- **
|
|
138
|
+
- A phase closes when its `> Estado:` reads `validada`: work done, `Condición de salida` true, proof **run and passed**. A proof still waiting on an operative handoff leaves it `bloqueada`.
|
|
139
|
+
- **The plan's own state is the third axis, and it stays `open` during the whole run.** Every phase `validada` is **not** the plan closed: the final validation still has to run. Keep `> Estado: open` under the title while executing — stamping it on the first write if the plan carries none — and never write `done` from the counters — a legacy plan with every box ticked is not closed by that fact (§ *Legacy plans degrade safely*).
|
|
140
|
+
- **Every phase `validada` + the final validation passed** → final *structured-choice* (content: `Marcar plan done` / `Preguntar algo más`; flow: `Compactar`/`Cerrar`). `Marcar plan done` is offered under no other condition: one `bloqueada` phase keeps the plan open, however many of its tasks are ticked.
|
|
141
|
+
- **Marking done = ONE status line in the plan-doc**, under the title's blockquote: `> Estado: done`, updated in place on a re-run. The machine value **stands alone** — the date and session go on their own `> Cierre: YYYY-MM-DD · sesión NNN` line right under it, for the same reason a blocker never rides on a phase's state line. It never replaces the per-phase lines inside the `### Fn` blocks — position tells the two apart. No per-phase result tables, no ✅ suffixes — that record lives in the session (`DECISION`/`CHECKPOINT`).
|
|
142
|
+
- **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.
|
|
92
143
|
- **No automatic export**: the artifacts (`SCRIPTS.sql`, `DECISION`, …) stay in the session. Promoting them to `docs/` (scripts, manuals, …) is a separate step via `export-*`.
|
|
93
144
|
|
|
94
145
|
## Delta 7 — Probe (PoC) tasks
|
|
@@ -104,43 +155,58 @@ Chassis § *Proof of concept (probe)*, instantiated for execution — for a plan
|
|
|
104
155
|
```
|
|
105
156
|
plan-exec-loop(PPP-plan-<slug>.md):
|
|
106
157
|
session = create_or_resume("<slug>-plan-exec") # <slug> from the plan-doc; ONE session per run; CLI prepends global NNN; CHECKPOINT, resume
|
|
107
|
-
plan = read(PPP-plan-<slug>.md)
|
|
158
|
+
plan = read(PPP-plan-<slug>.md, its spec, checkpoint)
|
|
159
|
+
entry gate (executability): result · exit condition · phase proof · simulation boundary if any · no structural contradiction
|
|
160
|
+
minor gap → structured-choice [Normalizar y ejecutar | Ir a plan-refine] → normalize in place + DECISION
|
|
161
|
+
structural gap → CHECKPOINT(blocker) → hand off to /w:plan-refine → stop
|
|
108
162
|
for each Phase (### Fn block in ## Tasks; legacy: ## Phases table) in plan (in order, respecting deps):
|
|
109
|
-
if
|
|
163
|
+
if Estado == validada: skip # legacy (no line): all its Tasks - [x] AND the session shows it closed
|
|
164
|
+
read Resultado + Condición de salida; confirm the initial state
|
|
165
|
+
set > Estado: en ejecución
|
|
110
166
|
seed CHECKPOINT.Next = Phase N (Pending = its Tasks) # BEFORE starting the phase: seed the intent (artifact-first)
|
|
111
167
|
for each Task of the Phase:
|
|
112
168
|
if Task - [x] in the plan: skip # intra-phase resume by checkbox
|
|
113
169
|
verify each source's expected branch (branch-check)
|
|
114
170
|
on mismatch → pause + resolve with the human
|
|
115
|
-
execute Task:
|
|
171
|
+
execute Task (micro steps internal — never plan entries):
|
|
116
172
|
edit code in the sources (minimal change)
|
|
117
173
|
if it creates a tool/utility → the ambient creating-tools skill documents it in docs/tools
|
|
118
174
|
if read-only DB query → SCRIPTS.sql + execute read-only
|
|
119
175
|
if DB change (DDL/DML) → draft in SCRIPTS.sql (session artifact, DO NOT execute)
|
|
120
|
-
|
|
176
|
+
deviation gate:
|
|
177
|
+
local decision → resolve; DECISION only if non-obvious (tagged by phase/task)
|
|
178
|
+
structural deviation → CHECKPOINT(state + trigger) → stop → /w:plan-refine
|
|
179
|
+
functional change → CHECKPOINT(state + trigger) → stop → /w:spec-refine
|
|
121
180
|
if probe (PoC) task / runnable doubt → seed check → run throwaway code in the
|
|
122
181
|
session folder → verdict → CONCLUSIONS/DECISION; failed → structured-choice (Delta 7)
|
|
123
182
|
if doubt/gap → inline research, probe OR structured-choice # chassis
|
|
124
|
-
mark Task - [x] IN THE PLAN # AFTER
|
|
125
|
-
phase
|
|
126
|
-
what runs and fails → back
|
|
127
|
-
what
|
|
183
|
+
mark Task - [x] IN THE PLAN # AFTER its local work; checkbox flip ONLY — results go to DECISION/CHECKPOINT
|
|
184
|
+
phase proof (Validación de fase) + the justified focused tests: # Delta 4 levels 1→3
|
|
185
|
+
what runs and fails → back into the phase (no validada)
|
|
186
|
+
what cannot run (unapplied migration) → defer the CHECK, never the validation: the phase stays bloqueada
|
|
128
187
|
closing review gate (pre-commit): # Delta 5: CHECKPOINT.Next = "review phase N"
|
|
129
|
-
INDEPENDENT re-read of the phase diff + installed ambient conventions
|
|
188
|
+
INDEPENDENT re-read of the WHOLE phase diff + installed ambient conventions
|
|
189
|
+
+ floor lenses: minimality · test value (overtest) · temporary simulation · tooling
|
|
130
190
|
findings → fix (and re-validate the phase) OR defer justified (Open questions + BACKLOG)
|
|
131
|
-
|
|
191
|
+
confirm the Condición de salida → set > Estado: validada # ONLY with the proof run and passed; NEVER from the checkboxes alone
|
|
192
|
+
blocker still live → set > Estado: bloqueada + > Bloqueo: <reason> + CHECKPOINT + Open questions
|
|
193
|
+
check not runnable (SQL) → set > Estado: bloqueada + > Bloqueo: <reason> + CHECKPOINT + Open questions + BACKLOG
|
|
194
|
+
update CHECKPOINT (functional state reached · simulation boundary if any · tests + result · decisions · deferrals · next state)
|
|
132
195
|
propose commit(s) per source (approve first) # never push/amend/--no-verify; only after the gate is green
|
|
133
196
|
if rejected → changes stay; record "phase uncommitted"
|
|
134
197
|
next-phase precondition: working tree clean or acknowledged
|
|
135
|
-
final validation (whatever can run;
|
|
136
|
-
|
|
137
|
-
|
|
198
|
+
final validation (whatever can run; a deferred check keeps its phase bloqueada)
|
|
199
|
+
if every phase validada AND the final validation passed:
|
|
200
|
+
structured_choice(content: [Marcar plan done, Preguntar algo más], flow: [Compactar, Cerrar])
|
|
201
|
+
mark plan done → > Estado: done + > Cierre: YYYY-MM-DD · sesión NNN under the title (Delta 6), in place
|
|
202
|
+
else: the plan-level > Estado: stays open → CHECKPOINT.Next = the action that unblocks the phase(s)
|
|
138
203
|
# NO export: artifacts stay in the session; a separate export-* promotes them
|
|
139
204
|
finalize: CHECKPOINT (+ BACKLOG if something is deferred) + close session + report
|
|
140
205
|
```
|
|
141
206
|
|
|
142
207
|
## Convergence / exit
|
|
143
208
|
|
|
144
|
-
-
|
|
209
|
+
- **Every phase `validada`** + final validation **run and passed** + **every phase passed its closing review gate** before committing → `Marcar plan done`. A phase left `pendiente`, `en ejecución` or `bloqueada` keeps the plan open, whatever its checkboxes say — a proof waiting on an operative handoff (an unapplied migration) is exactly that case.
|
|
210
|
+
- 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.
|
|
145
211
|
- `Cerrar` (`flow` control, at any time) → `finalize` persists `CHECKPOINT` (and `BACKLOG` only if something remained unexecuted / uncommitted / unapplied), closes the session, reports.
|
|
146
212
|
- Promoting artifacts to `docs/` (via `export-*`) is **always** a later, explicit step outside this loop.
|
|
@@ -3,7 +3,8 @@ name: plan-new-loop
|
|
|
3
3
|
description: >-
|
|
4
4
|
Generates a rich implementation plan (docs/plans/PPP-plan-<slug>.md) from a
|
|
5
5
|
spec. Heir of the chassis (loops/CHASSIS.md). Deltas: the plan absorbs the
|
|
6
|
-
TECHNICAL-NOTE level +
|
|
6
|
+
TECHNICAL-NOTE level + Tasks phased by verifiable functional state
|
|
7
|
+
(### Fn blocks with live state),
|
|
7
8
|
code/impact-mapping research, planning gap taxonomy, and per-screen design
|
|
8
9
|
SPECs via ui-design
|
|
9
10
|
when the plan includes UI. If the spec is not refined it suggests
|
|
@@ -25,7 +26,7 @@ PLAN
|
|
|
25
26
|
`/w:plan-new` — **resumable** (same chassis mechanism, keyed off CHECKPOINT).
|
|
26
27
|
|
|
27
28
|
## Reads
|
|
28
|
-
`docs/specs/NNN-spec-*.md` (glob — locates the spec by number; or the exact path from the command argument). **
|
|
29
|
+
`docs/specs/NNN-spec-*.md` (glob — locates the spec by number; or the exact path from the command argument). **Ready vs not** is read from the spec's frontmatter `status`: `ready-for-plan` → proceed (legacy compat: a frontmatter-less spec carrying `## Refinement decisions`, or the older `## Q&A traceability`, counts as ready). Otherwise → **soft-suggest** running `/w:spec-refine` first (planning over a solid spec produces better plans), **never a block**: the user may proceed. Questions the spec left with destination `PLAN` are **input to this loop**, not a reason to send it back.
|
|
29
30
|
|
|
30
31
|
## Writes
|
|
31
32
|
`docs/plans/PPP-plan-<slug>.md` (`generate`; **overwrites with confirmation** if it exists) — or **several sibling plans** when an accepted split applies (§ *Split gate (multi-plan)*). It writes only `docs/plans` — never other `docs/` folders, no auto-export. If the plan **includes UI**, it also produces **design SPECs** (`NNN-SPEC-<SLUG>.md`) as artifacts **of its session** (see *Delta 4* — they are not `docs/`, no auto-export).
|
|
@@ -54,6 +55,7 @@ The plan absorbs the `TECHNICAL-NOTE` level **inline** (user decision) + the roa
|
|
|
54
55
|
# Plan PPP — <slug>
|
|
55
56
|
|
|
56
57
|
> Derived from docs/specs/NNN-spec-<slug>.md · generated by plan-new-loop
|
|
58
|
+
> Estado: open ← plan-level machine state (open | done); plan-exec closes it
|
|
57
59
|
|
|
58
60
|
## Origin source spec · prompt (bootstrapped via spec-new) · "adopted from <source>" + attribution (external plan — /w:plan-new mode 4 / /w:persist)
|
|
59
61
|
## Solution the how (core): 1–2 summary sentences + the AS-IS → TO-BE
|
|
@@ -62,10 +64,12 @@ The plan absorbs the `TECHNICAL-NOTE` level **inline** (user decision) + the roa
|
|
|
62
64
|
aligned with the spec criteria. One narration, not four.
|
|
63
65
|
## Impacted FE · BE · DB (schemas/tables/functions) · APIs · integr. (core)
|
|
64
66
|
## Dependencies docs / sources / databases / sessions · inter-plan order on a split (opt.)
|
|
65
|
-
## Tasks (core) `### Fn — <name>` blocks
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
## Tasks (core) `### Fn — <name>` blocks per the phase contract
|
|
68
|
+
below: each one a verifiable functional state with its
|
|
69
|
+
`> Estado:` line, its evidence and its `- [ ] Tn.m`
|
|
70
|
+
units of purpose — never a list of layers or files.
|
|
71
|
+
The `### Fn` headers are the ONLY source of phases;
|
|
72
|
+
there is no separate Phases table.
|
|
69
73
|
## Validations validations / constraints / business logic (core)
|
|
70
74
|
## Risks / impact technical risks and impacts (opt.)
|
|
71
75
|
## Assumptions assumptions — only the delta over the spec, never re-imported (opt.)
|
|
@@ -76,6 +80,54 @@ The plan absorbs the `TECHNICAL-NOTE` level **inline** (user decision) + the roa
|
|
|
76
80
|
|
|
77
81
|
> **Catalog implication:** `TECHNICAL-NOTE` stops being a session artifact and becomes **sections of the plan-doc**. Reconciled in [`plan-exec-loop`](../plan-exec-loop/LOOP.md): the single plan-exec session carries **no** `TECHNICAL-NOTE` nor its own `TASKS`; the technical detail and the progress live inline in the plan-doc (living).
|
|
78
82
|
|
|
83
|
+
## Phase contract (canonical)
|
|
84
|
+
|
|
85
|
+
A `### Fn` block is a **verifiable state of the system**, never a list of layers, files or classes. It answers one question: *what can the system do or demonstrate at the end that it could not at the start?* The contract is defined **once** here — [`plan-refine-loop`](../plan-refine-loop/LOOP.md) and [`plan-exec-loop`](../plan-exec-loop/LOOP.md) reference it and never redefine it.
|
|
86
|
+
|
|
87
|
+
**Required — every phase, always:**
|
|
88
|
+
|
|
89
|
+
```markdown
|
|
90
|
+
### F1 — <result-oriented name>
|
|
91
|
+
|
|
92
|
+
> Estado: pendiente
|
|
93
|
+
|
|
94
|
+
**Resultado:** <the new verifiable state of the system>
|
|
95
|
+
|
|
96
|
+
**Trabajo:**
|
|
97
|
+
- [ ] T1.1 — <coherent unit of work>
|
|
98
|
+
|
|
99
|
+
**Validación de fase:** <the primary proof that the promised state was reached>
|
|
100
|
+
|
|
101
|
+
**Condición de salida:** <falsifiable result · contract preserved>
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
**Conditional — added to that block only when its own condition holds:**
|
|
105
|
+
|
|
106
|
+
```markdown
|
|
107
|
+
**Estado inicial:** <where the phase starts>
|
|
108
|
+
**Recorrido afectado:** <consumer → components → current boundary>
|
|
109
|
+
**Dependencias:** <phase(s) that must land first>
|
|
110
|
+
**Límite de simulación:** antes <where it is> → después <where it lands, or removed>
|
|
111
|
+
**Diferido:** <work consciously reserved for another phase>
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
- **Required**: `Resultado` · `Trabajo` · `Validación de fase` · `Condición de salida`, plus the `> Estado:` line.
|
|
115
|
+
- **Conditional**: `Estado inicial` (when it is not obvious) · `Recorrido afectado` (distributed change) · `Dependencias` (the phase cannot run in direct sequence) · `Límite de simulación` (**only** when temporary behavior exists) · `Diferido` (only when work was consciously excluded).
|
|
116
|
+
|
|
117
|
+
**A new phase never writes an empty conditional block.** No temporary behavior in the change → no `Límite de simulación` line at all; nothing consciously excluded → no `Diferido`. Writing the label with `no aplica` under it is the failure mode this split exists to prevent: it invites inventing a stub to justify the heading, and turns a contract into a form to fill in. The gates check the same way — an absent conditional block is not a gap (§ *Convergence / exit*).
|
|
118
|
+
|
|
119
|
+
**Phase state = machine state.** One `> Estado: <value>` line directly under the `### Fn` heading; vocabulary `pendiente` | `en ejecución` | `bloqueada` | `validada`, updated **in place**, never duplicated. It is what `aw status` counts (`phases_validated` / `phases_total`), **alongside — not instead of —** the checkbox progress. A phase reaches `validada` only when its work is done, its `Condición de salida` holds, its validation **ran and passed**, and the closing review gate passed. **Never** because all its checkboxes are ticked. *(Legacy plans carry no line at all: `aw status` reports them as zero phases — checkbox progress only. A missing line among stated blocks reads `pendiente`, and nothing is back-filled.)*
|
|
120
|
+
|
|
121
|
+
**The state line carries its value alone** — no comment, no suffix, no annotation; an annotated value reads as `pendiente`. A blocker's reason lives on its own `> Bloqueo: <reason>` line inside the block, and in `CHECKPOINT`, `## Open questions` and `BACKLOG`.
|
|
122
|
+
|
|
123
|
+
**The plan carries its own state, and it is a different axis.** One `> Estado:` line under the title, vocabulary `open` | `done`, born `open` with the plan; `plan-exec` writes `done` only after the final validation, adding a `> Cierre: YYYY-MM-DD · sesión NNN` line for the date and session (§ *Delta 6* there). `aw status` derives `plan_state` from that declaration **and** both counters: a `done` over open tasks or unvalidated phases reads `inconsistent`, and every phase `validada` with no closure reads `final_validation_pending` — still open. Position disambiguates the two marks: the plan-level one lives under the title, the phase-level one inside its `### Fn` block. *(Legacy: `> Estado: done — YYYY-MM-DD · sesión NNN` is still read; the next legitimate write normalizes it.)*
|
|
124
|
+
|
|
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
|
+
|
|
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
|
+
|
|
79
131
|
## Delta 2 — Gap taxonomy (of "plan")
|
|
80
132
|
|
|
81
133
|
Replaces the spec gap taxonomy with a planning-oriented one:
|
|
@@ -85,9 +137,13 @@ Replaces the spec gap taxonomy with a planning-oriented one:
|
|
|
85
137
|
| Approach/Solution undefined | the how is vague | research / human |
|
|
86
138
|
| Components unidentified | FE/BE/DB impact unknown | **research** (maps the code) |
|
|
87
139
|
| AS-IS wiring unknown | current state unknown | **research** |
|
|
88
|
-
|
|
|
140
|
+
| Journey unmapped | the observable contract, the participating components or the repo/process boundaries are unknown — the phases cannot be ordered | **research** |
|
|
141
|
+
| Phase without a state | a `### Fn` mixes unrelated functional states, or nothing can be validated until the very end | the AI re-shapes it by state (**human** confirms an order change) |
|
|
89
142
|
| Plan splittable | independently deliverable tranches — different moments/priorities, no shared deps/risk | **human consents** → split (see *Split gate (multi-plan)*) |
|
|
90
|
-
| Task
|
|
143
|
+
| Task named as an edit | the name states an edit operation ("create class X", "add method Y") instead of a purpose | the AI re-states it by purpose |
|
|
144
|
+
| Structural micro-tasks | the plan enumerates files, classes or methods as entries | the AI groups them by purpose |
|
|
145
|
+
| Simulation without lifecycle | temporary behavior exists with no phase that displaces it and no phase that retires it | the AI derives both / **human** |
|
|
146
|
+
| Phase without evidence | the block declares no `Validación de fase` | the AI derives it from the criteria / **human** |
|
|
91
147
|
| Over-engineered solution | approach heavier than the criteria need — needless abstraction/layer/dependency, or a phase/task not required to meet the spec (chassis § *Minimality*) | AI proposes the lighter path + **human** confirms (**probe** if "lighter works" is a runnable doubt) |
|
|
92
148
|
| Missing deps | order unclear | research / human |
|
|
93
149
|
| Spec criteria uncovered | tasks don't trace to acceptance criteria | the AI derives + human confirms |
|
|
@@ -132,8 +188,8 @@ Resolves the **Plan splittable** gap (Delta 2) — the canonical definition for
|
|
|
132
188
|
```
|
|
133
189
|
plan-new-loop(spec):
|
|
134
190
|
input = glob(docs/specs/NNN-spec-*.md) | argument path
|
|
135
|
-
if the spec
|
|
136
|
-
soft-suggest /w:spec-refine
|
|
191
|
+
if the spec is not status: ready-for-plan (nor a legacy mark):
|
|
192
|
+
soft-suggest /w:spec-refine # never blocks — the user may proceed anyway
|
|
137
193
|
session = create_or_resume("<slug>-plan-new") # CLI prepends global NNN
|
|
138
194
|
seed SESSION.Success criteria = coherence-gate checklist # verification-first, BEFORE
|
|
139
195
|
work = plan skeleton (Delta 1) derived from the spec (+ checkpoint progress if resuming)
|
|
@@ -147,7 +203,11 @@ plan-new-loop(spec):
|
|
|
147
203
|
- every spec acceptance criterion traces to a phase/task
|
|
148
204
|
(split: each criterion → exactly one sibling — complete, disjoint partition)
|
|
149
205
|
- the Final behavior block of ## Solution covers the criteria
|
|
150
|
-
- ### Fn
|
|
206
|
+
- every ### Fn leaves a verifiable state with its own exit condition — never a list of layers or files
|
|
207
|
+
- the order allows early integration · deps without cycles · Impacted consistent with Solution
|
|
208
|
+
- the simulation boundary, ONLY when the change carries one, is located, its displacement planned, and one phase owns its retirement
|
|
209
|
+
- every phase declares its primary evidence; per-layer tests are justified, never automatic
|
|
210
|
+
- resumable: a stop between phases leaves a stable state and a legible next intent
|
|
151
211
|
- minimality (chassis § *Minimality*): the Solution is the lightest that meets its Final behavior block; no phase/task/abstraction the criteria don't require
|
|
152
212
|
- (UI) every screen/UI task traces to its design SPEC and does not contradict ## UI spec
|
|
153
213
|
whatever fails → comes back as a gap
|
|
@@ -163,6 +223,7 @@ finalize: CHECKPOINT persisted (+ BACKLOG only if something is deferred) + close
|
|
|
163
223
|
## Convergence / exit
|
|
164
224
|
|
|
165
225
|
- **No material gaps** → **coherence gate** (the *Sequence* checklist; the PLAN-new instance of the chassis convergence gate). Criterion→task traceability is a **checked invariant**, never a separate section.
|
|
226
|
+
- **The gate judges functional states, not size.** A plan converges when every `### Fn` is a verifiable state with its exit condition and its primary evidence — plus its simulation boundary located, **only when the change carries one**; a phase that only enumerates layers or files comes back as a gap, however small it is.
|
|
166
227
|
- Passes → `Guardar plan` (writes with confirmation if it exists) → `finalize`.
|
|
167
228
|
- **Split branch**: `Guardar planes` writes the N siblings sequentially (mint before each write) → `finalize` — one session, one HISTORY row.
|
|
168
229
|
- `Cerrar` at any time → `finalize` (persists `CHECKPOINT`; `BACKLOG` only if something is deferred; closes the session, reports).
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: plan-refine-loop
|
|
3
3
|
description: >-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
Turns an existing plan (docs/plans/PPP-plan-<slug>.md) into an EXECUTABLE
|
|
5
|
+
sequence of functional states, editing it IN PLACE. Heir of the chassis
|
|
6
|
+
(loops/CHASSIS.md). Deltas: functional journey map, phases re-shaped by
|
|
7
|
+
verifiable state (contract in plan-new-loop), simulation lifecycle,
|
|
8
|
+
evidence by behavior, executability gate, replanning of partially executed
|
|
9
|
+
plans, and design SPECs via ui-design on UI changes. Started by
|
|
10
|
+
/w:plan-refine — also the return path when plan-exec stops on a structural
|
|
11
|
+
deviation; resumable and re-runnable on demand.
|
|
11
12
|
---
|
|
12
13
|
|
|
13
14
|
# plan-refine-loop
|
|
@@ -22,11 +23,19 @@ PLAN
|
|
|
22
23
|
## Layer
|
|
23
24
|
2 — the AI runs it end to end.
|
|
24
25
|
|
|
26
|
+
## Objective — an executable sequence of functional states
|
|
27
|
+
|
|
28
|
+
This loop turns a plan into a sequence of **verifiable states of the system**. Exit condition:
|
|
29
|
+
|
|
30
|
+
> `plan-exec` can implement every phase **without inventing** contracts, observable states, structural order, simulation boundary or exit evidence.
|
|
31
|
+
|
|
32
|
+
The phase contract is defined **once** in [`plan-new-loop`](../plan-new-loop/LOOP.md) § *Phase contract (canonical)* — this loop **applies** it and never redefines it: a `### Fn` block is a state the system reaches, with its `> Estado:` line, its work, its evidence and its exit condition.
|
|
33
|
+
|
|
25
34
|
## Auxiliary / NOT mandatory
|
|
26
|
-
`plan-exec` runs **any** plan, refined or not — there is **no** gate requiring plan-refine. This loop exists to incorporate changes (new requirements, scope adjustments, deps/risks spotted on re-read) **before** executing, without regenerating
|
|
35
|
+
`plan-exec` runs **any** plan that is already executable, refined or not — there is **no** gate requiring plan-refine. This loop exists to incorporate changes (new requirements, scope adjustments, deps/risks spotted on re-read) **before** executing, and to give an unexecutable plan the shape its execution needs, without regenerating it from scratch.
|
|
27
36
|
|
|
28
37
|
## Started by
|
|
29
|
-
`/w:plan-refine` — **resumable** (same chassis mechanism, keyed off CHECKPOINT) and **re-runnable on demand** (see *Compact / resume*).
|
|
38
|
+
`/w:plan-refine` — **resumable** (same chassis mechanism, keyed off CHECKPOINT) and **re-runnable on demand** (see *Compact / resume*). Second path: **the return from execution** — `plan-exec` derives here when its entry check finds a structural gap it cannot normalize, or when it stops mid-run on a structural deviation (§ *Replanning executed work*).
|
|
30
39
|
|
|
31
40
|
## Reads
|
|
32
41
|
`docs/plans/PPP-plan-*.md` (glob — locates the plan by number; or the exact path from the command argument). **Always the plan itself**: this loop edits it in place; there is no separate "refined" file. Provenance is irrelevant — generated by `plan-new`, **hand-written, or adopted** from a host planner (`plan-new` mode 4 / `persist`); existence is the only requirement.
|
|
@@ -52,25 +61,29 @@ The plan uses the **same skeleton** [`plan-new-loop`](../plan-new-loop/LOOP.md)
|
|
|
52
61
|
|
|
53
62
|
```markdown
|
|
54
63
|
## Refinement decisions ← NEW (ADDED) — the run's single trace
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
`Q: <question> → <chosen answer> — <rationale
|
|
64
|
+
MATERIAL changes only: contracts, journey, shape or order of the phases,
|
|
65
|
+
movement of the simulation boundary, risks that altered the plan, and work
|
|
66
|
+
already executed that conditions the replanning. A doubt that changed one of
|
|
67
|
+
those goes as `Q: <question> → <chosen answer> — <rationale>` (ref to the
|
|
68
|
+
session's CONCLUSIONS for what research resolved). A micro-decision, or a
|
|
69
|
+
question that changed nothing, is NOT transcribed.
|
|
59
70
|
```
|
|
60
71
|
|
|
61
72
|
> **No gating contract** (unlike spec↔plan): the presence of `## Refinement decisions` in the plan is **audit trace only** — `plan-exec` neither requires nor checks it (it runs any plan). It serves to (a) distinguish a re-refined plan from a freshly generated one on resume, and (b) record what changed and why. *(Legacy plans may also carry `## Q&A traceability`; new runs never write it.)*
|
|
62
73
|
|
|
63
|
-
>
|
|
74
|
+
> **Execution updates progress; refinement changes structure.** `plan-exec` updates the plan's operational state in place — task checkboxes, the phase `> Estado:` line with its `> Bloqueo:` line while blocked, declared deferrals and the plan's own status mark. It does **not** redesign contracts, phase shape or order, participating components, evidence or simulation boundaries: those structural changes are this loop's, and a change of functional behavior belongs to `spec-refine`.
|
|
75
|
+
|
|
76
|
+
> **Normalize on write, never invent.** A save through this loop leaves the document on the current contract. The plan-level `> Estado:` line sits under the title — `open`, unless execution already closed it, and then with the date and session on their own `> Cierre:` line. Each `### Fn` carries its required blocks, and **no conditional block is written empty**: a phase with no temporary behavior gets no `Límite de simulación`, one with nothing excluded gets no `Diferido`. Normalizing is a rewrite of form — it never changes a phase's state, never ticks a box, and never closes a plan.
|
|
64
77
|
|
|
65
78
|
## Delta 2 — Gap taxonomy (of "plan")
|
|
66
79
|
|
|
67
|
-
Reuses plan-new-loop's gap taxonomy **in full** ([`plan-new-loop`](../plan-new-loop/LOOP.md) § *Delta 2*): vague Approach/Solution, components unidentified, AS-IS wiring unknown,
|
|
80
|
+
Reuses plan-new-loop's gap taxonomy **in full** ([`plan-new-loop`](../plan-new-loop/LOOP.md) § *Delta 2*), semantic rows included: journey unmapped, phase without a state, task named as an edit, structural micro-tasks, simulation without lifecycle, phase without evidence, plus the shared ones (vague Approach/Solution, components unidentified, AS-IS wiring unknown, over-engineered solution, missing deps, spec criteria uncovered, unaddressed risks, splittable plan, UI without design SPEC). **Focus difference:** plan-new **builds** the plan from scratch; plan-refine re-shapes what is already written — what changed against the plan (or against the spec, if the spec was re-refined) and what still keeps the plan from being executable. One extra re-refine gap:
|
|
68
81
|
|
|
69
82
|
| Gap | Signal | Resolved by |
|
|
70
83
|
|---|---|---|
|
|
71
84
|
| Plan↔spec drift | the spec was re-refined and the plan fell out of line | **research** (re-reads the spec) / **human** |
|
|
72
85
|
|
|
73
|
-
> **Spec-less degradation (hand-written / adopted plans).** When the plan has **no source spec** (`## Origin` = adopted / hand-written), the spec-anchored checks **degrade gracefully**: "spec criteria uncovered" and "plan↔spec drift" do **not** apply — criterion→task traceability anchors to the plan's **own** Final behavior block (in `## Solution`) / `## Validations` instead. The rest of the taxonomy (
|
|
86
|
+
> **Spec-less degradation (hand-written / adopted plans).** When the plan has **no source spec** (`## Origin` = adopted / hand-written), the spec-anchored checks **degrade gracefully**: "spec criteria uncovered" and "plan↔spec drift" do **not** apply — criterion→task traceability anchors to the plan's **own** Final behavior block (in `## Solution`) / `## Validations` instead. The rest of the taxonomy (phase shape, simulation, evidence, deps, Impacted↔Solution, UI→SPEC) applies unchanged. Normalizing an adopted plan to the full Delta 1 schema **is** this loop's job (missing `(core)` sections are gaps).
|
|
74
87
|
|
|
75
88
|
> **Adjust the Solution the laziest-that-works way** (chassis § *Minimality*, generative side): reuse what already exists before adding abstractions, layers or dependencies — the coherence gate only *confirms* minimality, and a re-refine is a chance to *remove* over-building, not add it.
|
|
76
89
|
|
|
@@ -82,6 +95,57 @@ Same as plan-new (maps code/impact: FE/BE/DB components, AS-IS wiring, deps), bu
|
|
|
82
95
|
|
|
83
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.
|
|
84
97
|
|
|
98
|
+
## Functional journey map
|
|
99
|
+
|
|
100
|
+
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:
|
|
101
|
+
|
|
102
|
+
- **Observable contract** — who starts the operation, what inputs it provides, what successful result and what errors or states it observes, which contracts are created or changed, and what must stay compatible.
|
|
103
|
+
- **Technical journey** — participating components and their approximate order, boundaries between repos or processes, where persistence and external integrations sit, what already exists and what must be wired.
|
|
104
|
+
- **Incremental strategy** — the first demonstrable journey and, **only when the change carries temporary behavior**, where a safe simulation can live, how it is displaced and which phase retires it (reference shapes: [`plan-new-loop`](../plan-new-loop/LOOP.md) § *Incremental strategy*).
|
|
105
|
+
- **Evidence** — the primary proof of each phase, which rules deserve an isolated test, which integrations need a real one, and what cannot be validated because of operational constraints (that one goes to `## Open questions`).
|
|
106
|
+
|
|
107
|
+
> **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
|
+
|
|
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
|
+
## Evidence by behavior
|
|
118
|
+
|
|
119
|
+
Each phase carries proof of behavior, not of structure. Three levels, **chosen** — never descended automatically:
|
|
120
|
+
|
|
121
|
+
1. **Primary phase proof** — demonstrates the state the phase promised: component interaction, endpoint smoke, a vertical run down to the stub, persistence integration, or the end-to-end happy path.
|
|
122
|
+
2. **Focused proofs** — where a layer owns rules, a relevant transformation, error handling, persistence, transactions, temporal logic or an external integration.
|
|
123
|
+
3. **Risk proofs** — security, concurrency, idempotency, retries, known regressions, plausible high-impact failures.
|
|
124
|
+
|
|
125
|
+
The primary proof lives **inside its `### Fn` block** (`Validación de fase`); `## Validations` keeps the cross-cutting rules and constraints. A simulation gets only the minimum proof that demonstrates the wiring — no suite is built around what the next phase retires.
|
|
126
|
+
|
|
127
|
+
> **Necessity gate** (design criterion, not a record to keep): what behavior does the test demonstrate, what unique failure would it catch, is that already demonstrated elsewhere, does it target a stable boundary or an internal detail, does the layer own logic or risk, is it still worth keeping once the simulation is gone? No clear answer → it is not planned. Whatever slips through and only mirrors structure is flagged `overtest` by execution's closing review gate.
|
|
128
|
+
|
|
129
|
+
## Executability gate
|
|
130
|
+
|
|
131
|
+
This loop's instance of the chassis convergence gate — the same one `plan-exec` verifies on entry. Whatever fails comes back as a gap:
|
|
132
|
+
|
|
133
|
+
- **Contract** — relevant inputs, outputs and observable states identified; the final behavior matches the spec; no functional criterion invented here.
|
|
134
|
+
- **Journey** — main components identified, order reasonable, repo/process boundaries visible, the described architecture the one the project actually has.
|
|
135
|
+
- **Phases** — each leaves a verifiable state with its exit condition, none is a list of layers or files, the order allows early integration, deferrals are explicit.
|
|
136
|
+
- **Simulation** *(only when the change carries one)* — initial boundary identified, every displacement foreseen, one phase owns the retirement, nothing can stay active by accident. No temporary behavior → the check does not apply, and no empty `Límite de simulación` is required.
|
|
137
|
+
- **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
|
+
- **Resumability** — tasks legible enough for a `CHECKPOINT`, intermediate states stable, pending work distinguishable from work already `validada`.
|
|
139
|
+
|
|
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
|
+
|
|
85
149
|
## Split gate — refine semantics
|
|
86
150
|
|
|
87
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:
|
|
@@ -103,8 +167,11 @@ Full mechanism (3 cases, `Compactar`, re-run with `--reopen`) in the chassis (§
|
|
|
103
167
|
plan-refine-loop(plan):
|
|
104
168
|
input = glob(docs/plans/PPP-plan-*.md) | argument path # always the plan itself (in place)
|
|
105
169
|
session = create_or_resume("<slug>-plan-refine") # reopens if it exists (see Compact / resume)
|
|
106
|
-
seed SESSION.Success criteria =
|
|
107
|
-
work = read(plan) (+ the spec if realignment is needed; + checkpoint
|
|
170
|
+
seed SESSION.Success criteria = executability-gate checklist # verification-first, BEFORE
|
|
171
|
+
work = read(plan) (+ the spec if realignment is needed; + checkpoint/exec history if resuming or returning from plan-exec)
|
|
172
|
+
journey = map(observable contract, technical journey, incremental strategy, evidence) # bounded research
|
|
173
|
+
work = phases grouped by verifiable state (phase contract) + simulation lifecycle if any + primary proof each
|
|
174
|
+
keep validated phases and their completed tasks; redesign ONLY pending work
|
|
108
175
|
repeat: # chassis engine
|
|
109
176
|
gaps = detect_gaps(work) (plan-new taxonomy + plan↔spec drift) minus the exhausted ones
|
|
110
177
|
if gaps == ∅: break
|
|
@@ -112,8 +179,9 @@ plan-refine-loop(plan):
|
|
|
112
179
|
research (scoped to the delta — Delta 3) · human (structured-choice) · probe (chassis) ·
|
|
113
180
|
ui-design (Delta 4, only new/changed screens)
|
|
114
181
|
integrate + update CHECKPOINT # artifact-first cycle
|
|
115
|
-
|
|
116
|
-
-
|
|
182
|
+
executability gate (read-only) = Success criteria green:
|
|
183
|
+
- contract · journey · phases · simulation · evidence · resumability (§ Executability gate)
|
|
184
|
+
- plan-new checklist (criterion→task · Final behavior block of Solution · deps · Impacted↔Solution · UI→current SPEC · minimality)
|
|
117
185
|
# spec-less plan (adopted/hand-written): criteria anchor to the plan's own Final behavior block/Validations (see Delta 2)
|
|
118
186
|
- re-refine's own check: the plan is REALIGNED with what changed
|
|
119
187
|
whatever fails → comes back as a gap
|
|
@@ -128,7 +196,9 @@ finalize: CHECKPOINT persisted (+ BACKLOG only if something is deferred) + close
|
|
|
128
196
|
|
|
129
197
|
## Convergence / exit
|
|
130
198
|
|
|
131
|
-
- **No material gaps** → **
|
|
199
|
+
- **No material gaps** → **executability gate** (the *Sequence* checklist: contract · journey · phases · simulation · evidence · resumability, plus plan-new's coherence checks and the re-refine's own realignment check).
|
|
132
200
|
- Passes → `Guardar plan refinado` (edits in place with confirmation) → `finalize`.
|
|
133
201
|
- **Split branch**: `Guardar planes` edits the original reduced and writes the extracted siblings → `finalize`.
|
|
134
202
|
- `Cerrar` at any time → `finalize` (persists `CHECKPOINT`; `BACKLOG` only if something is deferred; closes the session, reports).
|
|
203
|
+
|
|
204
|
+
> **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.
|