2025-09-08 11:35:30 +09:00
|
|
|
|
# Self Current Task — Backlog (main)
|
|
|
|
|
|
|
2025-12-16 23:30:39 +09:00
|
|
|
|
Status: Active
|
|
|
|
|
|
Scope: 「次にやる候補」を短く列挙するメモ。現状は `docs/development/current/main/10-Now.md` を入口にする。
|
|
|
|
|
|
Related:
|
|
|
|
|
|
- `docs/development/current/main/10-Now.md`
|
|
|
|
|
|
- `docs/development/current/main/DOCS_LAYOUT.md`
|
2025-12-14 05:24:31 +09:00
|
|
|
|
|
2025-12-16 23:30:39 +09:00
|
|
|
|
## 直近(JoinIR/selfhost)
|
2025-12-14 05:24:31 +09:00
|
|
|
|
|
feat(anf): Phase 146/147 - Loop/If Condition ANF with Compare support
## Phase 146 P0: ANF Routing SSOT Unified
**Goal**: Unify ANF routing in `lower_expr_with_scope()` L54-84, remove legacy lowering
**Changes**:
- expr_lowerer_box.rs: Added scope check (PureOnly → skip ANF, WithImpure → try ANF)
- post_if_post_k.rs: Removed legacy inline lowering (L271-285), added `lower_condition_legacy()` helper
- contract.rs: Already had `CondLoweringFailed` out-of-scope reason
**Test Results**: ✅ Phase 146 P0 smoke (exit 7), 0 regressions
## Phase 146 P1: Compare Operator Support
**Goal**: Enable ANF for condition expressions with Compare operators
**Changes**:
- joinir_dev.rs: Added `anf_allow_pure_enabled()` (HAKO_ANF_ALLOW_PURE=1)
- expr_lowerer_box.rs: PureOnly scope ANF support (L56-66)
- execute_box.rs: Compare operator support (+122 lines)
- `execute_compare_hoist()`, `execute_compare_recursive()`, `ast_compare_to_joinir()`
- Extended `normalize_and_lower()` for Compare
**Test Results**: ✅ Phase 146 P1 smoke (exit 7 with flags), 0 regressions
## Phase 147 P0: Recursive Comparison ANF
**Goal**: Extend recursive ANF to Compare operators
**Changes**:
- contract.rs: Added `AnfParentKind::Compare` variant
- plan_box.rs: Compare case in BinaryOp routing (L68-79, L134-139)
- Distinguishes Compare vs arithmetic BinaryOp
**Benefits**: Enables recursive ANF for comparisons
- `s.length() == 3` → `t = s.length(); if (t == 3)` ✅
- `s1.length() < s2.length()` → `t1 = s1.length(); t2 = s2.length(); if (t1 < t2)` ✅
## Implementation Summary
**Files Modified** (9 files, +253 lines, -25 lines = +228 net):
1. src/config/env/joinir_dev.rs (+28 lines)
2. src/mir/control_tree/normalized_shadow/anf/contract.rs (+2 lines)
3. src/mir/control_tree/normalized_shadow/anf/execute_box.rs (+122 lines)
4. src/mir/control_tree/normalized_shadow/anf/plan_box.rs (+18 lines)
5. src/mir/control_tree/normalized_shadow/common/expr_lowerer_box.rs (+18 lines, -0 lines)
6. src/mir/control_tree/normalized_shadow/post_if_post_k.rs (+44 lines, -25 lines)
7. CURRENT_TASK.md
8. docs/development/current/main/10-Now.md
9. docs/development/current/main/30-Backlog.md
**Files Created** (7 files):
- apps/tests/phase146_p0_if_cond_unified_min.hako
- apps/tests/phase146_p1_if_cond_intrinsic_min.hako
- tools/smokes/.../phase146_p0_if_cond_unified_vm.sh
- tools/smokes/.../phase146_p0_if_cond_unified_llvm_exe.sh
- tools/smokes/.../phase146_p1_if_cond_intrinsic_vm.sh
- tools/smokes/.../phase146_p1_if_cond_intrinsic_llvm_exe.sh
- docs/development/current/main/phases/phase-146/README.md
**Acceptance Criteria**: ✅ All met
- cargo build --release: PASS (0 errors, 0 warnings)
- Phase 145 regressions: PASS (exit 12, 18, 5)
- Phase 146 P0: PASS (exit 7)
- Phase 146 P1: PASS (exit 7 with HAKO_ANF_ALLOW_PURE=1)
**Architecture**:
- SSOT: ANF routing only in `lower_expr_with_scope()` L54-84
- Box-First: Phase 145 `anf/` module extended
- Legacy removed: post_if_post_k.rs unified with SSOT
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-19 17:03:56 +09:00
|
|
|
|
- **収束方針(SSOT案): Expr/Condition/Control の 3 箱分割**
|
|
|
|
|
|
- ExprLowererBox(式SSOT): `AST(expr)` → `(prelude, value)`(ANF含む)。pure/impure/whitelist/strict を集約(入口SSOT)。
|
|
|
|
|
|
- ConditionLowererBox(条件→分岐SSOT): `AST(cond)` → `BranchPlan`。評価順は ExprLowererBox に委譲し、`&&/||` は制御語彙で扱う。
|
|
|
|
|
|
- ControlLowererBox(制御SSOT): `StepNode/ControlTree` → JoinIR(継続 + env)。`if/loop` を担当し、条件は ConditionLowererBox に委譲。
|
|
|
|
|
|
|
2025-12-19 05:28:49 +09:00
|
|
|
|
- **Phase 141 P2+(planned): Call/MethodCall(effects + typing を分離して段階投入)**
|
|
|
|
|
|
- ねらい: pure/impure 境界を壊さずに、impure lowering を段階投入する。
|
|
|
|
|
|
- 前提(DONE):
|
|
|
|
|
|
- Phase 141 P1.5: known intrinsic allowlist + available_inputs 3-source merge + diagnostics
|
|
|
|
|
|
- 受け入れ条件:
|
|
|
|
|
|
- out-of-scope は `Ok(None)` でフォールバック(既定挙動不変)
|
|
|
|
|
|
- effects の順序付けは SSOT で固定してから解禁(by-name 増殖禁止)
|
|
|
|
|
|
|
2025-12-19 08:36:45 +09:00
|
|
|
|
- **Phase 144-anf(planned): impure 式導入の順序固定(ANF)**
|
|
|
|
|
|
- ねらい: `x + f(y)` 等の “pure + impure 混在” で評価順が仕様になる前に、ANF で順序固定を SSOT 化する
|
|
|
|
|
|
- 入口: `docs/development/current/main/phases/phase-144-anf/INSTRUCTIONS.md`
|
|
|
|
|
|
- 受け入れ条件:
|
|
|
|
|
|
- impure を lowering できない場合は `Ok(None)` でフォールバック(既定挙動不変)
|
|
|
|
|
|
- dev/strict では「順序固定の欠落」を Fail-Fast(診断に順序ログを含める)
|
|
|
|
|
|
|
2025-12-19 06:33:56 +09:00
|
|
|
|
- **Phase 143-loopvocab R0(planned): Contract SSOT 抽出(refactor P0 → modular components)**
|
|
|
|
|
|
- 目的: loop_true_if_break_continue.rs を「検出/契約/変換」に分割し、P1/P2 での if分岐増殖を防ぐ
|
|
|
|
|
|
- 実装:
|
|
|
|
|
|
- 新ファイル: `src/mir/control_tree/normalized_shadow/common/loop_if_exit_contract.rs`
|
|
|
|
|
|
- `enum LoopIfExitThen { Break, Continue }`
|
|
|
|
|
|
- `struct LoopIfExitShape { has_else: bool, then: LoopIfExitThen, else_: Option<LoopIfExitThen>, cond_scope: ExprLoweringScope }`
|
|
|
|
|
|
- `enum OutOfScopeReason { NotLoopTrue, BodyNotSingleIf, ThenNotExit, ElseNotSupported, CondOutOfScope(...) }`
|
|
|
|
|
|
- Refactor: loop_true_if_break_continue.rs は「shape抽出 → lower」だけに縮退(SSOT は contract側)
|
|
|
|
|
|
- Tests: unit test を dedicated module へ分離(test maintainability)
|
2025-12-19 05:28:49 +09:00
|
|
|
|
- 受け入れ条件:
|
2025-12-19 06:33:56 +09:00
|
|
|
|
- cargo check ✅(no errors)
|
|
|
|
|
|
- P1/P2 での if分岐を防ぐ(contract で決定性を保証)
|
|
|
|
|
|
- out-of-scope は `Ok(None)` で一貫(既定挙動不変)
|
|
|
|
|
|
|
|
|
|
|
|
- **Phase 143-loopvocab P1(planned): continue 語彙追加**
|
|
|
|
|
|
- 対象: `loop(true) { if(cond_pure) continue }` を same lowering に通す
|
|
|
|
|
|
- 実装:
|
|
|
|
|
|
- LoopIfExitShape で `LoopIfExitThen::Continue` を許可
|
|
|
|
|
|
- JoinModule: if true → loop_step (continue semantics)
|
|
|
|
|
|
- Fixtures: `phase143_loop_true_if_continue_min.hako`
|
|
|
|
|
|
- Smoke: VM + LLVM EXE
|
|
|
|
|
|
- Out-of-scope は `Ok(None)` のまま
|
|
|
|
|
|
|
2025-12-19 16:19:49 +09:00
|
|
|
|
(DONE)Phase 143-loopvocab P2: else 対称化(B-C / C-B)
|
|
|
|
|
|
- 記録: `docs/development/current/main/10-Now.md`
|
|
|
|
|
|
|
|
|
|
|
|
- **Phase 143-loopvocab P3+(planned): impure conditions 対応**
|
|
|
|
|
|
- 目的: `if(cond_impure) break/continue` を ANF/順序固定の上で段階投入する
|
|
|
|
|
|
- 方針: Phase 145-anf の契約(hoist + left-to-right)を条件式にも適用
|
2025-12-18 08:36:38 +09:00
|
|
|
|
|
2025-12-17 17:39:12 +09:00
|
|
|
|
- **real-app loop regression の横展開(VM + LLVM EXE)**
|
|
|
|
|
|
- ねらい: 実コード由来ループを 1 本ずつ最小抽出して fixture/smoke で固定する(段階投入)。
|
2025-12-17 23:30:13 +09:00
|
|
|
|
- 現状: Phase 107(find_balanced_array/object / json_cur 由来)まで固定済み。
|
2025-12-18 02:19:41 +09:00
|
|
|
|
- 次候補: JsonLoader/JsonCur から 1 本ずつ(fixture + integration smoke)で増やす。
|
2025-12-17 17:39:12 +09:00
|
|
|
|
|
2025-12-16 23:30:39 +09:00
|
|
|
|
- **P5b “完全E2E”**(escape skip の実ループを end-to-end で固定)
|
2025-12-17 00:59:33 +09:00
|
|
|
|
- 現状: Phase 94 で VM E2E まで固定済み。次は selfhost 実コード(`apps/selfhost-vm/json_loader.hako`)へ横展開して回帰を減らす。
|
|
|
|
|
|
- 入口: `docs/development/current/main/phases/phase-94/README.md`
|
2025-12-18 02:19:41 +09:00
|
|
|
|
|
2025-12-16 23:30:39 +09:00
|
|
|
|
- **制御の再帰合成(docs-only → dev-only段階投入)**
|
2025-12-18 05:29:34 +09:00
|
|
|
|
- ねらい: `loop/if` ネストの "構造" を SSOT(ControlTree/StepTree)で表せるようにする
|
2025-12-16 23:30:39 +09:00
|
|
|
|
- 注意: canonicalizer は観測/構造SSOTまで(ValueId/PHI配線は Normalized 側へ)
|
2025-12-18 07:28:30 +09:00
|
|
|
|
- 現状: Phase 119–128(if-only Normalized: reads/inputs/unknown-read/partial-assign keep/merge)まで完了
|
2025-12-18 08:33:56 +09:00
|
|
|
|
- ✅ 完了: Phase 129-C(post-if を post_k continuation で表現)
|
2025-12-18 02:19:41 +09:00
|
|
|
|
- 入口: `docs/development/current/main/design/control-tree.md`
|
2025-12-04 10:52:10 +09:00
|
|
|
|
|
2025-12-16 23:30:39 +09:00
|
|
|
|
## 中期(ループ在庫の残り)
|
2025-09-08 11:35:30 +09:00
|
|
|
|
|
2025-12-16 23:30:39 +09:00
|
|
|
|
- **P5(guard-bounded)**: 大型ループを “小粒度” に割ってから取り込む(分割 or 新契約)
|
|
|
|
|
|
- **P6(nested loops)**: capability guard で Fail-Fast 維持しつつ、解禁時の契約を先に固定
|
2025-09-08 11:35:30 +09:00
|
|
|
|
|
2025-12-21 05:47:37 +09:00
|
|
|
|
## 中期(制御の表現力)
|
|
|
|
|
|
|
|
|
|
|
|
北極星: `docs/development/current/main/design/join-explicit-cfg-construction.md`
|
|
|
|
|
|
設計メモ: `docs/development/current/main/design/exception-cleanup-async.md`
|
|
|
|
|
|
|
|
|
|
|
|
- **catch/cleanup(Invoke)**
|
|
|
|
|
|
- 追加語彙を `Invoke(ok_edge, err_edge)` に絞って例外 edge を明示する(例外値は edge-args で運ぶ)。
|
|
|
|
|
|
- 実装タイミング: Phase 260(edge-args terminator 収束)の P1〜P2 以降が推奨。
|
|
|
|
|
|
- **cleanup/defer(cleanup normalizer)**
|
|
|
|
|
|
- Return/Throw/Break/Continue を cleanup に寄せる “脱出 edge 正規化” を箱化する(finally の後継としての cleanup)。
|
|
|
|
|
|
- 実装タイミング: catch/cleanup の次(例外 edge も含めて正規化するため)。
|
|
|
|
|
|
- **async/await(state machine lowering)**
|
|
|
|
|
|
- CFG語彙に混ぜず、AsyncLowerBox で state machine 化してから MIR に落とす。
|
|
|
|
|
|
- 実装タイミング: finally/defer の後(cancel/drop と cleanup の接続を先に固める)。
|
|
|
|
|
|
|
2025-12-16 23:30:39 +09:00
|
|
|
|
## ドキュメント運用
|
|
|
|
|
|
|
|
|
|
|
|
- 重複が出たら「設計 SSOT(design)」に集約し、Phaseログ(phases)は “何をやったか/検証したか” に限定する
|
|
|
|
|
|
- 調査ログ(investigations)は結論を SSOT に反映してから Historical 化する
|