mindforge-cc 1.0.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 (324) hide show
  1. package/.agent/CLAUDE.md +462 -0
  2. package/.agent/forge/help.md +7 -0
  3. package/.agent/forge/init-project.md +32 -0
  4. package/.agent/forge/plan-phase.md +30 -0
  5. package/.agent/mindforge/approve.md +18 -0
  6. package/.agent/mindforge/audit.md +30 -0
  7. package/.agent/mindforge/benchmark.md +33 -0
  8. package/.agent/mindforge/complete-milestone.md +18 -0
  9. package/.agent/mindforge/debug.md +126 -0
  10. package/.agent/mindforge/discuss-phase.md +138 -0
  11. package/.agent/mindforge/execute-phase.md +165 -0
  12. package/.agent/mindforge/health.md +21 -0
  13. package/.agent/mindforge/help.md +23 -0
  14. package/.agent/mindforge/init-org.md +131 -0
  15. package/.agent/mindforge/init-project.md +155 -0
  16. package/.agent/mindforge/install-skill.md +15 -0
  17. package/.agent/mindforge/map-codebase.md +298 -0
  18. package/.agent/mindforge/metrics.md +22 -0
  19. package/.agent/mindforge/migrate.md +40 -0
  20. package/.agent/mindforge/milestone.md +12 -0
  21. package/.agent/mindforge/next.md +105 -0
  22. package/.agent/mindforge/plan-phase.md +125 -0
  23. package/.agent/mindforge/plugins.md +40 -0
  24. package/.agent/mindforge/pr-review.md +41 -0
  25. package/.agent/mindforge/profile-team.md +23 -0
  26. package/.agent/mindforge/publish-skill.md +19 -0
  27. package/.agent/mindforge/quick.md +135 -0
  28. package/.agent/mindforge/release.md +10 -0
  29. package/.agent/mindforge/retrospective.md +26 -0
  30. package/.agent/mindforge/review.md +157 -0
  31. package/.agent/mindforge/security-scan.md +233 -0
  32. package/.agent/mindforge/ship.md +100 -0
  33. package/.agent/mindforge/skills.md +141 -0
  34. package/.agent/mindforge/status.md +104 -0
  35. package/.agent/mindforge/sync-confluence.md +11 -0
  36. package/.agent/mindforge/sync-jira.md +12 -0
  37. package/.agent/mindforge/tokens.md +8 -0
  38. package/.agent/mindforge/update.md +42 -0
  39. package/.agent/mindforge/verify-phase.md +62 -0
  40. package/.agent/mindforge/workspace.md +29 -0
  41. package/.claude/CLAUDE.md +462 -0
  42. package/.claude/commands/forge/help.md +7 -0
  43. package/.claude/commands/forge/init-project.md +32 -0
  44. package/.claude/commands/forge/plan-phase.md +30 -0
  45. package/.claude/commands/mindforge/approve.md +18 -0
  46. package/.claude/commands/mindforge/audit.md +30 -0
  47. package/.claude/commands/mindforge/benchmark.md +33 -0
  48. package/.claude/commands/mindforge/complete-milestone.md +18 -0
  49. package/.claude/commands/mindforge/debug.md +126 -0
  50. package/.claude/commands/mindforge/discuss-phase.md +138 -0
  51. package/.claude/commands/mindforge/execute-phase.md +165 -0
  52. package/.claude/commands/mindforge/health.md +21 -0
  53. package/.claude/commands/mindforge/help.md +23 -0
  54. package/.claude/commands/mindforge/init-org.md +131 -0
  55. package/.claude/commands/mindforge/init-project.md +155 -0
  56. package/.claude/commands/mindforge/install-skill.md +15 -0
  57. package/.claude/commands/mindforge/map-codebase.md +298 -0
  58. package/.claude/commands/mindforge/metrics.md +22 -0
  59. package/.claude/commands/mindforge/migrate.md +40 -0
  60. package/.claude/commands/mindforge/milestone.md +12 -0
  61. package/.claude/commands/mindforge/next.md +105 -0
  62. package/.claude/commands/mindforge/plan-phase.md +125 -0
  63. package/.claude/commands/mindforge/plugins.md +40 -0
  64. package/.claude/commands/mindforge/pr-review.md +41 -0
  65. package/.claude/commands/mindforge/profile-team.md +23 -0
  66. package/.claude/commands/mindforge/publish-skill.md +19 -0
  67. package/.claude/commands/mindforge/quick.md +135 -0
  68. package/.claude/commands/mindforge/release.md +10 -0
  69. package/.claude/commands/mindforge/retrospective.md +26 -0
  70. package/.claude/commands/mindforge/review.md +157 -0
  71. package/.claude/commands/mindforge/security-scan.md +233 -0
  72. package/.claude/commands/mindforge/ship.md +100 -0
  73. package/.claude/commands/mindforge/skills.md +141 -0
  74. package/.claude/commands/mindforge/status.md +104 -0
  75. package/.claude/commands/mindforge/sync-confluence.md +11 -0
  76. package/.claude/commands/mindforge/sync-jira.md +12 -0
  77. package/.claude/commands/mindforge/tokens.md +8 -0
  78. package/.claude/commands/mindforge/update.md +42 -0
  79. package/.claude/commands/mindforge/verify-phase.md +62 -0
  80. package/.claude/commands/mindforge/workspace.md +29 -0
  81. package/.forge/org/CONVENTIONS.md +0 -0
  82. package/.forge/org/ORG.md +0 -0
  83. package/.forge/org/SECURITY.md +0 -0
  84. package/.forge/org/TOOLS.md +0 -0
  85. package/.forge/personas/analyst.md +0 -0
  86. package/.forge/personas/architect.md +0 -0
  87. package/.forge/personas/debug-specialist.md +0 -0
  88. package/.forge/personas/developer.md +26 -0
  89. package/.forge/personas/qa-engineer.md +0 -0
  90. package/.forge/personas/release-manager.md +0 -0
  91. package/.forge/personas/security-reviewer.md +33 -0
  92. package/.forge/personas/tech-writer.md +0 -0
  93. package/.forge/skills/api-design/SKILL.md +0 -0
  94. package/.forge/skills/code-quality/SKILL.md +0 -0
  95. package/.forge/skills/documentation/SKILL.md +0 -0
  96. package/.forge/skills/security-review/SKILL.md +23 -0
  97. package/.forge/skills/testing-standards/SKILL.md +27 -0
  98. package/.github/workflows/mindforge-ci.yml +224 -0
  99. package/.gitlab-ci-mindforge.yml +18 -0
  100. package/.mindforge/MINDFORGE-SCHEMA.json +165 -0
  101. package/.mindforge/audit/AUDIT-SCHEMA.md +451 -0
  102. package/.mindforge/ci/ci-config-schema.md +21 -0
  103. package/.mindforge/ci/ci-mode.md +179 -0
  104. package/.mindforge/ci/github-actions-adapter.md +224 -0
  105. package/.mindforge/ci/gitlab-ci-adapter.md +31 -0
  106. package/.mindforge/ci/jenkins-adapter.md +44 -0
  107. package/.mindforge/distribution/registry-client.md +166 -0
  108. package/.mindforge/distribution/registry-schema.md +96 -0
  109. package/.mindforge/distribution/skill-publisher.md +44 -0
  110. package/.mindforge/distribution/skill-validator.md +74 -0
  111. package/.mindforge/engine/compaction-protocol.md +182 -0
  112. package/.mindforge/engine/context-injector.md +128 -0
  113. package/.mindforge/engine/dependency-parser.md +113 -0
  114. package/.mindforge/engine/skills/conflict-resolver.md +69 -0
  115. package/.mindforge/engine/skills/loader.md +184 -0
  116. package/.mindforge/engine/skills/registry.md +98 -0
  117. package/.mindforge/engine/skills/versioning.md +75 -0
  118. package/.mindforge/engine/verification-pipeline.md +111 -0
  119. package/.mindforge/engine/wave-executor.md +235 -0
  120. package/.mindforge/governance/GOVERNANCE-CONFIG.md +17 -0
  121. package/.mindforge/governance/approval-workflow.md +37 -0
  122. package/.mindforge/governance/change-classifier.md +63 -0
  123. package/.mindforge/governance/compliance-gates.md +31 -0
  124. package/.mindforge/integrations/confluence.md +27 -0
  125. package/.mindforge/integrations/connection-manager.md +163 -0
  126. package/.mindforge/integrations/github.md +25 -0
  127. package/.mindforge/integrations/gitlab.md +13 -0
  128. package/.mindforge/integrations/jira.md +102 -0
  129. package/.mindforge/integrations/slack.md +41 -0
  130. package/.mindforge/intelligence/antipattern-detector.md +75 -0
  131. package/.mindforge/intelligence/difficulty-scorer.md +55 -0
  132. package/.mindforge/intelligence/health-engine.md +208 -0
  133. package/.mindforge/intelligence/skill-gap-analyser.md +40 -0
  134. package/.mindforge/intelligence/smart-compaction.md +71 -0
  135. package/.mindforge/metrics/METRICS-SCHEMA.md +42 -0
  136. package/.mindforge/metrics/quality-tracker.md +32 -0
  137. package/.mindforge/monorepo/cross-package-planner.md +114 -0
  138. package/.mindforge/monorepo/dependency-graph-builder.md +32 -0
  139. package/.mindforge/monorepo/workspace-detector.md +129 -0
  140. package/.mindforge/org/CONVENTIONS.md +62 -0
  141. package/.mindforge/org/ORG.md +51 -0
  142. package/.mindforge/org/SECURITY.md +50 -0
  143. package/.mindforge/org/TOOLS.md +53 -0
  144. package/.mindforge/org/integrations/INTEGRATIONS-CONFIG.md +58 -0
  145. package/.mindforge/org/skills/MANIFEST.md +38 -0
  146. package/.mindforge/personas/analyst.md +52 -0
  147. package/.mindforge/personas/architect.md +75 -0
  148. package/.mindforge/personas/debug-specialist.md +52 -0
  149. package/.mindforge/personas/developer.md +85 -0
  150. package/.mindforge/personas/overrides/README.md +85 -0
  151. package/.mindforge/personas/qa-engineer.md +61 -0
  152. package/.mindforge/personas/release-manager.md +76 -0
  153. package/.mindforge/personas/security-reviewer.md +91 -0
  154. package/.mindforge/personas/tech-writer.md +51 -0
  155. package/.mindforge/plugins/PLUGINS-MANIFEST.md +23 -0
  156. package/.mindforge/plugins/plugin-loader.md +93 -0
  157. package/.mindforge/plugins/plugin-registry.md +44 -0
  158. package/.mindforge/plugins/plugin-schema.md +68 -0
  159. package/.mindforge/pr-review/ai-reviewer.md +266 -0
  160. package/.mindforge/pr-review/finding-formatter.md +46 -0
  161. package/.mindforge/pr-review/review-prompt-templates.md +44 -0
  162. package/.mindforge/production/compatibility-layer.md +39 -0
  163. package/.mindforge/production/migration-engine.md +52 -0
  164. package/.mindforge/production/production-checklist.md +165 -0
  165. package/.mindforge/production/token-optimiser.md +68 -0
  166. package/.mindforge/skills/accessibility/SKILL.md +106 -0
  167. package/.mindforge/skills/api-design/SKILL.md +98 -0
  168. package/.mindforge/skills/code-quality/SKILL.md +88 -0
  169. package/.mindforge/skills/data-privacy/SKILL.md +126 -0
  170. package/.mindforge/skills/database-patterns/SKILL.md +192 -0
  171. package/.mindforge/skills/documentation/SKILL.md +91 -0
  172. package/.mindforge/skills/incident-response/SKILL.md +180 -0
  173. package/.mindforge/skills/performance/SKILL.md +120 -0
  174. package/.mindforge/skills/security-review/SKILL.md +83 -0
  175. package/.mindforge/skills/testing-standards/SKILL.md +97 -0
  176. package/.mindforge/team/TEAM-PROFILE.md +42 -0
  177. package/.mindforge/team/multi-handoff.md +23 -0
  178. package/.mindforge/team/profiles/README.md +13 -0
  179. package/.mindforge/team/session-merger.md +18 -0
  180. package/.planning/ARCHITECTURE.md +0 -0
  181. package/.planning/AUDIT.jsonl +0 -0
  182. package/.planning/HANDOFF.json +28 -0
  183. package/.planning/PROJECT.md +33 -0
  184. package/.planning/RELEASE-CHECKLIST.md +68 -0
  185. package/.planning/REQUIREMENTS.md +0 -0
  186. package/.planning/ROADMAP.md +0 -0
  187. package/.planning/STATE.md +31 -0
  188. package/.planning/approvals/.gitkeep +1 -0
  189. package/.planning/archive/.gitkeep +1 -0
  190. package/.planning/audit-archive/.gitkeep +1 -0
  191. package/.planning/decisions/.gitkeep +0 -0
  192. package/.planning/decisions/ADR-001-handoff-tracking.md +41 -0
  193. package/.planning/decisions/ADR-002-markdown-commands.md +46 -0
  194. package/.planning/decisions/ADR-003-skills-trigger-model.md +37 -0
  195. package/.planning/decisions/ADR-004-wave-parallelism-model.md +45 -0
  196. package/.planning/decisions/ADR-005-append-only-audit-log.md +51 -0
  197. package/.planning/decisions/ADR-006-tiered-skills-system.md +22 -0
  198. package/.planning/decisions/ADR-007-trigger-keyword-model.md +22 -0
  199. package/.planning/decisions/ADR-008-just-in-time-skill-loading.md +29 -0
  200. package/.planning/decisions/ADR-009-enterprise-integration-retry-policy.md +8 -0
  201. package/.planning/decisions/ADR-010-governance-tier-escalation.md +8 -0
  202. package/.planning/decisions/ADR-011-multi-developer-handoff-contract.md +8 -0
  203. package/.planning/decisions/ADR-012-intelligence-feedback-loops.md +19 -0
  204. package/.planning/decisions/ADR-013-mindforge-md-constitution.md +16 -0
  205. package/.planning/decisions/ADR-014-metrics-as-signals-not-evaluation.md +15 -0
  206. package/.planning/decisions/ADR-015-npm-based-skill-registry.md +26 -0
  207. package/.planning/decisions/ADR-016-ci-exit-code-0-on-timeout.md +27 -0
  208. package/.planning/decisions/ADR-017-sdk-localhost-only.md +28 -0
  209. package/.planning/decisions/ADR-018-installer-self-install-detection.md +15 -0
  210. package/.planning/decisions/ADR-019-self-update-scope-preservation.md +14 -0
  211. package/.planning/decisions/ADR-020-v1.0.0-stable-interface-contract.md +23 -0
  212. package/.planning/jira-sync.json +9 -0
  213. package/.planning/milestones/.gitkeep +1 -0
  214. package/.planning/phases/day1/REVIEW-DAY1.md +50 -0
  215. package/.planning/phases/day1/SECURITY-REVIEW-DAY1.md +15 -0
  216. package/.planning/phases/day2/REVIEW-DAY2.md +521 -0
  217. package/.planning/phases/day3/REVIEW-DAY3.md +234 -0
  218. package/.planning/slack-threads.json +6 -0
  219. package/CHANGELOG.md +175 -0
  220. package/LICENSE +21 -0
  221. package/MINDFORGE.md +76 -0
  222. package/README.md +182 -0
  223. package/RELEASENOTES.md +41 -0
  224. package/SECURITY.md +4 -0
  225. package/bin/install.js +120 -0
  226. package/bin/installer-core.js +292 -0
  227. package/bin/migrations/0.1.0-to-0.5.0.js +37 -0
  228. package/bin/migrations/0.5.0-to-0.6.0.js +17 -0
  229. package/bin/migrations/0.6.0-to-1.0.0.js +100 -0
  230. package/bin/migrations/migrate.js +151 -0
  231. package/bin/migrations/schema-versions.js +64 -0
  232. package/bin/updater/changelog-fetcher.js +62 -0
  233. package/bin/updater/self-update.js +169 -0
  234. package/bin/updater/version-comparator.js +68 -0
  235. package/bin/validate-config.js +92 -0
  236. package/bin/wizard/config-generator.js +112 -0
  237. package/bin/wizard/environment-detector.js +76 -0
  238. package/bin/wizard/setup-wizard.js +237 -0
  239. package/docs/Context/Master-Context.md +701 -0
  240. package/docs/architecture/README.md +35 -0
  241. package/docs/architecture/decision-records-index.md +26 -0
  242. package/docs/ci-cd-integration.md +30 -0
  243. package/docs/ci-quickstart.md +78 -0
  244. package/docs/commands-reference.md +11 -0
  245. package/docs/contributing/CONTRIBUTING.md +38 -0
  246. package/docs/contributing/plugin-authoring.md +50 -0
  247. package/docs/contributing/skill-authoring.md +41 -0
  248. package/docs/enterprise-setup.md +25 -0
  249. package/docs/faq.md +38 -0
  250. package/docs/getting-started.md +36 -0
  251. package/docs/governance-guide.md +23 -0
  252. package/docs/mindforge-md-reference.md +53 -0
  253. package/docs/monorepo-guide.md +26 -0
  254. package/docs/persona-customisation.md +56 -0
  255. package/docs/quick-verify.md +33 -0
  256. package/docs/reference/audit-events.md +53 -0
  257. package/docs/reference/commands.md +82 -0
  258. package/docs/reference/config-reference.md +64 -0
  259. package/docs/reference/sdk-api.md +48 -0
  260. package/docs/reference/skills-api.md +57 -0
  261. package/docs/release-checklist-guide.md +37 -0
  262. package/docs/requirements.md +29 -0
  263. package/docs/sdk-reference.md +27 -0
  264. package/docs/security/SECURITY.md +42 -0
  265. package/docs/security/penetration-test-results.md +31 -0
  266. package/docs/security/threat-model.md +142 -0
  267. package/docs/skills-authoring-guide.md +119 -0
  268. package/docs/skills-publishing-guide.md +21 -0
  269. package/docs/team-setup-guide.md +21 -0
  270. package/docs/troubleshooting.md +119 -0
  271. package/docs/tutorial.md +195 -0
  272. package/docs/upgrade.md +44 -0
  273. package/docs/user-guide.md +131 -0
  274. package/docs/usp-features.md +214 -0
  275. package/eslint.config.mjs +31 -0
  276. package/examples/starter-project/.planning/AUDIT.jsonl +1 -0
  277. package/examples/starter-project/.planning/HANDOFF.json +23 -0
  278. package/examples/starter-project/.planning/PROJECT.md +27 -0
  279. package/examples/starter-project/.planning/STATE.md +10 -0
  280. package/examples/starter-project/MINDFORGE.md +40 -0
  281. package/examples/starter-project/README.md +14 -0
  282. package/implementation-roadmap/day-1-imp/DAY1-HARDEN.md +823 -0
  283. package/implementation-roadmap/day-1-imp/DAY1-IMPLEMENT.md +2459 -0
  284. package/implementation-roadmap/day-1-imp/DAY1-REVIEW.md +288 -0
  285. package/implementation-roadmap/day-2-imp/DAY2-HARDEN.md +954 -0
  286. package/implementation-roadmap/day-2-imp/DAY2-IMPLEMENT.md +2347 -0
  287. package/implementation-roadmap/day-2-imp/DAY2-REVIEW.md +422 -0
  288. package/implementation-roadmap/day-3-imp/DAY3-HARDEN.md +870 -0
  289. package/implementation-roadmap/day-3-imp/DAY3-IMPLEMENT.md +2798 -0
  290. package/implementation-roadmap/day-3-imp/DAY3-REVIEW.md +484 -0
  291. package/implementation-roadmap/day-4-imp/DAY4-HARDEN.md +1087 -0
  292. package/implementation-roadmap/day-4-imp/DAY4-IMPLEMENT.md +2874 -0
  293. package/implementation-roadmap/day-4-imp/DAY4-REVIEW.md +386 -0
  294. package/implementation-roadmap/day-5-imp/DAY5-HARDEN.md +1078 -0
  295. package/implementation-roadmap/day-5-imp/DAY5-IMPLEMENT.md +3151 -0
  296. package/implementation-roadmap/day-5-imp/DAY5-REVIEW.md +345 -0
  297. package/implementation-roadmap/day-6-imp/DAY6-COMPLETE.md +3919 -0
  298. package/implementation-roadmap/day-7-imp-prod/DAY7-PRODUCTION-FINAL.md +4513 -0
  299. package/package.json +31 -0
  300. package/sdk/README.md +69 -0
  301. package/sdk/eslint.config.mjs +34 -0
  302. package/sdk/package-lock.json +1507 -0
  303. package/sdk/package.json +30 -0
  304. package/sdk/src/client.ts +133 -0
  305. package/sdk/src/commands.ts +63 -0
  306. package/sdk/src/events.ts +166 -0
  307. package/sdk/src/index.ts +22 -0
  308. package/sdk/src/types.ts +87 -0
  309. package/sdk/tsconfig.json +13 -0
  310. package/tests/audit.test.js +206 -0
  311. package/tests/ci-mode.test.js +162 -0
  312. package/tests/compaction.test.js +161 -0
  313. package/tests/distribution.test.js +205 -0
  314. package/tests/e2e.test.js +618 -0
  315. package/tests/governance.test.js +130 -0
  316. package/tests/install.test.js +209 -0
  317. package/tests/integrations.test.js +128 -0
  318. package/tests/intelligence.test.js +117 -0
  319. package/tests/metrics.test.js +96 -0
  320. package/tests/migration.test.js +309 -0
  321. package/tests/production.test.js +416 -0
  322. package/tests/sdk.test.js +200 -0
  323. package/tests/skills-platform.test.js +403 -0
  324. package/tests/wave-engine.test.js +338 -0
@@ -0,0 +1,954 @@
1
+ # MindForge — Day 2 Hardening Prompt
2
+ # Branch: `feat/mindforge-wave-engine`
3
+ # Run this AFTER DAY2-REVIEW.md is APPROVED
4
+
5
+ ---
6
+
7
+ ## CONTEXT
8
+
9
+ You are performing **Day 2 Hardening** of the MindForge wave execution engine,
10
+ audit pipeline, compaction protocol, and four new commands.
11
+
12
+ Activate the **`architect.md`** persona. Think in failure modes and edge cases.
13
+ The goal is not new features — it is making every Day 2 component production-grade:
14
+ resilient, unambiguous, and impossible to misuse.
15
+
16
+ Confirm all review findings (BLOCKING + MAJOR) are fixed before starting:
17
+ ```bash
18
+ git log --oneline | head -20 # look for review fix commits
19
+ node tests/install.test.js && node tests/wave-engine.test.js &&
20
+ node tests/audit.test.js && node tests/compaction.test.js
21
+ # all must pass
22
+ ```
23
+
24
+ ---
25
+
26
+ ## HARDEN 1 — Fix all review findings
27
+
28
+ For every BLOCKING and MAJOR finding from DAY2-REVIEW.md:
29
+ 1. Read the finding and recommendation precisely
30
+ 2. Make exactly the change described
31
+ 3. Commit: `fix(day2-review): [finding title]`
32
+
33
+ Do not combine multiple findings into one commit — one fix per commit.
34
+
35
+ After all fixes, re-run the full test suite to confirm no regressions.
36
+
37
+ ---
38
+
39
+ ## HARDEN 2 — Wave executor: add explicit failure handling paths
40
+
41
+ The current wave executor specifies the happy path well. Harden every failure path.
42
+
43
+ Add a **"Failure Handling" section** to `wave-executor.md`:
44
+
45
+ ```markdown
46
+ ## Failure handling
47
+
48
+ ### Task verify failure (mid-wave)
49
+
50
+ When a task's `<verify>` step fails:
51
+
52
+ 1. **Stop the task immediately.** Do not attempt a second run automatically.
53
+ 2. **Write the SUMMARY file** with status `Failed ❌` and the full verify output.
54
+ 3. **Write a `task_failed` AUDIT entry** (see AUDIT-SCHEMA.md).
55
+ 4. **Stop the entire wave.** Other tasks in this wave that have not yet started:
56
+ do not start them. Tasks already running in parallel: let them complete
57
+ naturally, but do not start the next wave regardless of their outcome.
58
+ 5. **Report to the orchestrator:**
59
+ ```
60
+ ━━━ Wave [W] STOPPED — Task Failure ━━━━━━━━━━━━━━━━━━━━━━
61
+ Failed task : Plan [N]-[M]: [task name]
62
+ Verify output:
63
+ [full verify output]
64
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
65
+ ```
66
+ 6. **Ask the user:**
67
+ ```
68
+ Options:
69
+ 1. Spawn debug agent to diagnose the failure
70
+ 2. Show me the failing code and I'll fix it manually
71
+ 3. Skip this task and continue the wave (not recommended)
72
+ 4. Abort the entire phase
73
+
74
+ Choose 1, 2, 3, or 4:
75
+ ```
76
+ 7. If user chooses 1: invoke `/mindforge:debug` with the failure context pre-loaded.
77
+ 8. If user chooses 3 (skip): write a `quality_gate_failed` AUDIT entry with
78
+ `"gate": "verify_skipped_by_user"` and continue. This is tracked.
79
+ 9. If user chooses 4: update STATE.md with `status: Phase [N] aborted` and stop.
80
+
81
+ ### Test suite failure (between waves)
82
+
83
+ When the test suite fails after a wave completes:
84
+
85
+ 1. **Identify the failing tests** — capture the full test output.
86
+ 2. **Identify the likely causal commit:**
87
+ ```bash
88
+ git log --oneline -[number of tasks in this wave]
89
+ ```
90
+ 3. **Report specifically:**
91
+ ```
92
+ ━━━ Test Suite Failure After Wave [W] ━━━━━━━━━━━━━━━━━━━━━
93
+ [N] tests failing.
94
+
95
+ Likely cause: [commit sha] — [commit message]
96
+ Failing tests:
97
+ - [test name]: [error]
98
+ - [test name]: [error]
99
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
100
+ ```
101
+ 4. **Write a `quality_gate_failed` AUDIT entry.**
102
+ 5. **Do not start the next wave.** This is absolute — no exceptions.
103
+ 6. **Ask the user:**
104
+ ```
105
+ Options:
106
+ 1. Debug the failing tests now
107
+ 2. Revert the last wave's commits and re-plan
108
+ 3. I'll fix the tests manually — notify me when done
109
+ ```
110
+
111
+ ### Subagent hang (no SUMMARY file after expected duration)
112
+
113
+ When a subagent has been running for an unexpectedly long time:
114
+ (Heuristic: if a task with < 5 files has no SUMMARY after 30 minutes of session time)
115
+
116
+ 1. Alert the user: "Task [N]-[M] appears to be taking longer than expected.
117
+ Check if the subagent is still running or has stalled."
118
+ 2. Provide the option to: wait longer | restart the task | skip the task.
119
+ 3. Never silently let a wave stall indefinitely.
120
+
121
+ ### Missing PLAN file detected at runtime
122
+
123
+ When execute-phase discovers a PLAN file referenced in the dependency graph is missing:
124
+
125
+ 1. Stop immediately.
126
+ 2. Report: "PLAN-[N]-[M].md was referenced but does not exist.
127
+ Run /mindforge:plan-phase [N] to regenerate the missing plan."
128
+ 3. Do not continue with partial plan execution.
129
+ ```
130
+
131
+ **Commit:**
132
+ ```bash
133
+ git add .mindforge/engine/wave-executor.md
134
+ git commit -m "harden(wave-engine): add explicit failure handling for all failure paths"
135
+ ```
136
+
137
+ ---
138
+
139
+ ## HARDEN 3 — Dependency parser: add self-reference and empty-graph guards
140
+
141
+ Add these cases to `dependency-parser.md` under Step 3 (Validate the graph):
142
+
143
+ ```markdown
144
+ ### Additional validation cases
145
+
146
+ **Self-referencing plan:**
147
+ If any plan lists its own ID in `<dependencies>` (e.g., Plan 03 depends on 03):
148
+ ```
149
+ Error: Plan [N]-[M] declares a dependency on itself.
150
+ This is impossible to satisfy. Remove [M] from its own <dependencies> list.
151
+ ```
152
+
153
+ **Empty plan directory:**
154
+ If the phase directory contains zero PLAN files:
155
+ ```
156
+ Error: No PLAN files found in .planning/phases/[N]/.
157
+ Run /mindforge:plan-phase [N] to create plans before executing.
158
+ ```
159
+ Do not return an empty graph — return this error explicitly.
160
+
161
+ **Dependency on a completed phase's plans:**
162
+ If a PLAN in Phase 3 declares a dependency on a PLAN in Phase 2:
163
+ This is valid only if Phase 2 is complete (all SuMMARY files exist and passing).
164
+ If Phase 2 is not complete: flag as a warning, not an error.
165
+ Allow execution to proceed but note the cross-phase dependency.
166
+
167
+ **All plans in the same wave touch the same file:**
168
+ If all plans in a computed wave touch at least one common file, the wave
169
+ cannot run in parallel without conflicts. In this case:
170
+ Sort the plans into sequential execution order within the wave.
171
+ Notify: "Wave [W]: file conflicts detected — executing plans sequentially."
172
+ This is suboptimal but safe. The user should redesign plans to avoid this.
173
+ ```
174
+
175
+ **Commit:**
176
+ ```bash
177
+ git add .mindforge/engine/dependency-parser.md
178
+ git commit -m "harden(dependency-parser): add self-reference, empty graph, and cross-phase guards"
179
+ ```
180
+
181
+ ---
182
+
183
+ ## HARDEN 4 — Context injector: add path traversal guard and SECURITY.md validation
184
+
185
+ Add to `context-injector.md`:
186
+
187
+ ```markdown
188
+ ## Security guards (run before building any context package)
189
+
190
+ ### Path traversal guard
191
+ Before reading any file referenced in a PLAN's `<context>` field (ADR files,
192
+ skill paths, or any other referenced file):
193
+
194
+ 1. Resolve the file path to an absolute path.
195
+ 2. Verify the absolute path starts with the project root directory.
196
+ 3. If it does not: STOP. Report:
197
+ "Security: Plan [N]-[M] references a file outside the project root: [path]
198
+ This may indicate a path traversal attempt. Review the plan before continuing."
199
+ 4. Never read files outside the project root directory, regardless of the reference.
200
+
201
+ ### SECURITY.md validation
202
+ Before injecting SECURITY.md into a subagent context:
203
+
204
+ 1. Check if SECURITY.md contains placeholder text.
205
+ Look for any of: `[ORG NAME]`, `[specify]`, `[your-org]`, `TODO`, `[placeholder]`
206
+ 2. If placeholder text is found: warn the user:
207
+ "Warning: .mindforge/org/SECURITY.md still contains placeholder text.
208
+ Subagents will receive incomplete security guidance.
209
+ Fill in SECURITY.md before running phases with security-sensitive tasks."
210
+ 3. Allow the user to proceed or fill in SECURITY.md first.
211
+ 4. Log a AUDIT entry: `{"event":"security_config_warning","detail":"SECURITY.md has placeholder text"}`
212
+
213
+ ### Context size enforcement
214
+ Before injecting context to a subagent:
215
+
216
+ 1. Estimate total token count (rough estimate: characters / 4)
217
+ 2. If estimated tokens > 30,000:
218
+ a. Log which files are contributing most
219
+ b. Try summarising ARCHITECTURE.md to relevant sections only
220
+ c. If still > 30,000 after summarisation: warn the user and ask to proceed
221
+ 3. Never silently inject oversized context — the budget exists for a reason.
222
+ ```
223
+
224
+ **Commit:**
225
+ ```bash
226
+ git add .mindforge/engine/context-injector.md
227
+ git commit -m "harden(context-injector): add path traversal guard, SECURITY.md validation, size enforcement"
228
+ ```
229
+
230
+ ---
231
+
232
+ ## HARDEN 5 — Compaction protocol: add the missing edge cases
233
+
234
+ Add to `compaction-protocol.md`:
235
+
236
+ ```markdown
237
+ ## Edge case handling
238
+
239
+ ### Compaction during active wave execution
240
+ If compaction is triggered while a wave is executing (subagents are running):
241
+
242
+ 1. **Do not interrupt running subagents.** Let them complete their current task.
243
+ 2. When the running subagent writes its SUMMARY file: trigger compaction immediately
244
+ after (before starting the next subagent in the wave or the next wave).
245
+ 3. Never compact mid-task. Always compact at task boundaries.
246
+
247
+ ### WIP commit and pre-commit hooks
248
+ Compaction may need to commit uncommitted work-in-progress. If pre-commit hooks
249
+ (lint, type check, test) are configured, a WIP commit might fail these hooks.
250
+
251
+ Resolution:
252
+ ```bash
253
+ git add -A
254
+ git commit --no-verify -m "wip(phase-[N]-plan-[M]): compaction checkpoint — [description]"
255
+ ```
256
+
257
+ Use `--no-verify` for compaction commits ONLY. Document this in STATE.md:
258
+ ```
259
+ [timestamp]: WIP commit at compaction point (hooks bypassed per compaction protocol)
260
+ ```
261
+ This is acceptable and tracked. The bypassed hooks will be enforced on the
262
+ next real task commit.
263
+
264
+ ### Staleness detection
265
+ When a new session reads HANDOFF.json:
266
+
267
+ 1. Check `updated_at` timestamp.
268
+ 2. If older than 48 hours: warn the user:
269
+ "HANDOFF.json is [N] days old. Context may have changed significantly.
270
+ Recent git history will be compared against recorded commits."
271
+ 3. Compare `recent_commits` in HANDOFF.json against `git log`:
272
+ - If commits match: safe to continue from HANDOFF state.
273
+ - If git log shows commits not in HANDOFF: "These commits happened since
274
+ the last session was saved. Review them before continuing:"
275
+ [list the new commits]
276
+ 4. Let the user decide: continue from HANDOFF state | run fresh state detection.
277
+
278
+ ### Multiple session risk
279
+ HANDOFF.json is a shared file. If two agents read it simultaneously:
280
+
281
+ 1. Note: this risk exists but is mitigated by the single-user nature of
282
+ Claude Code and Antigravity sessions.
283
+ 2. In a team environment where multiple engineers might share the same repo
284
+ and both run MindForge: the last writer wins for HANDOFF.json.
285
+ 3. Mitigation: each team member should use their own feature branch.
286
+ HANDOFF.json on different branches does not conflict.
287
+ 4. Future: Day 4 will introduce per-developer HANDOFF.json naming for teams.
288
+
289
+ ### Compaction when near 85%+ context
290
+ If compaction was not triggered at 70% and context is now at 85%+:
291
+
292
+ 1. This is an error condition — the 70% trigger was missed.
293
+ 2. Emergency compact immediately: skip the "summarise last 20 tool calls" step
294
+ (there may not be enough context to do it well).
295
+ 3. Write HANDOFF.json from whatever state is available.
296
+ 4. Restart immediately with the minimum viable context.
297
+ 5. Add an AUDIT entry with `"event":"compaction_late"` to flag this for review.
298
+ ```
299
+
300
+ **Commit:**
301
+ ```bash
302
+ git add .mindforge/engine/compaction-protocol.md
303
+ git commit -m "harden(compaction): add wave-active handling, WIP commit protocol, staleness detection"
304
+ ```
305
+
306
+ ---
307
+
308
+ ## HARDEN 6 — Command hardening: close the gaps found in review
309
+
310
+ ### Update `/mindforge:next`
311
+
312
+ Add to the command file:
313
+
314
+ ```markdown
315
+ ## HANDOFF.json priority rule
316
+ Check HANDOFF.json BEFORE running the decision tree.
317
+
318
+ If HANDOFF.json exists AND `updated_at` is within 48 hours AND `next_task` is not null:
319
+ Present the HANDOFF state first. Let the user choose to continue from it.
320
+ Only run the decision tree if the user says no or HANDOFF.json is stale.
321
+
322
+ ## Partial phase execution handling
323
+ In the decision tree step "Do SUMMARY files exist for all plans?":
324
+
325
+ Do not treat this as binary. Check individually:
326
+
327
+ ```
328
+ PLAN-[N]-01.md exists? SUMMARY-[N]-01.md exists?
329
+ PLAN-[N]-02.md exists? SUMMARY-[N]-02.md exists?
330
+ PLAN-[N]-03.md exists? SUMMARY-[N]-03.md exists?
331
+ ```
332
+
333
+ If some SUMMARY files exist and some don't: this is a partially-executed phase.
334
+ Report: "Phase [N] is partially executed: plans [X, Y] are done, [Z] is not."
335
+ Ask: "Resume execution from Plan [Z]? (yes/no)"
336
+ Do not restart the entire phase — resume from the first missing SUMMARY.
337
+ ```
338
+
339
+ ### Update `/mindforge:quick`
340
+
341
+ Add to the command file:
342
+
343
+ ```markdown
344
+ ## Sequential quick task numbering
345
+ To determine the next quick task number:
346
+ 1. List `.planning/quick/` directory.
347
+ 2. Find all directories matching `[0-9][0-9][0-9]-*`.
348
+ 3. Extract the numeric prefix, find the maximum, and add 1.
349
+ 4. If `.planning/quick/` does not exist: create it. Start at 001.
350
+ 5. Example: existing dirs `001-fix-login`, `002-update-readme` → next is `003`.
351
+
352
+ This is deterministic regardless of session.
353
+
354
+ ## Auto-trigger security review on quick tasks
355
+ Before executing ANY quick task, check the task description and files for security keywords:
356
+ [auth, authentication, login, password, token, JWT, session, payment, PII, upload, credential, secret, key]
357
+
358
+ If any keyword matches: automatically load `security-review/SKILL.md` and activate
359
+ `security-reviewer.md` persona for the implementation step.
360
+ This applies even without the `--full` flag.
361
+ Security review is never optional on security-sensitive quick tasks.
362
+
363
+ ## Linting always runs
364
+ Regardless of flags, after every quick task execution:
365
+ 1. Run the project's linter (from CONVENTIONS.md — check which linter applies)
366
+ 2. If lint errors found: fix them before committing.
367
+ 3. Linting is not part of `--full` — it is always part of quick.
368
+ The `--full` flag adds: full test suite + type checking + security scan.
369
+ ```
370
+
371
+ ### Update `/mindforge:status`
372
+
373
+ Add to the command file:
374
+
375
+ ```markdown
376
+ ## Handling empty/missing data sources gracefully
377
+
378
+ ### Empty AUDIT.jsonl
379
+ If AUDIT.jsonl is empty or does not exist:
380
+ ```
381
+ Recent Activity
382
+ ───────────────────────────────────────────────────────
383
+ No activity logged yet. Activity will appear here
384
+ after running /mindforge:execute-phase.
385
+ ```
386
+ Never crash on empty AUDIT.jsonl.
387
+
388
+ ### Missing VERIFICATION.md (phase in progress)
389
+ For any phase without a VERIFICATION.md:
390
+ Show progress bar based on SUMMARY files only.
391
+ Label it "In progress" not "0% verified".
392
+
393
+ ### Phase progress calculation (correction from review)
394
+ Count ONLY SUMMARY files that contain `Status: Completed ✅` or `Status\nCompleted`.
395
+ Do NOT count SUMMARY files with `Status: Failed ❌`.
396
+ Failed tasks are not progress.
397
+
398
+ ### Status command performance
399
+ The status command reads many files. For large projects:
400
+ 1. Read AUDIT.jsonl for "recent activity" but only the LAST 500 bytes
401
+ (recent entries are at the end — no need to read the entire file)
402
+ ```
403
+ tail -c 500 .planning/AUDIT.jsonl | [parse last complete JSON objects]
404
+ ```
405
+ 2. For REQUIREMENTS.md requirement counting: count lines starting with `| FR-`
406
+ rather than parsing the full document.
407
+ These optimisations keep the status command fast even on mature projects.
408
+ ```
409
+
410
+ **Commit:**
411
+ ```bash
412
+ git add .claude/commands/mindforge/next.md .agent/mindforge/next.md \
413
+ .claude/commands/mindforge/quick.md .agent/mindforge/quick.md \
414
+ .claude/commands/mindforge/status.md .agent/mindforge/status.md
415
+ git commit -m "harden(commands): close logic gaps in next, quick, and status commands"
416
+ ```
417
+
418
+ ---
419
+
420
+ ## HARDEN 7 — Add missing test coverage
421
+
422
+ Add the missing tests identified in the review.
423
+
424
+ ### Add to `tests/wave-engine.test.js`:
425
+
426
+ ```javascript
427
+ // Add these tests after the existing ones:
428
+
429
+ console.log('\nAdditional edge cases:');
430
+
431
+ test('handles empty graph (zero plans)', () => {
432
+ const waves = groupIntoWaves({});
433
+ assert.deepStrictEqual(waves, []);
434
+ });
435
+
436
+ test('detects self-referencing dependency (plan depends on itself)', () => {
437
+ const graph = { '01': { dependsOn: ['01'] } };
438
+ assert.strictEqual(hasCircularDependency(graph), true);
439
+ });
440
+
441
+ test('three plans all touching the same file — all conflict', () => {
442
+ const plans = [
443
+ { id: '01', files: ['src/shared.ts'] },
444
+ { id: '02', files: ['src/shared.ts'] },
445
+ { id: '03', files: ['src/shared.ts'] },
446
+ ];
447
+ const conflicts = findFileConflicts(plans);
448
+ assert.ok(conflicts.length >= 2, `Expected >= 2 conflicts, got ${conflicts.length}`);
449
+ });
450
+
451
+ test('6-plan complex graph groups correctly', () => {
452
+ const graph = {
453
+ '01': { dependsOn: [] },
454
+ '02': { dependsOn: [] },
455
+ '03': { dependsOn: [] },
456
+ '04': { dependsOn: ['01', '02'] },
457
+ '05': { dependsOn: ['02', '03'] },
458
+ '06': { dependsOn: ['04', '05'] },
459
+ };
460
+ const waves = groupIntoWaves(graph);
461
+ assert.strictEqual(waves.length, 3);
462
+ assert.deepStrictEqual(waves[0].sort(), ['01', '02', '03']);
463
+ assert.deepStrictEqual(waves[1].sort(), ['04', '05']);
464
+ assert.deepStrictEqual(waves[2], ['06']);
465
+ });
466
+
467
+ test('single linear chain of 4 plans → 4 waves', () => {
468
+ const graph = {
469
+ '01': { dependsOn: [] },
470
+ '02': { dependsOn: ['01'] },
471
+ '03': { dependsOn: ['02'] },
472
+ '04': { dependsOn: ['03'] },
473
+ };
474
+ const waves = groupIntoWaves(graph);
475
+ assert.strictEqual(waves.length, 4);
476
+ waves.forEach((wave, i) => {
477
+ const expectedId = String(i + 1).padStart(2, '0');
478
+ assert.deepStrictEqual(wave, [expectedId]);
479
+ });
480
+ });
481
+
482
+ test('wave executor stops on first failure — does not cascade', () => {
483
+ // Simulates: Wave 1 has 3 tasks. Task 02 fails.
484
+ // Expected: tasks 01 and 03 may run, but Wave 2 must NOT start.
485
+ const executionLog = [];
486
+
487
+ function simulateWaveExecution(graph, failingPlan) {
488
+ const waves = groupIntoWaves(graph);
489
+ let phaseFailed = false;
490
+
491
+ for (const wave of waves) {
492
+ if (phaseFailed) break; // critical: wave 2 must not start after failure
493
+ for (const planId of wave) {
494
+ if (planId === failingPlan) {
495
+ executionLog.push({ plan: planId, status: 'failed' });
496
+ phaseFailed = true;
497
+ } else if (!phaseFailed) {
498
+ executionLog.push({ plan: planId, status: 'completed' });
499
+ }
500
+ }
501
+ }
502
+ return { phaseFailed, executionLog };
503
+ }
504
+
505
+ const graph = {
506
+ '01': { dependsOn: [] },
507
+ '02': { dependsOn: [] }, // this one will fail
508
+ '03': { dependsOn: [] },
509
+ '04': { dependsOn: ['01', '03'] }, // must NOT execute
510
+ };
511
+
512
+ const result = simulateWaveExecution(graph, '02');
513
+ assert.strictEqual(result.phaseFailed, true);
514
+ // Plan 04 must not appear in the execution log
515
+ const plan04Executed = result.executionLog.some(e => e.plan === '04');
516
+ assert.strictEqual(plan04Executed, false, 'Plan 04 should not execute after wave failure');
517
+ });
518
+ ```
519
+
520
+ ### Add to `tests/audit.test.js`:
521
+
522
+ ```javascript
523
+ // Add after existing tests:
524
+
525
+ console.log('\nAdditional audit tests:');
526
+
527
+ test('validates security_finding event type', () => {
528
+ const entry = {
529
+ id: '550e8400-e29b-41d4-a716-446655440002',
530
+ timestamp: new Date().toISOString(),
531
+ event: 'security_finding',
532
+ agent: 'mindforge-security-reviewer',
533
+ phase: 1,
534
+ session_id: 'sess_test',
535
+ severity: 'HIGH',
536
+ owasp_category: 'A03:Injection',
537
+ finding: 'SQL query built by string concatenation',
538
+ file: 'src/api/search.ts',
539
+ line: 42,
540
+ remediated: false
541
+ };
542
+ assert.doesNotThrow(() => validateAuditEntry(entry));
543
+ assert.strictEqual(entry.event, 'security_finding');
544
+ });
545
+
546
+ test('validates context_compaction event type', () => {
547
+ const entry = {
548
+ id: '550e8400-e29b-41d4-a716-446655440003',
549
+ timestamp: new Date().toISOString(),
550
+ event: 'context_compaction',
551
+ agent: 'mindforge-orchestrator',
552
+ phase: 2,
553
+ plan: '03',
554
+ session_id: 'sess_test',
555
+ context_usage_pct: 72,
556
+ handoff_written: true
557
+ };
558
+ assert.doesNotThrow(() => validateAuditEntry(entry));
559
+ });
560
+
561
+ test('rejects entry with malformed UUID', () => {
562
+ const entry = {
563
+ id: 'not-a-uuid',
564
+ timestamp: new Date().toISOString(),
565
+ event: 'task_completed',
566
+ agent: 'test',
567
+ session_id: 'sess_test'
568
+ };
569
+ assert.throws(() => validateAuditEntry(entry), /Invalid UUID/);
570
+ });
571
+
572
+ test('AUDIT.jsonl contains no secrets', () => {
573
+ const content = fs.readFileSync('.planning/AUDIT.jsonl', 'utf8');
574
+ const secretPatterns = [
575
+ /password\s*["']?\s*:\s*["'][^"']{6,}/i,
576
+ /sk-[a-zA-Z0-9]{20,}/,
577
+ /-----BEGIN.*KEY-----/,
578
+ ];
579
+ secretPatterns.forEach(pattern => {
580
+ assert.ok(!pattern.test(content), `Potential secret found in AUDIT.jsonl`);
581
+ });
582
+ });
583
+ ```
584
+
585
+ ### Add to `tests/compaction.test.js`:
586
+
587
+ ```javascript
588
+ // Add after existing tests:
589
+
590
+ console.log('\nAdditional compaction tests:');
591
+
592
+ test('HANDOFF.json has recent_commits field', () => {
593
+ const obj = JSON.parse(fs.readFileSync('.planning/HANDOFF.json', 'utf8'));
594
+ assert.ok('recent_commits' in obj, 'Missing recent_commits field');
595
+ assert.ok(Array.isArray(obj.recent_commits), 'recent_commits must be an array');
596
+ });
597
+
598
+ test('HANDOFF.json has recent_files field', () => {
599
+ const obj = JSON.parse(fs.readFileSync('.planning/HANDOFF.json', 'utf8'));
600
+ assert.ok('recent_files' in obj, 'Missing recent_files field');
601
+ assert.ok(Array.isArray(obj.recent_files), 'recent_files must be an array');
602
+ });
603
+
604
+ test('compaction-protocol.md covers WIP commit with --no-verify', () => {
605
+ const content = fs.readFileSync('.mindforge/engine/compaction-protocol.md', 'utf8');
606
+ assert.ok(
607
+ content.includes('--no-verify') || content.includes('no-verify'),
608
+ 'Should mention --no-verify for WIP commits that bypass hooks'
609
+ );
610
+ });
611
+
612
+ test('compaction-protocol.md covers staleness detection', () => {
613
+ const content = fs.readFileSync('.mindforge/engine/compaction-protocol.md', 'utf8');
614
+ assert.ok(
615
+ content.includes('48 hours') || content.includes('staleness') || content.includes('stale'),
616
+ 'Should cover HANDOFF.json staleness detection'
617
+ );
618
+ });
619
+
620
+ test('compaction-protocol.md mentions 85% emergency compaction', () => {
621
+ const content = fs.readFileSync('.mindforge/engine/compaction-protocol.md', 'utf8');
622
+ assert.ok(
623
+ content.includes('85%') || content.includes('emergency'),
624
+ 'Should cover emergency compaction when 85%+ context is reached'
625
+ );
626
+ });
627
+ ```
628
+
629
+ **Commit:**
630
+ ```bash
631
+ git add tests/
632
+ git commit -m "test(day2): add missing edge case tests from hardening review"
633
+ ```
634
+
635
+ ---
636
+
637
+ ## HARDEN 8 — Write ADR-004 and ADR-005 for Day 2 decisions
638
+
639
+ Two significant architectural decisions were made in Day 2 that need ADRs.
640
+
641
+ ### `.planning/decisions/ADR-004-wave-parallelism-model.md`
642
+
643
+ ```markdown
644
+ # ADR-004: Wave-based parallel execution over full parallelism
645
+
646
+ **Status:** Accepted
647
+ **Date:** [today]
648
+ **Deciders:** MindForge core team
649
+
650
+ ## Context
651
+ When executing multiple tasks in a phase, we can choose:
652
+ A) Run all tasks simultaneously (maximum parallelism)
653
+ B) Run tasks in dependency-ordered waves (wave parallelism — chosen)
654
+ C) Run tasks sequentially (no parallelism)
655
+
656
+ ## Decision
657
+ Wave-based parallel execution. Tasks within a wave run in parallel.
658
+ Waves execute sequentially.
659
+
660
+ ## Options considered
661
+
662
+ ### Option A — Full parallelism
663
+ Pros: Maximum speed
664
+ Cons: Cannot handle dependencies safely. If Plan 03 depends on Plan 01's output
665
+ and both run simultaneously, Plan 03 reads stale data. Produces corrupt output.
666
+
667
+ ### Option B — Wave parallelism (chosen)
668
+ Pros: Safely parallel within dependency constraints. Significantly faster than
669
+ sequential. Dependency correctness is guaranteed by wave ordering.
670
+ Cons: Some tasks that could theoretically run in parallel must wait for their
671
+ dependency wave to complete.
672
+
673
+ ### Option C — Sequential
674
+ Pros: Simplest to implement and reason about.
675
+ Cons: Discards the primary quality advantage of parallel subagents — isolated
676
+ 200K token contexts per task. In sequential mode, the orchestrator's context
677
+ fills up across tasks, degrading output quality over time.
678
+
679
+ ## Rationale
680
+ Wave parallelism gives the correctness of sequential execution (dependency order
681
+ respected) with the quality benefits of parallel isolation (each task gets a
682
+ fresh 200K context). This is the optimal tradeoff.
683
+
684
+ ## Consequences
685
+ - Plan authors must declare dependencies accurately — incorrect dependencies
686
+ can cause parallel tasks to conflict.
687
+ - The dependency parser must catch cycles and conflicts before execution starts.
688
+ - A small planning overhead (building the wave graph) is incurred per phase.
689
+ ```
690
+
691
+ ### `.planning/decisions/ADR-005-append-only-audit-log.md`
692
+
693
+ ```markdown
694
+ # ADR-005: Append-only JSONL audit log over structured database
695
+
696
+ **Status:** Accepted
697
+ **Date:** [today]
698
+ **Deciders:** MindForge core team
699
+
700
+ ## Context
701
+ MindForge needs an audit trail of agent actions. The storage format choices are:
702
+ A) Append-only JSONL file (chosen)
703
+ B) SQLite database
704
+ C) In-memory log (written to JSON on session end)
705
+
706
+ ## Decision
707
+ Append-only JSONL file: `.planning/AUDIT.jsonl`
708
+
709
+ ## Options considered
710
+
711
+ ### Option A — Append-only JSONL (chosen)
712
+ Pros:
713
+ - Zero dependencies (no SQLite driver needed)
714
+ - Readable with standard Unix tools (grep, jq, tail)
715
+ - Git-trackable — history of history
716
+ - Tamper-evident via git (any deletion or modification is visible in `git diff`)
717
+ - Works identically across all platforms and environments
718
+
719
+ Cons:
720
+ - No query language — filtering requires grep/jq
721
+ - File grows unboundedly (mitigated by archiving strategy)
722
+ - No transactions — a crash mid-write could produce a partial line
723
+
724
+ ### Option B — SQLite
725
+ Pros: Full SQL query capability, transactional writes
726
+ Cons: Binary file — not readable without tooling, not meaningfully git-diffable,
727
+ adds a native dependency, harder to inspect in CI/CD environments
728
+
729
+ ### Option C — In-memory log
730
+ Pros: No I/O overhead during session
731
+ Cons: Lost entirely if session crashes mid-execution — exactly when the audit log
732
+ is most needed.
733
+
734
+ ## Rationale
735
+ For a framework targeting solo developers and small teams, readability and
736
+ zero-dependency simplicity outweigh query sophistication. The primary audit use
737
+ case is "what happened in this phase?" which grep handles well.
738
+
739
+ ## Consequences
740
+ - A partial-line recovery tool should be built in a future hardening pass.
741
+ (Run `python3 -c "import sys,json;[print(l.strip()) for l in sys.stdin if json.loads(l)]"
742
+ to filter clean lines from a corrupted AUDIT.jsonl)
743
+ - An archiving strategy (rotate after 10,000 lines) will be added in Day 4.
744
+ - The `status` command reads AUDIT.jsonl from the tail for performance.
745
+ ```
746
+
747
+ **Commit:**
748
+ ```bash
749
+ git add .planning/decisions/
750
+ git commit -m "docs(adr): add ADR-004 wave parallelism, ADR-005 append-only audit log"
751
+ ```
752
+
753
+ ---
754
+
755
+ ## HARDEN 9 — Run the complete test battery
756
+
757
+ Run every test. All must pass before pushing.
758
+
759
+ ```bash
760
+ echo "=== Day 1 Tests ===" && node tests/install.test.js
761
+ echo "=== Wave Engine ===" && node tests/wave-engine.test.js
762
+ echo "=== Audit System ===" && node tests/audit.test.js
763
+ echo "=== Compaction ===" && node tests/compaction.test.js
764
+ ```
765
+
766
+ Expected output per suite: "All tests passed."
767
+
768
+ If any test fails: fix the source, not the test. Tests describe requirements.
769
+
770
+ ---
771
+
772
+ ## HARDEN 10 — Update README.md for Day 2 features
773
+
774
+ Add a new section to README.md documenting Day 2 capabilities:
775
+
776
+ ```markdown
777
+ ## How the wave engine works
778
+
779
+ MindForge's execution engine is not sequential. It analyses task dependencies and
780
+ runs independent tasks in parallel — each with its own isolated 200K-token context.
781
+
782
+ ```
783
+ /mindforge:plan-phase 1
784
+ → Creates 5 task plans with dependency declarations
785
+
786
+ /mindforge:execute-phase 1
787
+ → Parser builds dependency graph
788
+ → Groups into waves: [01,02] → [03,04] → [05]
789
+ → Wave 1: Plans 01 and 02 run in parallel (independent)
790
+ → Wave 2: Plans 03 and 04 run in parallel (both depend on Wave 1 only)
791
+ → Wave 3: Plan 05 runs (depends on both Wave 2 plans)
792
+ → Full test suite runs between each wave
793
+ → Automated verification after all waves complete
794
+ ```
795
+
796
+ This produces consistently higher quality than sequential execution: each subagent
797
+ has a full, clean context window focused entirely on its specific task.
798
+
799
+ ## Long sessions and context compaction
800
+
801
+ MindForge monitors context window usage. At 70%:
802
+ 1. Current state is committed to git
803
+ 2. `STATE.md` and `HANDOFF.json` are updated with full session context
804
+ 3. Work resumes in a fresh context window with clean working memory
805
+
806
+ Sessions never degrade. Every session starts fresh with complete state awareness.
807
+
808
+ ## Audit trail
809
+
810
+ Every agent action is logged to `.planning/AUDIT.jsonl`:
811
+ - Task starts and completions with commit SHAs
812
+ - Security findings with OWASP classification
813
+ - Context compaction events
814
+ - Quality gate failures
815
+
816
+ Query the audit log:
817
+ ```bash
818
+ # What happened in phase 1?
819
+ grep '"phase":1' .planning/AUDIT.jsonl | jq .
820
+
821
+ # Any security findings?
822
+ grep '"event":"security_finding"' .planning/AUDIT.jsonl | jq '{severity,finding,file}'
823
+
824
+ # Today's activity
825
+ grep "$(date -u +%Y-%m-%d)" .planning/AUDIT.jsonl | jq .event
826
+ ```
827
+ ```
828
+
829
+ **Commit:**
830
+ ```bash
831
+ git add README.md
832
+ git commit -m "docs(readme): document wave engine, compaction, and audit trail"
833
+ ```
834
+
835
+ ---
836
+
837
+ ## HARDEN 11 — Final pre-merge checklist
838
+
839
+ Run every check. Do not push until all pass.
840
+
841
+ ```bash
842
+ # 1. All tests pass (complete battery)
843
+ node tests/install.test.js && \
844
+ node tests/wave-engine.test.js && \
845
+ node tests/audit.test.js && \
846
+ node tests/compaction.test.js
847
+ # Expected: all suites show "All tests passed"
848
+
849
+ # 2. Engine files complete
850
+ ls .mindforge/engine/
851
+ # Expected: 4 files
852
+ # dependency-parser.md wave-executor.md context-injector.md
853
+ # compaction-protocol.md verification-pipeline.md
854
+
855
+ # 3. All 10 commands present in both runtimes
856
+ ls .claude/commands/mindforge/ | wc -l # Expected: 10
857
+ ls .agent/mindforge/ | wc -l # Expected: 10
858
+ diff <(ls .claude/commands/mindforge/ | sort) <(ls .agent/mindforge/ | sort)
859
+ # Expected: no output (identical)
860
+
861
+ # 4. AUDIT.jsonl is valid JSON Lines
862
+ node -e "
863
+ const fs = require('fs');
864
+ const c = fs.readFileSync('.planning/AUDIT.jsonl','utf8').trim();
865
+ if (!c) { console.log('AUDIT.jsonl: empty (valid)'); process.exit(0); }
866
+ const lines = c.split('\n').filter(l => l.trim());
867
+ lines.forEach((l, i) => { try { JSON.parse(l); } catch(e) { throw new Error('Line '+(i+1)+': '+e.message); }});
868
+ console.log('AUDIT.jsonl: ' + lines.length + ' valid entries');
869
+ "
870
+
871
+ # 5. HANDOFF.json has all hardened fields
872
+ node -e "
873
+ const h = JSON.parse(require('fs').readFileSync('.planning/HANDOFF.json','utf8'));
874
+ const required = ['schema_version','next_task','_warning','context_refs',
875
+ 'blockers','decisions_needed','recent_commits','recent_files'];
876
+ const missing = required.filter(f => h[f] === undefined);
877
+ if (missing.length) throw new Error('Missing: ' + missing.join(', '));
878
+ console.log('HANDOFF.json: all fields present');
879
+ "
880
+
881
+ # 6. ADRs: now 5 total
882
+ ls .planning/decisions/*.md | wc -l # Expected: 5
883
+
884
+ # 7. Git log: clean Day 2 commits (roughly 12 commits)
885
+ git log --oneline | head -20
886
+ # No WIP, temp, fix, or oops commits
887
+
888
+ # 8. No secrets in any file
889
+ grep -rE "(password|api_key|secret)\s*=\s*['\"][^'\"]{6,}" \
890
+ --include="*.md" --include="*.js" --include="*.json" \
891
+ --exclude-dir=node_modules --exclude-dir=.git \
892
+ . 2>/dev/null | grep -v "placeholder\|example\|your-"
893
+ # Expected: no output
894
+
895
+ # 9. README covers all Day 2 features
896
+ grep -c "wave engine\|compaction\|audit" README.md
897
+ # Expected: 3 or more matches
898
+
899
+ # 10. CLAUDE.md updated with Day 2 references
900
+ grep "wave-executor\|compaction-protocol\|AUDIT.jsonl" .claude/CLAUDE.md | wc -l
901
+ # Expected: 3 or more matches
902
+ ```
903
+
904
+ ---
905
+
906
+ ## FINAL COMMIT AND PUSH
907
+
908
+ ```bash
909
+ git add .
910
+ git commit -m "harden(day2): complete Day 2 hardening — engine, audit, compaction, commands"
911
+ git push origin feat/mindforge-wave-engine
912
+ ```
913
+
914
+ ---
915
+
916
+ ## DAY 2 COMPLETE — What you have built
917
+
918
+ | Component | Files Added | Status |
919
+ |---|---|---|
920
+ | Wave execution engine | 4 engine spec files | ✅ |
921
+ | Dependency parser | dependency-parser.md | ✅ |
922
+ | Context injector | context-injector.md | ✅ |
923
+ | Compaction protocol | compaction-protocol.md | ✅ |
924
+ | Verification pipeline | verification-pipeline.md | ✅ |
925
+ | AUDIT system + schema | AUDIT-SCHEMA.md + AUDIT.jsonl | ✅ |
926
+ | /mindforge:next | next.md (both runtimes) | ✅ |
927
+ | /mindforge:quick | quick.md (both runtimes) | ✅ |
928
+ | /mindforge:status | status.md (both runtimes) | ✅ |
929
+ | /mindforge:debug | debug.md (both runtimes) | ✅ |
930
+ | Day 2 test suites | 3 new test files | ✅ |
931
+ | Architecture ADRs | ADR-004, ADR-005 | ✅ |
932
+
933
+ ---
934
+
935
+ ## DAY 3 PREVIEW
936
+
937
+ ```
938
+ Branch: feat/mindforge-skills-platform
939
+
940
+ Day 3 scope:
941
+ - Org-wide skills distribution system (install org skills globally)
942
+ - 5 additional skill packs: performance, accessibility, data-privacy,
943
+ incident-response, database-patterns
944
+ - Skills CLI: /mindforge:skills list | add | update | validate
945
+ - Skill versioning and compatibility checks
946
+ - /mindforge:review command (full code review using code-quality skill)
947
+ - /mindforge:security-scan command (standalone security scan)
948
+ - /mindforge:map-codebase command (brownfield project onboarding)
949
+ - Phase discussion command (/mindforge:discuss-phase)
950
+ - Persona customisation system (override persona defaults per project)
951
+ ```
952
+
953
+ **Branch:** `feat/mindforge-wave-engine`
954
+ **Day 2 hardening complete. Open PR → assign reviewer → merge to main.**