Commit Graph

1000 Commits

Author SHA1 Message Date
ab1510920c feat(edgecfg): Phase 265 P0 - compose/verify 最小実装(入口SSOT迷子防止)
🎯 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-21 13:07:17 +09:00
923a442326 refactor(edgecfg): add Frag/ExitKind API entrypoint (Phase 264 design-first)
Phase 264 P0: EdgeCFG Fragment 入口API作成(実装置換なし)

- 入口フォルダ作成: src/mir/builder/control_flow/edgecfg/api/
- コア型定義: ExitKind, EdgeStub, Frag
- 合成関数シグネチャ: seq, if_, loop_, cleanup(中身TODO、pub(crate))
- 最小テスト: 3個のユニットテスト追加(frag.rs)
- ドキュメント連動: edgecfg-fragments.md に実装入口追記

制約遵守:
- 既存 pattern6/7/8 未改変
- merge/EdgeCFG 未改変
- 既存LoopId使用(control_form.rs に PartialOrd, Ord 追加)
- MIR側EdgeArgs使用(JoinIRと混線回避)
- BTreeMap採用(決定的順序保証、Phase 69-3 教訓)

次フェーズ: Phase 265 で Pattern8 適用時に compose::loop_ を実装

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-21 12:49:53 +09:00
be4de67601 fix(joinir): improve Pattern3 classification to exclude simple conditional assignment (Phase 264 P0)
Problem:
- Pattern3 heuristic was too conservative: detect_if_in_body() returned
  true for ANY if statement, causing simple conditional assignments to be
  misclassified as Pattern3IfPhi
- Example: `if i == 0 then seg = "first" else seg = "other"` was routed
  to Pattern3, but Pattern3 only handles if-sum patterns like
  `sum = sum + (if x then 1 else 0)`
- This caused loops with conditional assignment to fail Pattern3 check
  and exhaust all routing paths

Solution (Conservative, Phase 264 P0):
- ast_feature_extractor.rs:
  - detect_if_else_phi_in_body(): Always return false
  - has_if = has_if_else_phi (don't use detect_if_in_body())
- loop_pattern_detection/mod.rs:
  - Add has_if_sum_signature() (returns false for P0)
  - has_if_else_phi = carrier_count > 1 && has_if_sum_signature(scope)

Effect:
- Simple conditional assignment loops now fall through to Pattern1 
- Pattern3 misrouting prevented 

Results:
- Lib tests: 1368/1368 PASS (no regression)
- Minimal repro: phase264_p0_bundle_resolver_loop_min.hako PASS 
- Quick smoke: 45/46 (unchanged - complex BundleResolver loop needs P1)

Phase 264 P1 TODO:
- Implement accurate if-sum signature detection (AST/CFG analysis)
- Support complex nested loops in Pattern2 or new pattern

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-21 11:49:03 +09:00
e3dd1bbecb docs: Phase 263 P0 完了記録(Pattern2 fallback 修正)
- 10-Now.md: Phase 263 P0 完了記録を追加(最上部に配置)
- phase-263/README.md: 詳細な実装記録・検証結果を作成
- 30-Backlog.md: Phase 263+ planned 項目を追加
  - Pattern2 LoopBodyLocal promotion(seg)
  - PromoteDecision API hardening(構造で迷子防止)
- phase263_p0_pattern2_seg_vm.sh: smoke test スクリプト改善

検証結果:
- cargo test --lib: 1368/1368 PASS 
- quick smoke: 45/46 PASS  (大幅改善)
- Pattern2 が正しく abort することを確認
2025-12-21 10:39:48 +09:00
fc6eed1b04 docs: Phase 260 P2 完了記録 + EdgeCFG SSOT 確立
Update phase-260/README.md:
- Status: P2 完了 (EdgeCFG SSOT確立)
- Add P2 completion record with test results
- Add EdgeCFG SSOT definition (Jump/Branch: terminator SSOT, Return: metadata exception)
- Document unified API (read/write separation)
- Note Option B' trade-off (Return metadata exception)

Update 10-Now.md:
- Add Phase 260 P2 completion entry (2025-12-21)
- Test results: 1368 lib tests, 45/46 smoke, phase258 tail call
- Verification: 0 jump_args references (comments excluded)
- 9 files modified

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-21 09:39:39 +09:00
c0334f8b7e refactor(mir): phase260 p0.2 hide legacy edge-args reads behind BasicBlock API
- Add block.return_env() getter for Return env metadata
- Update instruction_rewriter.rs to use block.return_env()
- Update exit_collection.rs to use block.return_env()
- Prepare for Phase 260 P2 (jump_args deletion)

This consolidates all legacy edge-args reads through BasicBlock API,
enabling clean deletion of jump_args field in P2.
2025-12-21 09:01:35 +09:00
2f2596db37 refactor(mir): phase261 p0.1 unify return edge-args writes 2025-12-21 08:40:34 +09:00
7c9f453fc6 refactor(mir): phase261 p0 enforce edge-args writer ssot (verify + sync) 2025-12-21 08:32:04 +09:00
89c5fc2654 docs: Phase 260 P0.3 完了記録 + 既知FAIL SSOT更新
**10-Now.md 更新**:
- Phase 260 P0.2/P0.3 完了記録追加(15モジュール、約3941行、53単体テスト)
- Current First FAIL を "P0.3完了後" に更新
- 既知FAILに "Phase 260 scope外" を明記
- 期待/実際の詳細追加
- 次アクション: 機能側Phase(Pattern2 LoopBodyLocal promotion)へ

**phase-260/README.md 更新**:
- Status: P0.3 完了 
- P0.2/P0.3 進捗セクション追加(commit履歴、成果)
- モジュール分割の責務一覧(Utilities 7 + Handlers 8)
- SSOT維持確認項目(jump_args直参照ゼロ、out_edges()/edge_args_to() SSOT維持、PHI preservation、Phase metadata保持)

Phase 260 完全達成: CFG基盤整備完了、今後は機能側Phaseへ

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-21 08:18:29 +09:00
8fa7e64f24 docs(phase260): checkpoint P0/P0.1 + update quick first fail 2025-12-21 05:54:00 +09:00
1fe5be347d refactor(mir): phase260 p0.1 strangler hardening + smoke fixtures 2025-12-21 05:47:37 +09:00
4dfe3349bf refactor(mir): phase260 p0 edge-args plumbing (strangler) + ssot api + docs 2025-12-21 04:34:22 +09:00
4496b6243d feat(joinir): Phase 259 P0 complete - Pattern8 final fixes + docs (pre-block-params migration)
Phase 259 P0: Pattern8 (BoolPredicateScan) 完全完了
is_integer/1 を Pattern8 で受理し、VM/LLVM EXE 両方で動作確認完了。
次の大工事(block-parameterized CFG への移行)前のマイルストーンとして記録。

## Key Fixes Applied

1. **skipped_entry_redirects** (instruction_rewriter.rs)
   - k_exit のスキップ時、entry block 参照を exit_block_id へリダイレクト
   - BasicBlockId not found エラーを根治

2. **loop_var_name** (pattern8_scan_bool_predicate.rs)
   - merge_entry_block 選択に使用(`Some(parts.loop_var.clone())`)
   - 未設定時の誤った entry block 選択を修正

3. **loop_invariants** (pattern8_scan_bool_predicate.rs)
   - PHI-free 不変量パラメータ(`[(me, me_host), (s, s_host)]`)
   - loop_var_name 設定時、BoundaryInjector が join_inputs Copy を全スキップするため必要
   - Pattern6 と同じ設計(header PHI で不変量を保持)

4. **expr_result** (pattern8_scan_bool_predicate.rs)
   - k_exit からの返り値を明示設定(`Some(join_exit_value)`)
   - Pattern7 style(推測ではなく明示)

5. **Smoke test scripts**
   - set +e パターンで exit code 7 をキャプチャ
   - LLVM EXE スクリプトにコメント追加(tools/build_llvm.sh 経由の明記)

## Contract Documentation

- join-explicit-cfg-construction.md に Pattern8 契約の具体例を追加
  - "pattern増でも推測増にしない" の実例として記録
  - loop_var_name / loop_invariants / expr_result / jump_args_layout の契約を明示
- 20-Decisions.md に正規化(Semantic/Plumbing)の分離方針を追記
- DOCS_LAYOUT.md に重要ドキュメントへの参照を追加

## Test Results

-  VM smoke test: `[PASS] phase259_p0_is_integer_vm` (exit 7)
-  LLVM EXE: tools/build_llvm.sh 経由で exit 7 確認
-  --verify: PASS

## Next FAIL (Phase 260+)

- Function: `Main.main/0` in `apps/examples/json_lint/main.hako`
- Error: `[cf_loop/pattern2] Failed to extract break condition from loop body`
- Pattern: Nested loop(外側 loop + 内側 loop with break)

🚀 次の大工事: block-parameterized CFG への移行を開始します。

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-21 03:21:22 +09:00
a767f0f3a9 feat(joinir): Phase 259 P0 - Pattern8 BoolPredicateScan + Copy binding fix
Pattern8 (Boolean Predicate Scan) implementation for is_integer/1:
- New pattern detection for `loop + if not predicate() { return false }`
- JoinIR lowerer with main/loop_step/k_exit structure
- Me receiver passed as param (by-name 禁止)

Key fixes:
1. expr_result = Some(join_exit_value) (Pattern7 style)
2. Tail-call: dst: None (no extra Ret instruction)
3. instruction_rewriter: Add `&& is_loop_header_with_phi` check
   - Pattern8 has no carriers → no PHIs → MUST generate Copy bindings
   - Without this, ValueId(103/104/105) were undefined

Status: Copy instructions now generated correctly, but exit block
creation issue remains (next step: Step A-C in指示書).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-21 02:40:07 +09:00
e4f57ea83d docs: update Phase 257-259 SSOT (first FAIL is is_integer) 2025-12-21 00:29:55 +09:00
73ddc5f58d feat(joinir): Phase 257 P1.1/P1.2/P1.3 - Pattern6 SSOT + LoopHeaderPhi CFG fix
P1.1: Pattern6 false positive fix (SSOT approach)
- can_lower() now calls extract_scan_with_init_parts() for SSOT
- index_of_string/2 no longer triggers false positive
- Graceful fall-through with Ok(None)

P1.2: LoopHeaderPhi CFG-based correction
- Step 0: Manual successor update from terminators
- CFG-based entry predecessor computation (header_preds - latch)
- Multi-entry-pred support (bb0 host + bb10 JoinIR main)
- Explicit host_entry_block addition (emit_jump runs after finalize)

P1.3: Smoke script validation
- phase254_p0_index_of_vm.sh: --verify + VM error detection
- phase257 smokes updated

Acceptance criteria (all PASS):
 phase254_p0_index_of_min.hako verify
 phase257_p0_last_index_of_min.hako verify
 ./tools/smokes/v2/run.sh --profile quick (no Pattern6 false positive)

Technical discovery:
- Host entry block (bb0) Jump set in Phase 6 (after finalize)
- instruction_rewriter bypasses set_terminator(), skips successor update

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-20 23:30:27 +09:00
9ba89bada2 feat(pattern6): support reverse scan for last_index_of
Extend Pattern6 (ScanWithInit) to handle both forward and reverse scans:
- Forward: i=0, loop(i < len), i=i+1 (existing)
- Reverse: i=len-1, loop(i >= 0), i=i-1 (NEW)

Implementation:
- Added ScanDirection enum (Forward/Reverse)
- Updated extract_scan_with_init_parts() to detect both patterns
- Created lower_scan_with_init_reverse() lowerer
- Pattern6 now selects appropriate lowerer based on scan direction

Files modified:
- src/mir/builder/control_flow/joinir/patterns/pattern6_scan_with_init.rs
- src/mir/join_ir/lowering/scan_with_init_reverse.rs (new)
- src/mir/join_ir/lowering/mod.rs

Known issue (pre-existing):
- PHI predecessor mismatch bug exists in Pattern6 (both forward and reverse)
- This bug existed BEFORE Phase 257 P0 implementation
- Out of scope for Phase 257 P0 - will be addressed separately

Phase 257 P0
2025-12-20 20:28:41 +09:00
8394b2d6fd docs(phase256): document P1.13.5 boundary SSOT unification
Phase 256.8.5 Cleanup: Document the completion of boundary SSOT
unification across Pattern4/6/7.

Updates:
- Phase 256 README: Add P1.13.5 section with implementation details
- 10-Now.md: Add P1.13.5 to recent fixes list

Documentation highlights:
- Background: Pattern2 fix needed horizontal expansion
- Implementation: SSOT unified across all patterns (2,3,4,6,7)
- Benefits: Structural prevention of entry param mismatch
- Results: ~40 lines of duplication eliminated, magic numbers removed

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-20 20:12:26 +09:00
edc7355937 refactor(joinir): unify boundary join_inputs SSOT (pattern4/6/7)
Apply Phase 256.8 SSOT fix to Pattern4/6/7:
- Use join_module.entry.params.clone() instead of hardcoded ValueIds
- Add fail-fast validation for params count mismatch
- Remove ValueId(0), ValueId(PARAM_MIN + k) patterns
- Clean up unused PARAM_MIN imports

This prevents entry_param_mismatch errors structurally and maintains
consistency with Pattern2/3.

Changes:
- pattern4_with_continue.rs: Lines 442-476 (SSOT extraction + validation)
- pattern6_scan_with_init.rs: Lines 447-471 (SSOT extraction + validation)
- pattern7_split_scan.rs: Lines 495-526 (SSOT extraction + validation)

All patterns now use the same SSOT principle:
1. Extract entry function (priority: join_module.entry → fallback "main")
2. Use params as SSOT: join_inputs = entry_func.params.clone()
3. Build host_inputs in expected order (pattern-specific)
4. Fail-fast validation: join_inputs.len() == host_inputs.len()

Verification:
- cargo build --release:  PASS (no PARAM_MIN warnings)
- Quick profile:  First FAIL still json_lint_vm (baseline maintained)
- Pattern6 smoke:  PASS (index_of test)
- Pattern7 smoke: Pre-existing phi pred mismatch (not introduced by SSOT)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-20 20:05:11 +09:00
4439d64da3 refactor(joinir): make jump_args layout explicit (Phase 256) 2025-12-20 13:04:24 +09:00
1028bd419c fix(joinir): stabilize Phase 256 merge (jump_args, DCE, func names) 2025-12-20 11:01:48 +09:00
077657b7a1 feat(joinir): Phase 256 P1.5-P1.7 contracts and naming SSOT 2025-12-20 06:38:21 +09:00
64f679354a fix(joinir): Phase 256 P1 - Carrier PHI wiring and parameter mapping (in progress)
**Status**: Core carrier PHI issue partially resolved, debugging loop body

**Progress**:
 Task 1: split_scan_minimal.rs Carriers-First ordering (6 locations)
 Task 2: pattern7_split_scan.rs boundary configuration (host/join inputs, exit_bindings, expr_result)
 Result now flows from k_exit to post-loop code (RC issue resolved)
⚠️  Loop body instruction execution needs review

**Key Fixes**:
1. Fixed host_inputs/join_inputs to match main() params Carriers-First order
2. Added result to exit_bindings (CarrierRole::LoopState)
3. Added result back to loop_invariants for variable initialization
4. Added expr_result=join_exit_value_result for loop expression return
5. Fixed jump args to k_exit to include all 4 params [i, start, result, s]

**Current Issue**:
- Loop body type errors resolved (String vs Integer fixed)
- New issue: Loop body computations (sep_len) undefined in certain blocks
- Likely cause: JoinIR→MIR conversion of local variables needs review

**Next Steps**:
- Review JoinValueSpace allocation and ValueId mapping in conversion
- Verify loop_step instruction ordering and block structure
- May need to refactor bound computation or revisit split algorithm

🤖 Generated with Claude Code
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-20 01:24:04 +09:00
575a5d750f refactor(joinir): Phase 255 P2 - loop_invariants + var() unification + Phase 256 prep
## Task A: Loop Invariants Architecture (Option A - Boundary Extension)

Introduced explicit loop_invariants concept for variables that are:
- Used in loop body but never modified (e.g., substring needle in index_of)
- Need header PHI (all iterations use same value)
- Do NOT need exit PHI (not a LoopState)

Implementation:
- Added `loop_invariants: Vec<(String, ValueId)>` field to JoinInlineBoundary
- Added `with_loop_invariants()` method to JoinInlineBoundaryBuilder
- Modified Pattern 6 to use loop_invariants instead of ConditionOnly misuse
  * s (haystack) and ch (needle) now properly classified
  * exit_bindings simplified to only LoopState carriers
- Extended LoopHeaderPhiBuilder to generate invariant PHIs
  * Entry PHI: from host
  * Latch PHI: self-reference (same value every iteration)
- Updated instruction_rewriter to handle invariant latch incoming

Files Modified:
- src/mir/join_ir/lowering/inline_boundary.rs (structure + builder)
- src/mir/join_ir/lowering/inline_boundary_builder.rs (builder method)
- src/mir/builder/control_flow/joinir/patterns/pattern6_scan_with_init.rs
- src/mir/builder/control_flow/joinir/merge/loop_header_phi_builder.rs
- src/mir/builder/control_flow/joinir/merge/mod.rs
- src/mir/builder/control_flow/joinir/merge/instruction_rewriter.rs

## Task B: Code Quality - var() Helper Unification

Created common module to eliminate var() duplication:
- New module: src/mir/builder/control_flow/joinir/patterns/common/
- Centralized var() helper in ast_helpers.rs
- Updated Pattern 6 and Pattern 2 to use common var()
- Test code (5 occurrences) deferred to Phase 256+ per 80/20 rule

Result: Eliminated 2 duplicate var() functions, 5 test occurrences remain

Files Created:
- src/mir/builder/control_flow/joinir/patterns/common/ast_helpers.rs
- src/mir/builder/control_flow/joinir/patterns/common/mod.rs

Files Modified:
- src/mir/builder/control_flow/joinir/patterns/mod.rs
- src/mir/builder/control_flow/joinir/patterns/pattern6_scan_with_init.rs
- src/mir/builder/control_flow/joinir/patterns/policies/balanced_depth_scan_policy.rs

## Task C: Documentation - PostLoopEarlyReturnPlan Usage Examples

Enhanced post_loop_early_return_plan.rs with:
- Architecture explanation (exit PHI usage prevents DCE)
- Pattern 2 example (Less: balanced_depth_scan)
- Pattern 6 example (NotEqual: index_of)
- Builder defer decision: when 4+ patterns emerge, add builder

Files Modified:
- src/mir/builder/control_flow/joinir/patterns/policies/post_loop_early_return_plan.rs

## Task D: Phase 256 Preparation

Analyzed next failure from smoke tests:
- `StringUtils.split/2` with variable-step loop
- Not constant step (i += len or similar)
- Three implementation options identified

Created Phase 256 README with:
- Minimal reproduction code
- Root cause analysis
- Implementation options with trade-offs
- Clear next steps

Files Created:
- docs/development/current/main/phases/phase-256/README.md

## Verification Results

 All tests passing:
- pattern254_p0_index_of_vm.sh: PASS
- No regression in Pattern 1-5
- Smoke test progresses past json_lint_vm to next failure

 Architecture achievements:
- Semantic clarity: loop_invariants vs exit_bindings properly separated
- ConditionOnly misuse eliminated
- PHI generation correct for all carrier types
- Code quality: var() duplication reduced
- Next phase clearly defined

## Summary

Phase 255 P2 achieves root-cause fix for multi-param loop support:
- Boundary concept expanded (loop_invariants field)
- Pattern 6 architecture corrected (no ConditionOnly misuse)
- Code quality improved (var() centralized)
- Next pattern (variable-step) is now the challenge

 Box-first principles maintained: clean separation, explicit roles, minimal coupling

🧠 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-19 23:48:49 +09:00
2d9c6ea3c6 feat(joinir): Phase 254-255 - Pattern 6 (ScanWithInit) + exit PHI DCE fix
## Phase 254: Pattern 6 (ScanWithInit) Detection & JoinIR Lowering

Pattern 6 detects index_of/find/contains-style loops:
- Loop condition: i < x.length()
- Loop body: if with method call condition + early return
- Step: i = i + 1
- Post-loop: return not-found value (-1)

Key features:
- Minimal lowering: main/loop_step/k_exit functions
- substring hoisted to init-time BoxCall
- Two k_exit jumps (found: i, not found: -1)
- Tests: phase254_p0_index_of_min.hako

## Phase 255 P0: Multi-param Loop CarrierInfo

Implemented CarrierInfo architecture for Pattern 6's 3-variable loop (s, ch, i):
- i: LoopState (header PHI + exit PHI)
- s, ch: ConditionOnly (header PHI only)
- Alphabetical ordering for determinism
- All 3 PHI nodes created correctly
- Eliminates "undefined ValueId" errors

## Phase 255 P1: Exit PHI DCE Fix

Prevents exit PHI from being deleted by DCE:
- PostLoopEarlyReturnStepBox emits post-loop guard
- if (i != -1) { return i } forces exit PHI usage
- Proven pattern from Pattern 2 (balanced_depth_scan)
- VM/LLVM backends working

## Test Results

 pattern254_p0_index_of_vm.sh: PASS (exit code 1)
 pattern254_p0_index_of_llvm_exe.sh: PASS (mock)
 Quick profile: json_lint_vm PASS (progresses past index_of)
 Pattern 1-5: No regressions

## Files Added

- src/mir/builder/control_flow/joinir/patterns/pattern6_scan_with_init.rs
- src/mir/join_ir/lowering/scan_with_init_minimal.rs
- apps/tests/phase254_p0_index_of_min.hako
- docs/development/current/main/phases/phase-254/README.md
- docs/development/current/main/phases/phase-255/README.md

🧠 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-19 23:32:25 +09:00
9336785680 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
6a3b6deb20 feat(anf): Phase 145 P0/P1/P2 - ANF (A-Normal Form) transformation
Implement ANF transformation for impure expressions to fix evaluation order:

Phase 145 P0 (Skeleton):
- Add anf/ module with contract/plan/execute 3-layer separation
- AnfDiagnosticTag, AnfOutOfScopeReason, AnfPlan enums
- Stub execute_box (always returns Ok(None))
- 11 unit tests pass

Phase 145 P1 (Minimal success):
- String.length() whitelist implementation
- BinaryOp + MethodCall pattern: x + s.length() → t = s.length(); result = x + t
- Exit code 12 verification (VM + LLVM EXE)
- 17 unit tests pass

Phase 145 P2 (Generalization):
- Recursive ANF for compound expressions
- Left-to-right, depth-first evaluation order
- Patterns: x + s.length() + z, s1.length() + s2.length()
- ANF strict mode (HAKO_ANF_STRICT=1)
- Diagnostic tags (joinir/anf/*)
- 21 unit tests pass, 0 regression

Also includes Phase 143 P2 (else symmetry) completion.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-19 16:19:49 +09:00
845ae70cb7 chore: Remove unused imports in normalized_shadow modules
Cleaned up unused imports after Phase 143 execution fix (5e662eaaf).

**Priority files (Phase 143)**:
- if_as_last_join_k.rs: removed ValueId, BTreeMap
- loop_true_break_once.rs: added #[cfg(test)] for test-only imports
- post_if_post_k.rs: removed ValueId, BTreeMap
- normalized_helpers.rs: added #[cfg(test)] for Span

**Additional cleanup**:
- contract_checks.rs: removed BasicBlockId
- joinir/mod.rs: removed Info struct re-exports (functions kept)
- patterns/mod.rs: removed Info struct re-exports (functions kept)
- ast_feature_extractor.rs: removed EscapeSkipPatternInfo
- plan_box.rs: added #[cfg(test)] for PlanKind

**Verification**:
- 0 unused import warnings (was 20+)
- All 69 normalized_shadow tests pass
- Clean build with --release

Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-19 08:36:45 +09:00
5e662eaaf6 fix(normalization): Phase 143 execution fix - Param region SSOT
Problem: normalized_helpers allocated env params as ValueId(1,2...)
in PHI Reserved region (0-99) instead of Param region (100-999)
per JoinValueSpace contract.

Root cause: All 4 normalized shadow modules started from
next_value_id=1, violating the Param region contract.

Solution:
- Add NormalizedHelperBox::alloc_env_params_param_region()
  that allocates params starting from PARAM_MIN (100)
- Update 4 normalized shadow files to use new API:
  - loop_true_if_break_continue.rs
  - loop_true_break_once.rs
  - if_as_last_join_k.rs
  - post_if_post_k.rs
- Fix instruction_rewriter.rs type mismatch
  (func.signature.params → func.params)

Verification:
- Unit tests: 69/69 PASS
- VM smoke: exit code 7 
- LLVM EXE smoke: exit code 7  (timeout resolved!)

ValueId Space Contract (Phase 201):
| Region       | Range    | Purpose                      |
|--------------|----------|------------------------------|
| PHI Reserved | 0-99     | Loop header PHI dst          |
| Param        | 100-999  | env params (flag, counter)   |
| Local        | 1000+    | Const, BinOp, condition      |

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-19 08:23:20 +09:00
7030b110cb feat(phase143/r0): Contract SSOT extraction - loop-if-exit pattern refactoring
Phase 143 R0: Refactor P0 to prevent if-branch explosion in P1/P2

**Key Changes**:
- New: loop_if_exit_contract.rs (LoopIfExitShape, LoopIfExitThen, OutOfScopeReason)
- Contract SSOT for pattern shape detection and exit action discrimination
- Separated unit tests to tests/phase143_loop_if_exit_contract.rs (8 tests)
- Removed embedded tests from implementation file
- Updated module declarations for contract and test modules

**Benefits**:
- Enum-driven pattern discrimination (no if-branch explosion)
- P1 extension: Add Continue via 1 enum variant + 1 match arm
- P2 extension: Add else via contract fields (linear growth, not exponential)
- Improved maintainability and code discoverability

**Verification**:
- cargo check:  0 errors
- Unit tests:  8/8 passed
- Documentation:  Updated 10-Now.md and 30-Backlog.md

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-19 06:33:56 +09:00
27663097c5 docs(phase143): Step 9 - Phase 143-loopvocab P0 documentation
Phase 143 P0: Final documentation

Content:
- Purpose: Extend vocabulary for conditional break pattern
- P0 scope: loop(true) { if(cond_pure) break } only
- Design: 6-function JoinModule with Jump/Call/Return
- Implementation: Steps 1-8 (pattern detection → fixtures)
- Verification: cargo check , 4 commits created
- Out-of-scope handling: Ok(None) graceful fallback
- Next steps: P1 (with statements), P2 (else branches), P3 (impure conditions)

Status:  Phase 143 P0 COMPLETE

Files:
- Core: loop_true_if_break_continue.rs (~400 lines)
- Fixtures: phase143_loop_true_if_break_min.hako
- Tests: VM + LLVM EXE smoke tests

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-19 06:03:09 +09:00
af2a5e27d6 feat(normalization): Phase 142 P1 - LLVM EXE parity for loop normalization
Some checks failed
fast-smoke / fast (push) Has been cancelled
Phase 142-loopstmt P1: LLVM EXE smoke test for statement-level loop normalization

- Added: tools/smokes/v2/profiles/integration/apps/phase142_loop_stmt_only_then_return_length_min_llvm_exe.sh
- Verification: Exit code 3 parity with VM test
- Status:  PASS (exit code 3, string length computed correctly)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-19 05:42:11 +09:00
4082abb30c feat(normalization): Phase 142 P0 - Loop statement-level normalization
Phase 142-loopstmt P0: Statement-level normalization

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-19 05:28:49 +09:00
1742f0412e feat(normalized): Phase 141 P1.5 - external env inputs + KnownIntrinsic SSOT
## Task B: External env input bug fix (Priority 1)

Fix: Suffix normalization couldn't access prefix-built local variables

**Problem**: `s.length()` failed because 's' (from prefix `s = "abc"`) was
not in available_inputs during suffix normalization.

**Root cause**: `AvailableInputsCollectorBox::collect()` only collected
function params and CapturedEnv, missing `builder.variable_map`.

**Solution**: Add `prefix_variables` parameter with 3-source merge:
1. Function params (highest priority)
2. Prefix variables (medium priority - NEW)
3. CapturedEnv (lowest priority)

**Changed files**:
- src/mir/control_tree/normalized_shadow/available_inputs_collector.rs
- src/mir/builder/control_flow/normalization/execute_box.rs
- src/mir/builder/control_flow/joinir/patterns/policies/normalized_shadow_suffix_router_box.rs
- src/mir/builder/control_flow/joinir/routing.rs
- src/mir/builder/stmts.rs
- src/mir/control_tree/normalized_shadow/dev_pipeline.rs
- docs/development/current/main/design/normalized-expr-lowering.md (Available Inputs SSOT section)

**Tests**: 3 new unit tests (prefix merge, priority order)

## Task A: KnownIntrinsic SSOT化 (Priority 2)

Eliminate string literal scattered matching by centralizing to registry.

**Problem**: Adding new intrinsics required editing if/match chains with
hard-coded string literals (`if method == KnownIntrinsic::Length0.method_name()`).

**Solution**: Create `KnownIntrinsicRegistryBox` as SSOT:
- `lookup(method, arity) -> Option<KnownIntrinsic>`
- `get_spec(intrinsic) -> KnownIntrinsicSpec`
- Adding new intrinsics now requires: (1) enum variant, (2) registry entry only

**Changed files**:
- src/mir/control_tree/normalized_shadow/common/known_intrinsics.rs (NEW)
- src/mir/control_tree/normalized_shadow/common/expr_lowerer_box.rs
- src/mir/control_tree/normalized_shadow/common/expr_lowering_contract.rs (deprecated methods removed)
- src/mir/control_tree/normalized_shadow/common/mod.rs
- docs/development/current/main/design/normalized-expr-lowering.md (Known Intrinsic SSOT section)

**Impact**: ~30% code reduction in intrinsic matching logic

## Task C: Better diagnostics (Priority 3)

Add `OutOfScopeReason::IntrinsicNotWhitelisted` for precise diagnostics.

**Changed files**:
- src/mir/control_tree/normalized_shadow/common/expr_lowering_contract.rs (enum variant)
- src/mir/control_tree/normalized_shadow/common/expr_lowerer_box.rs (diagnostic logic)

## Verification

 Build: `cargo build --release` - PASS
 Phase 97 regression: next_non_ws LLVM EXE - PASS
 Phase 131: loop(true) break-once VM - PASS
 Phase 136: return literal VM - PASS
 Phase 137: return x+2 VM - PASS

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-19 03:59:41 +09:00
1154aeb40a docs: Phase 138 - ReturnValueLowererBox SSOT documentation
Phase 138 Documentation:
- Created docs/development/current/main/phases/phase-138/README.md
- Goal: Extract return lowering to shared Box for SSOT
- SSOT: common/return_value_lowerer_box.rs
- Supported: Variable, Integer literal, Add expression (x + 2, 5 + 3)
- Implementation: New files, modified files, call sites
- Tests: 5 unit tests + all regressions PASS
- Architecture Impact: Code reduction, maintainability, testability
- Phase 139 準備: Next step clearly indicated (post_if_post_k.rs unification)

10-Now.md Updates:
- Added Phase 138 entry (ReturnValueLowererBox SSOT)
- Implementation details and test coverage
- Design decision: Phase 138 P0 migrated loop paths only
- Link to Phase 138 README

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-19 00:56:02 +09:00
962d1803c9 docs: Phase 136/137 - return literal and add expression documentation
Phase 136 Documentation:
- Created docs/development/current/main/phases/phase-136/README.md
- Goal: loop(true) break-once with return literal (Integer)
- Supported: return 7, loop + post + return literal
- Implementation: lower_return_value_to_vid() method
- Tests: 2 fixtures + 4 smokes
- VM/LLVM EXE parity verification commands

Phase 137 Documentation:
- Created docs/development/current/main/phases/phase-137/README.md
- Goal: loop(true) break-once with return add expression
- Supported: return x+2, return 5+3, loop+post+return add
- Implementation: Extended lower_return_value_to_vid() for BinaryOp Add
- Return Value Lowering SSOT documented (lines 29-46)
- Boxification trigger: when 2+ files need identical logic
- Tests: 3 fixtures + 6 smokes
- VM/LLVM EXE parity verification commands

10-Now.md Updates:
- Added Phase 136 entry (return literal)
- Added Phase 137 entry (return add expression)
- Implementation details and test coverage
- Links to phase READMEs

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-19 00:16:06 +09:00
91c7dfbf0b refactor(normalization): Phase 135 P0 - Extend plan to zero post-loop assigns
Generalize NormalizationPlan suffix detection to accept zero post-loop assignments:

Goal: Improve entry point consistency by allowing `loop + assign* + return` (N >= 0)

Implementation:
- Modified plan_box.rs detection logic (only file changed)
- Removed `post_assign_count >= 1` requirement
- Unified Phase 131 (loop + return) and Phase 132-133 (loop + assign+ + return) paths

Changes:
- src/mir/builder/control_flow/normalization/plan_box.rs:
  - Removed assignment count constraint
  - Unified pattern detection: `loop + assign* + return` (N >= 0)
- apps/tests/phase135_loop_true_break_once_post_empty_return_min.hako (new fixture)
- tools/smokes/v2/profiles/integration/apps/phase135_*.sh (new smoke tests)

Pattern support:
- Phase 131/135: loop + return only (consumed: 2, post_assign_count: 0) 
- Phase 132: loop + 1 assign + return (consumed: 3, post_assign_count: 1) 
- Phase 133: loop + N assigns + return (consumed: 2+N, post_assign_count: N) 

Design principles maintained:
- **Minimal change**: Only plan_box.rs modified (execute_box unchanged)
- **SSOT**: Detection logic centralized in plan_box.rs
- **Box-First**: Responsibility separation preserved (Plan/Execute)

Test results:
- Unit tests (plan_box): 9/9 PASS (2 new tests added)
- Phase 135 VM/LLVM EXE: PASS (exit code 1)
- Phase 131 regression: 2/2 PASS (path now unified)
- Phase 133 regression: 2/2 PASS
- cargo test --lib: PASS

Benefits:
- Unified entry point for all loop + post patterns
- Easier maintenance (single detection logic)
- Future extensibility (easy to add new patterns)
- Clear separation of Phase 131 and Phase 132-135 paths

Default behavior unchanged: Dev-only guard maintained

Related: Phase 135 normalization pattern consistency improvement

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-18 22:46:32 +09:00
f4ab5ca5f4 refactor(control_flow): Phase 134 P0 - Normalization entry point SSOT
Consolidate dual entry points into unified NormalizationPlan system:

Problem:
- Dual entry points: try_normalized_shadow() + suffix_router_box
- ~220 lines of duplicated pattern detection logic
- Maintenance burden: changes required in two places

Solution:
- New normalization module with Box-First architecture
- NormalizationPlanBox: Single source of truth for pattern detection
- NormalizationExecuteBox: Single source of truth for execution

Implementation:
- src/mir/builder/control_flow/normalization/ (new module)
  - README.md: Design contract (SSOT)
  - plan.rs: NormalizationPlan data structure
  - plan_box.rs: Pattern detection (7 unit tests)
  - execute_box.rs: Execution logic
  - mod.rs: Module integration

Refactored files:
- routing.rs::try_normalized_shadow(): 165 → 87 lines (-78 lines)
- suffix_router_box::try_lower_loop_suffix(): 258 → 116 lines (-142 lines)

Pattern support maintained:
- Phase 131: loop(true) only (consumed: 1)
- Phase 132: loop + single post (consumed: 3)
- Phase 133: loop + multiple post (consumed: 2+N)

Box-First principles:
- Plan Box: Detection responsibility only
- Execute Box: Execution responsibility only
- README.md: Contract documentation (SSOT)
- Clear separation enables independent testing

Test results:
- cargo test --lib: 1186 PASS (10 new tests added)
- Phase 133 VM/LLVM EXE: PASS (exit code 6)
- Phase 132 LLVM EXE: PASS (exit code 3)
- Phase 131 LLVM EXE: PASS (exit code 1)

Benefits:
- Code duplication eliminated (~220 lines)
- Single source of truth for normalization decisions
- Improved maintainability and testability
- Future-proof extensibility (easy to add new patterns)

Default behavior unchanged: Dev-only guard maintained

Related: Phase 134 normalization infrastructure improvement

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-18 22:29:29 +09:00
ef71ea955c feat(control_tree): Phase 133 P0 - Multiple post-loop assigns support
Extend Phase 132's loop(true) + post-loop to accept multiple assignments:

Goal: `x=0; loop(true){ x=1; break }; x=x+2; x=x+3; return x` → exit code 6

Implementation:
- Extended loop_true_break_once.rs pattern detection (len() == 2 → len() >= 2)
- Added iterative assignment lowering (for loop over post_nodes)
- Reused Phase 130's lower_assign_stmt for each assignment
- Maintained ExitMeta DirectValue mode (PHI-free)

Changes:
- apps/tests/phase133_loop_true_break_once_post_multi_add_min.hako (new fixture)
- tools/smokes/v2/profiles/integration/apps/phase133_*_multi_add_*.sh (new smokes)
- src/mir/control_tree/normalized_shadow/loop_true_break_once.rs (+30 lines)
- docs/development/current/main/phases/phase-133/README.md (new documentation)
- docs/development/current/main/10-Now.md (Phase 133 entry added)

Scope (Phase 130 baseline):
-  x = <int literal>
-  x = y (variable copy)
-  x = x + <int literal> (increment)
-  Function calls / general expressions (future phases)

Design principles:
- Minimal change: ~30 lines added
- SSOT preservation: env_post_k remains single source of truth
- Reuse: Leveraged existing lower_assign_stmt
- Fail-Fast: Contract violations trigger freeze_with_hint

Test results:
- cargo test --lib: 1176 PASS
- Phase 133 VM: PASS (exit code 6)
- Phase 133 LLVM EXE: PASS (exit code 6)
- Phase 132 regression: PASS (exit code 3)
- Phase 131 regression: PASS (exit code 1)
- Phase 97 regression: PASS

Architecture maintained:
- 5-function structure unchanged (main/loop_step/loop_body/k_exit/post_k)
- PHI-free DirectValue mode
- Zero changes to ExitMeta, merge logic, or JoinIR contracts

Related: Phase 133 loop(true) + multiple post-loop assignments

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-18 22:11:08 +09:00
9fb35bbc05 docs: Phase 132 DONE - loop(true) + post-loop complete
Update documentation to mark Phase 132 as complete:

**10-Now.md**:
- Add Phase 132 completion entry (P0/P0.5/P1/R0)
- Document what was solved:
  - loop(true) + post VM/LLVM EXE parity (exit code 3)
  - Continuation contracts SSOT化
  - merge が by-name 推測禁止
- Entry link: docs/development/current/main/phases/phase-132/README.md

**phase-132/README.md**:
- Update Status: IN PROGRESS → DONE 
- Add Current Status section with P0/P0.5/P1/R0 completion details
- Document SSOT achievements:
  - JoinInlineBoundary::default_continuations()
  - src/mir/builder/control_flow/joinir/merge/README.md (merge contracts)
  - src/mir/builder/control_flow/joinir/legacy/README.md (removal conditions)
- Test placement: continuation_contract.rs
- Test results: All Phase 131/132/97 smokes PASS

Phase 132 Summary:
- P0: post_k generation (loop_true_break_once.rs extension)
- P0.5: Suffix router for StepTree (post statements visibility fix)
- P1: k_exit continuation classification fix (structural check)
- R0: Infrastructure refactoring (SSOT + legacy isolation + docs)

Key achievements:
- VM/LLVM EXE parity for loop(true) + post-loop
- Continuation contracts SSOT and documented
- Legacy code path isolated for future removal
- Code quality improved (warnings reduced)

Related: Phase 132 loop(true) + post-loop complete implementation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-18 21:53:54 +09:00
4169da8c33 docs: Phase 131 refactoring tasks 1-7 completion
Update documentation with refactoring results:

**phase-131/README.md**:
- Document all 7 refactoring tasks (1: MergeContracts, 2: instruction_rewriter boxification,
  3-4: OutputContract + require_joinir_dev, 5: env.sh SSOT, 6: MergeConfig, 7: contract_checks tests)
- Add task descriptions and success criteria
- Document benefits and test results
- Reference implementation files and commits

**tools/build_llvm.sh**:
- Use TARGET_TMPDIR from env.sh for TMPDIR configuration
- Improve EXDEV mitigation for WSL compatibility
- Better artifact finalization handling

**Summary of Phase 131 Refactoring**:

7 refactoring tasks completed on schedule:
 Task 1 (MergeContracts): +30 lines, SSOT for merge contracts
 Task 2 (instruction_rewriter): +212 lines (policy box), -50 lines (rewriter)
 Task 3 (OutputContract): +90 lines, unified verification interface
 Task 4 (require_joinir_dev): +14 lines, dev-only helper
 Task 5 (env.sh SSOT): +1014 lines, centralized environment
 Task 6 (MergeConfig): +54 lines, unified configuration
 Task 7 (contract_checks tests): +116 lines, 4 new tests

Total: ~2500 new lines, 0 regressions, all tests PASS

Benefits:
- Code organization: Single responsibility principle
- Maintainability: SSOT reduces duplication
- Testability: Policy boxes and unit tests enable regression detection
- Developer experience: Clearer code, better documentation

Related: Phase 131 P1.5-P2 DirectValue exit reconnection + infrastructure improvement

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-18 18:29:02 +09:00
0ef032ccc8 refactor(smokes): Task 5 - Environment variable SSOT centralization
Create single source of truth for smoke test environment configuration:

**tools/smokes/v2/lib/env.sh** (new, 183 lines):
- Centralize 16 environment variables across 6 categories
- JoinIR development (NYASH_JOINIR_DEV, HAKO_JOINIR_STRICT)
- LLVM features (NYASH_LLVM_USE_HARNESS, NYASH_LLVM_BACKEND, etc.)
- Tmpdir EXDEV mitigation (TARGET_TMPDIR)
- Plugin loader strategy (NYASH_LOAD_NY_PLUGINS, NYASH_DISABLE_PLUGINS)
- Parser features (NYASH_FEATURES, using system variables)
- Debug features (NYASH_CLI_VERBOSE, etc.)

**Mode Presets**:
- dev: Verbose logging, unlimited fuel, JoinIR dev enabled
- integration: Moderate settings, JoinIR dev enabled
- quick: Minimal logging, fast execution

**Helper Functions**:
- setup_smoke_env [mode]: Configure environment for test profiles
- validate_env_setup: Validate configuration
- show_smoke_env: Display current configuration

**Documentation**:
- ENV_README.md: Comprehensive usage guide
- ENV_QUICK_START.md: Quick reference for script authors
- p1.5-task5-env-ssot.md: Implementation details and testing

Benefits:
- SSOT: Single file for all environment variables
- Sparrow prevention: No duplicate settings
- Clarity: Well-documented configuration
- Backward compatibility: Existing scripts work unchanged

Test Results:
- All environment presets work correctly
- Phase 131 smoke tests PASS
- Syntax validation for all shell files PASS

Related: Phase 131 smoke test infrastructure improvement

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-18 18:28:37 +09:00
f775c0fe01 docs: Phase 131 P2 DirectValue exit reconnection complete
Update completion status for Phase 131 P2:
- CURRENT_TASK.md: Note WSL restart resolved EXDEV issue
- 10-Now.md: Add Phase 131 P2 completion entry
- phase-131/README.md: Document P1.5 and P2 deliverables

Phase 131 Status: DONE 
- loop(true) break-once executes correctly
- Exit values propagate through DirectValue mode
- VM + LLVM EXE parity verified

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-18 17:48:18 +09:00
bfac188732 docs: Phase 131 P1.5 DirectValue exit reconnection design
Add design documents for Phase 131 P1.5 DirectValue mode:
- Root cause analysis of PHI-based exit merge assumptions
- Option B (DirectValue) analysis and trade-offs
- Implementation guide for exit value reconnection

Also add exit_reconnector.rs module stub for future extraction.

Related:
- Phase 131: loop(true) break-once Normalized support
- Normalized shadow path uses continuations, not PHI
- Exit values reconnect directly to host variable_map

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-18 17:47:45 +09:00
bd39e09c5d docs: Phase 131 P0 structure implementation complete
Document Phase 131 P0 Normalized loop(true) break-once:

**Documentation**:
- docs/development/current/main/phases/phase-131/README.md (234 lines)
  - Goal: loop(true) { <assign>* ; break } in Normalized (PHI-free)
  - Scope: one-time execution loop only
  - Contract: Bool(true) literal + break at end
  - SSOT: EnvLayout, loop structure contract, VM+LLVM parity
  - Current status: structure implemented, execution wiring pending
- docs/development/current/main/10-Now.md
  - Updated Next section with Phase 131 P0 status

**Deliverables** (P0):
-  Complete loop(true) break-once Normalized lowering logic
-  PHI-free implementation (env + continuations)
-  Box-First modular design
-  Foundation for execution (structure verified)
-  Unit tests passing (1155/1155)

**Known Limitation**:
- Execution path not yet wired (dev-only observation mode)
- Follow-up phase needed to route execution through Normalized shadow
- VM/LLVM smokes fail (expected until execution wiring)

**Next Steps**:
1. Modify try_cf_loop_joinir to check Normalized shadow first
2. Add dev-mode routing for loop(true) break-once
3. Implement JoinModule → MIR merge for loop patterns
4. Enable VM/LLVM smoke tests

Related: Phase 131 P0 - loop(true) break-once Normalized structure
2025-12-18 09:36:50 +09:00
353b8022af docs: clarify Phase 130 LLVM EXE smoke gating 2025-12-18 09:22:15 +09:00
b5d628d8bf docs: Phase 130 DONE (if-only normalized small expr/assign) 2025-12-18 09:13:19 +09:00
05fccce09a docs: add Phase 130 plan and set Now to Phase 130 2025-12-18 08:36:38 +09:00
80df1cccd4 feat(control_tree): Phase 129-C post-if via post_k continuation 2025-12-18 08:33:56 +09:00
b2af9fb297 docs: update normalized_shadow references and Phase 129 status 2025-12-18 08:18:20 +09:00