diff --git a/docs/development/current/main/10-Now.md b/docs/development/current/main/10-Now.md index f6cd8932..9a264af2 100644 --- a/docs/development/current/main/10-Now.md +++ b/docs/development/current/main/10-Now.md @@ -2,31 +2,24 @@ ## Next (planned) +- Phase 259: `StringUtils.is_integer/1`(nested-if + loop)を JoinIR で受理して `--profile quick` を進める - Phase 141 P2+: Call/MethodCall 対応(effects + typing を分離して段階投入、ANF を前提に順序固定) - Phase 143-loopvocab P3+: 条件スコープ拡張(impure conditions 対応) - 詳細: `docs/development/current/main/30-Backlog.md` -## 2025-12-20:Phase 257 P1.1/P1.2/P1.3 完了 ✅ +## Current First FAIL (SSOT) -- **P1.1**: Pattern6 SSOT fix(false positive 根治) - - `can_lower()` が `extract_scan_with_init_parts()` を呼び出して SSOT を確立 - - `index_of_string/2` の誤検出が解消(`Ok(None)` で graceful fall-through) -- **P1.2**: LoopHeaderPhi CFG correction(entry predecessor 自動計算) - - Step 0: `update_successors_from_terminator()` を手動実行(instruction_rewriter が set_terminator() をバイパスするため) - - CFG から entry predecessors を計算(header_preds - latch_block) - - 複数 entry preds 対応(bb0 host + bb10 JoinIR main) - - host_entry_block を明示的に追加(emit_jump が finalize() 後に実行されるため) -- **P1.3**: Smoke script validation(既存実装確認) - - `phase254_p0_index_of_vm.sh`:`--verify` + VM error detection で false positive 回避 +- `json_lint_vm / StringUtils.is_integer/1`(Phase 259) -**検証結果**: -- ✅ `phase254_p0_index_of_min.hako` verify → PASS -- ✅ `phase257_p0_last_index_of_min.hako` verify → PASS -- ✅ `./tools/smokes/v2/run.sh --profile quick` → Pattern6 false positive なし(別の未サポートパターンで止まる) +## 2025-12-20:Phase 258(index_of_string/2 dynamic window scan)✅ -**技術的発見**: -- JoinIR merge では host entry block (bb0) の Jump が Phase 6 で設定されるため、Phase 4.5 の finalize() 時点で CFG に現れない -- 解決策:`builder.current_block` を捕捉し、CFG 計算後に明示的に entry_preds へ追加 +- Phase 258 README: `docs/development/current/main/phases/phase-258/README.md` +- Result: `index_of_string/2` を JoinIR で受理し、quick の first FAIL を `is_integer/1` へ進めた + +## 2025-12-20:Phase 257(Pattern6 reverse scan + PHI/CFG stabilization)✅ + +- Phase 257 README: `docs/development/current/main/phases/phase-257/README.md` +- Result: `last_index_of/2` を Pattern6(reverse scan)で受理し、PHI predecessor mismatch を fail-fast + 自動補正で根治 ## 2025-12-19:Phase 146/147 完了 ✅ @@ -93,11 +86,16 @@ - Goal: `StringUtils.last_index_of/2` を JoinIR で受理し、`--profile quick` を緑に戻す - Investigation(最小再現/論点): `docs/development/current/main/investigations/phase-257-last-index-of-loop-shape.md` - Status: Pattern6 reverse scan + PHI/CFG 安定化は完了(最初の FAIL は次へ移動) - - Current first FAIL: `json_lint_vm / StringUtils.is_integer/1`(nested-if + loop pattern, unsupported) + - Current first FAIL: `json_lint_vm / StringUtils.index_of_string/2`(dynamic window scan, unsupported) ## 2025-12-20:Phase 258(is_integer nested-if + loop)🔜 - Phase 258 README: `docs/development/current/main/phases/phase-258/README.md` + - Status: `index_of_string/2` を対象(dynamic window scan) + +## 2025-12-20:Phase 259(is_integer nested-if + loop)🔜 + +- Phase 259 README: `docs/development/current/main/phases/phase-259/README.md` ## 2025-12-19:Phase 254(index_of loop pattern)✅ 完了(Blocked by Phase 255) diff --git a/docs/development/current/main/phases/phase-257/README.md b/docs/development/current/main/phases/phase-257/README.md index 1d40190e..408f4e66 100644 --- a/docs/development/current/main/phases/phase-257/README.md +++ b/docs/development/current/main/phases/phase-257/README.md @@ -1,6 +1,6 @@ # Phase 257: Loop with Early Return Pattern -Status: Active +Status: Completed (2025-12-20) Scope: Pattern6(ScanWithInit)拡張で reverse scan + early return を受理する Related: - Phase 256 完了(Pattern2 boundary SSOT 化、entry_param_mismatch 根治) @@ -9,8 +9,8 @@ Related: ## Current Status (SSOT) - Former first FAIL: `json_lint_vm / StringUtils.last_index_of/2`(P0/P1で解消) -- Current first FAIL: `json_lint_vm / StringUtils.is_integer/1`(nested-if + loop, still unsupported) -- Approach (done): Pattern6(ScanWithInit)を reverse scan + early return に拡張し、PHI/CFG を fail-fast + 自動補正で安定化 +- Current first FAIL: `json_lint_vm / StringUtils.is_integer/1`(Phase 259) +- Result: Pattern6 reverse scan + PHI/CFG 安定化(P0/P1)により quick が次へ進む --- @@ -129,23 +129,16 @@ Pattern6(ScanWithInit)を “scan direction” を持つ形に一般化す - Pattern6 を双方向 scan に拡張(forward/reverse) - reverse scan 用 lowerer を追加(`scan_with_init_reverse.rs`) - `apps/tests/phase257_p0_last_index_of_min.hako` を追加 -- ただし現状は「PHI predecessor mismatch」が先に露出しており、P1 でインフラ不変条件を固定する必要がある +- ただし当初は「PHI predecessor mismatch」が露出したため、P1 でインフラ不変条件を固定した -## Phase 257 P1(次の指示書 / SSOT) +### P1(完了) -### Goal +P1 で以下を実装し、runtime の `phi pred mismatch` を compile-time 側で捕捉・根治した: -- Pattern6 の実行時 `phi pred mismatch` を根治し、`index_of` / `last_index_of` が VM で正常に走る -- `./tools/smokes/v2/run.sh --profile quick` の最初の FAIL を次へ進める - -### Tasks(順序) - -1) MIR verifier を強化して `InvalidPhi` を検出する(fail-fast) - - 期待: phi inputs が「ブロックの predecessor 全部」をカバーし、自己ブロック(self)を含まない -2) Pattern6 の loop header PHI の entry edge source を正す - - `entry_block == header_block` になっているケースを禁止し、必要なら preheader を作る or merge entry を main に寄せる -3) smoke の false positive を防ぐ - - `phase254_p0_index_of_vm.sh` は `--verify` を併用するか、VM error を検出して FAIL にする +- Pattern6 の誤検出防止(detect/extract SSOT) +- MIR verifier へ PHI predecessor 検証を追加(fail-fast) +- loop header PHI の entry edge を CFG から復元(self pred 根治) +- smoke の false positive を抑止(`--verify` + VM error 検出) --- diff --git a/docs/development/current/main/phases/phase-258/README.md b/docs/development/current/main/phases/phase-258/README.md new file mode 100644 index 00000000..f8b80070 --- /dev/null +++ b/docs/development/current/main/phases/phase-258/README.md @@ -0,0 +1,47 @@ +Status: Completed (2025-12-20) +Scope: `StringUtils.index_of_string/2`(dynamic window scan)を JoinIR で受理して `--profile quick` を進める。 +Related: +- Now: `docs/development/current/main/10-Now.md` +- Phase 257: `docs/development/current/main/phases/phase-257/README.md` +- Phase 259 (Next): `docs/development/current/main/phases/phase-259/README.md` +- Design goal: `docs/development/current/main/design/join-explicit-cfg-construction.md` + +# Phase 258: `StringUtils.index_of_string/2` (dynamic window scan) + +## Current Status (SSOT) + +- ✅ **P0 完了**(2025-12-21) +- Former first FAIL: `json_lint_vm / StringUtils.index_of_string/2` +- **New first FAIL**: `json_lint_vm / StringUtils.is_integer/1`(Phase 259へ移行) +- Shape summary (from quick log): + - prelude: `if substr.length()==0 return 0`, `if substr.length()>s.length() return -1` + - loop: `loop(i <= s.length() - substr.length()) { if s.substring(i, i+substr.length()) == substr return i; i=i+1 }` + - post: `return -1` + - caps: `If,Loop,Return` + +## Goal + +- ✅ `./tools/smokes/v2/run.sh --profile quick` が `StringUtils.index_of_string/2` を突破し、次の FAIL へ進む + +## Proposed Approach (P0) + +方針: Pattern6(ScanWithInit)を “needle length 付き scan” に最小拡張する(構造で解決) + +Pattern6 との差分だけを足す: +- loop cond: `i <= s.length() - substr.length()`(bound 付き) +- window: `substring(i, i + substr.length())` +- needle: `substr`(String) + +JoinIR 側は P0 では “毎回 length() を呼んでよい”。まず correctness を固定: +- `needle_len = substr.length()` +- `bound = s.length() - needle_len` +- stop: `i > bound` で k_exit(not-found return) +- match: `s.substring(i, i + needle_len) == substr` で return i +- step: `i = i + 1` + +## Tasks (Draft) + +1) Fixture + integration smokes +2) Pattern6 extractor を拡張して `index_of_string/2` の loop 形を accept(Fail-Fast) +3) Pattern6 lowerer を拡張(dynamic window length / bound)して JoinIR を生成 +4) `--verify` / integration / quick を回して SSOT 更新 diff --git a/docs/development/current/main/phases/phase-259/README.md b/docs/development/current/main/phases/phase-259/README.md new file mode 100644 index 00000000..0a8ec299 --- /dev/null +++ b/docs/development/current/main/phases/phase-259/README.md @@ -0,0 +1,29 @@ +Status: Active +Scope: `StringUtils.is_integer/1`(nested-if + loop)を JoinIR で受理して `--profile quick` を進める。 +Related: +- Now: `docs/development/current/main/10-Now.md` +- Phase 258: `docs/development/current/main/phases/phase-258/README.md` +- Design goal: `docs/development/current/main/design/join-explicit-cfg-construction.md` + +# Phase 259: `StringUtils.is_integer/1` (nested-if + loop) + +## Current Status (SSOT) + +- Current first FAIL: `json_lint_vm / StringUtils.is_integer/1` +- Shape summary(ログ由来): + - prelude: nested-if to compute `start` (handles leading `"-"`) + - loop: `loop(i < s.length()) { if not this.is_digit(s.substring(i, i+1)) { return false } i = i + 1 }` + - post: `return true` + - caps: `If,Loop,NestedIf,Return` + +## Goal + +- `StringUtils.is_integer/1` を JoinIR で受理し、quick の first FAIL を次へ進める + +## Proposed Approach (P0) + +方針: prelude(nested-if)は既存 lowering のまま、loop 部分だけを scan パターンへ寄せる(構造で解決)。 + +P0 の狙い: +- loop の core は “scan until mismatch” で、Pattern6(scan)と近い +- ただし return 値が `i/-1` ではなく `true/false` なので、scan パターンの “return payload” を一般化する必要がある可能性がある