@tacuchi/agent-workflow-cli 20.26.0 → 21.1.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 (220) hide show
  1. package/README.md +2 -1
  2. package/dist/adapters/node-file-system.js +3 -0
  3. package/dist/adapters/node-file-system.js.map +1 -1
  4. package/dist/application/capability/compose.js +161 -0
  5. package/dist/application/capability/compose.js.map +1 -0
  6. package/dist/application/capability/descriptor-loader.js +109 -0
  7. package/dist/application/capability/descriptor-loader.js.map +1 -0
  8. package/dist/application/capability/design-handler.js +299 -0
  9. package/dist/application/capability/design-handler.js.map +1 -0
  10. package/dist/application/capability/dispatcher.js +312 -0
  11. package/dist/application/capability/dispatcher.js.map +1 -0
  12. package/dist/application/capability/durable-effect.js +220 -0
  13. package/dist/application/capability/durable-effect.js.map +1 -0
  14. package/dist/application/capability/installed-inventory.js +168 -0
  15. package/dist/application/capability/installed-inventory.js.map +1 -0
  16. package/dist/application/capability/readiness.js +204 -0
  17. package/dist/application/capability/readiness.js.map +1 -0
  18. package/dist/application/capability/resolution.js +264 -0
  19. package/dist/application/capability/resolution.js.map +1 -0
  20. package/dist/application/capability/wrapper.js +187 -0
  21. package/dist/application/capability/wrapper.js.map +1 -0
  22. package/dist/application/context/manifest.js +11 -5
  23. package/dist/application/context/manifest.js.map +1 -1
  24. package/dist/application/context/measure.js +5 -2
  25. package/dist/application/context/measure.js.map +1 -1
  26. package/dist/application/context/plan-service.js +6 -6
  27. package/dist/application/context/plan-service.js.map +1 -1
  28. package/dist/application/design/design-bundle-service.js +148 -0
  29. package/dist/application/design/design-bundle-service.js.map +1 -0
  30. package/dist/application/design/design-gate-service.js +246 -0
  31. package/dist/application/design/design-gate-service.js.map +1 -0
  32. package/dist/application/design/design-graph-service.js +85 -0
  33. package/dist/application/design/design-graph-service.js.map +1 -0
  34. package/dist/application/design/design-index-service.js +132 -0
  35. package/dist/application/design/design-index-service.js.map +1 -0
  36. package/dist/application/design/design-proposal-service.js +69 -0
  37. package/dist/application/design/design-proposal-service.js.map +1 -0
  38. package/dist/application/design/design-publish-service.js +756 -0
  39. package/dist/application/design/design-publish-service.js.map +1 -0
  40. package/dist/application/design/design-record-service.js +100 -0
  41. package/dist/application/design/design-record-service.js.map +1 -0
  42. package/dist/application/design/design-resolver-service.js +165 -0
  43. package/dist/application/design/design-resolver-service.js.map +1 -0
  44. package/dist/application/flow/advance.js +533 -0
  45. package/dist/application/flow/advance.js.map +1 -0
  46. package/dist/application/flow/flow-service.js +65 -0
  47. package/dist/application/flow/flow-service.js.map +1 -0
  48. package/dist/application/flow/run-projection.js +80 -0
  49. package/dist/application/flow/run-projection.js.map +1 -0
  50. package/dist/application/flow/run-state-service.js +107 -0
  51. package/dist/application/flow/run-state-service.js.map +1 -0
  52. package/dist/application/flow/submit.js +423 -0
  53. package/dist/application/flow/submit.js.map +1 -0
  54. package/dist/application/resume-service.js +46 -14
  55. package/dist/application/resume-service.js.map +1 -1
  56. package/dist/application/self/install-skill.js +11 -0
  57. package/dist/application/self/install-skill.js.map +1 -1
  58. package/dist/application/self/uninstall.js +21 -0
  59. package/dist/application/self/uninstall.js.map +1 -1
  60. package/dist/application/semantic-operation/protocol.js +18 -12
  61. package/dist/application/semantic-operation/protocol.js.map +1 -1
  62. package/dist/application/semantic-operation/publish.js +56 -9
  63. package/dist/application/semantic-operation/publish.js.map +1 -1
  64. package/dist/application/skills-resolver-service.js +27 -6
  65. package/dist/application/skills-resolver-service.js.map +1 -1
  66. package/dist/application/status-service.js +5 -1
  67. package/dist/application/status-service.js.map +1 -1
  68. package/dist/application/workline-index-service.js +6 -0
  69. package/dist/application/workline-index-service.js.map +1 -1
  70. package/dist/application/workspace-init-service.js +22 -2
  71. package/dist/application/workspace-init-service.js.map +1 -1
  72. package/dist/cli/commands/capability.js +182 -0
  73. package/dist/cli/commands/capability.js.map +1 -0
  74. package/dist/cli/commands/designs.js +110 -0
  75. package/dist/cli/commands/designs.js.map +1 -0
  76. package/dist/cli/commands/flow.js +71 -0
  77. package/dist/cli/commands/flow.js.map +1 -0
  78. package/dist/cli/commands/index.js +6 -0
  79. package/dist/cli/commands/index.js.map +1 -1
  80. package/dist/cli/commands/resume.js +8 -0
  81. package/dist/cli/commands/resume.js.map +1 -1
  82. package/dist/cli/commands/skills.js +55 -2
  83. package/dist/cli/commands/skills.js.map +1 -1
  84. package/dist/cli/commands/status.js +50 -0
  85. package/dist/cli/commands/status.js.map +1 -1
  86. package/dist/cli/help-groups.js +9 -0
  87. package/dist/cli/help-groups.js.map +1 -1
  88. package/dist/cli/parser.js +7 -0
  89. package/dist/cli/parser.js.map +1 -1
  90. package/dist/cli/tui/data/workflow-content.js +5 -0
  91. package/dist/cli/tui/data/workflow-content.js.map +1 -1
  92. package/dist/cli/tui/tabs/workflow-tab.js +5 -1
  93. package/dist/cli/tui/tabs/workflow-tab.js.map +1 -1
  94. package/dist/domain/capability/descriptor.js +553 -0
  95. package/dist/domain/capability/descriptor.js.map +1 -0
  96. package/dist/domain/capability/effects.js +90 -0
  97. package/dist/domain/capability/effects.js.map +1 -0
  98. package/dist/domain/capability/protocol.js +494 -0
  99. package/dist/domain/capability/protocol.js.map +1 -0
  100. package/dist/domain/contract-reader.js +84 -0
  101. package/dist/domain/contract-reader.js.map +1 -0
  102. package/dist/domain/design/adapter.js +161 -0
  103. package/dist/domain/design/adapter.js.map +1 -0
  104. package/dist/domain/design/artifact-body.js +223 -0
  105. package/dist/domain/design/artifact-body.js.map +1 -0
  106. package/dist/domain/design/artifact.js +750 -0
  107. package/dist/domain/design/artifact.js.map +1 -0
  108. package/dist/domain/design/baseline.js +359 -0
  109. package/dist/domain/design/baseline.js.map +1 -0
  110. package/dist/domain/design/capability.js +310 -0
  111. package/dist/domain/design/capability.js.map +1 -0
  112. package/dist/domain/design/closure.js +161 -0
  113. package/dist/domain/design/closure.js.map +1 -0
  114. package/dist/domain/design/direct.js +108 -0
  115. package/dist/domain/design/direct.js.map +1 -0
  116. package/dist/domain/design/external-send.js +65 -0
  117. package/dist/domain/design/external-send.js.map +1 -0
  118. package/dist/domain/design/governance.js +298 -0
  119. package/dist/domain/design/governance.js.map +1 -0
  120. package/dist/domain/design/identity.js +145 -0
  121. package/dist/domain/design/identity.js.map +1 -0
  122. package/dist/domain/design/manifest.js +552 -0
  123. package/dist/domain/design/manifest.js.map +1 -0
  124. package/dist/domain/design/maturity.js +305 -0
  125. package/dist/domain/design/maturity.js.map +1 -0
  126. package/dist/domain/design/naming.js +117 -0
  127. package/dist/domain/design/naming.js.map +1 -0
  128. package/dist/domain/design/offline.js +92 -0
  129. package/dist/domain/design/offline.js.map +1 -0
  130. package/dist/domain/design/profiles.js +212 -0
  131. package/dist/domain/design/profiles.js.map +1 -0
  132. package/dist/domain/design/projections.js +165 -0
  133. package/dist/domain/design/projections.js.map +1 -0
  134. package/dist/domain/design/proposal.js +234 -0
  135. package/dist/domain/design/proposal.js.map +1 -0
  136. package/dist/domain/design/reference.js +234 -0
  137. package/dist/domain/design/reference.js.map +1 -0
  138. package/dist/domain/design/render-bundle.js +0 -0
  139. package/dist/domain/design/render-bundle.js.map +1 -0
  140. package/dist/domain/design/rendition.js +472 -0
  141. package/dist/domain/design/rendition.js.map +1 -0
  142. package/dist/domain/design/retired.js +61 -0
  143. package/dist/domain/design/retired.js.map +1 -0
  144. package/dist/domain/design/revision.js +219 -0
  145. package/dist/domain/design/revision.js.map +1 -0
  146. package/dist/domain/design/secrets.js +86 -0
  147. package/dist/domain/design/secrets.js.map +1 -0
  148. package/dist/domain/design/sources.js +180 -0
  149. package/dist/domain/design/sources.js.map +1 -0
  150. package/dist/domain/design/validation.js +19 -0
  151. package/dist/domain/design/validation.js.map +1 -0
  152. package/dist/domain/design/visual-evidence.js +155 -0
  153. package/dist/domain/design/visual-evidence.js.map +1 -0
  154. package/dist/domain/design/yaml-subset.js +390 -0
  155. package/dist/domain/design/yaml-subset.js.map +1 -0
  156. package/dist/domain/flow/answer.js +459 -0
  157. package/dist/domain/flow/answer.js.map +1 -0
  158. package/dist/domain/flow/authority.js +2276 -0
  159. package/dist/domain/flow/authority.js.map +1 -0
  160. package/dist/domain/flow/authorization.js +62 -0
  161. package/dist/domain/flow/authorization.js.map +1 -0
  162. package/dist/domain/flow/directive.js +421 -0
  163. package/dist/domain/flow/directive.js.map +1 -0
  164. package/dist/domain/flow/rules.js +140 -0
  165. package/dist/domain/flow/rules.js.map +1 -0
  166. package/dist/domain/flow/run-state.js +317 -0
  167. package/dist/domain/flow/run-state.js.map +1 -0
  168. package/dist/domain/harnesses.js +21 -0
  169. package/dist/domain/harnesses.js.map +1 -1
  170. package/dist/domain/safe-path.js +23 -0
  171. package/dist/domain/safe-path.js.map +1 -0
  172. package/dist/domain/skills.js +26 -3
  173. package/dist/domain/skills.js.map +1 -1
  174. package/package.json +1 -1
  175. package/skills/w/SKILL.md +15 -13
  176. package/skills/w/artifacts/README.md +3 -4
  177. package/skills/w/artifacts/artifacts-core/CHECKPOINT.md +2 -2
  178. package/skills/w/commands/plan-exec.md +11 -5
  179. package/skills/w/commands/plan-new.md +6 -2
  180. package/skills/w/commands/plan-refine.md +6 -3
  181. package/skills/w/commands/quick.md +2 -2
  182. package/skills/w/commands/spec-new.md +2 -2
  183. package/skills/w/commands/spec-refine.md +1 -0
  184. package/skills/w/context/MANIFEST.json +57 -9
  185. package/skills/w/harness/HARNESS.md +20 -0
  186. package/skills/w/loops/CHASSIS.md +11 -20
  187. package/skills/w/loops/CODE-POLICIES.md +18 -9
  188. package/skills/w/loops/README.md +1 -1
  189. package/skills/w/loops/plan-exec-loop/LOOP.md +126 -62
  190. package/skills/w/loops/plan-new-loop/LOOP.md +71 -73
  191. package/skills/w/loops/plan-refine-loop/LOOP.md +20 -10
  192. package/skills/w/loops/quick-loop/LOOP.md +18 -26
  193. package/skills/w/loops/spec-refine-loop/LOOP.md +28 -30
  194. package/skills/w/modules/COMPACTION.md +2 -6
  195. package/skills/w/modules/DB-SCRIPTS-ONLY.md +2 -0
  196. package/skills/w/modules/DESIGN-REFERENCES.md +113 -0
  197. package/skills/w/modules/IDEATION-GATE.md +3 -3
  198. package/skills/w/modules/PERSIST-ROUTING.md +1 -0
  199. package/skills/w/modules/PLAN-EXECUTION-BATCHES.md +65 -0
  200. package/skills/w/modules/PLAN-INPUT.md +5 -3
  201. package/skills/w/modules/PLAN-REFINE-SPLIT.md +3 -1
  202. package/skills/w/modules/PLAN-SPLIT-GATE.md +7 -5
  203. package/skills/w/modules/PROMPT-CONTINUITY.md +3 -1
  204. package/skills/w/modules/SPEC-CHANGE-SHAPE.md +4 -4
  205. package/skills/w/roles/README.md +9 -5
  206. package/skills/w/roles/design/CONTRACT.md +80 -0
  207. package/skills/w/roles/design/ROLE.md +224 -0
  208. package/skills/w/schemas/capability-descriptor.schema.json +260 -0
  209. package/skills/w/schemas/design/design-baseline.v1.schema.json +71 -0
  210. package/skills/w/schemas/design/design-manifest.v1.schema.json +322 -0
  211. package/skills/w/schemas/design/design-render-bundle.v1.schema.json +191 -0
  212. package/skills/w/schemas/design/design-rendition.v1.schema.json +232 -0
  213. package/skills/w/schemas/design/design-review.v1.schema.json +72 -0
  214. package/skills/w/schemas/design/design-revocation.v1.schema.json +54 -0
  215. package/skills/w/schemas/design/ui-flow.v1.schema.json +211 -0
  216. package/skills/w/schemas/design/ui-screen.v1.schema.json +242 -0
  217. package/skills/w/artifacts/artifacts-design/SPEC.md +0 -42
  218. package/skills/w/modules/PLAN-DESIGN-SPECS.md +0 -12
  219. package/skills/w/modules/PLAN-REFINE-DESIGN-SPECS.md +0 -7
  220. package/skills/w/roles/ui-spec/ROLE.md +0 -147
@@ -1,17 +1,27 @@
1
1
  # CODE-POLICIES — policies for code-editing loops
2
2
 
3
- They apply to **`plan-exec-loop`** (per plan phase) and **`quick-loop`** (the single task; **proportional** gate): each orders this doc read from its `## Inherits`, **together with the chassis** ([`CHASSIS.md`](CHASSIS.md)). The document loops (spec-refine, plan-new, plan-refine) edit no code and do **not** load this doc — that is why it lives apart from the chassis. These policies materialize the **DB scripts-only** and **safe git** invariants — which also stay summarized **inline** (1-2 lines) in each code-editing loop's `LOOP.md`, because advisory hosts do not follow Reads; the full normative text lives here.
3
+ They apply to **`plan-exec-loop`** (per effective batch) and **`quick-loop`** (the single task;
4
+ **proportional** gate): each reads this doc with the chassis. Document loops do not edit code and
5
+ do not load it. These policies own the DB scripts-only, safe Git and closing-review invariants;
6
+ code loops keep only a short inline floor for advisory hosts.
4
7
 
5
8
  ## Safe git — verified branch + proposed commits
6
9
 
7
- - **Before editing** a source's files: verify current branch = that source's expected branch (`aw check-branch --source <alias>`; see the `git` role). On mismatch → **pause and resolve with the human**; never `stash`/`reset --hard`/`checkout -- .`/`clean` without per-source confirmation.
8
- - **Proposed commits** (propose-then-execute, approve before): **after the closing review gate passes** (below), propose commits **per source**in plan-exec at each phase close (or on `Cerrar`); in quick, **a single commit** at the end if there were code changes. Never `push`/`--amend`/`--no-verify`. Nothing reaches a proposed commit without review.
9
- - **Rejected commit**: the changes **stay in the working tree** (never reverted). Re-proposing / editing the message is allowed. Record in `CHECKPOINT` + `BACKLOG` that the phase/task remained **uncommitted** (resumable).
10
- - **Between-phase precondition** (plan-exec): `branch-check` validates branch *identity*, **not** working-tree *cleanliness*. Before starting the next phase, each source's working tree must be **clean** (committed) or explicitly **acknowledged** as "uncommitted changes from phase N" — so two phases never co-mingle in one commit.
10
+ Sources are edited on a **verified** branch (`aw check-branch`), and the unit's commits are
11
+ **proposed**: exactly one commit per affected source — at effective-batch close in plan-exec, at task
12
+ close in quick never `push`/`--amend`/`--no-verify`, and never a destructive clean or a branch
13
+ switch without confirmation. A **rejected** commit leaves the changes in the tree and the unit
14
+ recorded as uncommitted in `CHECKPOINT` and `BACKLOG`. Between units each working tree is clean or
15
+ explicitly acknowledged; a `continuous` batch is the narrow exception that intentionally co-mingles
16
+ its internal phases in one reviewed commit, and no batch may co-mingle with another.
17
+
18
+ > **When the branch is verified, when a commit becomes available and what an approval covers is not this document's call:** the deterministic steps below are decided by the CLI (`aw flow advance`), not by this document. Approving is the person's act and committing is a separate effect that comes back as the sources' real git state — which is also what makes "the checks passed" impossible to assert without having run them.
11
19
 
12
20
  ## Closing review gate (conventions, pre-commit)
13
21
 
14
- After validation (of the phase in plan-exec; of the task in quick, proportional) and **before proposing its commits** (also on an early `Cerrar`, before proposing the pending commits), the diff passes a **closing review gate**:
22
+ After validation and before commits, the whole execution-unit diff passes a **closing review
23
+ gate**: an effective batch in plan-exec, or the proportional task in quick. Early `Cerrar` uses the
24
+ same gate before any pending commit.
15
25
 
16
26
  - **Independent re-read** of the diff (subagent or clean re-read — the engine's *independent verification*: it does not assume the implementation is correct; *only command output counts*).
17
27
  - **Apply the installed ambient conventions** relevant to the touched stack (code/stack standards, security, diff review, the workspace's own families) — the host **auto-discovers them by `description`**. Workline **names and binds no** concrete conventions skill: **it creates the moment; the installed skills fill it** (that is why review is **not a role** — see [`../roles/README.md`](../roles/README.md)). With no convention skills installed → minimal generic checklist: SOLID/early-return, clear names, DRY, no silenced errors, no secrets/PII, parametrized SQL, no dead code, + the plan's `Validations` (if any).
@@ -20,9 +30,8 @@ After validation (of the phase in plan-exec; of the task in quick, proportional)
20
30
  - **Temporary simulation check** (only when the change carries one): stubs, fakes and in-memory adapters are **explicit and named as such** (`Stub…` / `Fake…`), they sit at the boundary the plan declares, and no configuration can select them in a production runtime. A simulation still active on the main path with no declared removal is a finding, not a detail.
21
31
  - **Tooling check** (`docs/tools`): did the run create **reusable auxiliary tooling** (support scripts/CLIs/generators/reusable configs — not product code, not session probes)? → the host applies the **ambient `creating-tools` skill** (auto-discovered by its `description`; Workline does not bind it) so the tool gets its home under `docs/tools/<slug>/` (README + run/output structure per that skill's contract + its index row). Host without such a skill → the loop still **never writes `docs/tools` itself**: **declare the gap** — the homeless tool goes to the plan's `Open questions` + `BACKLOG` (in quick, `BACKLOG`) — never silent.
22
32
  - **Findings**: **fix** them in the working tree and **re-run validation** (the gate does not replace the tests: it re-verifies after fixing), or **defer them justified** (→ the plan's `Open questions` + `BACKLOG`; in quick, `BACKLOG`); the non-obvious → `DECISION`. Gate integrity (see [`CHASSIS.md`](CHASSIS.md) § *Verification-first*): never weaken a check or lower a convention to pass.
23
- - **Artifact-first + verification-first**: `CHECKPOINT.Next = "review <phase/task>"` before the pass; `SESSION.Success criteria` includes from the start "the diff passed the review gate before its commits".
24
-
25
- Only with the gate green are the commits proposed.
33
+ - **Artifact-first + verification-first**: seed `CHECKPOINT.Next = "review <batch/task>"`; Success
34
+ criteria require the whole diff to pass before commits.
26
35
 
27
36
  ## Location
28
37
 
@@ -47,7 +47,7 @@ The **5 loops** are heirs: they use `## Inherits` (a one-line reference to [`CHA
47
47
 
48
48
  ## Chassis / heirs
49
49
 
50
- The **engine lives in [`CHASSIS.md`](CHASSIS.md)** (a referenced doc, not a skill); the 5 loops — including `spec-refine-loop` — are **heirs** of that engine. The canonical heirs list and their deltas live in the chassis itself (§ *Heirs*). The chassis is **not a bindable capability**: it is the loop engine; what is pluggable are the **capabilities** a loop composes (e.g. `ui-design`, `sql`, `git`), resolved via `.workflow/skills.toml`.
50
+ The **engine lives in [`CHASSIS.md`](CHASSIS.md)** (a referenced doc, not a skill); the 5 loops — including `spec-refine-loop` — are **heirs** of that engine. The canonical heirs list and their deltas live in the chassis itself (§ *Heirs*). The chassis is **not a bindable capability**: it is the loop engine; what is pluggable are the **capabilities** a loop composes (e.g. `design`, `sql`, `git`), resolved via `.workflow/skills.toml`.
51
51
 
52
52
  ## Composed capabilities (roles)
53
53
 
@@ -2,12 +2,10 @@
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: 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
- pre-commit closing review gate, no auto-export. Composes git and sql.
5
+ doc: re-infers isolated or continuous phase batches, edits real code, then
6
+ validates/reviews/commits each effective batch. Heir of CHASSIS.md and
7
+ CODE-POLICIES.md. Keeps the executability and deviation gates, one resumable
8
+ session, safe git, DB scripts-only and no auto-export. Composes git and sql.
11
9
  Started by /w:plan-exec. Invoke to implement an already generated plan.
12
10
  ---
13
11
 
@@ -25,7 +23,7 @@ PLAN
25
23
  `/w:plan-exec` — **resumable** (same chassis mechanism; here resume keys off the plan-doc phase states + checkboxes + CHECKPOINT, see Delta 1).
26
24
 
27
25
  ## 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) **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)).
26
+ `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 pins design, it also reads the **UI Design Package** revisions its `## Design references` and its tasks name **read-only**, at the exact revision each one fixed (§ *Design precondition gate*).
29
27
 
30
28
  ## Writes
31
29
  - `docs/plans/PPP-plan-<slug>.md` (**read/update**, living doc: phase/task state, `Open questions`).
@@ -40,6 +38,10 @@ Full rule in the chassis (§ *docs/ boundary — no auto-export*). Here: the onl
40
38
 
41
39
  Read **[`../CHASSIS.md`](../CHASSIS.md)** — the loop's **full engine** — **and** **[`../CODE-POLICIES.md`](../CODE-POLICIES.md)** — the *code-editing loop policies* — **always before** these deltas. *(If `../` does not resolve: same names next to this file — global layout rule, chassis § Reference resolution.)*
42
40
 
41
+ Read the shared execution-unit contract in
42
+ [`PLAN-EXECUTION-BATCHES`](../../modules/PLAN-EXECUTION-BATCHES.md); it owns batch syntax,
43
+ inference, the deferred-validation cycle and conditional Git authorization.
44
+
43
45
  ## Composes
44
46
 
45
47
  `git` (safe branch + proposed commits) · `sql` (DB rule). Both resolved via `.workflow/skills.toml`; `off` → the loop continues without the capability and, if it was needed, says so or asks.
@@ -65,27 +67,72 @@ Read **[`../CHASSIS.md`](../CHASSIS.md)** — the loop's **full engine** — **a
65
67
 
66
68
  Execution **no longer accepts in silence** a plan that would force it to invent its own structure. Two outcomes:
67
69
 
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`.
70
+ - **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. Normalizing edits the `### Fn` blocks in place, **adds no scope and moves no boundary**, and is recorded in `DECISION` + `CHECKPOINT`.
69
71
  - **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
72
 
73
+ > **Which outcome a declared gap produces, and whether anybody is asked to consent, is not this document's call:** the deterministic steps below are decided by the CLI (`aw flow advance`), not by this document. Normalization is offered on a minor gap and on nothing else — a structural one is not something to consent to.
74
+
71
75
  > **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
76
 
73
77
  > 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
78
 
75
- ## Delta 1 One session per run; the phase cycle in the plan-doc
76
-
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.)*
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
+ After this gate and before editing, infer the effective batches over pending phases. The live
80
+ checkout may merge or split the plan's declaration without consent; record the result and drift in
81
+ `CHECKPOINT`. A missing `## Execution batches` is legacy compatibility, not an entry gap.
82
+
83
+ ## Design precondition gate (fail-closed, per task)
84
+
85
+ Applies **only** to a task that pins design (`DES-001@r4 / SCR-002@r2#empty`). Run
86
+ `aw designs --plan <plan-doc>` before implementing the batch; it answers per task
87
+ and the verdict is the command's, not the implementer's.
88
+
89
+ **Four causes block, and each names the artifact and the corrective action:** the
90
+ reference does not resolve · its digest no longer matches the bytes · the revision
91
+ is **revoked** · the applicable **closure** does not reach `handoff`. A blocked
92
+ task is not implemented, its phase stays `en ejecución` or `bloqueada`, and the
93
+ correction goes to `/w:plan-refine` — or to `/w:spec-refine` when it changes
94
+ behavior or acceptance.
95
+
96
+ **One cause only warns:** a revision **superseded** by a newer one but intact
97
+ stays executable. Publishing `@r5` never invalidates the `@r4` a task pinned on
98
+ purpose; only an explicit, audited revocation does. A **stale path hint** warns
99
+ the same way — identity resolved, the recorded path moved.
100
+
101
+ > **`plan-exec` never redesigns.** Completing an `outline` artifact, inventing a
102
+ > missing state or promoting a revision to `handoff` are design decisions and
103
+ > belong to the refine that owns them. Full contract in
104
+ > [`DESIGN-REFERENCES.md`](../../modules/DESIGN-REFERENCES.md) (signal `ui`).
105
+
106
+ **Publishing a document together with a package revision is one transition.** A
107
+ spec or plan whose reference moves is written in the **same** all-or-nothing batch
108
+ as the revision it points at, so no reader ever sees a document citing a baseline
109
+ that is not there, or a revision no document reached. An effect the batch cannot
110
+ cover — anything outside the workspace files — is recorded as **pending
111
+ reconciliation** in `CHECKPOINT`, never reported as published.
112
+
113
+ ## Delta 1 — One session per run; execution-unit cycle in the plan-doc
114
+
115
+ - Walk the plan's `### Fn` blocks under `## Tasks` in dependency order inside one session. Infer
116
+ effective `continuous`/`isolated` batches first; legacy `## Phases` tables degrade the same way.
117
+ - **Execution-unit cycle:** seed one batch intent; implement all its phases in order; validate and
118
+ review at unit close; then update states/`CHECKPOINT` and enter Git. An isolated unit contains
119
+ one phase. A continuous unit follows `PLAN-EXECUTION-BATCHES`: no proof, runner, build, lint,
120
+ review or commit between its phases.
79
121
  - 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.
122
+ - **Marking order (hard rule):** a phase reaches `validada` only with its proof run and passed, its
123
+ exit condition true and the combined review green; a blocker is never deferred into `validada`.
124
+ **Never** because all its checkboxes are ticked.
81
125
  - **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
126
  - **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
127
  - **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.
128
+ - **CHECKPOINT per execution unit:** record its effective grouping, functional states, simulation
129
+ boundary when applicable, checks/results, decisions, deferrals and next intent. The task boxes
130
+ and `en ejecución` marks preserve an intra-batch resume.
85
131
  - 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*).
86
132
  - 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.
87
133
 
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.
134
+ > **Legacy plans degrade safely:** a missing line reads `pendiente`; missing execution batches are
135
+ > inferred into `CHECKPOINT`; neither is back-filled. Checked boxes alone prove nothing.
89
136
 
90
137
  ## Deviation gate
91
138
 
@@ -108,7 +155,9 @@ On either return path: `CHECKPOINT` records the state reached and the trigger, t
108
155
 
109
156
  ## Delta 2 — Git policy: **safe branch + proposed commits**
110
157
 
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`.
158
+ Full policy in [`../CODE-POLICIES.md`](../CODE-POLICIES.md), and its gating is the CLI's: this loop
159
+ adds nothing of its own beyond running on a verified branch and never
160
+ `push`/`--amend`/`--no-verify`.
112
161
 
113
162
  ## Delta 4 — Validation: phase proof + progressive tests
114
163
 
@@ -117,7 +166,12 @@ Full policy in [`../CODE-POLICIES.md`](../CODE-POLICIES.md) (§ *Safe git*: bran
117
166
  2. **focused tests** — added when the layer carries its own rules, a relevant transformation, error handling, persistence, transactions, temporal logic or external integration;
118
167
  3. **risk tests** — security, concurrency, idempotency, retries, known regressions.
119
168
  - **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.
120
- - 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`.
169
+ - `isolated` remains compatible with literal TDD. A continuous batch may author evidence before
170
+ code, but first runs it at batch close. No phase becomes `validada` before its exit is demonstrated.
171
+ - **Continuous means all checks at batch close.** Do not run its phase proofs, focused/risk tests,
172
+ build, typecheck, lint or review while implementing internal phases. At close run proofs in phase
173
+ order, then the justified checks and cross-cutting validations. `isolated` runs the same stack for
174
+ its single phase.
121
175
  - 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.
122
176
  - 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).
123
177
  - A validation that **runs and fails** → back into the phase (gap): no advancing, no `validada`.
@@ -127,13 +181,19 @@ Full policy in [`../CODE-POLICIES.md`](../CODE-POLICIES.md) (§ *Safe git*: bran
127
181
 
128
182
  ## Delta 5 — Closing review gate (conventions, pre-commit)
129
183
 
130
- 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.
184
+ Full gate in [`../CODE-POLICIES.md`](../CODE-POLICIES.md): independent re-read, ambient
185
+ conventions and the floor lenses. It covers the execution unit's **whole** diff after every phase
186
+ proof/check and before states or Git advance. Findings are fixed and the affected checks rerun, or
187
+ deferred with justification when they are not blockers.
131
188
 
132
189
  ## Delta 6 — Completion / close
133
190
 
134
- - 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`.
191
+ - A phase closes when its `> Estado:` reads `validada`: work done, exit condition true and proof
192
+ passed. In a continuous batch every phase waits for the batch review; an operative handoff leaves
193
+ the affected phase `bloqueada` and the unit uncommitted.
135
194
  - **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*).
136
- - **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.
195
+ - **Every phase `validada` + final validation passed** unlocks completion, and on the last batch the
196
+ same Git approval covers this mark, so the status write lands in the same source commit.
137
197
  - **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`).
138
198
  - **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.
139
199
  - **No automatic export**: the artifacts (`SCRIPTS.sql`, `DECISION`, …) stay in the session. Promoting them to `docs/` (scripts, manuals, …) is a separate step via `export-*`.
@@ -147,54 +207,58 @@ plan-exec-loop(PPP-plan-<slug>.md):
147
207
  entry gate (executability): result · exit condition · phase proof · simulation boundary if any · no structural contradiction
148
208
  minor gap → structured-choice [Normalizar y ejecutar | Ir a plan-refine] → normalize in place + DECISION
149
209
  structural gap → CHECKPOINT(blocker) → hand off to /w:plan-refine → stop
150
- for each Phase (### Fn block in ## Tasks; legacy: ## Phases table) in plan (in order, respecting deps):
151
- if Estado == validada: skip # legacy (no line): all its Tasks - [x] AND the session shows it closed
152
- read Resultado + Condición de salida; confirm the initial state
153
- set > Estado: en ejecución
154
- seed CHECKPOINT.Next = Phase N (Pending = its Tasks) # BEFORE starting the phase: seed the intent (artifact-first)
155
- for each Task of the Phase:
156
- if Task - [x] in the plan: skip # intra-phase resume by checkbox
157
- verify each source's expected branch (branch-check)
158
- on mismatch pause + resolve with the human
159
- execute Task (micro steps internal — never plan entries):
160
- edit code in the sources (minimal change)
161
- if it creates a tool/utility → the ambient creating-tools skill documents it in docs/tools
162
- if read-only DB query SCRIPTS.sql + execute read-only
163
- if DB change (DDL/DML) draft in SCRIPTS.sql (session artifact, DO NOT execute)
164
- deviation gate:
165
- local decision → resolve; DECISION only if non-obvious (tagged by phase/task)
166
- structural deviation CHECKPOINT(state + trigger) stop → /w:plan-refine
167
- functional change → CHECKPOINT(state + trigger) stop /w:spec-refine
168
- if probe (PoC) task / runnable doubt → seed check → run throwaway code in the
169
- session folder verdict CONCLUSIONS/DECISION; failed structured-choice (Delta 7)
170
- if doubt/gap inline research, probe OR structured-choice # chassis
171
- mark Task - [x] IN THE PLAN # AFTER its local work; checkbox flip ONLY — results go to DECISION/CHECKPOINT
172
- phase proof (Validación de fase) + the justified focused tests: # Delta 4 levels 1→3
173
- what runs and fails → back into the phase (no validada)
174
- what cannot run (unapplied migration) defer the CHECK, never the validation: the phase stays bloqueada
175
- closing review gate (pre-commit): # Delta 5: CHECKPOINT.Next = "review phase N"
176
- INDEPENDENT re-read of the WHOLE phase diff + installed ambient conventions
177
- + floor lenses: minimality · test value (overtest) · temporary simulation · tooling
178
- findings fix (and re-validate the phase) OR defer justified (Open questions + BACKLOG)
179
- confirm the Condición de salida set > Estado: validada # ONLY with the proof run and passed; NEVER from the checkboxes alone
180
- blocker still live set > Estado: bloqueada + > Bloqueo: <reason> + CHECKPOINT + Open questions
181
- check not runnable (SQL) set > Estado: bloqueada + > Bloqueo: <reason> + CHECKPOINT + Open questions + BACKLOG
182
- update CHECKPOINT (functional state reached · simulation boundary if any · tests + result · decisions · deferrals · next state)
183
- propose commit(s) per source (approve first) # never push/amend/--no-verify; only after the gate is green
184
- if rejected changes stay; record "phase uncommitted"
185
- next-phase precondition: working tree clean or acknowledged
186
- final validation (whatever can run; a deferred check keeps its phase bloqueada)
187
- if every phase validada AND the final validation passed:
188
- structured_choice(content: [Marcar plan done, Preguntar algo más], flow: [Compactar, Cerrar])
189
- mark plan done → > Estado: done + > Cierre: YYYY-MM-DD · sesión NNN under the title (Delta 6), in place
190
- else: the plan-level > Estado: stays open → CHECKPOINT.Next = the action that unblocks the phase(s)
210
+ batches = infer_effective_batches(pending phases, plan + live checkout)
211
+ may merge/split declared rows without asking; legacy absence is allowed
212
+ record batches + declaration drift in CHECKPOINT
213
+ commit_authorization = explicit conditional pre-authorization from the user, if any
214
+ record it before editing; otherwise approval is deferred to each green batch close
215
+ for each Batch in batches:
216
+ verify every affected source's branch; mismatch stop + human
217
+ seed CHECKPOINT.Next = Batch Bn (mode + phases + tasks)
218
+ for each Phase in Batch:
219
+ if Estado == validada: skip
220
+ read Resultado + Condición de salida; set > Estado: en ejecución
221
+ for each pending Task:
222
+ execute minimal work; keep DB/tool policies; apply deviation gate
223
+ local decisionresolve; DECISION only if non-obvious
224
+ structural/functional deviation → CHECKPOINT + stop → refine destination
225
+ probe whose verdict shapes later work batch was ineligible; stop/re-infer
226
+ mark Task - [x] after its local work
227
+ # continuous: advance directly to the next phase; run NO validation/review/commit here
228
+ at Batch close, in phase order:
229
+ run every Validación de fase, then justified focused/risk checks
230
+ run applicable plan Validations; last Batch also runs final validation before Git
231
+ failures fix + rerun affected checks
232
+ unrun operative check phase bloqueada + > Bloqueo: + CHECKPOINT + Open questions
233
+ closing review gate over the WHOLE BATCH diff
234
+ findingsfix + rerun affected checks OR defer justified if non-blocking
235
+ if any proof/check/review/exit condition is not green:
236
+ preserve actual states + combined uncommitted diff; record unblocking action; stop
237
+ set every Batch phase > Estado: validada; update CHECKPOINT
238
+ prepare exactly one commit per affected source
239
+ if last Batch + final validation green:
240
+ pre-authorizedmark plan done, then commit once per affected source without asking
241
+ otherwise structured_choice(content: [Marcar plan done, Preguntar algo más], flow: [Compactar, Cerrar])
242
+ Marcar plan done approve; mark done; commit all source changes once
243
+ else if pre-authorized commit without another question
244
+ elseone consolidated approval for all source commits
245
+ rejected changes stay; record "batch uncommitted"
246
+ next-batch precondition: working trees clean or acknowledged
247
+ if no Batch ran and phases are already validada:
248
+ run final validation now
249
+ if green:
250
+ use the same pre-authorized/final structured-choice completion branch
251
+ when authorized → mark plan done with > Estado: done + > Cierre: YYYY-MM-DD · sesión NNN under the title (Delta 6), then commit that source once
252
+ if plan is not done:
253
+ the plan-level > Estado: stays open → CHECKPOINT.Next = the action that unblocks the phase(s)
191
254
  # NO export: artifacts stay in the session; a separate export-* promotes them
192
255
  finalize: CHECKPOINT (+ BACKLOG if something is deferred) + close session + report
193
256
  ```
194
257
 
195
258
  ## Convergence / exit
196
259
 
197
- - **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.
260
+ - **Every phase `validada`** + final validation passed + every effective batch reviewed before its
261
+ commits → `Marcar plan done`. Any pending/running/blocked phase keeps the plan open.
198
262
  - 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.
199
263
  - `Cerrar` (`flow` control, at any time) → `finalize` persists `CHECKPOINT` (and `BACKLOG` only if something remained unexecuted / uncommitted / unapplied), closes the session, reports.
200
264
  - Promoting artifacts to `docs/` (via `export-*`) is **always** a later, explicit step outside this loop.