scrumrun 1.5.2 → 2.1.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 (112) hide show
  1. package/CHANGELOG.md +64 -0
  2. package/CORE.md +231 -308
  3. package/DECISIONS.md +151 -11
  4. package/LICENSE +21 -0
  5. package/MIGRATION-1-to-2.md +120 -0
  6. package/README.md +147 -78
  7. package/SPEC.md +259 -251
  8. package/bin/claude-install.js +18 -132
  9. package/bin/scrumrun.js +1367 -174
  10. package/docs/COMMANDS.md +71 -0
  11. package/docs/ENTITY-MODEL.md +38 -0
  12. package/docs/RELEASE-SCORECARD.md +43 -0
  13. package/docs/RELEASE.md +51 -0
  14. package/docs/SCHEMA.md +89 -0
  15. package/docs/SEMANTIC-MEMORY.md +68 -0
  16. package/docs/TROUBLESHOOTING.md +78 -0
  17. package/lib/code-intel/adapter.js +20 -0
  18. package/lib/code-intel/javascript.js +199 -0
  19. package/lib/code-intel/learning.js +66 -0
  20. package/lib/code-intel/scanner.js +126 -0
  21. package/lib/commands/manifest.js +118 -0
  22. package/lib/commands/render.js +78 -0
  23. package/lib/memory/index.js +659 -0
  24. package/lib/memory/markdown.js +51 -0
  25. package/lib/memory/service.js +300 -0
  26. package/lib/runtime/budgets.js +23 -0
  27. package/lib/runtime/canonical-snapshot.js +110 -0
  28. package/lib/runtime/context.js +101 -0
  29. package/lib/runtime/orchestrator.js +303 -0
  30. package/lib/runtime/policy-engine.js +184 -0
  31. package/lib/runtime/request-engine.js +132 -0
  32. package/lib/runtime/run-ledger.js +324 -0
  33. package/lib/security/secrets.js +23 -0
  34. package/lib/v2/artifacts.js +363 -0
  35. package/lib/v2/conformance.js +214 -0
  36. package/lib/v2/migration.js +1221 -0
  37. package/lib/v2/project-store.js +44 -0
  38. package/lib/v2/run-ledger-migration.js +240 -0
  39. package/lib/v2/schema.js +148 -0
  40. package/lib/v2/transaction.js +254 -0
  41. package/package.json +16 -6
  42. package/scripts/generate-contract-docs.js +124 -0
  43. package/templates/project/.scrumrun/config.md +4 -7
  44. package/templates/project/.scrumrun/guardrails.md +31 -0
  45. package/templates/project/.scrumrun/map.md +5 -16
  46. package/templates/project/.scrumrun/memory/decisions/.gitkeep +1 -0
  47. package/templates/project/.scrumrun/memory/dossiers/.gitkeep +1 -0
  48. package/templates/project/.scrumrun/memory/insights/.gitkeep +1 -0
  49. package/templates/project/.scrumrun/memory/knowledge/.gitkeep +1 -0
  50. package/templates/project/.scrumrun/method.json +7 -0
  51. package/templates/project/.scrumrun/project.md +6 -12
  52. package/templates/project/.scrumrun/runs/.gitkeep +1 -0
  53. package/templates/project/.scrumrun/sprints/.gitkeep +1 -0
  54. package/templates/project/.scrumrun/state.md +14 -0
  55. package/templates/project/.scrumrun/tasks/.gitkeep +1 -0
  56. package/templates/project/AGENTS.md +16 -49
  57. package/templates/project-lean/AGENTS.md +18 -0
  58. package/templates/shared/skills/scrumrun/SKILL.md +211 -0
  59. package/templates/codex/prompts/sc-agent.md +0 -14
  60. package/templates/codex/prompts/sc-backlog.md +0 -13
  61. package/templates/codex/prompts/sc-challenge.md +0 -57
  62. package/templates/codex/prompts/sc-config.md +0 -18
  63. package/templates/codex/prompts/sc-context.md +0 -24
  64. package/templates/codex/prompts/sc-decisions.md +0 -8
  65. package/templates/codex/prompts/sc-feature.md +0 -16
  66. package/templates/codex/prompts/sc-fix.md +0 -21
  67. package/templates/codex/prompts/sc-goal.md +0 -14
  68. package/templates/codex/prompts/sc-golden.md +0 -14
  69. package/templates/codex/prompts/sc-help.md +0 -12
  70. package/templates/codex/prompts/sc-init.md +0 -14
  71. package/templates/codex/prompts/sc-intake.md +0 -22
  72. package/templates/codex/prompts/sc-know.md +0 -75
  73. package/templates/codex/prompts/sc-map.md +0 -13
  74. package/templates/codex/prompts/sc-review.md +0 -13
  75. package/templates/codex/prompts/sc-sprint.md +0 -28
  76. package/templates/codex/prompts/sc-study.md +0 -23
  77. package/templates/codex/prompts/sc-uninstall.md +0 -14
  78. package/templates/codex/prompts/sc-update.md +0 -8
  79. package/templates/codex/prompts/sc-vault.md +0 -27
  80. package/templates/codex/skills/scrumrun/SKILL.md +0 -412
  81. package/templates/opencode/commands/sc-agent.md +0 -14
  82. package/templates/opencode/commands/sc-backlog.md +0 -13
  83. package/templates/opencode/commands/sc-challenge.md +0 -57
  84. package/templates/opencode/commands/sc-config.md +0 -18
  85. package/templates/opencode/commands/sc-context.md +0 -24
  86. package/templates/opencode/commands/sc-decisions.md +0 -8
  87. package/templates/opencode/commands/sc-feature.md +0 -16
  88. package/templates/opencode/commands/sc-fix.md +0 -21
  89. package/templates/opencode/commands/sc-goal.md +0 -14
  90. package/templates/opencode/commands/sc-golden.md +0 -14
  91. package/templates/opencode/commands/sc-help.md +0 -12
  92. package/templates/opencode/commands/sc-init.md +0 -14
  93. package/templates/opencode/commands/sc-intake.md +0 -22
  94. package/templates/opencode/commands/sc-know.md +0 -75
  95. package/templates/opencode/commands/sc-map.md +0 -13
  96. package/templates/opencode/commands/sc-review.md +0 -13
  97. package/templates/opencode/commands/sc-sprint.md +0 -28
  98. package/templates/opencode/commands/sc-study.md +0 -23
  99. package/templates/opencode/commands/sc-uninstall.md +0 -14
  100. package/templates/opencode/commands/sc-update.md +0 -8
  101. package/templates/opencode/commands/sc-vault.md +0 -27
  102. package/templates/opencode/skills/scrumrun/SKILL.md +0 -412
  103. package/templates/project/.scrumrun/agents.md +0 -36
  104. package/templates/project/.scrumrun/backlog.md +0 -7
  105. package/templates/project/.scrumrun/context.md +0 -61
  106. package/templates/project/.scrumrun/goals/main/decisions.md +0 -9
  107. package/templates/project/.scrumrun/goals/main/history.md +0 -51
  108. package/templates/project/.scrumrun/goals/main/sprint.md +0 -54
  109. package/templates/project/.scrumrun/golden-rules.md +0 -9
  110. package/templates/project/.scrumrun/knowledge.md +0 -15
  111. package/templates/project/.scrumrun/runbook.md +0 -101
  112. package/templates/project/.scrumrun/token-policy.md +0 -43
package/SPEC.md CHANGED
@@ -1,324 +1,332 @@
1
1
  # ScrumRun Method Specification
2
2
 
3
- Version: `method 1.0` · Status: draft for review
3
+ Version: `2.0.0` · Status: stable
4
4
 
5
- This document is the formal specification of the ScrumRun method. `CORE.md` is the operational guide agents follow at runtime. `SPEC.md` is the source of truth for state machines, invariants, and composition rules.
5
+ `SPEC.md` defines normative meanings and invariants. `lib/v2/schema.js` defines the machine-enforced ids, paths, statuses, transitions, structural relations, and truth ownership metadata; `lib/commands/manifest.js` defines command grammar. `CORE.md` is the operational runtime guide. Generated `docs/SCHEMA.md` must match the executable schema byte-for-byte. A conflict is a conformance failure: semantics defer to SPEC, mechanically enforced values defer to the schema, grammar defers to the command manifest, and the conflicting representation must be corrected.
6
6
 
7
- If a conflict exists between `CORE.md` and `SPEC.md`, `SPEC.md` wins and `CORE.md` must be updated.
7
+ ## 1. Purpose and principles
8
8
 
9
- ---
9
+ ScrumRun is an evidence-driven Agile runtime for AI-assisted software work. It keeps intent, execution, decisions, and learning distinct while preserving a small daily interface.
10
10
 
11
- ## 1. Terminology
11
+ The method is built on five principles:
12
12
 
13
- | Term | Definition |
14
- |---|---|
15
- | **Method** | The ScrumRun protocol itself, versioned separately from tooling. |
16
- | **Artifact** | A `.md` file under `.scrumrun/` that represents state or intent. |
17
- | **Goal** | The primary long-lived outcome of the project. Exactly one main goal per project. |
18
- | **Sprint** | A bounded unit of work under the main goal. |
19
- | **Feature lane** | An isolated planning surface for work that should not pollute the main goal. |
20
- | **Fix** | A corrective action for a defect or regression. Lighter than a sprint. |
21
- | **Backlog item** | A candidate for future work. Not active, not committed. |
22
- | **Decision** | A pending question that blocks or shapes execution. |
23
- | **Golden rule** | An absolute constraint. Cannot be silently overridden. |
24
- | **Knowledge fact** | A short, approved statement about the project used during planning. |
25
- | **Dossier** | A deep, topic-focused study persisted as a durable document. |
26
- | **Review agent** | A reusable review persona with defined scope and prompt. |
27
- | **Intake** | The natural-language classifier that routes requests to workflows. |
28
- | **Approval gate** | A synchronous checkpoint requiring explicit owner consent. |
13
+ 1. no canonical write before explicit approval;
14
+ 2. Task is the atomic work unit; Sprint is only a timebox or delivery batch;
15
+ 3. every execution attempt is a separate Run;
16
+ 4. Markdown is canonical and generated indexes are disposable;
17
+ 5. knowledge becomes active truth only through evidence and review.
29
18
 
30
- ---
19
+ ## 2. Terminology
20
+
21
+ | Term | Meaning |
22
+ |---|---|
23
+ | Feature | Long-lived initiative explaining why related work matters. |
24
+ | Task | Atomic intended work: what must be changed or learned. |
25
+ | Sprint | Explicit timebox or delivery batch grouping Tasks: when work is grouped. |
26
+ | Run | One concrete attempt to execute a Task: how it happened. |
27
+ | Review | Scoped validation evidence for a Run, artifact, migration, or release. |
28
+ | Knowledge | Reviewed project fact. |
29
+ | Decision | Explicit normative choice and its evidence. |
30
+ | Insight | Contextual explanation, trade-off, warning, or rationale. |
31
+ | Dossier | Curated topic/module memory with evidence and review metadata. |
32
+ | Guardrail | Mandatory project policy that configuration cannot weaken. |
33
+ | Context package | Bounded, temporary evidence assembled for one request. |
34
+ | Semantic index | Ignored SQLite projection of canonical artifacts, code symbols, and relations. |
35
+
36
+ A fix is a Task with `type: fix`. A backlog is a view of Tasks with `status: backlog`; neither is a separate canonical entity.
37
+
38
+ Exact status sets, transitions, directories, cardinalities, and truth-ownership boundaries are generated in [`docs/SCHEMA.md`](docs/SCHEMA.md); they are not duplicated manually here.
39
+
40
+ ## 3. Canonical project model
41
+
42
+ ```text
43
+ .scrumrun/
44
+ core.md
45
+ guardrails.md
46
+ config.md
47
+ project.md
48
+ method.json
49
+ state.md # generated view
50
+ map.md # generated view
51
+ features/FEAT-NNN.md
52
+ tasks/TASK-NNN.md
53
+ sprints/SPRINT-NNN.md
54
+ runs/RUN-NNN.md
55
+ reviews/REV-NNN.md
56
+ memory/
57
+ knowledge/K-NNN.md
58
+ decisions/DEC-NNN.md
59
+ insights/INS-NNN.md
60
+ dossiers/DOS-NNN.md
61
+ .cache/ # ignored and disposable
62
+ semantic-index.sqlite
63
+ contexts/
64
+ vault.local.md # optional, ignored, never indexed/rendered
65
+ ```
31
66
 
32
- ## 2. Artifact Catalog
67
+ `guardrails.md` is the only canonical project-policy file. A v1 `golden-rules.md` may remain as migrated source evidence, but it is never a competing v2 authority.
33
68
 
34
- Every artifact lives at a canonical path and carries mandatory frontmatter. Files without valid frontmatter are treated as untrusted context.
69
+ ### 3.1 Universal frontmatter
35
70
 
36
- ### 2.1 Frontmatter schema (universal)
71
+ Every canonical entity file must contain:
37
72
 
38
73
  ```yaml
39
74
  ---
40
- id: <artifact-id> # e.g. SPR-042, FIX-007, KNOW-K-013
41
- kind: sprint|fix|feature|goal|backlog|decision|golden|knowledge|dossier|agent|review
42
- status: <see state machine per kind>
43
- created: YYYY-MM-DD
44
- updated: YYYY-MM-DD
45
- method: 1.0 # method version at time of creation
75
+ id: TASK-018
76
+ kind: task
77
+ status: running
78
+ created: 2026-07-21
79
+ updated: 2026-07-21
80
+ method: 2.0.0
46
81
  ---
47
82
  ```
48
83
 
49
- ### 2.2 Path map
84
+ IDs, filenames, kind, status, real ISO dates, and method version must agree. Unknown fields and authored prose are preserved. Duplicate fields, malformed frontmatter, unsafe paths, and symlinked canonical paths are invalid.
50
85
 
51
- | Kind | Path |
52
- |---|---|
53
- | goal (main) | `.scrumrun/goals/main/sprint.md` |
54
- | goal history | `.scrumrun/goals/main/history.md` |
55
- | goal decisions | `.scrumrun/goals/main/decisions.md` |
56
- | feature | `.scrumrun/features/<slug>/feature.md` |
57
- | feature sprint | `.scrumrun/features/<slug>/sprint.md` |
58
- | feature history | `.scrumrun/features/<slug>/history.md` |
59
- | feature decisions | `.scrumrun/features/<slug>/decisions.md` |
60
- | fix | `.scrumrun/fixes.md` (append-only) |
61
- | backlog | `.scrumrun/backlog.md` |
62
- | golden rules | `.scrumrun/golden-rules.md` |
63
- | knowledge facts | `.scrumrun/knowledge.md` |
64
- | dossier | `.scrumrun/knowledge/dossiers/<slug>.md` |
65
- | map | `.scrumrun/map.md` |
66
- | context | `.scrumrun/context.md` |
67
- | config | `.scrumrun/config.md` |
68
- | agents | `.scrumrun/agents.md` |
69
- | reviews | `.scrumrun/reviews/<id>.md` |
70
- | vault (local) | `.scrumrun/vault.local.md` |
86
+ ### 3.2 Stable identifiers
71
87
 
72
- ---
73
-
74
- ## 3. State Machines
75
-
76
- ### 3.1 Sprint
77
-
78
- ```
79
- proposed ──approve──▶ approved ──run──▶ running ──complete──▶ done
80
- │ │ │
81
- │ └──backlog──▶ shelved
82
- │ │
83
- └──reject──▶ rejected └──abort──▶ aborted
84
-
85
- running ──block──▶ blocked ──unblock──▶ running
88
+ | Kind | Identifier |
89
+ |---|---|
90
+ | Feature | `FEAT-NNN` |
91
+ | Task | `TASK-NNN` |
92
+ | Sprint | `SPRINT-NNN` |
93
+ | Run | `RUN-NNN` |
94
+ | Review | `REV-NNN` |
95
+ | Knowledge | `K-NNN` |
96
+ | Decision | `DEC-NNN` |
97
+ | Insight | `INS-NNN` |
98
+ | Dossier | `DOS-NNN` |
99
+
100
+ Relations use stable IDs or qualified code subjects. Example:
101
+
102
+ ```text
103
+ FEAT-003
104
+ └── TASK-018
105
+ ├── executed_by → RUN-044
106
+ ├── included_in → SPRINT-012
107
+ ├── constrained_by → DEC-018
108
+ └── generated → INS-041
86
109
  ```
87
110
 
88
- **Transitions:**
89
- - `proposed → approved`: owner approval required.
90
- - `approved → running`: explicit `--run` or intake execution consent.
91
- - `running → done`: all acceptance criteria met AND review agents passed.
92
- - `running → blocked`: unresolved decision, missing dependency, or golden rule fire.
93
- - `running → aborted`: owner-initiated cancellation. Requires reason in history.
94
- - `approved → shelved`: sent to backlog before execution.
111
+ ### 3.3 Run event ledger
95
112
 
96
- **Invariant references:** I-01, I-02, I-05, I-07.
113
+ A newly authored Run declares `ledger: 1` and owns exactly one append-only operational event stream under `## Events`. Event ids are stable and scoped to the Run (`RUN-044-EVT-001`, `RUN-044-EVT-002`, ...). Each JSON event records a contiguous sequence, RFC3339 timestamp, timestamp precision, actor, source and destination states, reason, and typed evidence.
97
114
 
98
- ### 3.2 Fix
115
+ Native Runs begin with `created → executing`. A migration may instead create one evidenced `snapshot` as the historical baseline when the source proves a recorded status but not its full transition path. A snapshot exposes that uncertainty and never fabricates intermediate states.
99
116
 
100
- ```
101
- proposed ──approve──▶ approved ──run──▶ running ──complete──▶ done
102
-
103
- └──escalate──▶ (becomes sprint)
104
- ```
117
+ The ledger is the execution authority. Task retains approved scope and synchronized current status, but does not copy Run events. Conformance reconstructs the Run state from its ledger and rejects missing or duplicate ids, invalid ordering, time reversal, illegal transitions, frontmatter drift, missing evidence, and unevidenced completion.
105
118
 
106
- Fix is lighter than sprint: no formal review agents required unless the affected area has agents configured. If scope grows during execution, `escalate` promotes to sprint with the same id lineage recorded in history.
119
+ ## 4. State machines
107
120
 
108
- ### 3.3 Feature lane
121
+ Only the following transitions are valid.
109
122
 
110
- ```
111
- proposed ──approve──▶ active ──archive──▶ archived
112
-
113
- └──merge-to-main──▶ merged
114
- ```
115
-
116
- A feature lane is a container for sprints. Its sprints follow the sprint state machine independently. `merge-to-main` folds accepted sprints into main goal history.
117
-
118
- ### 3.4 Backlog item
123
+ ### Feature
119
124
 
125
+ ```text
126
+ backlog → proposed|active|cancelled
127
+ proposed → active|cancelled
128
+ active → paused|completed|cancelled
129
+ paused → active|cancelled
120
130
  ```
121
- added ──promote──▶ (becomes sprint|fix|feature)
122
-
123
- └──drop──▶ dropped
124
- ```
125
-
126
- Backlog items have no execution state. Promotion creates a new artifact.
127
131
 
128
- ### 3.5 Decision
132
+ ### Task
129
133
 
130
- ```
131
- open ──resolve──▶ resolved
132
-
133
- └──defer──▶ deferred
134
+ ```text
135
+ backlog proposed|running|cancelled
136
+ proposed → running|cancelled
137
+ running → validating|failed|blocked|cancelled
138
+ validating → learning|failed|blocked
139
+ learning → completed|failed|blocked
140
+ partial|failed|blocked → running|cancelled
134
141
  ```
135
142
 
136
- An open decision that blocks a running sprint moves the sprint to `blocked` (see 3.1).
143
+ ### Sprint
137
144
 
138
- ### 3.6 Knowledge fact
139
-
140
- ```
141
- proposed ──approve──▶ approved ──deprecate──▶ deprecated
142
-
143
- └──reject──▶ rejected (kept for anti-repetition)
145
+ ```text
146
+ proposed → running|cancelled
147
+ running → partial|completed|blocked|cancelled
148
+ partial running|completed|cancelled
149
+ blocked → running|cancelled
144
150
  ```
145
151
 
146
- Only `approved` facts are planning truth. `rejected` facts are preserved to prevent re-proposing the same bad assumption.
152
+ ### Run
147
153
 
148
- ### 3.7 Dossier
149
-
150
- ```
151
- drafted ──approve──▶ current ──update──▶ current ──deprecate──▶ deprecated
154
+ ```text
155
+ executing → validating|failed|blocked
156
+ validating → learning|failed|blocked
157
+ learning completed|failed|blocked
158
+ partial → executing|failed|blocked
159
+ blocked → executing|failed
152
160
  ```
153
161
 
154
- Every `update` records the previous `commit` hash. A dossier older than the current HEAD by more than N commits (configurable) is marked stale in `context.md`.
155
-
156
- ### 3.8 Golden rule
157
-
158
- ```
159
- proposed ──approve──▶ active ──retire──▶ retired
162
+ A failed or blocked Run is never reused as a new attempt. Retrying its Task creates a new `RUN-NNN` with an incremented attempt and preserves the previous Run byte-for-byte.
163
+
164
+ ### Review and memory
165
+
166
+ ```text
167
+ Review: proposed running; running → passed|failed
168
+ failed → running|archived; passed → archived
169
+ Knowledge: candidate → approved|rejected; approved → deprecated|invalidated
170
+ rejected → candidate; deprecated → approved
171
+ Decision: open → resolved|deprecated|invalidated; resolved → deprecated|invalidated
172
+ deprecated → open
173
+ Insight: candidate → confirmed|invalidated
174
+ confirmed → stale|deprecated|invalidated
175
+ stale → confirmed|deprecated|invalidated; deprecated → confirmed
176
+ Dossier: active → stale|deprecated|archived; stale → active|deprecated|archived
177
+ deprecated → archived
160
178
  ```
161
179
 
162
- Active golden rules cannot be silently bypassed (see I-08). Retirement requires explicit owner action and is logged.
163
-
164
- ---
165
-
166
- ## 4. Composition Rules
167
-
168
- Which artifact can generate which:
169
-
170
- | From ↓ / Generates | Sprint | Fix | Feature | Backlog | Decision | Knowledge | Dossier |
171
- |---|---|---|---|---|---|---|---|
172
- | Intake | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
173
- | Goal (`--set`) | ✓ | — | — | ✓ | ✓ | — | — |
174
- | Sprint (running) | — | ✓ | — | ✓ | ✓ | ✓ | — |
175
- | Fix (running) | ✓ (escalate) | — | — | — | ✓ | ✓ | — |
176
- | Feature (active) | ✓ | ✓ | — | ✓ | ✓ | ✓ | — |
177
- | Study | — | — | — | ✓ | — | ✓ | ✓ |
178
- | Review | | ✓ | — | ✓ | ✓ | ✓ | — |
179
-
180
- Blocking relationships:
181
-
182
- - An `open` decision **linked** to a sprint blocks that sprint.
183
- - A `proposed` golden rule does not block anything.
184
- - An `active` golden rule blocks any transition that would violate it.
185
- - A `stale` dossier does not block, but must be surfaced in intake responses.
186
-
187
- ---
188
-
189
- ## 5. Precedence
190
-
191
- When guidance conflicts, apply in this strict order:
192
-
193
- ```
194
- 1. Golden rules (active)
195
- 2. Open decisions linked to current work
196
- 3. Approved knowledge facts
197
- 4. Current sprint / feature plan
198
- 5. Backlog priority
199
- 6. Dossiers and map
200
- 7. context.md (never authoritative)
180
+ Confirmation/resolution requires at least one resolvable evidence reference. An active Dossier requires evidence at creation; refreshing an already active Dossier records verification without changing its state. AI extraction may create candidates only.
181
+
182
+ ## 5. Request and execution protocol
183
+
184
+ ```text
185
+ RECEIVED
186
+ CONTEXTUALIZING (Project Scan + History Engine + Decision Engine)
187
+ → CONTEXT_PACKAGE
188
+ POLICY
189
+ → RISK
190
+ CLASSIFICATION
191
+ PLANNING
192
+ AWAITING_APPROVAL
193
+ EXECUTING
194
+ VALIDATING
195
+ LEARNING
196
+ COMPLETED | FAILED | BLOCKED
201
197
  ```
202
198
 
203
- Higher precedence always wins. Lower precedence never silently overrides.
199
+ Everything through `AWAITING_APPROVAL` is read-only. It may exist in process memory or ignored cache only. A valid approval token binds the normalized request, policy result, classification, risk, issuance time, and canonical context fingerprint.
204
200
 
205
- ---
201
+ Approval atomically creates one Task and its first Run. If either write fails, neither may remain. Project changes after planning invalidate the token. Reusing a successfully consumed token is idempotent.
206
202
 
207
- ## 6. Invariants
208
-
209
- Numbered for stable reference. Every implementation must uphold all of these.
210
-
211
- - **I-01** — No sprint may transition from `proposed` to `running` without explicit owner approval.
212
- - **I-02** — No code changes may occur outside a `running` sprint, a `running` fix, or an explicitly authorized quick task.
213
- - **I-03** — An active golden rule cannot be bypassed by any command, flag, or config. Retirement is the only path.
214
- - **I-04** — Intake is read-only. Intake cannot create, modify, or delete artifacts. Intake cannot modify code.
215
- - **I-05** — Main goal history and feature lane history are physically separate files and never merge automatically.
216
- - **I-06** — Approval is synchronous and explicit. Ambiguous acknowledgements (e.g., "ok", "sure") do not constitute approval unless the owner has enabled `Quick Tasks: allow` for that class of action.
217
- - **I-07** — Every state transition writes exactly one entry to the relevant history file. History is append-only.
218
- - **I-08** — Golden rules are checked before every planning or execution workflow. A rule fire during a running sprint moves that sprint to `blocked`.
219
- - **I-09** — `context.md` is never authoritative. All planning must verify against canonical artifacts and source.
220
- - **I-10** — Only `approved` knowledge facts inform planning. `pending` and `rejected` facts are context, not truth.
221
- - **I-11** — Secrets from `vault.local.md` must never appear in history, knowledge, backlog, reviews, commits, or logs.
222
- - **I-12** — Every artifact carries `id`, `kind`, `status`, `created`, `updated`, and `method` frontmatter fields.
223
- - **I-13** — A dossier update must record the source commit hash for drift detection.
224
- - **I-14** — Quick tasks may be executed with `Quick Tasks: allow`, but never bypass golden rules, security checks, or explicit user constraints.
225
- - **I-15** — Rejecting a knowledge fact preserves it in `rejected` state to prevent re-proposing the same assumption.
203
+ Run transitions synchronously update the linked Task and append exactly one structured event to the Run ledger. Validation, learning, completion, failure, block, and resume transitions require a reason or typed evidence. Task status changes without receiving a duplicate narrative history. Multi-file mutations use a durable local transaction journal: `prepared` operations roll back byte-exactly after failure/interruption, while `committed` journals are verified and finalized. Ordinary audit is read-only and reports pending recovery; `doctor --recover` or retrying the approved mutation performs recovery explicitly. Entering `learning` may extract structured candidates from the Run, but extraction failure never blocks Run progress.
226
204
 
227
- ---
205
+ ## 6. Policy and precedence
228
206
 
229
- ## 7. Intake Protocol (Formal)
207
+ When guidance conflicts, apply this order:
230
208
 
231
- Intake is the single natural-language entry point. Formal steps:
209
+ 1. current explicit owner constraints;
210
+ 2. universal method invariants in `core.md`/this specification;
211
+ 3. active project Guardrails;
212
+ 4. resolved Decisions and confirmed, non-stale Memory relevant to the subject;
213
+ 5. the approved Task and active Run;
214
+ 6. Sprint/Feature grouping context;
215
+ 7. generated `state.md`, `map.md`, context packages, and indexes as navigation only.
232
216
 
233
- 1. **Load minimum context:** `core.md`, `golden-rules.md`, `config.md`, `context.md`, and the header of `map.md`.
234
- 2. **Interpret intent** using the desired outcome, not keyword matching.
235
- 3. **Determine risk class:** trivial / bounded / cross-cutting / sensitive.
236
- 4. **Load conditional context** based on risk class:
237
- - trivial: current sprint header only.
238
- - bounded: current sprint + relevant dossier + relevant knowledge facts.
239
- - cross-cutting: full sprint plan + all decisions + map.
240
- - sensitive: everything in cross-cutting + full history relevant to affected modules.
241
- 5. **Classify** into one of: `quick-task`, `discovery`, `sprint`, `fix`, `feature`, `backlog`, `reject`, `clarify`.
242
- 6. **Compose response:**
243
- - Recommendation with rationale.
244
- - Up to two alternatives with tradeoffs.
245
- - Risks and unknowns.
246
- - Explicit approval request.
247
- 7. **Wait for approval.** No side effects until owner responds.
217
+ Configuration controls preferences but cannot weaken higher levels. Missing or stale context must be surfaced, never rendered as certainty.
248
218
 
249
- Response format is machine-parseable enough to be logged verbatim in `history.md` if the request is approved.
219
+ Every project Guardrail has a stable `GR-NNN` identity, lifecycle status, rule text, enforcement mode, and optional scope/source. Intake evaluates active Guardrails into structured `passed`, `blocked`, or `deferred` results. A block names the responsible Guardrail and machine-readable reason code; a deferred result is shown explicitly and must be enforced at the mutation, migration, review, or owner gate it names. Deferred checks do not become evidence of a pass.
250
220
 
251
- ---
252
-
253
- ## 8. Approval Semantics
254
-
255
- Approval is a first-class concept and comes in three kinds:
256
-
257
- | Kind | What it permits |
258
- |---|---|
259
- | **Planning approval** | Create planning records (sprint plan, fix plan, backlog item, dossier draft). |
260
- | **Execution approval** | Change application code, run tests, execute review agents. |
261
- | **Structural approval** | Modify golden rules, retire rules, change config, delete artifacts. |
262
-
263
- Config policy `Execution Approval: always` requires both planning AND execution approvals separately. `implementation-only` collapses them for the recommended path but still requires an explicit yes before code changes.
264
-
265
- There is intentionally no mode that grants blanket implementation permission.
221
+ The executable Policy Engine may infer enforcement for migrated prose, but fresh v2 policy declares it explicitly. Unknown enforcement, duplicate ids, inactive-only policy, configuration that disables approval, and unsafe read-only paths fail conformance. Configuration can tune presentation and workflow preferences; it cannot retire, bypass, or weaken active Guardrails.
266
222
 
267
- ---
223
+ ## 7. Semantic memory and code intelligence
268
224
 
269
- ## 9. History Semantics
225
+ Memory records include subject, source, evidence, validity window, confidence where useful, review trigger, and last-verified commit. Insight types may include placement rationale, design constraint, known trade-off, failure history, usage warning, compatibility reason, business rule, performance reason, security reason, and testing note.
270
226
 
271
- `history.md` files are append-only. Every entry has:
227
+ The derived graph may contain:
272
228
 
273
- ```
274
- ## <YYYY-MM-DD HH:MM> · <id> · <transition>
275
- - Owner: <name or "agent-approved">
276
- - Reason: <one line>
277
- - Files touched: <optional list>
278
- - Commit: <optional hash>
229
+ ```text
230
+ defined_in
231
+ depends_on
232
+ used_by
233
+ protected_by
234
+ constrained_by
235
+ introduced_by
236
+ modified_by
237
+ has_insight
238
+ evidenced_by
279
239
  ```
280
240
 
281
- History is the audit substrate. It answers "what happened, when, and why" without requiring `git log`.
241
+ JavaScript/TypeScript symbols carry a qualified id, path, kind, line, content fingerprint, commit, and adapter identity. A move with the same fingerprint may be remapped. A rename/removal that cannot be proved is retained as orphaned context. Code or evidence drift marks linked memory stale in the projection; it never silently rewrites canonical Markdown.
282
242
 
283
- ---
243
+ Queries must explain content/relation matches, return evidence/provenance, distinguish candidate/confirmed/stale/inactive/orphaned truth, cap result and relation counts, and exclude rejected/deprecated/invalidated records by default.
284
244
 
285
- ## 10. Method Versioning
245
+ The agreed v1 control-context baseline is 48,000 characters. A fresh lean v2 intake control package, excluding the user's request, must remain at or below 12,000 characters (25%). Default semantic retrieval returns at most 10 records and 40 relations per record; hard caps are 100/100.
286
246
 
287
- `method` version is separate from `cli` and `skill` versions.
247
+ ## 8. Generated views and cache
288
248
 
289
- - **Patch** (`1.0.x`): clarifications, non-normative additions.
290
- - **Minor** (`1.x.0`): additive changes (new artifact kind, new state, new invariant).
291
- - **Major** (`x.0.0`): breaking changes (removed states, changed invariants, changed frontmatter schema, changed path map).
249
+ `state.md`, `map.md`, context packages, and `.cache/semantic-index.sqlite` are non-authoritative projections. They carry source fingerprints or are treated as stale. `state.md` uses the exact canonical fingerprint bound into intake, plus a projection schema, RFC3339 generation time, and a disposable watch fingerprint. SQLite stores its source and watch fingerprints with an explicit cache schema.
292
250
 
293
- Every method-version change ships with `MIGRATION-<from>-to-<to>.md`.
251
+ Freshness checks use a two-tier strategy: unchanged path/stat identity proves that no source read or reparse is needed; changed metadata triggers a complete canonical/source content fingerprint before staleness is asserted. Cache metadata may optimize verification but never supplies project truth. A cache-schema mismatch forces one disposable rebuild. Deleting `.cache/` must not remove authored knowledge, and rebuilding it from unchanged sources must yield equivalent query results.
294
252
 
295
- Tooling versions may change freely. `skill 1.4.2` and `cli 1.4.2` can implement `method 1.0`. A future `skill 2.0.0` can still implement `method 1.0`.
253
+ The index must never scan or store `vault.local.md`. Source scanning is bounded, skips dependencies/build output and symlinks, and uses replaceable language adapters.
296
254
 
297
- ---
255
+ ## 9. Migration from v1
298
256
 
299
- ## 11. Conformance
257
+ Migration is explicit and reversible:
300
258
 
301
- An implementation is ScrumRun-compatible if it:
259
+ ```text
260
+ scrumrun migrate --to 2 --dry-run
261
+ scrumrun migrate --to 2 --apply
262
+ scrumrun migrate --to 2 --rollback
263
+ ```
302
264
 
303
- 1. Honors every invariant in §6.
304
- 2. Implements the state machines in §3 for every artifact it exposes.
305
- 3. Enforces precedence in §5.
306
- 4. Provides intake per §7 or refuses to accept natural-language requests entirely.
307
- 5. Writes history per §9.
308
- 6. Declares the `method` version it targets.
265
+ `npx scrumrun@latest update` performs the same read-only preflight when run inside a v1 project and leaves project data untouched. `update --migrate` is an explicit request to apply the verified plan; it is not implicit migration.
266
+
267
+ Inside an early v2 project, the same commands preflight and explicitly upgrade legacy Run prose to ledger schema 1. Deterministic transition chains are recovered; incomplete history becomes an evidenced snapshot. Apply keeps byte-exact ignored backups, verifies hashes, is idempotent, and supports rollback that refuses to erase later Run changes.
268
+
269
+ The migrator must:
270
+
271
+ - hash every source file and block;
272
+ - keep a byte-exact ignored backup;
273
+ - transform in staging and validate before an atomic switch;
274
+ - map each source block to a destination or explicit warning;
275
+ - preserve original v1 files byte-exactly in the ignored backup while removing legacy-only aggregates from the active v2 tree;
276
+ - detect incomplete hybrid v1/v2 layouts and reuse proven canonical Task/Sprint/Run relations instead of duplicating them;
277
+ - normalize only deterministic schema aliases and require resolvable evidence for active migrated memory;
278
+ - be idempotent;
279
+ - reject symlinks, malformed markers, ambiguous destructive guesses, and concurrent source changes;
280
+ - rollback only when doing so cannot erase post-migration work.
281
+
282
+ Legacy sprint entries become Tasks. History entries become Runs only with an evidenced Task relation. A Sprint is created only from real grouping/timebox evidence. Feature lanes become Features, fixes become `type: fix` Tasks, backlog items become backlog Tasks, extracted insights remain candidates, and golden rules become stable-id Guardrails.
283
+
284
+ ## 10. Normative invariants
285
+
286
+ - **I-01** No canonical artifact or code write occurs before explicit approval.
287
+ - **I-02** Approval creates a linked Task/Run pair atomically or creates nothing.
288
+ - **I-03** Task is atomic work; Sprint only groups Tasks with real batch/timebox evidence.
289
+ - **I-04** Every retry creates a new Run and preserves earlier attempts.
290
+ - **I-05** Only declared, ordered, evidenced state transitions are accepted; Run event ids are unique and paired transitions are recoverable.
291
+ - **I-06** `guardrails.md` is canonical project policy and configuration cannot weaken it.
292
+ - **I-07** Markdown is canonical; SQLite and generated views are disposable projections.
293
+ - **I-08** AI-created facts/insights remain candidates until explicit human confirmation.
294
+ - **I-09** Confirmed claims have resolvable evidence and review metadata.
295
+ - **I-10** Rejected, deprecated, and invalidated memory is auditable but not active truth; stale memory is labeled.
296
+ - **I-11** Vault values never enter context, artifacts, indexes, reports, logs, commits, or approval tokens.
297
+ - **I-12** Canonical artifacts have valid, matching id/kind/status/date/method frontmatter.
298
+ - **I-13** Missing/stale projections are surfaced and never treated as authoritative.
299
+ - **I-14** Context and semantic retrieval are bounded and explain why evidence matched.
300
+ - **I-15** Migration is explicit; dry-run and ordinary update perform no project writes.
301
+ - **I-16** Migration preserves hashed source coverage, backup, mapping, idempotency, and safe rollback.
302
+ - **I-17** Migration warnings preserve ambiguity; they never invent Sprints, Runs, approval, or truth.
303
+ - **I-18** Partial/interrupted writes, conflicting overwrites, unsafe paths, and symlink traversal fail or recover without corrupting canonical state or overwriting later owner work.
304
+ - **I-19** Code intelligence is derived, adapter-based, fingerprinted, and cannot silently confirm memory.
305
+ - **I-20** Post-validation learning proposes candidates and never blocks Task/Run completion.
306
+
307
+ ## 11. Command grammar
308
+
309
+ The only canonical root is:
310
+
311
+ ```text
312
+ /sc <noun> <subject> <action> [args]
313
+ ```
309
314
 
310
- A conformance test suite lives at `tests/conformance/` and MUST pass for any release claiming compatibility.
315
+ Exactly five nouns exist: `plan`, `knowledge`, `rules`, `review`, and `config`. The implementation manifest is the command source of truth for help and client adapters. Fresh installs expose `/sc`; generated v1 aliases may remain for one compatibility cycle and must execute the canonical route.
311
316
 
312
- ---
317
+ Unknown syntax fails deterministically and never guesses a mutation.
313
318
 
314
- ## 12. Open Questions
319
+ ## 12. Conformance and compatibility
315
320
 
316
- Items to resolve before `method 1.0` freezes. Tracked as `⚠️ revisitar` per plan discipline.
321
+ An implementation may claim ScrumRun method 2.0.0 only when it:
317
322
 
318
- - ⚠️ Should `blocked` be a real state or a decoration on `running`?
319
- - ⚠️ How is a dossier "stale threshold" measured — commits since capture, or file-level touch?
320
- - ⚠️ Should quick tasks generate a lightweight artifact (e.g., `tasks.md` line) or only a history entry?
321
- - ⚠️ Precedence between two active golden rules that conflict — defined explicit order, or rejection at rule creation?
322
- - ⚠️ Do feature lane sprints inherit main goal golden rules automatically, or opt-in?
323
+ 1. passes positive and negative tests for I-01 through I-20;
324
+ 2. enforces every exposed state machine and schema;
325
+ 3. proves read-only intake and dry-run migration through full-tree fingerprints;
326
+ 4. proves migration failure recovery, rollback safety, and vault exclusion;
327
+ 5. reconstructs every native Run status from a valid, evidenced ledger and detects tampering;
328
+ 6. proves cache deletion/rebuild equivalence and inactive-memory filtering;
329
+ 7. bounds context/retrieval and records benchmark budgets;
330
+ 8. declares method `2.0.0` and requires Node.js `>=22.13.0` for the native SQLite index.
323
331
 
324
- Resolution goes to `DECISIONS.md` as an ADR when closed.
332
+ Method changes follow semantic versioning. Breaking entity, path, invariant, or state changes require a major version and a migration guide.