@limina-labs/momentum 0.30.2

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 (182) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +214 -0
  3. package/adapters/antigravity/adapter.js +196 -0
  4. package/adapters/antigravity/hooks.json +39 -0
  5. package/adapters/antigravity/instructions/AGENTS.md +638 -0
  6. package/adapters/antigravity/instructions/header.md +3 -0
  7. package/adapters/antigravity/instructions/surfaces.md +153 -0
  8. package/adapters/antigravity/instructions/vars.json +1 -0
  9. package/adapters/antigravity/scripts/antigravity-hook-adapter.sh +147 -0
  10. package/adapters/antigravity/skills/momentum-orient/SKILL.md +29 -0
  11. package/adapters/antigravity/skills/momentum-reviewer-architecture/SKILL.md +39 -0
  12. package/adapters/antigravity/skills/momentum-reviewer-qa/SKILL.md +38 -0
  13. package/adapters/antigravity/skills/momentum-reviewer-security/SKILL.md +42 -0
  14. package/adapters/antigravity/skills/swarm-supervisor/SKILL.md +75 -0
  15. package/adapters/antigravity/workflows/continue.md +39 -0
  16. package/adapters/antigravity/workflows/dispatch.md +49 -0
  17. package/adapters/antigravity/workflows/handoff.md +38 -0
  18. package/adapters/antigravity/workflows/review-code.md +84 -0
  19. package/adapters/antigravity/workflows/scout.md +42 -0
  20. package/adapters/antigravity/workflows/swarm.md +203 -0
  21. package/adapters/claude-code/adapter.js +148 -0
  22. package/adapters/claude-code/commands/continue.md +82 -0
  23. package/adapters/claude-code/commands/dispatch.md +154 -0
  24. package/adapters/claude-code/commands/handoff.md +85 -0
  25. package/adapters/claude-code/commands/review-code.md +194 -0
  26. package/adapters/claude-code/commands/scout.md +119 -0
  27. package/adapters/claude-code/commands/swarm.md +242 -0
  28. package/adapters/claude-code/instructions/header.md +3 -0
  29. package/adapters/claude-code/instructions/vars.json +1 -0
  30. package/adapters/claude-code/settings.json +36 -0
  31. package/adapters/codex/adapter.js +225 -0
  32. package/adapters/codex/agents/momentum-reviewer-architecture.toml +57 -0
  33. package/adapters/codex/agents/momentum-reviewer-qa.toml +52 -0
  34. package/adapters/codex/agents/momentum-reviewer-security.toml +57 -0
  35. package/adapters/codex/agents/swarm-supervisor.toml +76 -0
  36. package/adapters/codex/commands/continue.md +40 -0
  37. package/adapters/codex/commands/dispatch.md +111 -0
  38. package/adapters/codex/commands/handoff.md +57 -0
  39. package/adapters/codex/commands/scout.md +90 -0
  40. package/adapters/codex/commands/swarm.md +334 -0
  41. package/adapters/codex/hooks.json +36 -0
  42. package/adapters/codex/instructions/AGENTS.md +691 -0
  43. package/adapters/codex/instructions/header.md +3 -0
  44. package/adapters/codex/instructions/surfaces.md +206 -0
  45. package/adapters/codex/instructions/vars.json +1 -0
  46. package/adapters/codex/skills/momentum-orient/SKILL.md +29 -0
  47. package/adapters/opencode/adapter.js +224 -0
  48. package/adapters/opencode/agents/momentum-reviewer-architecture.md +54 -0
  49. package/adapters/opencode/agents/momentum-reviewer-qa.md +48 -0
  50. package/adapters/opencode/agents/momentum-reviewer-security.md +48 -0
  51. package/adapters/opencode/agents/swarm-supervisor.md +51 -0
  52. package/adapters/opencode/commands/continue.md +40 -0
  53. package/adapters/opencode/commands/dispatch.md +111 -0
  54. package/adapters/opencode/commands/handoff.md +57 -0
  55. package/adapters/opencode/commands/review-code.md +194 -0
  56. package/adapters/opencode/commands/scout.md +90 -0
  57. package/adapters/opencode/commands/swarm.md +334 -0
  58. package/adapters/opencode/instructions/AGENTS.md +604 -0
  59. package/adapters/opencode/instructions/header.md +3 -0
  60. package/adapters/opencode/instructions/surfaces.md +119 -0
  61. package/adapters/opencode/instructions/vars.json +1 -0
  62. package/adapters/opencode/plugins/momentum.js +219 -0
  63. package/adapters/opencode/skills/momentum-lanes/SKILL.md +30 -0
  64. package/adapters/opencode/skills/momentum-orient/SKILL.md +29 -0
  65. package/adapters/opencode/skills/momentum-track/SKILL.md +28 -0
  66. package/adapters/opencode/skills/momentum-validate/SKILL.md +31 -0
  67. package/bin/antigravity.js +112 -0
  68. package/bin/ecosystem.js +1302 -0
  69. package/bin/lanes.js +300 -0
  70. package/bin/momentum.js +1857 -0
  71. package/bin/okf.js +72 -0
  72. package/bin/orchestration-commands.js +305 -0
  73. package/bin/state-commands.js +218 -0
  74. package/bin/swarm.js +1104 -0
  75. package/bin/waves.js +147 -0
  76. package/core/adapter-capabilities.md +112 -0
  77. package/core/adapter-parity-matrix.md +170 -0
  78. package/core/commands/brainstorm-idea.md +98 -0
  79. package/core/commands/brainstorm-phase.md +129 -0
  80. package/core/commands/complete-phase.md +130 -0
  81. package/core/commands/ecosystem.md +161 -0
  82. package/core/commands/hotfix.md +64 -0
  83. package/core/commands/initiative.md +119 -0
  84. package/core/commands/lanes.md +94 -0
  85. package/core/commands/log.md +45 -0
  86. package/core/commands/migrate.md +70 -0
  87. package/core/commands/review.md +31 -0
  88. package/core/commands/session.md +79 -0
  89. package/core/commands/start-phase.md +161 -0
  90. package/core/commands/start-project.md +142 -0
  91. package/core/commands/sync-docs.md +81 -0
  92. package/core/commands/systematic-debug.md +46 -0
  93. package/core/commands/track.md +54 -0
  94. package/core/commands/validate.md +96 -0
  95. package/core/ecosystem/layout.md +128 -0
  96. package/core/ecosystem/lib/index.js +245 -0
  97. package/core/ecosystem/lib/initiative.js +258 -0
  98. package/core/ecosystem/lib/pointer.js +198 -0
  99. package/core/ecosystem/lib/state.js +295 -0
  100. package/core/ecosystem/schema/ecosystem.schema.json +85 -0
  101. package/core/ecosystem/schema/initiative.schema.json +61 -0
  102. package/core/ecosystem/scripts/session-append.sh +167 -0
  103. package/core/ecosystem/templates/ecosystem-agents.md +79 -0
  104. package/core/ecosystem/templates/ecosystem-claude.md +79 -0
  105. package/core/ecosystem/templates/ecosystem-settings-claude.json +14 -0
  106. package/core/ecosystem/templates/initiative-template.md +50 -0
  107. package/core/engines/subagent-dispatch.md +80 -0
  108. package/core/git-hooks/commit-msg +14 -0
  109. package/core/git-hooks/contract.js +176 -0
  110. package/core/git-hooks/pre-push +15 -0
  111. package/core/git-hooks/run-check.js +160 -0
  112. package/core/instructions/legacy-project-md-hashes.json +12 -0
  113. package/core/instructions/navigation.md +14 -0
  114. package/core/instructions/rules-body.md +454 -0
  115. package/core/lanes/lib/board.js +161 -0
  116. package/core/lanes/lib/land.js +301 -0
  117. package/core/lanes/lib/signals.js +207 -0
  118. package/core/lanes/lib/state.js +325 -0
  119. package/core/lib/frontmatter.js +163 -0
  120. package/core/lib/okf-migrate.js +374 -0
  121. package/core/lib/okf-types.js +61 -0
  122. package/core/lifecycle-contract.md +59 -0
  123. package/core/orchestration/capability-routing.js +120 -0
  124. package/core/orchestration/continue.js +102 -0
  125. package/core/orchestration/dispatch.js +366 -0
  126. package/core/orchestration/events.js +197 -0
  127. package/core/orchestration/handoff.js +317 -0
  128. package/core/orchestration/index.js +50 -0
  129. package/core/orchestration/run-artifact.js +93 -0
  130. package/core/orchestration/scout.js +327 -0
  131. package/core/orchestration/session-log.js +123 -0
  132. package/core/orchestration/tracking.js +180 -0
  133. package/core/orchestration/types.js +131 -0
  134. package/core/scripts/brainstorm-gate.sh +157 -0
  135. package/core/scripts/check-history-reminder.sh +110 -0
  136. package/core/scripts/sessionstart-handoff.sh +180 -0
  137. package/core/specs-templates/CLAUDE.md +484 -0
  138. package/core/specs-templates/README.md +32 -0
  139. package/core/specs-templates/specs/README.md +30 -0
  140. package/core/specs-templates/specs/adhoc/README.md +31 -0
  141. package/core/specs-templates/specs/adhoc/_TEMPLATE.md +29 -0
  142. package/core/specs-templates/specs/architecture/ecosystem.md +214 -0
  143. package/core/specs-templates/specs/backlog/backlog.md +46 -0
  144. package/core/specs-templates/specs/backlog/details/.gitkeep +0 -0
  145. package/core/specs-templates/specs/changelog/.gitkeep +0 -0
  146. package/core/specs-templates/specs/decisions/0000-template.md +33 -0
  147. package/core/specs-templates/specs/decisions/README.md +29 -0
  148. package/core/specs-templates/specs/decisions/impact-map.md +14 -0
  149. package/core/specs-templates/specs/decisions/index.md +4 -0
  150. package/core/specs-templates/specs/index.md +16 -0
  151. package/core/specs-templates/specs/phases/README.md +41 -0
  152. package/core/specs-templates/specs/phases/index.md +6 -0
  153. package/core/specs-templates/specs/planning/roadmap.md +23 -0
  154. package/core/specs-templates/specs/status.md +70 -0
  155. package/core/specs-templates/specs/vision/principles.md +16 -0
  156. package/core/specs-templates/specs/vision/project-charter.md +35 -0
  157. package/core/specs-templates/specs/vision/success-criteria.md +19 -0
  158. package/core/swarm/absorb.js +294 -0
  159. package/core/swarm/conductor.js +499 -0
  160. package/core/swarm/focus.js +151 -0
  161. package/core/swarm/inbox.js +222 -0
  162. package/core/swarm/join.js +138 -0
  163. package/core/swarm/lib/board.js +178 -0
  164. package/core/swarm/lib/brief.js +157 -0
  165. package/core/swarm/lib/git-sha-cache.js +71 -0
  166. package/core/swarm/lib/incremental-log.js +117 -0
  167. package/core/swarm/lib/manifest.js +578 -0
  168. package/core/swarm/lib/pre-merge.js +112 -0
  169. package/core/swarm/lib/saga.js +146 -0
  170. package/core/swarm/lib/sessions.js +83 -0
  171. package/core/swarm/lib/tokens.js +255 -0
  172. package/core/swarm/lib/wave-ordering.js +55 -0
  173. package/core/swarm/schema/board.schema.json +54 -0
  174. package/core/swarm/schema/contract.schema.json +56 -0
  175. package/core/swarm/schema/dispatch-run.schema.json +70 -0
  176. package/core/swarm/schema/manifest.schema.json +234 -0
  177. package/core/swarm/schema/signal.schema.json +61 -0
  178. package/core/swarm/signals.js +296 -0
  179. package/core/swarm/supervise.md +81 -0
  180. package/core/waves/lib/plan-graph.js +175 -0
  181. package/core/waves/lib/waves.js +83 -0
  182. package/package.json +46 -0
@@ -0,0 +1,604 @@
1
+ <!-- momentum-managed (generated) — regenerate with `npm run generate-instructions`
2
+ in the momentum repo; sources: core/instructions/ + adapters/<agent>/instructions/.
3
+ Everything above '## Project Extensions' may be replaced by `momentum upgrade`. -->
4
+
5
+ # Project Rules: <Project Name>
6
+
7
+ > opencode configuration for this momentum-managed project.
8
+
9
+ ## Navigation (Where to Find Things)
10
+
11
+ | Question | File |
12
+ |----------|------|
13
+ | Current state / what phase? | `specs/status.md` |
14
+ | What's in the backlog? | `specs/backlog/backlog.md` |
15
+ | Phase tasks/progress? | `specs/phases/phase-N-*/tasks.md` |
16
+ | Why was X chosen? | `specs/decisions/NNNN-*.md` |
17
+ | Roadmap / timeline? | `specs/planning/roadmap.md` |
18
+ | How to contribute? | `docs/developer-guide.md` |
19
+
20
+ > **First file to read: ALWAYS `specs/status.md`.**
21
+
22
+ ---
23
+
24
+ ## Momentum Recipes — opencode Commands
25
+
26
+ Every momentum recipe ships as a native opencode command at
27
+ `.opencode/commands/<name>.md` ([opencode commands
28
+ docs](https://opencode.ai/docs/commands/)). opencode auto-discovers them
29
+ at startup — type `/` in the TUI and the full recipe set appears; e.g.
30
+ `/brainstorm-phase` runs the phase-planning recipe. Arguments flow via
31
+ `$ARGUMENTS` (e.g. `/track BUG some description`).
32
+
33
+ The shipped recipe set (one command per recipe):
34
+
35
+ | Recipe | What it does |
36
+ |---|---|
37
+ | brainstorm-idea | Explore an idea before scaffolding anything |
38
+ | brainstorm-phase | Plan the next implementation phase (gate-protected) |
39
+ | start-project | Scaffold a new spec-driven project |
40
+ | start-phase | Begin a planned phase (autonomous execution contract) |
41
+ | complete-phase | Verify, retro, release a finished phase |
42
+ | sync-docs | Propagate history entries to other spec docs |
43
+ | track | Track a backlog item (bug / feature / tech debt / enhancement) |
44
+ | review | Review and groom the backlog between phases |
45
+ | log | Append a manual narrative entry to the history of the phase bound to your branch (fallback: status.md) |
46
+ | hotfix | Ship a bounded ad-hoc change (quick-task / spike) without a phase |
47
+ | lanes | Work with lanes — concurrent workstreams in one repo (Rule 15) |
48
+ | migrate | Onboard an existing project into momentum |
49
+ | validate | Check spec structure health |
50
+ | ecosystem | Cross-repo ecosystem coordination |
51
+ | initiative | Manage cross-repo initiatives |
52
+ | session | Append a manual narrative entry to today's ecosystem session log |
53
+ | systematic-debug | Systematically isolate, reproduce, and resolve task execution failures |
54
+ | scout | Read-only context fetch from one ecosystem member repo |
55
+ | dispatch | Parallel multi-repo fan-out + synthesis |
56
+ | handoff | Cross-session control transfer with structured context block |
57
+ | continue | Pick up a pending handoff in this repo |
58
+ | review-code | Multi-perspective code review (uses momentum-reviewer-* subagents) |
59
+ | swarm | Sustained parallel multi-project feature delivery (uses the swarm-supervisor agent) |
60
+
61
+ The recipes are platform-independent — they describe what to do, not how
62
+ opencode specifically should do it. When a recipe mentions "use the Task
63
+ tool" (Claude Code terminology), use opencode's task tool: invoke the
64
+ relevant subagent (`@momentum-reviewer-qa` mention or automatic task
65
+ dispatch).
66
+
67
+ ## Momentum Skills
68
+
69
+ Momentum also ships skills at `.opencode/skills/<name>/SKILL.md`
70
+ ([opencode skills docs](https://opencode.ai/docs/skills/)). opencode
71
+ discovers them natively and exposes them through the `skill` tool — the
72
+ agent loads a skill on demand when its description matches the work.
73
+ Skills complement commands: commands are user-invoked (`/name`), skills
74
+ are agent-invoked (momentum-orient runs Rule 1 orientation without you
75
+ asking).
76
+
77
+ Add project-specific skills under `.opencode/skills/<name>/SKILL.md`
78
+ with `name` + `description` frontmatter (name must match
79
+ `^[a-z0-9]+(-[a-z0-9]+)*$`).
80
+
81
+ ## Momentum Plugin — enforcement hooks
82
+
83
+ Momentum's enforcement layer ships as one plugin at
84
+ `.opencode/plugins/momentum.js` ([opencode plugins
85
+ docs](https://opencode.ai/docs/plugins/)), auto-loaded at startup:
86
+
87
+ | Hook | Purpose |
88
+ |---|---|
89
+ | `tool.execute.before` | Brainstorm gate — blocks write-class tools targeting `specs/**` while `.momentum/brainstorm-active` exists (throws to block, mirroring the Claude Code PreToolUse gate). |
90
+ | `tool.execute.after` | History reminder — prompts for a `history.md` append when meaningful edits land during phase work (Rule 8); bash tool calls additionally delegate to the installed scripts/check-history-reminder.sh, which also feeds the ecosystem session log (ENH-058). |
91
+ | `event (session.created)` | Handoff banner — surfaces pending `.momentum/inbox/` handoffs at session start. **Run-mode caveat**: this handler is registered only in TUI/serve sessions. In `opencode run` (headless/non-interactive) the handler is skipped — its mere presence hangs `opencode run` on 1.17.x (upstream candidate, noted in ENH-058). Session banners are meaningless in headless mode anyway. |
92
+
93
+ The plugin is self-contained (no npm dependencies) and reads the same
94
+ `.momentum/` sentinels as the other adapters' hook scripts — the
95
+ enforcement semantics are identical across platforms.
96
+
97
+ ## Momentum Subagents
98
+
99
+ Momentum ships four agents at `.opencode/agents/` ([opencode agents
100
+ docs](https://opencode.ai/docs/agents/)):
101
+
102
+ - `momentum-reviewer-security.md` — OWASP/STRIDE-focused
103
+ - `momentum-reviewer-qa.md` — test coverage + edge cases + regression risk
104
+ - `momentum-reviewer-architecture.md` — rule compliance + pattern consistency
105
+ - `swarm-supervisor.md` — per-repo supervisor spawned by `/swarm start`
106
+
107
+ The three reviewers declare `mode: subagent` with `permission: edit: deny`
108
+ — they cannot modify the codebase. The `review-code` recipe dispatches
109
+ all three in one turn so opencode can fan them out via the task tool.
110
+ The swarm supervisor is not read-only — supervisors write code, that's
111
+ the job.
112
+
113
+ To add a project-specific reviewer, drop another `<name>.md` into
114
+ `.opencode/agents/` with `description` + `mode: subagent` frontmatter.
115
+
116
+ ## Swarm — Lookup Pattern
117
+
118
+ Momentum's swarm primitive ships on opencode. The swarm recipe lives at
119
+ `.opencode/commands/swarm.md` (`/swarm <sub>`); the CLI floor is
120
+ `momentum swarm <sub> [args]` — both produce the same on-disk artifacts.
121
+
122
+ **Supervisor spawn**: the conductor dispatches spawns through
123
+ `adapters/opencode/adapter.js::spawn(directive)`, which shells
124
+
125
+ ```bash
126
+ opencode run --dir <repoPath> --agent swarm-supervisor "<boot directive>"
127
+ ```
128
+
129
+ `--dir` pins each supervisor's working directory to its repo — no MCP
130
+ cwd shim needed (unlike Codex). If `opencode` isn't on PATH,
131
+ `momentum swarm start --spawn` degrades to dry-run and prints the spawn
132
+ directives for manual launch.
133
+
134
+ ## Instruction precedence note
135
+
136
+ opencode reads `AGENTS.md` (this file) as its primary project
137
+ instruction, with `CLAUDE.md` as a compatibility fallback — when both
138
+ exist (e.g. a project installed for multiple agents), `AGENTS.md` wins
139
+ and nothing is read twice. opencode also discovers Claude-compatible
140
+ skill paths (`.claude/skills/`, `.agents/skills/`); momentum's opencode
141
+ surfaces live under `.opencode/` so multi-adapter installs stay
142
+ side-by-side without collisions.
143
+
144
+ ## Autonomous Behaviors (Always-On Rules)
145
+
146
+ ### Rule 1: Always Orient First
147
+
148
+ Before ANY work, read `specs/status.md`. This tells you:
149
+ - What phase is active
150
+ - What's blocking progress
151
+ - What P0 items need attention
152
+
153
+ ### Rule 2: Auto-Update Tracking After Changes
154
+
155
+ After completing ANY meaningful work, automatically update:
156
+
157
+ 1. **Your phase's `tasks.md`** (the phase bound to your branch — Rule 15) — mark completed `[x]`, in-progress `[/]`
158
+ 2. **`specs/status.md`** — if phase progress, blockers, or P0 items changed (touch only your own lane's row — Rule 15)
159
+ 3. **`specs/changelog/YYYY-MM.md`** — log what changed (one line per change, append-only)
160
+
161
+ Use the built-in **task** tool (subagent fan-out) to track in-session task progress. Do NOT wait for the user to ask you to update tracking.
162
+
163
+ #### Why
164
+ Tracking debt compounds invisibly. A task list one day stale is recoverable; one week stale is fiction. Status drift is how phases silently lose direction.
165
+
166
+ #### Red Flags — STOP and update tracking now
167
+
168
+ | If you find yourself thinking… | …STOP and update before doing anything else |
169
+ |---|---|
170
+ | "I'll batch the tracking updates at the end" | The end never comes — context fades and details get lost |
171
+ | "This change is too small to log" | Small changes accumulate into invisible drift |
172
+ | "The diff makes it obvious what changed" | The diff shows *what*; the changelog explains *why* |
173
+ | "The user can read git log" | Git log doesn't index by phase or backlog ID |
174
+ | "I'll log this as part of the next bigger update" | Bigger updates conflate decisions and lose per-step reasoning |
175
+
176
+ #### Anti-Rationalization Counters
177
+
178
+ - "It's faster to do the work first and track at the end" — wrong: reconstruction takes 2-3× longer than real-time logging.
179
+ - "The task tool is enough" — The task tool is in-session only; `tasks.md` is the durable record.
180
+ - "Mid-task tracking interrupts flow" — a one-line update costs <30s; reconstructing a day later costs 30 minutes.
181
+
182
+ ### Rule 3: Auto-Track Discoveries
183
+
184
+ When you discover a bug, tech debt, or enhancement during work:
185
+ - Add it to `specs/backlog/backlog.md` immediately with appropriate priority
186
+ - Mention it to the user: "I found [issue] and added it as [ID] to backlog"
187
+
188
+ ### Rule 4: Pre-Phase Bug Check
189
+
190
+ Before starting work on a new phase:
191
+ - Scan `specs/backlog/backlog.md` for P0/P1 bugs
192
+ - If any exist, recommend addressing them first
193
+ - Present: "N open bugs (X critical), recommend fixing before proceeding"
194
+
195
+ Starting a phase while other lanes are active is normal (Rule 15) — the bug
196
+ check still runs per phase start.
197
+
198
+ ### Rule 5: Phase Boundary Awareness
199
+
200
+ When completing the last task in a phase:
201
+ - Prompt the user: "All tasks in Phase N are complete. Run `/complete-phase` to verify and release?"
202
+ - Do NOT auto-complete a phase without user confirmation
203
+ - "Complete" means the phase bound to YOUR branch (Rule 15); landing it on
204
+ `main` follows the Rule 6 landing order when other lanes are in flight
205
+
206
+ ### Rule 6: Git Lifecycle
207
+
208
+ > **Enforced vs advised.** momentum installs git hooks that *enforce* the
209
+ > high-stakes parts of this lifecycle (see `core/lifecycle-contract.md`):
210
+ > `commit-msg` validates Conventional Commits; `pre-push` blocks direct pushes
211
+ > to `main`/`staging` without the single-use `.momentum/merge-approved`
212
+ > sentinel, and blocks release-tag pushes lacking verification evidence
213
+ > (Rule 12). Hooks install to `.githooks/` via `core.hooksPath`. Emergency
214
+ > bypass (auditable, preferred over `--no-verify`): `MOMENTUM_SKIP_HOOKS=1`.
215
+ > Everything else below is agent convention, not mechanism.
216
+ >
217
+ > *Optional hardening:* enable your forge's server-side branch protection
218
+ > (GitHub Rulesets / GitLab protected branches / Bitbucket permissions) as an
219
+ > unbypassable backstop. momentum stays forge-neutral and ships no forge code.
220
+
221
+ #### Starting Work
222
+ - **Before ANY code change**, check current branch
223
+ - If on `main` or `staging`, **auto-create a feature branch**:
224
+ - Phase work: `phase-N-shortname`
225
+ - Bug fix: `fix/BUG-NNN-short-desc`
226
+ - Feature: `feat/short-desc`
227
+ - Tech debt: `refactor/TD-NNN-short-desc`
228
+
229
+ #### During Work
230
+ - **Auto-commit** after each logical unit with conventional commits:
231
+ - `feat(scope):` | `fix(scope):` | `docs:` | `refactor(scope):` | `chore:` | `infra:`
232
+ - Keep commits atomic — one logical change per commit
233
+ - Push to remote after significant milestones
234
+
235
+ #### Completing Work
236
+ - Commit all remaining changes, push branch
237
+ - **ASK the user** before merging to `staging` or `main`
238
+
239
+ | Action | Agent does automatically | Needs approval | Hook enforcement |
240
+ |--------|--------------------------|----------------|------------------|
241
+ | Create feature branch | Yes | No | — (convention) |
242
+ | Commit to feature branch | Yes | No | `commit-msg` validates the message |
243
+ | Push feature branch | Yes | No | `pre-push` allows (non-protected) |
244
+ | Delete merged feature branch | Yes (after confirmed merge) | No | `/complete-phase` step 13 |
245
+ | Merge to `staging`/`main` | No | **Yes** | `pre-push` **blocks** without `.momentum/merge-approved` |
246
+ | Tag a release | No | **Yes** | `pre-push` **blocks** without verification evidence |
247
+
248
+ #### Landing Order — Concurrent Lanes (Rule 15)
249
+
250
+ When more than one lane is in flight, `main` is the runway — lanes land
251
+ **one at a time**:
252
+
253
+ 1. One lane merges (with its approval gate above).
254
+ 2. The full suite runs green on the updated `main` **before** the next landing.
255
+ 3. Remaining lanes **rebase onto the updated `main`** before they land.
256
+ 4. Stacked (dependent) lanes land parent-first; a child rebases onto its
257
+ parent until the parent lands, then onto `main`.
258
+
259
+ Never land two lanes back-to-back without the suite passing in between — a
260
+ green suite on each lane's branch does not prove the *combination* is green.
261
+
262
+ #### Why
263
+ Direct commits to `main` bypass review, history, and rollback. A single rushed commit on `main` is harder to revert than ten commits on a branch. The branch convention is the cheapest possible insurance against catastrophic mistakes.
264
+
265
+ #### Red Flags — STOP and check the branch
266
+
267
+ | If you find yourself thinking… | …STOP and switch to a branch |
268
+ |---|---|
269
+ | "Just one tiny commit to main" | One becomes ten — branch first, decide later |
270
+ | "I'll create the branch after these edits" | The edits are the work; the branch is non-optional |
271
+ | "The hook is in the way, --no-verify just this once" | The momentum hooks are real now. Fix the cause; for a genuine emergency use the auditable `MOMENTUM_SKIP_HOOKS=1`, never blanket `--no-verify`. |
272
+ | "Force push is fine, nobody else is on this branch" | Future you is on this branch. `--force-with-lease` at minimum. |
273
+
274
+ #### Anti-Rationalization Counters
275
+
276
+ - "It's a one-line typo fix on main" — branches are free; revert is cheap; main is sacred.
277
+ - "The branch protection isn't set up yet" — that's a reason to be more careful, not less.
278
+ - "I'll squash-merge later, so the intermediate commits don't matter" — they matter for `git bisect` and for narrating *why*.
279
+
280
+ ### Rule 7: Plan Before Implementing
281
+
282
+ For any non-trivial implementation (new feature, architectural change):
283
+ - Use `/brainstorm-phase` to design the approach first
284
+ - Present the plan for user approval before making changes
285
+
286
+ ### Rule 8: Record Phase History
287
+
288
+ While working on a phase, append meaningful changes to that phase's history log — `specs/phases/<phase-bound-to-your-branch>/history.md` (Rule 15; each lane writes only its own history).
289
+
290
+ #### What counts as "meaningful"
291
+
292
+ Append a history entry when ANY of these occur:
293
+
294
+ | Trigger | Entry type |
295
+ |---|---|
296
+ | ADR was created or its status/decision changed | `[DECISION]` |
297
+ | Phase scope was added to or reduced | `[SCOPE_CHANGE]` |
298
+ | Bug, tech debt, or enhancement was added to backlog | `[DISCOVERY]` |
299
+ | New feature was added to the phase plan | `[FEATURE]` |
300
+ | Architectural pattern or integration approach changed | `[ARCH_CHANGE]` |
301
+ | Locked evaluator was defined or its evaluation set changed | `[EVALUATOR]` |
302
+ | Anything else worth a future reader's time | `[NOTE]` |
303
+
304
+ After writing a history entry, check `specs/decisions/impact-map.md` and add any new topics so `/sync-docs` can find affected files.
305
+
306
+ The hook script `scripts/check-history-reminder.sh` runs after edits as a safety net — heed its prompts.
307
+
308
+ #### Format (APPEND ONLY)
309
+
310
+ ```
311
+ ### [TYPE] YYYY-MM-DD — Short title
312
+ Topics: topic-1, topic-2
313
+ Affects-phases: phase-N-name (or "none")
314
+ Affects-specs: path/to/file.md#section (or "none")
315
+ Detail: One to three sentences describing what changed and why.
316
+
317
+ ---
318
+ ```
319
+
320
+ #### Why
321
+ The history log is the only place that preserves *why* a decision was made at the moment it was made. Specs document the current state; commits document mechanical changes; only history captures motivation. Without it, six months later nobody can reconstruct whether a constraint is load-bearing or accidental.
322
+
323
+ #### Red Flags — STOP and log
324
+
325
+ | If you find yourself thinking… | …STOP and append the entry now |
326
+ |---|---|
327
+ | "I'll write the history at the end of the phase" | You won't remember the *why*. Log when the decision is fresh. |
328
+ | "This decision isn't important enough to log" | If it's not worth logging, it's not worth deciding — log it or revert it. |
329
+ | "I already mentioned it in the commit message" | Commit messages get buried; history.md is the canonical source. |
330
+ | "The change is obvious from the diff" | Diffs show *what*; history shows *why*. |
331
+
332
+ #### Anti-Rationalization Counters
333
+
334
+ - "We didn't decide anything — just discovered an issue" — that's `[DISCOVERY]`, log it.
335
+ - "It's a minor scope tweak, not a real `[SCOPE_CHANGE]`" — every scope change is real, log it.
336
+ - "I'll consolidate entries later" — consolidation loses per-decision context.
337
+
338
+ ### Rule 9: Doc Sync Protocol — Never Mid-Phase, Always at Completion
339
+
340
+ - **During a phase**: Record to history. Do NOT update other specs.
341
+ - **At phase completion**: Run `/sync-docs` BEFORE `/complete-phase`.
342
+
343
+ #### Multi-repo projects only
344
+
345
+ If this project depends on, or is depended on by, other repos in a parent workspace:
346
+ - NEVER modify docs that live in another repo during `/sync-docs`. You only own this repo's docs.
347
+ - If a history entry's `Affects-specs:` path starts with `../` (or otherwise points outside this repo), leave that file alone.
348
+ - Flag the cross-repo impact to the user — give the exact path — so they can sync the other repo manually.
349
+ - Cross-repo doc ownership is a structural choice. Never quietly change docs you don't own.
350
+
351
+ ### Rule 10: Architecture Specs Stability (monorepo only)
352
+
353
+ Files under `specs/architecture/` are constitutional documents. Treat them as a stable reference *during* phase work. The key distinction is **additive bookkeeping** vs **architectural decisions**.
354
+
355
+ **During phase implementation (both types — no spec changes):**
356
+ - READ specs as stable reference
357
+ - NEVER modify them based on implementation discoveries
358
+ - Log all gaps and changes as `[ARCH_CHANGE]` in phase history with `Affects-specs:`
359
+
360
+ **At phase completion (via `/sync-docs`):**
361
+ - **Additive changes** (new fields, new ports, new modes — extending an existing design): update specs directly. No ADR required.
362
+ - **Decisional changes** (approach changes, trade-off choices, design direction shifts): require an ADR amendment **before** any spec update.
363
+
364
+ #### Why
365
+ The original "all spec changes via ADR" rule worked when the architecture was stabilizing and every change was a decision. By mid-to-late phases, the architecture is proven — most changes are additive extensions, not decisions. Requiring ADRs for bookkeeping creates spec staleness while adding no value. ADRs capture *why* a path was chosen; they're not required when you're just recording *what was added*.
366
+
367
+ #### Red Flags — STOP and route correctly
368
+
369
+ | If you find yourself thinking… | …STOP |
370
+ |---|---|
371
+ | "I just need to update one field, not a real change" | Additive — fine at completion; not now. Log `[ARCH_CHANGE]`. |
372
+ | "It's faster to fix the spec than to log the gap" | Faster locally, catastrophic globally — specs out of sync with rationale. |
373
+ | "The implementation diverged because the spec was wrong" | That's a decision — ADR first, spec update second. Don't silently rewrite. |
374
+ | "I'll log it as `[NOTE]` instead of `[ARCH_CHANGE]`" | If it touches `specs/architecture/`, it's `[ARCH_CHANGE]`. |
375
+
376
+ #### Anti-Rationalization Counters
377
+
378
+ - "Specs are wrong, code is right, so update specs" — only after an ADR documents *why* the design shifted.
379
+ - "Mid-phase spec edits are fine if I'm careful" — the rule isn't about care; it's about preventing reference instability while you're depending on the reference.
380
+ - "This is just renaming, not redesigning" — renames are decisions when others read the spec.
381
+
382
+ ### Rule 11: Evaluator Discipline — Lock Evaluators Before Loops
383
+
384
+ Before building any learning, optimization, or self-improvement loop:
385
+
386
+ 1. Define the **evaluation set** — a fixed corpus with known-good outputs
387
+ 2. Define the **scalar** — a single number that improves or doesn't
388
+ 3. Commit the evaluator to `tests/benchmarks/` with a version tag
389
+ 4. Build the loop **AFTER** the evaluator is committed
390
+ 5. **NEVER** change the evaluator while the loop is being optimized
391
+
392
+ #### Why
393
+ Optimization loops with mutable evaluators don't measure progress — they measure motion. Every "small fix" to the eval set silently rewrites the score history and makes A-vs-B comparisons meaningless. Locking the evaluator first costs an hour; not locking it costs the entire experiment.
394
+
395
+ #### Red Flags — STOP and freeze
396
+
397
+ | If you find yourself thinking… | …STOP |
398
+ |---|---|
399
+ | "Just one tweak to the eval so this run looks better" | That's exactly the failure mode. Freeze first; tweak in a v2 evaluator. |
400
+ | "We'll lock the evaluator after we know what works" | You can't know what works without a locked evaluator. |
401
+ | "The current eval doesn't measure what we actually care about" | Correct — but freeze it before optimizing, then version-bump to a new locked eval. |
402
+ | "It's just an internal experiment, locking is overkill" | Internal experiments produce internal beliefs that drive external decisions. Lock. |
403
+
404
+ #### Anti-Rationalization Counters
405
+
406
+ - "The eval set is too small, I'll just add a few more cases" — version-bump the evaluator (`v1` → `v2`); don't mutate `v1`.
407
+ - "I noticed a bug in the scorer mid-run" — fix it in `v2`; rerun the prior runs against `v2`; don't backfill `v1` scores.
408
+ - "Production data drifted, I should refresh the eval" — that's a `v2` decision, not a `v1` patch.
409
+
410
+ ### Rule 12: Verify Before Claim — No Completion Without Evidence
411
+
412
+ Before claiming any task, fix, or implementation is "done":
413
+
414
+ 1. Run the actual verification command (test, lint, typecheck, smoke test, build)
415
+ 2. Read the output — both exit code and content
416
+ 3. If the output isn't fresh from this attempt in this session, treat the task as unverified
417
+ 4. Only mark a task `[x]` after a verification command produced passing output in this session
418
+
419
+ #### Why
420
+ The most common agentic-workflow failure is "should work now" — claiming completion based on intent rather than evidence. Fresh, observable output is the only signal that the change actually achieves what was claimed. Box-checking without verification compounds across phases until shipped releases contain unrun code paths.
421
+
422
+ #### Red Flags — STOP and run the verification
423
+
424
+ | If you find yourself thinking… | …STOP and run the verification before marking done |
425
+ |---|---|
426
+ | "I'm confident this works — no need to test" | Confidence is not evidence. Run the test. |
427
+ | "The change is small enough that I can skip verification" | "Small" is the most common predicate of a regression. Run it. |
428
+ | "I already tested something similar earlier" | Earlier ≠ now. Re-run against the current code. |
429
+ | "The unit tests pass — that's enough" | Unit tests don't catch wiring bugs. Run the integration / smoke path too. |
430
+ | "I'll batch verifications at the end of the phase" | At the end you can't tell which change caused which failure. Verify per-task. |
431
+
432
+ #### Anti-Rationalization Counters
433
+
434
+ - "The diff is obviously correct" — diffs lie when context is incomplete. Run the test.
435
+ - "The CI will catch any issue" — CI catches it after you claimed done; that's the failure mode this rule prevents.
436
+ - "Type checking passed, so it works" — types catch shape errors, not behavior. Run the runtime check.
437
+ - "I read the code carefully and it looks right" — careful reading misses race conditions, missing imports, off-by-one bugs. Verification commands don't.
438
+ - "The previous task was similar and that worked" — previous ≠ current. Each task gets its own verification.
439
+
440
+ If a verification command does not exist for the task, write one before marking done. If a command can't run in the current environment, say so explicitly — do not silently downgrade to "looks correct".
441
+
442
+ ---
443
+
444
+ ### Rule 13: Test-Driven Development (TDD) — Opt-in
445
+
446
+ If enabled in the project rules extensions (under `## Project Extensions` in this file), follow a strict test-first development loop:
447
+
448
+ 1. **Red**: Write a unit or integration test that specifies the new behavior *before* writing any application code.
449
+ 2. **Verify Failure**: Run the test runner and verify that the newly added test fails. Do not write any implementation code until you have seen the test fail.
450
+ 3. **Green**: Write the minimal application code necessary to make the test pass.
451
+ 4. **Refactor**: Clean up and optimize the code while keeping all tests green.
452
+
453
+ #### Red Flags — STOP and write the test first
454
+
455
+ | If you find yourself thinking… | …STOP |
456
+ |---|---|
457
+ | "I will write the tests at the end" | Post-facto tests are not TDD — they inherit confirmation bias from the implementation. |
458
+ | "The change is too simple to warrant a test-first approach" | Simple changes are excellent TDD candidates to establish correct wiring. |
459
+
460
+ ### Rule 14: Work-Type Escalation — Pick the Lightest Type That Fits
461
+
462
+ Not every change is a phase. momentum has three work types (see
463
+ `specs/adhoc/README.md`):
464
+
465
+ | Type | When | How |
466
+ |---|---|---|
467
+ | `phase` | Net-new features; cross-cutting or architectural work | `/brainstorm-phase` → `/start-phase` → … → `/complete-phase` |
468
+ | `quick-task` | A bounded bugfix / chore / audit / dependency bump | `/hotfix` — ad-hoc record + Rule 12 gate, no phase scaffold |
469
+ | `spike` | Time-boxed, throwaway exploration | `/hotfix --spike` — declared, gate-exempt, record what was learned |
470
+
471
+ **Governing principle:** select the lightest work type that fits; escalate only
472
+ when scope/risk/cross-cutting impact justifies it. (Per Anthropic's "build the
473
+ simplest thing first; add structure only when it demonstrably helps.")
474
+
475
+ **A quick-task MUST escalate to a phase when it:** touches more than ~5 files of
476
+ production code, modifies anything under `specs/architecture/`, needs an ADR,
477
+ changes a public contract/interface, or displaces a planned phase.
478
+
479
+ #### Red Flags — STOP and escalate (or de-escalate)
480
+
481
+ | If you find yourself thinking… | …STOP |
482
+ |---|---|
483
+ | "This `/hotfix` is growing — I'll just keep going" | If it now touches architecture or many files, it's a phase. Escalate. |
484
+ | "I'll spin up a whole phase for this one-line fix" | Over-ceremony. A `/hotfix` quick-task is the right size. |
485
+ | "It's exploratory but I'll ship it straight to main" | A spike is gate-exempt *because* it's throwaway. Harden it as a quick-task first. |
486
+
487
+ ### Rule 15: Concurrent Workstreams — Lanes
488
+
489
+ Multiple workstreams may be active in one repo at the same time (see
490
+ ADR-0001). A **lane** is one workstream: a branch (usually in its own
491
+ worktree) bound to one phase or ad-hoc record.
492
+
493
+ #### Lane binding — which phase is yours
494
+
495
+ - Your phase is **the phase bound to your branch**: branch
496
+ `phase-N-shortname` ↔ directory `specs/phases/phase-N-shortname/`.
497
+ - `specs/status.md`'s Active Phase table is the **fallback and the
498
+ cross-lane overview** — read it to see what else is in flight, not to
499
+ decide which phase is yours.
500
+ - Non-phase branches (`fix/*`, `chore/*`, `feat/*`) bind to the ad-hoc lane
501
+ (`specs/adhoc/`, Rule 14). Detached HEAD → fall back to `status.md`.
502
+
503
+ #### Lane-scoped tracking
504
+
505
+ - Write ONLY your own phase's artifacts (`tasks.md`, `history.md`,
506
+ `evidence/`) — these are parallel-safe by construction.
507
+ - Shared tracking files (`status.md`, `backlog.md`, `changelog/`) are
508
+ **append / own-row-touch only** from a lane: add or edit your own
509
+ row/line; never reformat, renumber, or rewrite other lanes' entries.
510
+ - The Active Phase table holds **one row per active lane**
511
+ (Phase | Branch | Status | Progress). Add your row at phase start; update
512
+ only your row; mark it at completion.
513
+
514
+ #### Landing
515
+
516
+ Lanes integrate per the Rule 6 **Landing Order** — one lane at a time, suite
517
+ green on updated `main` between landings, remaining lanes rebase.
518
+
519
+ **Mechanism:** `momentum lanes` — open/board/queue/signal/inbox/done/land
520
+ (see the `/lanes` recipe). The board shows every lane + queue pressure from
521
+ any session; `lanes land` enforces turn, rebase-freshness, and the
522
+ Rule-14-graded evidence gate before merging.
523
+
524
+ #### Off-lane work
525
+
526
+ Brainstorms and spikes are **off-lane** — zero tracking contention by
527
+ design. `/brainstorm-idea` writes no files; a spike writes only its own
528
+ `specs/adhoc/<id>/` record. Neither touches the Active Phase table.
529
+
530
+ #### Why
531
+ Two concurrent sessions cannot both be right about "the active phase" when
532
+ the spec layer models exactly one. Binding phase to branch makes each
533
+ session's context unambiguous, and append-only discipline on shared files
534
+ keeps N lanes trivially mergeable. Git isolation (worktrees) was never the
535
+ problem — the spec layer was.
536
+
537
+ #### Red Flags — STOP and re-scope to your lane
538
+
539
+ | If you find yourself thinking… | …STOP |
540
+ |---|---|
541
+ | "I'll just fix this line in the other phase's tasks.md while I'm here" | That's another lane's artifact. Leave it; tell the user or file a backlog item. |
542
+ | "status.md is stale for that other lane, I'll update their row" | Their session owns that row. Touch only your own. |
543
+ | "I'll reformat the Active Phase table while adding my row" | Reformatting rewrites every lane's row — append yours, change nothing else. |
544
+ | "Which phase am I on? I'll take status.md's first row" | Your branch decides your phase. status.md is the overview, not the binding. |
545
+ | "Both lanes are done, I'll merge them together to save a suite run" | One at a time; suite green between landings (Rule 6 Landing Order). |
546
+
547
+ #### Anti-Rationalization Counters
548
+
549
+ - "The other lane's edit is tiny and obviously right" — cross-lane edits are how tracking corrupts; smallness is irrelevant.
550
+ - "Rebasing my lane again is wasted work" — rebasing is the price of a green runway; a stale lane landing on moved `main` is how combination bugs ship.
551
+ - "There's only one lane active right now, Rule 15 doesn't apply" — a single lane is the N=1 case; the binding still defines which phase is yours.
552
+
553
+ ---
554
+
555
+ ## Naming Conventions
556
+
557
+ ### Backlog IDs
558
+ | Type | Prefix | Example |
559
+ |------|--------|---------|
560
+ | Bug | `BUG-` | `BUG-001` |
561
+ | Feature | `FEAT-` | `FEAT-001` |
562
+ | Tech Debt | `TD-` | `TD-001` |
563
+ | Enhancement | `ENH-` | `ENH-001` |
564
+
565
+ ### Priorities
566
+ | Level | Meaning | SLA |
567
+ |-------|---------|-----|
568
+ | `P0` | Critical — blocks current phase | < 1 day |
569
+ | `P1` | High — current/next phase | < 1 week |
570
+ | `P2` | Medium — within 2 phases | < 1 phase |
571
+ | `P3` | Low — nice to have | best-effort |
572
+
573
+ ### Git Branches
574
+ | Type | Pattern |
575
+ |------|---------|
576
+ | Phase | `phase-N-shortname` |
577
+ | Feature | `feat/description` |
578
+ | Bug fix | `fix/description` |
579
+ | Refactor | `refactor/description` |
580
+ | Infrastructure | `infra/description` |
581
+ | Delete after merge | `git push origin --delete <branch>` once merged |
582
+
583
+ ### Git Commits (Conventional)
584
+ `feat:` | `fix:` | `docs:` | `refactor:` | `chore:` | `infra:`
585
+
586
+ Also accepted by the `commit-msg` hook: `test:` `perf:` `build:` `ci:` `style:` `revert:` (standard Conventional-Commit types). Scope and breaking-change `!` are optional, e.g. `fix(install)!: …`.
587
+
588
+ Use `infra:` for CI, build, deploy, tooling, and release-pipeline changes that don't ship code.
589
+
590
+ ---
591
+
592
+ ## Constraints
593
+
594
+ 1. **No secrets in code** — all credentials via env vars
595
+ 2. **Never commit to main** — always use feature/phase branches
596
+ 3. **Plan before implementing** — use `/brainstorm-phase` for non-trivial work
597
+
598
+ ---
599
+
600
+ ## Project Extensions
601
+
602
+ > Everything below this heading is preserved across `momentum upgrade`.
603
+ > Add project-specific navigation, rules, cross-repo references, etc. here.
604
+ > Anything above this heading is managed by momentum and may be replaced on upgrade.
@@ -0,0 +1,3 @@
1
+ # Project Rules: <Project Name>
2
+
3
+ > opencode configuration for this momentum-managed project.