diff --git a/CURRENT_TASK.md b/CURRENT_TASK.md index f7093b8e..1f6793b7 100644 --- a/CURRENT_TASK.md +++ b/CURRENT_TASK.md @@ -19,7 +19,7 @@ Scope: Repo root の旧リンク互換。現行の入口は `docs/development/cu `docs/development/current/main/design/coreplan-migration-roadmap-ssot.md` が移行タスクの Done 判定の入口。 **Next implementation (CorePlan Step-B / Facts SSOT)** -`docs/development/current/main/phases/phase-29an/P8-EXITUSAGE-INVARIANTS-INSTRUCTIONS.md` +`docs/development/current/main/phases/phase-29an/P9-SKELETON-UNIFICATION-INFERENCE-INSTRUCTIONS.md` **2025-12-29: Phase 29am P0 COMPLETE (CorePlan If/Exit lowerer/verifier)** CorePlan の If/Exit を lowerer/verifier で扱えるようにして、CorePlan 移行の土台を作った。 diff --git a/docs/development/current/main/10-Now.md b/docs/development/current/main/10-Now.md index eb629739..d3953595 100644 --- a/docs/development/current/main/10-Now.md +++ b/docs/development/current/main/10-Now.md @@ -2,11 +2,16 @@ ## Current Focus: Phase 29an(Skeleton/Feature Facts) -Next: Phase 29an P8(exit_usage invariants, debug-only) +Next: Phase 29an P9(Skeleton unification inference, unused) 運用ルール: integration filter で phase143_* は回さない(JoinIR 回帰は phase29ae pack のみ) 運用ルール: phase286_pattern9_* は legacy pack (SKIP) を使う 移行道筋 SSOT: `docs/development/current/main/design/coreplan-migration-roadmap-ssot.md` +**2025-12-29: Phase 29an P8 完了** ✅ +- 目的: exit_usage と DomainPlan(Pattern1/2/4/5)の整合を debug-only で固定(release は仕様不変) +- 変更: `src/mir/builder/control_flow/plan/planner/build.rs` +- 検証: `cargo build --release` / `./tools/smokes/v2/run.sh --profile quick` / `./tools/smokes/v2/profiles/integration/joinir/phase29ae_regression_pack_vm.sh` + **2025-12-29: Phase 29an P7 完了** ✅ - 目的: CanonicalLoopFacts に skeleton/exit_usage の projection を追加(挙動不変) - 変更: `src/mir/builder/control_flow/plan/normalize/canonicalize.rs` / `src/mir/builder/control_flow/plan/planner/build.rs` diff --git a/docs/development/current/main/phases/phase-29an/P9-SKELETON-UNIFICATION-INFERENCE-INSTRUCTIONS.md b/docs/development/current/main/phases/phase-29an/P9-SKELETON-UNIFICATION-INFERENCE-INSTRUCTIONS.md new file mode 100644 index 00000000..619d77ba --- /dev/null +++ b/docs/development/current/main/phases/phase-29an/P9-SKELETON-UNIFICATION-INFERENCE-INSTRUCTIONS.md @@ -0,0 +1,72 @@ +--- +Status: Active +Scope: code(仕様不変、Skeleton一意化のSSOT足場) +Related: +- docs/development/current/main/phases/phase-29an/README.md +- docs/development/current/main/design/coreplan-skeleton-feature-model.md +- docs/development/current/main/design/planfrag-freeze-taxonomy.md +- docs/development/current/main/phases/phase-29ae/README.md +--- + +# Phase 29an P9: Skeleton 一意化(0/1/2+ → None/Some/Freeze)を Facts 側で SSOT 化(未接続) + +Date: 2025-12-29 +Status: Ready for execution +Scope: skeleton inference の境界をコードで固定する(未接続、仕様不変) + +## Objective + +- Skeleton の “一意化” を **Facts 側**で SSOT として固定する + - 0 個 → `Ok(None)`(StraightLine: plan対象外) + - 1 個 → `Ok(Some(SkeletonFacts))` + - 2 個以上 → `Err(Freeze::unstructured(...))`(複合構造/定義域外) +- 将来の Region planning(loop/if/match を入口分岐で増やさない)に備え、Skeleton/Feature 合成の前提を固める + +## Non-goals + +- 既存の routing / planner-first / legacy fallback の変更 +- 既存の `try_build_loop_facts*` の gate 変更 +- 新 env var / 恒常ログ追加 +- “骨格の完全推論” をやり切る(P9は境界SSOTが目的。subsetでOK) + +## Implementation + +### Step 1: Region skeleton inference API を追加(Facts層SSOT) + +Update: +- `src/mir/builder/control_flow/plan/facts/skeleton_facts.rs` + +Add: +- `pub(in crate::mir::builder) fn infer_region_skeleton_facts(stmts: &[ASTNode]) -> Result, Freeze>` + +Subset rules(保守的): +- stmts を走査し、`try_extract_skeleton_facts_from_stmt(stmt)` が `Some` を返した数を数える +- `skeleton_count == 0` → `Ok(None)` +- `skeleton_count == 1` → その skeleton を返す(他が straight-line でもOK) +- `skeleton_count >= 2` → `Err(Freeze::unstructured("multiple top-level skeleton statements"))` + +Notes: +- “2個以上” を `ambiguous` ではなく `unstructured` にするのが自然(複合骨格は単一skeletonではない) + +### Step 2: unit tests(0/1/2+ 境界を固定) + +Add tests in `skeleton_facts.rs`: +- empty slice → `Ok(None)` +- `[loop]` → `Ok(Some(Loop))` +- `[assign, if]` → `Ok(Some(If2))` +- `[loop, if]` → `Err(Freeze::unstructured(_))` + +### Step 3: wiring はしない(仕様不変) + +P9 では `infer_region_skeleton_facts()` を呼び出し側へ配線しない。 + +## Verification(required) + +- `cargo build --release` +- `./tools/smokes/v2/run.sh --profile quick` +- `./tools/smokes/v2/profiles/integration/joinir/phase29ae_regression_pack_vm.sh` + +## Commit + +- `git add -A && git commit -m "phase29an(p9): add skeleton unification facts api"` + diff --git a/docs/development/current/main/phases/phase-29an/README.md b/docs/development/current/main/phases/phase-29an/README.md index e3584ada..a97e5902 100644 --- a/docs/development/current/main/phases/phase-29an/README.md +++ b/docs/development/current/main/phases/phase-29an/README.md @@ -40,8 +40,6 @@ Status: ✅ COMPLETE(実装コミット: `c7fbcf3c8`) Status: ✅ COMPLETE(実装コミット: `f866badb3`) -## Next(planned) - ## P3: Add Freeze tag `unstructured` (taxonomy alignment) - 指示書: `docs/development/current/main/phases/phase-29an/P3-FREEZE-UNSTRUCTURED-TAG-SSOT-INSTRUCTIONS.md` @@ -78,9 +76,18 @@ Status: ✅ COMPLETE(実装コミット: `80c879fdb`) Status: ✅ COMPLETE(実装コミット: `5ac2f3586`) +## P8: exit_usage invariants (debug-only) + +- 指示書: `docs/development/current/main/phases/phase-29an/P8-EXITUSAGE-INVARIANTS-INSTRUCTIONS.md` +- ねらい: exit_usage と DomainPlan(Pattern1/2/4/5)の整合を debug-only で固定(release は仕様不変) + +Status: ✅ COMPLETE(実装コミット: `195b424cc`) + +## P9: Skeleton unification (0/1/2+ boundary) in Facts (unused, SSOT groundwork) + +- 指示書: `docs/development/current/main/phases/phase-29an/P9-SKELETON-UNIFICATION-INFERENCE-INSTRUCTIONS.md` +- ねらい: Skeleton 一意化の境界を Facts 側で SSOT 化(未接続、仕様不変) + ## Next(planned) -- P8: exit_usage と DomainPlan の整合を debug-only で固定(再発防止、仕様不変) - - 指示書: `docs/development/current/main/phases/phase-29an/P8-EXITUSAGE-INVARIANTS-INSTRUCTIONS.md` -- P9: Skeleton 一意化(0/1/2+ → None/Some/Freeze)を “骨格推論” に限定して SSOT 化 - P10: Feature 合成(ExitMap / ValueJoin / Cleanup)を CorePlan 合成へ繋ぐ