From 6910949583b7dd452cf5f4e99401377e90e546e8 Mon Sep 17 00:00:00 2001 From: tomoaki Date: Wed, 31 Dec 2025 04:54:02 +0900 Subject: [PATCH] phase29ap(p4): shrink joinir legacy loop pattern table --- docs/development/current/main/10-Now.md | 2 +- docs/development/current/main/30-Backlog.md | 2 +- .../main/design/coreplan-migration-roadmap-ssot.md | 2 +- .../current/main/phases/phase-29ap/README.md | 13 +++++++++++-- .../builder/control_flow/joinir/patterns/router.rs | 12 ++++-------- 5 files changed, 18 insertions(+), 13 deletions(-) diff --git a/docs/development/current/main/10-Now.md b/docs/development/current/main/10-Now.md index 39e5b866..ccb7aa96 100644 --- a/docs/development/current/main/10-Now.md +++ b/docs/development/current/main/10-Now.md @@ -3,7 +3,7 @@ ## Current Focus - Phase: `docs/development/current/main/phases/phase-29ap/README.md` -- Next: Phase 29ap P4 (planned; see `docs/development/current/main/phases/phase-29ap/README.md`) +- Next: Phase 29ap P5 (planned; see `docs/development/current/main/phases/phase-29ap/README.md`) ## Gate (SSOT) diff --git a/docs/development/current/main/30-Backlog.md b/docs/development/current/main/30-Backlog.md index 64d9c1af..1a768142 100644 --- a/docs/development/current/main/30-Backlog.md +++ b/docs/development/current/main/30-Backlog.md @@ -5,7 +5,7 @@ Scope: 「次にやる候補」を短く列挙するメモ。入口は `docs/dev ## Active -- Phase 29ap: `docs/development/current/main/phases/phase-29ap/README.md` (Next: P4 planned) +- Phase 29ap: `docs/development/current/main/phases/phase-29ap/README.md` (Next: P5 planned) - JoinIR regression gate SSOT: `docs/development/current/main/phases/phase-29ae/README.md` - CorePlan hardening (docs-first): `docs/development/current/main/phases/phase-29al/README.md` diff --git a/docs/development/current/main/design/coreplan-migration-roadmap-ssot.md b/docs/development/current/main/design/coreplan-migration-roadmap-ssot.md index 6fafb69d..85bb9ada 100644 --- a/docs/development/current/main/design/coreplan-migration-roadmap-ssot.md +++ b/docs/development/current/main/design/coreplan-migration-roadmap-ssot.md @@ -34,7 +34,7 @@ Related: ## 1.1 Current (active) - Active phase: `docs/development/current/main/phases/phase-29ap/README.md` -- Next step: Phase 29ap P4 (planned) +- Next step: Phase 29ap P5 (planned) ## 2. すでに固めた SSOT(再発防止の土台) diff --git a/docs/development/current/main/phases/phase-29ap/README.md b/docs/development/current/main/phases/phase-29ap/README.md index 21879359..c75bdc5d 100644 --- a/docs/development/current/main/phases/phase-29ap/README.md +++ b/docs/development/current/main/phases/phase-29ap/README.md @@ -53,7 +53,16 @@ Gate (SSOT): - No new logs or error strings. - Fallback remains `Ok(None)` when shape does not match. +## P4: JoinIR legacy table shrink (Pattern8 removal) ✅ + +- Scope: + - Remove Pattern8 from `LOOP_PATTERNS` so plan/composer stays SSOT for normal loops. + - Keep legacy table as last resort for Pattern2/4/9 only. +- Guardrails: + - No change to logs or error strings. + - Legacy routing remains a last-resort fallback. + ## Next (planned) -- P4: Router pattern-name branching reduction (planner outcome + composer SSOT) -- P5: Facts/Feature expansion if needed +- P5: Router pattern-name branching reduction (planner outcome + composer SSOT) +- P6: Facts/Feature expansion if needed diff --git a/src/mir/builder/control_flow/joinir/patterns/router.rs b/src/mir/builder/control_flow/joinir/patterns/router.rs index a42d09b6..6421fb41 100644 --- a/src/mir/builder/control_flow/joinir/patterns/router.rs +++ b/src/mir/builder/control_flow/joinir/patterns/router.rs @@ -222,7 +222,7 @@ pub(crate) struct LoopPatternEntry { /// /// **IMPORTANT**: Patterns are tried in array order (SSOT). /// Array order defines priority - earlier entries are tried first. -/// Pattern4 → Pattern8 → Pattern9 → Pattern2 +/// Pattern4 → Pattern9 → Pattern2 /// /// # Current Patterns (Structure-based detection, established Phase 131-11+) /// @@ -243,6 +243,7 @@ pub(crate) struct LoopPatternEntry { /// /// Note: func_name is now only used for debug logging, not pattern detection /// Phase 286: Pattern5 removed (migrated to Plan-based routing) +/// Phase 29ap P4: Pattern8 removed (migrated to Plan-based routing) pub(crate) static LOOP_PATTERNS: &[LoopPatternEntry] = &[ LoopPatternEntry { name: "Pattern6_NestedLoopMinimal", // Phase 188.3: 1-level nested loop @@ -258,11 +259,6 @@ pub(crate) static LOOP_PATTERNS: &[LoopPatternEntry] = &[ // Pattern6_ScanWithInit now handled via extract_scan_with_init_plan() + PlanLowerer // Phase 273 P2: Pattern7 entry removed (migrated to Plan-based routing) // Pattern7_SplitScan now handled via extract_split_scan_plan() + PlanLowerer - LoopPatternEntry { - name: "Pattern8_BoolPredicateScan", // Phase 259 P0: boolean predicate scan (is_integer/is_valid) - detect: super::pattern8_scan_bool_predicate::can_lower, - lower: super::pattern8_scan_bool_predicate::lower, - }, LoopPatternEntry { name: "Pattern9_AccumConstLoop", // Phase 270 P1: accumulator const loop (橋渡しパターン, before P1) detect: super::pattern9_accum_const_loop::can_lower, @@ -293,7 +289,7 @@ pub(crate) static LOOP_PATTERNS: &[LoopPatternEntry] = &[ /// This function implements the following routing strategy: /// 1. Try Plan-based Pattern6 (extract_scan_with_init_plan) → DomainPlan /// 2. Try Plan-based Pattern7 (extract_split_scan_plan) → DomainPlan -/// 3. Fall through to legacy Pattern2/4/8/9 table for other patterns +/// 3. Fall through to legacy Pattern2/4/9 table for other patterns /// /// The Plan line (Extractor → Normalizer → Verifier → Lowerer) is the /// current operational SSOT for Pattern6/7. Legacy patterns (1/2/4/8/9) use @@ -308,7 +304,7 @@ pub(crate) static LOOP_PATTERNS: &[LoopPatternEntry] = &[ /// SSOT Entry Points: /// - Pattern6: src/mir/builder/control_flow/plan/normalizer.rs (ScanWithInit normalization) /// - Pattern7: src/mir/builder/control_flow/plan/normalizer.rs (SplitScan normalization) -/// - Pattern2/4/8/9: src/mir/builder/control_flow/joinir/patterns/pattern*.rs (direct lowering) +/// - Pattern2/4/9: src/mir/builder/control_flow/joinir/patterns/pattern*.rs (direct lowering) pub(crate) fn route_loop_pattern( builder: &mut MirBuilder, ctx: &LoopPatternContext,