feat(plan): Phase 282 P5 - Pattern3 ExtractionBased Migration & Classification

- Pattern3 extraction logic separated to extractors/pattern3.rs
- ExtractionBased strategy: pure functions, Fail-Fast, SSOT
- Pattern classification restored (AST-based pattern detection)
- Pattern1 extractor migrated (extractors/pattern1.rs)
- Documentation: phase-282 README updated, joinir-architecture updated

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
2025-12-23 08:13:47 +09:00
parent c3fb3c5833
commit 32ccccd272
7 changed files with 608 additions and 28 deletions

View File

@ -163,7 +163,7 @@ Pattern numbers (1-9+) became architectural decision points:
- `seq(a, b)`: Sequential composition (Normal wiring)
- `if_(header, cond, t, e, join)`: Conditional composition (Branch wiring)
- `loop_(loop_id, header, after, body)`: Loop composition (Break/Continue wiring)
- `cleanup(body, cleanup)`: Cleanup composition (planned, Phase 280+)
- `cleanup(main, cleanup_frag, normal_target, ret_target)`: Cleanup composition (Normal/Return wiring; Phase 281)
**Reference**: `docs/development/current/main/design/edgecfg-fragments.md` (Active SSOT)
@ -183,36 +183,36 @@ Both routes converge on the same Frag composition SSOT:
- Plan route: Handles complex scan patterns (Pattern6/7) via DomainPlan → CorePlan → Frag
- Both routes use same Frag composition API for CFG lowering (no duplication)
### Pattern Absorption Status (Phase 280)
### Pattern Absorption Status (Phase 281)
| Pattern | Structure | Status | Absorption Target |
|---------|-----------|--------|-------------------|
| **Pattern6** | ScanWithInit (forward scan) | Plan-based (Phase 273) | **Phase 280 C: Frag refactor target** |
| **Pattern7** | SplitScan (conditional split) | Plan-based (Phase 273) | **Phase 280 C: Frag refactor target** |
| Pattern8 | BoolPredicateScan (is_integer) | JoinIR-based | Phase 281+ (migration planned) |
| **Pattern6** | ScanWithInit (early-exit) | ✅ compose-based (Phase 281) | absorbed (hand-roll removed) |
| **Pattern7** | SplitScan (then/else join) | ✅ compose-based (Phase 281) | absorbed (hand-roll removed) |
| Pattern8 | BoolPredicateScan (is_integer) | JoinIR-based | Phase 283+ (migration planned) |
| Pattern9 | AccumConstLoop (bridge) | JoinIR-based (Phase 271) | 撤去条件 defined (minimal loop SSOT) |
| Pattern1-5 | Legacy (SimpleWhile, Break, IfPhi, Continue, InfiniteEarlyExit) | JoinIR-based | Test/error stubs (not absorbed) |
**Phase 280 Focus**: Pattern6/7 preparation (documentation of hand-rolled locations, defer refactor to Phase 281)
**Phase 281 Result**: Pattern6/7 absorbed (compose SSOT), hand-rolled Frag eliminated
**Absorption criteria** (Pattern6/7 → Frag composition):
1. Hand-rolled Frag construction identified (function name + 識別コメント)
2. TODO comments documenting future compose_* migration path
3. Behavior-preserving refactor deferred to Phase 281 (Phase 280 = SSOT positioning only)
3. Behavior-preserving refactor completed in Phase 281
### Absorption Timeline
**Phase 280 (Current)**: SSOT positioning + 導線固定
**Phase 280 (Complete)**: SSOT positioning + 導線固定
- A: Documentation (edgecfg-fragments.md → Active SSOT)
- B: API solidification (compose.rs contract verification)
- C: Pattern preparation (Pattern6/7 hand-rolled locations documented)
- **Goal**: Establish Frag composition as THE absorption destination
- **Non-Goal**: Full Pattern6/7 migration (deferred to Phase 281)
**Phase 281 (Planned)**: Full Pattern6/7 absorption
- Replace hand-rolled Frag construction with compose_* calls
- Behavior-preserving verification (smoke tests)
- Goal: Pattern6/7 use compose::if_/loop_ exclusively
**Phase 281 (Complete)**: Full Pattern6/7 absorption
- Pattern7: body cond_match → `compose::if_()`
- Pattern6: early-exit → `compose::cleanup()`Normal/Return wiring
- Behavior-preserving verification (VM/LLVM smokes)
**Phase 282 (Planned)**: Router shrinkage
- Pattern numbers → test labels only

View File

@ -58,8 +58,9 @@ CFG構築は以下に収束させる
- ❌ 禁止: CFG 分岐(`if pattern == 6 then ...`)、アーキテクチャ SSOTFrag composition が SSOT
**Detection 戦略**(簡潔版、詳細は P2+ で補完):
- **ExtractionBased**Pattern6,7,8: extract() 成功 → matchSSOT 単一)
- **StructureBased**Pattern1-5,9: ctx.pattern_kind チェックlegacy、2 つの SSOT
- **ExtractionBased**Pattern6/7/8/9: extract() 成功 → matchSSOT 単一)
- 注: Pattern8/9 は JoinIR table 経由でも、can_lower 内部で extract を使って判定しているpattern_kind 依存ではない
- **StructureBased**(主に Pattern1-5: ctx.pattern_kind などの事前分類を使うlegacy、SSOT が二重になりやすい)
**SSOT 参照**:
- Frag composition: `src/mir/builder/control_flow/edgecfg/api/compose.rs`
@ -108,7 +109,7 @@ extract_scan_with_init_plan() → Ok(None) for unsupported cases
5. **Emission**: emit_frag()terminator SSOT
**JoinIR table の責務**Phase 194+ table-driven:
1. **Detection**: can_lower()structure-based、ctx.pattern_kind
1. **Detection**: can_lower()pattern により structure-based / extraction-based が混在
2. **Extraction**: cf_loop 抽出
3. **収束先**: Frag composition → emit_frag内部パイプライン詳細は最小化
@ -126,4 +127,3 @@ extract_scan_with_init_plan() → Ok(None) for unsupported cases
- router の責務が docs で SSOT 化されている
- router の変更が「extractor配線」のみになっているCFG構築の詳細を持たない
- 既存の VM/LLVM smokes に退行がない