@tacuchi/agent-workflow-cli 21.17.0 → 22.0.1

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 (208) hide show
  1. package/README.md +4 -16
  2. package/dist/adapters/git-cli.js +66 -5
  3. package/dist/adapters/git-cli.js.map +1 -1
  4. package/dist/adapters/node-process.js +25 -5
  5. package/dist/adapters/node-process.js.map +1 -1
  6. package/dist/application/capability/design-handler.js +67 -21
  7. package/dist/application/capability/design-handler.js.map +1 -1
  8. package/dist/application/capability/dispatcher.js +1 -1
  9. package/dist/application/capability/dispatcher.js.map +1 -1
  10. package/dist/application/capability/durable-effect.js +1 -1
  11. package/dist/application/capability/durable-effect.js.map +1 -1
  12. package/dist/application/check-branch-service.js +1 -0
  13. package/dist/application/check-branch-service.js.map +1 -1
  14. package/dist/application/checkpoint-service.js +4 -3
  15. package/dist/application/checkpoint-service.js.map +1 -1
  16. package/dist/application/design/consumer-document.js +179 -0
  17. package/dist/application/design/consumer-document.js.map +1 -0
  18. package/dist/application/design/design-gate-service.js +18 -1
  19. package/dist/application/design/design-gate-service.js.map +1 -1
  20. package/dist/application/design/design-index-service.js +22 -3
  21. package/dist/application/design/design-index-service.js.map +1 -1
  22. package/dist/application/design/design-publish-service.js +27 -6
  23. package/dist/application/design/design-publish-service.js.map +1 -1
  24. package/dist/application/design/design-simple-service.js +34 -22
  25. package/dist/application/design/design-simple-service.js.map +1 -1
  26. package/dist/application/dev-only-services.js +19 -12
  27. package/dist/application/dev-only-services.js.map +1 -1
  28. package/dist/application/docs-canon-service.js +79 -5
  29. package/dist/application/docs-canon-service.js.map +1 -1
  30. package/dist/application/dsn-reader-service.js +12 -47
  31. package/dist/application/dsn-reader-service.js.map +1 -1
  32. package/dist/application/export-service.js +20 -11
  33. package/dist/application/export-service.js.map +1 -1
  34. package/dist/application/flow/flow-service.js +25 -0
  35. package/dist/application/flow/flow-service.js.map +1 -1
  36. package/dist/application/flow/internal-actions.js +5 -0
  37. package/dist/application/flow/internal-actions.js.map +1 -1
  38. package/dist/application/flow/submit.js +156 -22
  39. package/dist/application/flow/submit.js.map +1 -1
  40. package/dist/application/history-table.js +82 -44
  41. package/dist/application/history-table.js.map +1 -1
  42. package/dist/application/history-update-service.js +19 -9
  43. package/dist/application/history-update-service.js.map +1 -1
  44. package/dist/application/hook-git-commit-advisor.js +5 -4
  45. package/dist/application/hook-git-commit-advisor.js.map +1 -1
  46. package/dist/application/hook-sql-mutation-guard.js +1 -1
  47. package/dist/application/hook-sql-mutation-guard.js.map +1 -1
  48. package/dist/application/lifecycle-target.js +1 -0
  49. package/dist/application/lifecycle-target.js.map +1 -1
  50. package/dist/application/local-proposal.js +47 -23
  51. package/dist/application/local-proposal.js.map +1 -1
  52. package/dist/application/mcp-connections-service.js +37 -2
  53. package/dist/application/mcp-connections-service.js.map +1 -1
  54. package/dist/application/mcp-dbhub-launcher.js +22 -50
  55. package/dist/application/mcp-dbhub-launcher.js.map +1 -1
  56. package/dist/application/mcp-doctor-service.js +14 -23
  57. package/dist/application/mcp-doctor-service.js.map +1 -1
  58. package/dist/application/mcp-remove-service.js +3 -3
  59. package/dist/application/mcp-remove-service.js.map +1 -1
  60. package/dist/application/mcp-setup-service.js +4 -4
  61. package/dist/application/mcp-setup-service.js.map +1 -1
  62. package/dist/application/mcp-test-connection-service.js +9 -9
  63. package/dist/application/mcp-test-connection-service.js.map +1 -1
  64. package/dist/application/parsers/phases.js +17 -5
  65. package/dist/application/parsers/phases.js.map +1 -1
  66. package/dist/application/parsers/project-block.js +5 -11
  67. package/dist/application/parsers/project-block.js.map +1 -1
  68. package/dist/application/parsers/sessions-csv.js +16 -14
  69. package/dist/application/parsers/sessions-csv.js.map +1 -1
  70. package/dist/application/parsers/spec-relation.js +15 -11
  71. package/dist/application/parsers/spec-relation.js.map +1 -1
  72. package/dist/application/parsers/tasks.js +25 -1
  73. package/dist/application/parsers/tasks.js.map +1 -1
  74. package/dist/application/persist-service.js +67 -29
  75. package/dist/application/persist-service.js.map +1 -1
  76. package/dist/application/plugin-doctor/skills.js +1 -40
  77. package/dist/application/plugin-doctor/skills.js.map +1 -1
  78. package/dist/application/plugin-doctor-service.js +1 -3
  79. package/dist/application/plugin-doctor-service.js.map +1 -1
  80. package/dist/application/release-data/artifacts.js +1 -0
  81. package/dist/application/release-data/artifacts.js.map +1 -1
  82. package/dist/application/release-data/bundles.js +15 -6
  83. package/dist/application/release-data/bundles.js.map +1 -1
  84. package/dist/application/release-data/common.js +16 -7
  85. package/dist/application/release-data/common.js.map +1 -1
  86. package/dist/application/release-data/sessions.js +36 -8
  87. package/dist/application/release-data/sessions.js.map +1 -1
  88. package/dist/application/render/project-block.js +2 -2
  89. package/dist/application/render/project-block.js.map +1 -1
  90. package/dist/application/resume-service.js +9 -1
  91. package/dist/application/resume-service.js.map +1 -1
  92. package/dist/application/retirement/graph.js +14 -13
  93. package/dist/application/retirement/graph.js.map +1 -1
  94. package/dist/application/retirement/prepare.js +15 -2
  95. package/dist/application/retirement/prepare.js.map +1 -1
  96. package/dist/application/retirement/resolve.js.map +1 -1
  97. package/dist/application/self/clean-legacy.js +2 -4
  98. package/dist/application/self/clean-legacy.js.map +1 -1
  99. package/dist/application/self/install-plugin-skills-git.js +8 -4
  100. package/dist/application/self/install-plugin-skills-git.js.map +1 -1
  101. package/dist/application/self/mcp-config.js +8 -9
  102. package/dist/application/self/mcp-config.js.map +1 -1
  103. package/dist/application/session-close-service.js +8 -2
  104. package/dist/application/session-close-service.js.map +1 -1
  105. package/dist/application/session-create-service.js +26 -14
  106. package/dist/application/session-create-service.js.map +1 -1
  107. package/dist/application/session-resolver.js +80 -34
  108. package/dist/application/session-resolver.js.map +1 -1
  109. package/dist/application/session-resume-service.js +4 -3
  110. package/dist/application/session-resume-service.js.map +1 -1
  111. package/dist/application/source-boundary-policy.js +504 -0
  112. package/dist/application/source-boundary-policy.js.map +1 -0
  113. package/dist/application/status-service.js +1 -0
  114. package/dist/application/status-service.js.map +1 -1
  115. package/dist/application/workline-index-service.js +42 -20
  116. package/dist/application/workline-index-service.js.map +1 -1
  117. package/dist/application/workspace-migrate/apply.js +2 -4
  118. package/dist/application/workspace-migrate/apply.js.map +1 -1
  119. package/dist/application/workspace-migrate/plan.js +9 -6
  120. package/dist/application/workspace-migrate/plan.js.map +1 -1
  121. package/dist/application/workspace-migrate/preview.js +3 -3
  122. package/dist/application/workspace-migrate/preview.js.map +1 -1
  123. package/dist/application/worktree-service.js +3 -0
  124. package/dist/application/worktree-service.js.map +1 -1
  125. package/dist/cli/commands/capability.js +89 -5
  126. package/dist/cli/commands/capability.js.map +1 -1
  127. package/dist/cli/commands/designs.js +2 -6
  128. package/dist/cli/commands/designs.js.map +1 -1
  129. package/dist/cli/commands/dev-only.js +1 -1
  130. package/dist/cli/commands/dev-only.js.map +1 -1
  131. package/dist/cli/commands/flow.js +3 -1
  132. package/dist/cli/commands/flow.js.map +1 -1
  133. package/dist/cli/commands/index.js +0 -2
  134. package/dist/cli/commands/index.js.map +1 -1
  135. package/dist/cli/commands/mcp.js +53 -55
  136. package/dist/cli/commands/mcp.js.map +1 -1
  137. package/dist/cli/commands/persist.js +27 -21
  138. package/dist/cli/commands/persist.js.map +1 -1
  139. package/dist/cli/commands/resume.js +2 -2
  140. package/dist/cli/commands/resume.js.map +1 -1
  141. package/dist/cli/commands/session-create.js +2 -1
  142. package/dist/cli/commands/session-create.js.map +1 -1
  143. package/dist/cli/help-groups.js +0 -1
  144. package/dist/cli/help-groups.js.map +1 -1
  145. package/dist/cli/main.js +0 -0
  146. package/dist/cli/main.js.map +1 -1
  147. package/dist/cli/parser.js +1 -0
  148. package/dist/cli/parser.js.map +1 -1
  149. package/dist/cli/tui/data/recommended-skills.js +2 -2
  150. package/dist/cli/tui/data/recommended-skills.js.map +1 -1
  151. package/dist/cli/tui/tabs/mcp-tab-helpers.js +1 -1
  152. package/dist/cli/tui/tabs/mcp-tab.js +2 -2
  153. package/dist/cli/tui/tabs/mcp-tab.js.map +1 -1
  154. package/dist/domain/capability/protocol.js.map +1 -1
  155. package/dist/domain/correlative.js +121 -0
  156. package/dist/domain/correlative.js.map +1 -0
  157. package/dist/domain/design/capability.js +18 -0
  158. package/dist/domain/design/capability.js.map +1 -1
  159. package/dist/domain/docs-canon.js +31 -0
  160. package/dist/domain/docs-canon.js.map +1 -0
  161. package/dist/domain/flow/answer.js +57 -1
  162. package/dist/domain/flow/answer.js.map +1 -1
  163. package/dist/domain/flow/authority.js +28 -29
  164. package/dist/domain/flow/authority.js.map +1 -1
  165. package/dist/domain/flow/execution-result.js +13 -1
  166. package/dist/domain/flow/execution-result.js.map +1 -1
  167. package/dist/domain/flow/run-state.js.map +1 -1
  168. package/dist/domain/mcp-entry.js +7 -12
  169. package/dist/domain/mcp-entry.js.map +1 -1
  170. package/dist/domain/retirement/selector.js +16 -14
  171. package/dist/domain/retirement/selector.js.map +1 -1
  172. package/dist/domain/source-boundary.js +3 -0
  173. package/dist/domain/source-boundary.js.map +1 -0
  174. package/dist/domain/workline-node.js +12 -5
  175. package/dist/domain/workline-node.js.map +1 -1
  176. package/dist/runtime/namespace-resolver.js +0 -3
  177. package/dist/runtime/namespace-resolver.js.map +1 -1
  178. package/package.json +5 -5
  179. package/skills/w/SKILL.md +2 -2
  180. package/skills/w/artifacts/artifacts-core/SCRIPTS.sql +14 -9
  181. package/skills/w/artifacts/artifacts-research/CONCLUSIONS.md +7 -0
  182. package/skills/w/commands/export-scripts.md +8 -2
  183. package/skills/w/commands/plan-new.md +1 -0
  184. package/skills/w/context/MANIFEST.json +2 -9
  185. package/skills/w/exports/export-scripts/EXPORT.md +13 -9
  186. package/skills/w/loops/CHASSIS.md +1 -1
  187. package/skills/w/loops/plan-exec-loop/LOOP.md +14 -10
  188. package/skills/w/loops/plan-new-loop/LOOP.md +16 -16
  189. package/skills/w/loops/plan-refine-loop/LOOP.md +6 -1
  190. package/skills/w/loops/quick-loop/LOOP.md +2 -2
  191. package/skills/w/loops/spec-refine-loop/LOOP.md +4 -0
  192. package/skills/w/modules/DB-RESEARCH-RULE.md +5 -5
  193. package/skills/w/modules/DB-SCRIPTS-ONLY.md +5 -6
  194. package/skills/w/modules/EXEC-DB-POLICY.md +2 -2
  195. package/skills/w/modules/PLAN-INPUT.md +11 -9
  196. package/skills/w/roles/sql/ROLE.md +9 -9
  197. package/dist/application/decisiones-service.js +0 -31
  198. package/dist/application/decisiones-service.js.map +0 -1
  199. package/dist/application/dev-bootstrap-dsn-service.js +0 -76
  200. package/dist/application/dev-bootstrap-dsn-service.js.map +0 -1
  201. package/dist/application/profile/profile-service.js +0 -199
  202. package/dist/application/profile/profile-service.js.map +0 -1
  203. package/dist/application/tasks-service.js +0 -45
  204. package/dist/application/tasks-service.js.map +0 -1
  205. package/dist/cli/commands/bootstrap-dsn.js +0 -16
  206. package/dist/cli/commands/bootstrap-dsn.js.map +0 -1
  207. package/dist/cli/tui/components/process-list.js +0 -43
  208. package/dist/cli/tui/components/process-list.js.map +0 -1
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tacuchi/agent-workflow-cli",
3
- "version": "21.17.0",
4
- "description": "Runtime CLI for Workline — the stages + loops + artifacts system for agent work. Bundles the universal `w` skill set under `skills/w/` (slash commands `/w:*`: spec-new/spec-refine, plan-new/plan-exec, quick, persist, workspace-init, export-*); `self install --target <host>` copies SKILL + commands + hooks into the host. Pluggable capability skills via `.workflow/skills.toml`. Multi-empresa parametrization via `profile.json` cascade. Namespace auto-detected from any `.<ns>/sessions/` dir in CWD; default `workflow`.",
3
+ "version": "22.0.1",
4
+ "description": "Runtime CLI for Workline — the stages + loops + artifacts system for agent work. Bundles the universal `w` skill set under `skills/w/` (slash commands `/w:*`: spec-new/spec-refine, plan-new/plan-exec, quick, persist, workspace-init, export-*); `self install --target <host>` copies SKILL + commands + hooks into the host. Pluggable capability skills resolve through `.workflow/skills.toml`. Namespace auto-detected from any `.<ns>/sessions/` dir in CWD; default `workflow`.",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "agent-workflow": "dist/cli/main.js",
@@ -9,8 +9,8 @@
9
9
  },
10
10
  "files": ["dist", "skills", "LICENSE", "README.md"],
11
11
  "scripts": {
12
- "build": "tsc",
13
- "build:watch": "tsc --watch",
12
+ "build": "node scripts/clean-dist.mjs && tsc",
13
+ "build:watch": "node scripts/clean-dist.mjs && tsc --watch",
14
14
  "test": "vitest run",
15
15
  "test:watch": "vitest",
16
16
  "test:golden": "vitest run tests/golden",
@@ -31,7 +31,7 @@
31
31
  "codex",
32
32
  "namespace"
33
33
  ],
34
- "author": "Tacuchi <jesus.loayza@quetalcompra.com>",
34
+ "author": "Tacuchi",
35
35
  "license": "AGPL-3.0-or-later",
36
36
  "repository": {
37
37
  "type": "git",
package/skills/w/SKILL.md CHANGED
@@ -55,7 +55,7 @@ USER invokes
55
55
  - **Layer 2** — the AI iterates end to end until convergence. No direct human invocation.
56
56
  - **Layer 3** — ephemeral, internal, process-only. Nobody invokes it by hand.
57
57
 
58
- > **Tools pointer:** auxiliary tooling has its home under `docs/tools/<slug>/` (README + run/output structure per the skill's contract; index row in `docs/tools/README.md`), authored by the **ambient `creating-tools` skill** — the host auto-discovers it when authoring any support tool, and the code loops' closing gate catches the miss (`loops/CODE-POLICIES.md` § *Closing review gate*). A ready implementation ships in the `tool-builder@qtc-marketplace` plugin; Workline does **not** depend on it (ambient, never bound).
58
+ > **Tools pointer:** auxiliary tooling has its home under `docs/tools/<slug>/` (README + run/output structure per the skill's contract; index row in `docs/tools/README.md`), authored by the **ambient `creating-tools` skill** — the host auto-discovers it when authoring any support tool, and the code loops' closing gate catches the miss (`loops/CODE-POLICIES.md` § *Closing review gate*). A ready implementation may be installed independently; Workline does **not** depend on it (ambient, never bound).
59
59
 
60
60
  ### The 3 flows
61
61
 
@@ -196,7 +196,7 @@ One language per plane — never mix them:
196
196
  | **Section headings** of artifacts and docs (`## Requirement`, `## Completed`, …) | **English** (parse contract) |
197
197
  | Everything **user-facing**: structured-choice questions, reports, dashboards, the **content** the AI writes into artifacts and `docs/` deliverables, commit messages | **the user's language** (this product: Spanish) |
198
198
  | Literal option labels (`Continuar`, `Compactar`, `Cerrar`, `Aceptar recomendaciones`, `Aprobar y guardar`, `Refinar`, …) | canonical product strings — use them **verbatim** |
199
- | Domain terms (class/route/table names, e.g. the QTC fleet) | the domain's ubiquitous language (Spanish) — never translated |
199
+ | Domain terms (class/route/table names, e.g. an existing fleet) | the domain's ubiquitous language (Spanish) — never translated |
200
200
 
201
201
  ### The 6 hard invariants
202
202
 
@@ -1,8 +1,8 @@
1
1
  -- SCRIPTS.sql — session artifact (common)
2
2
  --
3
- -- What it is: the SQL produced by a session. TWO types, distinguished by whether they are EXECUTED:
4
- -- A) READ-ONLY queries (diagnosis/validation): the AI writes them here and then
5
- -- executes them read-only via MCP.
3
+ -- What it is: SQL and remote-read context produced by a session. TWO roles are distinguished:
4
+ -- A) READ-ONLY remote queries: research context captured before plan approval, never
5
+ -- execution validation or a closing proof.
6
6
  -- B) DDL/DML migrations (schema/data changes): the AI DRAFTS them as a
7
7
  -- deliverable but NEVER executes them; they are exported to docs/scripts/ (forward +
8
8
  -- rollback) for a human/DBA to apply.
@@ -12,24 +12,29 @@
12
12
  --
13
13
  -- Rules:
14
14
  -- 1) One entry per script, numbered, with purpose, DB/MCP target and type (A or B).
15
- -- 2) Only type A is executed (read-only, via the declared MCP).
15
+ -- 2) A type A entry records `{kind: remote-read, connection, readonly: true, query_artifact,
16
+ -- captured_at, result_digest}` and has a matching note in CONCLUSIONS.md.
16
17
  -- 3) Lives in the session (.workflow/sessions/NNN-.../SCRIPTS.sql).
17
18
  -- 4) Type B is exported to docs/scripts/ as a deliverable (not executed by the AI).
18
19
 
19
20
  -- ============================================================
20
- -- [Q1] <purpose of the query> | Type: A (read-only)
21
- -- DB/MCP: <which> | Origin: <gap / task that motivates it>
21
+ -- [Q1] <purpose of the query> | Type: A (remote-read research context)
22
+ -- Snapshot: {kind: remote-read, connection: <which>, readonly: true,
23
+ -- query_artifact: SCRIPTS.sql#Q1, captured_at: <ISO-8601>, result_digest: <digest>}
24
+ -- Origin: <research gap only; never a plan task/validation/exit condition>
22
25
  -- ------------------------------------------------------------
23
26
  SELECT ...;
24
27
 
25
28
  -- ============================================================
26
- -- [Q2] <purpose> | Type: A (read-only)
27
- -- DB/MCP: <which> | Origin: <...>
29
+ -- [Q2] <purpose> | Type: A (remote-read research context)
30
+ -- Snapshot: {kind: remote-read, connection: <which>, readonly: true,
31
+ -- query_artifact: SCRIPTS.sql#Q2, captured_at: <ISO-8601>, result_digest: <digest>}
32
+ -- Origin: <research gap only>
28
33
  -- ------------------------------------------------------------
29
34
  SELECT ...;
30
35
 
31
36
  -- ============================================================
32
- -- [M1] <migration> | Type: B — DO NOT EXECUTE (deliverable; applied by a DBA;
37
+ -- [M1] <migration> | Type: B — DO NOT EXECUTE (deliverable; external application is handoff;
33
38
  -- exported to docs/scripts/ via export-*)
34
39
  -- DB/MCP: <which> | Origin: <plan task>
35
40
  -- ------------------------------------------------------------
@@ -15,3 +15,10 @@ Example:
15
15
 
16
16
  ## Details
17
17
  Supporting detail, evidence references, or additional context.
18
+
19
+ ## Remote context (only when captured)
20
+
21
+ For each read-only remote investigation, record the matching `RemoteContextSnapshot` from
22
+ `SCRIPTS.sql`: connection, query artifact, capture time and result digest. It is research context
23
+ with no automatic expiry; refreshing it requires a plan/spec refine. It is never copied into a
24
+ task, validation, exit condition or closure claim.
@@ -1,5 +1,5 @@
1
1
  ---
2
- description: Use to promote the type-B `SCRIPTS.sql` artifacts of N sessions into a docs/scripts/ bundle — continuous forwards plus rollback. `aw export-scripts` checks the bundle shape and NEVER executes SQL. Never automatic.
2
+ description: Use to promote the type-B `SCRIPTS.sql` artifacts of N sessions into a docs/scripts/ bundle — continuous forwards plus rollback. `aw export-scripts` checks shape and NEVER executes SQL. Never automatic.
3
3
  argument-hint: "[--sessions <ids>] [--since <YYYY-MM-DD>] [--source <alias>]"
4
4
  allowed-tools: ["Bash", "Read"]
5
5
  ---
@@ -14,9 +14,15 @@ allowed-tools: ["Bash", "Read"]
14
14
  ## What it produces
15
15
 
16
16
  - `docs/scripts/NNN-export-scripts-YYYY-MM-DD/`: `00-ROLLBACK.sql` and `README.md`, both required, + forwards `NN-<nombre>.sql` numbered **continuously from 01**; the CLI rejects a gap.
17
- - Neither the AI nor the CLI executes the SQL: the bundle is for a human or DBA to apply.
17
+ - Neither the AI nor the CLI executes the SQL: its application is a non-blocking handoff to an authorized operator.
18
18
  - Never write into `docs/` with a file tool: one pass, all or nothing, no session or loop created/touched.
19
19
 
20
+ ## Net final state
21
+
22
+ Publish the final state, not a session chronology: omit transients, write migrations in final form,
23
+ and reconcile code before delivery. Rollback safely reverses it; exclude concrete identities and test seeds.
24
+ `ESTADO FINAL NETO` · `orden seguro para las dependencias` · `objetos compartidos y necesarios para el estado final`
25
+
20
26
  ## More context
21
27
 
22
28
  `aw context-plan --command export-scripts --signal <s> --root "${CLAUDE_PLUGIN_ROOT}/skills/w"` returns the extra documents a case needs; read exactly what it lists:
@@ -13,6 +13,7 @@ allowed-tools:
13
13
  # plan-new — trampoline to the planning loop
14
14
 
15
15
  SPEC → PLAN bridge. Turns the "what" (refined spec) into the "how" (plan). Delegates to `plan-new-loop` (Layer 2).
16
+ An unready or legacy spec is input, never a block.
16
17
 
17
18
  > **Hard floor — applies even if you read nothing beyond this file:**
18
19
  >
@@ -175,18 +175,11 @@
175
175
  },
176
176
  {
177
177
  "path": "modules/EXEC-DB-POLICY.md",
178
- "signal": "db",
179
- "requires": "external-data"
178
+ "signal": "db"
180
179
  },
181
180
  {
182
181
  "path": "modules/DB-SCRIPTS-ONLY.md",
183
- "signal": "db",
184
- "requires": "external-data"
185
- },
186
- {
187
- "path": "modules/DB-RESEARCH-RULE.md",
188
- "signal": "db",
189
- "requires": "external-data"
182
+ "signal": "db"
190
183
  },
191
184
  {
192
185
  "path": "modules/SIMULATION-LIFECYCLE.md",
@@ -1,11 +1,11 @@
1
1
  ---
2
2
  name: export-scripts
3
- description: "Consolidates the workspace's pending SQL into a single `docs/scripts/NNN-export-scripts-YYYY-MM-DD/` bundle with continuous numbering after `00-ROLLBACK.sql`. Reads type-B migrations (DDL/DML) from two sources: `.workflow/sessions/<folder>/SCRIPTS.sql` across N sessions AND standalone `docs/scripts/*.sql` (excluding previous bundles). Ignores read-only type-A (diagnostic queries, not deliverables). Minimal SQL headers + a simple README (3 sections: Files / Apply / Revert). The rollback is derived from the forwards. Read-only/report: it NEVER executes SQL nor commits the bundle is for a human/DBA to apply. Composes the `sql` capability. Use for 'release SQL bundle', 'prepare the prod push', 'consolidate pending SQLs'. User-invoked via `/w:export-scripts`."
3
+ description: "Consolidates pending SQL into one `docs/scripts/NNN-export-scripts-YYYY-MM-DD/` bundle with continuous numbering after `00-ROLLBACK.sql`. It publishes the net final state, not a chronological transcript. Reads type-B migrations (DDL/DML) from session `SCRIPTS.sql` and standalone `docs/scripts/*.sql`, excluding prior bundles and read-only research. Read-only/report: it NEVER executes SQL nor commits; external application is a handoff. Composes the `sql` capability. User-invoked via `/w:export-scripts`."
4
4
  ---
5
5
 
6
6
  # export-scripts — consolidated SQL bundle, simple and direct
7
7
 
8
- Consolidates the pending SQL migrations of N sessions + standalone files into a single bundle under `docs/scripts/NNN-export-scripts-YYYY-MM-DD/`, with continuous numbering after `00-ROLLBACK.sql`. **Read-only / report** — the AI **never executes** the SQL; the user/DBA applies the bundle manually.
8
+ Consolidates the pending SQL migrations of N sessions + standalone files into a single bundle under `docs/scripts/NNN-export-scripts-YYYY-MM-DD/`, with continuous numbering after `00-ROLLBACK.sql`. **Read-only / report** — the AI **never executes** the SQL; external application is an optional handoff.
9
9
 
10
10
  > `export-*` family (the only artifact→`docs/` path). Design: `docs/referencias/workflow-exports/export-scripts.md`.
11
11
 
@@ -19,16 +19,16 @@ The **`sql`** capability (built-in default `sql`), resolved via `.workflow/skill
19
19
 
20
20
  ## When to use
21
21
 
22
- - "Release SQL bundle", "prepare the prod push", "consolidate pending SQLs".
23
- - Before promoting a branch to certification / `main`.
22
+ - "Release SQL bundle", "consolidate pending SQLs".
23
+ - Before an authorized release handoff.
24
24
  - After several `exec`/`quick` sessions left `SCRIPTS.sql` files with migrations.
25
25
 
26
26
  ## What it does
27
27
 
28
28
  1. Collects the workspace's SQL from **two sources**: each corpus session's type-B `SCRIPTS.sql` + standalone `docs/scripts/*.sql` (excluding previous bundles).
29
29
  2. Classifies the statements by canonical category (DDL-TABLES / DDL-FUNCTIONS / DML / INSERTS).
30
- 3. Consolidates cross-source per category with **continuous numbering** after `00-ROLLBACK.sql`.
31
- 4. Writes the consolidated forwards (each statement with its origin, 1 line).
30
+ 3. Resolves the **net final state** across sources, then groups it by category with **continuous numbering** after `00-ROLLBACK.sql`.
31
+ 4. Writes only the forwards needed for that final state, retaining traceable origin where useful.
32
32
  5. Derives `00-ROLLBACK.sql` **at the end**, reading the already-written forwards.
33
33
  6. Writes a minimal `README.md` (Files / Apply / Revert).
34
34
 
@@ -90,9 +90,13 @@ If the A + B union is empty → **abort**: there is no pending SQL in the worksp
90
90
 
91
91
  `aw next-number docs/scripts` → `docs/scripts/NNN-export-scripts-YYYY-MM-DD/`.
92
92
 
93
- ### Step 3 — Classification and internal order
93
+ ### Step 3 — Net final state, classification and internal order
94
94
 
95
- Group by canonical category: `01 DDL-TABLES` · `02 DDL-FUNCTIONS` · `03 DML` · `04 INSERTS`. Internal order chronological by origin (ascending session → ascending stmt; standalone interleaved by lexical filename order).
95
+ Reconcile the session and standalone candidates against the code and the declared final state. Omit
96
+ objects born and retired within the sequence; write migrated objects directly in their final form;
97
+ omit explicitly retired objects even when their deletion is absent from the input. Then group the
98
+ remaining statements by canonical category: `01 DDL-TABLES` · `02 DDL-FUNCTIONS` · `03 DML` ·
99
+ `04 INSERTS`. Origin is traceability, not an ordering authority over the final contract.
96
100
 
97
101
  ### Step 4 — Continuous numbering (no gaps)
98
102
 
@@ -100,7 +104,7 @@ Assign sequential numbers **only to categories with content**, in canonical orde
100
104
 
101
105
  ### Step 5 — Write the forwards
102
106
 
103
- Per category with content, one file with a 1-2 line header (`-- 0N-<CATEGORY>.sql — bundle NNN-export-scripts-YYYY-MM-DD`) and, per statement, **a one-line origin comment** (`-- sessionXXX / stmt-id` or `-- docs/scripts/001-filename.sql`) followed by the SQL exactly as the developer wrote it (wrapped in `BEGIN; COMMIT;` where it applies). Do not replicate motivation/impact/idempotency already present at the origin; no statement index, no invented verification SELECTs.
107
+ Per category with content, one file with a 1-2 line header (`-- 0N-<CATEGORY>.sql — bundle NNN-export-scripts-YYYY-MM-DD`) and traceable origin comments where useful. Write SQL for the reconciled final state, not necessarily the original statement verbatim; preserve explicit intent, idempotency and safe transaction boundaries. Do not replicate motivation/impact already present at the origin; no statement index, no invented verification SELECTs.
104
108
 
105
109
  ### Step 6 — Derive `00-ROLLBACK.sql` (at the end)
106
110
 
@@ -40,7 +40,7 @@ The persistent objective needs a **checkable done-condition** — otherwise the
40
40
  - **Form and weight scale**: a chore = "existing tests/build stay green" (one line); a feature = real acceptance tests. The rule is "**always declare the check before**", not "always write new tests".
41
41
  - **Subjective deliverable** (analysis/design): the AI **proposes** the rubric and the **human ratifies** it before pursuing it.
42
42
  - **Unresolvable criterion** (no evidence, DB unavailable): closes as `inconclusive` and the loop **degrades** — **never iterates against a fake target**.
43
- - **Cert-only**: a criterion needing **production or the deployed product** is not a done-condition nobody in the run can run it, so the phase waits forever. Verify in cert.
43
+ - **Source-bounded**: a closing criterion is demonstrated by a command or inspection tied to the acquired checkout. A deployed product, host runtime or remote connection is research context or an operational handoff, never a done-condition.
44
44
 
45
45
  **Gate integrity (anti-gaming + independent verification).** The gate only counts if it is not gamed to pass. The loop does **not**: modify the check or loosen a `Success criterion` to force green; weaken, delete or skip tests/validations; use trivial or tautological asserts that always pass (the expected value comes from an independent source, never from the output itself); patch the test instead of fixing the cause (prefer fixing production code).
46
46
 
@@ -23,7 +23,7 @@ PLAN
23
23
  `/w:plan-exec` — **resumable** (same chassis mechanism; here resume keys off the plan-doc phase states + checkboxes + CHECKPOINT, see Delta 1).
24
24
 
25
25
  ## Reads
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*).
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 whose source contract is executable: `> Límite de ejecución: checkout`, explicit phase/task sources and aliases from `AGENTS.md > Fuentes`. A legacy or v21 plan that lacks it fails closed to [`plan-refine-loop`](../plan-refine-loop/LOOP.md); plan-refine remains auxiliary only after that contract exists. 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*).
27
27
 
28
28
  ## Writes
29
29
  - `docs/plans/PPP-plan-<slug>.md` (**read/update**, living doc: phase/task state, `Open questions`).
@@ -44,7 +44,7 @@ inference, the deferred-validation cycle and conditional Git authorization.
44
44
 
45
45
  ## Composes
46
46
 
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.
47
+ `git` (safe branch + proposed commits). `plan-exec` does **not** load `external-data`: its proof comes from the acquired checkout only. SQL fixture/ephemeral tests are ordinary local commands; remote MCP reads belong to earlier research, never this loop.
48
48
 
49
49
  > **Ambient conventions (not roles):** code/testing/writing standards and `creating-tools` are standalone skills the host auto-discovers by `description` — Workline neither binds nor depends on them. Full doctrine: [../../roles/README.md](../../roles/README.md).
50
50
 
@@ -59,11 +59,14 @@ inference, the deferred-validation cycle and conditional Git authorization.
59
59
  ## Entry gate — executability
60
60
 
61
61
  **Before touching code**, read the plan and its spec and check the shape execution depends on:
62
+ this is § *Entry gate — executability*. Once that shape exists, plan-refine is auxiliary, not mandatory.
62
63
 
63
- 1. every phase declares its `Resultado`, its `Condición de salida` and its `Validación de fase`;
64
- 2. if temporary behavior exists, its current boundary and retirement phase are identifiable; otherwise the simulation check is not applicable;
65
- 3. the primary proof of the first `pendiente` phase is identifiable;
66
- 4. no structural contradiction is evident (a phase that undoes an earlier one, evidence nobody can produce).
64
+ 1. the plan declares `> Límite de ejecución: checkout`; every phase has `> Fuentes:` and every task has `_(fuentes: …)_`; aliases resolve through `AGENTS.md > Fuentes` (except reserved `workspace`) and task sources are a subset of their phase;
65
+ 2. every phase declares its `Resultado`, its `Condición de salida` and its `Validación de fase`;
66
+ 3. if temporary behavior exists, its current boundary and retirement phase are identifiable; otherwise the simulation check is not applicable;
67
+ 4. the primary proof of the first `pendiente` phase is identifiable and is a checkout command or inspection;
68
+ 5. no structural contradiction is evident (a phase that undoes an earlier one, evidence nobody can produce).
69
+ 6. reading the phase prose shows that no deployed product, installed host, MCP connection or remote URL is a validation or exit condition; those observations belong to research or `Handoff operativo`, never the closure path.
67
70
 
68
71
  Execution **no longer accepts in silence** a plan that would force it to invent its own structure. Two outcomes:
69
72
 
@@ -122,8 +125,8 @@ reconciliation** in `CHECKPOINT`, never reported as published.
122
125
  - **Marking order (hard rule):** a phase reaches `validada` only with its proof run and passed, its
123
126
  exit condition true and the combined review green; a blocker is never deferred into `validada`.
124
127
  **Never** because all its checkboxes are ticked.
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`.
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.
128
+ - **Intermediate states:** `bloqueada` = the phase is stopped on a live checkout blocker — recorded in `CHECKPOINT` + the plan's `## Open questions`, back to `en ejecución` when it clears; it counts as **not validated**. A proof that cannot run **stays `bloqueada`**. A deferred check never counts as a passed one. A script awaiting real-world application is a **handoff**, not a blocker: local fixture/ephemeral validation can still establish the promised behavior and the phase may become `validada`.
129
+ - **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** in the checkout, never an operator's deployed run.
127
130
  - **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.
128
131
  - **CHECKPOINT per execution unit:** record its effective grouping, functional states, simulation
129
132
  boundary when applicable, checks/results, decisions, deferrals and next intent. The task boxes
@@ -175,9 +178,10 @@ adds nothing of its own beyond running on a verified branch and never
175
178
  - 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.
176
179
  - 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).
177
180
  - A validation that **runs and fails** → back into the phase (gap): no advancing, no `validada`.
178
- - **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.)
179
181
 
180
- > 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).
182
+ - **SQL delivery**: validate the migration's behavior against a fixture or ephemeral database in the acquired checkout. The forward/rollback script is delivered through `SCRIPTS.sql` and `export-scripts`; a real application is an optional handoff and never keeps a phase or the plan open.
183
+
184
+ > 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 local proof passes. For code and persistence these are checkout commands/tests; a script's real-world application is never a closing criterion.
181
185
 
182
186
  ## Delta 5 — Closing review gate (conventions, pre-commit)
183
187
 
@@ -1,16 +1,10 @@
1
1
  ---
2
2
  name: plan-new-loop
3
3
  description: >-
4
- Generates a rich implementation plan (docs/plans/PPP-plan-<slug>.md) from a
5
- spec. Heir of the chassis (loops/CHASSIS.md). Deltas: the plan absorbs the
6
- TECHNICAL-NOTE level + Tasks phased by verifiable functional state
7
- (### Fn blocks with live state),
8
- code/impact-mapping research, planning gap taxonomy, and promotion of the
9
- design closure to handoff via `design`: reuse a valid one, promote the rest,
10
- then pin the roots
11
- when the plan includes UI. If the spec is not refined it suggests
12
- spec-refine first. Started by /w:plan-new; resumable. Invoke when a spec
13
- must become an executable plan.
4
+ Generates an executable plan (docs/plans/PPP-plan-<slug>.md) from a spec.
5
+ Heir of CHASSIS: phases are verifiable states; research maps impact and
6
+ gaps; UI design roots are reused or promoted and pinned. Suggests
7
+ spec-refine first when needed. Started by /w:plan-new; resumable.
14
8
  ---
15
9
 
16
10
  # plan-new-loop
@@ -27,14 +21,14 @@ PLAN
27
21
  `/w:plan-new` — **resumable** (same chassis mechanism, keyed off CHECKPOINT).
28
22
 
29
23
  ## Reads
30
- `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`, never from the filename, and a spec that is not ready is a **soft suggestion** to refine first, never a block — the four input modes are in [`PLAN-INPUT`](../../modules/PLAN-INPUT.md). Questions the spec left with destination `PLAN` are **input to this loop**, not a reason to send it back.
24
+ `docs/specs/NNN-spec-*.md` (glob or argument path). Readiness comes from frontmatter `status`, never the filename; an unrefined spec only suggests [`PLAN-INPUT`](../../modules/PLAN-INPUT.md)'s refine path. Questions routed to `PLAN` remain input to this loop.
31
25
 
32
26
  ## Writes
33
- `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)*). With UI, also the design revision it publishes under `docs/designs` (chassis § *docs/ boundary*). It never graduates/exports anything else to `docs/` — that is separate `export-*` work.
27
+ `docs/plans/PPP-plan-<slug>.md` (`generate`; overwrite needs confirmation), or sibling plans after an accepted split (§ *Split gate (multi-plan)*). With UI it also publishes the scoped design revision in `docs/designs/`; it never graduates/exports anything else to `docs/` — that is separate `export-*` work.
34
28
 
35
- > **Naming** follows [`PLAN-INPUT`](../../modules/PLAN-INPUT.md) § *Numbering*: the claim CLAIMS `PPP` **for its run** — two flows never get the same one, only its owner fills it; closing unpublished frees it. Plans glob as `docs/plans/PPP-plan-*.md`.
29
+ > **Naming:** [`PLAN-INPUT`](../../modules/PLAN-INPUT.md) § *Numbering* claims `PPP` for its run; only its owner fills it and an unpublished close frees it. Plans glob as `docs/plans/PPP-plan-*.md`.
36
30
 
37
- > **Adoption (command mode 4):** an **externally-built plan** (host plan mode, hand-written, another agent) is materialized by the **command** in a single pass — this loop does not run: transcribe + normalize into the Delta 1 schema, `## Origin` = "adopted from <source>" + attribution; then `plan-refine` closes schema gaps (its coherence gate degrades for spec-less plans). See `../../modules/PLAN-INPUT.md` (the command's `input` module).
31
+ > **Adoption (mode 4):** the command transcribes an externally-built plan once into Delta 1, records `## Origin`, then `plan-refine` closes schema gaps. See [`PLAN-INPUT`](../../modules/PLAN-INPUT.md).
38
32
 
39
33
  ## Inherits
40
34
 
@@ -57,6 +51,7 @@ The plan keeps technical detail and roadmap inline:
57
51
 
58
52
  > Derived from docs/specs/NNN-spec-<slug>.md · generated by plan-new-loop
59
53
  > Estado: open
54
+ > Límite de ejecución: checkout
60
55
 
61
56
  ## Origin source spec/prompt or adopted source + attribution
62
57
  ## Solution the how: brief AS-IS → TO-BE + closing "Final behavior" block (core)
@@ -86,19 +81,24 @@ This is the single contract; the other PLAN loops reference it.
86
81
  ```markdown
87
82
  ### F1 — <result-oriented name>
88
83
  > Estado: pendiente
84
+ > Fuentes: workspace, <declared-source>
89
85
 
90
86
  **Resultado:** <the new verifiable state of the system>
91
87
  **Trabajo:**
92
- - [ ] T1.1 — <coherent unit of work>
88
+ - [ ] T1.1 — <coherent unit of work> _(fuentes: <declared-source>)_
93
89
  **Validación de fase:** <the primary proof that the promised state was reached>
94
90
  **Condición de salida:** <falsifiable result · contract preserved>
95
91
  ```
96
92
 
97
93
  **Required**: `Resultado` · `Trabajo` · `Validación de fase` · `Condición de salida` · the state
98
- line. **Conditional**: `Estado inicial` when unclear · `Recorrido afectado` for a distributed
94
+ line · `Fuentes`. Every task declares `_(fuentes: …)_`; task sources are a phase subset and either
95
+ `workspace` or an exact `AGENTS.md > Fuentes` alias. `Impacted` never substitutes them. **Conditional**: `Estado inicial` when unclear · `Recorrido afectado` for a distributed
99
96
  change · `Dependencias` when direct sequence is insufficient · `Límite de simulación` (**only** when temporary behavior exists) · `Diferido` when work was consciously excluded.
100
97
  **A new phase never writes an empty conditional block.**
101
98
 
99
+ **Checkout is the only closing surface.** Proof is a local command, fixture, ephemeral DB or checkout
100
+ inspection. A deployed host, product or remote read is research or non-blocking `Handoff operativo`, never phase closure.
101
+
102
102
  **Phase state = machine state.** One bare `> Estado: <value>` line uses `pendiente` | `en ejecución`
103
103
  | `bloqueada` | `validada`. It is updated in place and counted
104
104
  **alongside — not instead of —** checkboxes. `validada` requires completed work, a true exit
@@ -48,6 +48,9 @@ can establish.
48
48
  ## Writes
49
49
  Updates `docs/plans/PPP-plan-<slug>.md` **in place** (when the user picks `Aprobar y guardar`): completes/adjusts sections and **adds** `## Refinement decisions`. Since it overwrites an existing doc, the preview says so and the person approves it **once**. On an accepted split (§ *Split gate — refine semantics*) the same proposal also **creates** the extracted sibling plans (newly minted `docs/plans` files) — one preview, one decision, one all-or-nothing write. It writes `docs/plans` and, when the refine **touches UI**, the **revision it publishes** — scoped to the artifacts the delta actually affects — of the design package under `docs/designs` (chassis § *docs/ boundary*; see [`DESIGN-REFERENCES.md`](../../modules/DESIGN-REFERENCES.md)). It never graduates/exports anything else to `docs/` — that is separate `export-*` work.
50
50
 
51
+ > **Revision + consumer:** a new baseline carries the final plan as `consumer_document`
52
+ > (path + base digest); package, manifest and plan publish or roll back together.
53
+
51
54
  ## Inherits
52
55
 
53
56
  Read **[`../CHASSIS.md`](../CHASSIS.md)** — the loop's **full engine** — **always before** these deltas. *(If `../` does not resolve: `CHASSIS.md` next to this file — global layout rule, chassis § Reference resolution.)*
@@ -127,6 +130,8 @@ This loop's instance of the chassis convergence gate — the same one `plan-exec
127
130
  - **Contract** — relevant inputs, outputs and observable states identified; the final behavior matches the spec; no functional criterion invented here.
128
131
  - **Journey** — main components identified, order reasonable, repo/process boundaries visible, the described architecture the one the project actually has.
129
132
  - **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.
133
+ - **Source boundary** — the plan declares `> Límite de ejecución: checkout`, each phase declares `> Fuentes:`, every task carries `_(fuentes: …)_`, aliases resolve through `AGENTS.md > Fuentes` (or reserved `workspace`) and task sources stay within their phase.
134
+ - **Source-bounded semantics** — read the meaning of every task, phase validation and exit condition. A deployed product, installed host, MCP connection or remote URL may be research context or `Handoff operativo`, never a prerequisite or proof of closure; rewrite it as a fixture, ephemeral dependency or checkout inspection. This is semantic review, not a word denylist.
130
135
  - **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.
131
136
  - **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.
132
137
  - **Execution batches** — every phase appears once; maximal continuous ranges cross no decision, proof, handoff, irreversible action or required recovery boundary.
@@ -152,7 +157,7 @@ plan-refine-loop(plan):
152
157
  design (revisions only for the artifacts this refine affects; behavior/acceptance → spec-refine first)
153
158
  integrate + update CHECKPOINT # artifact-first cycle
154
159
  executability gate (read-only) = Success criteria green:
155
- - contract · journey · phases · simulation · evidence · execution batches · resumability (§ Executability gate)
160
+ - contract · journey · phases · source boundary · simulation · evidence · execution batches · resumability (§ Executability gate)
156
161
  - plan-new checklist (criterion→task · Final behavior block of Solution · deps · Impacted↔Solution · UI→exact roots · minimality)
157
162
  # spec-less plan (adopted/hand-written): criteria anchor to the plan's own Final behavior block/Validations (see Delta 2)
158
163
  - re-refine's own check: the plan is REALIGNED with what changed
@@ -52,7 +52,7 @@ Read **[`../CHASSIS.md`](../CHASSIS.md)** — the loop's **full engine** — **a
52
52
 
53
53
  - **No phases, no plan-doc**: the prompt **is** the task (a single unit). No roadmap.
54
54
  - **Proportional verification-first** (minimal ceremony): even here the check is **seeded before**, sized to the task. Code: one test (bug repro → fix) or "existing build/lint/tests stay green" (chore). **Analysis/design**: a **short falsifiable rubric**, *ratified by the user* before pursuing it. It is the run's `SESSION.Success criteria` (see [chassis § *Verification-first*](../CHASSIS.md)).
55
- - **Git and DB inline** (full policies in [`../CODE-POLICIES.md`](../CODE-POLICIES.md)): before editing, verify each source's expected branch (`aw check-branch`); **proposed** commit (approve first) — never `push`/`--amend`/`--no-verify`. The AI **never executes DML/DDL**: migrations are drafted into the session's `SCRIPTS.sql` (read-only queries do run, via MCP).
55
+ - **Git and DB inline** (full policies in [`../CODE-POLICIES.md`](../CODE-POLICIES.md)): before editing, verify each source's expected branch (`aw check-branch`); **proposed** commit (approve first) — never `push`/`--amend`/`--no-verify`. The AI **never executes DML/DDL**: migrations are drafted into the session's `SCRIPTS.sql`; fixture/ephemeral checks are local proof and any remote read is research context, never closure.
56
56
  - **One session. One commit** proposed at the end (only if there were code changes), **after the proportional closing review gate** ([`../CODE-POLICIES.md`](../CODE-POLICIES.md) § *Closing review gate*): diff re-read + ambient conventions; fix or defer; nothing reaches the commit unreviewed.
57
57
  - **Entry SIZE GATE** (before creating the session): a quick that should have been a spec costs more than the ceremony it saved, so the size of the objective is judged **before** anything exists. Your part is recognizing the signals; the threshold, the question and its options are the CLI's. A signal already resolved by *adopted context* is **not** a signal (chassis § *Adopted context*). A **resume** of an existing quick never re-fires it.
58
58
  - **`Recortar alcance`**, if chosen: propose the **sub-task that DOES fit** a quick (`SESSION.Objective` = the sub-task; the original prompt goes into `## Origin`) and defer the rest to `BACKLOG` ("trimmed at the gate — may warrant its own spec, `/w:spec-new`").
@@ -81,7 +81,7 @@ quick-loop(prompt):
81
81
  work the task (minimal loop):
82
82
  if it edits code → verify each source's expected branch (`aw check-branch`); mismatch → pause + resolve
83
83
  produce the deliverable: edit code (minimal change) OR author the analysis/design
84
- if read-only DB querySCRIPTS.sql + execute read-only
84
+ if fixture/ephemeral DB checkrun it from the checkout + capture its proof
85
85
  if DB change (DDL/DML) → SCRIPTS.sql (session artifact, DO NOT execute)
86
86
  if non-obvious decision → DECISION
87
87
  if doubt/gap → inline research, a probe OR structured-choice # chassis § Proof of concept
@@ -70,6 +70,9 @@ The **UI unspecified** gap (when the requirement involves UI; see *Gap taxonomy*
70
70
 
71
71
  > **Two levels of the same capability:** a compact SPEC may already close its exact roots at `handoff`; otherwise SPEC keeps an `outline` reference and PLAN promotes exactly the closure it implements. A valid handoff is reused, never re-authored. One package, two questions — never two formats.
72
72
 
73
+ > **Compound publication:** a new baseline carries this final spec as `consumer_document`
74
+ > (path + base digest); package, manifest and spec publish or roll back together.
75
+
73
76
  Other transversal capabilities the engine always uses: `research` (**inline** — chassis § *Research*), `sql` (DB rule inside research — chassis). All resolved by config; `off` → the loop continues without the capability and, if it was needed, says so or asks. The spec's **prose** follows the **ambient** writing conventions (the host auto-applies an installed writing skill if present), not a composed role.
74
77
 
75
78
  > **Ambient conventions (not roles):** code/testing/writing standards and `creating-tools` are standalone skills the host auto-discovers by `description` — Workline neither binds nor depends on them. Full doctrine: [../../roles/README.md](../../roles/README.md).
@@ -224,6 +227,7 @@ finalize:
224
227
  - every **blocking** functional decision is resolved, and every remaining question carries its destination;
225
228
  - **Minimality** — no gold-plating: every criterion and scope item earns its place (chassis § *Minimality*); speculative scope is cut or deferred, and no technical solution was imposed that the requirement did not ask for;
226
229
  - `PLAN` can continue without inventing behavior, scope or product decisions.
230
+ - its gate evidence is checkout-bounded: local inspection/commands may establish it; a deployed product, host runtime or remote query is context or handoff, never a closing condition.
227
231
  - Whatever fails **comes back as a gap**. A question owned by `PLAN` **never** fails the gate: it is recorded with its destination, not closed.
228
232
  - Passes → `edit_in_place_with_confirm(spec)` + `status: ready-for-plan` → `finalize`. The stamp only counts once the document really carries it.
229
233
  - `Cerrar` → the chassis `finalize` (always persists `CHECKPOINT`; `BACKLOG` **only if** something is deferred — here: close reason + deferred `Open questions`).
@@ -2,10 +2,10 @@
2
2
 
3
3
  Loaded when the run reads or writes a database (signal `db`).
4
4
 
5
- Investigation is otherwise autonomous: the AI investigates inline and reports without asking permission. A database is the one place where it asks first.
5
+ Research is autonomous except for DB choice. A remote read is context, never plan-execution proof.
6
6
 
7
- 1. **MCP choice**: if the gap needs DB and there is **>1 candidate MCP with no configured default**, the AI asks which one to use. That question goes through the **same structured-choice** as a **content question** (counts inside the ≤3 + `flow` limit), **before** running queries. A single MCP or a default → no question.
8
- 2. Write the queries **first** into the session's `SCRIPTS.sql`.
9
- 3. Execute them **read-only** via MCP (respect `sql-mutation-guard`: never DML/DDL).
7
+ 1. With >1 candidate MCP and no default, ask which one through the content structured-choice (inside the ≤3 + `flow` limit) before querying; otherwise do not ask.
8
+ 2. Write queries first in session `SCRIPTS.sql`.
9
+ 3. Run them read-only via MCP (`sql-mutation-guard`: never DML/DDL), then record `RemoteContextSnapshot` in `SCRIPTS.sql` plus conclusion/digest in `CONCLUSIONS.md` before plan approval.
10
10
 
11
- > The AI **never executes DML/DDL**. A migration is drafted in the session's `SCRIPTS.sql` and handed off; promoting it to `docs/scripts/` is a separate `export-*`, never a loop.
11
+ > Snapshots have no automatic TTL; refreshing during execution means `/w:plan-refine`. The AI **never executes DML/DDL**. Draft migrations in session `SCRIPTS.sql`; `export-*` promotes them separately as handoff.
@@ -4,11 +4,10 @@ Loaded when a code-editing run touches the database (signal `db`).
4
4
 
5
5
  ## DB scripts-only — the AI never executes DML/DDL
6
6
 
7
- Distinguished by **execution**, not by file (see the [`SCRIPTS.sql`](../artifacts/artifacts-core/SCRIPTS.sql) schema):
7
+ Classify by **role**, not file (see [`SCRIPTS.sql`](../artifacts/artifacts-core/SCRIPTS.sql)):
8
8
 
9
- - **Read-only queries** (diagnosis/validation) `SCRIPTS.sql` (session artifact); the AI **does** execute them read-only via MCP (`sql-mutation-guard`).
10
- - **DDL/DML migrations** (schema/data changes) the AI **drafts them in `SCRIPTS.sql`** (session artifact) but **NEVER executes them**.
9
+ - **Read-only remote query** → research context: record query, digest and `RemoteContextSnapshot` before approval.
10
+ - **Fixture/ephemeral DB test** checkout proof; may validate a phase locally.
11
+ - **DDL/DML migration** → draft in session `SCRIPTS.sql`; **NEVER execute**.
11
12
 
12
- > Mutating SQL **stays in the session**; it is never moved to `docs/`. Its promotion to `docs/scripts/` (forward + rollback) is done by a separate `export-*`, never by the loop.
13
-
14
- > **Showing beats asserting here:** the deterministic steps below are decided by the CLI (`aw flow advance`), not by this document — it asks the session's script back, because no narration tells drafting from running.
13
+ > Migration application is a non-blocking handoff, never a task, validation or exit condition. The plan closes on its local contract/tests; the deterministic steps below are decided by the CLI (`aw flow advance`), not by this document and it verifies the session script, not narration.
@@ -2,6 +2,6 @@
2
2
 
3
3
  Loaded when a phase touches the database (signal `db`).
4
4
 
5
- ## Delta 3 — DB policy: **the AI never executes DML**
5
+ ## Delta 3 — DB policy: **checkout proof, never deployed closure**
6
6
 
7
- Full policy in [`DB-SCRIPTS-ONLY.md`](DB-SCRIPTS-ONLY.md), the `db` module of [`../loops/CODE-POLICIES.md`](../loops/CODE-POLICIES.md). **Inline:** read-only queries the session's `SCRIPTS.sql`, executed via MCP (`sql-mutation-guard`); DDL/DML migrations the AI **drafts them in `SCRIPTS.sql` but NEVER executes them** — their promotion to `docs/scripts/` is done by a separate `export-*`, never this loop.
7
+ See [`DB-SCRIPTS-ONLY.md`](DB-SCRIPTS-ONLY.md) and [`../loops/CODE-POLICIES.md`](../loops/CODE-POLICIES.md). Fixture/ephemeral-DB checks in the acquired checkout may close a phase. Do not open remote reads here: they are captured research context. Draft DDL/DML in `SCRIPTS.sql`; applying it is handoff and never blocks `validada` or plan closure.
@@ -4,25 +4,27 @@ Loaded when the input is not plainly a `ready-for-plan` spec (signal `input`).
4
4
 
5
5
  ## plan-new — four modes
6
6
 
7
- 1. **Ready spec** (`docs/specs/NNN-spec-<slug>.md` whose frontmatter declares `status: ready-for-plan`) → ideal. Proceed straight to the loop.
8
- 2. **Spec not ready** (`status: draft` / `refining`, or no mark at all) → **soft-suggest** running `/w:spec-refine` first, **never a block**. Questions the spec left with destination `PLAN` are this flow's **input**, not a reason to send it back.
9
- 3. **Prompt** (no spec referenced) → propose the SPEC flow; **by default launch `/w:spec-new`** with that prompt and continue the natural flow from there.
10
- 4. **External plan content** — the argument carries an **already-built plan** (host plan mode, hand-written, another agent's) → **adopt it**. Single pass, **NO RESEARCH**: materialize as `docs/plans/PPP-plan-<slug>.md`, normalized to the rich-plan schema with only what the source provides. `## Origin` = "adopted from <source>" + attribution (host · model · date). Then offer `/w:plan-refine` or `/w:plan-exec`. Anti-duplicate: a plan whose `## Origin` matches this objective is resumed, never duplicated. Adoption **never regenerates over** an existing plan-doc.
7
+ 1. **Ready spec** (`docs/specs/NNN-spec-<slug>.md`, `status: ready-for-plan`) → proceed.
8
+ 2. **Spec not ready** (`draft`, `refining`, or no mark) → **soft-suggest** `/w:spec-refine`, never a block. `PLAN` questions remain input here.
9
+ 3. **Prompt** (no spec) → propose and normally launch `/w:spec-new`, then continue.
10
+ 4. **External plan** (host, hand-written, another agent) → **adopt once, NO RESEARCH** at `docs/plans/PPP-plan-<slug>.md`. Normalize only supplied material; set `## Origin` to "adopted from <source>" + host/model/date; offer `/w:plan-refine` or `/w:plan-exec`. A matching Origin resumes; never overwrite a plan-doc.
11
11
 
12
12
  > **Mode 3 vs 4:** a prompt that *describes a wish* → SPEC (mode 3); content that *already is a plan* → adopt (mode 4).
13
13
 
14
- > **What adoption may do once the mode is settled is not this document's call:** the deterministic steps below are decided by the CLI (`aw flow advance`), not by this document.
14
+ > Adoption is CLI-owned: the deterministic steps below are decided by the CLI (`aw flow advance`), not by this document.
15
+
16
+ > **Source-bounded:** new/refined plans declare `> Límite de ejecución: checkout`; each phase `> Fuentes:`; each task `_(fuentes: …)_`. `workspace` is reserved; other aliases exist in `AGENTS.md > Fuentes`; task sources are a phase subset. A legacy/manual plan without this form is adopted but **cannot execute**: `/w:plan-refine` adds it.
15
17
 
16
18
  > **Ready vs not** is read from the spec's frontmatter `status`, never from the filename. **Legacy compat:** a spec with no frontmatter that carries `## Refinement decisions` — or the older `## Q&A traceability` — counts as ready the same way.
17
19
 
18
20
  ## plan-refine — three modes
19
21
 
20
- 1. **Existing plan** (`docs/plans/PPP-plan-<slug>.md`) → proceed, **regardless of provenance**: generated, hand-written, or adopted. Existence is the only requirement.
21
- 2. **No plan** → **soft-suggest** `/w:plan-new` first; the user decides.
22
- 3. **Returned by `plan-exec`** (its entry check found the plan unexecutable, or execution stopped on a structural deviation) → proceed carrying that finding: phases already `validada` stay, only pending work is re-designed.
22
+ 1. **Existing plan** (`docs/plans/PPP-plan-<slug>.md`) → proceed regardless of provenance.
23
+ 2. **No plan** → soft-suggest `/w:plan-new`; the user decides.
24
+ 3. **Returned by `plan-exec`** (unexecutable entry or structural deviation) → retain `validada` phases and redesign only pending work.
23
25
 
24
26
  > **Spec-less plans are legitimate input.** The coherence gate **degrades gracefully**: criteria trace to the plan's own Final behavior block instead of spec criteria, and the "spec criteria uncovered" gap does not apply.
25
27
 
26
28
  ## Numbering
27
29
 
28
- The plan is named `docs/plans/PPP-plan-<slug>.md`; `aw next-number docs/plans --claim plan-<slug>.md --code <NNN>` claims it **for its run**; the slug comes from the Requirement. It does **not inherit the spec's `NNN`** — the link is established by reference in `## Origin`, never by number.
30
+ The name is `docs/plans/PPP-plan-<slug>.md`; `aw next-number docs/plans --claim plan-<slug>.md --code <NNN>` claims it for this run. The slug comes from the Requirement. It does not inherit the spec `NNN`: `## Origin` carries that link.