@ionivetech/mugiwara 0.7.0 → 0.8.1

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 (87) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/.codex-plugin/plugin.json +1 -1
  4. package/.cursor-plugin/plugin.json +1 -1
  5. package/.kimi-plugin/plugin.json +1 -1
  6. package/.opencode/mugiwara-helpers.mjs +2 -2
  7. package/README.md +196 -330
  8. package/content/agents/brook-healing.md +1 -1
  9. package/content/agents/franky-gates.md +1 -1
  10. package/content/agents/luffy-orchestrator.md +2 -2
  11. package/content/agents/memory-keeper.md +5 -0
  12. package/content/agents/usopp-brainstorm.md +3 -2
  13. package/content/agents/zoro-execution.md +4 -3
  14. package/content/skills/mugiwara-backend/SKILL.md +52 -43
  15. package/content/skills/mugiwara-brainstorm/SKILL.md +5 -3
  16. package/content/skills/mugiwara-checkpoint/SKILL.md +21 -8
  17. package/content/skills/mugiwara-contract-first/SKILL.md +46 -1
  18. package/content/skills/mugiwara-execution/SKILL.md +34 -33
  19. package/content/skills/mugiwara-execution/references/dispatch.md +1 -1
  20. package/content/skills/mugiwara-execution/references/execution-phase-flows.md +18 -0
  21. package/content/skills/mugiwara-frontend/SKILL.md +44 -44
  22. package/content/skills/mugiwara-gates/SKILL.md +28 -16
  23. package/content/skills/mugiwara-healing/SKILL.md +30 -25
  24. package/content/skills/mugiwara-lessons/SKILL.md +3 -0
  25. package/content/skills/mugiwara-orchestration/SKILL.md +10 -9
  26. package/content/skills/mugiwara-orchestration/references/control-commands.md +14 -0
  27. package/content/skills/mugiwara-planning/SKILL.md +28 -14
  28. package/content/skills/mugiwara-planning/references/large-campaign-subplan.md +41 -0
  29. package/content/skills/mugiwara-planning/references/plan-template.md +22 -0
  30. package/content/skills/mugiwara-quality/SKILL.md +8 -13
  31. package/content/skills/mugiwara-quality/references/order-checklist.md +18 -0
  32. package/content/skills/mugiwara-resume/SKILL.md +3 -9
  33. package/content/skills/mugiwara-resume/references/resume-protocol.md +16 -0
  34. package/content/skills/mugiwara-review/SKILL.md +17 -24
  35. package/content/skills/mugiwara-review/references/red-flags-review.md +17 -0
  36. package/content/skills/mugiwara-security/SKILL.md +47 -35
  37. package/content/skills/mugiwara-ship/SKILL.md +2 -0
  38. package/content/skills/mugiwara-workflow/SKILL.md +13 -13
  39. package/content/skills/mugiwara-workflow/references/large-campaign-subplan.md +29 -0
  40. package/content/skills/mugiwara-workflow/references/workspace-layout.md +6 -3
  41. package/dist/mugiwara.js +1802 -316
  42. package/gemini-extension.json +1 -1
  43. package/hooks/mugiwara-mode-tracker.js +24 -4
  44. package/hooks/mugiwara-mode-tracker.ts +36 -7
  45. package/hooks/pipeline-guard.js +1 -1
  46. package/hooks/pipeline-guard.ts +2 -1
  47. package/hooks/session-start.js +6 -1
  48. package/hooks/session-start.ts +8 -1
  49. package/package.json +2 -2
  50. package/plugin.json +1 -1
  51. package/references/cost-governor.md +104 -0
  52. package/references/multi-actor.md +21 -0
  53. package/references/posture-routing.md +31 -0
  54. package/references/wave-banners.md +1 -2
  55. package/scripts/benchmark-governor.ts +516 -0
  56. package/scripts/benchmark-thresholds.json +47 -0
  57. package/scripts/check-doc-links.ts +8 -2
  58. package/scripts/gate-selftest.ts +104 -21
  59. package/scripts/lib/lane-base.sh +4 -4
  60. package/scripts/retrieval-eval.ts +9 -3
  61. package/scripts/savepoint.sh +41 -2
  62. package/scripts/validate-content.ts +82 -3
  63. package/scripts/verify-install.ts +20 -0
  64. package/scripts/write-metrics.ts +73 -0
  65. package/src/adaptive-budget.ts +178 -0
  66. package/src/args.ts +3 -2
  67. package/src/budget.ts +18 -16
  68. package/src/check-artifacts.ts +45 -0
  69. package/src/cli.ts +221 -8
  70. package/src/cognition.ts +234 -0
  71. package/src/config.ts +113 -0
  72. package/src/context.ts +72 -0
  73. package/src/continue.ts +29 -0
  74. package/src/cost.ts +189 -0
  75. package/src/evidence.ts +160 -0
  76. package/src/installer.ts +2 -16
  77. package/src/integrity.ts +65 -16
  78. package/src/investigation.ts +72 -0
  79. package/src/mission.ts +246 -16
  80. package/src/policy.ts +355 -2
  81. package/src/posture.ts +86 -0
  82. package/src/provenance.ts +29 -9
  83. package/src/reporting.ts +225 -0
  84. package/src/scope.ts +321 -0
  85. package/src/sign.ts +234 -18
  86. package/src/slop.ts +306 -0
  87. package/src/work.ts +273 -0
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  name: mugiwara-frontend
3
3
  description: Use for frontend component, CSS styling, responsive layout, accessible — matching standards, extraction.
4
+ gate_artifact: flows/01-execution.md — frontend evidence (tokens.css + component evidence)
4
5
  ---
5
6
 
6
7
  # Frontend (Anti-Slop)
@@ -9,41 +10,52 @@ description: Use for frontend component, CSS styling, responsive layout, accessi
9
10
 
10
11
  - Diff touches no UI code: backend, docs, config, or CLI-only change.
11
12
  - No visual change, markup, styling, or frontend behavior in the mission.
12
-
13
13
  Interfaces built under this skill must not look templated.
14
14
 
15
15
  ## Source-backed code
16
16
 
17
17
  Framework code from docs, not memory — `_shared/references/source-grounding.md`.
18
-
18
+ - React Server Actions: `useActionState` for form pending/error state — https://react.dev/reference/react/useActionState
19
+ - Tailwind class scanning: `content` purge paths — https://v3.tailwindcss.com/docs/content-configuration
19
20
  ## Existing repo standard first
20
21
 
21
22
  Match the repo's standard before writing anything new; reuse its components and patterns. Greenfield with no UI: skip to design-system extraction.
22
23
  - Component library (MUI/Tailwind/shadcn/etc) — a new button looks like the repo's buttons, not the internet's.
23
24
  - File conventions, naming, folder structure, CSS strategy; lint/format/test scripts.
24
25
  - Tokens already in the theme/config; existing page patterns — how pages compose sections and state.
25
-
26
26
  ## Redesigns: audit first
27
27
 
28
28
  Capture current layout, spacing/type scales, palette, and component inventory before changing existing UI. Fix real problems; do not restyle what works.
29
29
 
30
30
  ## Design-system extraction (before markup)
31
- Extract tokens from the stack's design system BEFORE markup — spacing scale, type scale, role-based palette, radii, shadows, motion language. Name them semantically (`surface-muted`, not `c3`); store where the stack keeps tokens. No tokens extracted, no markup written; token set and naming: `references/design-tokens.md`. Then turn tokens into a small primitive set (button, input, card, icon, layout helpers) before composing screens — reuse primitives everywhere; every bespoke component is debt on every screen.
32
31
 
32
+ Tokens BEFORE markup — no tokens, no markup. Write `tokens.css` (CSS custom properties on `:root`) unless the stack keeps tokens elsewhere:
33
+ - Spacing: 4/8 grid — 4, 8, 12, 16, 24, 32, 48, 64 (`space-xs`…`space-3xl`).
34
+ - Type: 12/14/16/18/24/32/48 scale, 1.5 line-height, 45–75ch measure (`text-sm`…`text-display`).
35
+ - Role palette: `surface-muted`, `text-primary`, `border-default`, `accent` — semantic, not color names.
36
+ - Radii: 2/4/8/12/full; shadows sm–xl; motion: duration + easing (`duration-fast`, `ease-in-out`).
37
+ Semantic names only (`surface-muted`, never `gray-100`). Full rules: `references/design-tokens.md`.
38
+
39
+ ## Primitives (reuse, 100%)
40
+
41
+ Build `Button`, `Input`, `Card`, `Stack` from tokens; compose every screen from them. A bespoke component is debt on every screen — reuse primitives or justify the exception.
42
+ - Storybook story per primitive as behavior reference, not a build harness — https://storybook.js.org/docs
43
+ - Tailwind: `content: ['./src/**/*.{ts,tsx}']` purge in `tailwind.config.ts`; `prettier-plugin-tailwindcss` for stable class order.
44
+ - Variants over props soup: 3+ boolean props = split the component; children/slots over config flags.
45
+ ## Server Actions (React)
46
+
47
+ `useActionState(fn, initial)` returns `[state, formAction, isPending]`; pass `formAction` to `<form action>`. Progressive enhancement works even before hydration.
48
+ - Disable submit while `isPending` (`useFormStatus` for nested buttons).
49
+ - Render `state.error` into a `role="alert"`/`aria-live` region; every async region gets a `data-testid`.
50
+ - Keyboard path asserted: tab order, focus, Enter/Escape; no focus trap without escape.
33
51
  ## Component architecture
34
52
 
35
- Compose, don't inherit. Small, single-purpose components; the tree mirrors the page, not a god-component.
36
- - Boundaries: one component = one responsibility; extract on reuse; leaves stay presentational (no data fetching).
53
+ Compose, don't inherit. One responsibility per component; extract on reuse; leaves presentational (no data fetching).
37
54
  - Composition over configuration: children/slots beat dozens of props.
38
- - Props: primitives and plain callbacks over object-shaped flags; 3+ boolean props = split the component.
39
55
  - Naming by role (`ProductCard`, not `CardA`); variants over copy-paste.
40
-
41
56
  ## State management
42
57
 
43
- Minimal state, local first; lift only what is shared.
44
- - Server vs client state: never store a per-screen copy of API data; cache/refetch at a data layer; derive on render.
45
- - Single source of truth per state, no duplicate mirrors; lift only when siblings share — context/store for app-wide state, not one screen.
46
- - Loading, error, empty, success states designed, not an afterthought.
58
+ Minimal state, local first; lift only what is shared. Server vs client: cache/refetch at a data layer, derive on render; no per-screen copies of API data. Loading/error/empty/success designed, not an afterthought.
47
59
 
48
60
  ## From Figma / image references
49
61
 
@@ -53,61 +65,48 @@ Extract tokens first, then reproduce structure faithfully: hierarchy, alignment,
53
65
 
54
66
  - Hierarchy and rhythm: one primary action per view, one focal point, consistent spacing.
55
67
  - Restraint: fewer, more considered elements; whitespace is a tool.
56
- - Typography: 1-2 typefaces, deliberate scale, weight for emphasis not decoration, 45-75ch lines.
57
- - Color: role-based palette, contrast AA minimum, never pure-black-on-pure-white for text-heavy surfaces.
58
- - Consistency: the same thing looks the same everywhere; no three ways to render a button.
68
+ - Typography: 1-2 typefaces, deliberate scale, weight for emphasis, 45-75ch lines.
69
+ - Color: role-based palette, contrast AA minimum, never pure-black-on-pure-white for text.
70
+ - Consistency: the same thing looks the same everywhere.
59
71
  - Intentionality: every element earns its place; if you cannot say why, remove it.
60
- - State design: hover, focus, active, disabled, loading, error, empty — designed, not forgotten.
61
- - Craft: deliberate spacing grids; subtle motion respecting `prefers-reduced-motion`; verified at all breakpoints.
62
-
72
+ - State design: hover, focus, active, disabled, loading, error, empty — designed.
73
+ - Craft: spacing grids; motion respecting `prefers-reduced-motion`; verified at breakpoints.
63
74
  ## Responsive behavior
64
75
 
65
- Mobile-first: start at the smallest screen, add breakpoints as layout needs them. Default full-width stacked; columns only when there is room. Use the stack's breakpoints, not a parallel scale; fluid containers, type, and spacing. Verify at every breakpoint, including between them — 3 widths checked is not 12 checked.
76
+ Mobile-first; default full-width stacked, columns only when there is room. Use the stack's breakpoints, not a parallel scale; fluid containers, type, and spacing. Verify at every breakpoint, including between them — 3 widths checked is not 12 checked.
66
77
 
67
- ## Banned AI-default patterns (the slop list)
68
- - Centered hero trio: headline + subtitle + two buttons, dead center, gradient text.
69
- - Row of 3-4 identical feature cards with icon-circle + title + two lines.
70
- - Purple/indigo gradient everything; glassmorphism everywhere; emoji as icons.
71
- - Placeholder content where real product copy exists.
72
- - Stock hero illustrations when the design specifies otherwise.
78
+ ## Performance budgets
73
79
 
74
- Full catalog with the tell for each: `references/slop-catalog.md`. If the brief genuinely calls for one of these, execute it well but the default is: don't.
80
+ - LCP <2.5s, CLS <0.1, INP <200ms. Images carry width/height or aspect-ratio; LCP asset preloaded; fonts `font-display`; input handlers off the main thread.
81
+ - No layout thrash; animate only transform/opacity; lazy-load below the fold; no whole icon library for two icons; no re-render storms (stable keys, no work in render).
82
+ - Lighthouse/lighthouse-ci in repo? Run it; scores meet budgets, deltas explained. Measure before optimizing.
83
+ ## Banned AI-default patterns (the slop list)
75
84
 
85
+ - Centered hero trio; row of 3-4 identical feature cards; purple/indigo gradient everything; glassmorphism; emoji as icons; placeholder copy; stock hero illustrations.
86
+ - Full catalog with the tell for each: `references/slop-catalog.md`. Brief genuinely calls for one? Execute it well — but default is don't.
76
87
  ## WCAG 2.1 AA accessibility
77
88
 
78
- Non-negotiable baseline. Full checklist: `references/checklist.md`.
79
-
80
- - Keyboard: every interaction operable by keyboard alone; logical tab order; visible focus; no focus trap without escape.
81
- - Semantics: native elements over ARIA; landmarks; logical heading order; buttons for actions, links for navigation.
89
+ Full checklist: `references/checklist.md`.
90
+ - Keyboard: operable alone; logical tab order; visible focus; no trap without escape.
91
+ - Semantics: native elements over ARIA; landmarks; logical heading order.
82
92
  - Contrast: 4.5:1 text, 3:1 large text/UI; never color-only meaning.
83
- - Forms: every input labeled (placeholder is not a label); errors/success announced; `aria-describedby` help.
84
- - Dynamic content: `aria-live` for changes; reduced-motion respected.
85
-
93
+ - Forms: every input labeled (placeholder is not a label); `aria-describedby` help.
94
+ - Dynamic content: `aria-live`; reduced-motion respected.
86
95
  ## Testability and verification
87
96
 
88
- Add stable `data-testid` to every interactive element per the repo's testing convention; async states (loading/error/empty) get testids too. Never test by CSS class or by text that changes. Prefer role/label queries (`getByRole`) in tests an accessible name doubles as an accessibility assertion. Keyboard paths for non-trivial interactions (menu, modal, form) are asserted, not assumed. Then compare the result against the reference side by side; list remaining deltas before calling it done.
89
-
90
- ## Performance
91
-
92
- - Core Web Vitals are the bar: LCP <2.5s, CLS <0.1, INP <200ms. Images carry width/height or aspect-ratio (CLS); the LCP asset is preloaded and fonts ship `font-display` (LCP); input handlers stay off the main thread (INP).
93
- - No layout thrash: batch DOM reads/writes; heavy work off the scroll path; animate only transform/opacity.
94
- - Assets: no giant images/font payloads; lazy-load below the fold; no whole icon library for two icons.
95
- - No re-render storms: memoize heavy computation, stable keys, no work in render.
96
- - Repo has Lighthouse or lighthouse-ci? Run it — performance and accessibility scores meet the repo's budgets, deltas explained. Measure before optimizing; do not guess the bottleneck.
97
+ Stable `data-testid` on every interactive element and every async state (loading/error/empty). Never test by CSS class or by text that changes. Prefer `getByRole` — accessible name doubles as an a11y assertion. Keyboard paths asserted for menu/modal/form. Compare result against reference; list remaining deltas before done.
97
98
 
98
99
  ## Frontend security
99
100
 
100
101
  - Never render user content via `dangerouslySetInnerHTML`/`v-html` unless sanitized.
101
102
  - Escape user input in every template; no secrets in client code; validate URL params/storage/API input.
102
103
  - `rel="noopener"` on `target="_blank"`; validate URLs before navigating.
103
-
104
104
  ## Red flags
105
105
 
106
106
  - "Optimize when it's slow" — perf regressions ship measured later, rarely.
107
107
  - "It's client-side, so no security review" — client is public by definition.
108
108
  - "New screen, new components" — primitives are default; bespoke is exception.
109
109
  - "Global store for everything" — local state first; lift only what's shared.
110
-
111
110
  ## Common Rationalizations
112
111
 
113
112
  | Excuse | Reality |
@@ -120,3 +119,4 @@ Add stable `data-testid` to every interactive element per the repo's testing con
120
119
  | "Our repo is messy, I'll use my own style." | Match the repo standard first, then propose raising it. |
121
120
 
122
121
  If a rationalization wins, name it in the report as a known delta — not as silence.
122
+
@@ -1,10 +1,13 @@
1
1
  ---
2
2
  name: mugiwara-gates
3
3
  description: Use after quality checks — sonar-style gate, coverage thresholds, build exit 0, Definition of Done. Binary verdicts with evidence, no negotiation.
4
+ gate_artifact: flows/04-gates.md verdict — coverage + build + DoD evidence
4
5
  ---
5
6
 
6
7
  # Gates (Franky)
7
8
 
9
+ **Language:** Conversational language may be any language, but all `.mugiwara/missions/<mission>/plan.md` artifacts (`plan.md`, `flows/*`, `report.md`, `spec.md`, `decisions.md`, `blockers.md`, `review.md`, `state.json` and `continue.json`) are always English, one language only. Chat responses follow the user's language.
10
+
8
11
  ## Skip when
9
12
 
10
13
  - No code changed: docs-only or README-only diff with zero production surface.
@@ -15,47 +18,55 @@ Gates are binary: pass or fail, with evidence. No negotiation, no "almost passes
15
18
  ## Coverage gate
16
19
 
17
20
  1. Measure coverage with the project's existing tooling.
18
- 2. Read thresholds from `.mugiwara/config` then `~/.mugiwara/config` for `coverage_new` and `coverage_modified`. Defaults: new ≥ 90%, modified ≥ 80%. Missing key or 0 = no threshold. Identify new/modified via git diff.
21
+ 2. Read thresholds from `.mugiwara/config` then `~/.mugiwara/config` for `coverage_new` and `coverage_modified`. Defaults: new ≥ 85%, modified ≥ 90%. Policy may raise, never lower. Missing key or 0 = no threshold. Identify new/modified via git diff.
19
22
  3. No coverage tooling or no test suite → record a SKIP with its reason. Never a fake pass; propose minimal tooling, ask user to add or waive.
20
23
  4. In this repo the gate is executable: `bun run coverage-gate` (`scripts/coverage-gate.ts`) does all three against the mission's `base_sha`, and runs as the last step of `bun run gate`. Never lower a threshold or exclude a file to make it green — add the missing tests.
21
24
  5. User-AC declared (per `mugiwara-testcases`): config thresholds apply to unit-level code only; user-AC verdict governs ship-readiness.
22
25
 
23
26
  ## Sonar-style quality gate
24
27
 
25
- Franky reads evidence from prior flow-stage reports (never re-runs
26
- checks): Jinbe (`.mugiwara/missions/<mission>/security.md`),
27
- Robin (`.mugiwara/missions/<mission>/review.md`), Sanji
28
- (`.mugiwara/missions/<mission>/flows/03-quality.md`).
29
- Evaluated: Vulnerabilities=0, Bugs=0, Code smells≤project
30
- threshold, Coverage(new code)≥config threshold,
31
- Duplications(new code)<3%, Security hotspots reviewed≥80%.
32
- These mirror Sonar's default gate on new code; its AI-Code variant adds
33
- security rating A and reliability rating C on new code with hotspots 100%
34
- reviewed adopt when the team asks for it.
35
- PASS when ALL pass list each with actual + threshold.
36
- Missing data → CANNOT pass: report gap, do not fake.
28
+ Franky reads evidence from prior flow-stage reports (never re-runs checks): Jinbe (`.mugiwara/missions/<mission>/security.md`), Robin (`.mugiwara/missions/<mission>/review.md`), Sanji (`.mugiwara/missions/<mission>/flows/03-quality.md`).
29
+
30
+ Grounding (quality gate = conditions measured against new code during analysis): https://docs.sonarsource.com/sonarqube-server/quality-standards-administration/managing-quality-gates/introduction-to-quality-gates.md — Sonar way: no new issues, all new hotspots reviewed, coverage ≥ 80%, duplication ≤ 3%. Agentic-AI variant thresholds: https://docs.sonarsource.com/sonarqube-cloud/standards/ai-code-assurance/quality-gate-for-agentic-ai.md
31
+
32
+ Evaluated against these fixed numbers (policy may raise, never lower):
33
+ - Vulnerabilities (new) = 0
34
+ - Bugs (new) = 0
35
+ - Code smells (new) project threshold
36
+ - Coverage (new code) config threshold (default 90%)
37
+ - Duplications (new code) < 3%
38
+ - Security hotspots reviewed 80%
39
+
40
+ PASS only when ALL pass — list each with actual + threshold. Missing data → CANNOT pass: report the gap, do not fake.
37
41
 
38
42
  ## Build gate
39
43
 
40
44
  Run the project's build (or typecheck for interpreted stacks). Must exit 0. Capture the tail of output. Skip when `flows/03-quality.md` already recorded an exit-0 build on an unchanged diff.
41
45
 
46
+ ## Diff size gate (reviewability)
47
+
48
+ The change diff against `base_sha` must be ≤ 400 LOC (via `git diff --numstat`). Larger → FAIL with the count; split into smaller changes before re-checking. An oversized diff is not reviewable regardless of other green gates.
49
+
42
50
  ## Optional e2e gate (per `mugiwara-quality`)
43
51
 
44
52
  Runs only when quality flow stage triggered it (repo e2e setup + changed-file e2e patterns, user consent). Skipped/unrun is logged, never blocks PASS. Final verdict: coverage + sonar + build + DoD.
45
53
 
46
54
  ## Definition of Done standing gate
47
55
 
48
- A fixed cross-project bar. Full definitions: `_shared/references/definition-of-done.md`. PASS only when all hold:
56
+ A fixed cross-project bar. Full definitions: `_shared/references/definition-of-done.md`. PASS only when all five axes hold:
49
57
  - Correctness — work does what plan specifies.
50
58
  - Quality — lint/format/unit clean, configs unweakened.
51
59
  - Integration — fits existing system (build/typecheck green).
52
60
  - Docs — user-facing and internal docs updated where change requires.
53
61
  - Ship-readiness — no blocker rows in issues ledger.
54
62
 
63
+ ## Lane-aware gates
64
+
65
+ Direct (1 file <20 LOC) → 3 steps: `build-hooks:check`, `typecheck`, `build`. Lean → +`validate-content`, `lane-base`, `check-doc-links` (6). Standard → +`test:coverage`, `coverage-gate`, `verify-install` (9). Full → +`run-evals`, `retrieval-eval`, `conformance` (+`benchmark-governor` via `conformance` lane) (12). Policy `src/policy.ts:gatesForLane` is source of truth — `gate` counts steps by lane. Conformance 12-platform goldens unchanged — full still passes; direct skips heavy gates.
66
+
55
67
  ## Verdict
56
68
 
57
- PASS only when coverage AND sonar AND build AND DoD all pass with evidence. Write verdict to `.mugiwara/missions/<mission>/flows/04-gates.md`.
58
- PASS → return to Luffy (routes to Robin/Jinbe). FAIL → list files under threshold + by how much → return to Luffy (routes to Brook). Never dispatch the next flow stage yourself.
69
+ PASS only when coverage AND sonar AND build AND diff-size AND DoD all pass with evidence. Write verdict to `.mugiwara/missions/<mission>/flows/04-gates.md` — each criterion with actual + threshold (see `gate_artifact`). PASS → return to Luffy (routes to Robin/Jinbe). FAIL → list files under threshold + by how much → return to Luffy (routes to Brook). Never dispatch the next flow stage yourself.
59
70
 
60
71
  ## Red flags
61
72
 
@@ -66,5 +77,6 @@ PASS → return to Luffy (routes to Robin/Jinbe). FAIL → list files under thre
66
77
  - Gate waived without explicit user decision.
67
78
  - PASS on coverage/build while DoD fails.
68
79
  - Sonar PASS with unverified or faked data.
80
+ - Diff > 400 LOC passed without split.
69
81
  - Echoing raw output when `verbosity=normal` — summarize and cite the evidence path.
70
82
  All mean: the gate has not actually run. Report the gap or the fail, honestly.
@@ -1,45 +1,52 @@
1
1
  ---
2
2
  name: mugiwara-healing
3
3
  description: Use when an execution flow stage failed, earlier flow stages produced failures, broken things to fix — reads blocker ledger, stop-the-line triage, root-cause fixes, prove-it before fixing. Max 3 cycles.
4
+ gate_artifact: flows/05-healing.md — root-cause + guard test evidence
4
5
  ---
5
6
 
6
7
  # Healing (Brook)
7
8
 
9
+ **Language:** Conversational language may be any language, but all `.mugiwara/missions/<mission>/plan.md` artifacts (`plan.md`, `flows/*`, `report.md`, `spec.md`, `decisions.md`, `blockers.md`, `review.md`, `state.json` and `continue.json`) are always English, one language only. Chat responses follow the user's language.
10
+
8
11
  ## Skip when
9
12
 
10
13
  - No failures recorded: blocker ledger empty, all gates and reviews passed.
11
14
  - User explicitly accepts a failure as-is and recorded the decision.
15
+ - Failure reproduces only outside a clean checkout — proven `env`, not code.
12
16
 
13
- Fix what failed, minimally, and prove it. One clean retry per cycle.
17
+ Fix what failed, minimally, and prove it. One clean retry per cycle; `heal_halt` at 3.
14
18
 
15
19
  ## Read the ledger first
16
20
 
17
- Brook's inputs: `.mugiwara/missions/<mission>/blockers.md` rows + quality report (Sanji), gate verdict (Franky), review findings (Robin), security report (Jinbe). Process each ledger row — every row is one healing unit. Rows are appended by any agent that hit a blocker; never skip a row.
21
+ Inputs: `.mugiwara/missions/<mission>/blockers.md` rows + quality report, gate verdict, review findings, security report. Every row is one healing unit; rows are appended by any agent that hit a blocker never skip a row. Row fields: flow stage, task, symptom, attempted, help-needed. Full taxonomy: `references/failure-taxonomy.md`.
22
+
23
+ ## Stop-the-line triage (per failure)
24
+
25
+ 4-phase `reproduce → localize → reduce → guard` — every heal follows it, guard is the Prove-It test.
18
26
 
19
- ## Stop-the-Line triage (per failure)
27
+ 1. PRESERVE evidence — save the failing output/state verbatim before touching anything.
28
+ 2. Reproduce — re-run the failure; confirm it is real and current.
29
+ 3. Localize — layer map (config/test/code/env); `git bisect` when the regression window is unclear.
30
+ 4. Reduce — shrink to the minimal case that still fails.
31
+ 5. Diagnose before touching code — read the full error (line, file, code), ask what changed recently (`git diff`, new deps, config), chase the bad value upstream to its origin. Grep every caller before patching — a fix aimed only at the visible symptom leaves its siblings broken.
20
32
 
21
- 1. PRESERVE evidence: save the failing output/state before touching anything.
22
- 2. Reproduce: re-run the failure, confirm it is real and current.
23
- 3. Localize: layer map of where it sits (config/test/code/env); use `git bisect` when a regression window is unclear.
24
- 4. Reduce: shrink to the minimal case that still fails.
25
- 5. Diagnose before you touch code. Read the error in full (line, file, code), ask what changed recently (`git diff`, new deps, config), and chase the bad value upstream to its origin. Grep every caller before patching — a fix aimed only at the visible symptom leaves its siblings broken.
26
- 6. Test one theory at a time. State it, try the smallest change that could confirm it, and check. A failed theory → a new one; never pile a second fix on top of the first.
27
- 7. Guard with a regression test that fails without the fix.
28
- 8. Verify end-to-end: run the failed check, capture output.
33
+ Never push past a failing test — a red test stops the line until green or escalated.
29
34
 
30
- Never push past a failing test — a red test stops the line until it is green or escalated.
35
+ ## Root-cause, not symptom
31
36
 
32
- ## When fixes keep failingquestion the foundation
37
+ Fix at the shared function, not the caller that surfaced. One fix = smallest diff resolving the finding. No drive-by refactors. Test one theory at a time: state it, try the smallest change that could confirm it, check. A failed theory a new one; never pile a second fix on top of the first.
33
38
 
34
- Two or three different fixes that each uncover a fresh dependency somewhere else are a signal you're patching a symptom. The foundation, not the failure, is wrong. Stop, lay out the pattern to Luffy and the human, and argue about the architecture before attempting another fix.
39
+ ## Prove-It (red green) guard phase of 4-phase
35
40
 
36
- ## Prove-It pattern
41
+ Before fixing a bug: write the failing test that reproduces it, watch it fail, then fix until green. Red → code → green, in that order. A fix with no reproducing test is unproven. Every code fix ships with the failed check now passing — run it, capture output.
37
42
 
38
- Before fixing a bug: write the failing test that reproduces it, watch it fail, then fix until green. Red → code → green, in that order. A fix with no reproducing test is unproven.
43
+ ## Two-or-three-signal foundation check
44
+
45
+ Two or three different fixes that each uncover a fresh dependency elsewhere = symptom-patching. Stop, lay out the pattern to Luffy and the human, argue about the architecture before attempting another fix.
39
46
 
40
47
  ## Triage matrix
41
48
 
42
- Full taxonomy behind the matrix: `references/failure-taxonomy.md`.
49
+ Full taxonomy: `references/failure-taxonomy.md`.
43
50
 
44
51
  | Failure | Action |
45
52
  |---------|--------|
@@ -49,13 +56,11 @@ Full taxonomy behind the matrix: `references/failure-taxonomy.md`.
49
56
  | blocker security/review finding | smallest safe diff; add or extend the test that catches it |
50
57
  | architectural finding / high-risk change | DO NOT auto-fix — prepare fix/rollback plan, escalate to Luffy → human |
51
58
 
52
- ## Rules
59
+ Env rule: `env` must reproduce on a clean checkout in the same environment, or fail only on one OS/CI. "Probably env" is not proof — it stays a code failure until proven otherwise.
60
+
61
+ ## Cycle counter (`heal_halt`)
53
62
 
54
- 1. One fix = smallest diff resolving the finding. No drive-by refactors.
55
- 2. Every code fix ships with the failed check now passing (run it, capture output).
56
- 3. Never delete or weaken tests/configs to make a failure disappear.
57
- 4. After healing: update the ledger — mark each healed row with evidence; keep unfixed rows for escalation.
58
- 5. Cycle counter: read `heal_halt` from `.mugiwara/missions/<mission>/state.json | <member>.json` (savepoint writes it as `heal_cycle ≥ heal_max_cycles`, config default 3). After this flow stage the flow returns to Flow 4 (Chopper) for re-audit. **When `heal_halt` reads `true`, STOP and escalate to the user with full history — a halt, not a red flag.** Red flags are prose; the counter is state. Never re-run past `heal_max_cycles`.
63
+ Read `heal_halt` from `.mugiwara/missions/<mission>/state.json | <member>.json` savepoint writes it as `heal_cycle ≥ heal_max_cycles`, config default 3. After this flow stage, flow returns to Flow 4 (Chopper) for re-audit. **When `heal_halt` reads `true`, STOP and escalate to the user with full history — a halt, not a red flag.** Red flags are prose; the counter is state. Never re-run past `heal_max_cycles`.
59
64
 
60
65
  ## Worker subagents
61
66
 
@@ -63,7 +68,7 @@ Brook runs inline for triage + ledger reading; parallel fixes use disposable WOR
63
68
 
64
69
  ## Output
65
70
 
66
- Fixed list (finding → commit → evidence), escalated list (finding → plan → owner), updated ledger back to Flow 4 (Chopper).
71
+ Write `.mugiwara/missions/<mission>/flows/05-healing.md`: fixed list (finding → commit → evidence), escalated list (finding → plan → owner), updated ledger. After healing: update the ledger — mark each healed row with evidence; keep unfixed rows for escalation. Then back to Flow 4 (Chopper) for re-audit.
67
72
 
68
73
  ## Red flags
69
74
 
@@ -71,7 +76,7 @@ Fixed list (finding → commit → evidence), escalated list (finding → plan
71
76
  - A fix shipped without a reproducing test (Prove-It skipped).
72
77
  - A test or config deleted or weakened to silence a failure.
73
78
  - A drive-by refactor riding along with a fix.
74
- - A code failure marked `env` to close the ledger.
79
+ - A code failure marked `env` without clean-checkout proof.
75
80
  - A ledger row processed with no evidence recorded.
76
81
  - The same failure healing past 3 cycles without escalation.
77
82
  - Several failed fixes on one failure without taking the architecture question to Luffy.
@@ -5,8 +5,11 @@ description: Use at mission start/end — cross-mission lessons ledger. Read pas
5
5
 
6
6
  # Lessons (Mission Memory)
7
7
 
8
+ **Language:** Conversational language may be any language, but all `.mugiwara/missions/<mission>/plan.md` artifacts (`plan.md`, `flows/*`, `report.md`, `spec.md`, `decisions.md`, `blockers.md`, `review.md`, `state.json` and `continue.json`) are always English, one language only. Chat responses follow the user's language.
9
+
8
10
  ## Skip when
9
11
 
12
+ - Lane 0 direct with empty ledger — `lessons.md` missing or empty and lane `direct` → skip dispatch, record skip.
10
13
  - Fresh repo, zero prior missions: no ledger exists and nothing to surface.
11
14
  - Nothing learned worth keeping — no new lesson, no repeated failure pattern.
12
15
 
@@ -3,6 +3,7 @@ name: mugiwara-orchestration
3
3
  description: Gatekeeper + captain for any task: triage, classify, coordinate, route, refuse deploy, key rotation, hotfix, "skip the pipeline" pressure, direct calls, mode flips, lane escalation, heal cycles, check-in, close.
4
4
  ---
5
5
  # Orchestration (Luffy)
6
+ **Language:** Conversational language may be any language, but all `.mugiwara/missions/<mission>/plan.md` artifacts (`plan.md`, `flows/*`, `report.md`, `spec.md`, `decisions.md`, `blockers.md`, `review.md`, `state.json` and `continue.json`) are always English, one language only. Chat responses follow the user's language.
6
7
 
7
8
  ## Skip when
8
9
 
@@ -22,6 +23,10 @@ Every flow stage returns to Luffy — no crew member hands off directly to anoth
22
23
  - Franky → return gates → Luffy routes pass/fail
23
24
  - Robin/Jinbe → return findings → Luffy routes to Brook/Zoro/defer
24
25
 
26
+ **Control commands (pre-flow):** `mugiwara continue`/`status` are read-only,
27
+ pre-flow — never create config, never start a flow stage; exit 2 = user selects.
28
+ Full: `references/control-commands.md`.
29
+
25
30
  ## Coordination files
26
31
 
27
32
  Team repos — per-(mission, member) isolation, no collisions: `_shared/references/multi-actor.md`.
@@ -45,7 +50,7 @@ Classify every incoming request. 5-way table (Trivial/Explicit/Exploratory/Open-
45
50
 
46
51
  ## Lane routing + precedence (Flow 0, size before process)
47
52
 
48
- Alongside the class, size the mission and pick a lane (0 Direct / 1 Lean / 2 Standard / 3 Full / 4 Spike). **Precedence: class decides whether there is work; lane decides how much process — class first, lane second, record both.** A pasted Explicit spec still sizes the lane from its file list before Flow 2 (40-file spec → Lane 3). Escalation only: a lane may rise mid-mission, never drop. Full table: `references/triage-escalation.md`. Small tasks: read-only investigation → host `explore` agent or inline read — NOT a Luffy subagent (~5k inline vs ~132k measured per dispatch); explicit implement → Lane 1 Zoro inline. Review only when risky — full pipeline.
53
+ Alongside the class, size the mission and pick a lane (0 Direct / 1 Lean / 2 Standard / 3 Full / 4 Spike). **Precedence: class decides whether there is work; lane decides how much process — class first, lane second, record both.** Record the initial execution posture + rationale (default `inline-sequential`) per `_shared/references/posture-routing.md`. Cost: ladder + terse output + slop + budget — Full checklist: `_shared/references/cost-governor.md`. A pasted Explicit spec still sizes the lane from its file list before Flow 2 (40-file spec → Lane 3). Escalation only: a lane may rise mid-mission, never drop. Full table: `references/triage-escalation.md`. Small tasks: read-only investigation → host `explore` agent or inline read — NOT a Luffy subagent (~5k inline vs ~132k measured per dispatch); explicit implement → Lane 1 Zoro inline. Review only when risky — full pipeline.
49
54
 
50
55
  ## Spec bridge (Flow 0 → Flow 2)
51
56
 
@@ -56,9 +61,9 @@ Flow 1 (Usopp) writes the brainstorm output to `.mugiwara/missions/<mission>/spe
56
61
  User may summon crew members directly. Luffy records the route + reason. Zoro/Brook: execute/heal immediately. All others: return to Luffy. Direct calls do not skip check-ins.
57
62
 
58
63
  ## Periodic check-ins
59
- Full checklist: `references/check-ins.md` — 7 items + by-mode verdicts; unchecked boxes are not done. **Handoff contract:** the continue file at every flow-stage boundary — never only session end (rule #6).
64
+ Full checklist: `references/check-ins.md` — 7 items + by-mode verdicts; unchecked boxes are not done. **Handoff contract:** `mugiwara savepoint <mission> --flow N` at every flow-stage boundary — `state.json` flow+tasks (`- [x]`/`- [ ]` + `sub-plan/` fallback) sync with `continue.json`, no `0/0` (rule #6).
60
65
  **Auto never drops:** in `auto` mode the crew runs every flow stage autonomously to closure — lane rise (`lane_rose`), sensitive-path touches, and heal cycles do NOT downgrade the mode. Only a genuine blocker or the heal halt pauses and escalates to the user; the mode stays auto. Announce every pause. **Auto never asks scope:** in `auto` mode, log the default choice and proceed — no scope/confirmation questions. A genuinely unclear requirement is brainstormed with Usopp (Flow 1) before the choice — never guessed. Only a genuine blocker or a pause escalates.
61
- **Heal halt:** read `heal_halt` from `.mugiwara/missions/<mission>/state.json | <member>.json`. savepoint computes it (`heal_cycle ≥ heal_max_cycles`, config default 3); when it reads `true`, STOP and escalate to the user.
66
+ **Heal halt:** read `heal_halt` from `.mugiwara/missions/<mission>/state.json | <member>.json`. savepoint computes it (`heal_cycle ≥ heal_max_cycles`, config default 3); when it reads `true`, STOP and escalate. **Slop guard (all crews Luffy/Nami/Zoro/Brook):** before dispatch read `heal_cycle`/`heal_halt` + `context-registry.jsonl` `repeated_reads` — `repeated_reads>thr` skip/compress, `heal_cycle≥max` halt/escalate — trail `slop-governor` — Full checklist: `_shared/references/cost-governor.md` §§21-24,20,31-32.
62
67
  **Pressure:** "just skip it", "auto, don't ask", "just this once" — the Rationalizations table below is the answer, not urgency.
63
68
 
64
69
  ## Rationalizations (pressure resistance)
@@ -78,7 +83,7 @@ Shortcuts ("skip X", "just do it") reroute work inside the pipeline — never ou
78
83
  ## Flow transitions (visibility)
79
84
 
80
85
  Banner in the owning agent's color opens every flow stage — the equals line
81
- `===== ⚔️ FLOW 3 — ZORO (EXECUTION) =====` (ANSI-wrapped in terminals, plain in markdown UIs). Spec + colors: `_shared/references/wave-banners.md`. Timing: banner = FIRST line of the flow stage's first response; handoff `→ Flow N+1 — Crew (Role)` = LAST line of the flow stage's final response. A skip is recorded, never silent.
86
+ `===== ⚔️ FLOW 3 — ZORO (EXECUTION) =====` (ANSI-wrapped in terminals, plain in markdown UIs). Spec + colors: `_shared/references/wave-banners.md`. Timing: banner = FIRST line of the flow stage's first response; handoff `→ Flow N+1 — Crew (Role)` = LAST line. Close = `mugiwara savepoint <mission> --flow N` before handoff — `state.json` flow+tasks (`- [x]`/`- [ ]` + `sub-plan/` fallback) sync with `continue.json`, no `0/0`. A skip is recorded, never silent. **Host todos (Luffy):** At Flow 0 Luffy seeds host native todos (`todowrite` on opencode) mirroring `plan.md` every task + flow stage as `pending`; Zoro flips `pending→in_progress→completed` each wave; keep `flows/todos.md` as archive — UI sync via `todowrite`, same response as evidence. Full checklist: `_shared/references/cost-governor.md`.
82
87
 
83
88
  ## Output discipline
84
89
 
@@ -91,17 +96,13 @@ Rendered examples: `references/output-contract.md` — match the shape.
91
96
 
92
97
  When a flow stage has many independent tasks, instruct Zoro to parallelize — one task per WORKER subagent — and may split the mission into parallel tracks. Only `[PARALLEL]` sets are dispatched; sequential work stays inline. Never run more parallelism than the plan proves safe (check the dependency graph, no shared files). A `[PARALLEL]` task set with a hidden dependency edge is a red flag.
93
98
 
94
- ## Q&A hub
95
-
96
- Any agent routes a question to Luffy (via the main thread). Answer with: decision + reason + impact on the plan. Log every decision to `.mugiwara/missions/<mission>/decisions.md`; do NOT touch the plan doc.
97
-
98
99
  ## Override (in-session)
99
100
 
100
101
  Recognize the in-session phrase `mugiwara mode <guided|semi|auto>`: write the project `.mugiwara/config`, append a decision-log row (level, requester, timestamp), and apply from the next flow stage. No CLI flag. The mode is read once per flow stage — a flip never applies mid-flow-stage.
101
102
 
102
103
  ## Closure (Flow 9)
103
104
 
104
- Gate — every task's acceptance criteria verified, every gate passed, findings resolved or deferred with an owner, blocker ledger reviewed. Write the closure summary to `.mugiwara/missions/<mission>/report.md` (seeded from `flows/06-closure.md`); report and summary prose follow `_shared/references/prose-style.md`. Run `mugiwara savepoint <mission>` for final state, then `mugiwara archive <mission>` — waves, review, security, blockers, decisions fold into report.md; plan.md stays. The mission dir ends as two files: plan.md + report.md. Full detail: `references/closure.md`. With `auto_commit=off` (guided/semi): skip the save-point commit and push — hand the uncommitted tree + verdict to the user; auto always pushes.
105
+ Gate — every task's acceptance criteria verified, every gate passed, findings resolved or deferred with an owner, blocker ledger reviewed. Write the closure summary to `.mugiwara/missions/<mission>/report.md` (seeded from `flows/06-closure.md`); report and summary prose follow `_shared/references/prose-style.md`. Run `mugiwara savepoint <mission>` for final state, then `mugiwara archive <mission>` — waves, review, security, blockers, decisions fold into report.md; plan.md stays; the PR material (`flows/07-pr-verdict.md`) survives as `pr-verdict.md` at the mission root. The mission dir ends as plan.md + report.md + pr-verdict.md. Full detail: `references/closure.md`. With `auto_commit=off` (guided/semi): skip the save-point commit and push — hand the uncommitted tree + verdict to the user; auto always pushes.
105
106
 
106
107
  ## Spirit vs letter
107
108
 
@@ -0,0 +1,14 @@
1
+ # Control Commands (pre-flow)
2
+
3
+ `mugiwara continue` / `mugiwara status` are read-only control commands, not flow
4
+ work. They:
5
+
6
+ - Dispatch before Flow 0 and crew dispatch — the CLI is the deterministic half
7
+ of resume (directory scan + solo-vs-team rule), no reasoning turn needed.
8
+ - Never create `.mugiwara/config` and never print setup chatter — a fresh
9
+ project stays clean.
10
+ - Never start a flow stage.
11
+
12
+ Exit codes: 0 = a single resume point printed; 2 = ambiguous/absent — stop and
13
+ let the user select. Only after the CLI resolves the resume point does Flow 0
14
+ re-entry (or plan verification) begin.
@@ -1,16 +1,19 @@
1
1
  ---
2
2
  name: mugiwara-planning
3
3
  description: Use for turning an approved spec into an implementation plan — interview-first, full context scan, scaled Quick/Standard/Full plans, parallel-proof waves.
4
+ gate_artifact: plan.md Waves/Task index — planning evidence
4
5
  ---
5
6
 
6
- # Planning (Nami)
7
+ # Planning
8
+
9
+ **Language:** Conversational language may be any language, but all `.mugiwara/missions/<mission>/plan.md` artifacts (`plan.md`, `flows/*`, `report.md`, `spec.md`, `decisions.md`, `blockers.md`, `review.md`, `state.json` and `continue.json`) are always English, one language only. Chat responses follow the user's language.
7
10
 
8
11
  ## Skip when
9
12
 
10
13
  - Lane 0 direct work: no plan needed for a typo or single-file fix.
11
14
  - A plan already exists and is approved — execute, don't re-plan.
12
15
 
13
- Classify the mission by size first — after Luffy's route — then write the plan at the matching level. Quality bar: a zero-context senior engineer executes every task without asking one question.
16
+ Classify the mission by size first — after the route decision — then write the plan at the matching level. Quality bar: a zero-context senior engineer executes every task without asking one question. Rule: never plan above or below the measured size (file count + days from the spec) — a 40-file spec is never Quick.
14
17
 
15
18
  ## Classify mission size
16
19
 
@@ -27,17 +30,23 @@ Batch blocking ambiguities into ONE question round; never assume silently. Mode
27
30
 
28
31
  ## Full context scan
29
32
 
30
- Scan the whole codebase the mission touches before writing: structure, entry points, existing patterns, tests, tooling. If the mission needs it, scan everything — a plan written without the real code is fiction. Ground every file path and step in what exists; confirm tooling, do not assume. Trust-sort sources (high/medium/low): `references/plan-template.md`.
31
-
32
- **User AC mapping (per `mugiwara-testcases`).** In the context scan, read the declared test source (none = no user tests) and map each user AC to ≥1 per-task criterion: executable user test → the project test command scoped to that file; declarative AC → "translate to a project test file + run" or a literal command check. Cross-cutting user ACs (an e2e flow spanning tasks) become plan-level criteria re-run at the checkpoint against the whole diff; never invent an integration test as a criterion — user tests are the only integration-class criteria.
33
+ Scan the whole codebase the mission touches before writing: structure, entry points, existing patterns, tests, tooling. Ground every file path in what exists; confirm tooling, do not assume. Trust-sort sources: `references/plan-template.md`. Rule: every file path must be verified — unverified path fails.
33
34
 
34
35
  ## Zero-question standard
35
36
 
36
- A senior principal's plan leaves nothing to the executor's judgment. Every task specifies: exact file paths (never "the component"), the exact commands to run (TDD steps with the test command), an acceptance criterion that is a literal command or file check ("works correctly" is banned), and the dependency edge. If you cannot write it that specifically, scan again before the task goes in.
37
+ A senior principal's plan leaves nothing to the executor's judgment. Every task specifies: exact file paths (never "the component"), the exact commands to run (TDD steps with the test command), an acceptance criterion that is a literal command or file check ("works correctly" is banned), and the dependency edge. If you cannot write it that specifically, scan again before the task goes in. Rule: a stranger must read each task once and run the acceptance verbatim.
38
+
39
+ ## CODEOWNERS per area
40
+
41
+ Map every task to a codebase area before parallelizing. Each area (e.g. `src/auth/`, `api/`, `docs/`) lists the task(s) that own it; two tasks in the SAME area are never `[PARALLEL]`, disjoint areas are the only parallel proof. Route review per area from the same table. Rule: every task in the task index appears in exactly one area row of its wave — an unowned file is a planning defect.
42
+
43
+ | Area | Owner task(s) |
44
+ |------|---------------|
45
+ | <path prefix> | T1, T2 |
37
46
 
38
47
  ## Plan tables (wave + task index)
39
48
 
40
- Before the detail blocks, add two markdown tables so Zoro can read the shape at a glance and parallelize safely:
49
+ Before the detail blocks, add two markdown tables so the executor can read the shape at a glance and parallelize safely:
41
50
 
42
51
  | Wave | Focus | Tasks | Gate |
43
52
  |------|-------|-------|------|
@@ -60,10 +69,13 @@ Before the detail blocks, add two markdown tables so Zoro can read the shape at
60
69
  - Risk: none | <rollback plan>
61
70
  ```
62
71
 
63
- **Task size = commit granularity.** Zoro commits per LOGICAL task, not per micro-step. Size tasks as meaningful units of work (a feature, a fix, a refactor), not keystrokes — a "fix typo" or "rename variable" task should be folded into its neighboring logical task, never standalone. If the plan is full of XS tasks, merge them up before writing: a plan sliced into a dozen one-line commits is a plan that will litter the history. Few, well-sized tasks few, meaningful commits.
72
+ **Task size = commit granularity.** The executor commits per LOGICAL task, not per micro-step. Size tasks as meaningful units of work (a feature, a fix, a refactor), not keystrokes — a "fix typo" or "rename variable" task folds into its neighboring logical task, never standalone. A plan full of XS tasks is a history-littering plan; merge them up before writing. Rule: one task = one commit, no exceptions.
64
73
 
65
74
  ## Waves
66
- Group tasks into waves; each wave ends in a verified, reviewable state. `[PARALLEL]` ONLY when tasks share no file AND no interface dependency (state the proof); otherwise `[SEQUENTIAL, depends-on: Task M (file: <path>)].` Never mark parallel on assumption. Per-wave gate: acceptance checks run with evidence; a wave starts only when its dependencies are proven done.
75
+
76
+ Group tasks into waves; each wave ends in a verified, reviewable state. `[PARALLEL]` ONLY when tasks share no file AND no interface dependency AND no shared CODEOWNERS area (state the proof); otherwise `[SEQUENTIAL, depends-on: Task M (file: <path>)].` Never mark parallel on assumption. Per-wave gate: acceptance checks run with evidence; a wave starts only when its dependencies are proven done.
77
+
78
+ **Rollback per wave.** Every wave names its rollback point — a tag at the last proven-good commit — in the wave table. Rule: wave N starts only when wave N-1's rollback point is recorded; a failed wave gate means revert (`git revert <wave-N-tag>`), fix, re-run the gate. A wave with no named rollback point is a planning defect.
67
79
 
68
80
  ## Implementation graph
69
81
 
@@ -88,20 +100,22 @@ Any anti-pattern fails the quality bar — fix the plan before handoff. Never sh
88
100
 
89
101
  ## Full-level skeleton
90
102
 
91
- Full plan at `.mugiwara/missions/<mission>/plan.md`: `# <mission>`, `## Key decisions`, `## Architecture overview`, `## Project structure`, `## Waves`, `## Implementation graph`, `## Task index`, `## Detail tasks`, `## Risk & rollback`, `## Mission split`. Route reasons, check-ins, closure go to `logs/`/`results/`.
103
+ Full plan at `.mugiwara/missions/<mission>/plan.md`: `# <mission>`, `## Key decisions`, `## Architecture overview`, `## Project structure`, `## Waves`, `## CODEOWNERS`, `## Implementation graph`, `## Task index`, `## Detail tasks`, `## Risk & rollback`, `## Mission split`. Route reasons, check-ins, closure go to `logs/`/`results/`.
92
104
 
93
105
  ## Mission split (very large) — Lane 3
94
106
 
95
- Very-large missions (>2 days, multi-PR) split into sub-missions, never one giant plan. Each sub-mission: own PR, done-criteria, continuation pointer, and its own wave table; every sub-mission ends mergeable. Continuation flows through `.mugiwara/missions/<mission>/continue.json | continue-<member>.json` — next sub-mission resumes from the pointer, never restarts. Nami writes the split before any task detail.
107
+ Very-large missions (>2 days, multi-PR) split into sub-missions, never one giant plan. Each sub-mission: own PR, done-criteria, continuation pointer, and its own wave table; every sub-mission ends mergeable. Continuation flows through `.mugiwara/missions/<mission>/continue.json | continue-<member>.json` — next sub-mission resumes from the pointer, never restarts. The planner writes the split before any task detail.
96
108
 
109
+ ## Large campaign — sub-plan
110
+ Full checklist: `references/large-campaign-subplan.md` — 6 items; trigger `>3 phases` or `>1500 lines`, `sub-plan/NN-phaseNN-<slug>.md`, master index pattern.
97
111
  ## Handoff
98
112
 
99
- STOP after writing. The plan is written to `.mugiwara/missions/<mission>/plan.md` and it is clean — no agent names, no coordination log, no closure (that lives in `logs/` and `results/`). **Return to Luffy.** Present a 2-3 line summary (waves, task count, key risks) and hand off to Luffy for the GO decision. Luffy decides: approve → Zoro, revise → back to you, or escalate.
113
+ STOP after writing. The plan is written to `.mugiwara/missions/<mission>/plan.md` and it is clean — no agent names, no coordination log, no closure (that lives in `logs/` and `results/`). **Return to the orchestrator.** Present a 2-3 line summary (waves, task count, key risks) and hand off for the GO decision. The orchestrator decides: approve → executor, revise → back to you, or escalate.
100
114
 
101
- Never hand to Zoro without Luffy's GO. In `guided` mode, Luffy asks the user before delegating to Zoro. In `semi`/`auto`, Luffy may auto-go unless the task carries high risk (deploy, migration, DB, public API). You do not decide — you present, Luffy routes.
115
+ Never hand to the executor without a GO. In `guided` mode, the orchestrator asks the user before delegating. In `semi`/`auto`, the orchestrator may auto-go unless the task carries high risk (deploy, migration, DB, public API). You do not decide — you present, the orchestrator routes.
102
116
 
103
117
  ## Red flags
104
118
  - Shipping a plan with a known anti-pattern (TBD, "works correctly", assumed tooling).
105
119
  - Marking [PARALLEL] without file- AND interface-disjoint proof.
106
120
  - Missing file-level dependency edges or a Break point on an 8+ file task.
107
- - Handing the plan to Zoro without Luffy's GO.
121
+ - Handing the plan to the executor without a GO.
@@ -0,0 +1,41 @@
1
+ # Large Campaign — Sub-Plan Governance (Planning)
2
+
3
+ Trigger: `phase count >3` or `plan.md >1500 lines` (`wc -l`). When triggered, Nami auto-splits.
4
+
5
+ ## Naming
6
+
7
+ - `sub-plan/NN-phaseNN-<slug>.md` (zero-padded, slug from `Phase N: Title` lowercased, `[^a-z0-9]+` → `-`)
8
+ - Master `plan.md` holds Mission split table (index) + DoD + how-to-start; detail lives in `sub-plan/`
9
+ - Example: `sub-plan/01-phase01-cost-governor-foundation.md`
10
+
11
+ ## Master index
12
+
13
+ Master `plan.md` never exceeds 1500 lines — detail lives in sub-plan slices.
14
+
15
+ ## Phase isolation vs true sub-mission
16
+
17
+ Two distinct decisions — do not conflate:
18
+
19
+ - **Phase isolation** (sub-plan) = ONE mission, one plan. `sub-plan/NN-phaseNN-*.md`
20
+ slices detail; `flows/phase-NN/` owns evidence; archive folds the
21
+ trail. Phase-local posture lives in the slice.
22
+ - **True sub-mission** = a SEPARATE, independently mergeable unit: own branch,
23
+ done-criteria, continuation pointer, and mergeable end state. Only Nami
24
+ creates it explicitly.
25
+
26
+ ## Dependency / write conflicts
27
+
28
+ Each slice's task index makes write-conflict groups explicit: tasks that write
29
+ the same file/area are never parallel. `[PARALLEL]` requires file- AND
30
+ interface-disjoint proof (shared CODEOWNERS area is a conflict). Speculative
31
+ parallelization is prohibited — every parallel set traces to an evidence-backed
32
+ dependency map.
33
+
34
+ ## Skill body rule
35
+
36
+ If body would exceed 120 lines, move checklist here; SKILL.md keeps one-line pointer.
37
+
38
+ ## Acceptance
39
+
40
+ - `grep -c "sub-plan" content/skills/mugiwara-planning/SKILL.md` ≥1
41
+ - `validate-content --check-manifest --check-docs` 0