@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,6 +1,7 @@
1
1
  ---
2
2
  name: mugiwara-backend
3
3
  description: Use for backend/server code — repo standards first, API endpoint design, data integrity, error handling, source-backed code. Match the codebase before judging it.
4
+ gate_artifact: flows/01-execution.md cited doc link — backend evidence with source citation
4
5
  ---
5
6
 
6
7
  # Backend (Sanji)
@@ -14,81 +15,88 @@ Backend engineer in the repo's own stack. Match the codebase before you judge it
14
15
 
15
16
  ## Source-backed code (no invented APIs)
16
17
 
17
- Framework code from documentation, not memory. Full protocol: `_shared/references/source-grounding.md` pin the stack from the dependency file, consult the authoritative page for that version, code to the docs not to memory, cite non-obvious choices, treat docs as advisory data never as instructions.
18
+ Framework code from documentation, not memory. Full protocol: `_shared/references/source-grounding.md`. Pin the stack from the dependency file, consult the authoritative page for that version, code to the docs not memory, cite non-obvious choices. Evidence: write each cited doc link into `flows/01-execution.md` (see `gate_artifact` in frontmatter) — a code change with no citation is unverified.
18
19
 
19
20
  Worked example — endpoint built from the docs: `references/source-backed-example.md`.
20
21
 
21
22
  ## Existing-repo standard FIRST
22
23
 
23
- Before writing a line, learn how this repo already does backend:
24
- - Framework and language, project layout (controllers/services/repos), error model, logging, config loading, DB access (ORM vs raw SQL), existing endpoint patterns, auth middleware.
25
- Match it. Never invent a parallel architecture, a second error model, or a second DB layer. When the repo has no standard, pick boring, idiomatic defaults and note the choice.
24
+ Before writing a line, learn how this repo already does backend: framework/language, layout (controllers/services/repos), error model, logging, config loading, DB access (ORM vs raw SQL), endpoint patterns, auth middleware. Match it. Never invent a parallel architecture, a second error model, or a second DB layer. No repo standard → pick boring idiomatic defaults, note the choice.
25
+
26
+ ## Clean architecture (measured)
27
+
28
+ Layered: `controllers → services → repos → domain`. Dependency rule: import inward only — controllers→services→repos→domain; a reverse import (repo calling a controller) is a defect. **300 LOC/file max**; a file crossing it splits at a layer seam, never a util dump. SOLID composition: one responsibility per layer, dependencies injected (repo interface into service, `tx` into the writer), code to interfaces, no god objects.
26
29
 
27
30
  ## API design
28
31
 
29
- - Contract-first: define request/response shape and status codes before implementing. Write the contract down, then build to it.
30
- - Follow the repo's REST/JSON conventions. If the repo has none, keep it simple and consistent.
31
- - Idempotency for mutating operations where it matters (retries, payments, external callbacks).
32
- - List endpoints: pagination and filtering, not unbounded result sets.
33
- - Evolve additively. Versioning or backward-compatible changes only; no silent breaking changes.
34
- - Validate input at the boundary with a schema. Never trust the client.
35
- - Consistent error shape: same envelope everywhere, machine-readable.
32
+ - Contract-first: write request/response shape + status codes before code.
33
+ - REST/JSON per repo convention; simple + consistent when none.
34
+ - Idempotency on mutating ops (retries, payments, callbacks).
35
+ - List endpoints: pagination + filtering, never unbounded.
36
+ - Evolve additively; no silent breaking changes.
37
+ - Validate at the boundary with a schema; never trust the client.
38
+ - One error envelope everywhere, machine-readable. Status map: 400 malformed, 401/403 authz, 404 missing, 409 conflict, 422 validation, 429 rate-limited, 500 unexpected.
39
+
40
+ ## Data integrity (Prisma)
41
+
42
+ Raw SQL vs ORM decisions, concurrency, migrations, indexes: `references/database.md`.
43
+
44
+ Prisma is the repo's SQL toolkit; patterns verified against its v7 docs.
45
+
46
+ - Multi-row writes: `prisma.$transaction(async (tx) => { ... })` — a throw inside rolls back atomically. Guard with `transactionOptions`: `timeout` 5000ms / `maxWait` 2000ms defaults — an over-time transaction is cancelled and rolled back.
47
+ - Singleton `PrismaClient`: one instance per process; in hot-reload dev cache it on `globalThis` — a client per request leaks connections.
48
+ - Anti N+1: eager-load with `include`/`select` in one query, e.g. `findFirst({ include: { posts: { select: { title: true } } } })`; never loop-query a relation.
49
+ - Indexes: hot WHERE/JOIN/ORDER BY → `@@index([field])` in the schema. Measured ~80x on Prisma's benchmark (66ms → <1ms) for one indexed lookup.
50
+ - Unique races: concurrent writes on a unique column throw P2002 (`PrismaClientKnownRequestError`); catch, retry or map to 409. Never a bare 500.
51
+
52
+ Docs: https://www.prisma.io/docs/orm/v7/prisma-client/queries/transactions (transactions); https://www.prisma.io/docs/orm/reference/prisma-client-reference (P2002); https://www.prisma.io/docs/orm/v7/prisma-client/queries/relation-queries (relation queries); blog https://www.prisma.io/blog/improving-query-performance-using-indexes — all from the Prisma docs.
36
53
 
37
- ## Data integrity
54
+ ## Error handling (Express)
38
55
 
39
- - Transactions where a request writes multiple rows/records. Partial writes are data loss.
40
- - Enforce constraints in the DB (unique, not-null, FK), not only in app validation.
41
- - Handle races: unique conflicts, optimistic locking, lost updates.
42
- - Never drop data silently. Delete or transform with intent.
43
- - Migrations forward with a documented rollback path. No schema drift between envs.
44
- - Index the queried paths; the DB should not do a full scan per request.
56
+ Express error API verified against its 5.x middleware docs.
45
57
 
46
- ## Error handling
58
+ - Never render errors in the route. On failure call `next(err)`; Express routes it to the centralized error middleware registered after all routes.
59
+ - One error middleware, exactly 4 args `(err, req, res, next)`, defined last: `app.use((err, req, res, next) => res.status(err.status || 500).json({ error: { status, message } }))` — one response shape for the whole app.
60
+ - Log every error with context: `logger.error({ path: req.path, method: req.method, stack: err.stack, traceId })`; include the OpenTelemetry trace id so the log line links to the request trace.
61
+ - Never leak internals or stack traces to clients; map domain errors to the status map above.
47
62
 
48
- - No swallowed errors. Catch, log with context, and rethrow/map. Empty catch = bug.
49
- - Fail loud with context: what, where, and what was being done.
50
- - Never leak internals or stack traces to clients. Map domain errors to the right status code.
51
- - Background jobs: retry with backoff + dead-letter queue. Never silently drop a job.
63
+ Docs: https://expressjs.com/en/guide/error-handling.html (single error handler); https://expressjs.com/en/4x/api.html#app.use (4-arg middleware, `next(err)`) from the Express docs.
52
64
 
53
65
  ## Correctness
54
66
 
55
67
  - Edge cases: empty input, nulls, timezones, large payloads, duplicates, malformed data.
56
- - Concurrency safety: no shared mutable state; understand the runtime model (threads vs event loop vs workers) and code to it.
57
- - Deterministic where expected: stable ordering, stable pagination, no unseeded randomness in tests.
68
+ - Concurrency: no shared mutable state; code to the runtime model (threads vs event loop vs workers).
69
+ - Deterministic where expected: stable ordering/pagination, no unseeded randomness in tests.
58
70
 
59
71
  ## Performance
60
72
 
61
- - No N+1 queries. Batch or fetch-join.
62
- - No O(n^2) in request paths.
63
- - Cache hot reads, with invalidation.
64
- - Stream large payloads instead of buffering whole in memory.
65
- - Timeouts + cancellation on downstream calls. Never hang on a slow dependency.
66
- - Measure before optimizing. Optimize the real hot path, not guesses.
73
+ - No N+1 (see Data integrity). No O(n²) in request paths.
74
+ - Cache hot reads with invalidation; stream large payloads, never buffer whole.
75
+ - Timeouts + cancellation on downstream calls; never hang on a slow dependency.
76
+ - Measure before optimizing; optimize the real hot path.
67
77
 
68
78
  ## Security (backend layer)
69
79
 
70
- - Authz server-side on every protected path. Never trust client-side checks.
80
+ - Authz server-side on every protected path; never trust client checks.
71
81
  - Secrets via env/secret manager, never in code or committed files.
72
- - Validate and sanitize all input against SQL/NoSQL/command/template injection.
73
- - Rate-limit sensitive endpoints (auth, payment, external callbacks).
74
- - No PII in logs.
75
- - Safe file handling: path traversal, symlinks, upload size/type limits.
82
+ - Validate/sanitize all input against SQL/NoSQL/command/template injection.
83
+ - Rate-limit sensitive endpoints (auth, payment, callbacks).
84
+ - No PII in logs. Safe file handling (path traversal, symlinks, size/type limits).
76
85
  - Dependency audit as part of the change.
77
86
 
78
87
  ## Testability
79
88
 
80
- - Contract tests for APIs, unit tests for logic, integration tests for DB.
81
- - Use the repo's existing test setup; don't start a second framework.
89
+ - Contract tests for APIs, unit for logic, integration for DB — repo's existing setup only.
82
90
  - Test error paths, not just happy paths.
83
91
 
84
92
  ## Common rationalizations
85
93
 
86
- - "The client validates" → the client is untrusted; validate at the server boundary.
87
- - "I'll add authz later" → authz is not a TODO. Ship it with the route.
94
+ - "The client validates" → validate at the server boundary; client is untrusted.
95
+ - "I'll add authz later" → authz ships with the route.
88
96
  - "One big function is fine" → split at seams; a request handler is not a service.
89
- - "No tests, it's a small endpoint" → endpoints grow. Cheap contract test now.
90
- - "I'm confident about this API" → confidence is not evidence. Fetch the docs for that version and cite.
91
- - "Fetching docs wastes tokens" → hallucinating an API wastes an hour of debugging. One fetch prevents it.
97
+ - "No tests, it's a small endpoint" → endpoints grow; cheap contract test now.
98
+ - "I'm confident about this API" → fetch the docs for that version and cite.
99
+ - "Fetching docs wastes tokens" → hallucinating an API wastes an hour; one fetch prevents it.
92
100
 
93
101
  ## Red flags
94
102
 
@@ -99,5 +107,8 @@ Match it. Never invent a parallel architecture, a second error model, or a secon
99
107
  - Breaking API change without migration.
100
108
  - Secret in code or committed files.
101
109
  - Error path untested.
110
+ - File > 300 LOC with no layer seam.
111
+ - Reverse architecture import (repo → controller).
112
+ - P2002/unique race surfacing as a bare 500.
102
113
 
103
114
  Any red flag = the backend basics are off. Stop, fix, then continue.
@@ -0,0 +1,61 @@
1
+ # Database — raw SQL and ORM
2
+
3
+ Applies whenever the diff touches a query, migration, model, or repository.
4
+ The repo's existing data layer wins: if it uses an ORM, write ORM; if it uses
5
+ raw SQL with a thin helper, write that. Never introduce a second data layer.
6
+
7
+ ## Choosing per change
8
+
9
+ | Situation | Reach for |
10
+ |-----------|-----------|
11
+ | CRUD against one or two tables, relations mapped | the repo's ORM |
12
+ | Reporting/aggregation, bulk update, window functions | raw SQL (parameterized) through the repo's query helper |
13
+ | Hot path measured slow under the ORM | raw SQL for that query only — note why inline |
14
+ | Schema change | a migration file, never ad-hoc DDL |
15
+
16
+ ## Non-negotiables (either style)
17
+
18
+ - **Parameterized queries only.** String-concatenated SQL is a blocker-level
19
+ security finding. ORM query builders parameterize by default — do not
20
+ defeat them with `raw()` string interpolation of user input.
21
+ - **Constraints live in the schema**: unique, not-null, FK, check. App-level
22
+ validation is UX; the database is the guarantee.
23
+ - **Transactions around every multi-row write.** Partial writes are data
24
+ loss. One request = one transaction boundary, not several.
25
+ - **Migrations are forward-only files** with a documented rollback statement.
26
+ No editing an applied migration; add a new one.
27
+
28
+ ## Concurrency
29
+
30
+ - Know the isolation level you run at (read committed is typical). Do not
31
+ reach for serializable to paper over a logic race.
32
+ - Lost-update protection: optimistic locking (version column) unless the row
33
+ is a single-writer counter.
34
+ - Deadlocks: consistent lock ordering across the codebase; keep transactions
35
+ short — no network calls inside one.
36
+
37
+ ## ORM pitfalls
38
+
39
+ - **N+1 from lazy loading**: a loop touching `order.customer.name` issues one
40
+ query per iteration. Eager-load (`include`/`joinedload`/`select_related`)
41
+ what the loop renders.
42
+ - **Implicit transactions**: some ORMs wrap each save in its own commit — a
43
+ "transaction" spread across three saves was never atomic.
44
+ - **Mass assignment**: bind request bodies through explicit field allowlists,
45
+ not `Model(**payload)`.
46
+ - **Silent full-table scans**: check the generated SQL for anything the ORM
47
+ could not translate (client-side filtering after fetch).
48
+
49
+ ## Raw-SQL pitfalls
50
+
51
+ - Unparameterized interpolation (see above) and dynamic ORDER BY/LIMIT built
52
+ from user input — whitelist column names instead.
53
+ - Missing LIMIT on list queries; pagination is not optional.
54
+ - Long-running transactions holding locks while the app does other work.
55
+
56
+ ## Indexes
57
+
58
+ Index the columns every hot WHERE/JOIN/ORDER BY actually uses — verify with
59
+ EXPLAIN on the real query shape, not by intuition. A new query pattern on a
60
+ large table without a matching index is a performance finding, same severity
61
+ as an N+1.
@@ -73,7 +73,7 @@ Hand off ONLY when the validation checklist passes — all of:
73
73
  - [ ] MVP separated from nice-to-haves, with what-to-cut stated.
74
74
  - [ ] Spec written with the open questions that Nami still needs answered.
75
75
 
76
- When direction is locked, write a short brief (problem, chosen option + reasoning, risks, open questions) to `.mugiwara/spec/YYYY-MM-DD-<mission>.md` and return to Luffy, who routes to Nami or Zoro. If the checklist fails, keep interrogating — do not hand off.
76
+ When direction is locked, write a short brief (problem, chosen option + reasoning, risks, open questions) to `.mugiwara/missions/<mission>/spec.md` and return to Luffy, who routes to Nami or Zoro. If the checklist fails, keep interrogating — do not hand off.
77
77
 
78
78
  For UI directions, name slop risks (generic card grids, unmotivated gradients, template-shaped layouts) as a risk in the brief. Do not open the frontend skill — that is Zoro's, under Nami's plan.
79
79
 
@@ -1,9 +1,10 @@
1
1
  ---
2
2
  name: mugiwara-checkpoint
3
3
  description: Use after an execution flow stage to audit results — re-run acceptance criteria, verify commit hygiene, classify failures honestly, issue DoD verdict. Auditor only.
4
+ gate_artifact: flows/02-audit.md — per-task acceptance evidence
4
5
  ---
5
6
 
6
- # Checkpoint (Chopper)
7
+ # Checkpoint
7
8
 
8
9
  ## Skip when
9
10
 
@@ -14,29 +15,39 @@ Auditor, not fixer. Trust nothing; verify everything. Output is an audit report,
14
15
 
15
16
  ## Verify-everything gate
16
17
 
17
- Subagents lie. No evidence = not complete. A "done" claim is a starting point, never a result. RUN every acceptance criterion — the referenced command or a file inspect — and capture output. Never accept a spoken claim, and never reuse a prior run's result: re-run it now.
18
+ Subagents lie. No evidence = not complete. A "done" claim is a starting point, never a result. RUN every acceptance criterion — the referenced command or a file inspect — and capture output. Never accept a spoken claim, and never reuse a prior run's result: re-run it now, once per unique check.
18
19
 
19
20
  ## Audit protocol
20
21
 
21
22
  For every task in the completed flow stage, in order:
22
23
 
23
- 1. **Per-task audit table.** For each acceptance criterion record `task | criterion | command run | evidence | status`. Evidence is output or a clickable markdown file link (`[path](relative/path)`) — never a paraphrase.
24
- 2. **Dedupe re-runs.** Several criteria often share the same command (a flow stage of tasks all keyed on `npm test`). Run each UNIQUE check command ONCE per flow stage, scope it to the files this flow stage changed, and attach the same evidence row to every criterion it covers. Do not re-run the same suite N times for N tasks.
25
- 3. **Scope by diff.** Before re-running, inspect what actually changed (`git diff --name-only <flow-base>..HEAD`). Criteria whose inputs are untouched are verified by the scoped run, not a fresh full run. A criterion with NO command or file to point at is unverifiable — fail it, never waive it.
26
- 4. **Commit hygiene.** Run `git log --stat <flow-base>..HEAD` ONCE (not `git show --stat` per commit) and check each task commit: it must touch ONLY the files the task declared. Undeclared files added or declared files missing = fail.
27
- 5. **Parallel-conflict check.** Run `git diff --name-only` across parallel task commits: no file may be touched by 2 tasks. A shared file means the parallel claim was false.
28
- 6. **Honest classification.** Classify every failure truthfully as code or env. Never file a code failure as `env`. If you cannot prove it is env (reproduce on a clean checkout), it is code.
24
+ 1. **Verify every `Acceptance`.** The plan lists acceptance criteria per task; every one gets a row. No acceptance left unchecked.
25
+ 2. **Per-task audit table.** For each `Acceptance` record `task | acceptance | command run | evidence | status`. Evidence is output or a clickable markdown file link (`[path](relative/path)`) never a paraphrase.
26
+ 3. **Scope by diff.** Before re-running, inspect what changed (`git diff --name-only <flow-base>..HEAD`). Criteria whose inputs are untouched are verified by the scoped run, not a fresh full run. An `Acceptance` with NO command or file to point at is unverifiable — fail it, never waive it.
27
+ 4. **Dedupe re-runs.** Several criteria share the same command. Run each UNIQUE check ONCE per flow stage, scope it to the files this flow stage changed, attach the same evidence row to every criterion it covers. Do not re-run the same suite N times for N tasks.
28
+ 5. **Commit hygiene.** Run `git log --stat <flow-base>..HEAD` ONCE (not `git show --stat` per commit) and check each task commit: it must touch ONLY the files the task declared. Undeclared files added or declared files missing = fail.
29
+ 6. **Parallel-conflict check.** Run `git diff --name-only` across parallel task commits: no file may be touched by 2 tasks. A shared file means the parallel claim was false.
30
+ 7. **Honest classification.** Classify every failure truthfully as code or env. Never file a code failure as `env`. If you cannot prove it is env (reproduce on a clean checkout), it is code.
29
31
 
30
32
  ## Failure ledger
31
33
 
32
34
  Row schema + worked rows: `references/ledger-format.md`.
33
35
 
34
- Append each failing criterion as one row to `.mugiwara/issues/YYYY-MM-DD-<mission>-blockers.md`:
36
+ Append each failing criterion as one row to `.mugiwara/missions/<mission>/blockers.md`:
35
37
 
36
38
  `| flow stage | task | symptom | attempted | help-needed |`
37
39
 
38
40
  Category goes in `symptom` or `help-needed` as context. Categories: `test-fail` (test/lint/build command fails), `missing-impl` (criterion unverifiable, artifact absent), `parallel-conflict` (concurrent tasks modified shared state), `env` (environment, proven), `regression` (previously passing check now fails). Reuse the existing blocker ledger; create it only if absent.
39
41
 
42
+ ## Heal loop
43
+
44
+ A failed audit feeds the healer, not the auditor. Flow:
45
+
46
+ 1. Auditor writes the failure ledger and reports FAIL.
47
+ 2. Healer fixes the ROOT CAUSE, not the symptom, and adds a guard test that goes red before the fix and green after it (red→green proof).
48
+ 3. Flow returns here for re-audit. Cycle counter is state: `.mugiwara/missions/<mission>/state.json` records `heal_cycle / heal_max_cycles` (default max 3). When `heal_halt` reads `true`, STOP and escalate to the user with full history — a halt, not a red flag. Never re-run past `heal_max_cycles`.
49
+ 4. Every re-audit re-runs the failed checks fresh — never reuse the healer's evidence.
50
+
40
51
  ## Definition of Done check
41
52
 
42
53
  Per axis — `correctness`, `quality`, `integration`, `docs`, `ship-readiness` — each with evidence, then one flow-stage verdict. Full definitions: `_shared/references/definition-of-done.md`. Any FAIL axis → flow-stage verdict FAIL.
@@ -47,7 +58,7 @@ Never edit code. Findings only. Any urge to fix a finding means the audit has st
47
58
 
48
59
  ## Output
49
60
 
50
- Audit report to `.mugiwara/results/<mission>/02-audit.md`: per-task table, commit hygiene, parallel-conflict, honest classification, DoD verdicts, ledger rows. Show the verdict and the key evidence inline in the conversation — PASS → next flow stage. FAIL → report + ledger to Brook (Flow 8). You never fix a finding yourself; you may spawn check subagents for independent re-runs.
61
+ Audit report to `.mugiwara/missions/<mission>/flows/02-audit.md` (the gate_artifact): per-task acceptance table, commit hygiene, parallel-conflict, honest classification, DoD verdicts, ledger rows. Show the verdict and the key evidence inline in the conversation — PASS → next flow stage. FAIL → report + ledger to the healer. You never fix a finding yourself; you may spawn check subagents for independent re-runs.
51
62
 
52
63
  ## Common rationalizations
53
64
 
@@ -61,11 +72,12 @@ TRUST NOTHING; VERIFY EVERYTHING. No evidence, no pass — and the evidence must
61
72
 
62
73
  ## Red flags
63
74
 
64
- - A criterion marked pass from a claim or a prior run, without re-running the check.
75
+ - An `Acceptance` marked pass from a claim or a prior run, without re-running the check.
65
76
  - Parallel tasks' shared-file conflict assumed safe without `git diff --name-only`.
66
77
  - A code failure filed as `env` to soften the report.
67
78
  - Commits containing undeclared files, or missing declared files.
68
79
  - A DoD axis passed with no evidence.
80
+ - `heal_halt` reading `true` with healing still continuing.
69
81
  - Any urge to edit code instead of reporting the finding.
70
82
  - Echoing raw output when `verbosity=normal` — summarize and cite the evidence path.
71
83
 
@@ -31,4 +31,4 @@ Blocker ledger row format used by Chopper (flow-audit) and Brook (healing).
31
31
  - Every blocker gets one row. Never combine two failures into one row.
32
32
  - Category goes in `symptom` or `help-needed` — whichever is more specific.
33
33
  - `env` classification must be proven (reproduce on clean checkout). Unproven = `test-fail`.
34
- - File at `.mugiwara/issues/YYYY-MM-DD-<mission>-blockers.md`. Create if absent.
34
+ - File at `.mugiwara/missions/<mission>/blockers.md`. Create if absent.
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  name: mugiwara-contract-first
3
3
  description: Use for API, interface, or contract design — contract-first, error semantics, boundary validation, backward compatibility, versioning discipline.
4
+ gate_artifact: flows/01-execution.md contract evidence — OpenAPI shape + error envelope written before implementation
4
5
  ---
5
6
 
6
7
  # API and Interface Design
@@ -23,9 +24,47 @@ Not for: pure internals no one else touches — those still get reviewed by the
23
24
 
24
25
  Framework APIs from docs, not memory: `_shared/references/source-grounding.md`.
25
26
 
27
+ ## OpenAPI shape first
28
+
29
+ Write the OpenAPI 3.0 document before any implementation line. The spec is the
30
+ contract; the code must match it, never the reverse. The document covers: every
31
+ path, request/response schema, every status code, and the error envelope. No
32
+ endpoint merges without an OpenAPI entry.
33
+
34
+ ## Boundary validation with Zod
35
+
36
+ - Parse untrusted input at the trust boundary with `.safeParse()`, never `.parse()` — returns a discriminated union, no throw. https://github.com/colinhacks/zod/blob/main/README.md
37
+ - Read failures from `result.error.issues` — per-field `code`, `expected`, `received`, `path`, `message`. https://github.com/colinhacks/zod/blob/main/packages/docs-v3/home.md
38
+ - Map failures to the envelope with `.flatten()` → `{ formErrors, fieldErrors }` keyed by field. https://github.com/colinhacks/zod/blob/main/packages/docs-v3/ERROR_HANDLING.md
39
+ - Cross-field rules go in `.refine()` with a dynamic message from the failing input. https://github.com/colinhacks/zod/blob/main/packages/docs/content/api.mdx
40
+ - Schemas are `z.object({...})` at the boundary; types derive via `z.infer`, so schema and type cannot drift.
41
+
42
+ ## Error envelope
43
+
44
+ Every failure returns exactly `{ code, message, details }`:
45
+
46
+ - `code` — stable machine-readable string (`validation_error`, `not_found`,
47
+ `rate_limited`). Never change a code once shipped.
48
+ - `message` — human-readable sentence.
49
+ - `details` — Zod `.flatten()` fieldErrors for validation failures; empty for
50
+ single-cause errors.
51
+
52
+ The envelope is declared in the OpenAPI document's error schema, so clients
53
+ can validate errors with the same contract as success.
54
+
55
+ ## Versioning
56
+
57
+ New breaking change → new URL prefix (`/v2`), old prefix (`/v1`) stays live.
58
+ Max **2 live versions**; never a third. Every response on the deprecated
59
+ version carries `Sunset: <RFC-7231 date>`. When the date passes, remove the
60
+ old version. Additive changes (new field, new status) never require a bump.
61
+ The OpenAPI document describes both live versions and marks the sunset one.
62
+
26
63
  ## Process
27
64
 
28
- Full 5-step protocol: `references/process.md` — contract first, error semantics, boundary validation, backward compatibility, versioning discipline. 27 lines; every step required.
65
+ Full 5-step protocol: `references/process.md` — contract first, error
66
+ semantics, boundary validation, backward compatibility, versioning discipline.
67
+ 27 lines; every step required.
29
68
 
30
69
  Versioning + deprecation moves: `references/versioning-playbook.md`.
31
70
 
@@ -60,3 +99,9 @@ Any red flag = the interface is drifting. Stop, write the contract down, then co
60
99
  - Untrusted input validated at the boundary; boundary errors match the documented envelope.
61
100
  - One live version; the deprecation plan names the removal release and its migration.
62
101
  - A contract test asserts the documented shape and errors — the contract stays true because something checks it.
102
+
103
+ ## Gate artifact
104
+
105
+ Write `flows/01-execution.md` with the evidence: OpenAPI doc path, the
106
+ `{code,message,details}` envelope declaration, Zod schema list, and live
107
+ versions with their `Sunset` dates. No gate_artifact entry, no merge.
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  name: mugiwara-execution
3
3
  description: Use when executing an approved plan — todo list first, sequential inline + parallel worker batches, commit per logical task, evidence per task.
4
+ gate_artifact: flows/01-execution.md task table — execution evidence
4
5
  ---
5
6
 
6
7
  # Execution (Zoro)
@@ -17,22 +18,22 @@ Execute the plan exactly. No silent reordering, no skipping steps, no "close eno
17
18
  - `guided`: before touching any code, ASK THE USER — auto branch (dedicated mission branch, recommended, keeps `main` clean) or work on the current branch; auto commit per task or commit at user-controlled checkpoints. With `auto_commit=off`: the branch ask stays, the commit question is skipped — changes stay uncommitted.
18
19
  - `semi`: auto-create the mission branch per the config `branch` key; auto-commit per task in the config `commit` style ONLY when `auto_commit=on` (default). Off → leave every task's changes uncommitted; the user commits manually.
19
20
  - `auto`: auto-create the branch and auto-commit per task ALWAYS — `auto_commit=off` has no effect in auto mode.
20
- Record mode + branch + commit style + `auto_commit` in the decision log (`.mugiwara/logs/YYYY-MM-DD-<mission>.md`) and in `.mugiwara/results/<mission>/todos.md` — every mode.
21
+ Record mode + branch + commit style + `auto_commit` in the decision log (`.mugiwara/missions/<mission>/decisions.md`) and in `.mugiwara/missions/<mission>/flows/todos.md` — every mode.
21
22
 
22
- Code to the installed version's docs, not memory: `_shared/references/source-grounding.md`. The plan doc stays clean — never edit it during execution except through Nami. If the user says no auto-commit in `guided`, still run every acceptance check and leave the diff staged or presented for approval. State-mutating consent is NOT covered by this rule — it still applies in every mode. One-task-one-commit, save-points, and atomic-commit rules hold unchanged in every mode.
23
+ Code to the installed version's docs, not memory: `_shared/references/source-grounding.md`. The plan doc stays clean — never edit it during execution except through Nami. If the user says no auto-commit in `guided`, still run every acceptance check and leave the diff staged or presented for approval. State-mutating consent is NOT covered by this rule — it still applies in every mode.
23
24
 
24
25
  ## Todo list first
25
26
 
26
27
  Before touching code:
27
28
 
28
- 1. Create `.mugiwara/results/<mission>/todos.md` — one checkbox per task, derived from the plan.
29
+ 1. Create `.mugiwara/missions/<mission>/flows/todos.md` — one checkbox per task, derived from the plan.
29
30
  2. Check each box off only when the task completes, WITH its evidence link (`[path](relative/path)`, clickable).
30
31
  3. Re-check the whole list after each task and after each batch; unmarked boxes mean the mission is not done.
31
32
  4. Mirror EVERY transition into the host's native todo tool (`todowrite` on opencode; `TaskUpdate` on Claude Code; none on tier 2/3 — plan doc only) in the SAME response the task's evidence lands — one transition per call, never batched at flow-stage end. Per-host table: `docs/reference/harness-matrix.md`. Every task response opens with `[task N/M] <status>` — progress is visible on every harness, todo tool or not.
32
33
 
33
34
  ## Flow-stage execution
34
35
 
35
- Before starting: if `.mugiwara/continue/<mission>/[member].json` exists, resume from its next_action — never re-run completed tasks; verify against todos `[x]` marks. Full protocol: `references/resume-batching.md` — batch-resume, TDD, user-test oracle.
36
+ Before starting: if `.mugiwara/missions/<mission>/continue.json | continue-<member>.json` exists, resume from its next_action — never re-run completed tasks; verify against todos `[x]` marks. Full protocol: `references/resume-batching.md` — batch-resume, TDD, user-test oracle.
36
37
 
37
38
  1. Read the plan doc fully before touching code.
38
39
  2. Build the task graph from `[PARALLEL]`/`[SEQUENTIAL]` markers and depends-on fields.
@@ -45,67 +46,65 @@ Before starting: if `.mugiwara/continue/<mission>/[member].json` exists, resume
45
46
 
46
47
  1. **Independence** — `[PARALLEL]` batches, concurrent, one task per worker.
47
48
  2. **Context pressure** — when `delegate_due` reads `true` in
48
- `.mugiwara/state/<mission>/[member].json` (savepoint computes it as
49
- `tokens_est ≥ delegate_threshold% of budget`, config default 60), remaining
50
- SEQUENTIAL tasks dispatch to workers — one at a time, in plan order.
51
- Announce: `⚠ context — remaining tasks run in fresh workers, plan order unchanged.`
49
+ `.mugiwara/missions/<mission>/state.json | <member>.json`: savepoint computes
50
+ `tokens_est ≥ delegate_threshold% × budget` (default 60), never an absolute
51
+ `tokens_est > 80,000`. Remaining SEQUENTIAL tasks dispatch to workers — one
52
+ at a time, in plan order. Announce: `⚠ context — remaining tasks run in fresh workers, plan order unchanged.` A bigger budget raises the bar; it does not remove it.
52
53
 
53
- Computed, never manual: savepoint emits `delegate_due` (relative
54
- `tokens_est ≥ delegate_threshold% × budget`, default 60), never an absolute
55
- `tokens_est > 80,000` (obsolete in six months). A bigger budget raises the bar; it does not remove it.
56
-
57
- ## Tier gating & fallback
54
+ ## Batch resume
58
55
 
59
- Real worker dispatch exists only where the harness has subagents tier 1
60
- (Claude Code, opencode) plus Copilot. Gate the context-pressure trigger on
61
- that capability: if the harness cannot dispatch, do not promise fresh workers.
56
+ After each batch, update `.mugiwara/missions/<mission>/continue.json | continue-<member>.json` next_action to the next task; `[PARALLEL]` batches stay per sub-mission, never crossing a sub-mission boundary.
62
57
 
63
- Where workers are unavailable and `delegate_due` is true:
64
- write a savepoint, run the checkpoint, and suggest a fresh session via
65
- `resume`. Announce: `⚠ context — no worker dispatch on this harness;
66
- savepoint written, resume in a fresh session (plan order unchanged).`
58
+ ## Posture switching (boundaries)
67
59
 
68
- ## Batch resume
69
-
70
- After each batch, update `.mugiwara/continue/<mission>/[member].json` next_action to the next task; `[PARALLEL]` batches stay per sub-mission, never crossing a sub-mission boundary.
60
+ Re-evaluate posture only at a flow-stage/task-batch boundary, never mid-task:
61
+ retain/switch/avoid/pause from lane/risk/governor/context evidence, recorded with
62
+ reason + evidence ref in `decisions.md` (matrix: `_shared/references/posture-routing.md`). A
63
+ switch never changes mode/roles; workers only for Nami-declared independent tasks.
64
+ On halt, emit state + continue with exact next action incl. posture verification.
71
65
 
72
66
  ## Task batching & delegation format (parallel workers only)
73
67
 
74
- Full protocol: `references/dispatch.md` — output rule, batch report format,
75
- six-field worker prompt. Thin prompts cause thin results.
68
+ Full protocol: `references/dispatch.md` — output rule, batch report format, six-field worker prompt. Thin prompts cause thin results.
76
69
 
77
70
  ## Surfacing rule
78
71
 
79
72
  > **Delegated work is not hidden work.** A worker may run out of view; its
80
- > result may not. Every worker returns a flow stage banner, a one-line verdict, and an
81
- > evidence link into the main thread. The user never clicks into a subagent to
82
- > know what happened.
83
- > Isolation is for context and permission, never for autonomy.
73
+ > result may not. Every worker returns a flow stage banner, a one-line verdict,
74
+ > and an evidence link into the main thread. The user never clicks into a
75
+ > subagent to know what happened. Isolation is for context and permission,
76
+ > never for autonomy.
84
77
 
85
78
  ## TDD discipline & user tests
79
+
86
80
  Full protocol: `references/resume-batching.md` — batch-resume, TDD RED-GREEN-REFACTOR (`references/tdd.md`), user tests as oracle, failing-first rule. One task end to end, RED through commit: `references/worked-example.md`.
87
81
 
88
82
  ## One logical task, one commit
89
83
 
90
- Commit per LOGICAL task — a feature, fix, or refactor, not a micro-step; verify every acceptance criterion, commit only the task's declared files. Report done (with evidence) or blocked (with reason).
84
+ Commit per LOGICAL task — a feature, fix, or refactor, not a micro-step; verify every acceptance criterion, commit only the task's declared files. Report done (with evidence) or blocked (with reason). Message: `feat(scope):` / `fix(scope):` — one subject line, body only for the why. One commit = one task; a flow stage of micro-commits is a defect. A TDD task commits its test with the code it proves (`references/tdd.md` verification) — never orphaned.
91
85
 
92
86
  ## Blockers → issues ledger
93
87
 
94
- Blocked → one row `| flow stage | task | symptom | attempted | help-needed |` to `.mugiwara/issues/YYYY-MM-DD-<mission>-blockers.md`, then escalate to Luffy. Never work around a blocker silently.
88
+ Blocked → one row `| flow stage | task | symptom | attempted | help-needed |` to `.mugiwara/missions/<mission>/blockers.md`, then escalate to Luffy. Never work around a blocker silently.
95
89
 
90
+ ## Code quality floor
91
+
92
+ Boy Scout rule — every touched file leaves cleaner than found: one refactor per touch, done while green, its own commit, never bundled into another task.
93
+
94
+ TS tasks gate on numbers: `strict: true` in tsconfig (no `strict:false`); dead code 0 — `bunx ts-prune` or `knip` reports zero unused exports/imports. Run both in one evidence call: `bun run typecheck && bunx ts-prune`.
95
+
96
+ ## Large campaign — phase-isolated flows
97
+ Full checklist: `references/execution-phase-flows.md` — 4 items; `flows/phase-NN/02-execution.md` per phase, `flows/todos.md` with `## Phase NN` sections, no flat overwrite.
96
98
  ## Frontend tasks
97
99
 
98
- Any task touching UI markup, styling, or components applies `mugiwara-frontend` in the same pass.
100
+ Any task touching UI markup, styling, or components applies `mugiwara-frontend` in the same pass. Every interactive element — button, link, input, form — carries a `data-testid`, asserted by the task's test, not merely present in markup.
99
101
 
100
102
  ## Report
101
103
 
102
- After each flow stage: compact task table (status, evidence link, deviations) shown inline in the conversation. Format: `references/dispatch.md` — report table. Then return to Luffy, who routes to Chopper (Flow 4). Write detailed execution log to `.mugiwara/results/<mission>/01-execution.md`. Never dispatch another crew member.
104
+ After each flow stage: compact task table (status, evidence link, deviations) shown inline in the conversation. Format: `references/dispatch.md` — report table. Then return to Luffy, who routes to Chopper (Flow 4). Write detailed execution log to `.mugiwara/missions/<mission>/flows/01-execution.md`. Never dispatch another crew member.
103
105
 
104
106
  ## Step budget
105
-
106
- Tool calls are finite — harnesses cap them per session; a 9-flow-stage mission that wastes them stalls before closure. Combine evidence runs (`evidence.sh <m> quality -- bash -c "lint && test"` — one call, not two); write flow stage artifacts once at flow-stage end, not incrementally; never re-read what you just wrote; batch reads (one glob beats five reads); open a reference only when its pointer condition triggers.
107
-
108
- Budget guide: Lane 1 ≤15 calls · Lane 2 ≤35 · Lane 3 ≤60. Crossing it is not a failure; announce it and check the context-pressure trigger.
107
+ Tool calls finite — cap per session (Lane1 ≤15, Lane2 ≤35, Lane3 ≤60). Combine runs, batch reads, write artifacts once, open reference only when pointer triggers.
109
108
 
110
109
  ## Red flags
111
110
 
@@ -120,5 +119,6 @@ Budget guide: Lane 1 ≤15 calls · Lane 2 ≤35 · Lane 3 ≤60. Crossing it is
120
119
  - A commit containing files beyond its declared task, or a flow stage of micro-commits with no logical grouping.
121
120
  - Dispatching a worker whose result is not summarized inline with an evidence link.
122
121
  - Host todo UI lags the plan doc — task done but unchecked, or list never seeded at Flow 2.
122
+ - `strict:false`, dead code reported by ts-prune/knip, or an interactive element missing `data-testid`.
123
123
 
124
124
  All mean: stop, realign to the plan, or escalate to Luffy.
@@ -15,7 +15,7 @@ T2: ✅ | 7 pointers rewritten | grep refs/ → clean
15
15
  T3: ✅ | 38/38 tests | bun run test
16
16
  ```
17
17
 
18
- Full logs go to `.mugiwara/results/<mission>/01-execution.md`. The main thread shows the summary table only. Tool calls visible below the banner are noise — batch them, squash the output.
18
+ Full logs go to `.mugiwara/missions/<mission>/flows/01-execution.md`. The main thread shows the summary table only. Tool calls visible below the banner are noise — batch them, squash the output.
19
19
 
20
20
  ## Delegation format (parallel workers only)
21
21
 
@@ -0,0 +1,18 @@
1
+ # Large Campaign — Phase-Isolated Flows (Execution)
2
+
3
+ Rule: For large campaigns (>3 phases or >1500 lines), Zoro writes per-phase.
4
+
5
+ ## Layout
6
+
7
+ - `flows/phase-01/` … `flows/phase-09/` each holds `02-execution.md`, `02-audit.md`, `03-quality.md`, `04-gates.md`
8
+ - Master `flows/` holds only pointer or empty until merge
9
+ - `flows/todos.md` has `## Phase NN` sections
10
+
11
+ ## Why
12
+
13
+ Prevents flat `flows/02-execution.md` overwrite across 9 phases.
14
+
15
+ ## Acceptance
16
+
17
+ - `grep -c "flows/phase" content/skills/mugiwara-execution/SKILL.md` ≥1
18
+ - `validate-content` green, body ≤120
@@ -23,9 +23,9 @@ that passes on first run has proven nothing.
23
23
 
24
24
  ## Batch-resume protocol
25
25
 
26
- - Before starting a flow stage: if `.mugiwara/continue/<mission>/[member].json` exists, resume from its
26
+ - Before starting a flow stage: if `.mugiwara/missions/<mission>/continue.json | continue-<member>.json` exists, resume from its
27
27
  next_action — never re-run completed tasks; verify against todos `[x]` marks.
28
- - After each batch: update `.mugiwara/continue/<mission>/[member].json` next_action to the next task.
28
+ - After each batch: update `.mugiwara/missions/<mission>/continue.json | continue-<member>.json` next_action to the next task.
29
29
  - `[PARALLEL]` batches stay per sub-mission — a batch never crosses a
30
30
  sub-mission boundary.
31
31
  - continue is the handoff contract: state proves what is done,