@zalom/plastic 1.14.0 → 2.0.0-alpha.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 (190) hide show
  1. package/PLASTIC.md +101 -294
  2. package/README.md +5 -6
  3. package/agents/plastic-advisor.md +18 -17
  4. package/agents/plastic-enforcer.md +57 -69
  5. package/agents/plastic-executor.md +34 -20
  6. package/agents/plastic-faux-advisor.md +18 -18
  7. package/config_asks.yml +38 -0
  8. package/hooks/capture +4 -0
  9. package/hooks/check-update +12 -3
  10. package/hooks/close +5 -0
  11. package/hooks/hooks.json +9 -49
  12. package/hooks/record +4 -0
  13. package/package.json +3 -2
  14. package/scripts/agent-report +8 -9
  15. package/scripts/append-ledger +195 -0
  16. package/scripts/codex-hook +101 -95
  17. package/scripts/dashboard.rb +4 -4
  18. package/scripts/doctor.rb +106 -43
  19. package/scripts/end-intent +77 -76
  20. package/scripts/exec-worktree +11 -20
  21. package/scripts/file-session-intent +61 -0
  22. package/scripts/hook-capture +242 -0
  23. package/scripts/hook-close +34 -0
  24. package/scripts/hook-record +149 -0
  25. package/scripts/hook-session-start +95 -12
  26. package/scripts/install.rb +8 -6
  27. package/scripts/lib/agent_models.rb +1 -7
  28. package/scripts/lib/arm.rb +283 -0
  29. package/scripts/lib/backfill_intent.rb +316 -0
  30. package/scripts/lib/bridge.rb +24 -1597
  31. package/scripts/lib/doctor_core.rb +17 -88
  32. package/scripts/lib/doctor_session_ledger.rb +106 -0
  33. package/scripts/lib/exec_worktree.rb +14 -60
  34. package/scripts/lib/harness_text.rb +5 -4
  35. package/scripts/lib/hook_registry.rb +44 -107
  36. package/scripts/lib/insights.rb +3 -4
  37. package/scripts/lib/installer_core.rb +19 -30
  38. package/scripts/lib/lock.rb +6 -26
  39. package/scripts/lib/outcome_guard.rb +7 -5
  40. package/scripts/lib/project_validator.rb +30 -1
  41. package/scripts/lib/roadmap_queue.rb +3 -3
  42. package/scripts/lib/roadmap_savepoint.rb +1 -1
  43. package/scripts/lib/rule_catalog.rb +6 -3
  44. package/scripts/lib/savepoint.rb +320 -0
  45. package/scripts/lib/scaffold_intent.rb +13 -179
  46. package/scripts/lib/session_backfill.rb +184 -0
  47. package/scripts/lib/session_close.rb +84 -0
  48. package/scripts/lib/session_git.rb +469 -0
  49. package/scripts/lib/session_ledger.rb +497 -0
  50. package/scripts/lib/store_discovery.rb +1 -1
  51. package/scripts/lib/store_provisioning.rb +1 -1
  52. package/scripts/maintenance-run +7 -7
  53. package/scripts/new-intent +63 -4
  54. package/scripts/plastic-lock +94 -41
  55. package/scripts/promote-session-item +150 -0
  56. package/scripts/rebuild-graph +1 -1
  57. package/scripts/roadmap-next +2 -2
  58. package/scripts/rollback.rb +42 -3
  59. package/scripts/scaffold-intent +37 -63
  60. package/scripts/session-commit +116 -0
  61. package/scripts/spawn-preamble +5 -5
  62. package/scripts/update.rb +7 -3
  63. package/skills/agent-advisor/SKILL.md +3 -3
  64. package/skills/agent-advisor/references/advisor-protocol.md +20 -20
  65. package/skills/auto/SKILL.md +218 -317
  66. package/skills/auto/evals/evals.json +10 -10
  67. package/skills/auto/references/agent-architecture.md +102 -90
  68. package/skills/auto/references/agent-report-contract.md +4 -21
  69. package/skills/auto/references/end-tail.md +47 -53
  70. package/skills/auto/references/human-report-contract.md +8 -8
  71. package/skills/conventions/SKILL.md +1 -3
  72. package/skills/conventions/references/lifecycle-and-savepoints.md +35 -1
  73. package/skills/conventions/references/locks-and-worktrees.md +47 -55
  74. package/skills/conventions/references/maintenance-and-revisions.md +12 -12
  75. package/skills/dashboard/SKILL.md +1 -1
  76. package/skills/direct/SKILL.md +66 -0
  77. package/skills/direct/references/request-signals.md +59 -0
  78. package/skills/doctor/SKILL.md +58 -11
  79. package/skills/doctor/report.md +3 -1
  80. package/skills/install/SKILL.md +11 -9
  81. package/skills/intent-continuing/SKILL.md +131 -89
  82. package/skills/intent-continuing/references/boarding-matrix.md +34 -0
  83. package/skills/intent-continuing/references/context-management.md +2 -2
  84. package/skills/intent-creating/SKILL.md +2 -2
  85. package/skills/intent-creating/references/lifecycle.md +1 -1
  86. package/skills/intent-ending/SKILL.md +28 -37
  87. package/skills/intent-ending/evals/evals.json +4 -4
  88. package/skills/intent-executing/SKILL.md +12 -49
  89. package/skills/intent-executing/plan-reviewer-prompt.md +39 -0
  90. package/skills/intent-speccing/SKILL.md +108 -51
  91. package/skills/intent-speccing/evals/evals.json +5 -5
  92. package/skills/intent-speccing/references/per-section-fill-rules.md +4 -4
  93. package/skills/intent-speccing/references/self-verify-checklist.md +1 -2
  94. package/skills/project-creating/SKILL.md +1 -1
  95. package/skills/releasing/SKILL.md +7 -8
  96. package/skills/tutorial/SKILL.md +2 -2
  97. package/skills/tutorial/references/track-1-guided.md +16 -18
  98. package/skills/tutorial/references/track-2-auto.md +12 -13
  99. package/skills/tutorial/references/track-3-projects-and-roadmaps.md +2 -2
  100. package/templates/agents.md +4 -7
  101. package/templates/project.yml +7 -0
  102. package/templates/roadmap.md +1 -1
  103. package/templates/savepoint.md +2 -2
  104. package/templates/session-intent.md +29 -0
  105. package/agents/plastic-brainstorming.md +0 -48
  106. package/agents/plastic-future-intent-researcher.md +0 -35
  107. package/agents/plastic-intent-curator.md +0 -47
  108. package/agents/plastic-intent-discovery.md +0 -43
  109. package/agents/plastic-planner.md +0 -56
  110. package/agents/plastic-spec-specialist.md +0 -53
  111. package/hooks/auto-arm +0 -5
  112. package/hooks/bash-gate +0 -3
  113. package/hooks/continue +0 -31
  114. package/hooks/edit-gates +0 -3
  115. package/hooks/future-intent-check +0 -25
  116. package/hooks/gate-check +0 -12
  117. package/hooks/power-tools +0 -8
  118. package/scripts/hook-auto-arm +0 -51
  119. package/scripts/hook-bash-gate +0 -78
  120. package/scripts/hook-code-gate +0 -38
  121. package/scripts/hook-continue +0 -48
  122. package/scripts/hook-create-gate +0 -51
  123. package/scripts/hook-edit-gates +0 -58
  124. package/scripts/hook-future-intent-check +0 -90
  125. package/scripts/hook-gate-check +0 -169
  126. package/scripts/hook-links-gate +0 -54
  127. package/scripts/hook-lock-gate +0 -47
  128. package/scripts/hook-power-tools +0 -38
  129. package/scripts/hook-savepoint-pre +0 -32
  130. package/scripts/lib/codex_edit_gates.rb +0 -138
  131. package/scripts/lib/edit_gates.rb +0 -398
  132. package/scripts/lib/links_gate.rb +0 -140
  133. package/scripts/lib/qmd_hook.rb +0 -41
  134. package/scripts/lib/spec_header.rb +0 -83
  135. package/scripts/lib/start_intent.rb +0 -296
  136. package/scripts/start-intent +0 -89
  137. package/skills/_active-intent-gate.md +0 -26
  138. package/skills/auto/references/tiers.md +0 -100
  139. package/skills/continuing/SKILL.md +0 -34
  140. package/skills/continuing/evals/evals.json +0 -91
  141. package/skills/conventions/references/gates-and-enforcement.md +0 -53
  142. package/skills/conventions/references/tiers-and-dispatch.md +0 -135
  143. package/skills/doctor/references/gates-stuck-detection.md +0 -43
  144. package/skills/intent-brainstorming/SKILL.md +0 -118
  145. package/skills/intent-brainstorming/evals/evals.json +0 -67
  146. package/skills/intent-continuing/evals/evals.json +0 -145
  147. package/skills/intent-discovering/SKILL.md +0 -56
  148. package/skills/intent-grilling/SKILL.md +0 -108
  149. package/skills/intent-linking/SKILL.md +0 -128
  150. package/skills/intent-linking/evals/evals.json +0 -22
  151. package/skills/intent-linking/references/zettelkasten.md +0 -45
  152. package/skills/intent-locking/SKILL.md +0 -64
  153. package/skills/intent-planning/SKILL.md +0 -145
  154. package/skills/intent-planning/evals/evals.json +0 -81
  155. package/skills/intent-planning/references/plan-format.md +0 -130
  156. package/skills/intent-researching/SKILL.md +0 -123
  157. package/skills/intent-researching/evals/evals.json +0 -22
  158. package/skills/intent-savepoint/SKILL.md +0 -83
  159. package/skills/intent-savepoint/references/context-management.md +0 -32
  160. package/skills/intent-starting/SKILL.md +0 -151
  161. package/skills/intent-starting/evals/evals.json +0 -117
  162. package/skills/intent-starting/references/boarding-matrix.md +0 -35
  163. package/skills/project-continuing/SKILL.md +0 -119
  164. package/skills/project-continuing/evals/evals.json +0 -100
  165. package/skills/roadmap-continuing/SKILL.md +0 -89
  166. package/skills/roadmap-continuing/evals/evals.json +0 -82
  167. package/skills/skill-creating/SKILL.md +0 -75
  168. package/skills/skill-creating/evals/evals.json +0 -108
  169. package/skills/skill-creating/references/agents.md +0 -168
  170. package/skills/skill-creating/references/defaults-first.md +0 -23
  171. package/skills/skill-creating/references/evals.md +0 -41
  172. package/skills/skill-creating/references/hooks.md +0 -251
  173. package/skills/skill-creating/references/progressive-disclosure.md +0 -176
  174. package/skills/skill-creating/references/scripts.md +0 -166
  175. package/skills/skill-creating/references/skills.md +0 -169
  176. package/skills/skill-creating/scripts/scaffold.rb +0 -313
  177. package/skills/skill-evaluating/SKILL.md +0 -141
  178. package/skills/skill-evaluating/assets/eval-template.json +0 -12
  179. package/skills/skill-evaluating/evals/evals.json +0 -75
  180. package/skills/skill-evaluating/references/convention-checks.md +0 -76
  181. package/skills/skill-evaluating/references/eval-methodology.md +0 -154
  182. package/skills/store-curating/SKILL.md +0 -64
  183. package/skills/store-curating/evals/evals.json +0 -38
  184. package/skills/store-indexing/SKILL.md +0 -93
  185. package/skills/store-indexing/evals/evals.json +0 -22
  186. package/skills/store-indexing/references/zettelkasten-linking.md +0 -32
  187. package/skills/store-provisioning/SKILL.md +0 -55
  188. /package/skills/{project-continuing → intent-continuing}/references/board-fill.md +0 -0
  189. /package/skills/{roadmap-continuing → intent-continuing}/references/liveness-ranking.md +0 -0
  190. /package/skills/{intent-brainstorming → intent-speccing}/references/design-principles.md +0 -0
@@ -132,13 +132,13 @@
132
132
  "scope": "triggering",
133
133
  "set": "validation",
134
134
  "prompt": "what's the status of my active intents?",
135
- "expected_output": "Does NOT activate plastic-auto; this is a read/intent-continuing/store-indexing query.",
135
+ "expected_output": "Does NOT activate plastic-auto; this is a read/intent-continuing query.",
136
136
  "files": [],
137
137
  "assertions": [
138
138
  {
139
139
  "type": "code",
140
140
  "check": "router CHOICE != plastic-auto",
141
- "observed": "plastic-store-indexing",
141
+ "observed": "plastic-intent-continuing",
142
142
  "result": "pass"
143
143
  }
144
144
  ]
@@ -170,12 +170,12 @@
170
170
  "scope": "behavior",
171
171
  "set": "train",
172
172
  "prompt": "Active intent X exists. Deliver it in auto mode on a harness that supports subagents.",
173
- "expected_output": "Spins up one enforcer-led team per intent (brainstorming, spec-specialist, planner, executor, plastic-enforcer). The enforcer IS the orchestrator. Dispatches one specialist per stage sequentially on one branch, gating each deliverable (Context+Decisions, then spec.md, then plan.md+actions+checklist, then code) against the stage exit criteria before handoff, and dispatches an independent reviewer subagent at the final gate only.",
173
+ "expected_output": "Spins up one enforcer-led team per intent (plastic-enforcer, executor, an on-request reviewer). The enforcer IS the orchestrator: it writes spec.md, the action files, and checklist.md itself, dispatches one executor for the consolidated action on one branch, and dispatches an independent reviewer subagent at the final gate only.",
174
174
  "files": [],
175
175
  "assertions": [
176
176
  {
177
177
  "type": "human",
178
- "check": "five-role roster spun up; specialists dispatched stage-sequentially with per-stage gating; independent reviewer only at final gate",
178
+ "check": "enforcer writes Why and How itself; one executor dispatched; independent reviewer only at final gate",
179
179
  "observed": "dogfood: intents 60-62 delivered by exactly this enforcer-led team on a shared branch",
180
180
  "result": "pass"
181
181
  },
@@ -208,13 +208,13 @@
208
208
  "scope": "behavior",
209
209
  "set": "validation",
210
210
  "prompt": "A power-tool is present (qmd on PATH, or a .serena marker / serena on PATH). A substantive prompt arrives in auto mode.",
211
- "expected_output": "The UserPromptSubmit power-tools hook appends a MANDATORY obligation per present tool: a MUST-use-QMD line when qmd is present (to check for an existing or related intent before treating work as new), and a MUST-use-Serena line when serena is present (symbolic tools before grep/Read). No search hits are injected: intent 246 removed the per-prompt qmd hit search, so the hook emits the mandate and nothing else.",
211
+ "expected_output": "The agent prefers the present tool because PLASTIC.md (loaded at session start) recommends QMD for intents and Enola, or Serena when Enola is absent, for code navigation. No hook appends a per-prompt line: the power-tools hook was removed in 2.0 (intent 309).",
212
212
  "files": [],
213
213
  "assertions": [
214
214
  {
215
215
  "type": "code",
216
- "check": "PowerTools.mandate returns MUST/MANDATORY lines for each present tool; QmdHook.run appends the mandate",
217
- "observed": "power_tools_test.rb + qmd_hook_test.rb assert MUST wording; serena line gated on the serena detector; qmd_hook_test.rb test_no_retrieval_hits_are_ever_injected asserts no hit header for any tool combination",
216
+ "check": "PLASTIC.md carries the recommendation (doctrine_305_test) and PowerTools presence probes still back doctor's readiness checks (power_tools_test.rb)",
217
+ "observed": "doctrine_305_test test_plastic_md_carries_the_power_tools_mandate_as_a_recommendation; power_tools_test.rb presence probes",
218
218
  "result": "pass"
219
219
  }
220
220
  ]
@@ -224,13 +224,13 @@
224
224
  "scope": "behavior",
225
225
  "set": "validation",
226
226
  "prompt": "Neither qmd nor serena is present (no qmd on PATH, no .serena marker, no serena on PATH). A substantive prompt arrives.",
227
- "expected_output": "Detect-then-degrade: the hook emits nothing (silent no-op, exit 0). No mandate text appears. Nothing is required to install.",
227
+ "expected_output": "Detect-then-degrade: PLASTIC.md's recommendation applies only when a tool is present, so nothing is required to install and no per-prompt line appears (there is no hook to emit one since intent 309).",
228
228
  "files": [],
229
229
  "assertions": [
230
230
  {
231
231
  "type": "code",
232
- "check": "PowerTools.mandate returns nil and QmdHook.run returns nil when neither tool is present",
233
- "observed": "power_tools_test.rb test_mandate_neither_is_nil + qmd_hook_test.rb test_nil_when_neither_tool_present",
232
+ "check": "PowerTools.mandate returns nil when neither tool is present",
233
+ "observed": "power_tools_test.rb test_mandate_neither_is_nil",
234
234
  "result": "pass"
235
235
  }
236
236
  ]
@@ -12,68 +12,66 @@ The Main Orchestrator manages the global store (Main Knowledge Base). It:
12
12
 
13
13
  Project Orchestrators manage project stores (Project Knowledge Bases). They:
14
14
  - Care about intents and execution within their project
15
- - Spin up an enforcer-led team to deliver an intent
15
+ - Lead an auto team to deliver an intent
16
16
  - Contribute back to the Main Orchestrator when new intents are born
17
17
  that could enrich the Main Knowledge Base
18
18
 
19
19
  ## The Auto-Mode Team
20
20
 
21
- Auto mode spins up exactly ONE enforcer-led team per intent. The plastic-enforcer
22
- IS the auto orchestrator itself, not a separately dispatched agent. Making the
23
- orchestrator the enforcer avoids the who-gates-the-gater regress (the gate-keeper
24
- can never be ungated).
21
+ Auto mode runs exactly ONE team per intent, led by the orchestrating session itself: the
22
+ plastic-enforcer IS the lead, not a separately dispatched agent. The team has two standing
23
+ roles plus two reviewer prompts dispatched as fresh agents (the four stage agents were removed
24
+ in 2.0, intent 304; the lead writes the Why and How record itself):
25
25
 
26
- The team has five roles, one per place in the What, Why, How, Exec cycle:
26
+ - **plastic-enforcer** (the lead, spans the whole cycle): takes the intent, writes `spec.md`,
27
+ `plan.md`, the action files with their failure-mode matrix, and `checklist.md`; has the plan
28
+ reviewed before code; dispatches the executor; applies the risk rule; closes.
29
+ - **plastic-executor** (Exec): commits the matrix's tests red, writes the code, checks off
30
+ `checklist.md`, appends `## Insights`, and drives the suite green.
31
+ - **the plan reviewer**: a fresh agent on `plastic-intent-executing`'s
32
+ `plan-reviewer-prompt.md`, dispatched once before any code exists.
33
+ - **the post-execution reviewer**: a fresh agent on `code-quality-reviewer-prompt.md`,
34
+ dispatched only when the auto skill's risk rule fires; never the maker.
27
35
 
28
- - **plastic-brainstorming** (Why exploration): enriches `## Context` and records
29
- `### Decisions` with rationale.
30
- - **plastic-spec-specialist** (Why-to-How boundary): consolidates the Why into
31
- `spec.md` (Problem, Goals, Non-Goals, Approach, Decisions, Acceptance Criteria).
32
- - **plastic-planner** (How): produces `plan.md`, `actions/ACTION_N.md`, and
33
- `checklist.md`.
34
- - **plastic-executor** (Exec): writes the code, checks off `checklist.md`, appends
35
- `## Insights`, and drives the suite green.
36
- - **plastic-enforcer** (spans the whole cycle): orchestrates and gates.
36
+ Two agent boots is the normal delivery (the plan reviewer, the executor); the post-execution
37
+ reviewer is the third only when risk calls for it.
37
38
 
38
39
  ### Handoff Contracts
39
40
 
40
- Each specialist receives the prior stage's deliverable and produces the next stage's
41
- input. The enforcer dispatches one specialist per stage with a constructed context
42
- bundle, gates that deliverable against the stage's exit criteria, and only then hands
43
- off to the next stage. Dispatch is sequential on a single branch, because the stage
44
- deliverables share files (a parked spec, plan, and checklist all live in the same
45
- intent directory).
41
+ The lead hands the executor one constructed context bundle: the spec decisions, the plan, the
42
+ action files with their matrix, the checklist, and the worktree path. The executor hands back
43
+ the code, the red and green commits, a checked-off checklist, `## Insights`, and its completion
44
+ report. Dispatch is sequential on a single branch, because the deliverables share files.
46
45
 
47
- The chain: intent `## Intent` / `## Context`, then enriched `## Context` plus
48
- `### Decisions`, then `spec.md`, then `plan.md` plus `actions/` plus `checklist.md`,
49
- then the code changes plus a checked-off checklist plus `## Insights`.
46
+ The chain: intent `## Intent` / `## Context`, then enriched `## Context` plus `### Decisions`,
47
+ then `spec.md`, then `plan.md` plus `actions/` plus `checklist.md`, then the plan review, then
48
+ the code changes plus a checked-off checklist plus `## Insights`.
50
49
 
51
50
  ### Spawn Preamble (L2 live-state injection)
52
51
 
53
- Every dispatched specialist is booted with a spawn preamble: the enforcer runs
54
- `scripts/spawn-preamble <intent_dir> --role <role>` and prepends its output to the
55
- specialist's prompt. The preamble is a pure function of the intent directory on disk
56
- (no network, no clock, no randomness), so it is deterministic and rebuildable. It
57
- carries the active intent id and intent line, the current lifecycle stage (the last
58
- savepoint line, else stage derived from which lifecycle files exist), the cycle
59
- role, and the honoring instruction that the agent must emit valid lifecycle artifacts
60
- and not hallucinate intents or stages. This is the standard L2 live-state mechanism
61
- for harnesses whose spawned sub-agents do not inherit the top-level session event. See
62
- [`harness-adapters.md`](https://github.com/zalom/plastic/blob/main/docs/reference/harness-adapters.md) for how it slots into the per-harness contract.
52
+ Every dispatched agent is booted with a spawn preamble: the lead runs
53
+ `scripts/spawn-preamble <intent_dir> --role <role>` and prepends its output to the agent's
54
+ prompt. The preamble is a pure function of the intent directory on disk (no network, no clock,
55
+ no randomness), so it is deterministic and rebuildable. It carries the active intent id and
56
+ intent line, the current lifecycle stage (the last savepoint line, else the stage derived from
57
+ which lifecycle files exist), the cycle role, and the honoring instruction that the agent must
58
+ emit valid lifecycle artifacts and not hallucinate intents or stages. This is the standard L2
59
+ live-state mechanism for harnesses whose spawned sub-agents do not inherit the top-level
60
+ session event. See [`harness-adapters.md`](https://github.com/zalom/plastic/blob/main/docs/reference/harness-adapters.md) for how it slots into the per-harness contract.
63
61
 
64
62
  ### Completion Reports
65
63
 
66
- Every dispatched specialist ends its turn with a structured completion report as its final
67
- message (its return value), so the agent that did the work is the one that accounts for it. The
68
- report carries a common envelope plus a role-specific payload that fulfils the agent's place in
69
- the cycle; the planner explains the plan back to the orchestrator, the executor reports what was
70
- built and the test result, and so on. The format lives in `references/agent-report-contract.md`,
71
- and the verbatim instruction is injected once via the spawn preamble's `REPORT_CONTRACT`
72
- constant, which the role prompts reproduce.
64
+ Every dispatched agent ends its turn with a structured completion report as its final message
65
+ (its return value), so the agent that did the work is the one that accounts for it. The report
66
+ carries a common envelope plus a role-specific payload that fulfils the agent's place in the
67
+ cycle; the executor reports what was built and the test result, a reviewer reports its verdict
68
+ and findings. The format lives in `references/agent-report-contract.md`, and the verbatim
69
+ instruction is injected once via the spawn preamble's `REPORT_CONTRACT` constant, which the
70
+ role prompts reproduce.
73
71
 
74
72
  Enforcement is require-report then synthesize-fallback. The preamble and prompts make the report
75
73
  mandatory (decision-shaping), but child-agent honor is best-effort across harnesses (Tier B/C),
76
- so it is never a hard block. When a specialist returns no usable report, the enforcer runs
74
+ so it is never a hard block. When an agent returns no usable report, the lead runs
77
75
  `scripts/agent-report <intent_dir> --role <role>`, a pure function of the intent dir (no network,
78
76
  clock, or randomness, mirroring `spawn-preamble`) that emits a filesystem-derived report from the
79
77
  savepoint, the artifacts present, the checklist checked/total, and the outcome line. A handoff
@@ -81,77 +79,82 @@ account therefore always exists: agent-authored when present, deterministically
81
79
  otherwise. This structures the finish notification only; in-flight observations stay in
82
80
  `## Insights`, no progress chatter is added.
83
81
 
84
- Immediately after a specialist returns and before the next handoff, the enforcer records the
82
+ Immediately after an agent returns and before the next handoff, the lead records the
85
83
  delegate's activity through `plastic-lock delegate --intent-dir <intent-dir> --delegate <id>
86
84
  --status finished|failed`. `finished` requires a usable agent-authored or synthesized completion
87
85
  report. A blocked or errored return, or one with no report that can be synthesized, is `failed`
88
86
  and stops the handoff under the normal error procedure. Activity status is descriptive and does
89
87
  not revoke the registered delegate's authorization.
90
88
 
91
- ### Gate Ownership
89
+ ### Review Ownership
92
90
 
93
- The enforcer arms and verifies the lifecycle gate, then gates every stage transition.
94
- It never delegates gate ownership. At the final gate only, it dispatches an
95
- INDEPENDENT reviewer subagent to review the delivered work. That reviewer is not a
96
- permanent sixth role, it exists only for the final review.
91
+ The lead owns every review decision: it dispatches the plan reviewer before code, folds the
92
+ findings itself, and decides from the risk rule whether the post-execution reviewer runs. It
93
+ never delegates that decision, and neither reviewer is ever the maker of what it reviews.
94
+ Nothing blocks a write in 2.0 (the gate hooks were removed, intent 302); the lock, the
95
+ worktree, and the record are how the team keeps one delivery in one place.
97
96
 
98
- ### Headless Manual Gate
97
+ ### The risk list
99
98
 
100
- When running headless or in the background, the enforcer enforces gates manually rather
101
- than relying on hooks alone. The savepoint ledger and PostToolUse gate hook still fire
102
- (the gate hook reads `session_id` from stdin; the savepoint write is path-derived and
103
- bridge-independent), so they do not blanket no-op. Only the bridge-keyed stage-enforcement
104
- step degrades when no session id reaches the bridge and no bridge is discovered. The
105
- enforcer arms via `CLAUDE_CODE_SESSION_ID` or the bridge's derived-key fallback and
106
- verifies state itself.
99
+ The post-execution reviewer runs when the executor's diff touches any of these paths, or when
100
+ the auto skill's other two risk clauses fire:
101
+
102
+ - `hooks/`, `scripts/hook-*`, `scripts/lib/hook_registry.rb`
103
+ - `scripts/lib/lock.rb`, `scripts/lib/arm.rb`, `scripts/plastic-lock`, `scripts/end-intent`
104
+ - `scripts/lib/installer_core.rb`, `scripts/install*`, `scripts/update.rb`
105
+ - `package.json`, `.claude-plugin/*.json`, `CHANGELOG.md`
106
+
107
+ Grow this list here, not in the skill body.
108
+
109
+ ### Headless Note
110
+
111
+ In a headless or background run the session id may be unset. `plastic-lock arm` then keys the
112
+ lock by a derived session key, the record hook still writes the savepoint ledger from the
113
+ written path, and the lead verifies state from the files (`plastic-lock status`,
114
+ `savepoint.md`, the diff) rather than from a hook it assumes fired.
107
115
 
108
116
  ### Delegation
109
117
 
110
- The roles are thin handoff contracts, not a spawning engine. Dispatch and review run
111
- by default through Plastic's own engine, `plastic-intent-executing` (implementer plus
112
- two-stage review, no external plugin). When `superpowers:subagent-driven-development`
113
- and `superpowers:dispatching-parallel-agents` are available, or the user asks for them,
114
- they delegate to those as an enhancement. The team model defines who hands what to whom
115
- and where the gates sit; the dispatch engine, native or superpowers, does the actual
116
- spawning.
118
+ The roles are thin handoff contracts, not a spawning engine. Dispatch runs through Plastic's
119
+ own engine, `plastic-intent-executing`: one executor for the consolidated action, the two
120
+ reviewer prompts as fresh agents. The team model defines who hands what to whom and where the
121
+ reviews sit; the engine does the actual spawning.
117
122
 
118
123
  ### Fallback by Case
119
124
 
120
- The default is always Plastic's native engine, so a user without superpowers still gets
121
- the full behavior. If the harness supports subagents but superpowers is absent, auto
122
- mode dispatches through `plastic-intent-executing`. If the harness has no subagent dispatch
123
- at all, auto mode falls back to a single agent walking the full What, Why, How, Exec
124
- cycle itself. The enforcer's gate discipline still applies in every case.
125
+ If the harness supports agent dispatch, auto mode dispatches through
126
+ `plastic-intent-executing`. If the harness has no agent dispatch at all (Codex CLI today), the
127
+ lead walks the five steps itself: it still writes the matrix and the tests first, and reviews
128
+ its own plan against the matrix before code, saying so in `## Insights`.
125
129
 
126
130
  ### Dogfood Proof
127
131
 
128
- Intents 60, 61, and 62 were delivered by exactly this enforcer-led team on a shared
129
- branch, which is the dogfooded proof that the model works end to end.
132
+ Intents 60, 61, and 62 were delivered by the enforcer-led team on a shared branch, and the
133
+ simplify-plastic roadmap's batch 2 (intents 302 to 306) was delivered in the ruled two-boot
134
+ shape: the lead wrote the matrix, one adversarial plan reviewer read it, the lead built inline
135
+ tests first, one suite run per intent.
130
136
 
131
137
  ## Two Modes
132
138
 
133
- - **Human-driven:** Human chats with the Main Orchestrator, creates intents,
134
- brainstorms, then the Main Orchestrator dispatches Project Orchestrators and teams
135
- for execution.
136
- - **Autonomous:** Human gives the Main Orchestrator a starting intent with defined
137
- outcomes. The enforcer-led team runs the full cycle (the specialists do the
138
- lifecycle, the enforcer reviews Insights and gates), then the orchestrator spawns
139
- next intents and dispatches again.
139
+ - **Human-driven:** Human chats with the Main Orchestrator, creates intents, thinks them
140
+ through, then the Main Orchestrator dispatches Project Orchestrators and teams for execution.
141
+ - **Autonomous:** Human gives the Main Orchestrator a starting intent with defined outcomes.
142
+ The auto team runs the full cycle, then the orchestrator spawns next intents and dispatches
143
+ again.
140
144
 
141
145
  ## Autonomous Delivery
142
146
 
143
- Human owns What and Why for human-initiated intents. The team assists (research,
144
- exploration) but the human drives until handoff. When Why is complete, or the human
145
- triggers `plastic-auto`, the enforcer-led team takes over How and Exec autonomously.
146
-
147
- - **Safe-by-default:** the executor always prefers non-destructive routes (rename vs
148
- delete, additive migrations, backups before changes). Destructive actions on
149
- existing projects require human approval unless `--skip-permissions` is set.
150
- - **Notification only on:** finish or hard stop (blocked on destructive action,
151
- unresolvable error). No progress reports, `## Insights` tracks everything.
152
- - **Greenfield autonomy:** during initial project creation, all decisions are
153
- non-destructive (nothing to destroy), so the team has full autonomy for greenfield
154
- choices.
147
+ Human owns What and Why for human-initiated intents. The team assists (research, exploration)
148
+ but the human drives until handoff. When Why is complete, or the human triggers `plastic-auto`,
149
+ the auto team takes over How and Exec autonomously.
150
+
151
+ - **Safe-by-default:** the executor always prefers non-destructive routes (rename vs delete,
152
+ additive migrations, backups before changes). Destructive actions on existing projects
153
+ require human approval unless `--skip-permissions` is set.
154
+ - **Notification only on:** the How briefing, finish, or hard stop (blocked on destructive
155
+ action, unresolvable error). No progress reports, `## Insights` tracks everything.
156
+ - **Greenfield autonomy:** during initial project creation, all decisions are non-destructive
157
+ (nothing to destroy), so the team has full autonomy for greenfield choices.
155
158
  - **Autonomous decisions** are logged in `## Insights` with the `(autonomous)` marker.
156
159
 
157
160
  ## Coordinator Loop
@@ -162,4 +165,13 @@ When "work on Project X":
162
165
  3. Load project config (overrides)
163
166
  4. Load global INDEX.md, find hub intents tagged `project-<name>`
164
167
  5. Load project INDEX.md, find tactical intents
165
- 6. The coordinator has the full picture, spins up an enforcer-led team per intent
168
+ 6. The coordinator has the full picture, leads an auto team per intent
169
+
170
+ ## Spawn preamble (intent 152)
171
+
172
+ `scripts/spawn-preamble` emits a live-state block purely from filesystem state: the active
173
+ intent, stage, role/cycle-step, the honor instruction, and the report contract. When the
174
+ intent's code worktree is resolvable and exists on disk, it also appends the worktree's
175
+ absolute path plus a verbatim instruction to `cd` there directly, for harnesses whose
176
+ `EnterWorktree` cannot discover a nested repo from a non-repo launch directory. Output is
177
+ byte-identical when no worktree resolves.
@@ -29,7 +29,7 @@ fields stay exactly as below); it does not remove any required field.
29
29
 
30
30
  Every role report, whatever the stage, carries these fields:
31
31
 
32
- - **Role**: which specialist produced this (brainstorming, spec, planner, executor, reviewer).
32
+ - **Role**: which agent produced this (executor, plan reviewer, post-execution reviewer).
33
33
  - **Intent id and stage**: the active intent id and the cycle stage just completed.
34
34
  - **Status**: `delivered` or `blocked`.
35
35
  - **Artifacts written**: the files produced or changed (store paths, and project paths for the
@@ -53,26 +53,9 @@ Multi-item payload fields (ordered actions, insights, checklist deltas) default
53
53
  Each role appends a payload that fulfils its place in the What, Why, How, Exec cycle (decision
54
54
  D2). The payload is what makes the report useful to the orchestrator beyond the envelope.
55
55
 
56
- ### brainstorming (Why exploration)
57
- - Decisions recorded in `### Decisions`, each with its one-line rationale.
58
- - Context enriched: what was researched and the key findings.
59
- - Open questions resolved, and any deliberately left for the spec.
60
- - Insights: durable discoveries from the Why exploration, reported in the `insights:` field.
61
-
62
- ### spec-specialist (Why to How boundary)
63
- - Spec sections produced (Problem, Goals, Non-Goals, Approach, Decisions, Acceptance Criteria).
64
- - How the recorded decisions resolved into the chosen approach.
65
- - Acceptance-criteria count, so the planner knows the surface to cover.
66
- - Insights: durable discoveries from consolidating the spec, reported in the `insights:` field.
67
-
68
- ### planner (How): worked exemplar
69
- The planner report EXPLAINS THE PLAN BACK TO THE ORCHESTRATOR. It carries:
70
- - The ordered actions, one line each: what the action does and how it is verified.
71
- - Decomposition rationale: why this order, and why the actions are independent.
72
- - Checklist coverage: item count and that every action plus suite-green is covered.
73
- This is the exemplar because the plan is an argument, and the orchestrator gates on whether that
74
- argument is sound before any code is written.
75
- - Insights: durable discoveries from planning, reported in the `insights:` field.
56
+ The stage-agent role sections (brainstorming, spec-specialist, planner) were removed in 2.0
57
+ (intent 304): the orchestrator writes the Why and How artifacts itself and reports nothing to
58
+ itself. Two dispatched roles remain.
76
59
 
77
60
  ### executor (Exec)
78
61
  - Actions implemented this turn, mapped to checklist items checked off (checked / total).
@@ -1,72 +1,66 @@
1
- # End-Tail Mechanics: resolve_session and Disarm Ordering
1
+ # End-Tail Mechanics: Arm.disarm and the Ordering
2
2
 
3
- Deep WHY/mechanics detail behind two spots in `SKILL.md`: how `arm_auto` resolves a
4
- session id when arming the gate, and why the End-tail steps in Completion (release
5
- worktrees, clear the lock, purge the bridge, reindex) run in that exact order.
3
+ Deep mechanics behind two spots in `SKILL.md`: how `plastic-lock arm` resolves a session id
4
+ when it takes an intent, and why the End-tail steps in Completion (release the worktree, clear
5
+ the lock, reset the pointer, reindex) run in that exact order. The `/tmp` bridge JSON these
6
+ steps once also purged was removed in 2.0 (intent 307); `scripts/lib/arm.rb` is what remains.
6
7
 
7
8
  ## Table of Contents
8
9
 
9
- - [resolve_session fallback internals](#resolve_session-fallback-internals)
10
+ - [Session resolution](#session-resolution)
10
11
  - [Disarm ordering and worktree cleanup rationale](#disarm-ordering-and-worktree-cleanup-rationale)
11
12
  - [QMD reindex ordering rationale](#qmd-reindex-ordering-rationale)
12
13
 
13
- ## resolve_session fallback internals
14
+ ## Session resolution
14
15
 
15
- `arm_auto` calls `resolve_session`, which picks the first non-empty of: the explicit
16
- id you pass -> `CLAUDE_CODE_SESSION_ID` -> a deterministic derived key (a hash of the
17
- store and intent id). It never returns nil, so the gate engages even when every
18
- session env var is empty; the call never needs a non-empty session env var to
19
- function. Arming prints a one-line notice to stderr when it falls through to the
20
- derived key.
16
+ `Arm.resolve_session` picks the first non-empty of: the explicit id (`--session`, or the hook
17
+ stdin `session_id` when a caller has it), the `CLAUDE_CODE_SESSION_ID` the CLI read, then a
18
+ deterministic derived key (a hash of the store and the intent id). It never returns nil, so
19
+ the arm verb works even when every session variable is empty; a session-less arm and a later
20
+ session-less close resolve to the same key.
21
21
 
22
- Arming acquires the durable `delivery.lock` in the intent dir, keyed by that resolved
23
- session. Ownership is session-keyed, not process-keyed, so the arm one-liner exiting
24
- immediately is fine by construction: the lock stays yours for every later tool call in
25
- this session. A failed arm raises with a message naming the resolving `plastic-lock`
26
- verb.
22
+ Arming acquires the durable `delivery.lock` in the intent dir, keyed by that resolved session
23
+ and stamped with `run_mode`. Ownership is session-keyed, not process-keyed, so the arm command
24
+ exiting is fine by construction: the lock stays yours for every later tool call in this
25
+ session, and the record hook refreshes its lease on every write you make. The same call writes
26
+ the intent id into the session pointer (`~/.plastic/store/.tmp/<session>/current`), which is
27
+ why the capture and record hooks stop treating your prompts as day-ledger items for the rest
28
+ of the delivery.
27
29
 
28
30
  ## Disarm ordering and worktree cleanup rationale
29
31
 
30
- Disarm runs the ordered End tail: it releases the worktrees first, then clears the
31
- intent's `delivery.lock` (and the bridge's lock cache), and only then is the bridge
32
- purge-eligible. Disarming also purges stale bridge files from the temp directory
33
- automatically (it keeps the current bridge, any live run, and any bridge whose intent
34
- still holds a delivery lock), so no manual `/tmp` cleanup is needed.
32
+ `Arm.disarm` runs the ordered End tail: it releases the worktree first, then clears the
33
+ intent's `delivery.lock` as its recorded owner, and only then resets the session pointer to
34
+ today's day id (when it still names this intent). The worktree goes first so a released lock
35
+ never points at a checkout another session could claim; the pointer goes last so the record
36
+ hook keeps heartbeating the lock until the lock is gone.
35
37
 
36
- **Mechanized since intent 188.** `scripts/end-intent` performs this disarm itself, as its
37
- own step 5, after steps 1-4 (outcome/INDEX/savepoint/commit) commit. No agent needs to run
38
- a separate `Bridge.disarm_auto` one-liner any more on the auto mode / curator path: the
39
- single `end-intent` call in `SKILL.md`'s Completion section already does it. A pre-flight
40
- lock guard (before anything is written) refuses on a live foreign session (exit 4) and
41
- reclaims a stale foreign lock automatically (audited to savepoint.md); a dirty code
42
- worktree refuses before removal (exit 5, `--discard-worktree-changes` overrides
43
- deliberately); and the durable lock file is checked again after disarm, never merely
44
- trusted (exit 3 if it is somehow still present).
38
+ **Mechanized since intent 188.** `scripts/end-intent` performs this disarm itself, as its own
39
+ step 5, after steps 1-4 (outcome/INDEX/savepoint/commit) commit. A pre-flight lock guard
40
+ refuses on a live foreign session (exit 4) and reclaims a stale foreign lock automatically
41
+ (audited to savepoint.md); a dirty code worktree refuses before removal (exit 5,
42
+ `--discard-worktree-changes` overrides deliberately); and the durable lock file is checked
43
+ again after disarm, never merely trusted (exit 3 if it is somehow still present).
45
44
 
46
- **Worktree cleanup (mandatory, intent 73c3).** `end-intent`'s step 5 calls
47
- `Bridge.disarm_auto` by default, which calls `Worktree.release`, which removes the
48
- intent's code worktree under `<repo>/.claude/worktrees/{id}--{slug}`, prunes the repo, and
49
- clears the worktree block from the bridge. (Plastic used to also provision a paired store
50
- worktree under `<plastic_home>/.worktrees/{id}--{slug}`; intent 178 retired it, since
51
- lifecycle-doc writes go straight to the main store checkout, and intent 197's
52
- branch-from-main plus scoped commit already gives them their own write safety.) This is the
53
- plain remove path: the disarm route does NOT merge, so use it only when no release merges
54
- the branch (the branch survives and can be reclaimed).
45
+ **Worktree cleanup (mandatory, intent 73c3).** `end-intent`'s step 5 calls `Arm.disarm` by
46
+ default, which calls `Worktree.release` on the block `Arm.worktree_block` derives from
47
+ `projects.yml` and the intent id, removing the intent's code worktree under
48
+ `<repo>/.claude/worktrees/{id}--{slug}` and pruning the repo. This is the plain remove path:
49
+ the disarm route does NOT merge, so use it only when no release merges the branch (the branch
50
+ survives and can be reclaimed).
55
51
 
56
52
  When the work is being shipped through a release, do NOT rely on this plain remove.
57
- `skills/releasing/SKILL.md` reorders its own two steps for exactly this reason (intent 188,
58
- D7): its worktree-merge step now runs BEFORE its `end-intent` call, merging the intent's
59
- code branch (`plastic/{id}--{slug}`) back to the repo's default branch BEFORE the worktree
60
- is removed, via `Worktree.finish(bridge_data, merge: true)` (merge-then-remove), so the
61
- integrated work is not lost. By the time `end-intent`'s own step 5 runs afterward, the
62
- worktree is already gone (a harmless no-op) and only the delivery lock is left to clear,
63
- correctly, for the first time on that path. Never leave an orphaned worktree, and run
64
- `git worktree prune` if you hit a stale reference.
53
+ `skills/releasing/SKILL.md` runs its worktree-merge step BEFORE its `end-intent` call, merging
54
+ the intent's code branch (`plastic/{id}--{slug}`) back to the repo's default branch BEFORE
55
+ the worktree is removed, via `Worktree.finish(Arm.bridge_hash(intent_dir: ...), merge: true)`
56
+ (merge-then-remove), so the integrated work is not lost. By the time `end-intent`'s own step 5
57
+ runs afterward, the worktree is already gone (a harmless no-op) and only the delivery lock and
58
+ the pointer are left to clear. Never leave an orphaned worktree, and run `git worktree prune`
59
+ if you hit a stale reference.
65
60
 
66
61
  ## QMD reindex ordering rationale
67
62
 
68
- Completion is the lifecycle event that keeps the search index fresh. `<store-root>` is
69
- the store that holds this intent (the global store or the project store). The reindex is
70
- the LAST End-tail step, run after purge, so the index never references a bridge or lock
71
- that is about to disappear (see PLASTIC.md `## Delivery Isolation and the Single-Owner
72
- Lock`).
63
+ Completion is the lifecycle event that keeps the search index fresh. `<store-root>` is the
64
+ store that holds this intent (the global store or the project store). The reindex is the LAST
65
+ End-tail step, run after the disarm, so the index never references a lock that is about to
66
+ disappear.
@@ -1,8 +1,8 @@
1
1
  # Human Report Contract (per-stage EM-to-CTO briefing)
2
2
 
3
3
  This doc defines how the orchestrator briefs the human at each of the five stage boundaries
4
- (What, Why, How, Exec, Done) in auto mode, at M and L; at S only the How boundary fires (see
5
- `## Depth at Tier S`). It is the outward, human-facing counterpart to the
4
+ (What, Why, How, Exec, Done) in auto mode; for small work only the How boundary fires (see
5
+ `## Depth for small work`). It is the outward, human-facing counterpart to the
6
6
  internal report contract in `references/agent-report-contract.md`. Voice: an engineering
7
7
  manager briefing a CTO. Lead with impact, name the risk, leave the decision.
8
8
 
@@ -30,12 +30,12 @@ short. The words can flex to fit the stage.
30
30
  - **Done**: State = the delivered impact. Risk = residual risk. Call = the decision left to you
31
31
  (merge, release, accept).
32
32
 
33
- ## Depth at Tier S
33
+ ## Depth for small work
34
34
 
35
- At Tier S in auto mode the mid-flight briefings collapse to one. Only the How briefing fires, and
35
+ For small work in auto mode the mid-flight briefings collapse to one. Only the How briefing fires, and
36
36
  it folds in what the What and Why briefings would have said: the work picked up and the approach
37
- chosen go into its State line. The Exec briefing folds into the final owner report at End. M and L
38
- send all four. The shape does not change: still State, then Risk, then Call, and the per-stage
37
+ chosen go into its State line. The Exec briefing folds into the final owner report at End. Larger
38
+ work sends all four. The shape does not change: still State, then Risk, then Call, and the per-stage
39
39
  content above still says what each line covers. This is a depth cut, not a new report. A delivery
40
40
  still ends with `outcome.md` plus one owner report.
41
41
 
@@ -66,7 +66,7 @@ Apply the `writing-style` skill for the wording.
66
66
  In guided mode, the briefing lands at each stage boundary and the human acts on the Call line
67
67
  before the next stage starts.
68
68
 
69
- In auto mode, at M and L the orchestrator still emits the briefing at each boundary, as a running
70
- EM-to-CTO account. At S only the How briefing fires; see `## Depth at Tier S` above for what it
69
+ In auto mode, for larger work the orchestrator still emits the briefing at each boundary, as a
70
+ running EM-to-CTO account. For small work only the How briefing fires; see `## Depth for small work` above for what it
71
71
  folds in. The Call line becomes the go-ahead the orchestrator takes itself and moves on, except at
72
72
  the existing hard stops (destructive action without a safe alternative, project-path confirm).
@@ -2,7 +2,7 @@
2
2
  name: plastic-conventions
3
3
  description: >
4
4
  Chapters of Plastic doctrine used by more than one skill: the knowledge graph,
5
- lifecycle and savepoints, tiers and dispatch, gates and enforcement, locks and
5
+ lifecycle and savepoints, locks and
6
6
  worktrees, completion, maintenance, and roadmaps. Read a chapter when its trigger
7
7
  applies to the work in front of you.
8
8
  user-invocable: false
@@ -18,8 +18,6 @@ when the trigger in the second column applies to the work in front of you.
18
18
  |---|---|
19
19
  | `references/knowledge-graph.md` | when creating, linking, curating, or indexing intents and you need the sources-vs-chain doctrine, the tiers of influence, the `## Links` projection, or branch-vs-root directory semantics |
20
20
  | `references/lifecycle-and-savepoints.md` | when running a lifecycle stage or a savepoint and you need the subagent report-home contract for how an insight reaches the intent |
21
- | `references/tiers-and-dispatch.md` | when sizing an intent, choosing agent models, routing to the advisor, or writing an auto-mode human report |
22
- | `references/gates-and-enforcement.md` | when a transition gate blocks you, or before using an audited escape, for the gate mechanics and the logging contract, or when naming, registering, or retiring a hook or skill |
23
21
  | `references/locks-and-worktrees.md` | before taking or releasing a delivery lock, and when working with claims, worktrees, solo mode, or the station ledger |
24
22
  | `references/completion-and-done.md` | when ending an intent, for what "intent done" means and the End-stage tail |
25
23
  | `references/maintenance-and-revisions.md` | before any structural maintenance edit, for WORK vs MAINTENANCE, the `revisions.md` move-and-record contract, the violation-tag catalog, and the context-economy measurement buckets |
@@ -1,6 +1,40 @@
1
1
  # Lifecycle and Savepoints
2
2
 
3
- This chapter holds the subagent report-home depth for how an insight reaches the intent when the writer cannot write the file itself.
3
+ This chapter holds two things: what an intent records while the work runs versus what is
4
+ backfilled when it ends, and how an insight reaches the intent when the writer cannot
5
+ write the file itself.
6
+
7
+ ## The live record and the backfilled documents
8
+
9
+ While working, an intent records four things, and only these are its truth of what
10
+ happened:
11
+
12
+ - the intent file: `## Context` and `### Decisions` (written in Why) and `## Insights`
13
+ (one line per ruling, appended as it happens);
14
+ - checklist.md: the items, ticked as they are actually performed;
15
+ - savepoint.md: the append-only stage ledger, written by the hooks and the scripts;
16
+ - the commits on the intent's branch.
17
+
18
+ The four judgment documents (spec.md, plan.md, actions/, outcome.md) are written when
19
+ there is something to say. In thinking mode an agent writes them during Why and How. In
20
+ direct mode they usually stay as the scaffold placeholder until the close, and
21
+ `scripts/end-intent` then backfills each one still missing or still a placeholder from
22
+ the live record (intent 308): `## Problem` from `## Intent`, `## Decisions` from
23
+ `### Decisions`, `## Acceptance Criteria`, `## Steps`, `## Items`, `## Delivered`, and
24
+ `## Follow-ups` from the checklist, `## Notes` from `## Insights`, `## Verification` from
25
+ the diff on the intent's own worktree, and outcome.md's `disposition:` from the close.
26
+ Every other section keeps the template's stub text; nothing is invented. A backfilled
27
+ file carries a marker comment on the line after its title, and the savepoint gains one
28
+ `Exec backfilled <list>` line. A file with hand-written content, even under a leftover
29
+ sentinel line, is never touched. The same writer is exposed as `scaffold-intent backfill`
30
+ for the doctor fix hint `backfilled_complete`.
31
+
32
+ The close never refuses for a document it can write itself. Doctor's per-intent structure
33
+ check runs after the backfill as a report: an unchecked box, a malformed intent file, or
34
+ a wrong-disposition outcome.md is named on stderr, the close proceeds, and
35
+ `/plastic-doctor --intent <id>` keeps reporting it until fixed.
36
+
37
+ ## Insights from a writer that cannot write the file
4
38
 
5
39
  Background sessions and dispatched sub-agents do not write the insight themselves. They carry
6
40
  each nugget home in the completion report's `insights:` field, and the orchestrator (or any