Files
hakorune/CURRENT_TASK.md

180 lines
11 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# CURRENT_TASK (moved)
Status: SSOT
Scope: Repo root の旧リンク互換。現行の入口は `docs/development/current/main/10-Now.md`
- Now: `docs/development/current/main/10-Now.md`
- Backlog: `docs/development/current/main/30-Backlog.md`
---
## Handoff (current)
### 状況SSOT
**JoinIR 回帰 SSOT**
`./tools/smokes/v2/profiles/integration/joinir/phase29ae_regression_pack_vm.sh` が唯一の integration gate。phase143_* は対象外legacy pack で隔離。phase286_pattern9_* は legacy pack (SKIP) で運用。
**CorePlan migration 道筋 SSOT**
`docs/development/current/main/design/coreplan-migration-roadmap-ssot.md` が移行タスクの Done 判定の入口。
**Next implementation (Phase 29ao P7)**
`docs/development/current/main/phases/phase-29ao/README.md`
**2025-12-29: Phase 29am P0 COMPLETE (CorePlan If/Exit lowerer/verifier)**
CorePlan の If/Exit を lowerer/verifier で扱えるようにして、CorePlan 移行の土台を作った。
**2025-12-29: Phase 29am P1 COMPLETE (CoreLoopPlan.body Seq flatten)**
CoreLoopPlan.body の `Seq([Effect...])` を再帰で flatten して emit できるようにしたEffect-only制約は維持
**2025-12-29: Phase 29am P2 COMPLETE (Verifier: Loop.body Effect-only)**
Loop.body に If/Exit/Loop が混入したら PlanVerifier で fail-fast[V12]。Seq-of-effects は許可。
**2025-12-29: Phase 29am P3 COMPLETE (Exit alignment: “Exit is last” rule)**
CorePlan 内の Exit の乱用を抑制し、Frag/ExitMap と整合する表現へ寄せた([V11])。
**PlanRuleOrder SSOT**
single_planner の順序/名前 SSOT は `src/mir/builder/control_flow/plan/single_planner/rule_order.rs` に固定。PlannerContext で Pattern1 facts の抑制を開始し、残りの guard/filter は段階移行。
**2025-12-29: Phase 29aj P6 COMPLETE (JoinIR regression gate SSOT)**
JoinIR 回帰の integration gate を phase29ae pack に固定し、phase143_* を legacy pack で隔離。
**2025-12-29: Phase 29aj P7 COMPLETE (Pattern8 planner-first)**
Pattern8 BoolPredicateScan の Facts→Planner-first を導入し、single_planner の extractor 依存を縮小。
**2025-12-29: Phase 29ak P0 COMPLETE (PlanRuleOrder + PlannerContext plumbing)**
PlanRuleOrder を SSOT 化し、PlannerContext を配線未使用。single_planner の手書きテーブルを撤去。
**2025-12-29: Phase 29ak P1 COMPLETE (Pattern1 facts guard via planner)**
Pattern1 以外のループで pattern1_simplewhile facts 抽出を抑制。single_planner 側の guard は安全策として維持。
**2025-12-29: Phase 29ak P2 COMPLETE (Pattern8 static box filter via planner)**
static box では Pattern8 facts 抽出を抑制。single_planner 側の filter は安全策として維持。
**2025-12-29: Phase 29ak P3 COMPLETE (remove Pattern8 filter in single_planner)**
Pattern8 static box filter を single_planner から撤去し、planner/facts 側 SSOT に一本化。
**2025-12-29: Phase 29ak P4 COMPLETE (remove Pattern1 guard in single_planner)**
Pattern1 guard を single_planner から撤去し、planner/facts 側 SSOT と fallback 抑制に統一。
**2025-12-29: Phase 29ak P5 COMPLETE (planner candidate ctx gate)**
Pattern1/8 の候補抑制を planner 側に集約し、single_planner の Pattern1 抑制を撤去。
**2025-12-29: Phase 29al P0 COMPLETE (Skeleton/Feature model SSOT, docs-only)**
CorePlan を骨格→特徴→合成で説明する SSOT を追加し、Freeze taxonomy に unstructured を追加。
**2025-12-29: Phase 29al P1 COMPLETE (post-phi final form SSOT, docs-only)**
join 値PHI相当の最終表現layout/mapping/pred分類/verifyを 1 枚 SSOT として固定。
**2025-12-29: Phase 29al P2 COMPLETE (effect classification SSOT, docs-only)**
effect 分類Pure/Mut/Io/Controlと “許される変形” の最小法典を SSOT 化。
**2025-12-29: Phase 29al P3 COMPLETE (exitkind/cleanup/effect contract SSOT, docs-only)**
cleanup を ExitKind 語彙として扱い、Control/Io を跨いだ移動や DCE 消去の事故を防ぐ境界を SSOT 化。
**2025-12-29: Phase 29aj P10 COMPLETE (single_planner unified shape)**
single_planner を全パターンで planner-first → extractor フォールバックの共通形に統一(挙動不変)。
**2025-12-29: Phase 29aj P9 COMPLETE (phase286 pattern9 legacy isolation)**
phase286_pattern9_frag_poc を legacy pack (SKIP) に隔離し、JoinIR 回帰 SSOT を phase29ae pack に固定。
**2025-12-29: Phase 29aj P8 COMPLETE (Pattern9 planner-first)**
Pattern9 AccumConstLoop の Facts→Planner-first を導入し、single_planner の extractor 依存を縮小。
**2025-12-29: Phase 29ai P15 COMPLETE (Pattern2 promotion hint observe)**
strict/dev 時のみ `[plan/pattern2/promotion_hint:{TrimSeg|DigitPos}]` を観測できるようにし、次は promotion hint の Plan/Frag 吸収残作業P16候補
**2025-12-29: Phase 29aj P0 COMPLETE (PlannerOutcome observability SSOT)**
planner outcomefacts+planを SSOT 化し、single_planner の観測が planner facts のみに依存するように統一。
**2025-12-29: Phase 29aj P1 COMPLETE (Remove legacy_rules)**
single_planner の legacy_rules を撤去し、Pattern1/3/4/5/8/9 の抽出を plan/extractors に統一。
**2025-12-29: Phase 29aj P2 COMPLETE (Pattern1 planner-first)**
chosen_rule を撤去し、Pattern1 SimpleWhile の Facts→Planner-first を導入(仕様不変)。
**2025-12-29: Phase 29aj P3 COMPLETE (Pattern3 planner-first)**
Pattern3 If-Phi の Facts→Planner-first を導入し、single_planner の extractor 依存を縮小。
**2025-12-29: Phase 29aj P4 COMPLETE (Pattern4 planner-first)**
Pattern4 Continue の Facts→Planner-first を導入し、single_planner の extractor 依存を縮小。
**2025-12-29: Phase 29aj P5 COMPLETE (Pattern5 planner-first)**
Pattern5 Infinite Early Exit の Facts→Planner-first を導入し、single_planner の extractor 依存を縮小。
**2025-12-27: Phase 188.3 / Phase 287 P2 COMPLETE (Pattern6 nested loop: merge/latch fixes)**
Pattern61-level nested loopの JoinIR→bridge→merge 経路で発生していた `undefined ValueId``vm step budget exceeded`(無限ループ)を解消。`apps/tests/phase1883_nested_minimal.hako` が RC=9 を返し、quick 154 PASS を維持。
- SSOTmergeの契約:
- latch_incoming を記録してよいのは `TailCallKind::BackEdge` のみLoopEntry は上書き禁止)
- entry-like 判定は “JoinIR MAIN のみ” を対象にするblock-id 推測はしない): `src/mir/builder/control_flow/joinir/merge/contract_checks/entry_like_policy.rs`
- latch 二重設定は `debug_assert!` で fail-fast回帰検知
- 変更箇所:
- `src/mir/builder/control_flow/joinir/merge/instruction_rewriter.rs`
- `src/mir/builder/control_flow/joinir/merge/loop_header_phi_info.rs`
- 検証DONE:
- [x] 再現とPHI確認Pattern6
- [x] latch記録条件を修正BackEdgeのみ
- [x] デバッグ出力を撤去(恒常出力なし)
- [x] quick/fixtureで検証quick 154 PASS / fixture RC=9
- [x] docsを締めて次の指示書を用意refactor挟み込み用
**2025-12-26: Phase 286 P2.2 COMPLETE (Hygiene: extractor重複排除 + router小整理)**
Pattern1/Pattern4 の Plan/Frag PoC 完了後、extractor の `extract_loop_increment_plan``common_helpers.rs` に統一、router の 3行パターンnormalize→verify→lower`lower_via_plan()` ヘルパーで共通化。~65行削減、quick 154 PASS 維持。
**2025-12-26: Phase 286 P2.3 COMPLETE (Pattern9 AccumConstLoop Plan化 PoC)**
Pattern9 (AccumConstLoop) を Plan/Frag SSOT に移行完了。PHI 2本loop_var, acc_var、const/var 両方 OK。Pattern9 は Pattern1 より先にチェックより具体的なパターン。quick 154 PASS 維持。
- 現行の入口: `docs/development/current/main/10-Now.md`
- Phase 286 詳細: `docs/development/current/main/phases/phase-286/README.md`
- 次の候補: `docs/development/current/main/30-Backlog.md`
- Design goal: `docs/development/current/main/design/join-explicit-cfg-construction.md`
### 直近の道筋JoinIR / Normalized
### 設計方針メモSSOT候補
- ExprLowererBox式SSOT
- 役割: `AST(expr)``(prelude: Vec<Inst>, value: ValueId)`ANF含む
- pure/impure/whitelist/strict の契約を集約入口SSOT
- ConditionLowererBox条件→分岐SSOT
- 役割: `AST(cond)``BranchPlan`(短絡なら分岐語彙で組む)
- 評価順は ExprLowererBox に委譲ANFで順序固定
- `&&/||` は制御として扱い、式で無理しない
- ControlLowererBox制御SSOT
- 役割: `StepNode/ControlTree` → JoinIR継続 + env
- `if/loop` はここ、条件の中身は ConditionLowererBox に委譲
- Phase 139: if-only `post_k` の return lowering を `ReturnValueLowererBox` に統一DONE
- `docs/development/current/main/phases/phase-139/README.md`
- Phase 140: `NormalizedExprLowererBox` 初版pure expression のみDONE
- SSOT: `docs/development/current/main/design/normalized-expr-lowering.md`
- `docs/development/current/main/phases/phase-140/README.md`
- Phase 141 P0: impure 拡張点contractを SSOT 化Call/MethodCall はまだ out-of-scopeDONE
- `docs/development/current/main/phases/phase-141/README.md`
- Phase 141 P1: “既知 intrinsic だけ” を許可して段階投入DONE
- `docs/development/current/main/phases/phase-141/README.md`
- Phase 141 P1.5: known intrinsic registry + available_inputs 3-source merge + diagnosticsDONE
- `docs/development/current/main/phases/phase-141/README.md`
- Phase 142-loopstmt P0: 正規化単位を statementloop 1個へ寄せるDONE
- `docs/development/current/main/phases/phase-142-loopstmt/README.md`
- Phase 142-loopstmt P1: LLVM EXE smoke同 fixtureを追加DONE
- `docs/development/current/main/phases/phase-142-loopstmt/README.md`
- Phase 141 P2+: Call/MethodCalleffects + typingを分離して段階投入
- Historical context: `docs/development/current/main/investigations/joinir-generalization-study.md`
- Phase 143-loopvocab P0/P1: loop 内 if/break/continue の語彙追加DONE
- `docs/development/current/main/phases/phase-143-loopvocab/README.md`
- Phase 143-loopvocab P2: else 対称化B-C / C-BDONE
- `docs/development/current/main/phases/phase-143-loopvocab/README.md`
- Phase 145-anf P0/P1/P2: ANFimpure hoist + 再帰的線形化DONE
- `docs/development/current/main/phases/phase-145-anf/README.md`
- Phase 146in progress: Loop/If 条件式へ ANF を横展開(順序固定と診断)
- `docs/development/current/main/phases/phase-146/README.md`
## Resolved (historical)
### WSL EXDEV / cargo build failure (resolved)
- 2025-12-18: `Invalid cross-device link (os error 18)` により `cargo build` が失敗する事象があったが、`wsl --shutdown` 再起動後に復旧。
- 再発時のワークアラウンド: `tools/build_llvm.sh` は EXDEV を避けるため `TMPDIR``target/...` 配下へ寄せる。