@zalom/plastic 1.7.1 → 1.9.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 (72) hide show
  1. package/PLASTIC.md +75 -535
  2. package/README.md +3 -2
  3. package/agents/plastic-intent-curator.md +2 -2
  4. package/deprecations.yml +10 -2
  5. package/hooks/{links-gate → edit-gates} +1 -1
  6. package/hooks/hooks.json +4 -44
  7. package/hooks/power-tools +8 -0
  8. package/package.json +1 -2
  9. package/scripts/codex-hook +17 -22
  10. package/scripts/doctor.rb +688 -186
  11. package/scripts/end-intent +65 -22
  12. package/scripts/hook-code-gate +13 -28
  13. package/scripts/hook-create-gate +10 -57
  14. package/scripts/hook-edit-gates +58 -0
  15. package/scripts/hook-links-gate +8 -31
  16. package/scripts/hook-lock-gate +13 -58
  17. package/scripts/hook-power-tools +38 -0
  18. package/scripts/hook-savepoint-pre +8 -11
  19. package/scripts/lib/bridge.rb +2 -2
  20. package/scripts/lib/edit_gates.rb +342 -0
  21. package/scripts/lib/hook_registry.rb +61 -29
  22. package/scripts/lib/installer_core.rb +100 -18
  23. package/scripts/lib/outcome_guard.rb +38 -0
  24. package/scripts/lib/qmd_hook.rb +21 -41
  25. package/scripts/lib/qmd_sync.rb +0 -15
  26. package/scripts/lib/revisions_writer.rb +1 -1
  27. package/scripts/maintenance-run +56 -2
  28. package/scripts/restore-intent-v1 +16 -11
  29. package/skills/auto/SKILL.md +15 -4
  30. package/skills/auto/evals/evals.json +2 -2
  31. package/skills/conventions/SKILL.md +31 -0
  32. package/skills/conventions/references/completion-and-done.md +40 -0
  33. package/skills/conventions/references/gates-and-enforcement.md +23 -0
  34. package/skills/conventions/references/knowledge-graph.md +47 -0
  35. package/skills/conventions/references/lifecycle-and-savepoints.md +11 -0
  36. package/skills/conventions/references/locks-and-worktrees.md +113 -0
  37. package/skills/conventions/references/maintenance-and-revisions.md +170 -0
  38. package/skills/conventions/references/roadmaps.md +44 -0
  39. package/skills/conventions/references/tiers-and-dispatch.md +134 -0
  40. package/skills/doctor/SKILL.md +59 -19
  41. package/skills/intent-brainstorming/SKILL.md +4 -0
  42. package/skills/intent-continuing/SKILL.md +4 -0
  43. package/skills/intent-creating/SKILL.md +7 -2
  44. package/skills/intent-ending/SKILL.md +20 -6
  45. package/skills/intent-executing/SKILL.md +10 -0
  46. package/skills/intent-linking/SKILL.md +4 -0
  47. package/skills/intent-locking/SKILL.md +4 -0
  48. package/skills/intent-planning/SKILL.md +7 -0
  49. package/skills/intent-savepoint/SKILL.md +4 -0
  50. package/skills/intent-speccing/SKILL.md +4 -0
  51. package/skills/intent-starting/SKILL.md +10 -0
  52. package/skills/project-creating/references/project-scaffolding.md +2 -2
  53. package/skills/roadmap/SKILL.md +4 -0
  54. package/skills/roadmap-continuing/SKILL.md +4 -0
  55. package/skills/skill-creating/SKILL.md +3 -0
  56. package/skills/skill-creating/references/defaults-first.md +23 -0
  57. package/skills/skill-creating/references/hooks.md +4 -1
  58. package/skills/store-curating/SKILL.md +8 -0
  59. package/skills/store-indexing/SKILL.md +8 -0
  60. package/skills/tutorial/references/track-2-auto.md +2 -3
  61. package/templates/agents.md +8 -0
  62. package/PLASTIC-reference.md +0 -138
  63. package/hooks/code-gate +0 -27
  64. package/hooks/create-gate +0 -3
  65. package/hooks/lock-gate +0 -21
  66. package/hooks/qmd-search +0 -8
  67. package/hooks/retrieval-gate +0 -10
  68. package/hooks/savepoint-pre +0 -10
  69. package/scripts/hook-qmd-search +0 -44
  70. package/scripts/hook-retrieval-gate +0 -148
  71. package/scripts/lib/legacy_bookend_amnesty.rb +0 -35
  72. package/scripts/lib/retrieval_gate.rb +0 -211
@@ -0,0 +1,40 @@
1
+ # Completion and Done
2
+
3
+ This chapter holds what "intent done" means and the End-stage tail.
4
+
5
+ #### What "intent done" means (intent 93)
6
+
7
+ Done is one law with three signals, and they must agree. INDEX `## Completed` /
8
+ `## Abandoned` is the single canonical terminal marker: it is the store-wide ledger a fresh
9
+ session reads first, so it wins on any conflict. `outcome.md` is the "deliverable exists"
10
+ signal, and the savepoint `Done delivered|abandoned` line is the audit echo. All three must
11
+ agree; when they disagree, INDEX is authoritative and `doctor` flags the mismatch (the
12
+ `done_signals` check: `outcome.md` real but still under `## Active`, or terminal without a
13
+ real `outcome.md`, or a terminal intent whose savepoint carries no `Done` line).
14
+
15
+ `outcome.md` is mandatory at every terminal transition, delivered and abandoned alike. It
16
+ self-declares its disposition through a `disposition: delivered|abandoned` frontmatter
17
+ header. The delivered path authors it with the result; the abandoned path authors it with
18
+ the abandonment reason and no longer leaves the scaffolded placeholder sentinel in place.
19
+
20
+ The canonical End tail runs in this order, and the QMD reindex is always LAST, after the
21
+ purge: `outcome.md -> INDEX terminal -> savepoint Done -> commit -> disarm (Worktree.release
22
+ -> Lock.release -> purge) -> QMD reindex`. Running the reindex last keeps the index from
23
+ ever referencing a bridge or lock that disarm is about to remove.
24
+
25
+ `scripts/end-intent` performs this order's disarm step (verify the code worktree is clean,
26
+ then merge/remove worktrees, then clear the lock) as its own step 5, mechanically, since
27
+ intent 188: a session no longer needs a separate one-liner for it, and the script's own
28
+ exit code (0) is the single fact a caller needs that the intent is closed AND its delivery
29
+ lock is gone. A pre-flight lock guard runs before anything is written (refuses a live
30
+ foreign session, reclaims a stale one with an audit line), and a dirty code worktree
31
+ refuses before removal rather than force-discarding uncommitted changes.
32
+
33
+ The post-done access window is lock-bounded: `[INDEX terminal -> Lock.release]`. Through it
34
+ the completing session keeps full read and write access to the terminal directory and no
35
+ purge can fire (108's lock-held keep-guard keeps the bridge while `delivery.lock` exists).
36
+ Once the lock is released the window closes: the bridge becomes purge-eligible and the
37
+ directory is frozen. A crash mid-tail is recovered by stale-lock reclaim plus finishing the
38
+ tail; `doctor` surfaces this as a "stalled completion" (terminal in INDEX but the lock is
39
+ still present or stale). Finishing the tail is FINISHING a completion, never a reactivation:
40
+ a done intent is never moved back to `## Active`.
@@ -0,0 +1,23 @@
1
+ # Gates and Enforcement
2
+
3
+ This chapter holds the escape-and-logging depth for each transition gate.
4
+
5
+ #### The gates by name
6
+
7
+ Each gate guards one thing. All are hard:
8
+
9
+ - **create-gate** validates the proposed intent file at What write-time (Write, Edit, and MCP
10
+ edits), so a malformed or incomplete intent never lands.
11
+ - **gate-check** enforces lifecycle stage order (spec.md before plan.md, the plan triplet before
12
+ the checklist, all checklist items before outcome.md).
13
+ - **lock-gate** arbitrates ownership and claims: it admits only the intent's lock owner or a
14
+ registered delegate to write into an active intent directory, and every deny names the
15
+ resolving `plastic-lock` command.
16
+ - **bash-gate** intercepts a write attempted through a bash or interpreter one-liner (a heredoc, a
17
+ `>` redirect, a `ruby -e` or `python -c` write), so the same rules apply whether an edit goes
18
+ through the Write tool or a shell. A trailing `# plastic-ok` comment is an auditable escape that
19
+ lets a deliberate command through, and every use is logged to
20
+ `~/.plastic/.cache/gate-escapes.log`. The code gate (Write and Edit) carries the identical
21
+ audited `# plastic-ok` escape, logged to the same file. The escape does not extend to
22
+ `NotebookEdit` or MCP structural edits: they are still gated, just without an escape hatch.
23
+
@@ -0,0 +1,47 @@
1
+ # Knowledge Graph
2
+
3
+ This chapter holds the linking doctrine from Frontmatter and the branch-vs-root directory semantics from Directory Naming.
4
+
5
+ - `sources` (formative, must-load, acyclic) and `chain` (forward + relational, lighter,
6
+ may cycle) form the directed knowledge graph. Reciprocity is one-directional: every
7
+ `sources` edge has a reciprocal `chain` entry (I1), but `chain` may carry relational
8
+ entries with no reciprocal `sources` (I2), so the graph is not strictly symmetric.
9
+
10
+ - `## Links` (I5) is the human-readable projection of the graph. It mirrors the
11
+ frontmatter exactly: every entry is `- [[id--slug|<target's full intent: text>]]`, a
12
+ clickable `id--slug` wikilink target with the target intent's full `intent:` text as the
13
+ label (cross-store targets render `- [[store:id--slug|<target's full intent: text>]]`).
14
+ Ordering is mandatory: all `sources` first (top), then all `chain`, frontmatter order
15
+ preserved within each group. Sources never appear at the end. No source/chain tags, no
16
+ sub-grouping. An intent with empty `sources` and `chain` carries the empty-state comment.
17
+ - `## Links` is a DERIVED view, not a place to author links (Convention over Configuration).
18
+ It equals the projection of `sources` (first) then `chain`. Never hand-write or hand-edit a
19
+ `## Links` line, and never auto-delete one. The edge lives in the frontmatter graph; the
20
+ section is regenerated from it (doctor `graph_links_projection` enforces this identity). To
21
+ add a link, add the frontmatter edge, then reproject.
22
+
23
+ - Links are decided by CONTEXT INFLUENCE, not by shared files, shared symbols, or a topic
24
+ similarity score. The question is whether one intent's context actually informed another.
25
+ Three tiers:
26
+ - **sources:** the foundational context that shaped this intent's creation (a split, an idea
27
+ born during development, a merge). Earns an edge.
28
+ - **chain:** the context that materially helps DELIVER this intent. This is a HIGH bar: only
29
+ the genuinely delivery-moving intents, not everything in the same area. Earns an edge,
30
+ reflected in `## Links`.
31
+ - **tags:** a loose theme grouping for search. NOT a link. A shared tag is a door INTO the
32
+ store (filtered discovery), not a pathway BETWEEN two notes.
33
+ Judging influence is an agent's call, made by reading the candidate's Intent and Context. A
34
+ script cannot grade it, so `scripts/link-suggest` only gathers candidates with that evidence,
35
+ records a confirmed edge with a rating and reason, and flags drift.
36
+
37
+ **Branch vs root: the semantic decision.** The numbering is mechanics; choosing
38
+ *whether* to branch is meaning:
39
+
40
+ - **Branch (`14a`, `14b`):** a sub-task, refinement, or direct continuation of the
41
+ parent. It cannot stand on its own; it only makes sense as part of the parent's work.
42
+ - **Root (`15`, `16`)**: an independent thought, even if inspired by another intent.
43
+ Reserve `sources` for true created-from provenance (intents this was built out of). An
44
+ independent intent merely related to or inspired by another carries NO `sources`; record
45
+ the relation on the PREDECESSOR's `chain` (and mirror it as a
46
+ `[[id--slug|<target's full intent: text>]]` wikilink in `## Links`).
47
+ - **Rule of thumb:** if the intent could exist without its parent, it's a root.
@@ -0,0 +1,11 @@
1
+ # Lifecycle and Savepoints
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.
4
+
5
+ Background sessions and dispatched sub-agents do not write the insight themselves. They carry
6
+ each nugget home in the completion report's `insights:` field, and the orchestrator (or any
7
+ agent that can write the file) persists it via the helper. A session that cannot write the
8
+ intent file still returns its report, so the insight survives.
9
+
10
+ For the stage table (What/Why/How/Exec, deliverable, owning skill), see PLASTIC.md's Lifecycle
11
+ Stages section; each named skill's own `references/` holds that stage's own depth.
@@ -0,0 +1,113 @@
1
+ # Locks and Worktrees
2
+
3
+ This chapter holds the delivery lock, claims, worktrees, solo mode, fail-safe doctrine, and the station-by-station delivery table.
4
+
5
+ ### Delivery Isolation and the Single-Owner Lock
6
+
7
+ Exactly one session or agent develops an intent's delivery at a time. Ownership is
8
+ session-keyed and durable: arming acquires `delivery.lock` inside the intent directory
9
+ (atomically, O_EXCL). The session id is the authorization identity. Descriptive provenance
10
+ records the controller's explicit `harness`, `agent`, `model`, `thread`, and `mode` values,
11
+ but never grants access and is never inferred from transcripts or filesystem paths. Missing
12
+ fields on legacy locks display as `Unknown`. Liveness is a lease: the owner's hooks refresh
13
+ the lock file's mtime on tool activity, and that mtime is the sole heartbeat truth. The lock
14
+ counts as stale only when the mtime is older than the TTL. No process id is consulted anywhere.
15
+ The /tmp session bridge is a cache
16
+ of this state; on any disagreement, or when the bridge is missing, the lock file wins.
17
+ Another session that finds a fresh lock backs off; a stale lock is reclaimed only by
18
+ explicit takeover, which replaces the lock and appends an audit line to the intent's
19
+ savepoint.md. Rearming the same session preserves its acquired identity and refreshes known
20
+ provenance; an explicit takeover replaces the controller and starts new provenance.
21
+ Subagents spawned by the owner write under the owner's lock once registered as delegates.
22
+ Delegate activity status (`active`, `finished`, or `failed`) is descriptive and does not revoke
23
+ the session's string-array authorization. A registered delegate remains authorized until a
24
+ separate authorization-removal mechanism exists. Finished and failed delegate activity is
25
+ retained as descriptive history, bounded to the 20 most recent terminal entries. A controller,
26
+ a delegate, and an artifact claim are distinct evidence: controller ownership authorizes the
27
+ delivery, delegate registration authorizes a child session, and a claim selects one current
28
+ writer for one artifact. Disarm clears the lock; the End tail is ordered: verify, merge and remove
29
+ worktrees, clear the lock, and only then is the bridge purge-eligible. Repair is one
30
+ idempotent function with two entry points: the `plastic-lock` command (`who`, status, fix,
31
+ release, reclaim, delegate) and `/plastic-intent-starting`, so boarding self-heals. `who` is
32
+ read-only and reports the controller, mtime heartbeat, delegates, and claims from durable files.
33
+ This is
34
+ mandatory, not a convention.
35
+
36
+ Solo-mode gate defaults (intent 128): on a confirmed positive solo determination
37
+ (`Bridge.solo_delivery?`, a single owner working alone with no sign of parallel or team
38
+ delivery), the lock and worktree arbitration gates relax from enforced to advisory. The moment
39
+ any parallel or team activity appears they return to strictly enforced. This is a real behavior
40
+ difference, not just a message change: a solo session is not hard-blocked by these gates, a
41
+ shared one still is.
42
+
43
+ The bridge resolves the current session in a fixed precedence: the stdin `session_id` first, then
44
+ the `CLAUDE_CODE_SESSION_ID` environment variable, then a derived key when neither is present. A
45
+ bridge is purge-eligible by terminal state, not by age: it is removed only once its intent is no
46
+ longer active, never on a timer. See `docs/internals.md` for depth.
47
+
48
+ The delivery lock arbitrates at the whole-intent grain: it decides who may work
49
+ an intent at all. Underneath it, a per-artifact claim token (intent 111)
50
+ arbitrates at the file grain: it decides who, among those already holding the
51
+ delivery lock, is the one writer for one lifecycle file right now. A write to
52
+ `spec.md`, `plan.md`, `checklist.md`, or the intent file must hold both the
53
+ delivery lock and that file's claim. Claims live in `.claims/<artifact>.claim`
54
+ inside the intent directory, one small JSON file per artifact, scoped strictly
55
+ per-intent-per-artifact, never session-global. The claim gate is dormant
56
+ (allows) when no claim file exists for an artifact, so ordinary single-owner
57
+ work is unaffected; it engages, and denies, only when a second writer tries to
58
+ take a fresh claim someone else already holds. A stale or corrupt claim fails
59
+ open (the write proceeds, the claim yields) and the condition is surfaced in
60
+ `plastic-lock status`, which lists any live claims alongside the delivery
61
+ lock. See `plastic-lock claim`/`release-claim` and `docs/internals.md` for the
62
+ full mechanism.
63
+
64
+ There is exactly one lock in Plastic: `delivery.lock` (exclusive, one owner plus delegates),
65
+ shipped by intent 108. An earlier two-lock doctrine proposed a second `maintenance.lock`
66
+ (short TTL, structural move-and-record only); intent 112 built it in full and was then
67
+ abandoned before merge on a design pivot, so nothing from it ever shipped (`lock.rb`'s
68
+ `TYPES` seam is the only trace left). Intent 197 rejects the second lock outright rather than
69
+ reviving it: a lock held by a maintenance session could be mistaken by a resuming session
70
+ for an active delivery. Maintenance instead DETECTS `delivery.lock`'s freshness
71
+ (`Lock.fresh?`) and defers when fresh; it never acquires any lock of its own and leaves none
72
+ behind. See "WORK vs MAINTENANCE" in `references/maintenance-and-revisions.md` for the full
73
+ doctrine.
74
+
75
+ Every code-touching intent gets its own git worktree named `{id}--{slug}`, and all code edits
76
+ for that intent happen only inside it. Plastic provisions the worktree deterministically: it
77
+ resolves the project repo from `projects.yml` and runs `git -C <repo> worktree add`, so
78
+ isolation never depends on the current working directory. There is one worktree per project
79
+ intent, the code worktree at `<repo>/.claude/worktrees/{id}--{slug}` (branch
80
+ `plastic/{id}--{slug}`).
81
+
82
+ Plastic does not provision a second worktree for lifecycle-doc writes. Two things cover that
83
+ need instead. First, the harness's own native worktree: Claude Code manages its own code
84
+ worktree at `<repo>/.claude/worktrees/{name}`, and Codex manages its own at
85
+ `$CODEX_HOME/worktrees` (default `~/.codex/worktrees`); both exist on their own, independent of
86
+ anything Plastic provisions. Second, intent 197's branch-from-main plus scoped commit, which
87
+ gives store writes their own write safety without a dedicated worktree. Plastic tried a second,
88
+ dedicated store worktree at `<plastic_home>/.worktrees/{id}--{slug}` first; agents never wrote
89
+ into it, because every delivering agent writes lifecycle docs straight to the main store
90
+ checkout, so intent 178 retired the store worktree in favor of the two mechanisms above.
91
+
92
+ Provisioning fails open for intents that touch no project code (pure research or decision
93
+ intents in the global store, or a non-git repo): those get the lock only, and the worktree
94
+ block stays unprovisioned. The fail-open path is always logged, never silent.
95
+
96
+ Cleanup is part of Done: the End tail merges the branch, then removes the worktree. Never leave
97
+ an orphaned worktree behind, and clear a stale worktree reference with `git worktree prune`.
98
+
99
+
100
+ #### Intent delivery, station by station
101
+
102
+ How one intent travels from boarding to Done, and what the lock, bridge, and gates do at
103
+ each station.
104
+
105
+ | Station | Delivered artifact | Lock and bridge steps | Pre-stage gate | Post-stage record |
106
+ |---|---|---|---|---|
107
+ | 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 |
108
+ | 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` |
109
+ | 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` |
110
+ | 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` |
111
+ | 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 |
112
+ | 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 |
113
+ | 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 in `references/maintenance-and-revisions.md`) | 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` |
@@ -0,0 +1,170 @@
1
+ # Maintenance and Revisions
2
+
3
+ This chapter holds WORK vs MAINTENANCE, the revisions.md move-and-record contract, the violation-tag catalog, and the context-economy measurement buckets.
4
+
5
+ #### WORK vs MAINTENANCE (intent 197)
6
+
7
+ Plastic separates two different things an earlier doctrine blurred under one word,
8
+ "immutable." WORK is the delivered CONTENT an intent produced: the code and project files a
9
+ delivery changed, the research it recorded, the outcome it wrote. Once the intent is terminal
10
+ (Completed or Abandoned), that content is immutable - the only way to change it is another
11
+ intent that continues or reverts it. Editing a Done intent's own artifacts so it looks like it
12
+ delivered something different, or that parts are missing, is forbidden (the book analogy:
13
+ never rewrite the text on the pages of an old, valuable book).
14
+
15
+ MAINTENANCE is everything else: structure, the sources/chain graph, a section that does not
16
+ belong in the file, formatting, and any store-wide operational change (a new Plastic version
17
+ adding or removing a frontmatter field across every intent). Maintenance is not immutable and
18
+ needs no owner gate to run, on the one condition below (recording is universal). The
19
+ decidable test is CONTENT vs METADATA, not "meaning vs structure": a graph edit is structure
20
+ even when it is also, in a loose sense, about lineage, because it does not change what the
21
+ intent delivered. Precedent: plastic intent 124's own `revisions.md` v1 dropped a dead chain
22
+ edge to a non-existent `124b` (`[rule: broken-chain]`), and v2 added a missing required
23
+ reciprocity edge to `131` (`[rule: misplaced-content]`), both ordinary maintenance, not
24
+ owner-gated exceptions. Allowed maintenance: (a) a frontmatter chain/sources edge that points
25
+ to a non-existent or wrong intent, or a missing required edge; (b) an extra non-convention
26
+ section in the intent file, removed and moved into `revisions.md`; (c) a store-wide
27
+ operational change from a new Plastic version, applied to every intent; (d) any other
28
+ structural or operational tidy. Forbidden: anything that alters what the work delivered.
29
+
30
+ The residual guard on every graph edit: it must move TOWARD ground truth (drop a dangling or
31
+ false edge, add a reciprocity-forced or documented-real one) and must never invent a
32
+ relationship - "might be related" is never a valid `[rule:]` reason. This is already implied
33
+ by the mandatory `[rule: tag]` on every `revisions.md` entry; no additional per-edit owner
34
+ gate is needed for an ordinary graph fix of this kind.
35
+
36
+ Maintenance normally needs no intent and no roadmap at all; it runs through the maintenance
37
+ tools and skills and records itself. The one exception: a batch touching more than about 5
38
+ different intents at once must stay rare, and is always an owner decision - the agent asks
39
+ first and shows the diff before proceeding. This exception governs rare cross-intent sweeps;
40
+ it does not apply to an ordinary single-intent graph repair.
41
+
42
+ Maintenance target-state eligibility, by the intent's own lifecycle state: a Future intent,
43
+ yes; a Terminal (Completed or Abandoned) intent, yes; an Active intent mid-delivery, WAIT. The
44
+ wait is keyed on whether the target currently holds a FRESH `delivery.lock` (`Lock.fresh?`),
45
+ never on INDEX `## Active` membership - `end-intent` releases the lock only after the INDEX
46
+ move and its commit tail finish, so keying on Active membership would miss that tail window
47
+ and let maintenance race a live completion. A STALE lock is not maintenance's problem to
48
+ resolve; it is treated as not-active, and maintenance proceeds rather than waiting
49
+ indefinitely behind a dead session.
50
+
51
+ There is exactly one lock in the system (see the two-lock correction in
52
+ `references/locks-and-worktrees.md`, and the corrected history below in this chapter):
53
+ `delivery.lock`,
54
+ meaning an active agent is delivering that intent. Maintenance DETECTS this lock and NEVER
55
+ ACQUIRES it, even transiently, because a maintenance-held lock could be mistaken by a resuming
56
+ or continuation session for an active delivery. Maintenance leaves no lock behind: there is
57
+ nothing to clean up afterward, and no ambiguity about who, if anyone, holds the one lock.
58
+ `bridge.rb:1195`'s `lock_gate_decision` already allows any write once an intent is not in
59
+ INDEX `## Active` - there is no enforced freeze gate in the codebase today, and there never
60
+ was one that shipped (see the corrected history below).
61
+
62
+ Stranding and clobbering are avoided by construction, not by a second lock: a maintenance
63
+ action creates a fresh branch from the CURRENT state of store main, applies only its own
64
+ scoped changes, and merges that branch back to main as part of the SAME closed operation.
65
+ Nothing strands on an unmerged branch; two concurrent maintenance runs reconcile as ordinary
66
+ merge conflicts on main, never silent loss. This is lighter than intent 178's full per-session
67
+ delivery worktrees (178 stays about the agent write paths for delivery); maintenance only
68
+ needs branch-from-main plus scoped merge-back (`scripts/lib/maintenance_git.rb`,
69
+ `scripts/maintenance-run`).
70
+
71
+ No commit anywhere, store or project repo, uses `git add -A`; every maintenance and delivery
72
+ commit stages only the paths it actually changed (`scripts/end-intent`'s `store_commit`,
73
+ `scripts/maintenance-run`).
74
+
75
+ The one condition on every maintenance action, with no exception, is that it is recorded.
76
+ Every maintenance action, whether run by a tool or made by hand, must leave an append-only
77
+ `revisions.md` entry on its target intent (`## Revision vN`, a `Why ... [rule: tag]` line, a
78
+ `Prior location`, and the change itself). If the file already exists, a new run appends
79
+ `vN+1`; it never overwrites an earlier entry (precedent: intent 124's `revisions.md` v3
80
+ corrects v2 by appending a correction entry and explicitly leaving v2 in place). This is
81
+ tool-enforced, not prose alone: `scripts/project-links`, `scripts/rebuild-graph`, and
82
+ `scripts/restore-intent-v1` each write this receipt in the SAME write as the structural
83
+ change, or refuse to proceed without one (`scripts/lib/revisions_writer.rb`); the intent
84
+ curator (`agents/plastic-intent-curator.md`) holds itself to the identical rule by hand.
85
+
86
+ Doctor stays a detector: core and full checks, every installed agent, both global and project
87
+ stores. It gains no write path of its own. The "Fix all" prompt
88
+ (`skills/doctor/SKILL.md`) is a ROUTER: for each fixable finding it dispatches to the tool
89
+ that already owns that class of repair (`project-links`, `rebuild-graph`,
90
+ `restore-intent-v1`, or the curator, via `scripts/maintenance-run` where applicable), and
91
+ those tools perform the mutation and write the `revisions.md` receipt - never doctor itself.
92
+
93
+ Corrected history (D18): an earlier version of this section described a terminal-immutability
94
+ gate "intent 112 enforces" and a two-lock model. Intent 112 built that gate in full and was
95
+ then ABANDONED before merge on a design pivot; nothing from it ever shipped. `bridge.rb:1195`
96
+ confirms no such gate runs today: a write to a terminal intent is allowed unconditionally once
97
+ the intent leaves INDEX `## Active`. The deadlock that stopped intents 189, 192, and 195 from
98
+ repairing three live `graph_links_projection` violations was self-imposed discipline (agents
99
+ and the owner both treating undocumented doctrine as a real gate), not a technical one. This
100
+ section is the corrected doctrine; intent 112's own history stays in INDEX as an abandoned,
101
+ superseded design.
102
+
103
+ Restore-to-v1 (the owner rule that a completed intent is immutable: a late ruling goes to a
104
+ new `--parent` branch intent, and the completed intent is restored to v1) is performed ONLY by
105
+ `scripts/restore-intent-v1`. Its prose (the intent narrative, `checklist.md`, `outcome.md`,
106
+ `spec.md`, `plan.md`) is immutable and reverts to v1; its frontmatter graph
107
+ (`sources`/`chain`) is metadata about OTHER intents, not content of this one, and is
108
+ APPEND-ONLY: preserved as the union of the v1 snapshot and the current snapshot, never
109
+ subtracted. It writes its own `revisions.md` receipt in the same run. A hand-run whole-file
110
+ `git checkout`/revert of a completed intent is FORBIDDEN, because it cannot distinguish prose
111
+ from graph metadata and silently destroys backlinks written after v1 (proven on intent 124: a
112
+ legitimately accrued chain edge was destroyed by a hand-run restore and went undetected for a
113
+ week).
114
+
115
+ Fail-safe lock doctrine (the contract intent 111 implements): the lock system never traps a
116
+ session or burns credits. When a gate cannot verify lock integrity it fails open, degrading
117
+ to advisory (warn) rather than hard-blocking. Repair is orchestrator-driven: on a lock-issue
118
+ signal the orchestrator inspects and repairs the lock automatically, and the human
119
+ `plastic-lock` command is a fallback path, not the trigger. Intent 93 states this doctrine;
120
+ intent 111 builds the fail-open behavior, the lock-liveness surface, the lock-issue message,
121
+ and the auto-repair.
122
+
123
+ Scope split. Intent 93 ships doctrine plus the low-risk reconciliation that needs no new
124
+ lock: the canonical done-marker and three-signal reconciliation, the mandatory `outcome.md`
125
+ plus `disposition` header at both terminals, the End tail with the reindex moved last, the
126
+ `done_signals` doctor check (three-signal agreement plus stalled-completion detection), and
127
+ the lock-bounded post-done window with its keep-guard test. Intent 111 owns the lock
128
+ liveness surface, the lock-issue message, orchestrator auto-repair, and the fail-open
129
+ behavior itself. Intent 112 attempted a maintenance lock and an immutability gate; it was
130
+ abandoned before merge and superseded by intent 197's WORK vs MAINTENANCE doctrine
131
+ (detect-only lock, branch-and-merge, tool-enforced `revisions.md`). Intent 4a1b1 owns deep
132
+ agent stuck-detection and is not superseded.
133
+
134
+ `revisions.md` is an optional, append-only structural-maintenance audit trail. It is not a
135
+ lifecycle deliverable and is never scaffolded at intent birth. Its mere existence signals that
136
+ the intent underwent structural (not conceptual) change. Structural maintenance is move-and-record:
137
+ it removes a misplaced section, file, or ref from its artifact and preserves that content in full
138
+ inside `revisions.md` (newest entry at the bottom, one entry per relocated item), so no record is
139
+ lost and the delivered meaning is never altered. Changing what an intent delivered is a new intent,
140
+ not a revision.
141
+
142
+ #### Structural maintenance and revisions.md
143
+
144
+ When a delivered intent accumulates structural junk (an unsanctioned section, a stray file, a
145
+ frontmatter edge to an intent that no longer exists), the intent-curator relocates it into
146
+ `revisions.md` instead of reopening the work. Each entry is a versioned, dated header
147
+ (`## Revision vN - YYYY-MM-DD-HH:MM`) plus `Why` (one sentence naming the broken rule, ending
148
+ with `[rule: <tag>]`), `Prior location`, and either `Content held` (the verbatim removed
149
+ content) or, for a frontmatter edit, a one-line `Change` (before and after). A stray file has
150
+ its full content embedded and the original is deleted.
151
+
152
+ Violation tags (starter set, free-text tags allowed):
153
+ - `unsanctioned-section`: a top-level section the sanctioned-section rule now rejects
154
+ - `phantom-section`: a section referenced but not present or not sanctioned
155
+ - `stray-file`: a file that does not belong in the intent directory
156
+ - `dangling-ref`: a link or reference to something that no longer exists
157
+ - `broken-chain`: a chain frontmatter edge to an intent that no longer exists
158
+ - `broken-source`: a sources frontmatter edge to an intent that no longer exists
159
+ - `misplaced-content`: content that belongs in a different artifact or section
160
+ - `links-projection`: a tool-authored `## Links` regeneration (project-links; intent 197)
161
+ - `graph-rebuild`: a tool-authored sources/chain frontmatter rebuild (rebuild-graph; intent 197)
162
+
163
+ ### Context-economy measurement buckets (84a)
164
+
165
+ Intent 84 defines three buckets for sibling 84a to audit against; 84 does not run the audit.
166
+
167
+ - (a) gate-hook prose tokens: the per-transition narration emitted by the gate hook.
168
+ - (b) main-loop store-read tokens: tokens the main agent spends reading or grepping the store
169
+ in the transcript.
170
+ - (c) authored-section sizes: sizes of authored artifacts (INDEX entries and the like).
@@ -0,0 +1,44 @@
1
+ # Roadmaps
2
+
3
+ This chapter holds the full roadmap file format and its relationship to INDEX.md status and to loop engineering.
4
+
5
+ ### Roadmaps
6
+
7
+ Roadmaps exist for planned parallel delivery of intents in a coherent and organized way. A roadmap
8
+ is a named, ordered, delivery-side collection of intents: the delivery-side counterpart to a
9
+ release (completion-side, tracked in `CHANGELOG.md`). Use `plastic-roadmap` to create, order,
10
+ close, and consume one.
11
+
12
+ File location: `roadmaps/{slug}.md`, a sibling of `INDEX.md`, wherever `INDEX.md` lives, never
13
+ inside `store/` (store holds intent directories, not project artifacts). For a project that is its
14
+ root, `~/.plastic/projects/{slug}/roadmaps/`, beside `project.yml`; for the global tier it is
15
+ `~/.plastic/roadmaps/`, beside `~/.plastic/INDEX.md`. `roadmaps/` lists only live (open or
16
+ in-flight) roadmaps: once a roadmap's goal is reached, it moves to `roadmaps/archived/{slug}.md`,
17
+ a sibling subdirectory scaffolded once with a `.gitkeep`.
18
+
19
+ A roadmap file has four sections, in order: a title/meta header, `## Goal`, `## Batches`, and an
20
+ append-only dated `## Log`. `## Goal` is a checkable prose condition read by a human or agent, not
21
+ an executable checker. `## Batches` holds ordered batches; entries inside a batch are
22
+ parallel-safe, batches run sequentially, top to bottom. A roadmap written before owner ruling 145
23
+ may instead use the legacy `## Waves` heading; the tooling accepts both, but never renames an
24
+ existing roadmap file to migrate it.
25
+
26
+ Each batch entry carries a status token (`queued`/`delivering`/`delivered`/`abandoned`/`blocked`)
27
+ that mirrors that intent's status in `INDEX.md`. `INDEX.md` is the single writer of intent status;
28
+ on any conflict INDEX wins and the roadmap entry is corrected to match.
29
+
30
+ **Human-comprehension surface.** A roadmap is also written to be read cold. Batch entries render as
31
+ checkboxes (checked once delivered, unchecked otherwise) next to the status token, and each `## Log`
32
+ line is one plain-language sentence, starting `YYYY-MM-DD HH:MM UTC`, written the way an
33
+ engineering manager would brief a non-expert executive: what shipped and why it matters, no jargon
34
+ or codenames, ending with a link
35
+ to that intent's `outcome.md`. The log points at the detail instead of repeating it, so a person
36
+ opening the file with no other context can tell what shipped, what is running now, and what is
37
+ next in under a minute.
38
+
39
+ **Relationship to loop engineering (intent 69).** A roadmap is the planning half of the work; the
40
+ loop is its runtime. Batches lay out the parallelism plan: what can run together, and in what order.
41
+ Loop engineering (intent 69, not yet delivered) is expected to consume that plan and supply the
42
+ running parts, the heartbeat, how many dispatches run at once, checking the goal, and resuming
43
+ after a stop. This section only states the relationship and points to intent 69 as the future
44
+ consumer; it does not change intent 69's own design.
@@ -0,0 +1,134 @@
1
+ # Tiers and Dispatch
2
+
3
+ This chapter holds tier depth beyond the S/M/L definition, the agent-model and dispatch mechanics, and the auto-mode human reporting contract.
4
+
5
+ Speed comes from two levers only: artifact content depth and agent topology. The
6
+ same-structure invariant holds: same file set, stage order, gates, and savepoint ledger at
7
+ every tier and in both modes.
8
+
9
+ S/M collapse the topology (one thinker agent writes spec.md then plan.md plus
10
+ checklist.md plus at least one real action file in one context, consolidated into a single
11
+ actions/ACTION_1.md at S/M and one file per task at L; a sonnet executor implements). L
12
+ keeps the full team.
13
+
14
+ Never cut at any tier: the independent reviewer, outcome.md as truth of delivery, the
15
+ delivery lock, worktree isolation, intent creation via skill, INDEX as status truth, the
16
+ QMD reindex at End.
17
+
18
+ Guided mode is unchanged: full-depth artifacts, the human at every gate.
19
+
20
+ Every lifecycle stage has exactly one dispatchable background agent, plus the enforcer that
21
+ orchestrates them: see PLASTIC.md's Agent Models and Dispatch table for the stage-to-agent
22
+ mapping (What, Why, How, Exec, Done).
23
+
24
+ Final-gate code review stays an ad-hoc subagent the enforcer dispatches at the final gate, not
25
+ a standing role.
26
+
27
+ **The advisor: two consultation agents, never injected (intent 185).** Neither is a stage
28
+ role: never in PLASTIC.md's Agent Models and Dispatch table, never dispatched by the auto
29
+ pipeline, and neither ever touches a user's own session. `plastic-advisor` is the real advisor, ships `model: fable`,
30
+ expensive, billed through usage credits. `plastic-faux-advisor` is the imitation advisor, ships
31
+ `model: opus`, an ordinary model carrying the Operating Manual's reasoning discipline inlined
32
+ in its own body (not injected into anything), so it reasons the same disciplined way at a
33
+ fraction of the cost. The `plastic-agent-advisor` skill is the one front door: it teaches when
34
+ consulting is worth the money (from the Advisor Protocol: buy one-way doors, plans, adversarial
35
+ review, deadlocks, ranking; never buy what a tool can answer, code volume, or confirmation of a
36
+ decision already made), routes to the configured agent, and can set the config on request. The
37
+ user or the main session states a TIER (S, M, or L) and an EFFORT line in the brief; shipped
38
+ effort is `xhigh` for `plastic-advisor` and `max` for `plastic-faux-advisor`.
39
+
40
+ Config is harness-scoped, keys matching `InstallerCore::DEFAULT_AGENTS` exactly (`claude`,
41
+ `codex`, never `claude_code`): `advisor.enabled` (false skips installing both agents and the
42
+ skill), `advisor.claude.default` (which agent the skill routes to), `advisor.claude.primary`
43
+ and `.secondary` (the two slots, agent NAMES never model names, so a slot can point at a
44
+ locally registered agent). Each agent's actual model is a plain `agents.models.claude.<name>`
45
+ override, the SAME harness-scoped mechanism every other agent uses, resolved through
46
+ `InstallerCore#agent_model_overrides(harness:)`; there is no separate advisor-model key.
47
+ `agents.models` is harness-scoped from this release (`agents.models.claude.*`,
48
+ `agents.models.codex.*`), with the pre-existing flat form (`agents.models.<name>: value`)
49
+ still honored as the claude harness and nested winning over flat. This closes a real latent
50
+ bug: previously the same override map fed both the Claude frontmatter rewrite and the Codex
51
+ TOML generator, so a literal Claude model id could leak into a Codex config; a model named
52
+ under `claude` is now never emitted to `codex`. Install asks which advisor is the default
53
+ (Claude Code only), with a plain description of each: Faux Fable (recommended, cheaper,
54
+ available on any plan) or Fable 5 (the frontier model, billed through credits). Update asks
55
+ the same question once when the key is unset, then never again. Claude-only for this release:
56
+ the owner has not evaluated the Codex reasoning-model ecosystem long enough to judge it, so
57
+ `generate_codex_agents` skips both agents by name, tracked at intent 186, not a permanent
58
+ exclusion.
59
+
60
+ **Auto-mode entry.** `plastic-auto` is the entry skill for autonomous delivery: it takes over How
61
+ and Exec, spins up the stage-agent team named in PLASTIC.md's Agent Models and Dispatch table,
62
+ and works the dashboard's dispatchable queue. The dashboard's
63
+ `--data` output splits intents into a `dispatchable_queue` (work an agent can pick up) and
64
+ `human_only` (intents that need a person); auto mode consumes the former.
65
+
66
+ **Model contract.** Every agent in `agents/*.md` pins an explicit Claude Code model alias in
67
+ its own frontmatter: `opus`, `sonnet`, or `haiku`. Never `inherit`, never Fable by default,
68
+ unless an explicit `agents.models.<name>` config override names Fable for that role, in which
69
+ case the override is honored as written. The two advisors, `plastic-advisor` and
70
+ `plastic-faux-advisor`, are not lifecycle stage roles: the never-Fable rule governs stage
71
+ agents only. Neither is ever dispatched by the auto pipeline; they are consultation roles
72
+ summoned deliberately by the user or the main session, and their models are user configuration
73
+ (fable and opus by default on Claude Code). Aliases track "latest
74
+ per tier" so no Plastic release is required to advance a tier. The tier by role:
75
+ `plastic-enforcer`, `plastic-brainstorming`, `plastic-planner` are `opus`;
76
+ `plastic-spec-specialist`, `plastic-executor`, `plastic-intent-curator`,
77
+ `plastic-future-intent-researcher`, `plastic-intent-discovery` are `sonnet`.
78
+
79
+ **Config and installer mechanism.** `agents.models.<basename>` in a project's
80
+ `<dir>/.plastic_store/config.yml` or the global `~/.plastic/config.yml` overrides one agent's
81
+ tier. Precedence is project, then global, then the shipped default, matching every other
82
+ `read-config` key. The installer applies the resolved override to each agent file's `model:`
83
+ line at copy time (install, update, and repair, across every harness target). With no override
84
+ configured, the shipped frontmatter passes through unchanged.
85
+
86
+ **Dispatch-time contract.** Frontmatter is primary, and Claude Code reads it at dispatch, but
87
+ because that read is a harness implementation detail rather than a contract Plastic controls,
88
+ every dispatch site also resolves the target agent's model through the config chain
89
+ (`read-config agents.models.<basename> --project <repo>`) and passes it explicitly at dispatch,
90
+ belt-and-braces on top of the frontmatter pin.
91
+
92
+ **Cross-harness portability.** The dispatch and model-tier contract above is harness-facing. The
93
+ adapter layer that maps Plastic's hooks and model aliases onto each supported agent runtime
94
+ (Claude, Codex, Hermes) is the cross-harness portability layer; see
95
+ docs/reference/harness-adapters.md for the adapter contract.
96
+
97
+ **Spawn preamble (intent 152).** `scripts/spawn-preamble` emits a live-state block purely from
98
+ filesystem state: the active intent, stage, role/cycle-step, the honor instruction, and the
99
+ report contract. When the intent's code worktree is resolvable and exists on disk, it also
100
+ appends the worktree's absolute path plus a verbatim instruction to `cd` there directly, for
101
+ harnesses whose `EnterWorktree` cannot discover a nested repo from a non-repo launch directory.
102
+ Output is byte-identical when no worktree resolves.
103
+
104
+ **Orchestrator advisory.** At auto-mode start, the orchestrator recommends once that the user
105
+ run the main session on the best available thinking model (Fable, Opus, or whatever supersedes
106
+ them). This is advisory only: it changes no behavior and blocks nothing if ignored, and it
107
+ concerns the human's main session, never a dispatched subagent. The two advisors,
108
+ `plastic-advisor` and `plastic-faux-advisor`, are not lifecycle stage roles: the never-Fable
109
+ rule governs stage agents only. Neither is ever dispatched by the auto pipeline; they are
110
+ consultation roles summoned deliberately by the user or the main session, and their models are
111
+ user configuration (fable and opus by default on Claude Code).
112
+
113
+ **`plastic-intent-discovery`.** The What-stage agent. It fires at intent activation, after the
114
+ delivery lock is armed and before Why begins, running under that lock as the owner session (it
115
+ does not acquire the lock itself and is not blocked by it): it reads the intent's
116
+ `chain`/`sources` frontmatter, runs QMD-first discovery over completed predecessor work and
117
+ related parked or future intents, and deposits findings to `resources/discovery--<slug>.md` in
118
+ the intent directory ONLY. It never writes the intent file, `spec.md`, or any other lifecycle
119
+ deliverable; the Why-stage `plastic-brainstorming` agent reads its deposit and enriches
120
+ `## Context`.
121
+
122
+ `savepoint.md`: a deterministic, append-only ledger of cycle-step milestones (one line per
123
+ lifecycle boundary, newest at the bottom), written automatically by the gate hook. It is
124
+ sugar on top of the conventions, not a source of truth: state is always derivable from
125
+ files-on-disk, and the ledger is rebuildable. It exists so a resuming agent reads the cycle's
126
+ succession at a glance (last line = where we are).
127
+
128
+ ### Auto-Mode Human Reporting (intent 92)
129
+
130
+ In auto mode the orchestrator briefs the human at every lifecycle stage boundary in a fixed,
131
+ impact-first shape (the EM-to-CTO report contract): State, then Risk, then Call. It leads with
132
+ what changed and why it matters, names one risk, and leaves the decision to the human. Separately,
133
+ the `plastic-humanizer` skill cleans authored prose (specs, outcomes, READMEs, release notes) of
134
+ AI tells and slop; it is for documents, not for every reply.