## 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>
Hakorune Smoke Tests v2 — Guide (Nyash-compatible)
Overview
- Entry:
tools/smokes/v2/run.sh— unified runner for quick/integration/full. - Profiles:
quick— fast developer checks.integration— VM↔LLVM parity, basic stability.full— comprehensive matrix.
🎯 Two Baselines (Runbook)
これから開発の基準となる2つのベースライン:
📦 VM ライン(Rust VM - 既定)
用途: 開発・デバッグ・検証用(高速・型安全)
# ビルド
cargo build --release
# 一括スモークテスト
tools/smokes/v2/run.sh --profile quick
# 個別スモークテスト
tools/smokes/v2/run.sh --profile quick --filter "<glob>"
# 例: --filter "core/json_query_min_vm.sh"
# 単発実行(参考)
$NYASH_BIN --backend vm apps/APP/main.hako
⚡ llvmlite ライン(LLVMハーネス)
用途: 本番・最適化・配布用(実証済み安定性)
前提: Python3 + llvmlite
pip install llvmlite # 未導入の場合
実行手順:
# ビルド(LLVM_SYS_180_PREFIX不要!)
cargo build --release --features llvm
# 一括スモークテスト
tools/smokes/v2/run.sh --profile integration
# 個別スモークテスト
tools/smokes/v2/run.sh --profile integration --filter "<glob>"
# 単発実行
NYASH_LLVM_USE_HARNESS=1 $NYASH_BIN --backend llvm apps/tests/peek_expr_block.hako
# 有効化確認
$NYASH_BIN --version | rg -i 'features.*llvm'
💡 重要: 両方のラインのテストが通ることで、MIR14統一アーキテクチャの品質を保証!
🔁 QuickでAST/LLVM系も実行したいとき
通常、quick は LLVM未ビルド時に AST/LLVM系テストを自動で SKIP します。
Quickでも実行したい場合は、先に LLVM 有効でビルドしてください:
LLVM_SYS_180_PREFIX=$(llvm-config-18 --prefix) cargo build --release --features llvm
tools/smokes/v2/run.sh --profile quick
テストランナーは LLVM 非対応時にヒントを出力します(buildコマンドの案内)。
Notes
- Using resolution: prefer nyash.toml aliases (SSOT). Some tests may enable
NYASH_ALLOW_USING_FILE=1internally for convenience. - Plugin warnings are informational; smokes are designed to pass without dynamic plugins.
- Harness single-run may take longer due to link+exec; integration profile includes generous timeouts.
- Binary selection in scripts: always use
$NYASH_BIN(the runner sets it totarget/release/hakorunewhen present, otherwise falls back tonyash). - Branding: user‑visible messages prefer “Hakorune”; the legacy
nyashbinary remains for compatibility but may be gated(HAKO_ALLOW_NYASH=1)。
Dev Mode (defaults)
- In v2 smokes, the
quickprofile exportsNYASH_DEV=1by default.- This enables CLI
--dev-equivalent defaults inside Nyash:- AST using ON (SSOT + AST prelude merge)
- Operator Boxes in observe mode (no adoption)
- Minimal diagnostics; output parity is preserved
- This enables CLI
- You can also run manually with
nyash --dev script.hako.
Common commands
- Quick suite (auto
NYASH_DEV=1):tools/smokes/v2/run.sh --profile quick
- Focus JSON smokes:
tools/opbox-json.sh(Roundtrip/Nested, plugins disabled, generous timeout)
- One-off program (VM):
$NYASH_BIN --backend vm --dev apps/APP/main.hako
Key env knobs
NYASH_DEV=1— enable dev defaults (same effect as--dev).SMOKES_DEFAULT_TIMEOUT— per test timeout seconds (default 15 for quick).SMOKES_PLUGIN_MODE=dynamic|static— plugin mode for preflight (auto by default).SMOKES_FORCE_CONFIG=rust_vm_dynamic|llvm_static— force backend config.SMOKES_NOTIFY_TAIL— lines to show on failure tail (default 80).
Notes
- Dev defaults are designed to be non-intrusive: tests remain behavior‑compatible.
- To repro outside smokes, either pass
--devor exportNYASH_DEV=1.
Heavy JSON probes
- Heavy JSON tests (nested/roundtrip/query_min) run a tiny parser probe first.
- The probe's stdout last non-empty line is trimmed and compared to
ok. - If not
ok, the test is SKIP (parser unavailable), not FAIL. This avoids false negatives due to environment noise or optional dependencies.