72f2c1f64d
feat(joinir/dev): Phase 126 wire available_inputs into normalized builder
...
- AvailableInputsCollectorBox::collect() called in lower_function_body (dev-only)
- try_lower_if_only() signature extended (accepts available_inputs)
- EnvLayout::from_contract() now uses real available_inputs (not empty stub)
- Unit tests updated (empty BTreeMap for backward compat)
- All 23 normalized_shadow tests PASS
2025-12-18 06:45:23 +09:00
89c2915fa0
feat(control_tree): Phase 126 AvailableInputsCollectorBox
...
- Collect available_inputs from function params + CapturedEnv (SSOT)
- BTreeMap for deterministic order
- Box-first modularization with unit tests (5 tests PASS)
- Source priority: params > CapturedEnv
- No AST inference (only pre-computed sources)
2025-12-18 06:43:27 +09:00
b7a16aacd0
docs: Phase 126 plan (wire available_inputs)
2025-12-18 06:40:36 +09:00
aabb67cdc2
docs: Phase 125 P2-P5 feedback (boxification review)
...
Feedback summary:
- 単一責任: EnvLayout / lower_return_value
- SSOT: reads ∩ available_inputs
- Fail-Fast: 構造化エラー + hint
- 段階的投入: 構造のみ(P3 で完成)
Good:
- Single responsibility principle maintained
- SSOT approach for env layout
- Fail-Fast with structured errors
- Graceful degradation (Ok(None))
Improvement proposals:
- P3 wiring clarification
- EnvLayout responsibility scope
- Error hint context-awareness
- Fixture completeness after P3
Next: Phase 125 P3 (available_inputs wiring)
Ref: docs/development/current/main/phases/phase-125/FEEDBACK.md
2025-12-18 06:33:55 +09:00
d7c77e1046
docs: Phase 125 P2-P5 DONE (structure-only, P3 pending)
...
Phase 125 P2-P5 完了:
- EnvLayout (writes + inputs) 導入
- Return(Variable) 解決拡張(writes or inputs)
- Fail-Fast with hint(構造化エラー)
- Unit tests: 18/18 PASS
- Integration smoke: PASS
- Regression: Phase 121-124, 118 維持
Next: Phase 125 P3 (available_inputs wiring)
- routing.rs / lowering.rs で available_inputs を配線
- SSOT: function params + CapturedEnv
Ref: docs/development/current/main/phases/phase-125/README.md
2025-12-18 06:33:03 +09:00
92b3c2afb5
test(joinir): Phase 125 P5 fixture + smoke (VM, structure-only)
...
Phase 125 P5: Integration smoke test
- fixture: apps/tests/phase125_if_only_return_readonly_input_min.hako
- Expected: 7 (return x from reads-only input)
- Note: Demonstrates structure, full functionality needs P3 wiring
- smoke: tools/smokes/v2/profiles/integration/apps/phase125_if_only_return_input_vm.sh
- NYASH_JOINIR_DEV=1 HAKO_JOINIR_STRICT=1
- VM backend only
Test results:
- Phase 125 smoke: PASS (exit code 7)
- Regression (Phase 121-124, 118): PASS
- phase124_if_only_return_var_vm: PASS
- phase123_if_only_normalized_semantics_vm: PASS
- phase121_shadow_if_only_vm: PASS (3/3 tests)
- phase118_loop_nested_if_merge_vm: PASS
Note:
- P3 (available_inputs wiring) not implemented yet
- Fixture uses simple return (no if-only pattern yet)
- Serves as design document for future P3 implementation
- EnvLayout.inputs will be populated when P3 is complete
Ref: docs/development/current/main/phases/phase-125/README.md
2025-12-18 06:32:10 +09:00
4c98313b58
refactor(control_tree): Phase 125 P2-P4 introduce EnvLayout (writes+inputs) + Return(Variable) from inputs
...
Phase 125 P2: EnvLayout introduction
- Add EnvLayout struct (writes + inputs)
- from_contract() creates layout from StepTreeContract + available_inputs
- SSOT: inputs = reads ∩ available_inputs (deterministic order)
- No AST inference (don't capture from AST, use provided available_inputs)
Phase 125 P2: Builder env mapping
- lower_if_only_to_normalized: Use EnvLayout to create env map
- writes: Generate ValueId (as before)
- inputs: Reference ValueId from available_inputs (placeholder for P3)
- Function params: writes only (inputs come from outer scope)
Phase 125 P4: Return(Variable) resolution extended
- lower_return_value: Check env (writes + inputs)
- If found: return it (Phase 124 for writes, Phase 125 for inputs)
- If not found: Fail-Fast with structured error + hint
- Hint: "Pass as param, add to pinned capture, or define before if"
- Phase 125 errors return Ok(None) (out of scope, graceful degradation)
Unit tests:
- test_return_variable_from_env: PASS (Phase 124 regression)
- test_return_variable_out_of_scope: PASS (updated for Phase 125)
- test_return_variable_from_inputs_stub: PASS (P3 not wired yet)
- All 1160 lib tests PASS (no regression)
Note:
- P3 (available_inputs wiring) not implemented yet
- available_inputs is empty BTreeMap (stub)
- EnvLayout.inputs will be empty until P3 is wired
- Structured error tags: [phase125/return/var_not_in_env]
Ref: docs/development/current/main/phases/phase-125/README.md
2025-12-18 06:30:55 +09:00
7eeeb588e4
docs: add Phase 125 entry (planned)
2025-12-18 06:28:39 +09:00
d044af1fbc
docs: Phase 124 DONE
...
Phase 124 完了:
- reads facts SSOT 化(StepTreeFacts/Contract に追加)
- Return(Variable) from env (writes) サポート(dev-only)
- env マッピング(変数名 → ValueId)を writes から生成
- extract_variables_from_ast() で Variable 抽出を SSOT 化
- Fail-Fast 原則(env に無い Variable はエラー)
- Unit tests: 1159 PASS (including test_return_variable_from_env)
- Integration smoke: PASS (phase124_if_only_return_var_vm.sh)
- 回帰確認: Phase 121/123/118 全て PASS
- 10-Now.md 更新(Phase 124 完了、Phase 125 計画追加)
2025-12-18 06:10:17 +09:00
8e6791a623
test(joinir): Phase 124 return-var normalized smoke (VM)
...
Phase 124-P4:
- Add fixture: apps/tests/phase124_if_only_return_var_min.hako
- local x; x = 7; print(x); return x
- Expected output: 7 (print), RC: 7 (return x)
- Add smoke: tools/smokes/v2/profiles/integration/apps/phase124_if_only_return_var_vm.sh
- NYASH_JOINIR_DEV=1 HAKO_JOINIR_STRICT=1 for dev-only features
- Accept exit code 7 (return x where x=7) as valid
- Verify all Phase 121/123/118 smokes still PASS
2025-12-18 06:09:36 +09:00
c40971dc74
feat(control_tree): Phase 124 return variable from env (dev-only)
...
Phase 124-P3:
- Add env: BTreeMap<String, ValueId> from writes in lower_if_only_to_normalized
- Pass env and contract to lower_return_from_tree, lower_if_node, lower_return_value
- Implement Return(Variable) support:
- If variable in env (writes): Ret(Some(vid))
- If variable not in env: Err (out of scope, phase124 error)
- Add phase124 errors to Ok(None) conversion (dev-only compatibility)
- Add unit test: test_return_variable_from_env (verifies Ret(Some(ValueId(1))))
- All 1159 tests PASS
2025-12-18 06:05:18 +09:00
320a23e3d1
refactor(control_tree): include reads in StepTreeContract signature
...
Phase 124-P2:
- Add reads: BTreeSet<String> to StepTreeContract
- Include reads in signature_basis_string (format: ...;reads=...;...)
- Update from_facts() to copy reads from StepTreeFacts
- Update all StepTreeContract construction sites (builder.rs, parity.rs tests)
- Update test expected signature to include reads field
- Maintains determinism: BTreeSet guarantees stable iteration order
2025-12-18 06:00:21 +09:00
95b25e54ad
feat(control_tree): Phase 124 add reads to StepTreeFacts
...
- Add reads: BTreeSet<String> to StepTreeFacts
- Add add_read() API and merge_reads() in merge()
- Add extract_variables_from_ast() helper for AST traversal
- Extract reads from:
- If/Loop condition AST
- Return value AST
- All Variable nodes recursively (BinaryOp, UnaryOp, FunctionCall, MethodCall, FieldAccess, Index, Assignment RHS, Print)
- SSOT: extract_variables_from_ast() is the single source for reads collection
2025-12-18 05:58:08 +09:00
fb4ec2c2bf
docs: Phase 124 plan (reads facts + return var)
2025-12-18 05:54:51 +09:00
4f0ffae70d
docs: Phase 123 DONE
...
Updates documentation to reflect Phase 123 completion.
**Updates**:
1. `docs/development/current/main/phases/phase-123/README.md`:
- Marked all success criteria as complete
- Added comprehensive DONE section with implementation details
- Documented key design decisions (graceful degradation, fail-fast, box-first)
- Added verification commands and next steps (Phase 124)
2. `docs/development/current/main/10-Now.md`:
- Moved Phase 123 from "Next" to "2025-12-18: Phase 123 完了"
- Added Phase 123 summary (Return literal, If minimal compare, graceful degradation)
- Updated "Next" to Phase 124 (Normalized reads facts + Return(Variable))
3. `docs/development/current/main/01-JoinIR-Selfhost-INDEX.md`:
- Added Phase 123 entry: "Normalized semantics (Return literal + If minimal compare, dev-only)"
**Phase 123 Summary**:
- P0: Docs complete, scope frozen ✅
- P1: Return(Integer literal) working ✅
- P2: Return(Variable) returns Ok(None) (graceful degradation) ✅
- P3: If(minimal compare) generates correct JoinIR ✅
- P4: Integration smoke passing ✅
- P5: Docs updated ✅
**Verification**:
- Unit tests: 8 passed
- Integration smoke: PASS
- Legacy tests: Still passing (graceful degradation confirmed)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-18 05:50:29 +09:00
b3cd7c0884
test(joinir): Phase 123 normalized semantics smoke (VM)
...
Adds integration smoke test for Phase 123 normalized semantics lowering.
**New Files**:
- `apps/tests/phase123_if_only_return_literal_min.hako`: Minimal test fixture (output: 7)
- `tools/smokes/v2/profiles/integration/apps/phase123_if_only_normalized_semantics_vm.sh`: Smoke test script
**What's Tested**:
- Return(Integer literal) generates correct output
- Dev+strict mode does not fail (graceful degradation works)
**Test Status**: PASS
**Verification**:
```bash
bash tools/smokes/v2/profiles/integration/apps/phase123_if_only_normalized_semantics_vm.sh
# Result: PASS (output: 7)
```
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-18 05:50:16 +09:00
7eec4ec0c8
feat(control_tree): Phase 123 if-only compare+return lowering (Normalized, dev-only)
...
Implements Phase 123 P3: If(cond_ast) minimal lowering with graceful degradation.
**What's Implemented**:
- If node lowering with minimal binary comparison (Variable op Integer)
- Supported operators: ==, !=, <, <=, >, >=
- Generates: Compare + Const + Ret structure
- Graceful degradation: returns Ok(None) for unsupported patterns
**Key Design Decisions**:
1. **Graceful Degradation**: Phase 123 limitations return `Ok(None)` instead of failing
- Allows dev-only mode to coexist with legacy code
- Error messages prefixed with `[phase123/...]` are caught
2. **Fail-Fast with Structured Errors**: All limitations use structured error codes
- Format: `[phase123/category/specific]`
3. **Box-First Principles**:
- `parse_minimal_compare`: Single responsibility parser
- `verify_branch_is_return_literal`: Branch validation box
- `lower_if_node`: If lowering box
**Implementation**:
- Added `lower_if_node`: If lowering with minimal compare
- Added `parse_minimal_compare`: Binary comparison parser
- Added `verify_branch_is_return_literal`: Branch validator
- Updated `lower_if_only_to_normalized` return type: `Result<Option<...>, ...>`
- Updated `test_return_variable_out_of_scope`: Verifies graceful degradation
- Added `test_if_minimal_compare`: Verifies If lowering structure
**Tests**: 8 passed (including graceful degradation test)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-18 05:50:09 +09:00
f72064f35a
feat(control_tree): Phase 123 P1 return integer literal in Normalized if-only
...
- Add value_ast to StepStmtKind::Return for payload tracking
- Implement lower_return_value for Integer literal → Compute(Const) + Ret
- Add 3 unit tests: integer literal, void, variable fail-fast
- All tests passing (7 passed)
2025-12-18 05:37:13 +09:00
51ed137339
docs: Phase 123 plan (if-only normalized semantics)
2025-12-18 05:29:34 +09:00
bf7d3899b0
docs: Phase 122 DONE (if-only Normalized emit dev-only)
2025-12-18 04:54:49 +09:00
4abd434366
test: Phase 122 if-only Normalized emit smoke
...
Phase 122 P4: Fixtures and smoke tests
- New fixture: phase122_if_only_normalized_emit_min.hako
- Smoke test: phase122_if_only_normalized_emit_vm.sh
- Verifies: module emission + structure verification in dev+strict mode
- Regression check: phase103 fixture still passes
- All tests PASS
2025-12-18 04:53:04 +09:00
cc1a0946b0
feat(joinir/dev): build Normalized if-only module with structure verification (no behavior change)
...
Phase 122 P2-P3: Dev-only wiring + structure verification
- Wire Phase 122 emission into existing Phase 121 dev path
- Add verify_normalized_structure() for module validation
- Check: phase, function count, entry point, env args count
- Strict mode: fail-fast on structure mismatch
- No behavior change to existing execution path
2025-12-18 04:52:09 +09:00
7603ef8a6a
feat(control_tree): emit Normalized JoinModule for if-only (dev-only)
...
Phase 122 P1: StepTree→Normalized JoinModule generation
- Generate env layout from writes (SSOT, deterministic)
- Minimal implementation: main function + Ret only
- Full If/Assign/Return lowering in future P2-P4
- Dev-only: no behavior change to existing path
2025-12-18 04:50:32 +09:00
c92154966c
docs: add Phase 122 entry (planned)
2025-12-18 04:48:53 +09:00
95c9394396
docs: Phase 122 plan (if-only emit)
2025-12-18 04:48:49 +09:00
2a53f87d10
docs: Phase 121 DONE (StepTree→Normalized shadow parity for if-only)
2025-12-18 04:40:53 +09:00
0892df6dff
test(joinir): Phase 121 shadow parity smokes (VM + LLVM EXE)
2025-12-18 04:39:23 +09:00
89b868703f
feat(joinir/dev): wire Phase 121 StepTree shadow lowering (strict fail-fast)
2025-12-18 04:34:43 +09:00
1e5432f61a
feat(control_tree): add StepTree→Normalized shadow lowerer (if-only, dev-only)
2025-12-18 04:31:41 +09:00
8d930d2dcc
docs: Phase 121 StepTree→Normalized shadow plan
2025-12-18 04:27:30 +09:00
9d5e58305e
docs: Phase 120 DONE
2025-12-18 04:19:48 +09:00
dd125cb700
test(control_tree): cover facts→contract determinism
2025-12-18 04:19:14 +09:00
43d3e7c935
refactor(control_tree): split StepTree facts vs contract boxes
2025-12-18 04:18:37 +09:00
4e863c7cd8
docs: Phase 120 StepTree facts/contract SSOT
2025-12-18 04:16:04 +09:00
708accc853
docs: Phase 119 DONE
2025-12-18 04:09:47 +09:00
98061260a0
refactor(control_tree): store AST cond handles in StepTree (dev-only)
...
Phase 119: StepTree cond SSOT (AST handle)
- Add AstNodeHandle to StepNode::If and StepNode::Loop
- cond_ast holds Box<ASTNode> clone (dev-only, acceptable overhead)
- cond_sig (AstSummary) remains signature/log material
- signature_basis_string() unchanged (Span-free, deterministic)
- Tests: cond_ast population + signature stability confirmed
2025-12-18 04:09:00 +09:00
84d63ac11b
docs: Phase 119 StepTree cond SSOT (AST handle)
2025-12-18 04:03:50 +09:00
052040e59c
refactor(joinir): extract ExitArgsCollectorBox for jump_args SSOT
...
Phase 118 refactoring: Box modularization for exit value collection.
# Changes
- Created `exit_args_collector.rs` with ExitArgsCollectorBox
- Extracted jump_args processing logic from instruction_rewriter.rs
- Implemented SSOT for offset calculation (0 vs 1 legacy layout)
- Added comprehensive unit tests (6 tests, all passing)
# Design
- **Responsibility**: Collects exit PHI inputs + carrier inputs from jump_args
- **SSOT**: Centralized offset calculation logic
- **Fail-Fast**: Validates jump_args length against exit_bindings
- **Phase 118 P2 Contract**: Uses boundary.exit_bindings as SSOT
# Key Features
- Filters ConditionOnly carriers (no exit PHI needed)
- Handles both direct mapping (offset=0) and legacy layout (offset=1)
- Strict mode: Fail-Fast on validation errors
- Non-strict mode: Warns and continues with best effort
# Test Results
- Unit tests: 6/6 PASS
- Phase 118 smoke tests: PASS (VM + LLVM)
- Phase 117 regression: PASS
# Reduced Code Complexity
- instruction_rewriter.rs: ~90 lines → ~25 lines (box call)
- Offset logic: Centralized in ExitArgsCollectorBox
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-18 03:56:21 +09:00
432fc96082
refactor(joinir): extract IfSumExitMetaBuilderBox for Fail-Fast carrier binding
...
Phase 118 refactoring: Box modularization for ExitMeta generation.
# Changes
- Created `exit_meta_builder.rs` with IfSumExitMetaBuilderBox
- Extracted ExitMeta generation logic from loop_with_if_phi_if_sum.rs
- Implemented Fail-Fast contract (carrier name validation)
- Added comprehensive unit tests (5 tests, all passing)
# Design
- **Responsibility**: Builds ExitMeta from carrier name + ValueId
- **Fail-Fast**: Validates carrier names immediately
- **Reusability**: Can be used by other patterns (Pattern 4, etc.)
# Test Results
- Unit tests: 5/5 PASS
- Phase 118 smoke tests: PASS (VM + LLVM)
- Phase 117 regression: PASS
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-18 03:56:10 +09:00
5091cda9cb
docs: Phase 118 DONE (loop+if merge parity)
2025-12-18 03:43:16 +09:00
8fb393b5e8
test(joinir): Phase 118 loop+if merge parity smokes
2025-12-18 03:43:10 +09:00
1080dee58f
fix(joinir): Phase 118 Pattern3 exit carrier PHI SSOT
2025-12-18 03:43:00 +09:00
2c7f5f7a5e
docs: Phase 117 DONE
...
Phase 117: if-only nested-if + call merge parity completed.
**Documentation**:
- docs/development/current/main/phases/phase-117/README.md (complete)
- docs/development/current/main/10-Now.md (updated with Phase 117 entry)
- docs/development/current/main/01-JoinIR-Selfhost-INDEX.md (added Phase 117 to index)
**Phase 117 Summary**:
- Verified nested if-only (inner if + outer else) with call merge
- Pattern: 3 call sites (f(1), f(2), f(3)) merge to single variable
- VM/LLVM EXE parity: both produce identical output "2\n3\n4"
- Regression: Phase 116 maintained
**Technical Details**:
- JoinIR Pattern3 (if-only) nested structure validation
- Call merge across nested control flow
- PHI node generation for nested branches
- LLVM EXE plugin integration (StringBox, IntegerBox, ConsoleBox)
**Next Steps**:
Phase 118+ will address more complex nested patterns (if-else nested, loop-if combinations).
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-18 02:55:14 +09:00
bc561682f6
test: Phase 117 if-only nested-if call merge parity (VM + LLVM EXE)
...
Fixture & Smoke tests for nested if-only with call merge verification.
**Fixture**:
- apps/tests/phase117_if_only_nested_if_call_merge_min.hako
- Pattern: nested if (inner: b == 1) inside outer if (a == 1), outer else
- Call merge: f(1), f(2), f(3) results merged to single variable v
- Expected output: 2, 3, 4 (f(x) = x + 1)
**VM Smoke**:
- tools/smokes/v2/profiles/integration/apps/phase117_if_only_nested_if_call_merge_vm.sh
- Execution: NYASH_DISABLE_PLUGINS=1 HAKO_JOINIR_STRICT=1
- Validation: numeric output 3 lines "2\n3\n4"
**LLVM EXE Smoke**:
- tools/smokes/v2/profiles/integration/apps/phase117_if_only_nested_if_call_merge_llvm_exe.sh
- Required plugins: FileBox, MapBox, StringBox, ConsoleBox, IntegerBox
- Validation: numeric output "2\n3\n4" (3 lines)
**Verification**:
✅ VM smoke: PASS
✅ LLVM EXE smoke: PASS
✅ Regression (Phase 116): PASS
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-18 02:55:02 +09:00
f63b5c3c64
docs: fix INDEX numbering + refresh backlog after Phase 116
...
- Fixed INDEX numbering: 24/25 → 28/29 (was duplicated after Phase 116 additions)
- Updated Backlog: next candidate Phase 114 → Phase 117 (nested if + call merge)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-18 02:52:01 +09:00
8440550b2f
docs: Phase 116 DONE
...
Phase 116 完了ドキュメント化
## 更新内容
### Phase 116 README
- 背景: LLVM fragile pattern(keep+call merge)
- 実装内容: fixture, VM smoke, LLVM EXE smoke
- 検証コマンド
- 技術的詳細: JoinIR Pattern 1, PHI接続
- Lessons Learned: Box-First原則, Fail-Fast原則
### 10-Now.md
- Phase 116 完了エントリ追加
- 入口: `docs/development/current/main/phases/phase-116/README.md`
### 01-JoinIR-Selfhost-INDEX.md
- Phase 116 を JoinIR Phase リストに追加
- 番号の重複を修正(18-27に整理)
## 成果物
✅ 片側元値保持、片側call結果のmergeパターンをVM/LLVM両方で固定
✅ output_validator.sh, llvm_exe_runner.sh 活用で統一的なテスト基盤
✅ 回帰防止: Phase 115 維持確認
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-18 02:39:44 +09:00
ed38aa820a
test: Phase 116 if-only keep+call merge parity (VM + LLVM EXE)
...
Phase 116 固定: if-only で片側が元値保持、片側が call 結果の merge パターン
## 実装内容
### Fixture
- `apps/tests/phase116_if_only_keep_plus_call_min.hako`
- Expected output: `10\n2`
- Pattern:
- then側: call結果でvを更新 (`v = f(1)`)
- else側: 元の値を保持 (`v = 10`)
- merge地点: 異なるソース(元値 vs call結果)からのPHI
### Smoke Tests
- `phase116_if_only_keep_plus_call_vm.sh` - VM parity
- output_validator.sh で数値2行 `10\n2` を検証
- `NYASH_DISABLE_PLUGINS=1 HAKO_JOINIR_STRICT=1`
- `phase116_if_only_keep_plus_call_llvm_exe.sh` - LLVM EXE parity
- llvm_exe_runner.sh を利用(plugin dlopen/cache/build-all SSOT)
- llvm_exe_build_and_run_numeric_smoke で検証
## 検証結果
✅ VM smoke: PASS (10\n2)
✅ LLVM EXE smoke: PASS (10\n2)
✅ 回帰 (Phase 115): PASS (2\n3)
## 技術的詳細
### JoinIR Pattern 1 (Simple If)
```
entry_block:
v = 10
if flag == 1 goto then_block else exit_block
then_block:
v = f(1)
goto exit_block
exit_block:
v_merged = PHI [v=10 from entry, v=f(1) from then]
print(v_merged)
```
### PHI接続の重要性
- entry → exit: 元値 (`10`) を直接伝播
- then → exit: call結果 (`f(1)`) を伝播
- PHI: 異なる型のソース(変数 vs call結果)を正しくmerge
LLVM IRでは、これらが適切な型で統一される必要がある。
## Box-First原則の適用
✅ 既存の箱化されたコンポーネントを活用
- output_validator.sh による出力検証の統一
- llvm_exe_runner.sh によるLLVM実行の標準化
- テストインフラの再利用(no reinvention)
## Fail-Fast原則
✅ VM/LLVM両方でエラーを即座に検出
- `HAKO_JOINIR_STRICT=1` で厳密な検証
- フォールバック処理なし(エラーは明示的に失敗)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-18 02:39:33 +09:00
5602aff8a9
refactor(smokes): add output_validator.sh for SSOT numeric assertion
...
Output検証をSSOT化して保守性を向上
**新規追加**:
- tools/smokes/v2/lib/output_validator.sh
- extract_numeric_lines N: 数値行をN行抽出(パターンマッチング)
- assert_equals_multiline EXPECTED ACTUAL: 複数行期待値と比較
- validate_numeric_output N EXPECTED OUTPUT: extract + assert の合成Box
**リファクタリング対象** (5ファイル):
- phase103_if_only_vm.sh
- phase103_if_only_early_return_vm.sh
- phase113_if_only_partial_assign_vm.sh
- phase114_if_only_return_then_post_vm.sh
- phase115_if_only_call_merge_vm.sh
**変更内容**:
- 重複パターン `grep -E '^-?[0-9]+$' | head -n N` → `extract_numeric_lines N`
- 比較ロジック → `validate_numeric_output` に統一
- 各smokeは `source output_validator.sh` で共通機能を利用
**検証結果**:
- phase103_if_only_vm: PASS ✅
- phase103_if_only_early_return_vm: PASS ✅
- phase113_if_only_partial_assign_vm: PASS ✅
- phase114_if_only_return_then_post_vm: PASS ✅
- phase115_if_only_call_merge_vm: PASS ✅
**箱化モジュール化の成果**:
- 単一責任: extract_numeric_lines(抽出のみ)、assert_equals_multiline(比較のみ)
- 分離: 各機能が独立したBox(テスト容易性向上)
- 合成: validate_numeric_output が extract + assert を組み合わせ
- Fail-Fast: 全関数でパラメータチェック(明示的エラー)
- 保守性: 検証パターン変更時は output_validator.sh の1箇所のみ修正
**設計原則**:
- Box-First: 機能を箱に切り出して境界を明確化
- SSOT: 数値行抽出と検証ロジックを1箇所に集約
- Fail-Fast: パラメータ不正時は即座にエラー(フォールバックなし)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-18 02:32:32 +09:00
0a29f1443e
test: Phase 115 if-only call result merge parity (VM + LLVM EXE)
...
Phase 115実装 - if分岐内での関数呼び出し結果をマージするパターンを固定
**実装内容**:
- Fixture: phase115_if_only_call_merge_min.hako (expected: 2, 3)
- if/else両分岐で関数呼び出し f() の結果を変数 v に代入
- if後にマージされた v を使用(LLVM EXE でのPHI node生成を検証)
- VM smoke: phase115_if_only_call_merge_vm.sh
- NYASH_DISABLE_PLUGINS=1 HAKO_JOINIR_STRICT=1 で実行
- LLVM EXE smoke: phase115_if_only_call_merge_llvm_exe.sh
- llvm_exe_runner.sh を利用した標準パリティ検証
**検証結果**:
- VM test: PASS ✅
- LLVM EXE test: PASS ✅
- Phase 114 regression: PASS ✅
**箱化モジュール化の観点**:
- 単一責任: 各smokeは1パターンのみ検証(call result merge)
- 分離: VM/LLVM EXEで独立したテスト(llvm_exe_runner.sh経由)
- Fail-Fast: HAKO_JOINIR_STRICT=1 で不正な制御フローを即座に検出
**関連**:
- Phase 103: If-Only基本パリティ(制御フロー基礎)
- Phase 113: If-Only部分代入パリティ(変数マージ)
- Phase 114: If-Only return+post パリティ(early returnとpost-if文)
- Phase 115: If-Only call result merge パリティ(関数呼び出し結果マージ) ← 今回
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-18 02:32:08 +09:00
97675b4035
docs: Phase 114 DONE
...
Phase 114完了に伴うドキュメント更新:
- 30-Backlog.md: Phase 114の次候補から完了済みに移行
- design/control-tree.md: Phase 110-112の進捗反映
- design/README.md, joinir-design-map.md, phases/README.md: マイナー更新
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-18 02:19:41 +09:00