docs(phase29an): add p8 exit usage invariants

This commit is contained in:
2025-12-29 19:20:41 +09:00
parent 5ac2f35866
commit 2f63e20fd8
4 changed files with 89 additions and 4 deletions

View File

@ -2,11 +2,16 @@
## Current Focus: Phase 29anSkeleton/Feature Facts
Next: Phase 29an P7CanonicalLoopFacts projections
Next: Phase 29an P8exit_usage invariants, debug-only
運用ルール: 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 P7 完了**
- 目的: CanonicalLoopFacts に skeleton/exit_usage の projection を追加(挙動不変)
- 変更: `src/mir/builder/control_flow/plan/normalize/canonicalize.rs` / `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 P6 完了**
- 目的: planner入口に skeleton gate を追加Loop 以外は Ok(None) で fallback 維持、仕様不変)
- 変更: `src/mir/builder/control_flow/plan/planner/build.rs`

View File

@ -0,0 +1,76 @@
---
Status: Active
Scope: code仕様不変、debug-only の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 P8: exit_usage と DomainPlan の整合を debug-only で固定(仕様不変)
Date: 2025-12-29
Status: Ready for execution
Scope: planner の候補生成に “Feature invariants” を足して再発防止release 既定は不変)
## Objective
- `ExitUsageFacts`feature`DomainPlan` の関係を **debug_assert** で固定し、将来の Facts 拡張で “矛盾した plan” を作らないようにする
- まずは **確実に対応が取れるものだけ**を対象にするPattern1/2/4/5
## Non-goals
- 候補の集合/順序/ログ/エラー文字列の変更
- Freeze の新規発火gate を壊さない)
- Pattern6/7/8/9/3 など “return を含む可能性がある/不明” のものへ広げるP8ではやらない
## Invariants (SSOT)
対象: `build_plan_from_facts_ctx()` が生成する候補(`PlanCandidate.plan`)。
`exit_usage` と plan の対応:
- `DomainPlan::Pattern1SimpleWhile(_)``exit_usage.has_break == false && has_continue == false && has_return == false`
- `DomainPlan::Pattern2Break(_)``exit_usage.has_break == true`
- `DomainPlan::Pattern4Continue(_)``exit_usage.has_continue == true`
- `DomainPlan::Pattern5InfiniteEarlyExit(p)``p.exit_kind` に対応するフラグが true
- Return → `has_return`
- Break → `has_break`
- Continue → `has_continue`
## Implementation
Update:
- `src/mir/builder/control_flow/plan/planner/build.rs`
### Step 1: debug-only ヘルパー追加
`#[cfg(debug_assertions)]` の private 関数で:
- `fn debug_assert_exit_usage_matches_plan(plan: &DomainPlan, exit_usage: &ExitUsageFacts)`
- 対象4種だけチェックし、それ以外は何もしない
### Step 2: 候補 push 直前/直後にチェック
候補を `candidates.push(...)` する直前(または直後)に:
- `debug_assert_exit_usage_matches_plan(&candidate.plan, &facts.exit_usage);`
注意:
- `facts.exit_usage` は P7 の projection を使う(`facts.facts.features...` を見ない)
### Step 3: unit testsdebug-only 固定)
`build.rs``#[cfg(test)]` 内で:
- OK ケースpanicしないを 2 本Pattern1/Pattern2
- NG ケース(`#[should_panic]`)を 1 本Pattern1 + `has_break=true` など)
## Verificationrequired
- `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(p8): debug-assert exit usage invariants for plans"`

View File

@ -76,7 +76,11 @@ Status: ✅ COMPLETE実装コミット: `80c879fdb`
- 指示書: `docs/development/current/main/phases/phase-29an/P7-CANONICAL-LOOPFACTS-PROJECTIONS-INSTRUCTIONS.md`
- ねらい: normalize SSOT に “骨格/特徴” の入口を揃える(候補/順序/挙動は不変)
Status: ✅ COMPLETE実装コミット: `5ac2f3586`
## Nextplanned
- P8: Skeleton 一意化0/1/2+ → None/Some/Freezeを “骨格推論” に限定して SSOT 化
- P9: Feature 合成ExitMap / ValueJoin / Cleanupを CorePlan 合成へ繋ぐ
- 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 合成へ繋ぐ