@ionivetech/mugiwara 0.3.0 → 0.5.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.
- package/.opencode/commands/mugiwara-plan.md +4 -0
- package/README.md +214 -418
- package/content/agents/brook-healing.md +2 -2
- package/content/agents/chopper-checkpoint.md +2 -1
- package/content/agents/eval-runner.md +4 -4
- package/content/agents/franky-gates.md +1 -1
- package/content/agents/jinbe-security.md +2 -1
- package/content/agents/luffy-orchestrator.md +3 -3
- package/content/agents/memory-keeper.md +1 -1
- package/content/agents/nami-planner.md +2 -2
- package/content/agents/resume-coordinator.md +8 -9
- package/content/agents/robin-reviewer.md +3 -2
- package/content/agents/sanji-quality.md +1 -1
- package/content/agents/skeptic-verifier.md +4 -3
- package/content/agents/using-mugiwara.md +3 -3
- package/content/agents/usopp-brainstorm.md +3 -3
- package/content/agents/zoro-execution.md +4 -3
- package/content/skills/mugiwara-agent-security/SKILL.md +19 -2
- package/content/skills/mugiwara-backend/SKILL.md +7 -8
- package/content/skills/mugiwara-backend/references/source-backed-example.md +77 -0
- package/content/skills/mugiwara-brainstorm/SKILL.md +7 -2
- package/content/skills/mugiwara-checkpoint/SKILL.md +7 -2
- package/content/skills/mugiwara-checkpoint/references/ledger-format.md +34 -0
- package/content/skills/{mugiwara-doubt-driven-development → mugiwara-claim-audit}/SKILL.md +7 -2
- package/content/skills/{mugiwara-context-engineering → mugiwara-context-budget}/SKILL.md +7 -2
- package/content/skills/mugiwara-context-budget/references/context-budget.md +37 -0
- package/content/skills/{mugiwara-api-and-interface-design → mugiwara-contract-first}/SKILL.md +9 -2
- package/content/skills/mugiwara-contract-first/references/versioning-playbook.md +36 -0
- package/content/skills/mugiwara-execution/SKILL.md +9 -2
- package/content/skills/mugiwara-execution/references/worked-example.md +88 -0
- package/content/skills/mugiwara-frontend/SKILL.md +21 -22
- package/content/skills/mugiwara-frontend/references/design-tokens.md +25 -0
- package/content/skills/mugiwara-frontend/references/slop-catalog.md +19 -0
- package/content/skills/mugiwara-gates/SKILL.md +9 -4
- package/content/skills/mugiwara-git/SKILL.md +6 -1
- package/content/skills/mugiwara-healing/SKILL.md +39 -7
- package/content/skills/mugiwara-healing/references/failure-taxonomy.md +23 -0
- package/content/skills/mugiwara-lessons/SKILL.md +6 -1
- package/content/skills/mugiwara-orchestration/SKILL.md +18 -5
- package/content/skills/mugiwara-planning/SKILL.md +16 -15
- package/content/skills/mugiwara-planning/references/anti-patterns.md +17 -0
- package/content/skills/mugiwara-planning/references/plan-template.md +46 -0
- package/content/skills/mugiwara-pr/SKILL.md +6 -1
- package/content/skills/{mugiwara-test-driven-development → mugiwara-proof-order}/SKILL.md +7 -2
- package/content/skills/mugiwara-proof-order/references/proof-order-examples.md +62 -0
- package/content/skills/mugiwara-quality/SKILL.md +8 -3
- package/content/skills/mugiwara-resume/SKILL.md +46 -30
- package/content/skills/mugiwara-review/SKILL.md +6 -1
- package/content/skills/mugiwara-review/references/five-axis-worksheet.md +36 -0
- package/content/skills/mugiwara-review/references/severity-rubric.md +20 -0
- package/content/skills/{mugiwara-systematic-debugging → mugiwara-root-cause}/SKILL.md +9 -2
- package/content/skills/mugiwara-root-cause/references/four-phase-worked.md +71 -0
- package/content/skills/mugiwara-security/SKILL.md +18 -18
- package/content/skills/mugiwara-security/references/owasp-mapping.md +30 -0
- package/content/skills/mugiwara-security/references/stride-worksheet.md +37 -0
- package/content/skills/mugiwara-ship/SKILL.md +6 -1
- package/content/skills/{mugiwara-deprecation → mugiwara-sunset}/SKILL.md +7 -2
- package/content/skills/mugiwara-testcases/SKILL.md +6 -1
- package/content/skills/mugiwara-testcases/references/intake-formats.md +42 -0
- package/content/skills/mugiwara-workflow/SKILL.md +26 -24
- package/dist/mugiwara.js +165 -28
- package/docs/adoption-guide.md +2 -2
- package/docs/agents.md +2 -2
- package/docs/audit-trail.md +65 -0
- package/docs/comparison.md +58 -63
- package/docs/compliance-matrix.md +81 -0
- package/docs/config.md +7 -2
- package/docs/cost.md +45 -0
- package/docs/developer-onboarding.md +17 -13
- package/docs/enforcement.md +35 -0
- package/docs/getting-started.md +103 -41
- package/docs/harness-matrix.md +41 -0
- package/docs/index.md +11 -5
- package/docs/lanes.md +82 -0
- package/docs/skill-anatomy.md +42 -49
- package/docs/skills.md +36 -54
- package/docs/troubleshooting.md +91 -0
- package/docs/workflow.md +15 -6
- package/evals/cases/adversarial-pressure-fake-pass.json +12 -0
- package/evals/cases/adversarial-pressure-skip-review.json +13 -0
- package/evals/cases/lane-exploratory-vague.json +12 -0
- package/evals/cases/lane-sensitivity-payment.json +12 -0
- package/evals/cases/negative-secrets-typo.json +12 -0
- package/evals/cases/negative-security-docs-change.json +12 -0
- package/evals/cases/positive-refactor-existing-tests.json +11 -0
- package/evals/cases/positive-resume-mid-mission.json +11 -0
- package/evals/cases/routing-auth-feature.json +13 -0
- package/evals/cases/routing-bug-one-file.json +13 -0
- package/evals/cases/routing-typo.json +13 -0
- package/package.json +6 -4
- package/references/definition-of-done.md +42 -0
- package/references/multi-actor.md +44 -0
- package/references/skill-versioning.md +44 -0
- package/references/source-grounding.md +23 -0
- package/references/token-budget.md +34 -0
- package/scripts/evidence.sh +37 -0
- package/scripts/lane.sh +74 -0
- package/scripts/mission-report.sh +88 -0
- package/scripts/release-notes.ts +65 -0
- package/scripts/retrieval-eval.ts +152 -0
- package/scripts/run-evals.ts +113 -0
- package/scripts/savepoint.sh +165 -0
- package/scripts/sync-version.ts +30 -0
- package/scripts/validate-content.ts +226 -0
- package/src/args.ts +2 -1
- package/src/cli.ts +21 -20
- package/src/installer.ts +31 -3
- package/src/mission.ts +48 -0
- package/src/targets/claude.ts +4 -0
- package/src/targets/copilot.ts +4 -0
- package/src/targets/generic.ts +33 -1
- package/src/targets/kilo.ts +1 -0
- package/src/targets/opencode.ts +4 -0
- package/content/skills/mugiwara-dynamic-workflow/SKILL.md +0 -85
- package/content/skills/mugiwara-eval/SKILL.md +0 -82
- package/content/skills/mugiwara-git-worktrees/SKILL.md +0 -62
- package/content/skills/mugiwara-mode/SKILL.md +0 -72
- package/content/skills/mugiwara-observability/SKILL.md +0 -54
- package/content/skills/mugiwara-writing-skills/SKILL.md +0 -60
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Plan Template
|
|
2
|
+
|
|
3
|
+
Scaled plan skeleton. Nami picks Quick/Standard/Full based on mission size.
|
|
4
|
+
|
|
5
|
+
## Quick (1 task, ≤2 files)
|
|
6
|
+
|
|
7
|
+
```markdown
|
|
8
|
+
# <mission> — <goal>
|
|
9
|
+
|
|
10
|
+
## Key decisions
|
|
11
|
+
<why this approach>
|
|
12
|
+
|
|
13
|
+
## Waves
|
|
14
|
+
|
|
15
|
+
| Wave | Focus | Tasks | Gate |
|
|
16
|
+
|------|-------|-------|------|
|
|
17
|
+
| 3 | <what> | T1 | <command-verifiable exit check> |
|
|
18
|
+
|
|
19
|
+
## Task index
|
|
20
|
+
|
|
21
|
+
| # | Task | Files | Size | Depends-on | Acceptance |
|
|
22
|
+
|---|------|-------|------|------------|------------|
|
|
23
|
+
| T1 | <title> | <paths> | S | — | <one-line check> |
|
|
24
|
+
|
|
25
|
+
## Detail: T1 — <title>
|
|
26
|
+
- Files: <exact paths>
|
|
27
|
+
- Steps: [ ] <test → impl → verify>
|
|
28
|
+
- Acceptance: <command>
|
|
29
|
+
- Risk: none
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Standard (1 wave, 2-8 tasks)
|
|
33
|
+
|
|
34
|
+
Add: Architecture overview, Context scan, Implementation graph, Acceptance per task.
|
|
35
|
+
|
|
36
|
+
## Full (multi-wave, parallel, risk)
|
|
37
|
+
|
|
38
|
+
Add all of Standard + Key decisions, Project structure, Risk & rollback, Definition of Done.
|
|
39
|
+
|
|
40
|
+
## Anti-patterns to avoid
|
|
41
|
+
|
|
42
|
+
- "TBD" or "add appropriate error handling" in a step.
|
|
43
|
+
- No file paths, or Acceptance like "works correctly" (uncheckable).
|
|
44
|
+
- `[PARALLEL]` without file- AND interface-disjoint proof.
|
|
45
|
+
- High-risk task with no rollback plan.
|
|
46
|
+
- Vague plan expecting the executor to figure it out.
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: mugiwara-pr
|
|
3
|
-
description: Use at closure to push
|
|
3
|
+
description: Use at closure to push branch + prepare PR material — plain git push, verdict file with ready PR summary. Never creates PR, merges, or deploys.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# PR Handoff (CI/CD Loop)
|
|
7
7
|
|
|
8
|
+
## Skip when
|
|
9
|
+
|
|
10
|
+
- Not at closure: PR material is terminal-step-only, never per-wave.
|
|
11
|
+
- User handles the PR themselves and declined the verdict file.
|
|
12
|
+
|
|
8
13
|
Mugiwara's evidence lands where the team reviews. At terminal, push the mission branch with plain `git` and write one structured verdict file. No PR is created by the crew — the user opens the PR and pastes the ready PR summary. Never per-wave.
|
|
9
14
|
|
|
10
15
|
## Verdict file
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
---
|
|
2
|
-
name: mugiwara-
|
|
3
|
-
description: Use when writing code
|
|
2
|
+
name: mugiwara-proof-order
|
|
3
|
+
description: Use when writing code — RED-GREEN-REFACTOR. Proof value from WHEN the test runs, not that it exists. One test = one behavior.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Test-Driven Development
|
|
7
7
|
|
|
8
|
+
## Skip when
|
|
9
|
+
|
|
10
|
+
- No production code written: docs, config, or pure dependency bump.
|
|
11
|
+
- Refactor already fully covered by existing passing tests (record the reason).
|
|
12
|
+
|
|
8
13
|
A test proves nothing by existing. It proves nothing by passing. Its entire value lives in WHEN it runs and HOW it fails. TDD is the discipline that makes that proof real.
|
|
9
14
|
|
|
10
15
|
## When to use
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# Proof Order Examples
|
|
2
|
+
|
|
3
|
+
The test's proof value comes from WHEN it runs, not that it exists.
|
|
4
|
+
|
|
5
|
+
## Why order matters
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
❌ Write implementation → Write test → Test passes immediately
|
|
9
|
+
The test never demonstrated it could catch the bug.
|
|
10
|
+
You cannot prove the test is testing the right thing.
|
|
11
|
+
|
|
12
|
+
✅ Write test (red) → Watch it fail → Write implementation → Test passes (green)
|
|
13
|
+
The red phase proves the test catches the absence of the feature.
|
|
14
|
+
The green phase proves the feature satisfies the test.
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Example: password validation
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
// RED — test first, watch it fail
|
|
21
|
+
describe('validatePassword', () => {
|
|
22
|
+
it('rejects passwords shorter than 8 characters', () => {
|
|
23
|
+
expect(validatePassword('short')).toBe(false);
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// FAIL: validatePassword is not defined
|
|
28
|
+
|
|
29
|
+
// GREEN — minimal impl
|
|
30
|
+
function validatePassword(pw: string): boolean {
|
|
31
|
+
return pw.length >= 8;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// REFACTOR — while green
|
|
35
|
+
function validatePassword(pw: string): boolean {
|
|
36
|
+
if (pw.length < 8) return false;
|
|
37
|
+
if (!/[A-Z]/.test(pw)) return false;
|
|
38
|
+
if (!/[0-9]/.test(pw)) return false;
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Anti-pattern: test after implementation
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
// Code already written, then test added later:
|
|
47
|
+
function formatCurrency(amount: number): string {
|
|
48
|
+
return `$${amount.toFixed(2)}`;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Test passes immediately — proves nothing:
|
|
52
|
+
it('formats currency', () => {
|
|
53
|
+
expect(formatCurrency(10)).toBe('$10.00'); // green on first run
|
|
54
|
+
});
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
The fix: comment out the implementation, watch the test fail, then uncomment.
|
|
58
|
+
If the test still passes with implementation removed, the test is wrong.
|
|
59
|
+
|
|
60
|
+
## Rule
|
|
61
|
+
|
|
62
|
+
A test that passes on first run has proven nothing. Discard the implementation and redo test-first, or comment it out and prove the test actually fails before restoring.
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: mugiwara-quality
|
|
3
|
-
description: Use after checkpoint passes
|
|
3
|
+
description: Use after checkpoint passes — formatter, linter, unit tests. Discovers project tooling, never weakens configs. User tests under consent matrix.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Quality (Sanji)
|
|
7
7
|
|
|
8
|
+
## Skip when
|
|
9
|
+
|
|
10
|
+
- No code changed: docs-only or config-only diff with no lint/test surface.
|
|
11
|
+
- Repo has no detectable tooling (no test/lint/format commands) — record the skip.
|
|
12
|
+
|
|
8
13
|
Cook the checks properly; never cut corners to make them pass.
|
|
9
14
|
|
|
10
15
|
## Discover the stack first
|
|
@@ -36,9 +41,9 @@ Optional, never default-on. Trigger ONLY when BOTH hold:
|
|
|
36
41
|
- Repo has e2e setup — any of `playwright.config.*`, `cypress.config.*`, `e2e/` dir, `test:e2e` npm script.
|
|
37
42
|
- Changed/staged files match e2e patterns — `e2e/**`, `*.e2e.*`, `specs/**`.
|
|
38
43
|
|
|
39
|
-
When triggered, consent by mode (per
|
|
44
|
+
When triggered, consent by mode (per mode config invariant): `guided`/`semi` ask first — run now / skip / run manually later; `auto` runs only provably-isolated e2e (in-memory / local / tooling-proven isolation). Otherwise skip-and-log: record the skip reason (no setup, no matching files, no consent) in the report. The e2e gate never blocks silently and never blocks a pass — a skip is logged, not a failure.
|
|
40
45
|
|
|
41
|
-
## Mode + consent (per
|
|
46
|
+
## Mode + consent (per mode config)
|
|
42
47
|
|
|
43
48
|
Consent is an invariant, not a mode knob. State-mutating tests against NON-isolated / shared state (real DB writes, network, browsers) ALWAYS require explicit user consent in ALL modes. Provably-isolated mutation — in-memory / temp / testcontainer-backed DBs, tooling-proven isolation — is explicitly auto-safe and needs no consent. `auto` runs only provably-isolated tests automatically (unit-level, or tooling-proven isolation such as in-memory / local DB). `guided`/`semi`: integration tests keep the existing ask-first rule — run automatically now / skip / run manually later. Record every consent answer in the report.
|
|
44
49
|
|
|
@@ -1,51 +1,67 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: mugiwara-resume
|
|
3
|
-
description: Use when
|
|
3
|
+
description: Use when mission interrupted, context lost, or new session mid-mission — rebuild from .mugiwara/state.json, continue never restart.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Session Resume (Never Start Over)
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
## Skip when
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
- Fresh mission: no `.mugiwara/` state exists to rebuild from.
|
|
11
|
+
- No interruption, compaction, or new-session-mid-mission happened.
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
The host AI can lose context — compaction, new session, crash. Disk state is truth. Rebuild from one file, continue from exact point, never restart.
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
|------|-------|
|
|
16
|
-
| `.mugiwara/plans/YYYY-MM-DD-<mission>.md` | waves, tasks, acceptance criteria (clean plan) |
|
|
17
|
-
| `.mugiwara/results/<mission>-todos.md` | checkbox per task, checked = done with evidence |
|
|
18
|
-
| `.mugiwara/results/<mission>-trace.md` | every dispatch, outcome |
|
|
19
|
-
| `.mugiwara/issues/YYYY-MM-DD-<mission>-blockers.md` | blocker rows with owners / heal state |
|
|
20
|
-
| `.mugiwara/logs/YYYY-MM-DD-<mission>.md` | Luffy's decision + check-in log |
|
|
21
|
-
| `.mugiwara/config` | current mode (project); `~/.mugiwara/config` = global default; per-mission override rows live in the decision log |
|
|
15
|
+
## State contract
|
|
22
16
|
|
|
23
|
-
|
|
17
|
+
Resume reads one file: `.mugiwara/state.json`. All position data is computed at every wave boundary by `scripts/savepoint.sh`.
|
|
18
|
+
|
|
19
|
+
```json
|
|
20
|
+
{
|
|
21
|
+
"mission": "2026-08-11-invitation-accepted",
|
|
22
|
+
"actor": "farid",
|
|
23
|
+
"branch": "feature/feat-MKR-412",
|
|
24
|
+
"lane": "full",
|
|
25
|
+
"lane_reason": "auth/ path touched",
|
|
26
|
+
"wave": 5,
|
|
27
|
+
"mode": "guided",
|
|
28
|
+
"base_sha": "a3f1c2e",
|
|
29
|
+
"files_touched": 11,
|
|
30
|
+
"loc_delta": 340,
|
|
31
|
+
"sensitive_paths": ["src/auth/invitation.ts"],
|
|
32
|
+
"tasks": { "done": 7, "total": 12 },
|
|
33
|
+
"blockers_open": 1,
|
|
34
|
+
"heal_cycle": 1,
|
|
35
|
+
"tokens_est": 14200,
|
|
36
|
+
"budget": 20000,
|
|
37
|
+
"evidence": [".mugiwara/results/wave4-audit.md"],
|
|
38
|
+
"updated_at": "2026-08-11T12:40:00Z"
|
|
39
|
+
}
|
|
40
|
+
```
|
|
24
41
|
|
|
25
|
-
|
|
42
|
+
## Resume protocol
|
|
26
43
|
|
|
27
|
-
1.
|
|
28
|
-
2.
|
|
29
|
-
3.
|
|
30
|
-
4.
|
|
31
|
-
5.
|
|
32
|
-
6. Re-derive position: wave N, tasks remaining, open blockers, heal counter, and the resumed mode.
|
|
33
|
-
7. State it in one line: "Resumed: Wave 5, tasks 5.3-5.7 pending, 1 blocker (env), heal counter 1, mode semi." Then CONTINUE — do not re-verify completed waves unless the trace shows a failure.
|
|
44
|
+
1. Read `.mugiwara/state.json`. If absent, this is a fresh mission — no resume needed.
|
|
45
|
+
2. Derive position from fields: wave N, tasks done/total, blockers open, heal cycle, mode.
|
|
46
|
+
3. If `state.json` is stale or corrupted, fall back to legacy files: plan doc → todos → trace → blocker ledger → config. Then write a fresh `state.json`.
|
|
47
|
+
4. State it: "Resumed: Wave 5, 7/12 tasks, 1 blocker, heal cycle 1, mode guided."
|
|
48
|
+
5. Continue — do not re-verify completed waves.
|
|
34
49
|
|
|
35
50
|
## Rules
|
|
36
51
|
|
|
37
52
|
1. Never trust memory over disk — disk is truth.
|
|
38
|
-
2. Never re-run completed work —
|
|
53
|
+
2. Never re-run completed work — state.json proves it.
|
|
39
54
|
3. Never skip the resume read — guessing position = drift.
|
|
40
|
-
4. If
|
|
55
|
+
4. If state.json is absent and no legacy files exist → fresh mission, escalate to Luffy.
|
|
41
56
|
|
|
42
|
-
##
|
|
57
|
+
## Rationalizations
|
|
43
58
|
|
|
44
|
-
|
|
59
|
+
- "I remember where we were" → memory lies after compaction; disk is truth.
|
|
60
|
+
- "Re-running is safer" → wastes the mission; trust state.json.
|
|
61
|
+
- "I'll update state later" → savepoint.sh runs at every wave boundary; state is always current.
|
|
45
62
|
|
|
46
|
-
##
|
|
63
|
+
## Red flags
|
|
47
64
|
|
|
48
|
-
-
|
|
49
|
-
-
|
|
50
|
-
-
|
|
51
|
-
- Red flags: reading any file out of order, re-doing a wave the trace shows complete, skipping the blocker ledger, inventing state instead of escalating, a resume position stated without citing the files.
|
|
65
|
+
- Resume position stated without citing state.json or legacy files.
|
|
66
|
+
- Re-doing a wave state.json shows complete.
|
|
67
|
+
- Inventing state instead of escalating when files are missing.
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: mugiwara-review
|
|
3
|
-
description: Use after
|
|
3
|
+
description: Use after gates pass to review the diff — breaking-change map via caller mapping, five-axis review, severity-tagged findings. Max 3 cycles.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Review (Robin)
|
|
7
7
|
|
|
8
|
+
## Skip when
|
|
9
|
+
|
|
10
|
+
- Zero diff to review: docs-only change or lane 0 one-line fix.
|
|
11
|
+
- User explicitly deferred review and recorded the decision.
|
|
12
|
+
|
|
8
13
|
Review like the diff will be maintained by someone else at 3am — and like the implementer is wrong until proven otherwise.
|
|
9
14
|
|
|
10
15
|
## Breaking-change analysis (do this FIRST) — build the damage map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Five-Axis Review Worksheet
|
|
2
|
+
|
|
3
|
+
One verdict + evidence per axis. No axis passes on assertion.
|
|
4
|
+
|
|
5
|
+
## Axes
|
|
6
|
+
|
|
7
|
+
| Axis | Question | Evidence required |
|
|
8
|
+
|------|----------|-------------------|
|
|
9
|
+
| Correctness | Does the change break anything that currently works? | Re-run caller tests, verify edge cases |
|
|
10
|
+
| Readability | Can a new team member understand the diff in 5 minutes? | Naming convention check, function length, comment quality |
|
|
11
|
+
| Architecture | Does the change fit the existing system structure? | No parallel patterns, no new abstraction without need |
|
|
12
|
+
| Security | Any security regression or new attack surface? | STRIDE on changed surface, checklist pass |
|
|
13
|
+
| Performance | Any N+1, O(n²), or unbounded resource use introduced? | Profiler output or manual analysis of hot path |
|
|
14
|
+
|
|
15
|
+
## Example
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
Axis: Correctness
|
|
19
|
+
Verdict: PASS
|
|
20
|
+
Evidence: npm test -- --shard=1/2 passes (312 tests), caller grep confirms all
|
|
21
|
+
imports of renamed function updated
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
Axis: Security
|
|
26
|
+
Verdict: FAIL
|
|
27
|
+
Evidence: New endpoint POST /api/export has no authz middleware. Missing rate
|
|
28
|
+
limit on file generation (DoS risk).
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Rules
|
|
32
|
+
|
|
33
|
+
- One verdict per axis. "Partial pass" = FAIL.
|
|
34
|
+
- Evidence is command output or file path, never a paraphrase.
|
|
35
|
+
- FAIL on any axis → overall review FAIL → Brook (Wave 8).
|
|
36
|
+
- PASS on all 5 → forward to closure.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Severity Rubric
|
|
2
|
+
|
|
3
|
+
For review findings. Every finding gets a severity backed by criteria.
|
|
4
|
+
|
|
5
|
+
| Severity | Definition | Examples | Action |
|
|
6
|
+
|----------|-----------|----------|--------|
|
|
7
|
+
| **blocker** | public-break with no migration path, wrong behavior shipped, security hole | renamed public API with callers unfixed, authz bypass, data loss | Fix before merge |
|
|
8
|
+
| **major** | internal-break with callers unfixed, missed contract, behavior change outside declared scope | changed function signature, missing error handling, N+1 in hot path | Fix this mission |
|
|
9
|
+
| **minor** | polish, style drift, batched items | inconsistent naming, missing test for edge case, duplicated 3-line helper | May batch with Brook |
|
|
10
|
+
|
|
11
|
+
## CVSS-style for security
|
|
12
|
+
|
|
13
|
+
| Severity | Exploitability × Impact |
|
|
14
|
+
|----------|------------------------|
|
|
15
|
+
| Critical | Reachable + tooling exists + pre-auth → data loss/auth bypass/RCE |
|
|
16
|
+
| High | Reachable + limited tooling → PII leak, privilege escalation |
|
|
17
|
+
| Medium | Requires auth/conditions → partial exposure |
|
|
18
|
+
| Low | Defense-in-depth gaps, no known exploit path |
|
|
19
|
+
|
|
20
|
+
Security findings are never "minor by default." Every finding gets the matrix.
|
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
---
|
|
2
|
-
name: mugiwara-
|
|
3
|
-
description: Use
|
|
2
|
+
name: mugiwara-root-cause
|
|
3
|
+
description: Use for debugging bugs, crashes, regressions — 4-phase: reproduce, localize, reduce, fix+guard. Stop-the-line on failures.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Systematic Debugging
|
|
7
7
|
|
|
8
|
+
## Skip when
|
|
9
|
+
|
|
10
|
+
- Cause already known and reproduced, fix obvious, failure not intermittent.
|
|
11
|
+
- One-line revert or rollback resolves it with no investigation needed.
|
|
12
|
+
|
|
8
13
|
A failure is a stopping event, not a speed bump. Do not guess, do not patch. Walk the four phases in order; each gates the next.
|
|
9
14
|
|
|
10
15
|
## When to use
|
|
11
16
|
|
|
12
17
|
Any bug, unexplained failure, crash, or regression in code, tests, or config. When the cause is unknown, the fix is not obvious, or the failure is intermittent. Standalone discipline — use it before any fix ships, and escalate when a phase cannot complete.
|
|
13
18
|
|
|
19
|
+
Framework code from docs, not memory: `references/source-grounding.md`.
|
|
20
|
+
|
|
14
21
|
## Process
|
|
15
22
|
|
|
16
23
|
### Phase 1 — Reproduce
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Four-Phase Debugging — Worked Example
|
|
2
|
+
|
|
3
|
+
A real bug traced end to end through reproduce → localize → reduce → fix + guard.
|
|
4
|
+
|
|
5
|
+
## The bug report
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
Title: Users see "null" instead of display name on profile page
|
|
9
|
+
Severity: medium
|
|
10
|
+
Reported: Aug 2026
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Phase 1 — Reproduce
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
# Create user with no displayName
|
|
17
|
+
$ curl -X POST /api/users -d '{"email":"test@ex.com"}'
|
|
18
|
+
{"id": "u_42", "email": "test@ex.com"}
|
|
19
|
+
|
|
20
|
+
# Fetch profile
|
|
21
|
+
$ curl /api/users/u_42
|
|
22
|
+
{"id": "u_42", "displayName": "null", "email": "test@ex.com"}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Expected: `displayName` should be `null` (JSON null) or omitted, not string `"null"`.
|
|
26
|
+
|
|
27
|
+
## Phase 2 — Localize
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
$ git grep -n 'displayName' src/
|
|
31
|
+
src/models/user.ts:12: displayName?: string | null;
|
|
32
|
+
src/services/user-profile.ts:34: return user.displayName ?? 'null';
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Bug at `src/services/user-profile.ts:34`: `?? 'null'` is the string `"null"`, not the JavaScript `null` value. The default should be `null` or `undefined`.
|
|
36
|
+
|
|
37
|
+
## Phase 3 — Reduce
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
// Before (broken):
|
|
41
|
+
return user.displayName ?? 'null'; // string "null"!
|
|
42
|
+
|
|
43
|
+
// Minimal reproduction:
|
|
44
|
+
const result = undefined ?? 'null'; // "null" — this is a string
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
The `??` operator returns the right operand only when the left is `null`/`undefined`. But `'null'` is a truthy string — it's never the `null` value.
|
|
48
|
+
|
|
49
|
+
## Phase 4 — Fix + Guard
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
// Fix:
|
|
53
|
+
return user.displayName ?? null; // JSON null
|
|
54
|
+
|
|
55
|
+
// Guard test:
|
|
56
|
+
it('returns null for missing displayName, not string "null"', () => {
|
|
57
|
+
const user = { id: 'u_42', email: 'test@ex.com' };
|
|
58
|
+
const profile = buildProfile(user);
|
|
59
|
+
expect(profile.displayName).toBeNull(); // was: toBe('null')
|
|
60
|
+
});
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
$ npm test -- user-profile.test.ts
|
|
65
|
+
PASS user-profile.test.ts
|
|
66
|
+
✓ returns null for missing displayName, not string "null"
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Lesson
|
|
70
|
+
|
|
71
|
+
String `"null"` ≠ JavaScript `null`. The `??` operator with a string default is almost always a bug. Grep the codebase: `git grep "?? '"` to find similar patterns.
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: mugiwara-security
|
|
3
|
-
description: Use for
|
|
3
|
+
description: Use for security audit of a diff — STRIDE threat model, OWASP Top 10, secrets, injection, authn/authz, dependency audit. Findings to .mugiwara/review/.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Security (Jinbe)
|
|
7
7
|
|
|
8
|
+
## Skip when
|
|
9
|
+
|
|
10
|
+
- Diff crosses no trust boundary: docs-only, no data/request/state flow change.
|
|
11
|
+
- No secrets, auth, injection, dependency, or network surface touched.
|
|
12
|
+
|
|
8
13
|
Senior security engineer. Assume the surface is hostile until proven safe.
|
|
9
14
|
|
|
10
15
|
## Threat model FIRST (STRIDE)
|
|
@@ -20,7 +25,7 @@ Before any check, map every application surface to STRIDE. A surface is any boun
|
|
|
20
25
|
| DoS | Can the surface be exhausted or taken down? |
|
|
21
26
|
| Elevation | Can a caller gain privileges beyond their grant? |
|
|
22
27
|
|
|
23
|
-
List every surface: endpoints, CLI, config inputs, file/DB reads, external calls, rendered output. A surface with no threat row is a modeling gap, not a safe surface.
|
|
28
|
+
List every surface: endpoints, CLI, config inputs, file/DB reads, external calls, rendered output. A surface with no threat row is a modeling gap, not a safe surface.
|
|
24
29
|
|
|
25
30
|
## OWASP Top 10 mapping
|
|
26
31
|
|
|
@@ -43,14 +48,13 @@ Required when the project handles payments, health data, or PII. Map each securi
|
|
|
43
48
|
|
|
44
49
|
- Authn ≠ authz: identity is not permission. Verify both, server-side only; client-side-only checks are findings, not controls.
|
|
45
50
|
- Sessions/tokens: validate server-side, enforce expiry and revocation, rotate on privilege change, never in URL or logs.
|
|
46
|
-
- Least privilege: smallest scope that works
|
|
47
|
-
- Fail closed: deny on any absent/ambiguous permission. Fail-open authz is Critical.
|
|
51
|
+
- Least privilege: smallest scope that works (a widened scope is a finding). Fail closed: deny on absent/ambiguous permission — fail-open authz is Critical.
|
|
48
52
|
|
|
49
53
|
## Secrets management
|
|
50
54
|
|
|
51
55
|
- Never in code: no hardcoded keys/tokens/passwords, no committed .env, no secrets in logs or dumps.
|
|
52
56
|
- Source from env or a vault (AWS Secrets Manager, Vault, etc.); inject at runtime, never inline.
|
|
53
|
-
- Rotate on a schedule; a key that ever hit a repo is revoked, not "cleaned up". Scan diff and history for secret shapes
|
|
57
|
+
- Rotate on a schedule; a key that ever hit a repo is revoked, not "cleaned up". Scan diff and history for secret shapes.
|
|
54
58
|
|
|
55
59
|
## Dependency auditing
|
|
56
60
|
|
|
@@ -61,27 +65,26 @@ Required when the project handles payments, health data, or PII. Map each securi
|
|
|
61
65
|
## Boundary system
|
|
62
66
|
|
|
63
67
|
- Every external interface is hostile: HTTP bodies/headers, query strings, uploads, CLI args, config, env, upstream responses, rendered HTML.
|
|
64
|
-
- Validate at the trust boundary, allowlist-first: shape, type, length, charset. A boundary with no validation is a finding even when input "looks safe"
|
|
68
|
+
- Validate at the trust boundary, allowlist-first: shape, type, length, charset. A boundary with no validation is a finding even when input "looks safe".
|
|
65
69
|
|
|
66
70
|
## Security-regression check
|
|
67
71
|
|
|
68
|
-
A change
|
|
72
|
+
A change can weaken what was already secured. For every control the diff touches, answer: was anything secured now weakened? Removed authz, loosened CORS, endpoint added without auth, PII newly logged, downgraded crypto, a vulnerable new dependency — each is a finding at the same severity as a fresh bug, not a side note.
|
|
69
73
|
|
|
70
74
|
## Cross-cutting impact
|
|
71
75
|
|
|
72
|
-
Map touched surface → blast radius. Does the change expose previously-internal data, widen the attack surface, add a new trust boundary, or change who can reach what? An internal-only surface made reachable is an elevation finding even if the endpoint is "not sensitive yet".
|
|
76
|
+
Map touched surface → blast radius. Does the change expose previously-internal data, widen the attack surface, add a new trust boundary, or change who can reach what? An internal-only surface made reachable is an elevation finding even if the endpoint is "not sensitive yet".
|
|
73
77
|
|
|
74
78
|
## Checklist (run all, in order)
|
|
75
79
|
|
|
76
80
|
Each item checks that the change did not weaken an existing control, not just that it introduced no new one.
|
|
77
81
|
|
|
78
|
-
1. Secrets: hardcoded keys/tokens/passwords, committed .env files, secrets in logs or
|
|
82
|
+
1. Secrets: hardcoded keys/tokens/passwords, committed .env files, secrets in logs or errors — including newly logged or newly exposed.
|
|
79
83
|
2. Injection: SQL/NoSQL/command/template injection; unsanitized input reaching exec/query/render. A rewritten handler must not drop an existing sanitizer.
|
|
80
84
|
3. Authn/Authz: server-side checks only — client-side-only authorization is a finding, not a control. Removed or loosened checks are regressions.
|
|
81
|
-
4. Data exposure: PII in logs, over-broad API responses, missing rate limiting on sensitive endpoints. A
|
|
82
|
-
5. Dependencies: run project audit tooling (npm audit, pip-audit, cargo audit, govulncheck). A skipped audit is a finding. New
|
|
83
|
-
6. Deserialization & file handling: unsafe parsing of untrusted input, path traversal in file operations.
|
|
84
|
-
7. Crypto hotspots: MD5/SHA1 for security purposes, ECB mode, hardcoded IV, insecure randomness for security use, permissive CORS, disabled TLS verification. Downgraded crypto is a regression.
|
|
85
|
+
4. Data exposure: PII in logs, over-broad API responses, missing rate limiting on sensitive endpoints. A widened response shape is a finding.
|
|
86
|
+
5. Dependencies: run project audit tooling (npm audit, pip-audit, cargo audit, govulncheck). A skipped audit is a finding. New deps get a vulnerability review before merge.
|
|
87
|
+
6. Deserialization & file handling: unsafe parsing of untrusted input, path traversal in file operations. Crypto hotspots: MD5/SHA1 for security, ECB, hardcoded IV, insecure randomness, permissive CORS, disabled TLS — downgraded crypto is a regression.
|
|
85
88
|
|
|
86
89
|
## Untrusted-data doctrine
|
|
87
90
|
|
|
@@ -98,7 +101,6 @@ Each finding: location + one-line attack scenario + severity + concrete fix.
|
|
|
98
101
|
## Verdict
|
|
99
102
|
|
|
100
103
|
PASS (no Critical/High) → closure. FAIL → Brook. Never defer a security finding to review; it either fixes now or it is Brook's problem.
|
|
101
|
-
|
|
102
104
|
## Common rationalizations
|
|
103
105
|
|
|
104
106
|
| Rationalization | Reality |
|
|
@@ -114,10 +116,8 @@ PASS (no Critical/High) → closure. FAIL → Brook. Never defer a security find
|
|
|
114
116
|
- A hardcoded secret or secret in logs/errors not flagged.
|
|
115
117
|
- Client-side-only authorization accepted, or authz missing on a non-public endpoint.
|
|
116
118
|
- A finding classified "minor by default" without an exploitability × impact analysis.
|
|
117
|
-
-
|
|
118
|
-
-
|
|
119
|
-
- External data treated as instructions instead of data.
|
|
120
|
-
- A security regression unchecked: an existing control weakened by the change (removed authz, loosened CORS, endpoint without auth, logged PII, downgraded crypto).
|
|
119
|
+
- An injection path (unsanitized input to exec/query/render) filed as a suggestion; external data treated as instructions.
|
|
120
|
+
- A security regression unchecked: weakened authz/CORS/crypto, endpoint without auth, logged PII.
|
|
121
121
|
- Cross-cutting impact unmapped: no blast-radius analysis for the touched surface.
|
|
122
122
|
- Previously-internal data or surface newly exposed without an elevation finding.
|
|
123
123
|
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# OWASP Top 10 Mapping
|
|
2
|
+
|
|
3
|
+
Required when the project handles payments, health data, or PII.
|
|
4
|
+
|
|
5
|
+
| Code | Category | Review area |
|
|
6
|
+
|------|----------|-------------|
|
|
7
|
+
| A01 | Broken access control | authz gaps, IDOR, missing server-side checks |
|
|
8
|
+
| A02 | Cryptographic failures | PII in transit/at rest, weak crypto, exposed secrets |
|
|
9
|
+
| A03 | Injection | SQL/NoSQL/OS/template injection, unsanitized input to exec/render |
|
|
10
|
+
| A04 | Insecure design | missing threat model, trust-boundary failures |
|
|
11
|
+
| A05 | Misconfiguration | default creds, verbose errors, permissive headers, debug on |
|
|
12
|
+
| A06 | Vulnerable components | dependency audit, known-vuln check, outdated libs |
|
|
13
|
+
| A07 | Authn failures | broken sessions, brute-forceable login, credential reuse |
|
|
14
|
+
| A08 | Integrity | insecure deserialization, supply-chain tamper |
|
|
15
|
+
| A09 | Logging/monitoring | PII in logs, missing audit trail, silent failures |
|
|
16
|
+
| A10 | SSRF | server-side requests to attacker-controlled targets, URL validation |
|
|
17
|
+
|
|
18
|
+
## How to map
|
|
19
|
+
|
|
20
|
+
For each security check run, record which OWASP category it covers. A handled
|
|
21
|
+
category with no mapping row = documentation gap in the security report.
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
| OWASP | Check | Verdict |
|
|
25
|
+
|-------|-------|---------|
|
|
26
|
+
| A01 | Authz on /api/admin routes | PASS |
|
|
27
|
+
| A02 | TLS enforced, no hardcoded secrets | PASS |
|
|
28
|
+
| A03 | SQL params in user query handler | PASS |
|
|
29
|
+
| A06 | npm audit: 0 critical/high | PASS |
|
|
30
|
+
```
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# STRIDE Worksheet
|
|
2
|
+
|
|
3
|
+
Map every application surface to STRIDE before running security checks.
|
|
4
|
+
|
|
5
|
+
## Surface inventory
|
|
6
|
+
|
|
7
|
+
List every surface where data, requests, or state cross trust levels:
|
|
8
|
+
|
|
9
|
+
- HTTP endpoints (REST, GraphQL, gRPC)
|
|
10
|
+
- CLI arguments and environment variables
|
|
11
|
+
- File uploads, database reads/writes
|
|
12
|
+
- External API calls, webhooks
|
|
13
|
+
- Rendered output (HTML, JSON, logs)
|
|
14
|
+
- Config files, secret stores
|
|
15
|
+
|
|
16
|
+
## STRIDE per surface
|
|
17
|
+
|
|
18
|
+
| STRIDE | Ask of each surface |
|
|
19
|
+
|--------|---------------------|
|
|
20
|
+
| Spoofing | Can an identity be forged or impersonated? |
|
|
21
|
+
| Tampering | Can data in transit or at rest be altered undetected? |
|
|
22
|
+
| Repudiation | Can an action occur without a traceable actor? |
|
|
23
|
+
| Info disclosure | Can data leak to an unintended party? |
|
|
24
|
+
| DoS | Can the surface be exhausted or taken down? |
|
|
25
|
+
| Elevation | Can a caller gain privileges beyond their grant? |
|
|
26
|
+
|
|
27
|
+
## Example
|
|
28
|
+
|
|
29
|
+
| Surface | S | T | R | I | D | E | Notes |
|
|
30
|
+
|---------|---|---|---|---|---|---|-------|
|
|
31
|
+
| POST /api/invite | ✅ | ✅ | — | ⚠️ | — | ✅ | Email exposed in error response |
|
|
32
|
+
| GET /api/users/:id | ✅ | — | — | ⚠️ | — | ✅ | IDOR: no ownership check |
|
|
33
|
+
| config upload | — | ✅ | — | — | — | — | YAML parsing, no schema validation |
|
|
34
|
+
|
|
35
|
+
✅ = threat present, ⚠️ = partial mitigation, — = not applicable
|
|
36
|
+
|
|
37
|
+
A surface with no STRIDE row is a modeling gap, not a safe surface.
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: mugiwara-ship
|
|
3
|
-
description: Use at mission end
|
|
3
|
+
description: Use at mission end — pre-launch checklist, feature flags, staged rollout, mandatory rollback plan. Binary GO/NO-GO.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Ship Gate (Luffy, Franky)
|
|
7
7
|
|
|
8
|
+
## Skip when
|
|
9
|
+
|
|
10
|
+
- Not releasing: no deploy, rollout, feature-flag flip, or user-facing change.
|
|
11
|
+
- Internal-only change with zero production exposure.
|
|
12
|
+
|
|
8
13
|
The last gate before anything reaches a user. Binary GO or NO-GO, each backed by evidence. Default is NO-GO until every item is proven.
|
|
9
14
|
|
|
10
15
|
## Pre-launch checklist
|