@zalom/plastic 1.8.0 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/PLASTIC.md +94 -556
  2. package/README.md +18 -6
  3. package/agents/plastic-enforcer.md +3 -2
  4. package/agents/plastic-intent-curator.md +2 -2
  5. package/agents/plastic-intent-discovery.md +7 -0
  6. package/bin/plastic.js +17 -8
  7. package/deprecations.yml +10 -2
  8. package/hooks/auto-arm +2 -2
  9. package/hooks/bash-gate +1 -1
  10. package/hooks/check-update +1 -1
  11. package/hooks/continue +2 -2
  12. package/hooks/edit-gates +3 -0
  13. package/hooks/future-intent-check +2 -2
  14. package/hooks/gate-check +3 -3
  15. package/hooks/hooks.json +4 -44
  16. package/hooks/power-tools +8 -0
  17. package/hooks/session-start +1 -1
  18. package/package.json +1 -2
  19. package/scripts/codex-hook +57 -118
  20. package/scripts/doctor.rb +146 -1012
  21. package/scripts/exec-worktree +103 -0
  22. package/scripts/hash-intent +1 -1
  23. package/scripts/hook-bash-gate +19 -0
  24. package/scripts/hook-code-gate +16 -28
  25. package/scripts/hook-continue +2 -2
  26. package/scripts/hook-create-gate +13 -57
  27. package/scripts/hook-edit-gates +58 -0
  28. package/scripts/hook-gate-check +17 -0
  29. package/scripts/hook-links-gate +11 -31
  30. package/scripts/hook-lock-gate +19 -60
  31. package/scripts/hook-power-tools +38 -0
  32. package/scripts/hook-savepoint-pre +11 -11
  33. package/scripts/hook-session-start +21 -15
  34. package/scripts/lib/apply_patch_envelope.rb +46 -13
  35. package/scripts/lib/bridge.rb +85 -17
  36. package/scripts/lib/codex_edit_gates.rb +138 -0
  37. package/scripts/lib/doctor_core.rb +1087 -0
  38. package/scripts/lib/edit_gates.rb +398 -0
  39. package/scripts/lib/exec_worktree.rb +325 -0
  40. package/scripts/lib/harness_text.rb +57 -0
  41. package/scripts/lib/hook_registry.rb +64 -28
  42. package/scripts/lib/installer_core.rb +166 -24
  43. package/scripts/lib/lock.rb +196 -47
  44. package/scripts/lib/qmd_hook.rb +21 -41
  45. package/scripts/lib/qmd_sync.rb +0 -15
  46. package/scripts/lib/revisions_writer.rb +1 -1
  47. package/scripts/lib/ruby_probe.rb +60 -0
  48. package/scripts/lib/scaffold_intent.rb +392 -0
  49. package/scripts/lib/spec_header.rb +83 -0
  50. package/scripts/lib/start_intent.rb +296 -0
  51. package/scripts/lib/verify_intent.rb +262 -0
  52. package/scripts/lib/worktree.rb +15 -1
  53. package/scripts/link-suggest +1 -1
  54. package/scripts/maintenance-run +5 -5
  55. package/scripts/migrate-to-global +2 -2
  56. package/scripts/restore-intent-v1 +17 -12
  57. package/scripts/scaffold-intent +120 -0
  58. package/scripts/start-intent +89 -0
  59. package/scripts/verify-intent +73 -0
  60. package/skills/agent-advisor/SKILL.md +5 -5
  61. package/skills/auto/SKILL.md +52 -32
  62. package/skills/auto/evals/evals.json +2 -2
  63. package/skills/auto/references/agent-architecture.md +1 -1
  64. package/skills/auto/references/agent-report-contract.md +1 -1
  65. package/skills/auto/references/human-report-contract.md +22 -3
  66. package/skills/auto/references/tiers.md +24 -2
  67. package/skills/conventions/SKILL.md +31 -0
  68. package/skills/conventions/references/completion-and-done.md +43 -0
  69. package/skills/conventions/references/gates-and-enforcement.md +39 -0
  70. package/skills/conventions/references/knowledge-graph.md +47 -0
  71. package/skills/conventions/references/lifecycle-and-savepoints.md +11 -0
  72. package/skills/conventions/references/locks-and-worktrees.md +113 -0
  73. package/skills/conventions/references/maintenance-and-revisions.md +170 -0
  74. package/skills/conventions/references/roadmaps.md +44 -0
  75. package/skills/conventions/references/tiers-and-dispatch.md +135 -0
  76. package/skills/dashboard/SKILL.md +1 -1
  77. package/skills/doctor/SKILL.md +15 -6
  78. package/skills/doctor/references/gates-stuck-detection.md +13 -8
  79. package/skills/doctor/report.md +1 -1
  80. package/skills/install/SKILL.md +1 -1
  81. package/skills/intent-brainstorming/SKILL.md +4 -2
  82. package/skills/intent-continuing/SKILL.md +4 -0
  83. package/skills/intent-creating/SKILL.md +13 -8
  84. package/skills/intent-creating/references/lifecycle.md +1 -1
  85. package/skills/intent-discovering/SKILL.md +10 -3
  86. package/skills/intent-ending/SKILL.md +12 -7
  87. package/skills/intent-executing/SKILL.md +37 -19
  88. package/skills/intent-grilling/SKILL.md +5 -3
  89. package/skills/intent-linking/SKILL.md +4 -0
  90. package/skills/intent-locking/SKILL.md +4 -0
  91. package/skills/intent-planning/SKILL.md +14 -3
  92. package/skills/intent-researching/SKILL.md +0 -2
  93. package/skills/intent-savepoint/SKILL.md +4 -0
  94. package/skills/intent-speccing/SKILL.md +4 -0
  95. package/skills/intent-starting/SKILL.md +20 -2
  96. package/skills/project-creating/SKILL.md +0 -2
  97. package/skills/project-creating/references/project-scaffolding.md +3 -3
  98. package/skills/releasing/SKILL.md +1 -1
  99. package/skills/releasing/references/promotion-and-tagging.md +14 -8
  100. package/skills/releasing/references/release-lines.md +1 -1
  101. package/skills/roadmap/SKILL.md +4 -0
  102. package/skills/roadmap-continuing/SKILL.md +4 -0
  103. package/skills/skill-creating/SKILL.md +8 -2
  104. package/skills/skill-creating/references/defaults-first.md +23 -0
  105. package/skills/skill-creating/references/hooks.md +4 -1
  106. package/skills/store-curating/SKILL.md +8 -0
  107. package/skills/store-indexing/SKILL.md +16 -5
  108. package/skills/store-indexing/references/zettelkasten-linking.md +1 -1
  109. package/skills/tutorial/references/track-1-guided.md +2 -2
  110. package/skills/tutorial/references/track-2-auto.md +10 -8
  111. package/skills/tutorial/references/track-3-projects-and-roadmaps.md +1 -1
  112. package/skills/uninstall/SKILL.md +6 -9
  113. package/templates/agents.md +12 -12
  114. package/templates/config.yml +6 -7
  115. package/templates/index.md +6 -3
  116. package/templates/spec.md +1 -1
  117. package/PLASTIC-reference.md +0 -138
  118. package/hooks/code-gate +0 -27
  119. package/hooks/create-gate +0 -3
  120. package/hooks/links-gate +0 -3
  121. package/hooks/lock-gate +0 -21
  122. package/hooks/qmd-search +0 -8
  123. package/hooks/retrieval-gate +0 -10
  124. package/hooks/savepoint-pre +0 -10
  125. package/scripts/hook-qmd-search +0 -44
  126. package/scripts/hook-retrieval-gate +0 -148
  127. package/scripts/lib/retrieval_gate.rb +0 -211
package/PLASTIC.md CHANGED
@@ -4,7 +4,19 @@
4
4
  > plugin is updated. Do not modify it: your changes will be lost.
5
5
  > For project-specific rules, use `AGENTS.md` instead.
6
6
 
7
- See `PLASTIC-reference.md` for reference material: read it on demand, it is not injected at session start.
7
+ Deeper doctrine lives in the `plastic-conventions` skill's chapters
8
+ (`plastic-conventions > references/<chapter>.md`); read the one that matches your task on demand,
9
+ it is not injected at session start.
10
+
11
+ ## Two Processes
12
+
13
+ | Process | Scope | Type | Actor |
14
+ |---|---|---|---|
15
+ | **Build → Observe → Repeat** | The system | Continuous loop | Coordinator |
16
+ | **What → Why → How → Exec** | One intent | Finite lifecycle | Agent |
17
+
18
+ B→O→R is the Coordinator's heartbeat. W→W→H→E is what happens inside each intent.
19
+ The connection: an intent's `## Insights` feeds the Coordinator's Observe phase.
8
20
 
9
21
  ## What is an Intent
10
22
 
@@ -19,7 +31,7 @@ store/
19
31
  spec.md # optional - specification (Why deliverable)
20
32
  plan.md # optional - implementation plan (How deliverable)
21
33
  checklist.md # optional - execution registry (How deliverable)
22
- outcome.md # optional - detailed result (Exec deliverable)
34
+ outcome.md # detailed result (Exec deliverable) - mandatory at a terminal (Completed and Abandoned alike)
23
35
  actions/ # optional - real action files (How deliverable, at least one required)
24
36
  resources/ # optional - research, references, screenshots, diagrams
25
37
  savepoint.md # optional - deterministic cycle-step ledger (auto-written)
@@ -31,14 +43,6 @@ roles. Supporting artifacts that aren't lifecycle deliverables (research reports
31
43
  reference docs, external API snapshots, screenshots, diagrams) go in `resources/`.
32
44
  Name files inside as `{type}--{description}.md` (e.g., `deep-research--gsd-core.md`).
33
45
 
34
- `revisions.md` is an optional, append-only structural-maintenance audit trail. It is not a
35
- lifecycle deliverable and is never scaffolded at intent birth. Its mere existence signals that
36
- the intent underwent structural (not conceptual) change. Structural maintenance is move-and-record:
37
- it removes a misplaced section, file, or ref from its artifact and preserves that content in full
38
- inside `revisions.md` (newest entry at the bottom, one entry per relocated item), so no record is
39
- lost and the delivered meaning is never altered. Changing what an intent delivered is a new intent,
40
- not a revision.
41
-
42
46
  ## Frontmatter
43
47
 
44
48
  Identity and knowledge graph only. Nothing operational.
@@ -55,47 +59,21 @@ tags: [plastic, architecture]
55
59
  ---
56
60
  ```
57
61
 
58
- - `sources` (formative, must-load, acyclic) and `chain` (forward + relational, lighter,
59
- may cycle) form the directed knowledge graph. Reciprocity is one-directional: every
60
- `sources` edge has a reciprocal `chain` entry (I1), but `chain` may carry relational
61
- entries with no reciprocal `sources` (I2), so the graph is not strictly symmetric.
62
62
  - Context contract: load `sources` strongly (they are what the intent was built from);
63
63
  traverse `chain` lightly for discovery. See
64
- docs/concepts/how-plastic-sources-and-chains-intents.md for the full model.
65
- - `## Links` (I5) is the human-readable projection of the graph. It mirrors the
66
- frontmatter exactly: every entry is `- [[id--slug|<target's full intent: text>]]`, a
67
- clickable `id--slug` wikilink target with the target intent's full `intent:` text as the
68
- label (cross-store targets render `- [[store:id--slug|<target's full intent: text>]]`).
69
- Ordering is mandatory: all `sources` first (top), then all `chain`, frontmatter order
70
- preserved within each group. Sources never appear at the end. No source/chain tags, no
71
- sub-grouping. An intent with empty `sources` and `chain` carries the empty-state comment.
72
- - `## Links` is a DERIVED view, not a place to author links (Convention over Configuration).
73
- It equals the projection of `sources` (first) then `chain`. Never hand-write or hand-edit a
74
- `## Links` line, and never auto-delete one. The edge lives in the frontmatter graph; the
75
- section is regenerated from it (doctor `graph_links_projection` enforces this identity). To
76
- add a link, add the frontmatter edge, then reproject.
77
- - Links are decided by CONTEXT INFLUENCE, not by shared files, shared symbols, or a topic
78
- similarity score. The question is whether one intent's context actually informed another.
79
- Three tiers:
80
- - **sources:** the foundational context that shaped this intent's creation (a split, an idea
81
- born during development, a merge). Earns an edge.
82
- - **chain:** the context that materially helps DELIVER this intent. This is a HIGH bar: only
83
- the genuinely delivery-moving intents, not everything in the same area. Earns an edge,
84
- reflected in `## Links`.
85
- - **tags:** a loose theme grouping for search. NOT a link. A shared tag is a door INTO the
86
- store (filtered discovery), not a pathway BETWEEN two notes.
87
- Judging influence is an agent's call, made by reading the candidate's Intent and Context. A
88
- script cannot grade it, so `scripts/link-suggest` only gathers candidates with that evidence,
89
- records a confirmed edge with a rating and reason, and flags drift.
64
+ [`how-plastic-sources-and-chains-intents.md`](https://github.com/zalom/plastic/blob/main/docs/concepts/how-plastic-sources-and-chains-intents.md) for the full model.
90
65
  - IDs use Luhmann's alternating convention: `1` → `1a` → `1a1` → `1a1a`
91
66
  - Multiple branches increment: `1a`, `1b`, `1c`
92
67
 
68
+ See `plastic-conventions > references/knowledge-graph.md` for the linking doctrine: the tiers
69
+ of influence (sources/chain/tags) and the `## Links` projection rules.
70
+
93
71
  ## Lifecycle Stages
94
72
 
95
73
  | Stage | Section | Deliverable | Detail |
96
74
  |-------|---------|-------------|--------|
97
75
  | **What** | `## Intent` | `{ID}--{slug}.md` | `plastic-intent-creating` |
98
- | **Why** | `## Context` + Decisions | `spec.md` | `plastic-intent-brainstorming` |
76
+ | **Why** | `## Context` + Decisions | `spec.md` | `plastic-intent-brainstorming` enriches Context/Decisions; `plastic-intent-speccing` writes `spec.md` |
99
77
  | **How** | Planning | `plan.md` + `actions/ACTION_N.md` (at least one) + `checklist.md` | `plastic-intent-planning` |
100
78
  | **Exec** | Execution | `outcome.md` | `plastic-intent-executing` |
101
79
 
@@ -123,39 +101,29 @@ The blessed write path is the `insight-append` helper
123
101
  install and update, formats the prefix, validates it, and appends at the bottom. Hand-editing
124
102
  `## Insights` is an escape hatch; the helper is the default so the format cannot drift.
125
103
 
126
- Background sessions and dispatched sub-agents do not write the insight themselves. They carry
127
- each nugget home in the completion report's `insights:` field, and the orchestrator (or any
128
- agent that can write the file) persists it via the helper. A session that cannot write the
129
- intent file still returns its report, so the insight survives.
130
- For full lifecycle detail, the skills in the Detail column have references/.
104
+ See `plastic-conventions > references/lifecycle-and-savepoints.md` for the subagent
105
+ report-home contract (how an insight reaches the intent when the writer cannot write the file
106
+ itself) and `savepoint.md`'s role.
131
107
 
132
108
  ## Tiers (proportional auto sizing)
133
109
 
134
110
  Auto mode sizes every intent S/M/L at Why: S = single mechanism or file cluster (hours);
135
111
  M = one subsystem (about a day); L = cross-cutting or novel design.
136
112
 
137
- Speed comes from two levers only: artifact content depth and agent topology. The
138
- same-structure invariant holds: same file set, stage order, gates, and savepoint ledger at
139
- every tier and in both modes.
140
-
141
- S/M collapse the topology (one thinker agent writes spec.md then plan.md plus
142
- checklist.md plus at least one real action file in one context, consolidated into a single
143
- actions/ACTION_1.md at S/M and one file per task at L; a sonnet executor implements). L
144
- keeps the full team.
145
-
146
- Never cut at any tier: the independent reviewer, outcome.md as truth of delivery, the
147
- delivery lock, worktree isolation, intent creation via skill, INDEX as status truth, the
148
- QMD reindex at End.
149
-
150
113
  Tier is recorded as a `Tier: S|M|L` line at the top of spec.md. It is convention-only,
151
114
  read by the orchestrator, not enforced by any gate or by doctor.
152
115
 
153
- Guided mode is unchanged: full-depth artifacts, the human at every gate.
116
+ Settledness is recorded separately, as a `Settled: yes (<reason>)` line directly beneath the
117
+ `Tier:` line, above the `# Spec:` heading. It records that a design has already done its
118
+ thinking, so a later stage can trust it without deriving it again. An absent line means not
119
+ settled; there is no `Settled: no` form. Settledness and scope are independent, so a large
120
+ intent can be settled and never becomes a smaller tier. `scripts/lib/spec_header.rb` is the
121
+ only parser of both lines; nothing else reads the grammar.
154
122
 
155
- ## Agent Models and Dispatch (intent 116)
123
+ See `plastic-conventions > references/tiers-and-dispatch.md` for topology by tier, what never
124
+ gets cut, and guided mode.
156
125
 
157
- Every lifecycle stage has exactly one dispatchable background agent, plus the enforcer that
158
- orchestrates them:
126
+ ## Agent Models and Dispatch (intent 116)
159
127
 
160
128
  | Stage | Agent |
161
129
  |---|---|
@@ -165,169 +133,23 @@ orchestrates them:
165
133
  | Exec | `plastic-executor` |
166
134
  | Done | `plastic-intent-curator` |
167
135
 
168
- Final-gate code review stays an ad-hoc subagent the enforcer dispatches at the final gate, not
169
- a standing role.
170
-
171
- **The advisor: two consultation agents, never injected (intent 185).** Neither is a stage
172
- role: never in the table above, never dispatched by the auto pipeline, and neither ever
173
- touches a user's own session. `plastic-advisor` is the real advisor, ships `model: fable`,
174
- expensive, billed through usage credits. `plastic-faux-advisor` is the imitation advisor, ships
175
- `model: opus`, an ordinary model carrying the Operating Manual's reasoning discipline inlined
176
- in its own body (not injected into anything), so it reasons the same disciplined way at a
177
- fraction of the cost. The `plastic-agent-advisor` skill is the one front door: it teaches when
178
- consulting is worth the money (from the Advisor Protocol: buy one-way doors, plans, adversarial
179
- review, deadlocks, ranking; never buy what a tool can answer, code volume, or confirmation of a
180
- decision already made), routes to the configured agent, and can set the config on request. The
181
- user or the main session states a TIER (S, M, or L) and an EFFORT line in the brief; shipped
182
- effort is `xhigh` for `plastic-advisor` and `max` for `plastic-faux-advisor`.
183
-
184
- Config is harness-scoped, keys matching `InstallerCore::DEFAULT_AGENTS` exactly (`claude`,
185
- `codex`, never `claude_code`): `advisor.enabled` (false skips installing both agents and the
186
- skill), `advisor.claude.default` (which agent the skill routes to), `advisor.claude.primary`
187
- and `.secondary` (the two slots, agent NAMES never model names, so a slot can point at a
188
- locally registered agent). Each agent's actual model is a plain `agents.models.claude.<name>`
189
- override, the SAME harness-scoped mechanism every other agent uses, resolved through
190
- `InstallerCore#agent_model_overrides(harness:)`; there is no separate advisor-model key.
191
- `agents.models` is harness-scoped from this release (`agents.models.claude.*`,
192
- `agents.models.codex.*`), with the pre-existing flat form (`agents.models.<name>: value`)
193
- still honored as the claude harness and nested winning over flat. This closes a real latent
194
- bug: previously the same override map fed both the Claude frontmatter rewrite and the Codex
195
- TOML generator, so a literal Claude model id could leak into a Codex config; a model named
196
- under `claude` is now never emitted to `codex`. Install asks which advisor is the default
197
- (Claude Code only), with a plain description of each: Faux Fable (recommended, cheaper,
198
- available on any plan) or Fable 5 (the frontier model, billed through credits). Update asks
199
- the same question once when the key is unset, then never again. Claude-only for this release:
200
- the owner has not evaluated the Codex reasoning-model ecosystem long enough to judge it, so
201
- `generate_codex_agents` skips both agents by name, tracked at intent 186, not a permanent
202
- exclusion.
203
-
204
- **Auto-mode entry.** `plastic-auto` is the entry skill for autonomous delivery: it takes over How
205
- and Exec, spins up the team above, and works the dashboard's dispatchable queue. The dashboard's
206
- `--data` output splits intents into a `dispatchable_queue` (work an agent can pick up) and
207
- `human_only` (intents that need a person); auto mode consumes the former.
208
-
209
- **Model contract.** Every agent in `agents/*.md` pins an explicit Claude Code model alias in
210
- its own frontmatter: `opus`, `sonnet`, or `haiku`. Never `inherit`, never Fable by default,
211
- unless an explicit `agents.models.<name>` config override names Fable for that role, in which
212
- case the override is honored as written. The two advisors, `plastic-advisor` and
213
- `plastic-faux-advisor`, are not lifecycle stage roles: the never-Fable rule governs stage
214
- agents only. Neither is ever dispatched by the auto pipeline; they are consultation roles
215
- summoned deliberately by the user or the main session, and their models are user configuration
216
- (fable and opus by default on Claude Code). Aliases track "latest
217
- per tier" so no Plastic release is required to advance a tier. The tier by role:
218
- `plastic-enforcer`, `plastic-brainstorming`, `plastic-planner` are `opus`;
219
- `plastic-spec-specialist`, `plastic-executor`, `plastic-intent-curator`,
220
- `plastic-future-intent-researcher`, `plastic-intent-discovery` are `sonnet`.
221
-
222
- **Config and installer mechanism.** `agents.models.<basename>` in a project's
223
- `<dir>/.plastic_store/config.yml` or the global `~/.plastic/config.yml` overrides one agent's
224
- tier. Precedence is project, then global, then the shipped default, matching every other
225
- `read-config` key. The installer applies the resolved override to each agent file's `model:`
226
- line at copy time (install, update, and repair, across every harness target). With no override
227
- configured, the shipped frontmatter passes through unchanged.
228
-
229
- **Dispatch-time contract.** Frontmatter is primary, and Claude Code reads it at dispatch, but
230
- because that read is a harness implementation detail rather than a contract Plastic controls,
231
- every dispatch site also resolves the target agent's model through the config chain
232
- (`read-config agents.models.<basename> --project <repo>`) and passes it explicitly at dispatch,
233
- belt-and-braces on top of the frontmatter pin.
234
-
235
- **Cross-harness portability.** The dispatch and model-tier contract above is harness-facing. The
236
- adapter layer that maps Plastic's hooks and model aliases onto each supported agent runtime
237
- (Claude, Codex, Hermes) is the cross-harness portability layer; see
238
- docs/reference/harness-adapters.md for the adapter contract.
239
-
240
- **Spawn preamble (intent 152).** `scripts/spawn-preamble` emits a live-state block purely from
241
- filesystem state: the active intent, stage, role/cycle-step, the honor instruction, and the
242
- report contract. When the intent's code worktree is resolvable and exists on disk, it also
243
- appends the worktree's absolute path plus a verbatim instruction to `cd` there directly, for
244
- harnesses whose `EnterWorktree` cannot discover a nested repo from a non-repo launch directory.
245
- Output is byte-identical when no worktree resolves.
246
-
247
- **Orchestrator advisory.** At auto-mode start, the orchestrator recommends once that the user
248
- run the main session on the best available thinking model (Fable, Opus, or whatever supersedes
249
- them). This is advisory only: it changes no behavior and blocks nothing if ignored, and it
250
- concerns the human's main session, never a dispatched subagent. The two advisors,
251
- `plastic-advisor` and `plastic-faux-advisor`, are not lifecycle stage roles: the never-Fable
252
- rule governs stage agents only. Neither is ever dispatched by the auto pipeline; they are
253
- consultation roles summoned deliberately by the user or the main session, and their models are
254
- user configuration (fable and opus by default on Claude Code).
255
-
256
- **`plastic-intent-discovery`.** The What-stage agent. It fires at intent activation, after the
257
- delivery lock is armed and before Why begins, running under that lock as the owner session (it
258
- does not acquire the lock itself and is not blocked by it): it reads the intent's
259
- `chain`/`sources` frontmatter, runs QMD-first discovery over completed predecessor work and
260
- related parked or future intents, and deposits findings to `resources/discovery--<slug>.md` in
261
- the intent directory ONLY. It never writes the intent file, `spec.md`, or any other lifecycle
262
- deliverable; the Why-stage `plastic-brainstorming` agent reads its deposit and enriches
263
- `## Context`.
264
-
265
- `savepoint.md`: a deterministic, append-only ledger of cycle-step milestones (one line per
266
- lifecycle boundary, newest at the bottom), written automatically by the gate hook. It is
267
- sugar on top of the conventions, not a source of truth: state is always derivable from
268
- files-on-disk, and the ledger is rebuildable. It exists so a resuming agent reads the cycle's
269
- succession at a glance (last line = where we are).
270
-
271
- ## Auto-Mode Human Reporting (intent 92)
272
-
273
- In auto mode the orchestrator briefs the human at every lifecycle stage boundary in a fixed,
274
- impact-first shape (the EM-to-CTO report contract): State, then Risk, then Call. It leads with
275
- what changed and why it matters, names one risk, and leaves the decision to the human. Separately,
276
- the `plastic-humanizer` skill cleans authored prose (specs, outcomes, READMEs, release notes) of
277
- AI tells and slop; it is for documents, not for every reply.
136
+ See `plastic-conventions > references/tiers-and-dispatch.md` for the advisor, model
137
+ configuration, the dispatch contract, and the spawn preamble.
278
138
 
279
139
  ## Operational Skills
280
140
 
281
- Beyond the lifecycle agents, Plastic ships thin skills for day-to-day operation:
282
-
283
- - **`plastic-dashboard`** renders a deterministic Value x Effort work cockpit across the global
284
- store and every project, and emits a machine-readable queue (`scripts/dashboard.rb --data
285
- [continue|project <slug>]`) that auto mode consumes.
286
- - **`plastic-doctor`** checks installation health across three scopes. See the `### Doctor`
287
- section below.
288
- - **Lifecycle skills** (`plastic-install`, `plastic-update`, `plastic-uninstall`,
289
- `plastic-rollback`, intent 55) are thin wrappers over a single pinned
290
- `npx -y @zalom/plastic@<channel> <verb>` call: initialize or repair an install, advance a
291
- channel, remove Plastic, and step the local versions ledger.
292
- - **`plastic-feedback`** (intent 174) turns a described Plastic quirk, bug, or feature idea
293
- into a redacted local report file and a prefilled GitHub issue URL; only the user can submit
294
- it. `disable-model-invocation` hides its description from your own context, so if the user
295
- hits a Plastic quirk, bug, or missing feature, offer to invoke the plastic-feedback skill
296
- yourself instead of waiting to be asked; the user still sends it, you never do.
297
-
298
- ### Doctor
299
-
300
- Doctor has three scopes, each with its own contract (intent 219, the governing doctrine):
301
-
302
- 1. **Core check** (`--core`): fast and binary. Is Plastic loaded and ready for work on every
303
- registered agent. No store-content scanning, no warnings.
304
- 2. **Store scan** (`--store [global|<slug>]`): fast, three-state. Verifies the operations
305
- Plastic itself depends on in one store (QMD reachability, sources/chain and cross-store
306
- resolution, INDEX parsing, links projection), plus tool readiness (Serena, Enola) for a
307
- project store. Runs at load time: the global board uses `--store global`, a project board
308
- uses `--store <slug>`.
309
- 3. **Full check** (no flag): the install-wide surface. Agent-scoped and install-scoped
310
- families (deprecations, install integrity, skill lint, config asks, config-honoring drift)
311
- plus the global store's own content. Never carries a per-project finding; `--store <slug>`
312
- is the project-scoped check, not this one.
313
-
314
- See `plastic-doctor/SKILL.md` for the operational encoding of all three.
141
+ - **`plastic-feedback`** turns a described Plastic quirk, bug, or feature idea into a redacted
142
+ local report file and a prefilled GitHub issue URL; only the user submits it. If the user hits
143
+ a Plastic quirk, bug, or missing feature, offer to invoke the plastic-feedback skill yourself
144
+ instead of waiting to be asked.
145
+ - **`plastic-doctor`** checks installation health across three scopes: core, store, and full.
146
+ See `plastic-doctor/SKILL.md` for the contract.
315
147
 
316
148
  ## Releases and Versioning
317
149
 
318
- Plastic ships as versioned releases. A release is a collection of intents: a cut bundles whichever
319
- intents landed since the previous cut and completes them, so the intent schema itself stays
320
- release-agnostic and carries no version number. Cutting a release bumps the three version files
321
- (`package.json`, `.claude-plugin/plugin.json`, `.claude-plugin/marketplace.json`), tags
322
- `v{version}`, runs `gh release create --latest`, and publishes to npm. The npm dist-tag follows
323
- the version string: a `-alpha` suffix routes to the `alpha` tag, `-beta` to `beta`, and a plain
324
- version with no suffix routes to `latest`. Release history lives in `CHANGELOG.md` at the repo
325
- root, one line per cut. The `plastic-releasing` skill runs the whole flow.
326
-
327
- Deprecations are declared in `deprecations.yml` and shown at SessionStart. While Plastic is
328
- pre-1.0, a satisfied deprecation may be removed immediately; from `1.0.0` on the steady-state
329
- grace rule applies (removal at least two minors ahead). See PLASTIC-reference.md for the
330
- Deprecation Process.
150
+ Plastic ships as versioned releases; a release is a collection of intents. Run
151
+ `plastic-releasing` for the full flow (version bump, tag, GitHub release, npm publish).
152
+ Deprecations are declared in `deprecations.yml` and shown at SessionStart.
331
153
 
332
154
  ## Gotchas
333
155
 
@@ -379,19 +201,10 @@ Format: `ID--three-to-five-words` (all stores).
379
201
  - Root intents: sequential numbers (`1`, `2`, `3`)
380
202
  - Branches alternate: `1` → `1a` → `1a1` → `1a1a`
381
203
  - Intent file matches directory: `1a1--slug/1a1--slug.md`
382
- - Next ID: `"${CLAUDE_PLUGIN_ROOT}/scripts/folgezettel-id" <parent_id> <store_path>`
383
-
384
- **Branch vs root: the semantic decision.** The numbering is mechanics; choosing
385
- *whether* to branch is meaning:
204
+ - Next ID: `ruby ~/.plastic/scripts/folgezettel-id <parent_id> <store_path>`
386
205
 
387
- - **Branch (`14a`, `14b`):** a sub-task, refinement, or direct continuation of the
388
- parent. It cannot stand on its own; it only makes sense as part of the parent's work.
389
- - **Root (`15`, `16`)**: an independent thought, even if inspired by another intent.
390
- Reserve `sources` for true created-from provenance (intents this was built out of). An
391
- independent intent merely related to or inspired by another carries NO `sources`; record
392
- the relation on the PREDECESSOR's `chain` (and mirror it as a
393
- `[[id--slug|<target's full intent: text>]]` wikilink in `## Links`).
394
- - **Rule of thumb:** if the intent could exist without its parent, it's a root.
206
+ See `plastic-conventions > references/knowledge-graph.md` for the branch-vs-root semantic
207
+ decision: when to branch versus start a root.
395
208
 
396
209
  ## INDEX.md
397
210
 
@@ -407,11 +220,9 @@ descriptions. This is a self-check, not a gate.
407
220
 
408
221
  ## Roadmaps
409
222
 
410
- A roadmap is a named, ordered, delivery-side collection of intents (waves of parallel-safe
411
- entries plus an append-only log), the delivery-side counterpart to a release and a sibling of
412
- `INDEX.md` (never inside `store/`). Create, order, close, and consume one with `plastic-roadmap`.
413
- `INDEX.md` stays the single writer of intent status; a roadmap entry mirrors it and yields on any
414
- conflict. See PLASTIC-reference.md for the full Roadmaps format.
223
+ A roadmap is a named, ordered, delivery-side collection of intents. Create, order, close, and
224
+ consume one with `plastic-roadmap`; see `plastic-conventions > references/roadmaps.md` for the
225
+ full format.
415
226
 
416
227
  ## Rules for Skills
417
228
 
@@ -454,42 +265,16 @@ tables-everywhere rule: simple data stays prose, and tables must not be overused
454
265
  **Bullets-limit.** Use bullets only when a table genuinely does not fit the content, and
455
266
  never more than 3-5 items.
456
267
 
457
- **Why tables.**
458
-
459
- | # | Reason |
460
- |---|--------|
461
- | 1 | Parallel structure makes comparison a row-vs-row scan, not a re-read. |
462
- | 2 | Coverage is provable: N items means N rows, an empty cell exposes a gap while a missing bullet hides it. |
463
- | 3 | Schema stated once in the headers, no repeated labels, higher density. |
464
- | 4 | A column reads vertically to show every value at once. |
465
- | 5 | Cells force terseness where bullets sprawl and nest. |
466
- | 6 | A ruling or decision column turns the report into the decision worksheet. |
467
- | 7 | Rows stay machine-readable for downstream tooling. |
468
- | 8 | Uniform granularity: every item answers the same questions. |
469
- | 9 | Line-scoped git diffs. |
470
-
471
268
  **Exception.** The EM-to-CTO human briefing (`skills/auto/references/human-report-contract.md`)
472
269
  keeps its deliberate prose shape (fixed State/Risk/Call, single item, nothing to tabulate) and
473
270
  is exempt from this rule.
474
271
 
475
- ## Retrieval Gate
476
-
477
- Advisory. Hard gates guard writes, locks, and structure, never reads or searches. Read,
478
- Grep, Glob, and bash search are always allowed, including over the stores. When QMD is
479
- present and fresh, a content search over store markdown receives an advisory hint pointing
480
- at `qmd search` alongside its result; when QMD is present but stale, a background reindex
481
- fires so the next turn's hint runs against a fresh index (never synchronous). QMD, Enola,
482
- and Serena are recommendations, not obligations: the UserPromptSubmit power-tools hook
483
- appends one recommendation line per present tool, naming Enola only, not both, when Enola
484
- and Serena are both present (Enola-first, one code-navigation slot). The legacy trailing `# qmd-ok` token is still
485
- accepted on Bash commands and simply silences the hint. Scope stays the agent's own tool
486
- calls; Ruby `File.read` inside a script is invisible to the hook by design.
487
-
488
- The deterministic entry point is the `scripts/qmd-sync` CLI (verbs: detect, register, reindex,
489
- status, search), a clean no-op when QMD is absent. Each store indexes into its own
490
- `plastic-<slug>` collection (`plastic-global` for the global store, `plastic-<slug>` per project).
491
- Index mutation is lifecycle-only, and the reindex runs LAST in the End tail, after the bridge
492
- purge. See `docs/internals.md` for depth.
272
+ ## QMD Search
273
+
274
+ QMD, Enola, and Serena are recommendations, not obligations. The deterministic entry point
275
+ is `scripts/qmd-sync` (detect, register, reindex, status, search). Intent delivery reindexes
276
+ the store; see `plastic-conventions > references/gates-and-enforcement.md` for gate
277
+ mechanics.
493
278
 
494
279
  ## Transition Gates
495
280
 
@@ -504,293 +289,46 @@ Hard blocking: hooks exit code 2 on gate failure.
504
289
 
505
290
  ### The gates by name
506
291
 
507
- Each gate guards one thing. All are hard except the retrieval gate:
508
-
509
- - **create-gate** validates the proposed intent file at What write-time (Write, Edit, and MCP
510
- edits), so a malformed or incomplete intent never lands.
511
- - **gate-check** enforces lifecycle stage order (spec.md before plan.md, the plan triplet before
512
- the checklist, all checklist items before outcome.md).
513
- - **lock-gate** arbitrates ownership and claims: it admits only the intent's lock owner or a
514
- registered delegate to write into an active intent directory, and every deny names the
515
- resolving `plastic-lock` command.
516
- - **bash-gate** intercepts a write attempted through a bash or interpreter one-liner (a heredoc, a
517
- `>` redirect, a `ruby -e` or `python -c` write), so the same rules apply whether an edit goes
518
- through the Write tool or a shell. A trailing `# plastic-ok` comment is an auditable escape that
519
- lets a deliberate command through, and every use is logged to
520
- `~/.plastic/.cache/gate-escapes.log`. The code gate (Write and Edit) carries the identical
521
- audited `# plastic-ok` escape, logged to the same file. The escape does not extend to
522
- `NotebookEdit` or MCP structural edits: they are still gated, just without an escape hatch.
523
- - **retrieval-gate** is advisory only (see the Retrieval Gate section): it hints at QMD and never
524
- blocks a read or search.
292
+ One line each. On Claude the five edit-path gates (savepoint-pre, lock-gate, code-gate,
293
+ links-gate, create-gate) run inside one dispatcher process per Write or Edit, in that fixed
294
+ order with the first deny winning; what each gate checks is unchanged.
295
+
296
+ - **savepoint-pre** appends the savepoint ledger line before a write into an intent dir; it
297
+ records and never denies.
298
+ - **lock-gate** admits only the intent's lock owner or a registered delegate to write into an
299
+ active intent directory.
300
+ - **code-gate** denies a code edit before How is delivered and a code edit outside the
301
+ provisioned worktree (stage rule or worktree rule, first match wins), with the audited
302
+ `# plastic-ok` escape.
303
+ - **links-gate** enforces the derived `## Links` projection contract at write time.
304
+ - **create-gate** validates the proposed intent file at What write-time.
305
+ - **bash-gate** (on the Bash matcher) intercepts a write attempted through a bash or
306
+ interpreter one-liner, with the same audited escape.
307
+ - **gate-check** (PostToolUse) enforces lifecycle stage order after each write.
308
+ - **future-intent-check** (UserPromptSubmit) surfaces parked future intents whose keywords
309
+ match the user's message; it informs and never denies.
310
+
311
+ See `plastic-conventions > references/gates-and-enforcement.md` for the escape and logging
312
+ detail.
525
313
 
526
314
  ## Delivery Isolation and the Single-Owner Lock
527
315
 
528
- Exactly one session or agent develops an intent's delivery at a time. Ownership is
529
- session-keyed and durable: arming acquires `delivery.lock` inside the intent directory
530
- (atomically, O_EXCL). The session id is the authorization identity. Descriptive provenance
531
- records the controller's explicit `harness`, `agent`, `model`, `thread`, and `mode` values,
532
- but never grants access and is never inferred from transcripts or filesystem paths. Missing
533
- fields on legacy locks display as `Unknown`. Liveness is a lease: the owner's hooks refresh
534
- the lock file's mtime on tool activity, and that mtime is the sole heartbeat truth. The lock
535
- counts as stale only when the mtime is older than the TTL. No process id is consulted anywhere.
536
- The /tmp session bridge is a cache
537
- of this state; on any disagreement, or when the bridge is missing, the lock file wins.
538
- Another session that finds a fresh lock backs off; a stale lock is reclaimed only by
539
- explicit takeover, which replaces the lock and appends an audit line to the intent's
540
- savepoint.md. Rearming the same session preserves its acquired identity and refreshes known
541
- provenance; an explicit takeover replaces the controller and starts new provenance.
542
- Subagents spawned by the owner write under the owner's lock once registered as delegates.
543
- Delegate activity status (`active`, `finished`, or `failed`) is descriptive and does not revoke
544
- the session's string-array authorization. A registered delegate remains authorized until a
545
- separate authorization-removal mechanism exists. Finished and failed delegate activity is
546
- retained as descriptive history, bounded to the 20 most recent terminal entries. A controller,
547
- a delegate, and an artifact claim are distinct evidence: controller ownership authorizes the
548
- delivery, delegate registration authorizes a child session, and a claim selects one current
549
- writer for one artifact. Disarm clears the lock; the End tail is ordered: verify, merge and remove
550
- worktrees, clear the lock, and only then is the bridge purge-eligible. Repair is one
551
- idempotent function with two entry points: the `plastic-lock` command (`who`, status, fix,
552
- release, reclaim, delegate) and `/plastic-intent-starting`, so boarding self-heals. `who` is
553
- read-only and reports the controller, mtime heartbeat, delegates, and claims from durable files.
554
- This is
555
- mandatory, not a convention.
556
-
557
- Solo-mode gate defaults (intent 128): on a confirmed positive solo determination
558
- (`Bridge.solo_delivery?`, a single owner working alone with no sign of parallel or team
559
- delivery), the lock and worktree arbitration gates relax from enforced to advisory. The moment
560
- any parallel or team activity appears they return to strictly enforced. This is a real behavior
561
- difference, not just a message change: a solo session is not hard-blocked by these gates, a
562
- shared one still is.
563
-
564
- The bridge resolves the current session in a fixed precedence: the stdin `session_id` first, then
565
- the `CLAUDE_CODE_SESSION_ID` environment variable, then a derived key when neither is present. A
566
- bridge is purge-eligible by terminal state, not by age: it is removed only once its intent is no
567
- longer active, never on a timer. See `docs/internals.md` for depth.
568
-
569
- The delivery lock arbitrates at the whole-intent grain: it decides who may work
570
- an intent at all. Underneath it, a per-artifact claim token (intent 111)
571
- arbitrates at the file grain: it decides who, among those already holding the
572
- delivery lock, is the one writer for one lifecycle file right now. A write to
573
- `spec.md`, `plan.md`, `checklist.md`, or the intent file must hold both the
574
- delivery lock and that file's claim. Claims live in `.claims/<artifact>.claim`
575
- inside the intent directory, one small JSON file per artifact, scoped strictly
576
- per-intent-per-artifact, never session-global. The claim gate is dormant
577
- (allows) when no claim file exists for an artifact, so ordinary single-owner
578
- work is unaffected; it engages, and denies, only when a second writer tries to
579
- take a fresh claim someone else already holds. A stale or corrupt claim fails
580
- open (the write proceeds, the claim yields) and the condition is surfaced in
581
- `plastic-lock status`, which lists any live claims alongside the delivery
582
- lock. See `plastic-lock claim`/`release-claim` and `docs/internals.md` for the
583
- full mechanism.
584
-
585
- There is exactly one lock in Plastic: `delivery.lock` (exclusive, one owner plus delegates),
586
- shipped by intent 108. An earlier two-lock doctrine proposed a second `maintenance.lock`
587
- (short TTL, structural move-and-record only); intent 112 built it in full and was then
588
- abandoned before merge on a design pivot, so nothing from it ever shipped (`lock.rb`'s
589
- `TYPES` seam is the only trace left). Intent 197 rejects the second lock outright rather than
590
- reviving it: a lock held by a maintenance session could be mistaken by a resuming session
591
- for an active delivery. Maintenance instead DETECTS `delivery.lock`'s freshness
592
- (`Lock.fresh?`) and defers when fresh; it never acquires any lock of its own and leaves none
593
- behind. See "WORK vs MAINTENANCE" below for the full doctrine.
594
-
595
- Every code-touching intent gets its own git worktree named `{id}--{slug}`, and all code edits
596
- for that intent happen only inside it. Plastic provisions the worktree deterministically: it
597
- resolves the project repo from `projects.yml` and runs `git -C <repo> worktree add`, so
598
- isolation never depends on the current working directory. There is one worktree per project
599
- intent, the code worktree at `<repo>/.claude/worktrees/{id}--{slug}` (branch
600
- `plastic/{id}--{slug}`).
601
-
602
- Plastic does not provision a second worktree for lifecycle-doc writes. Two things cover that
603
- need instead. First, the harness's own native worktree: Claude Code manages its own code
604
- worktree at `<repo>/.claude/worktrees/{name}`, and Codex manages its own at
605
- `$CODEX_HOME/worktrees` (default `~/.codex/worktrees`); both exist on their own, independent of
606
- anything Plastic provisions. Second, intent 197's branch-from-main plus scoped commit, which
607
- gives store writes their own write safety without a dedicated worktree. Plastic tried a second,
608
- dedicated store worktree at `<plastic_home>/.worktrees/{id}--{slug}` first; agents never wrote
609
- into it, because every delivering agent writes lifecycle docs straight to the main store
610
- checkout, so intent 178 retired the store worktree in favor of the two mechanisms above.
611
-
612
- Provisioning fails open for intents that touch no project code (pure research or decision
613
- intents in the global store, or a non-git repo): those get the lock only, and the worktree
614
- block stays unprovisioned. The fail-open path is always logged, never silent.
615
-
616
- Cleanup is part of Done: the End tail merges the branch, then removes the worktree. Never leave
617
- an orphaned worktree behind, and clear a stale worktree reference with `git worktree prune`.
618
-
619
- ### Intent delivery, station by station
620
-
621
- How one intent travels from boarding to Done, and what the lock, bridge, and gates do at
622
- each station.
623
-
624
- | Station | Delivered artifact | Lock and bridge steps | Pre-stage gate | Post-stage record |
625
- |---|---|---|---|---|
626
- | Start (board) | none (a procedure, not a stage) | `plastic-lock fix` self-heals stale, corrupt, or legacy state; arm acquires `delivery.lock` (O_EXCL, session-keyed), provisions the code worktree, writes the bridge cache | lock-gate denies any write into an active intent dir without this intent's lock; every deny names the resolving command | savepoint confirms the boarding station |
627
- | What (create) | `<id>--<slug>.md`, born complete | no lock yet; no bridge | create-gate validates the proposed intent content (Write, Edit, and MCP edits) | savepoint `What` line; intent listed in INDEX `## Active` |
628
- | Why | `spec.md` | owner writes refresh the lease (lock file mtime heartbeat) | gate-check requires the intent file with `## Intent` before spec.md; lock-gate admits only the owner or a delegate | savepoint `Why started`, `Why spec.md created` |
629
- | How | `plan.md`, `actions/ACTION_N.md` (at least one), `checklist.md` | heartbeat on writes; the code gate stays closed until plan.md, checklist.md, and a real action file all exist | gate-check requires spec.md before plan.md, and plan.md plus a real actions/ACTION_N.md before checklist.md | savepoint `How started`, `How plan.md created`, `How checklist.md created`, `Exec started` |
630
- | Exec | code on the intent branch, checklist checked off | heartbeat; code edits confined to the provisioned worktree; delegates write under the owner's lock; bash, interpreter, and MCP writes gated the same way | code-gate, worktree-gate, bash-gate, lock-gate | checklist boxes; savepoint milestones |
631
- | End (done) | mandatory `outcome.md` (`disposition: delivered\|abandoned`), INDEX moves to Completed or Abandoned | ordered End tail: verify, merge and remove worktrees, disarm clears `delivery.lock`, then the bridge is purge-eligible, and the QMD reindex runs LAST (after purge) | gate-check blocks outcome.md while checklist items are unchecked | savepoint `Done delivered` (or `abandoned`); takeover audits, if any, remain in savepoint.md |
632
- | Maintenance (Future, Terminal, or Active-with-a-stale-or-no-lock) | `revisions.md` move-and-record entries | detects (never acquires) `delivery.lock`; defers and reports while the target's lock is FRESH (`Lock.fresh?`); a stale or absent lock is not-active, maintenance proceeds | none enforced by any gate; the maintenance tool or skill itself checks `Lock.fresh?` (see WORK vs MAINTENANCE below) | append-only, rule-tagged `revisions.md` entry written in the same operation as the change, or the change is refused; lands via a fresh branch off store main merged back as one closed op, never `git add -A` |
633
-
634
- ### What "intent done" means (intent 93)
635
-
636
- Done is one law with three signals, and they must agree. INDEX `## Completed` /
637
- `## Abandoned` is the single canonical terminal marker: it is the store-wide ledger a fresh
638
- session reads first, so it wins on any conflict. `outcome.md` is the "deliverable exists"
639
- signal, and the savepoint `Done delivered|abandoned` line is the audit echo. All three must
640
- agree; when they disagree, INDEX is authoritative and `doctor` flags the mismatch (the
641
- `done_signals` check: `outcome.md` real but still under `## Active`, or terminal without a
642
- real `outcome.md`, or a terminal intent whose savepoint carries no `Done` line).
643
-
644
- `outcome.md` is mandatory at every terminal transition, delivered and abandoned alike. It
645
- self-declares its disposition through a `disposition: delivered|abandoned` frontmatter
646
- header. The delivered path authors it with the result; the abandoned path authors it with
647
- the abandonment reason and no longer leaves the scaffolded placeholder sentinel in place.
648
-
649
- The canonical End tail runs in this order, and the QMD reindex is always LAST, after the
650
- purge: `outcome.md -> INDEX terminal -> savepoint Done -> commit -> disarm (Worktree.release
651
- -> Lock.release -> purge) -> QMD reindex`. Running the reindex last keeps the index from
652
- ever referencing a bridge or lock that disarm is about to remove.
653
-
654
- `scripts/end-intent` performs this order's disarm step (verify the code worktree is clean,
655
- then merge/remove worktrees, then clear the lock) as its own step 5, mechanically, since
656
- intent 188: a session no longer needs a separate one-liner for it, and the script's own
657
- exit code (0) is the single fact a caller needs that the intent is closed AND its delivery
658
- lock is gone. A pre-flight lock guard runs before anything is written (refuses a live
659
- foreign session, reclaims a stale one with an audit line), and a dirty code worktree
660
- refuses before removal rather than force-discarding uncommitted changes.
661
-
662
- The post-done access window is lock-bounded: `[INDEX terminal -> Lock.release]`. Through it
663
- the completing session keeps full read and write access to the terminal directory and no
664
- purge can fire (108's lock-held keep-guard keeps the bridge while `delivery.lock` exists).
665
- Once the lock is released the window closes: the bridge becomes purge-eligible and the
666
- directory is frozen. A crash mid-tail is recovered by stale-lock reclaim plus finishing the
667
- tail; `doctor` surfaces this as a "stalled completion" (terminal in INDEX but the lock is
668
- still present or stale). Finishing the tail is FINISHING a completion, never a reactivation:
669
- a done intent is never moved back to `## Active`.
670
-
671
- ### WORK vs MAINTENANCE (intent 197)
672
-
673
- Plastic separates two different things an earlier doctrine blurred under one word,
674
- "immutable." WORK is the delivered CONTENT an intent produced: the code and project files a
675
- delivery changed, the research it recorded, the outcome it wrote. Once the intent is terminal
676
- (Completed or Abandoned), that content is immutable - the only way to change it is another
677
- intent that continues or reverts it. Editing a Done intent's own artifacts so it looks like it
678
- delivered something different, or that parts are missing, is forbidden (the book analogy:
679
- never rewrite the text on the pages of an old, valuable book).
680
-
681
- MAINTENANCE is everything else: structure, the sources/chain graph, a section that does not
682
- belong in the file, formatting, and any store-wide operational change (a new Plastic version
683
- adding or removing a frontmatter field across every intent). Maintenance is not immutable and
684
- needs no owner gate to run, on the one condition below (recording is universal). The
685
- decidable test is CONTENT vs METADATA, not "meaning vs structure": a graph edit is structure
686
- even when it is also, in a loose sense, about lineage, because it does not change what the
687
- intent delivered. Precedent: plastic intent 124's own `revisions.md` v1 dropped a dead chain
688
- edge to a non-existent `124b` (`[rule: broken-chain]`), and v2 added a missing required
689
- reciprocity edge to `131` (`[rule: misplaced-content]`), both ordinary maintenance, not
690
- owner-gated exceptions. Allowed maintenance: (a) a frontmatter chain/sources edge that points
691
- to a non-existent or wrong intent, or a missing required edge; (b) an extra non-convention
692
- section in the intent file, removed and moved into `revisions.md`; (c) a store-wide
693
- operational change from a new Plastic version, applied to every intent; (d) any other
694
- structural or operational tidy. Forbidden: anything that alters what the work delivered.
695
-
696
- The residual guard on every graph edit: it must move TOWARD ground truth (drop a dangling or
697
- false edge, add a reciprocity-forced or documented-real one) and must never invent a
698
- relationship - "might be related" is never a valid `[rule:]` reason. This is already implied
699
- by the mandatory `[rule: tag]` on every `revisions.md` entry; no additional per-edit owner
700
- gate is needed for an ordinary graph fix of this kind.
701
-
702
- Maintenance normally needs no intent and no roadmap at all; it runs through the maintenance
703
- tools and skills and records itself. The one exception: a batch touching more than about 5
704
- different intents at once must stay rare, and is always an owner decision - the agent asks
705
- first and shows the diff before proceeding. This exception governs rare cross-intent sweeps;
706
- it does not apply to an ordinary single-intent graph repair.
707
-
708
- Maintenance target-state eligibility, by the intent's own lifecycle state: a Future intent,
709
- yes; a Terminal (Completed or Abandoned) intent, yes; an Active intent mid-delivery, WAIT. The
710
- wait is keyed on whether the target currently holds a FRESH `delivery.lock` (`Lock.fresh?`),
711
- never on INDEX `## Active` membership - `end-intent` releases the lock only after the INDEX
712
- move and its commit tail finish, so keying on Active membership would miss that tail window
713
- and let maintenance race a live completion. A STALE lock is not maintenance's problem to
714
- resolve; it is treated as not-active, and maintenance proceeds rather than waiting
715
- indefinitely behind a dead session.
716
-
717
- There is exactly one lock in the system (see the two-lock correction above): `delivery.lock`,
718
- meaning an active agent is delivering that intent. Maintenance DETECTS this lock and NEVER
719
- ACQUIRES it, even transiently, because a maintenance-held lock could be mistaken by a resuming
720
- or continuation session for an active delivery. Maintenance leaves no lock behind: there is
721
- nothing to clean up afterward, and no ambiguity about who, if anyone, holds the one lock.
722
- `bridge.rb:1195`'s `lock_gate_decision` already allows any write once an intent is not in
723
- INDEX `## Active` - there is no enforced freeze gate in the codebase today, and there never
724
- was one that shipped (see the corrected history below).
725
-
726
- Stranding and clobbering are avoided by construction, not by a second lock: a maintenance
727
- action creates a fresh branch from the CURRENT state of store main, applies only its own
728
- scoped changes, and merges that branch back to main as part of the SAME closed operation.
729
- Nothing strands on an unmerged branch; two concurrent maintenance runs reconcile as ordinary
730
- merge conflicts on main, never silent loss. This is lighter than intent 178's full per-session
731
- delivery worktrees (178 stays about the agent write paths for delivery); maintenance only
732
- needs branch-from-main plus scoped merge-back (`scripts/lib/maintenance_git.rb`,
733
- `scripts/maintenance-run`).
734
-
735
- No commit anywhere, store or project repo, uses `git add -A`; every maintenance and delivery
736
- commit stages only the paths it actually changed (`scripts/end-intent`'s `store_commit`,
737
- `scripts/maintenance-run`).
738
-
739
- The one condition on every maintenance action, with no exception, is that it is recorded.
740
- Every maintenance action, whether run by a tool or made by hand, must leave an append-only
741
- `revisions.md` entry on its target intent (`## Revision vN`, a `Why ... [rule: tag]` line, a
742
- `Prior location`, and the change itself). If the file already exists, a new run appends
743
- `vN+1`; it never overwrites an earlier entry (precedent: intent 124's `revisions.md` v3
744
- corrects v2 by appending a correction entry and explicitly leaving v2 in place). This is
745
- tool-enforced, not prose alone: `scripts/project-links`, `scripts/rebuild-graph`, and
746
- `scripts/restore-intent-v1` each write this receipt in the SAME write as the structural
747
- change, or refuse to proceed without one (`scripts/lib/revisions_writer.rb`); the intent
748
- curator (`agents/plastic-intent-curator.md`) holds itself to the identical rule by hand.
749
-
750
- Doctor stays a detector: core and full checks, every installed agent, both global and project
751
- stores. It gains no write path of its own. The "Fix all" prompt
752
- (`skills/doctor/SKILL.md`) is a ROUTER: for each fixable finding it dispatches to the tool
753
- that already owns that class of repair (`project-links`, `rebuild-graph`,
754
- `restore-intent-v1`, or the curator, via `scripts/maintenance-run` where applicable), and
755
- those tools perform the mutation and write the `revisions.md` receipt - never doctor itself.
756
-
757
- Corrected history (D18): an earlier version of this section described a terminal-immutability
758
- gate "intent 112 enforces" and a two-lock model. Intent 112 built that gate in full and was
759
- then ABANDONED before merge on a design pivot; nothing from it ever shipped. `bridge.rb:1195`
760
- confirms no such gate runs today: a write to a terminal intent is allowed unconditionally once
761
- the intent leaves INDEX `## Active`. The deadlock that stopped intents 189, 192, and 195 from
762
- repairing three live `graph_links_projection` violations was self-imposed discipline (agents
763
- and the owner both treating undocumented doctrine as a real gate), not a technical one. This
764
- section is the corrected doctrine; intent 112's own history stays in INDEX as an abandoned,
765
- superseded design.
766
-
767
- Restore-to-v1 (the owner rule that a completed intent is immutable: a late ruling goes to a
768
- new `--parent` branch intent, and the completed intent is restored to v1) is performed ONLY by
769
- `scripts/restore-intent-v1`. Its prose (the intent narrative, `checklist.md`, `outcome.md`,
770
- `spec.md`, `plan.md`) is immutable and reverts to v1; its frontmatter graph
771
- (`sources`/`chain`) is metadata about OTHER intents, not content of this one, and is
772
- APPEND-ONLY: preserved as the union of the v1 snapshot and the current snapshot, never
773
- subtracted. It writes its own `revisions.md` receipt in the same run. A hand-run whole-file
774
- `git checkout`/revert of a completed intent is FORBIDDEN, because it cannot distinguish prose
775
- from graph metadata and silently destroys backlinks written after v1 (proven on intent 124: a
776
- legitimately accrued chain edge was destroyed by a hand-run restore and went undetected for a
777
- week).
778
-
779
- Fail-safe lock doctrine (the contract intent 111 implements): the lock system never traps a
780
- session or burns credits. When a gate cannot verify lock integrity it fails open, degrading
781
- to advisory (warn) rather than hard-blocking. Repair is orchestrator-driven: on a lock-issue
782
- signal the orchestrator inspects and repairs the lock automatically, and the human
783
- `plastic-lock` command is a fallback path, not the trigger. Intent 93 states this doctrine;
784
- intent 111 builds the fail-open behavior, the lock-liveness surface, the lock-issue message,
785
- and the auto-repair.
786
-
787
- Scope split. Intent 93 ships doctrine plus the low-risk reconciliation that needs no new
788
- lock: the canonical done-marker and three-signal reconciliation, the mandatory `outcome.md`
789
- plus `disposition` header at both terminals, the End tail with the reindex moved last, the
790
- `done_signals` doctor check (three-signal agreement plus stalled-completion detection), and
791
- the lock-bounded post-done window with its keep-guard test. Intent 111 owns the lock
792
- liveness surface, the lock-issue message, orchestrator auto-repair, and the fail-open
793
- behavior itself. Intent 112 attempted a maintenance lock and an immutability gate; it was
794
- abandoned before merge and superseded by intent 197's WORK vs MAINTENANCE doctrine
795
- (detect-only lock, branch-and-merge, tool-enforced `revisions.md`). Intent 4a1b1 owns deep
796
- agent stuck-detection and is not superseded.
316
+ Exactly one session or agent develops an intent's delivery at a time. Ownership is a
317
+ session-keyed, durable `delivery.lock` (O_EXCL) in the intent directory; liveness is a lease
318
+ (the owner's hooks refresh the file mtime, stale means older than the TTL). The `/tmp` session
319
+ bridge is only a cache: the lock file wins on any disagreement. A per-artifact claim token
320
+ arbitrates the file grain underneath the lock. Every code-touching intent gets its own git
321
+ worktree (`<repo>/.claude/worktrees/{id}--{slug}`, branch `plastic/{id}--{slug}`); code edits
322
+ happen only inside it. On a confirmed solo delivery the lock and worktree gates relax to
323
+ advisory; any parallel or team activity restores strict enforcement.
324
+
325
+ "Intent done" is one law with three signals that must agree: INDEX `## Completed` /
326
+ `## Abandoned`, `outcome.md`, and the savepoint `Done` line; INDEX is authoritative on any
327
+ conflict.
328
+
329
+ Structural maintenance (WORK vs MAINTENANCE) never touches delivered content: it only records
330
+ itself in `revisions.md`, and only proceeds when the target's `delivery.lock` is not fresh.
331
+
332
+ See `plastic-conventions > references/locks-and-worktrees.md`,
333
+ `references/completion-and-done.md`, and `references/maintenance-and-revisions.md` for the full
334
+ doctrine.