@ionivetech/mugiwara 0.6.6 → 0.8.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 (138) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/.claude-plugin/plugin.json +2 -7
  3. package/.codex-plugin/plugin.json +2 -7
  4. package/.cursor-plugin/plugin.json +2 -7
  5. package/.kimi-plugin/plugin.json +2 -7
  6. package/.opencode/mugiwara-helpers.mjs +2 -2
  7. package/.opencode/plugins/mugiwara.mjs +3 -18
  8. package/AGENTS.md +5 -4
  9. package/GEMINI.md +3 -3
  10. package/README.md +203 -331
  11. package/content/agents/brook-healing.md +8 -4
  12. package/content/agents/chopper-checkpoint.md +7 -3
  13. package/content/agents/eval-runner.md +4 -4
  14. package/content/agents/franky-gates.md +4 -4
  15. package/content/agents/jinbe-security.md +6 -7
  16. package/content/agents/luffy-orchestrator.md +11 -13
  17. package/content/agents/memory-keeper.md +4 -4
  18. package/content/agents/nami-planner.md +4 -4
  19. package/content/agents/resume-coordinator.md +7 -7
  20. package/content/agents/robin-reviewer.md +7 -3
  21. package/content/agents/sanji-quality.md +2 -2
  22. package/content/agents/skeptic-verifier.md +2 -2
  23. package/content/agents/usopp-brainstorm.md +3 -3
  24. package/content/agents/zoro-execution.md +6 -6
  25. package/content/skills/mugiwara-backend/SKILL.md +54 -43
  26. package/content/skills/mugiwara-backend/references/database.md +61 -0
  27. package/content/skills/mugiwara-brainstorm/SKILL.md +1 -1
  28. package/content/skills/mugiwara-checkpoint/SKILL.md +23 -11
  29. package/content/skills/mugiwara-checkpoint/references/ledger-format.md +1 -1
  30. package/content/skills/mugiwara-contract-first/SKILL.md +46 -1
  31. package/content/skills/mugiwara-execution/SKILL.md +37 -37
  32. package/content/skills/mugiwara-execution/references/dispatch.md +1 -1
  33. package/content/skills/mugiwara-execution/references/execution-phase-flows.md +18 -0
  34. package/content/skills/mugiwara-execution/references/resume-batching.md +2 -2
  35. package/content/skills/mugiwara-frontend/SKILL.md +44 -43
  36. package/content/skills/mugiwara-frontend/references/checklist.md +14 -0
  37. package/content/skills/mugiwara-gates/SKILL.md +23 -14
  38. package/content/skills/mugiwara-healing/SKILL.md +26 -25
  39. package/content/skills/mugiwara-lessons/SKILL.md +2 -2
  40. package/content/skills/mugiwara-orchestration/SKILL.md +11 -11
  41. package/content/skills/mugiwara-orchestration/references/check-ins.md +2 -2
  42. package/content/skills/mugiwara-orchestration/references/closure.md +17 -12
  43. package/content/skills/mugiwara-orchestration/references/control-commands.md +14 -0
  44. package/content/skills/mugiwara-orchestration/references/triage-escalation.md +11 -1
  45. package/content/skills/mugiwara-planning/SKILL.md +26 -29
  46. package/content/skills/mugiwara-planning/references/large-campaign-subplan.md +41 -0
  47. package/content/skills/mugiwara-planning/references/plan-template.md +24 -2
  48. package/content/skills/mugiwara-quality/SKILL.md +21 -12
  49. package/content/skills/mugiwara-resume/SKILL.md +8 -3
  50. package/content/skills/mugiwara-review/SKILL.md +19 -13
  51. package/content/skills/mugiwara-security/SKILL.md +47 -36
  52. package/content/skills/mugiwara-ship/SKILL.md +1 -1
  53. package/content/skills/mugiwara-ship/references/cleanup.md +17 -16
  54. package/content/skills/mugiwara-workflow/SKILL.md +11 -17
  55. package/content/skills/mugiwara-workflow/references/adaptive-budget-governor.md +5 -0
  56. package/content/skills/mugiwara-workflow/references/benchmark-governor.md +53 -0
  57. package/content/skills/mugiwara-workflow/references/cognitive-output-governor.md +5 -0
  58. package/content/skills/mugiwara-workflow/references/large-campaign-subplan.md +29 -0
  59. package/content/skills/mugiwara-workflow/references/scope-code-governor.md +14 -0
  60. package/content/skills/mugiwara-workflow/references/stop-slop-governor.md +14 -0
  61. package/content/skills/mugiwara-workflow/references/workspace-layout.md +42 -38
  62. package/dist/mugiwara.js +1642 -528
  63. package/gemini-extension.json +1 -1
  64. package/hooks/auto-savepoint.js +18 -10
  65. package/hooks/auto-savepoint.ts +23 -23
  66. package/hooks/engagement-marker.js +1 -1
  67. package/hooks/engagement-marker.ts +1 -1
  68. package/hooks/pipeline-guard.js +17 -13
  69. package/hooks/pipeline-guard.ts +24 -20
  70. package/hooks/session-start.js +13 -10
  71. package/hooks/session-start.ts +24 -19
  72. package/package.json +2 -2
  73. package/plugin.json +1 -1
  74. package/references/complexity.md +27 -4
  75. package/references/definition-of-done.md +1 -1
  76. package/references/multi-actor.md +20 -2
  77. package/references/posture-routing.md +31 -0
  78. package/references/prose-style.md +54 -0
  79. package/scripts/benchmark-governor.ts +516 -0
  80. package/scripts/benchmark-thresholds.json +47 -0
  81. package/scripts/check-doc-links.ts +46 -0
  82. package/scripts/conformance.ts +6 -16
  83. package/scripts/coverage-gate.ts +20 -6
  84. package/scripts/gate-selftest.ts +138 -7
  85. package/scripts/lane.sh +54 -8
  86. package/scripts/lib/lane-base.sh +4 -4
  87. package/scripts/lib/patterns.sh +5 -0
  88. package/scripts/policy-force.ts +22 -0
  89. package/scripts/retrieval-eval.ts +10 -4
  90. package/scripts/savepoint.sh +155 -58
  91. package/scripts/validate-content.ts +43 -11
  92. package/scripts/verify-install.ts +9 -7
  93. package/src/adaptive-budget.ts +178 -0
  94. package/src/args.ts +4 -3
  95. package/src/budget.ts +47 -0
  96. package/src/check-artifacts.ts +45 -0
  97. package/src/cli.ts +257 -108
  98. package/src/cognition.ts +234 -0
  99. package/src/config.ts +107 -0
  100. package/src/context.ts +72 -0
  101. package/src/continue.ts +29 -10
  102. package/src/cost.ts +186 -0
  103. package/src/evidence.ts +160 -0
  104. package/src/installer.ts +25 -34
  105. package/src/integrity.ts +158 -0
  106. package/src/investigation.ts +72 -0
  107. package/src/mission.ts +341 -94
  108. package/src/policy.ts +156 -0
  109. package/src/posture.ts +86 -0
  110. package/src/provenance.ts +116 -0
  111. package/src/reporting.ts +225 -0
  112. package/src/rollback.ts +95 -0
  113. package/src/routing.ts +69 -0
  114. package/src/run.ts +2 -2
  115. package/src/scope.ts +321 -0
  116. package/src/sign.ts +235 -0
  117. package/src/slop.ts +306 -0
  118. package/src/targets/claude.ts +2 -2
  119. package/src/work.ts +273 -0
  120. package/.opencode/commands/mugiwara-execute.md +0 -13
  121. package/.opencode/commands/mugiwara-heal.md +0 -13
  122. package/.opencode/commands/mugiwara-onboard.md +0 -14
  123. package/.opencode/commands/mugiwara-plan.md +0 -17
  124. package/.opencode/commands/mugiwara-ship.md +0 -13
  125. package/.opencode/commands/using-mugiwara.md +0 -20
  126. package/content/skills/mugiwara-agent-security/SKILL.md +0 -58
  127. package/content/skills/mugiwara-agent-security/references/checklist.md +0 -20
  128. package/content/skills/mugiwara-context-budget/SKILL.md +0 -66
  129. package/content/skills/mugiwara-context-budget/references/context-budget.md +0 -37
  130. package/content/skills/mugiwara-pr/SKILL.md +0 -69
  131. package/content/skills/mugiwara-pr/references/verdict-format.md +0 -31
  132. package/content/skills/mugiwara-sunset/SKILL.md +0 -82
  133. package/content/skills/using-mugiwara/SKILL.md +0 -51
  134. package/references/token-budget.md +0 -56
  135. package/scripts/evidence.sh +0 -81
  136. package/scripts/initiative.ts +0 -296
  137. package/scripts/mission-report.sh +0 -293
  138. package/src/onboard.ts +0 -207
@@ -1,25 +1,26 @@
1
1
  # Cleanup (after the terminal step)
2
2
 
3
- Once the branch is pushed and the PR material is written, clean `.mugiwara/` of
4
- consumed intermediates. Never touch anything outside `.mugiwara/`.
3
+ Once the branch is pushed and the PR material is written, compact the mission
4
+ dir to its durable core. Never touch anything outside `.mugiwara/`.
5
5
 
6
6
  **KEEP** (the audit trail and PR material):
7
7
 
8
- - `config`
9
- - `plans/YYYY-MM-DD-<mission>.md` — the clean plan doc
10
- - `results/<mission>/06-closure.md` — closure report
11
- - `results/<mission>/07-pr-verdict.md` PR material
12
- - `reports/YYYY-MM-DD-<mission>.md` the mission report (the consolidated evidence)
13
- - `logs/lessons.md` and any cross-mission state (`backup/`, `manifest.json`)
8
+ - `config`, `lessons.md` — cross-mission
9
+ - `missions/<mission>/plan.md` — the clean plan doc
10
+ - `missions/<mission>/report.md` — the consolidated evidence: closure report
11
+ with every flow file, review, security, blockers, and decisions folded in
12
+ - any cross-mission state (`backup/`, `manifest.json`)
14
13
 
15
- **ARCHIVE, then remove** (fold into the mission report first, never delete outright):
14
+ **FOLDED, then removed by archive**:
16
15
 
17
- - `results/<mission>/01-execution.md` … `05-healing.md`, `todos.md` — flow-stage artifacts, folded
18
- - `spec/YYYY-MM-DD-<mission>.md` — consumed by planning
19
- - `review/`, `issues/` per-mission findings — folded into the report
20
- - `logs/YYYY-MM-DD-<mission>.md` and mode-flip logs — folded
21
- - `.mugiwara/continue/<mission>/[member].json` — consumed once closed (delete by exact name, never a glob)
16
+ - `missions/<mission>/flows/01-execution.md` … `08-verifier.md`, `todos.md`
17
+ - `missions/<mission>/spec.md` — consumed by planning
18
+ - `missions/<mission>/review.md`, `security.md`, `blockers.md`, `decisions.md`
19
+ - `missions/<mission>/state.json | <member>.json`,
20
+ `continue.json | continue-<member>.json` — session state dies with the mission
22
21
 
23
- Procedure: run `mugiwara archive <mission>` (dry-run first), which folds evidence
24
- into the report, removes the loose files, and appends a summary-index line.
22
+ Procedure: run `mugiwara archive <mission>` (dry-run first) it folds the wave
23
+ files into `report.md`, removes the loose files, and appends an index line to
24
+ `.mugiwara/index.md`. Batch form for several closed missions:
25
+ `mugiwara clean [--all] [--before <date>]`.
25
26
  A mission is only closed after the archive runs — the trail must survive the merge.
@@ -23,8 +23,6 @@ description: Use at start of any non-trivial mission — Luffy triage gateway, f
23
23
  Skeptic — adversarial verify
24
24
  ```
25
25
 
26
- Flow stages are phases, not files. The plan doc defines them. The harness runs inline.
27
-
28
26
  | # | Flow stage | Crew | Skill | Delivers |
29
27
  |---|------|------|-------|----------|
30
28
  | 0 | Triage | Luffy | `orchestration` | 5-way class + lane |
@@ -47,14 +45,10 @@ Flow stages are phases, not files. The plan doc defines them. The harness runs i
47
45
 
48
46
  **Subagents only for parallelism.** `[PARALLEL]` task batches, parallel review, parallel heal workers. Crew members never dispatch crew members.
49
47
 
50
- **Compact output.** Do not stream tool calls. Progress stays visible: per-task `[task N/M]` lines and one status table per batch. Full logs → `.mugiwara/results/<mission>/01-execution.md`.
48
+ **Compact output.** Do not stream tool calls. Progress stays visible: per-task `[task N/M]` lines and one status table per batch. Full logs → `.mugiwara/missions/<mission>/flows/01-execution.md`.
51
49
 
52
50
  **Mode flips.** `/mugiwara mode <guided|semi|auto>` applies from the next flow stage, never mid-stage. If a flip arrives mid-stage, say so — "recorded, applies from Flow N+1" — never apply silently, never ignore.
53
51
 
54
- ## Workspace
55
-
56
- Full layout: `references/workspace-layout.md`.
57
-
58
52
  ## Flow 0 — Triage (always first)
59
53
 
60
54
  Luffy classifies every request 8 ways:
@@ -70,17 +64,15 @@ Luffy classifies every request 8 ways:
70
64
  | Refuse | deploy / migration / key rotation / merge | decline at Flow 0, offer branch handoff |
71
65
  | Hotfix | production broken | Lane 1, gates deferred with owner |
72
66
 
73
- Precedence: class decides whether there is work; lane decides how much process — class first, lane second.
74
-
75
- Lane: 0=Direct (<20 LOC), 1=Lean (1-2 files), 2=Standard (3-8 files), 3=Full (9+ or sensitive), 4=Spike. Record route in `.mugiwara/logs/`. Read-only investigation (no file change) → Answer/Explore — no crew, no Luffy subagent.
67
+ Precedence: class decides work; lane decides process — class first, lane second. Lane: 0=Direct (<20 LOC), 1=Lean (1-2), 2=Standard (3-8), 3=Full (9+), 4=Spike. Record route in `decisions.md`.
76
68
 
77
69
  ## Session handoff
78
70
 
79
- At session end (step limit, crash, or manual stop) the crew writes `.mugiwara/continue/<mission>/[member].json` before the final text response: mission, member, flow stage, tasks, next_action (exact files + commands), next_session_prompt. Owner: orchestrator (captain); writer: the agent ending the flow stage. Next session starts with `/mugiwara continue <mission> [member]` — no re-explanation. `auto` mode continues across sessions via the continue file: one command per session, no re-explanation. State proves what is done; continue says what is next — verify next_action against state, escalate contradictions.
71
+ At session end (step limit, crash, or manual stop) the crew writes `.mugiwara/missions/<mission>/continue.json | continue-<member>.json` before the final text response: mission, member, flow stage, tasks, next_action (exact files + commands), next_session_prompt. Owner: orchestrator (captain); writer: the agent ending the flow stage. Next session starts with `/mugiwara continue <mission> [member]` — no re-explanation. `auto` mode continues across sessions via the continue file: one command per session, no re-explanation. State proves what is done; continue says what is next — verify next_action against state, escalate contradictions.
80
72
 
81
73
  ## Blocker protocol
82
74
 
83
- Blocked agent appends to `.mugiwara/issues/YYYY-MM-DD-<mission>-blockers.md`:
75
+ Blocked agent appends to `.mugiwara/missions/<mission>/blockers.md`:
84
76
  ```
85
77
  | flow stage | task | symptom | attempted | help-needed |
86
78
  ```
@@ -88,21 +80,23 @@ Brook reads this at Flow 8. Never silently work around a blocker.
88
80
 
89
81
  ## Cleanup (Flow 9)
90
82
 
91
- Archive, never delete: run `mugiwara archive <mission>` — folds `logs/`, `spec/`, `review/`, `issues/` into the mission report and removes the loose files. Step results `results/<mission>/01..05` + `todos.md` are EVIDENCE KEEP them in place; they feed `reports/` and closure links. Keep: everything under `results/<mission>/`, `plans/`, `reports/`, `config`, `logs/lessons.md`. Full layout: `references/workspace-layout.md`.
83
+ Archive, never delete: run `mugiwara archive <mission>` — folds waves + spec + review + security + blockers + decisions into `report.md`, removes session state (`*.json`). The dir ends as two files: plan.md + report.md. Keep cross-mission: `config`, `lessons.md`. Batch: `mugiwara clean [--all]`. Full layout: `references/workspace-layout.md`.
92
84
 
93
85
  ## Rules
94
-
95
86
  1. Evidence over claims — run checks, show output.
96
- 2. No flow stage skipped without reason recorded in logs.
87
+ 2. No flow stage skipped without a reason recorded in the decision log. 2a. Work Governor: classify stages required/conditional/optional (§7); record skip/avoid verdicts as work-governor trail rows; never skip a required stage. 2b. Scope & Code Governor: before adding code, check §14 reuse; justify new abstractions (§15) and dependencies (§16); prefer minimum sufficient implementation; record scope verdicts as scope-governor trail rows. 2c. Cognitive & Output Governor: keep reasoning Question→Evidence→Decision→Action; bound alternatives; compress output to Decision/Action/Result/Evidence/Blocker; dedup explanations; record cognitive verdicts as cognitive-governor trail rows. 2d. Stop-Slop Governor: detect slop via taxonomy/signals; measure progress vs cost; flag anomaly; intervene (tolerate/stop/compress/escalate); detect retry/healing/scope/context/investigation/code slop; record slop-governor trail rows. 2e. Adaptive Budget & Circuit Breaker: reserve/projection/expansion/thresholds/breaker/anomaly; record budget-governor trail rows. 2f. Reporting & CLI: ledger aggregates envelope+events+registry+trail; mugiwara cost surfaces ledger (--json); report Cost section renders ledger+avoided+efficiency+trail (§43). 2g. Benchmark & Hardening: cost (§48) + Stop-Slop (§45) suites, large/long/runaway stress, thresholds tokens>projected+overhead fails, §49 regression fails, deterministic harness, CI via bun run gate, thresholds ratchet like retrieval-eval — Full checklist: references/benchmark-governor.md — 12 scenarios; unchecked boxes are not done.
97
88
  3. Heal loop: max 3 cycles, then escalate.
98
89
  4. Flow 7: Robin and Jinbe parallel over same diff.
99
90
  5. Plan doc is source of truth from Flow 2.
100
91
  6. Resume via `resume-coordinator` before any flow stage — never restart.
101
92
  7. Push branch + hand verdict to user; crew never merges or deploys. 8. Host todo mirrors the plan doc every task + flow stage — same response as evidence.
102
-
93
+ ## Governors
94
+ Work (§7), Scope/Code (§14-16), Cognitive, Stop-Slop (§45), Budget (§43), Reporting/CLI, Benchmark (§48-49) — full checklists: `references/scope-code-governor.md`, `references/cognitive-output-governor.md`, `references/stop-slop-governor.md`, `references/adaptive-budget-governor.md`, `references/benchmark-governor.md`; trail rows; savepoint/lane-base/config untouched.
95
+ ## Large campaign — sub-plan & archive merge
96
+ Full checklist: `references/large-campaign-subplan.md` — 12 items; `sub-plan/` when `>3 phases` or `>1500 lines`, `flows/phase-NN/` isolation, `mugiwara archive` folds into `report.md`.
103
97
  ## Iron Law
104
98
 
105
- EVIDENCE OVER CLAIMS. "Done" = command re-run, output captured, evidence fresh. Every evidence pointer is a CLICKABLE markdown link — `[path](relative/path)` — so reports link straight to the artifact. Step results in results/<mission>/01..05 are EVIDENCE: never deleted at cleanup, they feed the mission report.
99
+ EVIDENCE OVER CLAIMS. "Done" = command re-run, output captured, evidence fresh. Every evidence pointer is a CLICKABLE markdown link — `[path](relative/path)` — so reports link straight to the artifact.
106
100
 
107
101
  ## Artifact trust
108
102
 
@@ -0,0 +1,5 @@
1
+ # Adaptive Budget & Circuit Breaker (Phase 7)
2
+
3
+ Reserve expected max before expensive stages (Review/Security/Healing); continuously project `current + remaining required + expected conditional + possible healing` (§26); expand budget only with evidence (§27 valid: scope legitimately expanded, security-sensitive path, test surface larger, architecture dependency, legitimate healing; invalid: verbosity/reread/repeat/unnecessary code); respect progressive thresholds (§28: 60%→optimize, 75%→aggressive, 90%→protect, 100%→pause, 150%→warning, 300%→stop); trip breaker when `actual ≥ 2× expected` without progress/scope/evidence (§29, note: double-threshold); flag 5k-zero-progress anomaly (§24, re-consumes slop signal); record every non-ok verdict via `recordBudgetDecision` (§41).
4
+
5
+ Honest boundary: verdicts-not-enforcement; crew acts. No new config; savepoint/lane-base untouched. Report/CLI budget ledger → Phase 8.
@@ -0,0 +1,53 @@
1
+ # Benchmark & Hardening — Full Checklist (Phase 9)
2
+
3
+ Tracks `scripts/benchmark-governor.ts` harness (deterministic, no network).
4
+
5
+ ## Cost suite (§48) — 4 workloads
6
+ - [ ] lean-trivial: projected 8000 + overhead 1000, context ≤20000, evidence ≥1, surface files 2 loc 50
7
+ - [ ] standard-feature: projected 15000 + overhead 1500, context ≤40000, evidence ≥3
8
+ - [ ] large-repo: projected 22000 + overhead 2200, context ≤80000, evidence ≥5, surface 50 files
9
+ - [ ] long-mission: projected 23000 + overhead 2300, context ≤90000, 9 stages projection ≤ budget
10
+ - Check: `measured.tokens ≤ projected + overhead` else fail; `measured.context ≤ max` else fail
11
+
12
+ ## Stop-Slop suite (§45) — 12 scenarios detect→classify→intervene
13
+ - [ ] endless-exploration → investigation slop → stop
14
+ - [ ] repeated-reads (3× no evidence) → context slop → stop; with concrete reason → tolerate
15
+ - [ ] repeated-commands (same cmd+evidence fail) → retry slop → stop
16
+ - [ ] repeated-failed-test → retry slop → stop
17
+ - [ ] repeated-reasoning → reasoning slop → stop
18
+ - [ ] unnecessary-abstraction → code slop → stop
19
+ - [ ] unnecessary-dependency → code slop → stop
20
+ - [ ] unrelated-refactor → scope slop → stop
21
+ - [ ] verbose-output → output slop → stop
22
+ - [ ] no-progress-healing (cycle ≥3, 0 fixes) → healing slop → stop
23
+ - [ ] premature-completion → scope slop → escalate
24
+ - [ ] excessive-context (repeated reads + duplicate chars) → context slop → stop
25
+
26
+ ## Stress (bench-only, no runtime)
27
+ - [ ] large repository: 50 files within declared scope → pass (scope drift negative)
28
+ - [ ] long mission: 9 stages, projectBudget max ≤ full budget 50000 → pass
29
+ - [ ] runaway: actual 2× expected with no progress/scope/evidence → breaker tripped → fail (measures, not enforces)
30
+
31
+ ## Thresholds (ratchet, like retrieval-eval)
32
+ - Thresholds live in `scripts/benchmark-thresholds.json` (or in-script THRESHOLDS const)
33
+ - `tokens > projected + overhead` → harness fails workload
34
+ - `context_chars > context_max` → fail
35
+ - Thresholds only move on explicit fixture update (reviewed diff), never silently
36
+ - `note: thresholds are fixture constants, not config — ratchet like retrieval-eval`
37
+
38
+ ## Regression (§49)
39
+ - `checkRegression`: cost down but correctness/evidence/security/quality/scope down → fail
40
+ - Baseline from thresholds `baselines` + workload `expected_*`; measured vs baseline pure comparison
41
+
42
+ ## Cross-platform & Determinism
43
+ - Harness pure over explicit fixture inputs, no Date.now/Math.random/network, deterministic on all platforms
44
+ - `scripts/conformance.ts` 12-platform parity proves cross-platform
45
+
46
+ ## CI Enforcement
47
+ - `package.json:gate` includes `bun scripts/benchmark-governor.ts` (extend existing gate)
48
+ - `scripts/gate-selftest.ts` tampers thresholds → harness must exit 1 (G3 — gate that cannot fail is not a gate)
49
+ - note: harness measures, does not enforce — no runtime gate
50
+
51
+ ## Docs
52
+ - `docs/concepts/cost.md` ## Benchmark & Hardening documents harness/threshold/stress contracts
53
+ - `docs/cost-governor.md` hub links to cost.md for deep contracts
@@ -0,0 +1,5 @@
1
+ # Cognitive & Output Governor
2
+
3
+ Reasoning stays focused — Question→Evidence→Decision→Action, no speculative architecture/hypothetical requirements/repeated reconsideration/unrelated implementations (§17); investigation terminates when acceptance_mapped+surface_understood+path_established or limits hit without concrete reason (§13); alternatives bounded to evidence-backed options (default 3).
4
+
5
+ Output compressed to mission-focused structure (Decision/Action/Result/Evidence/Blocker, §18), duplicate explanations fingerprinted; every cognitive verdict lands as a `cognitive-governor` trail row in `.mugiwara/missions/<mission>/decisions.md` → `## Cost governor decisions`. savepoint/lane-base/config untouched.
@@ -0,0 +1,29 @@
1
+ # Large Campaign — Sub-Plan Governance (Workflow + Archive)
2
+
3
+ ## When to split
4
+
5
+ Large campaigns (>3 phases or >1500-line plans) split into isolated phase slices. Master `plan.md` is index; detail lives in `sub-plan/`.
6
+
7
+ ## Planning split (Nami)
8
+
9
+ - Trigger: `phase count >3` or `plan.md >1500 lines`
10
+ - Files: `sub-plan/01-phase01-<slug>.md` … `sub-plan/0N-phase0N-<slug>.md` + master index
11
+ - Master never appended to 2000+ lines
12
+
13
+ ## Execution isolation (Zoro)
14
+
15
+ - `flows/phase-NN/` per phase holds `02-execution.md`, `02-audit.md`, `03-quality.md`, `04-gates.md`
16
+ - No flat `flows/02-execution.md` overwrite for large campaigns
17
+ - Per-phase evidence captured, merged at archive
18
+
19
+ ## Archive merge (Luffy)
20
+
21
+ - `mugiwara archive` folds `sub-plan/*.md` + `flows/phase-*/` + `decisions.md` sections + `blockers.md` + `review.md`/`security.md` into single `report.md` seeded from `flows/06-closure.md`
22
+ - Final layout: `plan.md` (index) + `report.md` + `pr-verdict.md`/`provenance.md`/`rollback.sh`
23
+ - Idempotent — second run is no-op
24
+ - If code needs extend `src/mission.ts:archiveMission` with `sub-plan/` + `flows/phase-*/` allowlist; otherwise Luffy manual `cat flows/phase-*/... >> report.md` suffices
25
+
26
+ ## References
27
+
28
+ - Precedent: `native-cost-governor` (9 phases, 2688-line plan.md, 22 Archived sections in report.md)
29
+ - Validation: `validate-content` accepts `sub-plan/` as plan source; `verify-install` green; body ≤120 via this reference
@@ -0,0 +1,14 @@
1
+ # Scope & Code Governor
2
+
3
+ Prefer the smallest correct scope — reuse existing code + local modification
4
+ over new architecture (§14). An abstraction is justified only when used in ≥2
5
+ places or required by contract, never speculatively (§15); a dependency is
6
+ added only with explicit justification (§16); implementations are minimum
7
+ sufficient, never minimum LOC at the expense of verification/quality
8
+ (§15/§38).
9
+
10
+ Code waste (unnecessary helper/abstraction/wrapper/interface/config/
11
+ dependency/generated code/refactor) is named; the change surface is measured;
12
+ every scope verdict lands as a `scope-governor` trail row in
13
+ `.mugiwara/missions/<mission>/decisions.md` → `## Cost governor decisions`.
14
+ savepoint/lane-base/config untouched.
@@ -0,0 +1,14 @@
1
+ # Stop-Slop Governor
2
+
3
+ Slop taxonomy (§21 eight kinds); detection signals (§22: repeated reads/commands,
4
+ token-without-evidence, LOC-without-acceptance, abstraction-without-justification);
5
+ progress measurement (§23: evidence/criteria/tests/code vs cost delta, slop when
6
+ cost grows without progress); work-to-cost anomaly (§24 drop signal); intervention
7
+ rules (§20 tolerate/stop/compress/escalate by severity); six category detectors
8
+ (retry §21.6/§31 same-action-same-evidence-same-failure→STOP, healing §21.7/§32
9
+ no-progress→stop, scope §21.8 out-of-scope-without-acceptance→reject, context
10
+ §21.2 duplicate/irrelevant→discard/compress, investigation §21.1 unbounded-
11
+ exploration→stop, code §21.5 unnecessary abstraction/dependency/boilerplate→
12
+ remove/simplify). Every slop verdict lands as a `slop-governor` trail row in
13
+ `.mugiwara/missions/<mission>/decisions.md` → `## Cost governor decisions`.
14
+ savepoint/lane-base/config untouched.
@@ -1,59 +1,63 @@
1
1
  # Workspace layout
2
2
 
3
3
  Every mission creates and works inside `.mugiwara/` at the repo root.
4
+ One directory per mission — everything about a mission lives together.
4
5
 
5
- **Language:** every artifact the crew writes into `.mugiwara/` — plans, logs,
6
- results, reports, spec, state, continue, issues, review — is English, one
6
+ **Language:** every artifact the crew writes into `.mugiwara/` — plans, waves,
7
+ reports, spec, state, continue, blockers, review, decisions — is English, one
7
8
  language only. The audit trail is shared by the whole team and by future
8
9
  sessions; it must not depend on the author's conversational language. A
9
10
  mission artifact in any other language is a defect, not a style choice.
10
11
 
11
12
  ```
12
13
  .mugiwara/
13
- ├── config → runtime mode config (gitignored; project overrides global)
14
- ├── state/<mission>/ computed mission state per (mission, member): state.json (solo) or <member>.json (mugiwara savepoint)
15
- ├── continue/<mission>/ machine-written resume point per (mission, member): state.json (solo) or <member>.json
16
- ├── spec/ brainstorm output: YYYY-MM-DD-<mission>.md
17
- ├── plans/ plan doc: YYYY-MM-DD-<mission>.mdCLEAN, Nami-only, source of truth from Flow 2
18
- ├── results/ per-mission folder: results/<mission>/ holds every flow-stage artifact
19
- │ └── <mission>/
20
- ├── 01-execution.md flow stage 3: task table + evidence
21
- ├── 02-audit.md flow stage 4: checkpoint report
22
- ├── 03-quality.md flow stage 5: quality report
23
- ├── 04-gates.md → flow stage 6: gate verdict
24
- ├── 05-healing.md flow 8: healing report (only when heal ran)
25
- ├── 06-closure.md → flow stage 9: closure summary (KEEP at cleanup)
26
- ├── 07-pr-verdict.md flow stage 9: PR material (KEEP at cleanup)
27
- └── todos.md → execution checkbox list
28
- ├── reports/ mission report (aggregate): YYYY-MM-DD-<mission>.md one-file summary of all flow stages
29
- ├── review/ review + security findings
30
- ├── issues/ blocker log: YYYY-MM-DD-<mission>-blockers.md
31
- └── logs/ Luffy's decision + check-in log: YYYY-MM-DD-<mission>.md (deleted at cleanup)
14
+ ├── config → runtime mode config (gitignored; project overrides global)
15
+ ├── lessons.md cross-mission lessons ledger (memory keeper)
16
+ ├── index.md one line per archived mission (written by mugiwara archive/clean)
17
+ └── missions/<mission>/ ONE dir per mission; bare names, no date prefixes
18
+ ├── plan.md CLEAN execution plan — Nami-only, source of truth from Flow 2
19
+ ├── spec.md brainstorm output / spec bridge (consumed by planning)
20
+ ├── decisions.md → Luffy's decision + check-in log (route reasons, mode flips)
21
+ ├── blockers.md blocker ledger rows
22
+ ├── review.md Robin's findings
23
+ ├── security.md Jinbe's findings
24
+ ├── report.md closure report; archive folds the flow files into it
25
+ ├── state.json computed state per (mission): solo = state.json,
26
+ │ team = <member>.json (gitignored)
27
+ └── continue.json machine resume point: solo = continue.json,
28
+ team = continue-<member>.json (gitignored)
29
+ └── flows/ per-flow-stage artifacts, numbered by flow order
30
+ ├── 01-execution.md flow stage 3: task table + evidence
31
+ ├── 02-audit.md flow stage 4: checkpoint report
32
+ ├── 03-quality.md flow stage 5: quality report
33
+ ├── 04-gates.md → flow stage 6: gate verdict
34
+ ├── 05-healing.md → flow stage 8: healing report (only when heal ran)
35
+ ├── 06-closure.md → flow stage 9: closure summary (seeds report.md)
36
+ ├── 07-pr-verdict.md→ flow stage 9: PR material
37
+ ├── 08-verifier.md → flow stage 4.5: skeptic findings (optional)
38
+ └── todos.md → execution checkbox list
32
39
  ```
33
40
 
34
- Naming rule: every artifact inside `results/<mission>/` uses the SAME mission
35
- name, no date prefix the folder is the grouping, numbered by flow-stage order
36
- (`01-`, `02-`, …). Unnumbered support files may sit alongside the numbered
37
- ones (`todos.md`, `resume.md`, `eval.md`, evidence logs) and are not part of
38
- the flow-stages table. `reports/` and `logs/` and `plans/` files carry the
39
- `YYYY-MM-DD-` date prefix because they are cross-mission folders; `results/`
40
- does not, because each mission owns its folder.
41
+ Naming rule: bare names only. The date lives in `state.json` (`updated_at`)
42
+ and in git history; the folder is the grouping. Lane 0/1 missions write the
43
+ minimum: `state.json`, `flows/01-execution.md`, and `report.md` at closure
44
+ no plan/spec/blockers unless a blocker actually occurs (audit-lite).
41
45
 
42
46
  The plan doc stays clean: it holds ONLY the execution plan (flow stages, tasks,
43
47
  criteria, risks). Who did what, route decisions, and check-in verdicts go to
44
- `logs/`; the closure report goes to `results/<mission>/06-closure.md`. Nothing
45
- non-plan pollutes the plan doc.
48
+ `decisions.md`; the closure summary goes to `report.md`. Nothing non-plan
49
+ pollutes the plan doc.
46
50
 
47
51
  The owning agent creates the folder it needs on first write. No mission
48
52
  artifacts go outside `.mugiwara/`.
49
53
 
50
54
  ## Cleanup (Flow 9)
51
55
 
52
- Step results are evidence KEEP every file in `results/<mission>/`
53
- (`01-execution.md` through `05-healing.md`, `todos.md`, `06-closure.md`,
54
- `07-pr-verdict.md`); they feed the mission report and closure links. Delete
55
- only consumed cross-artifacts: `logs/`, `spec/`, `review/`, `issues/`,
56
- `state/<mission>/`, `continue/<mission>/`. Keep
57
- `plans/`, `reports/`, `config`, `logs/lessons.md` (canonical
58
- lessons ledger; cross-mission state: `backup/`, `manifest.json`). List
59
- candidates before deleting.
56
+ Run `mugiwara archive <mission>` (dry-run first). It folds every flow file,
57
+ review, security, blockers, and decisions into `report.md`, then removes them
58
+ along with session state (`*.json`). The PR material
59
+ (`flows/07-pr-verdict.md`) survives as a standalone `pr-verdict.md` at the
60
+ mission root — it is the handoff to the user and must not fold away. The
61
+ mission dir ends as durable files: `plan.md` + `report.md` +
62
+ `pr-verdict.md` (+ rollback/provenance). Batch form for several closed
63
+ missions: `mugiwara clean [--all] [--before <date>]`.