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/DECISIONS.md CHANGED
@@ -18,7 +18,7 @@ Date: YYYY-MM-DD
18
18
  ---
19
19
 
20
20
  ## ADR-001 — Markdown as the sole persistence format
21
- Status: accepted
21
+ Status: superseded in part by ADR-017
22
22
  Date: 2026-07-17
23
23
 
24
24
  **Context** — ScrumRun needs a persistence layer for state that is (a) portable across AI agents, (b) diffable via git, (c) readable by humans without tooling, (d) editable by hand in an emergency.
@@ -39,7 +39,7 @@ Date: 2026-07-17
39
39
 
40
40
  **Decision** — Approval gates are synchronous checkpoints requiring explicit owner response. There is intentionally no config option to grant blanket implementation permission (see I-01, I-06).
41
41
 
42
- **Consequences** — Slower than fully autonomous execution. But every code change has a recorded owner decision. Cost: friction on trivial tasks — mitigated by the `Quick Tasks: allow` policy, which still cannot override golden rules.
42
+ **Consequences** — Slower than fully autonomous execution. But every code change has a recorded owner decision. Cost: friction on trivial tasks — mitigated by concise quick-task planning, never by removing the approval gate or bypassing Guardrails.
43
43
 
44
44
  **Alternatives considered** — Async approval (approve later): breaks the "audit trail matches execution" property. Silent execution with rollback: rollback is not a substitute for consent.
45
45
 
@@ -74,7 +74,7 @@ Date: 2026-07-17
74
74
  ---
75
75
 
76
76
  ## ADR-005 — Main goal and feature lanes are physically separate
77
- Status: accepted
77
+ Status: superseded by ADR-015
78
78
  Date: 2026-07-17
79
79
 
80
80
  **Context** — Feature ideas frequently arrive mid-sprint. Merging them into main sprint history dilutes the narrative of the main goal and makes historical audit harder.
@@ -88,12 +88,12 @@ Date: 2026-07-17
88
88
  ---
89
89
 
90
90
  ## ADR-006 — Golden rules cannot be silently bypassed
91
- Status: accepted
91
+ Status: superseded by ADR-016
92
92
  Date: 2026-07-17
93
93
 
94
94
  **Context** — Configuration flags that disable safety features are the most common source of preventable damage in AI-assisted workflows.
95
95
 
96
- **Decision** — Active golden rules have highest precedence. There is no command flag, no config option, and no intake path that disables them. Retirement requires explicit owner action and is logged (see I-03, I-08).
96
+ **Decision** — Active project rules have highest precedence. There is no command flag, no config option, and no intake path that disables them. Retirement requires explicit owner action and is logged. ADR-016 later renamed and consolidated this authority as canonical Guardrails.
97
97
 
98
98
  **Consequences** — Guarantees that "add rule X" produces durable behavior. Cost: cannot temporarily suspend a rule — must retire, act, re-add. Intentional friction.
99
99
 
@@ -102,7 +102,7 @@ Date: 2026-07-17
102
102
  ---
103
103
 
104
104
  ## ADR-007 — `context.md` is never authoritative
105
- Status: accepted
105
+ Status: superseded by ADR-017
106
106
  Date: 2026-07-17
107
107
 
108
108
  **Context** — Token economy pressure encourages agents to trust cached summaries. A summary that is 90% accurate is a summary that will mislead 10% of the time on production decisions.
@@ -116,7 +116,7 @@ Date: 2026-07-17
116
116
  ---
117
117
 
118
118
  ## ADR-008 — Fixes and sprints coexist as distinct kinds
119
- Status: accepted
119
+ Status: superseded by ADR-015
120
120
  Date: 2026-07-17
121
121
 
122
122
  **Context** — A production bug is not a full sprint. Forcing every corrective action through the sprint protocol (plan, review, complete) adds overhead disproportionate to the risk.
@@ -185,15 +185,15 @@ Date: 2026-07-17
185
185
 
186
186
  ---
187
187
 
188
- ## ADR-013 — Six-command grammar (planned, not yet implemented)
189
- Status: proposed
188
+ ## ADR-013 — Root command with five domain nouns
189
+ Status: accepted
190
190
  Date: 2026-07-17
191
191
 
192
192
  **Context** — Twenty `sc-*` commands accumulated organically. Overlap between commands (study/know/map/context, sprint/fix/feature/backlog/goal) suggests the grammar has grown by addition rather than design.
193
193
 
194
- **Decision** — Consolidate the 20 verbs into 6 nouns: `/sc`, `/sc plan`, `/sc knowledge`, `/sc rules`, `/sc review`, `/sc config`. Legacy commands become invisible aliases for one release cycle, then removed.
194
+ **Decision** — Expose one root command, `/sc`, with five domain nouns: `plan`, `knowledge`, `rules`, `review`, and `config`. Actions remain canonical long flags. Client integrations are generated from one command manifest. Legacy commands are real compatibility adapters during migration, never prompts that merely tell the user to invoke another command.
195
195
 
196
- **Consequences** — Grammar reflects method structure (§4 composition). Discoverability improves without hiding power. Cost: one-time migration effort for existing users — currently only the author.
196
+ **Consequences** — The installed surface becomes genuinely smaller and the grammar reflects method structure. One manifest prevents drift between clients, help, tests, and documentation. Cost: v1 installations require an explicit migration path.
197
197
 
198
198
  **Alternatives considered** — Keep 20 with better docs: does not address root cause (design accretion). Reduce to 2 (only intake + one power command): loses the ability to script determin­istically.
199
199
 
@@ -210,3 +210,143 @@ Date: 2026-07-17
210
210
  **Consequences** — Method is usable in the owner's native language without translation overhead. Cost: docs and examples may lag between languages — accepted.
211
211
 
212
212
  **Alternatives considered** — Auto-detect from user input: unreliable across sessions and mixed-language inputs.
213
+
214
+ ---
215
+
216
+ ## ADR-015 — Task, Sprint, Feature, and Run are separate entities
217
+ Status: accepted
218
+ Date: 2026-07-21
219
+
220
+ **Context** — Earlier ScrumRun versions treated a sprint as the smallest executable unit. That conflated a task with an Agile timebox, made retries overwrite operational meaning, and forced agents to infer relationships from large Markdown catalogs.
221
+
222
+ **Decision** — Task is the atomic unit of intended work. Sprint is a timebox or delivery batch that references tasks. Feature is a long-lived initiative that can span tasks and sprints. Run is one concrete execution attempt of a task. All relations use stable ids: `FEAT-NNN`, `TASK-NNN`, `SPRINT-NNN`, and `RUN-NNN`.
223
+
224
+ **Consequences** — Agents can traverse an explicit graph, retry a task without erasing failed attempts, distinguish product intent from execution, and attach decisions/insights to the correct granularity. Cost: migration must split legacy sprint records into the new entities without inventing false detail.
225
+
226
+ **Alternatives considered** — Keep sprint as the atomic work item: simpler storage but semantically incorrect and weak for retries. Nest task files under features/sprints: creates duplicated ownership and fragile moves.
227
+
228
+ ---
229
+
230
+ ## ADR-016 — Guardrails are canonical and lean is a read policy
231
+ Status: accepted
232
+ Date: 2026-07-21
233
+
234
+ **Context** — A generated `guardrails.md` sourced from `golden-rules.md` duplicated the most important rules and could drift or point to missing canonical files in lean mode.
235
+
236
+ **Decision** — `.scrumrun/guardrails.md` is the single canonical project-policy artifact and replaces `golden-rules.md`. Universal method invariants remain in `core.md`; owner/project constraints live in `guardrails.md`; operational preferences live in `config.md`. Lean mode changes the initial read set, not the completeness of stored truth.
237
+
238
+ **Consequences** — The normal agent hot path is `AGENTS.md → guardrails.md → state.md`, with `core.md` and targeted canonical artifacts loaded only when needed. Cost: v1 golden rules require a lossless migration into guardrails.
239
+
240
+ **Alternatives considered** — Keep both files: preserves v1 paths but creates ambiguous precedence and drift. Make guardrails generated: fast to read but unsafe as an authority.
241
+
242
+ ---
243
+
244
+ ## ADR-017 — Semantic memory uses Markdown truth and a derived index
245
+ Status: accepted
246
+ Date: 2026-07-21
247
+
248
+ **Context** — Semantic code memory needs fast relationship queries, while ScrumRun's portability requires human-readable, diffable, tool-independent truth.
249
+
250
+ **Decision** — Knowledge, architectural decisions, insights, dossiers, tasks, sprints, features, and runs remain canonical Markdown artifacts. SQLite under `.scrumrun/.cache/` stores only rebuildable indexes, code symbols, derived relations, and temporary context packages. Deleting the cache must never delete authored knowledge.
251
+
252
+ **Consequences** — Agents get graph-speed retrieval without locking project memory to a database. Confirmed insights require evidence; AI extraction creates candidates only. Cost: rebuild and equivalence tests become release requirements.
253
+
254
+ **Alternatives considered** — SQLite as canonical storage: faster writes but opaque diffs and weaker portability. Markdown-only scanning: portable but increasingly slow and token-heavy.
255
+
256
+ ---
257
+
258
+ ## ADR-018 — ScrumRun v2 persists only after approval
259
+ Status: accepted
260
+ Date: 2026-07-21
261
+
262
+ **Context** — Contextualization, risk assessment, classification, and planning must inspect significant project state, but intake is required to remain side-effect free.
263
+
264
+ **Decision** — `RECEIVED → CONTEXTUALIZING → POLICY → RISK → CLASSIFICATION → PLANNING → AWAITING_APPROVAL` is transient. Context packages may exist only in ignored disposable cache. Explicit approval creates or updates the canonical Task and starts a Run. A Run then moves through `executing → validating → learning → completed|failed|blocked`.
265
+
266
+ **Consequences** — Intake remains read-only while approved execution becomes fully auditable. Retries create new runs for the same task. Learning proposes `K`, `DEC`, or `INS` records but never confirms them automatically.
267
+
268
+ **Alternatives considered** — Persist every received request: stronger raw audit but violates read-only intake and retains unapproved user content. Reuse task status for attempts: loses retry history.
269
+
270
+ ---
271
+
272
+ ## ADR-019 — v1-to-v2 migration is explicit, lossless, and reversible
273
+ Status: accepted
274
+ Date: 2026-07-21
275
+
276
+ **Context** — ScrumRun 1.x stores atomic work as sprint entries inside aggregate Markdown files. ScrumRun 2.0 separates Feature, Task, Sprint, Run, and Memory. Blindly renaming files would either lose history or invent relationships that never existed.
277
+
278
+ **Decision** — `scrumrun migrate --to 2` is an explicit workflow with `--dry-run`, content-hashed inventory, local backup, staged transformation, validation, atomic application, mapping report, idempotent replay, and `--rollback`. Ordinary updates never auto-migrate project data. An update may perform a read-only preflight; only the explicit `update --migrate` flag applies the verified plan. Legacy sprint entries become Tasks; historical attempts become Runs; a v2 Sprint is created only when v1 evidence supports a real grouping/timebox. Uncertain mappings are preserved and flagged, never guessed.
279
+
280
+ **Consequences** — Every source block is traceable to a destination id and users can recover the complete v1 tree. Cost: the v2 artifact kernel must ship with dual-layout readers and realistic migration fixtures before the new layout becomes default.
281
+
282
+ **Alternatives considered** — In-place rewrite: smaller implementation but unsafe and hard to audit. Preserve v1 forever: avoids migration risk but prevents a coherent v2 domain model.
283
+
284
+ ---
285
+
286
+ ## ADR-020 — Ongoing projects preflight migration during update
287
+ Status: accepted
288
+ Date: 2026-07-21
289
+
290
+ **Context** — Existing users naturally run `npx scrumrun@latest update` to receive new client commands. If project migration is completely separate, an ongoing v1 project can receive a v2 command surface without noticing that its canonical layout still needs review.
291
+
292
+ **Decision** — When `update` runs inside a v1 project, it automatically executes the v1→v2 dry-run and prints its verified inventory, mappings, warnings, and blockers. The preflight is read-only. Project state changes only when the owner supplies `--migrate`, which applies the same verified migration workflow and preserves standalone rollback.
293
+
294
+ **Consequences** — Ongoing projects cannot silently miss the required migration, while automation and cautious users retain a zero-write default. Cost: update output is longer inside a v1 project and the update command must remain migration-aware.
295
+
296
+ **Alternatives considered** — Automatically applying during every update: rejected because updating client integrations is not implicit consent to rewrite project state. Keeping update unaware: safer in isolation but makes partial upgrades easy and confusing.
297
+
298
+ ---
299
+
300
+ ## ADR-021 — Run owns a structured append-only event ledger
301
+ Status: accepted
302
+ Date: 2026-07-22
303
+
304
+ **Context** — A prose `history.md` made operational truth expensive to parse and allowed two incompatible event formats, ambiguous same-day entries, duplicated Task/Run history, and status derived from punctuation-sensitive text.
305
+
306
+ **Decision** — Run is the sole operational-history authority. Every native Run stores schema-versioned `RUN-NNN-EVT-NNN` JSON events with RFC3339 time, actor, ordered `from`/`to`, reason, and typed evidence. Task synchronizes current status without copying event prose. Early-v2 Runs migrate explicitly: deterministic chains are recovered; ambiguity becomes an evidenced snapshot rather than an invented transition.
307
+
308
+ **Consequences** — Status reconstruction and audit are deterministic, retries preserve attempts, and agents can retrieve a bounded Run instead of rereading a global log. Cost: event/schema migrations and stricter evidence gates become release obligations.
309
+
310
+ **Alternatives considered** — Keep one append-only Markdown history with a better template: simpler storage, but still global, token-heavy, and vulnerable to parser drift. Duplicate transitions into Task: convenient locally but creates two authorities.
311
+
312
+ ---
313
+
314
+ ## ADR-022 — Canonical multi-file mutations use durable local transactions
315
+ Status: accepted
316
+ Date: 2026-07-22
317
+
318
+ **Context** — Approval, Run transitions, and retries update linked artifacts. Per-file atomic rename prevents partial bytes but cannot prevent a crash after only one file has committed.
319
+
320
+ **Decision** — Linked canonical mutations use an ignored durable transaction journal with prepared/committed states, byte-exact before images, content hashes, fsync-backed writes, deterministic recovery, and hash-only receipts. Prepared work rolls back; committed work is verified and finalized. Recovery refuses to overwrite owner changes made after interruption. Ordinary audit reports pending recovery but remains read-only.
321
+
322
+ **Consequences** — Task/Run pairs cannot silently diverge after an interrupted mutation. Failure injection proves rollback and recovery. Cost: more local I/O and a transaction schema that must be validated as hostile input.
323
+
324
+ **Alternatives considered** — Best-effort compensating writes: cannot distinguish interruption from later owner edits. SQLite as canonical transaction store: violates Markdown portability and creates another authority.
325
+
326
+ ---
327
+
328
+ ## ADR-023 — Guardrails are evaluated by an executable Policy Engine
329
+ Status: accepted
330
+ Date: 2026-07-22
331
+
332
+ **Context** — Canonical Guardrails without deterministic evaluation could be present in context yet silently ignored or described as passed. Migrated prose also makes aggressive inference unsafe.
333
+
334
+ **Decision** — Active stable-id Guardrails produce structured `passed`, `blocked`, or `deferred` evaluations. Blocks cite the exact `GR-NNN` id and reason code. Deferred checks remain visible for their mutation, migration, review, or owner boundary. Fresh rules declare enforcement explicitly; migrated prose uses conservative inference and ambiguous rules stay manual. Configuration cannot disable approval or weaken active policy.
335
+
336
+ **Consequences** — Policy advice is traceable to project authority instead of model opinion, while uncertainty stays explicit. Cost: not every project rule can be automated; manual/deferred enforcement remains a first-class result.
337
+
338
+ **Alternatives considered** — Treat every loaded rule as passed unless a keyword matches: false assurance. Block all manual rules at intake: safe but makes legitimate project-specific policy unusable.
339
+
340
+ ---
341
+
342
+ ## ADR-024 — Derived freshness uses metadata fast path and content-hash fallback
343
+ Status: accepted
344
+ Date: 2026-07-22
345
+
346
+ **Context** — Recomputing every artifact hash and reparsing the entire code graph before each status or semantic query makes a disposable index defeat its purpose. Trusting timestamps alone would make cache metadata an accidental authority.
347
+
348
+ **Decision** — `state.md` and semantic SQLite store a source fingerprint plus a watch fingerprint over path/stat identity. An unchanged watch avoids source reads. Any metadata drift triggers a complete canonical/source content fingerprint before staleness is asserted. Cache schemas are explicit and mismatches force one rebuild. Commit-only changes do not invalidate semantically unchanged code.
349
+
350
+ **Consequences** — Normal queries stay fast while content remains the final verifier. State and intake share one canonical fingerprint implementation. Cost: metadata-only touches may trigger one full verification, and scanner changes require a cache-schema bump.
351
+
352
+ **Alternatives considered** — Hash every source on every query: maximally simple but O(project) on the hot path. Timestamp-only cache validity: faster but allows derived metadata to masquerade as truth.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Leander Costa
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,120 @@
1
+ # Migrating ScrumRun 1.x to 2.0
2
+
3
+ ScrumRun 2.0 changes the domain model: legacy “sprint entries” usually become Tasks, execution history becomes Runs, and Sprints exist only when the source proves a real timebox or delivery batch. Migration is therefore explicit, hashed, staged, and reversible.
4
+
5
+ ## Requirements
6
+
7
+ - Node.js `>=22.13.0`.
8
+ - A readable `.scrumrun/` v1 directory with no symlinks inside it.
9
+ - Enough local disk space for a byte-exact backup plus the migrated tree.
10
+ - A clean understanding of any post-migration changes before rollback.
11
+
12
+ The local vault stays at `.scrumrun/vault.local.md`; its content is preserved and never printed. Secret-like content outside the vault blocks migration so it is not duplicated into new artifacts.
13
+
14
+ ## Recommended ongoing-project flow
15
+
16
+ ```bash
17
+ npx scrumrun@latest update
18
+ ```
19
+
20
+ Inside a v1 project, update installs the current client integrations and runs a zero-write migration preflight. Review:
21
+
22
+ - source fingerprint and file count;
23
+ - generated artifact counts;
24
+ - source-to-destination mappings;
25
+ - warnings and blockers.
26
+
27
+ Apply exactly that workflow only after review:
28
+
29
+ ```bash
30
+ npx scrumrun@latest update --migrate
31
+ ```
32
+
33
+ `--migrate` is explicit consent. Ordinary update never changes canonical project data.
34
+
35
+ ### Early v2 Run upgrade
36
+
37
+ Projects created by the first 2.0.0 build may contain prose-based Run transitions. The same ongoing-project commands detect this layout without writes and, after explicit `--migrate`, upgrade it to ledger schema 1:
38
+
39
+ ```text
40
+ .scrumrun/.migration/run-ledger-v1/manifest.json
41
+ .scrumrun/.migration/run-ledger-v1/backup/runs/RUN-NNN.md
42
+ ```
43
+
44
+ Every changed Run and `method.json` is hashed and backed up byte-exactly. Proven transition chains become ordered `RUN-NNN-EVT-NNN` events. When only the recorded status is provable, migration emits one evidenced `snapshot`; it does not invent the missing path. Replay is idempotent, an interrupted apply restores prepared sources, and rollback refuses when a Run changed after migration.
45
+
46
+ ## Standalone flow
47
+
48
+ ```bash
49
+ npx scrumrun@latest migrate --to 2 --dry-run
50
+ npx scrumrun@latest migrate --to 2 --apply
51
+ ```
52
+
53
+ After apply, inspect:
54
+
55
+ ```text
56
+ .scrumrun/.migration/v1-to-v2/manifest.json
57
+ .scrumrun/.migration/v1-to-v2/report.md
58
+ .scrumrun/tasks/
59
+ .scrumrun/runs/
60
+ .scrumrun/sprints/
61
+ .scrumrun/features/
62
+ .scrumrun/memory/
63
+ ```
64
+
65
+ The `.migration/` directory is ignored. The manifest records the original tree fingerprint, every generated file hash, mappings, archived paths, and warnings. The backup contains the byte-exact original tree. After apply, legacy-only aggregate files exist only in that backup, so the active tree has one unambiguous v2 layout.
66
+
67
+ Incomplete hybrid trees are supported. If canonical `TASK-NNN`, `SPRINT-NNN`, or `RUN-NNN` artifacts already represent a legacy entry, the report marks it `represented-by-existing-v2` and does not create a duplicate. Deterministic pre-release aliases such as a Decision with `status: confirmed` may be normalized to the declared v2 status while the original bytes remain in the backup. Anything ambiguous is blocked or warned instead of guessed.
68
+
69
+ ## Mapping rules
70
+
71
+ | v1 source | v2 result |
72
+ |---|---|
73
+ | Main/feature sprint entry | Task with legacy provenance |
74
+ | History attempt linked by evidence | Run for the migrated Task |
75
+ | Explicit timebox/delivery batch | Sprint grouping Tasks |
76
+ | Feature lane | Feature plus linked Tasks/Runs |
77
+ | Backlog item | Task with `status: backlog` |
78
+ | Fix | Task with `type: fix`; Run when execution is evidenced |
79
+ | Approved/pending/rejected knowledge | Same semantic state in `K-NNN` |
80
+ | Reusable AI-like insight | Candidate `INS-NNN`, never confirmed |
81
+ | Decision | `DEC-NNN` with original source hash/content |
82
+ | Golden rule | Stable-id entry in canonical `guardrails.md` |
83
+ | Dossier/review | Canonical dossier/review artifact with provenance |
84
+
85
+ Ambiguous records remain preserved and produce warnings. The migrator never invents a Sprint, Run, approval, or confirmed insight.
86
+
87
+ ## Verification
88
+
89
+ ```bash
90
+ npx scrumrun@latest status
91
+ npx scrumrun@latest sc review artifact --run
92
+ npx scrumrun@latest doctor codex --strict
93
+ npx scrumrun@latest sc knowledge map --build
94
+ npx scrumrun@latest sc knowledge study <topic-or-symbol>
95
+ ```
96
+
97
+ Apply is idempotent. Re-running it reports that the project is already migrated and changes nothing.
98
+
99
+ ## Rollback
100
+
101
+ ```bash
102
+ npx scrumrun@latest migrate --to 2 --rollback
103
+ ```
104
+
105
+ Rollback verifies the backup fingerprint and first checks whether it would erase post-migration canonical, vault, source, or new-file changes. Disposable cache and newly generated `state.md`/`map.md` views do not block restoration. If any unsafe difference exists, rollback refuses.
106
+
107
+ When rollback refuses:
108
+
109
+ 1. read the listed changed paths;
110
+ 2. copy/export work you want to keep outside `.scrumrun/`;
111
+ 3. restore or deliberately reconcile those paths;
112
+ 4. run rollback again.
113
+
114
+ Do not delete `.scrumrun/.migration/` until the migration has been accepted and rollback is no longer required.
115
+
116
+ ## Failure recovery
117
+
118
+ Apply transforms a staging copy and validates it before an atomic directory switch. Injected and real failures before/during the switch restore the v1 tree. If a process is interrupted, do not manually merge staging directories: rerun the dry-run, inspect `.scrumrun` and sibling `.scrumrun-v2-*`/`.scrumrun-v1-*` temporary paths, and recover using the verified backup/manifest.
119
+
120
+ If the preflight reports a malformed `method.json`, a symlink, an unresolved collision, an active memory record without deterministic evidence, or secret-like content outside the vault, fix that blocker and repeat the dry-run. No canonical migration writes occur while blocked.