Skip to content

Commit 3f09335

Browse files
authored
feat(v3r2): Wave 3 — Permission Stack, MX TAG v2, Hook Handler, Constitution Pipeline (#741)
* feat(v3r2): Wave 1+2 Bundle — Constitution + Runtime Foundation Wave 1 — Constitution Foundation (CON-002, CON-003, SPC-001): - CON-002: 5-layer amendment safety gate (frozen guard, canary check, contradiction detector, rate limiter, human oversight) - CON-003: Rule tree consolidation (merge 4 deleted files, relocate content, frontmatter migration) - SPC-001: EARS hierarchical acceptance criteria parser with spec linter subcommand Wave 2 — Runtime Core (RT-005, RT-001, RT-004): - RT-005: Multi-layer settings resolution with provenance tags (8-source priority stack: policy > user > project > local > plugin > skill > session > builtin) - RT-001: Hook JSON-OR-ExitCode dual protocol (HookResponse schema, structured output for all 27 hook events) - RT-004: Typed session state with phase checkpoints and resumable permission context Supporting changes: - Template mirrors for all rules/skills changes - LSP client decision document - Master wave plan document - CLI subcommands: constitution, spec lint/view, state, doctor config 🤖 MoAI <email@mo.ai.kr> * feat(runtime): SPEC-V3R2-RT-002 Permission Stack + Bubble Mode 구현 8-소스 Permission Stack (SrcPolicy > SrcUser > SrcProject > SrcLocal > SrcPlugin > SrcSkill > SrcSession > SrcBuiltin) + 5 PermissionMode (Default, AcceptEdits, BypassPermissions, Plan, Bubble) + BubbleDispatcher for fork agent AskUserQuestion routing + moai doctor permission 서브커맨드 🧪 AC 15개 전체 통과 · 📦 7 files · 📊 ~750 LOC 🗿 MoAI <email@mo.ai.kr> * feat(spc): SPEC-V3R2-SPC-002 @mx TAG v2 — Sidecar Index + TagScanner 구현 16-언어 TagScanner (Go/Python/TypeScript/Rust/Java/Kotlin/C#/Ruby/PHP/ Elixir/C++/Scala/R/Dart/Swift) + JSON sidecar 인덱스 (.moai/state/ mx-index.json) + 원자적 쓰기 (temp+rename) + 7일 TTL 만료 아카이빙 + AnchorID resolver API (SPC-004 placeholder) 🧪 AC 15개 전체 통과 · 📦 9 files · 📊 ~800 LOC 🗿 MoAI <email@mo.ai.kr> * feat(runtime): SPEC-V3R2-RT-006 Hook Handler 27-Event Coverage + P-H02 CRITICAL 수정 5 UPGRADE: subagentStop (P-H02 tmux pane 누수 수정), postToolUseFailure (에러 분류 7종), instructionsLoaded (40K char budget), fileChanged (MX re-scan 16언어), configChange (YAML validation reload) 1 REMOVE: setup.go orphan 삭제 4 RETIRE-OBS-ONLY: notification/elicitation/elicitationResult/taskCreated 신규 audit_test.go: 핸들러 수 패리티 + retired event 검증 🧪 AC 17개 전체 통과 · 📦 18 files · 📊 ~1,000 LOC 🗿 MoAI <email@mo.ai.kr> * fix(lint): golangci-lint 20개 이슈 수정 (errcheck/staticcheck/unused) - errcheck: defer f.Close(), os.Remove(), json.Unmarshal 등 반환값 검사 추가 - ST1005: 에러 문자열 첫 글자 소문자화 (Layer → layer) - SA9003: 빈 분기 제거 (isFork bypass 로직 코멘트로 대체) - QF1003: if/else → tagged switch 전환 - unused: parseScoreFromProgress에 nolint 지시어 추가 (TODO 예약) - unused: evolutionLogPath 인라인 처리 🗿 MoAI <email@mo.ai.kr>
1 parent 7e098ee commit 3f09335

112 files changed

Lines changed: 13913 additions & 941 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.claude/rules/moai/core/moai-constitution.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
2-
description: Core constitutional principles for MoAI orchestrator - HARD rules that must always be followed
3-
globs:
2+
paths: "**/.claude/**"
43
---
54

65
# MoAI Constitution

.claude/rules/moai/development/coding-standards.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
2-
description: MoAI-specific coding standards for instruction documents and configuration files
3-
globs: .claude/**/*.md, .claude/**/*.yaml, .moai/**/*.yaml, CLAUDE.md
2+
paths: ".claude/**/*.md,.claude/**/*.yaml,.moai/**/*.yaml,CLAUDE.md"
43
---
54

65
# Coding Standards

.claude/rules/moai/workflow/context-window-management.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ This rule applies to all MoAI workflows:
7373
## Cross-references
7474

7575
- `feedback_large_spec_wave_split.md` (auto-memory) — wave-split mitigation for SPECs with 30+ tasks
76-
- `.claude/rules/moai/workflow/file-reading-optimization.md` — token budget per file read
76+
- `.claude/skills/moai/references/file-reading-optimization.md` — token budget per file read
7777
- `output-styles/moai/moai.md` §6 (Persistence & Context Awareness) — orchestrator persistence pattern
7878
- CLAUDE.md §11 (Error Handling) — token-limit recovery flow
7979

.claude/rules/moai/workflow/spec-workflow.md

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,55 @@ Token Strategy:
4545
- Selective file loading
4646
- Enables 70% larger implementations
4747

48-
Development Methodology:
49-
- Configured in quality.yaml (development_mode: ddd or tdd)
50-
- See @workflow-modes.md for detailed methodology cycles
48+
Development Methodology (configured in quality.yaml development_mode):
49+
50+
### DDD Mode — ANALYZE-PRESERVE-IMPROVE
51+
52+
Best for existing projects with < 10% test coverage. Uses manager-ddd agent.
53+
54+
**ANALYZE**: Read existing code, map domain boundaries, identify side effects and implicit contracts.
55+
**PRESERVE**: Write characterization tests capturing current behavior. Create behavior snapshots for regression detection.
56+
**IMPROVE**: Make small incremental changes. Run characterization tests after each change. Refactor with test validation.
57+
58+
### TDD Mode — RED-GREEN-REFACTOR (default)
59+
60+
Best for all development work, new projects, and brownfield with 10%+ coverage. Uses manager-tdd agent.
61+
62+
**RED**: Write a failing test describing desired behavior. Verify it fails. One test at a time.
63+
**GREEN**: Write simplest implementation that passes. No premature optimization.
64+
**REFACTOR**: Clean up while keeping tests green. Extract patterns, remove duplication.
65+
66+
Brownfield enhancement: Pre-RED step reads existing code to understand current behavior before writing the failing test.
67+
68+
### Methodology Auto-Detection
69+
70+
| Project State | Test Coverage | Recommendation |
71+
|--------------|---------------|----------------|
72+
| Greenfield (new) | N/A | TDD |
73+
| Brownfield | >= 10% | TDD |
74+
| Brownfield | < 10% | DDD |
75+
76+
Manual override: `quality.development_mode` in quality.yaml, `MOAI_DEVELOPMENT_MODE` env var, or `moai init --mode <ddd|tdd>`.
77+
78+
### Pre-submission Self-Review
79+
80+
Before marking implementation complete: review full diff against SPEC acceptance criteria. Ask "Is there a simpler approach?" and "Would removing any changes still satisfy the SPEC?" Skip for single-file changes under 50 lines, bug fixes with reproduction test, or user-approved annotation cycle changes.
81+
82+
### Drift Guard
83+
84+
After each methodology cycle, compare planned files against actual modifications. Warns at <= 30% drift. Triggers re-planning (Phase 2.7) above 30%.
85+
86+
### Team Mode Methodology
87+
88+
Each teammate applies the methodology within their file ownership scope. team-validator validates compliance. team-tester exclusively owns test files.
89+
90+
### MX Tag Integration
91+
92+
| Phase | TDD Action | DDD Action |
93+
|-------|-----------|-----------|
94+
| Test/Analyze | RED: add `@MX:TODO` | ANALYZE: 3-Pass scan, identify targets |
95+
| Implement/Preserve | GREEN: remove `@MX:TODO` | PRESERVE: validate tags, add `@MX:LEGACY` |
96+
| Refactor/Improve | REFACTOR: add `@MX:NOTE` | IMPROVE: update tags, add `@MX:NOTE` |
5197

5298
Success Criteria:
5399
- All SPEC requirements implemented

.claude/rules/moai/workflow/team-pattern-cookbook.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
description: "Five team execution patterns with role profiles and communication protocols"
3-
paths: ".moai/config/sections/workflow.yaml,.claude/rules/moai/workflow/team-protocol.md"
3+
paths: ".moai/config/sections/workflow.yaml,.claude/rules/moai/workflow/worktree-integration.md"
44
---
55

66
<!-- Source: revfactory/harness — Apache License 2.0 — see .claude/rules/moai/NOTICE.md -->

.claude/rules/moai/workflow/team-protocol.md

Lines changed: 0 additions & 54 deletions
This file was deleted.

.claude/rules/moai/workflow/workflow-modes.md

Lines changed: 0 additions & 195 deletions
This file was deleted.

0 commit comments

Comments
 (0)