@gobing-ai/spur 0.3.78 → 0.3.80

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.
@@ -3,478 +3,246 @@ name: Project Constitution
3
3
  doc: 99_PROJECT_CONSTITUTION
4
4
  owns: PROCESS — how the key files are maintained
5
5
  authority: authoritative-on-process
6
- version: 1.4.0
6
+ version: 1.6.0
7
7
  created_at: {{init-date}}
8
8
  updated_at: {{init-date}}
9
9
  edit_rules: 99 §6.8
10
10
  sync: [T7]
11
- read_before: editing any numbered doc above
11
+ read_before: editing key project documents
12
12
  ---
13
13
 
14
14
  # Project Constitution — How to Organize the Project
15
15
 
16
16
  ## 1. What this is & what this is not
17
17
 
18
- This is the **constitution** for the project's key files: an accumulated, machine-maintained set
19
- of rules and lessons for running the same file structure across different projects and
20
- cooperating with multiple coding agents (Claude Code, Codex, Gemini CLI, pi, omp, Antigravity,
21
- OpenCode, OpenClaw, Hermes, Grok, ...).
18
+ This file defines document responsibilities, authority, edit rules, and synchronization.
19
+ It is stable project metadata. Product facts, implementation guidance, task outcomes, review
20
+ reports, and accumulated lessons belong elsewhere (§4.2, §8).
22
21
 
23
- - One copy lives in every project at `docs/99_PROJECT_CONSTITUTION.md`.
24
- - It is **byte-identical across projects** except the Lessons sections (§8) and the tool-binding
25
- column (§3). When it improves in one project, propagate to the others — forks are drift.
26
- - It contains **zero project-specific facts** — no project command names, package names, feature
27
- states, or decisions. Project facts live in the numbered docs this file governs. If you find a
28
- project fact here, that itself is drift: move it to its owning doc.
29
-
30
- This is **not** a project review summary, a technical review list, or a product-design
31
- reflection.
32
-
33
- Audience: humans and coding agents equally. Every rule below is written to be checkable — an
34
- agent should be able to verify compliance mechanically, not interpret intent.
22
+ The same responsibilities apply to new-project templates. Project tool bindings belong in
23
+ `AGENTS.md`; this constitution does not require unrelated repositories to be byte-identical.
35
24
 
36
25
  ## 2. Authority model
37
26
 
38
- Two axes that cannot collide:
39
-
40
- | Axis | Question | Winner |
41
- |------|----------|--------|
42
- | **Content** | What is true about the project? | Lower number wins: `00_ADR` is binding on *decisions*; `01_PRD` is authoritative on *scope*; `02`–`05` are derived |
43
- | **Process** | How are the key files maintained? | **This file** |
27
+ Host instructions and the operator's request retain their native precedence.
28
+ Within project documentation, authority is scoped to the question:
44
29
 
45
- They cannot conflict because this file holds no project content (§1 rule 3).
30
+ | Question | Owner |
31
+ | --- | --- |
32
+ | Architectural choice and its rationale | `00_ADR` |
33
+ | Product intent and scope | `01_PRD` |
34
+ | Document responsibilities and maintenance | This constitution |
35
+ | Visual and interaction design | Root `DESIGN.md`, when present |
36
+ | Delivery sequence, current mechanisms, non-UI contracts, feature state | `02`–`05`, derived within their respective responsibilities |
46
37
 
47
- **Why this file is numbered 99, not 00:** "lower number wins" is a *content* rule, and this file
48
- plays on the other axis. The out-of-band number is the visible signal that the constitution sits
49
- outside the content chain renumbering it into the chain (e.g. as `00`) would re-entangle the
50
- two axes and force a renumber of every content doc, invalidating the dense web of cross-pointers
51
- (`03 §12`-style references baked into append-only ADR text) for a purely aesthetic gain. Do not
52
- renumber.
53
-
54
- **Content conflict rule:** when two docs disagree, fix the **authoritative** doc first (with a
55
- dated amendment if it is append-only), then the derived doc, then `AGENTS.md` — and flag the
56
- drift in the commit message or task. Never average two conflicting statements into a third.
38
+ Lower numbers win content conflicts within the same subject; `99` governs maintenance across
39
+ all key files. Neither an ADR nor a task can silently change the constitution. An ADR is not
40
+ a universal override for unrelated scope or UI facts. Fix the authoritative statement first,
41
+ then affected projections; never average conflicting statements. Keep document numbers stable.
57
42
 
58
43
  ## 3. Shared tools
59
44
 
60
- Tools are bound by **role**; roles are permanent, bindings evolve. This table is the only
61
- project-variable section besides Lessons update the binding when the toolchain migrates.
62
-
63
- | Role | Current binding | Notes |
64
- | ------ | ----------------- | ------- |
65
- | Spec lifecycle — tasks | *(project tool — e.g. `spur task` or a task CLI)* | Task files are tool-owned; edit through the tool, never the Write tool |
66
- | Spec lifecycle — features | *(project tool — e.g. `spur feature` or a feature CLI)* | Same tool-owned rule |
67
- | Delivery harness | *(project harness — e.g. `spur`)* | Quality gates are self-hosted through it where possible |
68
- | Agent-facing wrappers | per-project plugin dir (e.g. `plugins/sp/`) | **Fat Skills, thin others:** skills are the SSOT for agent-facing behavior and may be arbitrarily rich; slash commands and subagents are thin wrappers of skills (every agent supports skills; command/subagent support varies) |
45
+ Use the configured domain tools for records they own. Tasks, feature files, and generated
46
+ indexes are tool-owned; never modify them with raw file writes. `AGENTS.md` names the project's
47
+ CLI bindings and gates. Skills explain how to operate them; they do not redefine this document map.
69
48
 
70
49
  ## 4. Common file layout
71
50
 
72
51
  ### 4.1 The doc map (canonical template)
73
52
 
74
- Each project's `AGENTS.md` embeds an instantiated copy of this table (§4.4). A fact lives in
75
- **one** doc; other docs link to it, never restate it.
76
-
77
- | Doc | Owns the question | Authority | Read / edit when |
78
- | ----- | ------------------- | ----------- | ------------------ |
79
- | `docs/00_ADR.md` | **WHY**which cross-cutting decision was made, and the one-line reason | **Authoritative** (wins all content) | Read before any structural change; add a dated entry before diverging from a decision |
80
- | `docs/01_PRD.md` | **WHAT**product vision, users, scope (in / out / deferred) | **Authoritative on scope** | Read before adding a command/feature; edit when scope changes |
81
- | `docs/02_ROADMAP.md` | **WHEN**phases, current vs deferred, sequencing | Derived | Read to place work in a phase; edit when phase status changes |
82
- | `docs/03_ARCHITECTURE.md` | **HOW**module boundaries, data flow, runtime model, invariants, rationale-in-depth | Derived (ADR wins) | Read before cross-module/seam/schema work; edit when boundaries or mechanisms change |
83
- | `docs/04_DESIGN.md` | **SURFACE**concrete shapes: every CLI command, flag, config key, env var, table, DTO; **index over `docs/design/<slug>.md`** (§4.5) | Derived | Read/edit when changing a non-UI command, flag, env var, or schema — same commit |
84
- | `DESIGN.md` (repo root) | **UI/UX SURFACE** visual design, color tokens, typography, component specs, layout, micro-animations, accessibility | **Authoritative for UI/UX when present** | Read/edit when planning or implementing UI/UX visual changes (dynamically supported; ignored when absent) |
85
- | `docs/05_FEATURES.md` | **STATUS** — feature decomposition + state (✅ done / 🔶 partial / ⏳ planned / 💤 deferred); **index over `docs/features/<id>_<slug>.md`** (§4.5) | Derived | Read to find a feature's state; edit when a feature's status changes |
86
- | `docs/99_PROJECT_CONSTITUTION.md` | **PROCESS** how the files above are maintained | **Authoritative on process** | Read before editing any doc above; edit per §6.8 |
87
- | `AGENTS.md` (repo root) | **ENTRY** — how agents work in this repo: stack, commands, gates, conventions + the instantiated doc map | Derived (from 99 + 00/01/04) | Read first every session; regenerate factual blocks from code (§6.7) |
88
-
89
- **Routing — put each fact in its owning doc, link from the rest:**
90
-
91
- - Decision + one-line reason → `00`. Rationale/mechanism in depth → `03`.
92
- - Scope (in/out/deferred) → `01`. Mechanism / data flow / invariants → `03`.
93
- - UI/UX visual design, design tokens, component specs & accessibility → `DESIGN.md` (when present; otherwise follow established project UI conventions).
94
- - Non-UI command/flag/config/schema/DTO shapes → `04`. Phase timing → `02`. Feature status → `05`.
95
- - If you are writing *how it's built* or *why* inside `00`/`01`/`02`, it belongs in `03`/`04`.
53
+ | File | Owns | Excludes |
54
+ | --- | --- | --- |
55
+ | `AGENTS.md` | ENTRY — repo orientation, essential commands, constraints, and links to owners | Detailed designs, command catalogs, progress logs, duplicated runbooks |
56
+ | `DESIGN.md` (root, optional) | UI/UX visual language, tokens, typography, components, layout, motion, accessibility, responsive behavior | CLI/API/schema contracts, delivery status, general agent instructions |
57
+ | `docs/00_ADR.md` | WHY lasting architectural choices, context, alternatives/tradeoffs, consequences | Feature approvals, task updates, bugfix logs, verification receipts, implementation walkthroughs |
58
+ | `docs/01_PRD.md` | WHATproduct vision, users, principles, scope and exclusions | Delivery state, schedules, implementation details |
59
+ | `docs/02_ROADMAP.md` | WHENphase goals, sequence, dependencies, exit criteria | Per-task work logs, API details, repeated feature acceptance criteria |
60
+ | `docs/03_ARCHITECTURE.md` | HOW — current module boundaries, data flow, runtime, invariants | Command catalogs, schema dumps, task completion narratives |
61
+ | `docs/04_DESIGN.md` + `docs/design/` | SURFACEindex and detailed non-UI contracts: CLI, APIs, config, schemas, DTOs, boundary behavior | UI design rules, duplicated architecture, delivery receipts |
62
+ | `docs/05_FEATURES.md` + `docs/features/` | STATUSentry to tool-owned feature decomposition, acceptance criteria, lifecycle state | A second manually maintained status ledger |
63
+ | `docs/99_PROJECT_CONSTITUTION.md` | PROCESSresponsibilities, authority, maintenance and synchronization of these files | Product decisions, tool catalogs, project history, routine lessons |
64
+
65
+ A fact has one owner. Link from other documents. A feature may change architecture, but its
66
+ size, approval, task count, or completion alone does not qualify it for an ADR (§6.1).
96
67
 
97
68
  ### 4.2 Working layers (outside the authority chain)
98
69
 
99
- | Location | Purpose | Rules |
100
- | ---------- | --------- | ------- |
101
- | `docs/plans/YYYY-MM-DD-<topic>.md` | Dated working documents: research, triage, design discussions, decision records-in-progress | They **record**, they do not **govern**. Once concluded, immutable except dated correction sections. Decisions they reach must be promoted into `00`–`05` to take effect |
102
- | `docs/tasks/` | Task files | Tool-owned (§3). Never edited with raw file writes |
103
- | other `docs/` folders | Optional scratch (analysis, refactor notes, ...) | Nothing in the authority chain may depend on them |
70
+ - Dated `docs/plans/` and `docs/reports/` files hold proposals, investigations, audits and evidence.
71
+ They record work; accepted conclusions take effect only in their proper owner.
72
+ - Configured task folders hold requirements, implementation plans, results and verification,
73
+ maintained through the task tool. Resolve their paths through that tool.
74
+ - Existing project context or learning storage holds reusable lessons (§8).
75
+ - `docs/design/` and `docs/features/` are governed detail layers (§4.5), not scratch storage.
104
76
 
105
- `docs/design/` and `docs/features/` are **not** scratch they are the satellite layers of `04` and
106
- `05` and are governed by §4.5.
77
+ Preserve historical evidence and its dates. It may be linked for provenance, but current
78
+ contracts must be understandable without treating an old plan or report as governing policy.
107
79
 
108
80
  ### 4.3 Standard frontmatter (the doc's machine-readable contract)
109
81
 
110
- Every numbered doc (`00`–`05`, and `99` itself) opens with YAML frontmatter carrying its doc-map
111
- row plus bookkeeping so an agent learns the doc's contract from the file head without loading
112
- the doc map, and tooling can validate it:
82
+ Numbered documents carry `doc`, `owns`, `authority`, `version`, `updated_at`, `read_before`,
83
+ `edit_rules`, and `sync`; derived documents also identify `derived_from`. Keep existing
84
+ owner/creation metadata. `edit_rules` points to §6; `sync` names applicable §5 trigger IDs.
113
85
 
114
- ```yaml
115
- ---
116
- doc: 03_ARCHITECTURE
117
- owns: HOW module boundaries, data flow, runtime model, invariants
118
- authority: derived # authoritative | authoritative-on-scope | authoritative-on-process | derived
119
- version: 1.1.0
120
- derived_from: [00_ADR, 01_PRD] # omit for 00
121
- owner: <name>
122
- updated_at: YYYY-MM-DD
123
- read_before: cross-module, seam, or schema work
124
- edit_rules: 99 §6.4
125
- sync: [T1] # §5 trigger IDs that obligate touching this doc
126
- ---
127
- ```
128
-
129
- Rules:
130
-
131
- 1. The frontmatter **is** the instantiated copy of this file's §4.1 row — `owns`/`authority`
132
- must match it verbatim in meaning; the §7 audit checks this. On mismatch, §4.1 wins.
133
- 2. `edit_rules` points to the owning §6 subsection — rules are never restated in frontmatter
134
- (pointers over prose, §6.0).
135
- 3. Bump `version` (minor) on any substantive edit; always refresh `updated_at` in the same edit.
136
- A doc whose `updated_at` predates a change it should reflect is drift — repair per §7.
137
- 4. Frontmatter replaces the legacy bold header block (`**Version:** …` lines); a doc carrying
138
- both is drift.
139
- 5. Doc **bodies do not restate** their own authority or the conflict rule ("when this conflicts
140
- with the ADR, the ADR wins") — frontmatter `authority` and §2 own that. Preamble
141
- restatements are drift.
86
+ Use `authoritative` for `00`, `authoritative-on-scope` for `01`,
87
+ `authoritative-on-process` for `99`, and `derived` for `02`–`05`.
88
+ `owns` must match §4.1 in meaning. Bump the minor version for substantive edits and refresh
89
+ `updated_at` when content changes. Do not touch unrelated documents just to update a date.
90
+ Keep one metadata block. Root entry/UI files may use their established native format.
142
91
 
143
92
  ### 4.4 AGENTS.md synchronization
144
93
 
145
- - `AGENTS.md` is the **per-project instantiation**: the §4.1 table (instantiated), plus
146
- project-specific stack, commands, verification gates, and conventions.
147
- - This file is the canonical template; when §4.1 or §5 changes here, re-sync `AGENTS.md` in the
148
- same change.
149
- - `AGENTS.md` may **add** project facts; it may never **contradict** the numbered docs. On
150
- contradiction, the numbered doc wins — fix `AGENTS.md`.
151
- - In a monorepo, subdirectory `AGENTS.md` files merge with the root: the agent reads the root
152
- first, then the file for the package it is working in. Each level carries only its own scope —
153
- the root holds what spans packages, a package file holds what is true of that package alone.
154
- Never restate one level's facts at another.
94
+ Keep the responsibility map and essential repo instructions aligned with this constitution.
95
+ Update `AGENTS.md` only when its own facts or routing change. A new flag, finished task, or
96
+ unchanged governance contract does not require an entry-file edit.
97
+ Keep supported aliases such as `CLAUDE.md` and `GEMINI.md` pointing to the same entry;
98
+ do not maintain divergent copies. Propagate portable changes to the init templates in scope.
155
99
 
156
100
  ### 4.5 Index + satellite docs (`04`/`05` and their folders)
157
101
 
158
- Two derived docs are **index pages** over a folder of per-item **satellite** files. The index holds
159
- the headline rows + pointers; each satellite holds one item's detail. This keeps the index readable
160
- (loaded every session) while detail scales without bloating it.
161
-
162
- | Index doc | Satellite folder | Satellite file name | Satellite ownership |
163
- |-----------|------------------|---------------------|---------------------|
164
- | `docs/04_DESIGN.md` | `docs/design/` | `docs/design/<slug>.md` | Hand-maintained derived doc (§6.5) |
165
- | `docs/05_FEATURES.md` | `docs/features/` | `docs/features/<feature-id>_<slug>.md` | **Tool-owned** (§3 `spur feature`/`ftree`); satellites *and* the index region are written by the tool, never by raw file writes |
166
-
167
- Rules (both axes):
168
-
169
- 1. **The index is the single entry point.** A reader starts at `04`/`05`; every satellite is
170
- reachable from exactly one index row. A satellite with no index row, or an index row with no
171
- satellite, is drift (§7 audit).
172
- 2. **One item per satellite.** `<slug>` (design) / `<feature-id>_<slug>` (features) is the grep
173
- anchor (§6.0 rule 6) — stable once chosen; renaming is a rename of the file *and* its index row in
174
- the same change.
175
- 3. **Detail lives only in the satellite; the index carries pointer + status only.** The index never
176
- restates a satellite's body (§6.0 rule 2). For `05`, a row is `<id> <status> <name> → pointer`;
177
- for `04`, an index row names the surface area and points at its `docs/design/<slug>.md`.
178
- 4. **The index is regenerable for `05`** (tool-written) and **hand-curated for `04`** — but in both
179
- cases the satellite is the source of truth and the index is derived from it. Never edit `05`'s
180
- generated index region by hand; never let a `04` index row diverge from its satellite.
181
- 5. **Edit order is fixed (§5 T9): detail first, then index.** Write/update the satellite, then update
182
- the index row — in the **same change**. Updating the index before the detail exists creates a
183
- pointer to nothing; the reverse leaves the detail unindexed. For tool-owned features, "update the
184
- index" is running the tool's refresh (e.g. `spur feature refresh`), not a manual edit.
102
+ - `04` is a compact surface map pointing to `docs/design/<slug>.md`; detail lives in the satellite.
103
+ Existing stable filenames remain valid. Prefer updating an existing owner over adding a duplicate.
104
+ - `05` points to the feature tool's generated index when it has one; otherwise the tool owns
105
+ its generated region. Feature satellites and generated indexes remain CLI-gated.
106
+ - Update detail first. Update an index only if its pointer, title, or indexed state changes.
107
+ An unchanged pointer needs no ceremonial edit. New satellites must be discoverable from the index.
108
+ - Preserve heading/ID references when condensing or moving detail. Retain a short forwarding
109
+ section at a referenced old heading when callers cannot be migrated safely.
185
110
 
186
111
  ## 5. Sync triggers — same-commit obligations
187
112
 
188
- The root cause of stale key files is *unsynchronized success*: code ships, docs don't hear about
189
- it. Each trigger below has a stable ID (referenced by doc frontmatter `sync:` lists, §4.3) and
190
- names the docs that must be touched **in the same commit / same change**:
191
-
192
- | ID | When this happens | Touch (same change) |
193
- | ---- | ------------------- | --------------------- |
194
- | T1 | New cross-cutting decision, or reversal of one | `00` **first** (dated entry), then `03` mechanism, `01` if scope shifts |
195
- | T2 | A code change would contradict an existing ADR | **Stop.** Add the superseding/amending ADR entry first never silently diverge |
196
- | T3 | Command, flag, config key, env var, schema, or DTO added/changed | `04` + the `AGENTS.md` surface block |
197
- | T4 | A feature ships or changes state | its `05` row; a new `01` scope row if it is new surface |
198
- | T5 | A phase completes, reorders, or gains items | `02` (update the bullet to the *real, shipped name* of the deliverable) |
199
- | T6 | Scope added / cut / deferred | `01`; placement in `02` |
200
- | T7 | The doc map or process changes | this file re-sync `AGENTS.md` (§4.4) propagate to sibling projects |
201
- | T8 | A multi-wave batch is planned | schedule "doc sync" as an **explicit work item** same-commit discipline does not survive on memory alone |
202
- | T9 | A design or feature item is added/changed | the satellite **first** (`docs/design/<slug>.md` or `docs/features/<id>_<slug>.md`), **then** its index row in `04`/`05` same change (§4.5 rule 5) |
203
- | T10 | Corpus checker policy changes | Run one explicit unsuppressed audit plus focused rule tests; record/reconcile exposed essential failures without waivers. |
204
- | T11 | Ordinary task/feature commit prep | Check changed documents and their required linked evidence, not the whole corpus. Never regenerate an acceptance baseline or add routine audit callers. |
113
+ Update the documents whose owned facts changed, in the same change. This table routes edits;
114
+ it does not require touching every key file for each feature or task.
115
+
116
+ | ID | Change | Required synchronization |
117
+ | --- | --- | --- |
118
+ | T1 | New architectural choice passing §6.1, or reversal | Record `00` before divergence; update affected `03`/`04`; `01` only if scope changes |
119
+ | T2 | Implementation would contradict an existing ADR | Record the decision amendment or superseding ADR before implementing the contradiction |
120
+ | T3 | CLI/API/config/schema/DTO or non-UI behavior changes | Update the owning `04` satellite; index and `AGENTS.md` only if their own facts change |
121
+ | T4 | Feature lifecycle or acceptance changes | Update through the feature tool and refresh its generated projection; `01` only for scope changes |
122
+ | T5 | Phase goal, order, dependency, or exit changes | Update `02`; task completion alone does not trigger a roadmap entry |
123
+ | T6 | Product scope added, removed, or deferred | Update `01`; `02` if sequencing changes |
124
+ | T7 | Authorized change to document responsibilities, authority, or maintenance rules | Update `99`, affected entry/routing instructions, and in-scope init templates |
125
+ | T8 | Multi-wave batch planned | Include the applicable document synchronization in the plan |
126
+ | T9 | Design/feature satellite added, moved, or its indexed facts changed | Detail first, then the affected index; features use their tool |
127
+ | T10 | Corpus checking policy added or tightened | Run focused policy tests and an explicit unsuppressed corpus audit; reconcile exposed failures without waivers or acceptance snapshots |
128
+ | T11 | Ordinary task/feature edits | Check affected records and required linked evidence; do not turn routine work into a corpus-wide audit |
129
+
130
+ UI design changes update root `DESIGN.md` or its owning UI reference. If the same change affects
131
+ non-UI contracts or system boundaries, apply T3 or T1 separately.
205
132
 
206
133
  ## 6. Edit principles per file
207
134
 
208
135
  ### 6.0 Writing rules (all key files)
209
136
 
210
- Token economy is a design goal: these files are read by LLM agents at session start, every
211
- session, across every project a redundant sentence is paid for thousands of times. Precise
212
- **and** concise; precision wins when they conflict.
213
-
214
- 1. Declarative, information-dense sentences. No filler, no marketing adjectives, no hedging, no
215
- narrative buildup.
216
- 2. A fact lives once — link or point (`see 03 §12`) instead of restating, both in-file and
217
- cross-file. Restatement is the largest token sink in a doc system, bigger than any tone rule.
218
- 3. Tables for enumerable facts; prose only where reasoning is needed.
219
- 4. Front-load: rule first, elaboration after — readers (human or agent) may only take the head.
220
- 5. Define a term once, then reuse it verbatim. Synonyms read as new concepts to a machine.
221
- 6. Headings and IDs (`ADR-NNN`, `T1`–`T8`, `§6.x`, feature rows) are grep targets and
222
- cross-reference anchors — never rename casually.
223
- 7. **Concise never beats correct.** If brevity creates ambiguity, add the missing words: tokens
224
- saved in reading are lost many times over in a misexecuted run.
225
-
226
- These rules are stated once, here. Per-file sections below and doc frontmatter inherit them via
227
- pointer — restating them per file would violate rule 2.
137
+ Lead with the useful fact. Remove repeated rules, stale inventories, narration and redundant
138
+ examples. Prefer links to existing owners. Preserve stable IDs, meaningful qualifications,
139
+ security/accessibility requirements and evidence; brevity must not change semantics.
140
+ Do not append to a key file merely to prove work happened.
228
141
 
229
142
  ### 6.1 `docs/00_ADR.md`
230
143
 
231
- Entry template:
232
-
233
- ```markdown
234
- ## ADR-NNN: <Decision title, outcome-shaped>
235
-
236
- **Status:** Accepted | Accepted (design) | Superseded by ADR-MMM | Skipped · **Date:** YYYY-MM-DD
237
-
238
- **Decision.** <What was decided the smallest complete statement of the choice.>
239
-
240
- **Why.** <One line. The single strongest reason.>
241
-
242
- **Detail:** <pointer into 03/04/plans depth never lives here.>
243
- ```
244
-
245
- 1. **One decision per entry.** If a draft contains a principle *and* a deferred design *and* a
246
- mechanism choice *and* implementation tips split it: decision(s) here, mechanism in `03`,
247
- shapes in `04`, tips nowhere (they are implementation guidance, not decisions).
248
- 2. **ADR = decision + one-line reason.** No Zod patterns, no lock details, no code idioms.
249
- 3. **Append-only.** Never renumber, never delete, never rewrite history. Corrections are dated
250
- `**Amendment (YYYY-MM-DD)**` blocks inside the entry; reversals are **new entries** that name
251
- what they supersede, while the old entry's Status becomes `Superseded by ADR-MMM`.
252
- 4. **Numbering:** next free integer, one sequence per repo. A burned/skipped number gets a stub
253
- entry (`Status: Skipped`) so the gap is audit-clean and never reused.
254
- 5. **`Accepted (design)`** means decided but not built — readers must be able to tell decided
255
- from shipped.
256
- 6. **Before any code that contradicts an ADR:** the superseding entry lands first (§5 row 2).
257
- 7. **Retrofit rule:** the entry template binds **new entries and amendments only**. Historical
258
- entries are never restructured to match it — append-only beats stylistic consistency. The
259
- non-entry preamble is normal editable text.
260
- 8. **Amendments record the decision delta.** An `**Amendment**` block records *what changed about the
261
- decision* — the new choice and its one-line reason — plus a `Detail:` pointer for mechanism.
262
- Implementation file paths, detailed semantics, and multi-paragraph rationale belong in `03`/`04`,
263
- not in the amendment body. If an amendment would carry more than a few lines of non-decision text,
264
- the mechanism has leaked in; link it instead of inlining it.
144
+ Admit a decision only if it selects among meaningful alternatives and establishes or changes
145
+ a lasting architecture boundary or invariant across features/modules: dependency direction,
146
+ persistence ownership, trust model, protocol, runtime or shared execution model. Record the
147
+ choice, context/reason, material tradeoff/consequence, status/date, and a detail pointer.
148
+
149
+ Single-feature design, public-surface consent, task progress, test results and implementation
150
+ receipts go to their design/task records. Bug fixes that restore an existing contract need no ADR.
151
+ Doc-map and maintenance changes belong in `99`, not an ADR certifying a constitution edit.
152
+
153
+ - One architectural decision per entry. New choices append; reversals name the superseded ADR.
154
+ - Never renumber, reuse or delete an ADR ID. Preserve original titles/anchors and dates.
155
+ - Corrections to the decision use dated amendments; amendments record a decision delta only.
156
+ - Editorial condensation may remove repetition and misplaced detail while preserving the choice,
157
+ rationale, material alternatives, consequences and amendment history. It must not silently
158
+ reverse a decision or present a historical choice as current.
159
+ - For a historical entry that never qualified, retain its number/title/date as a short legacy
160
+ record pointing to the proper owner. It is not precedent for new feature/task ADRs.
161
+ - Distinguish accepted design from implemented behavior; delivery evidence lives in the feature/task.
162
+ - Use the next free number. Keep existing skipped-number stubs; reserve `ADR-000` for admission
163
+ guidance if the register already uses it.
265
164
 
266
165
  ### 6.2 `docs/01_PRD.md`
267
166
 
268
- 1. Owns vision, users, principles, scope. **No mechanism** (→ `03`), **no timing** (→ `02`),
269
- **no shapes** (→ `04`).
270
- 2. **Every shipped surface has a scope row.** When a command/capability ships, its row enters
271
- the in-scope table in the same change — shipped-but-unlisted is the most common drift.
272
- 3. Scope states are explicit: *in (committed)* / *supporting* / *deferred (needs design
273
- reconfirmation)* / *out of scope*. A deferred item carries the condition that would
274
- reactivate it.
275
- 4. Surface beyond the committed set is **not ported/built speculatively** — re-confirm the need
276
- first and record the evidence pointer (a dated plans doc, usage data) in the entry that
277
- admits it.
278
- 5. **Scope tables carry membership only** — no delivery-status columns (`05` owns status; a
279
- status column in `01` is a guaranteed drift magnet). Likewise, quantitative gate values
280
- (coverage thresholds, etc.) live with their enforcement config — point to the gate, never
281
- restate the numbers.
167
+ Keep vision, users, principles and capability-level scope. States are in, supporting, deferred
168
+ (with a reactivation condition), or out. Do not enumerate every flag or duplicate delivery
169
+ status; point to `04` and `05`. Link enforcement config rather than copying numeric gate values.
282
170
 
283
171
  ### 6.3 `docs/02_ROADMAP.md`
284
172
 
285
- 1. Derived: it may **sequence** facts from `00`/`01`/`05` but never introduce new ones.
286
- 2. Every phase has a goal sentence, checkbox items, and an explicit **Exit:** criterion.
287
- 3. Markers: `[x]` done · `[~]` partial · `[ ]` pending. `[x]`/`[~]` carry a one-line evidence
288
- note (what shipped, where).
289
- 4. When a deliverable lands under a different name than planned, rewrite the bullet to the real
290
- name — a roadmap that tracks dead names reads as undelivered work.
291
- 5. Phases gate on the previous one. Insert sub-phases (`1.5`) rather than renumbering existing
292
- ones.
173
+ Keep phase goals, sequence/dependencies, coarse deliverables and explicit exits. Preserve phase
174
+ identities; insert sub-phases rather than renumbering. Use real deliverable names and concise
175
+ evidence links. Consolidate completed waves; task WBS lists and implementation receipts stay
176
+ in their records. Do not claim a phase complete from a subset of its exit checks.
293
177
 
294
178
  ### 6.4 `docs/03_ARCHITECTURE.md`
295
179
 
296
- 1. Describes the **current** architecture. Future/accepted designs are allowed only in sections
297
- explicitly titled `(accepted design ADR-NNN; not yet built)`.
298
- 2. Owns module boundaries, data flow, runtime model, invariants, and rationale-in-depth. Not
299
- schemas/signatures (code and `04`), not decisions (`00`).
300
- 3. Write invariants as **enforceable statements** — phrased so a constraint rule or a reviewer
301
- can check them mechanically.
302
- 4. When a migration replaces a mechanism (parser, dispatcher, bootstrap), update the module
303
- descriptions in the same change — stale module lists survive multiple releases unnoticed.
304
- 5. On conflict with `00`: the ADR wins; fix here and flag.
180
+ Describe current topology, ownership, data flow, runtime and enforceable invariants. Mark
181
+ unbuilt accepted designs explicitly. Keep mechanism and essential rationale; link exact shapes
182
+ to `04`. Replace obsolete mechanisms in place. Do not accumulate per-task shipment paragraphs.
305
183
 
306
184
  ### 6.5 `docs/04_DESIGN.md` + `docs/design/<slug>.md`
307
185
 
308
- `04` is the **index page** over the `docs/design/` satellites (§4.5). The index carries the surface
309
- map + pointers; each `docs/design/<slug>.md` holds one surface area's detailed design.
310
-
311
- 1. **Same-commit rule:** any change to a command, flag, config key, env var, table, or DTO
312
- updates `04` (and its satellite) in that commit (§5 T3/T9). In batch planning, doc sync is an
313
- explicit scheduled item.
314
- 2. **Detail-first edit order (§4.5 rule 5 / T9):** write or update the `docs/design/<slug>.md`
315
- satellite first, then update its `04` index row — never the reverse. A new surface area gets a
316
- new satellite + a new index row in the same change.
317
- 3. Prefer **generated** artifacts over hand-maintained ones (e.g. OpenAPI from the contract);
318
- never hand-write what can be derived — and never let a derivable artifact be edited by hand.
319
- 4. Shapes only. Rationale lives in `00`/`03`. **Behavioral notes are shapes** ("resolving zero
320
- rules exits 1" — keep); justifications are not ("...because a silent gate is the worst
321
- failure mode" — cut, or point to `00`/`03`). This applies to satellites too — they hold
322
- *detailed shapes*, not rationale.
323
- 5. Command signatures are **transcribed from the code registrations**, never from memory or from
324
- an older doc revision — a signature is a factual block in the §6.7 sense.
325
- 6. The index never restates a satellite's body (§6.0 rule 2): an `04` row names the surface area,
326
- its status, and points at `docs/design/<slug>.md`. `<slug>` is a stable grep anchor (§6.0 rule 6).
186
+ Keep the index short. Satellites own non-UI signatures, schemas, defaults, errors, compatibility
187
+ and boundary behavior. Verify against registrations/contracts; prefer generated artifacts to
188
+ manual copies. UI rules belong in root `DESIGN.md`; architectural rationale belongs in `00`/`03`.
189
+ Separate proposed from current behavior. A completed task adds no delivery receipt here.
327
190
 
328
191
  ### 6.6 `docs/05_FEATURES.md` + `docs/features/<feature-id>_<slug>.md`
329
192
 
330
- `05` is the **index page** over the `docs/features/` satellites (§4.5). Both the satellites and `05`'s
331
- generated index region are **tool-owned** (§3 `spur feature`/`ftree`): edit through the tool, never
332
- with raw file writes.
333
-
334
- 1. One index row per deliverable, each with a concrete **acceptance** check, status from the legend
335
- (✅ done · 🔶 partial · ⏳ planned · 💤 deferred), and a pointer to its
336
- `docs/features/<feature-id>_<slug>.md` satellite.
337
- 2. The satellite + its index row change in the **same change** that ships or re-scopes the feature
338
- (§5 T4/T9).
339
- 3. **Detail-first edit order (§4.5 rule 5 / T9):** update the feature satellite first (via the tool),
340
- then refresh the index (e.g. `spur feature refresh`) — never hand-edit the generated index region,
341
- and never update the index ahead of the detail.
342
- 4. **Never trust a row you have not verified.** Before citing or building on a status, check it
343
- against code — status rows rot silently in both directions (done-but-⏳ and ⏳-but-claimed).
344
- 5. `05` keeps headline rows + pointers; the full decomposition lives in the satellite files.
345
- `<feature-id>` is the stable grep anchor (§6.0 rule 6); renaming is a tool operation, not a raw
346
- edit.
193
+ Maintain one feature status source through its tool. `05` is an entry to that source, not a
194
+ parallel hand-written status table. Requirements, acceptance and decomposition live in feature
195
+ records; execution evidence lives in task records. Verify status and acceptance against evidence
196
+ before relying on them. Never raw-edit satellites or generated regions.
347
197
 
348
198
  ### 6.7 `AGENTS.md`
349
199
 
350
- 1. Factual blocks that mirror code the command surface, the workspace layout, tool versions —
351
- are **regenerated from code**, never edited from memory. Verify with the actual registrations
352
- (e.g. list the CLI's registered nouns/verbs) before writing the block.
353
- 2. File structure is the most perishable thing you can write down: paths move, and a stale path
354
- sends an agent confidently to a file that is not there. Prefer capabilities and domain
355
- vocabulary — which outlive layout — over directory listings; where a concrete path is genuinely
356
- needed, regenerate it from code per rule 1.
357
- 3. Keep it lean: link to the owning doc instead of restating its facts. `AGENTS.md` repeats only
358
- what an agent needs in the first 30 seconds of a session.
359
- 4. Keep the instruction count inside a budget: roughly 150–200 instructions, beyond which an agent
360
- attends to them unevenly and the marginal rule buys nothing (MEDIUM confidence — secondary
361
- citation, not measured here). Over budget, cut the rule or move it to its owning doc and link
362
- per rule 3.
363
- 5. Surfaces that are decided-but-unbuilt are flagged as planned with their ADR pointer, and
364
- marked "do not invoke as if they exist".
365
- 6. Re-synced whenever this file changes the map or process (§4.4).
366
- 7. Deterministic size ceiling: repo-root `AGENTS.md` and `config/templates/AGENTS.md` stay at or
367
- below **20480 UTF-8 bytes** (20 KiB), enforced by
368
- `apps/cli/tests/agents-md-portable-alignment.test.ts` (task 0705). This byte gate guards the
369
- platform load limit and is separate from rule 4's approximate instruction budget. Over
370
- ceiling: cut or move content per rules 2–3, or compact via `sp:doc-evolve`.
200
+ Keep essential orientation, commands, boundaries and document routing. Verify facts from the
201
+ repository; avoid volatile version/catalog duplication and detailed runbooks. Link to deeper
202
+ owners. Preserve critical operational constraints inline. An entry-file size gate, if configured,
203
+ belongs to repo tooling, not a universal claim about agent limits.
371
204
 
372
205
  ### 6.8 This file (`99`)
373
206
 
374
- 1. **No project facts** ever (§1). Tool bindings (§3) and Lessons (§8) are the only
375
- project-variable content.
376
- 2. Structure and principles change only on operator request; Lessons sections are
377
- machine-appendable per the §8 protocol without asking.
378
- 3. When this file improves in one project, **propagate the improvement to sibling projects** —
379
- it is one constitution with N copies, not N constitutions.
380
-
381
- ## 7. Drift control
382
-
383
- **Drift** = reality (code, shipped behavior) disagreeing with what a key file says, or two key
384
- files disagreeing with each other.
385
-
386
- **Repair protocol** (always this order):
387
-
388
- 1. Fix the **authoritative** doc — for append-only files, by dated amendment, never rewriting.
389
- 2. Then the derived docs that restate or sequence it.
390
- 3. Then `AGENTS.md`.
391
- 4. Flag what drifted and why in the commit message / task — a silent fix hides the systemic
392
- cause.
393
-
394
- **Audit cadence:** at every phase exit, and before designing any large batch, run the drift
395
- audit:
396
-
397
- - [ ] List the real CLI/tool surface from code; diff against `AGENTS.md`'s surface block and
398
- `00`'s committed-surface entries.
399
- - [ ] For every `05` row marked ✅/🔶, spot-check the acceptance against code; for every ⏳, check
400
- it didn't quietly ship.
401
- - [ ] For every shipped surface, confirm a `01` scope row exists.
402
- - [ ] Check `02`'s current phase bullets name things that actually exist (no dead names).
403
- - [ ] Check `03`'s module descriptions against the real file tree of each app/package.
404
- - [ ] Confirm `04` covers every command/flag/config/schema that exists.
405
- - [ ] For `04`/`05` (§4.5): every index row points to an existing satellite, and every satellite
406
- (`docs/design/<slug>.md`, `docs/features/<id>_<slug>.md`) has exactly one index row — no orphan
407
- satellites, no dangling pointers.
408
- - [ ] Confirm `AGENTS.md`'s doc map matches §4.1 of this file.
409
- - [ ] Confirm each doc's frontmatter matches its §4.1 row and its `updated_at` is plausible
410
- against recent commits (§4.3).
411
-
412
- Findings are repaired via the protocol above, and anything systemic becomes a Lesson (§8) — or,
413
- if it recurs, a new rule in §6.
414
-
415
- ## 8. Lessons learned per file
416
-
417
- **Append protocol (machine-maintained):**
418
-
419
- - Format: `- [YYYY-MM-DD] <project>: <lesson — what went wrong / what to do instead>`
420
- - Threshold is **low** — when in doubt, append. Check for an existing equivalent first; bump its
421
- date instead of duplicating.
422
- - **Promotion rule:** a lesson that recurs or hardens into practice is promoted into a §6 rule
423
- (or a §5 trigger) and removed from this section. Lessons are the inbox; §5/§6 are the law.
424
- Promotion is the only sanctioned deletion.
425
- - Lessons carry project provenance because this file is copied across projects — a lesson from
426
- one project is a warning, not yet a law, for the others.
427
-
428
- ### Lessons for `docs/00_ADR.md`
429
-
430
- *(empty — add lessons as the project evolves)*
431
-
432
- ### Lessons for `docs/01_PRD.md`
433
-
434
- *(empty — add lessons as the project evolves)*
207
+ Change only for an operator-authorized correction to document responsibility, authority,
208
+ maintenance or synchronization. The change record must name the governance defect, the rule
209
+ changed, and affected files/templates. Existing authorization for that scope is sufficient.
435
210
 
436
- ### Lessons for `docs/02_ROADMAP.md`
211
+ Feature delivery, task closure, a test result, an ordinary lesson, or editing another key file
212
+ is not a reason to edit this file or bump its metadata. Keep implementation-specific gate commands
213
+ and tool bindings in their owners. Do not automatically promote lessons into constitutional rules.
214
+ Update authorized templates/copies; do not mutate unrelated repositories without authorization.
437
215
 
438
- *(empty add lessons as the project evolves)*
439
-
440
- ### Lessons for `docs/03_ARCHITECTURE.md`
441
-
442
- *(empty — add lessons as the project evolves)*
443
-
444
- ### Lessons for `docs/04_DESIGN.md`
445
-
446
- *(empty — add lessons as the project evolves)*
216
+ ## 7. Drift control
447
217
 
448
- ### Lessons for `docs/05_FEATURES.md`
218
+ Audit the affected owners, using source/help, manifests, Git diffs, generated indexes and links:
449
219
 
450
- *(empty add lessons as the project evolves)*
220
+ - Responsibility: content belongs to the file's §4.1 row; no competing ledger or rule owner.
221
+ - Reality: current contracts/mechanisms match source; proposed/historical content is labeled.
222
+ - Scope/status: `01` covers capabilities; phase/feature claims have current evidence.
223
+ - References: IDs, heading anchors, index pointers and aliases still resolve.
224
+ - Synchronization: apply §5 to changed facts; unchanged owners need no edit.
225
+ - Metadata/templates: contracts and dates match actual edits; portable guidance agrees.
451
226
 
452
- ### Lessons for `AGENTS.md`
227
+ Repair authority first, then affected detail/index/entry files. Record findings and verification
228
+ in the task or a dated report, including unverified claims. Do not claim a repository-wide audit
229
+ from focused checks. An ADR content reversal follows §6.1; editorial cleanup preserves history.
453
230
 
454
- *(empty add lessons as the project evolves)*
231
+ ## 8. Lessons learned per file
455
232
 
456
- ### Lessons for this file (`99`)
233
+ Lessons live in existing project learning/context storage or a dated report, outside this
234
+ constitution. Deduplicate useful lessons and link their evidence. Routine completion logs stay
235
+ in tasks. Do not import another project's lessons into a new project's governing documents.
457
236
 
458
- *(empty add lessons as the project evolves)*
237
+ A lesson may motivate a proposed §6.8 change when it reveals a document-governance defect;
238
+ recurrence alone does not authorize changing the constitution. Existing references to §8 mean
239
+ this routing rule, not an instruction to append lessons here.
459
240
 
460
241
  ## 9. Bootstrapping a new project
461
242
 
462
- Checklist to instantiate this structure in a fresh repo:
463
-
464
- 1. Copy this file verbatim to `docs/99_PROJECT_CONSTITUTION.md`; empty the §8 lessons of
465
- other projects' entries or keep them as inherited warnings (recommended: keep).
466
- 2. Update §3 bindings if the new project's toolchain differs.
467
- 3. Create `docs/00_ADR.md` with the §4.3 frontmatter and `ADR-001` recording the founding
468
- decision (stack, structure, the why).
469
- 4. Create `docs/01_PRD.md`: vision paragraph, users, principles table, scope tables (in /
470
- supporting / deferred / out).
471
- 5. Create `docs/02_ROADMAP.md` with Phase 0 and its exit criterion.
472
- 6. Create `docs/03_ARCHITECTURE.md`: topology, dependency boundary, runtime model — current
473
- state only.
474
- 7. Create `docs/04_DESIGN.md` (may start near-empty) and `docs/05_FEATURES.md` (legend + first
475
- rows).
476
- 8. Create root `AGENTS.md`: instantiated §4.1 doc map, stack/layout, commands, verification
477
- gate, conventions. Symlink `CLAUDE.md` (and equivalents) to it.
478
- 9. Wire the §3 tools (spec lifecycle, harness) per their own docs.
479
- 10. First-session rule for any agent: read `AGENTS.md` → this file → `00`/`01` before touching
480
- anything.
243
+ Seed `00`–`05`, this constitution and `AGENTS.md` through the project initializer. Fill project
244
+ facts from actual requirements and manifests; leave unknowns explicit. Do not pre-accept an
245
+ ADR, invent a completed phase, or create fictitious feature/status rows in a fresh project.
246
+ Use the feature tool for its index. Keep `DESIGN.md` optional; author it when UI work needs a
247
+ shared design language. Preserve existing customized docs and supported entry symlinks.
248
+ Read `AGENTS.md` first, then the owners relevant to the work.