af2a5e27d6
feat(normalization): Phase 142 P1 - LLVM EXE parity for loop normalization
...
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
275fe45ba4
feat(normalization): Phase 142 P0 - Statement-level normalization
...
## Summary
Changed normalization unit from "block suffix" to "statement (loop only)"
to prevent pattern explosion.
## Changes
1. **PlanBox** (`plan_box.rs`):
- Always return `loop_only()` for any `loop(true)`, regardless of what follows
- Subsequent statements (return, assignments) handled by normal MIR lowering
- ~70 lines reduced, 7 unit tests updated
2. **build_block** (`stmts.rs`):
- Removed `break` after consumed=1 from suffix_router
- Continue processing subsequent statements normally
- Phase 142 P0 comments added
3. **Tests**:
- Fixture: `phase142_loop_stmt_only_then_return_length_min.hako`
- VM smoke: exit code 3 (s="abc" → s.length() → 3)
## Results
- ✅ Unit tests: 10/10 passed
- ✅ Phase 142 VM smoke: PASS
- ✅ Phase 131 regression: PASS
- ✅ Build: Success
## Design
- **Pattern Explosion Prevention**: Normalize only the loop (consumed=1)
- **Out-of-Scope Policy**: Always Ok(None) for fallback
- **Fail-Fast**: Only for "in-scope but broken" cases
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-19 04:41:01 +09:00
ff09adebe0
feat(control_tree): Phase 136/137 - return literal and add expression (dev-only)
...
Phase 136 P0: Return literal (Integer) support
- Extend loop(true) break-once to support `return 7`
- Fixtures: phase136_loop_true_break_once_return_literal_min.hako (exit code 7)
- VM/LLVM EXE parity achieved
Phase 137 P0: Return add expression support
- Extend to support `return x + 2` and `return 5 + 3`
- LHS: Variable or Integer literal
- RHS: Integer literal only
- Fixtures:
- phase137_loop_true_break_once_return_add_min.hako (exit code 3)
- phase137_loop_true_break_once_return_add_const_min.hako (exit code 8)
- phase137_loop_true_break_once_post_return_add_min.hako (exit code 13)
- VM/LLVM EXE parity achieved
Implementation:
- Added lower_return_value_to_vid() method in loop_true_break_once.rs
- Replaced extract_variable_name() with unified return value lowering
- Supported patterns: Variable, Integer literal, BinaryOp Add
- Out-of-scope patterns return Ok(None) for fallback
- SSOT documentation added (lines 29-46)
Tests: 5 fixtures + 10 smoke tests (5 VM + 5 LLVM EXE), all PASS
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-19 00:15:32 +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
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
b5d8ace6ab
feat(control_tree): Phase 132 P0 + P0.5 - loop(true) + post-loop support
...
**Phase 132 P0**: Extend loop(true) break-once to support post-loop statements
Goal: Support `loop(true) { x = 1; break }; x = x + 2; return x` → exit code 3
Implementation:
- loop_true_break_once.rs: Add post_k continuation generation
- Reuse Phase 130's lower_assign_stmt for post statements
- ExitMeta uses DirectValue mode (PHI-free)
**Phase 132 P0.5**: Fix StepTree post-loop statement visibility
Root cause: routing.rs created StepTree from Loop node only, losing post statements
Solution:
- New: normalized_shadow_suffix_router_box.rs
- Detects block suffix: Loop + Assign* + Return
- Creates StepTree from entire suffix (Block([Loop, Assign, Return]))
- Modified build_block() to call suffix router (dev-only)
Changes:
- apps/tests/phase132_loop_true_break_once_post_add_min.hako (new fixture)
- tools/smokes/v2/profiles/integration/apps/phase132_loop_true_break_once_post_add_*.sh
- src/mir/control_tree/normalized_shadow/loop_true_break_once.rs (+150 lines)
- src/mir/builder/control_flow/joinir/patterns/policies/normalized_shadow_suffix_router_box.rs (+380 lines)
- src/mir/builder/stmts.rs (build_block modified to support suffix skipping)
Design principles:
- StepTree unchanged: Block is SSOT for statement order
- No data duplication: Loop doesn't hold post_nodes
- Suffix router handles detection + conversion
- build_block() handles wiring only
Test results:
- Phase 132 VM: PASS (exit code 3)
- Phase 131 regression: PASS
- Phase 97 regression: PASS
Related: Phase 132 loop(true) + post-loop minimal support
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-18 21:51:33 +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
f42fcd33b4
refactor(joinir,smokes): Task 2,3,4 - instruction_rewriter boxification + OutputContract unification
...
Task 2: instruction_rewriter 分箱化
- Extract k_exit special case logic into TailCallLoweringPolicyBox
- Separate detect/collect/transform concerns into dedicated policy box
- Rewriter becomes pure transformation engine
- Added 5 unit tests for exit edge normalization
- New file: src/mir/builder/control_flow/joinir/merge/tail_call_lowering_policy.rs (212 lines)
Changes:
- instruction_rewriter.rs: Delegate k_exit detection to policy box (-50 lines)
- merge_result.rs: Add MirMergeResult struct for intermediate results
- Single responsibility principle: each box handles one concern
Task 3 & 4: smokes runner 改善
- Unify exit_code and numeric output verification into check_output_contract()
- Add require_joinir_dev() helper for dev-only fixture setup
- Reduce boilerplate in phase131_loop_true_break_once_*.sh scripts
- Consistent error message format across verification types
Changes:
- tools/smokes/v2/lib/llvm_exe_runner.sh: Add OutputContract interface (+90 lines)
- tools/smokes/v2/lib/test_runner.sh: Add require_joinir_dev() helper
- Phase 131 smoke scripts: Use new helpers (cleaner, less repetition)
- Build script: Improve TMPDIR configuration for EXDEV mitigation
Benefits:
- Single responsibility: policy box handles one concern
- Code reuse: OutputContract eliminates duplication
- Clarity: Smoke scripts are more concise and readable
- Maintainability: Easier to add new verification types
Test Results:
- Policy box unit tests: 5 PASS
- Smoke tests: 2/2 PASS
- No regression in existing functionality
Related: Phase 131 refactoring for improved code organization
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com >
2025-12-18 18:28:50 +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
02c4c313e5
feat(control_tree): Phase 131 P1.5-P2 DirectValue exit reconnection
...
Implement DirectValue mode for Normalized shadow exit handling:
**P1.5 Changes**:
- Add ExitReconnectMode::DirectValue (skip exit PHI generation)
- Carry remapped_exit_values through merge result
- Update host variable_map directly with exit values
- Fix loop(true) { x = 1; break }; return x to return 1 correctly
**P2 Changes**:
- Normalize k_exit continuation entry/exit edges
- Rewrite TailCall(k_exit) → Jump(exit_block) for proper merge
- Add verify_all_terminator_targets_exist contract check
- Extend ExitLineReconnector to handle DirectValue mode
**Infrastructure**:
- tools/build_llvm.sh: Force TMPDIR under target/ (EXDEV mitigation)
- llvm_exe_runner.sh: Add exit_code verification support
- Phase 131 smokes: Update for dev-only + exit code validation
**Contracts**:
- PHI-free: Normalized path uses continuations only
- Exit values reconnect via remapped ValueIds
- Existing patterns unaffected (既定挙動不変)
Related: Phase 131 loop(true) break-once Normalized support
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-18 17:48:05 +09:00
38d3c98822
test(joinir): Phase 131 loop(true) break-once fixture + VM/LLVM smokes
...
Add minimal fixture and smoke tests for loop(true) break-once pattern:
**Fixture**:
- apps/tests/phase131_loop_true_break_once_min.hako
- Pattern: x=0; loop(true) { x=1; break }; return x
- Expected: return value 1 (exit code 1)
**Smokes**:
- tools/smokes/v2/profiles/integration/apps/phase131_loop_true_break_once_vm.sh
- VM backend test with dev-only flags
- tools/smokes/v2/profiles/integration/apps/phase131_loop_true_break_once_llvm_exe.sh
- LLVM EXE backend test with plugin gating
**Note**: Smokes currently fail (execution path not yet wired).
Structure implementation only - follow-up phase will wire execution.
Related: Phase 131 P0 (Normalized shadow structure)
2025-12-18 09:36:25 +09:00
46a623fd75
fix(llvm): make LLVM EXE smokes use workspace target and reliable build_llvm
2025-12-18 09:22:11 +09:00
4a109eb6b9
test(smokes): make LLVM EXE runner skip when object emit unavailable
2025-12-18 09:13:23 +09:00
1afbb17529
test(joinir): Phase 130 post-if add fixture + smokes
2025-12-18 09:13:13 +09:00
f0a03d20d0
test(joinir): Phase 129 join_k as-last fixture + VM smoke
2025-12-18 07:53:27 +09:00
083be99214
test(joinir): Phase 129 P2 - add post-if return var fixture + VM smoke
...
- Add phase129_if_only_post_if_return_var_min.hako
- Pattern: x=1; if flag==1 { x=2 }; print(x)
- Tests join_k continuation env merge
- Add phase129_if_only_post_if_return_var_vm.sh
- Expected output: 2 (x updated in then branch)
- Dev-only: NYASH_JOINIR_DEV=1 HAKO_JOINIR_STRICT=1
Note: Currently passes via fallback path (non-Normalized)
P1 implementation (join_k materialization) is next step
2025-12-18 07:18:00 +09:00
e7ad3d31ba
test(joinir): Phase 129 P0 - add LLVM EXE smoke for Phase 128
...
- Add phase128_if_only_partial_assign_normalized_llvm_exe.sh
- VM+LLVM parity for if-only partial assign pattern
- Expected output: 2 (print(2) in then branch)
Regression verified:
- phase103_if_only_llvm_exe.sh: PASS
- phase118_loop_nested_if_merge_llvm_exe.sh: PASS
2025-12-18 07:15:23 +09:00
daf1827c03
test(joinir): Phase 128 - add fixture + smoke test (VM)
...
- Fixture: phase128_if_only_partial_assign_normalized_min.hako
- Tests basic assign lowering with if/return pattern
- Expected output: 2 (from then branch with print)
- Smoke: phase128_if_only_partial_assign_normalized_vm.sh
- Validates output: 2 with exit code 0
- Dev-only: NYASH_JOINIR_DEV=1 HAKO_JOINIR_STRICT=1
- Result: PASS
2025-12-18 07:07:04 +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
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
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
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
0892df6dff
test(joinir): Phase 121 shadow parity smokes (VM + LLVM EXE)
2025-12-18 04:39:23 +09:00
8fb393b5e8
test(joinir): Phase 118 loop+if merge parity smokes
2025-12-18 03:43:10 +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
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
80be814fa4
test: Phase 114 if-only return+post parity (VM + LLVM EXE)
...
Phase 114 validates that if-only lowering correctly handles cases with:
- Early return in the if-only branch
- Post-if statements that execute on the else path
- Different return values from each path
Fixture: apps/tests/phase114_if_only_return_then_post_min.hako
- Expected output: 7\n2
- f(1): condition true → early return 7
- f(0): condition false → x=1+1=2, return 2
Testing:
- VM backend: phase114_if_only_return_then_post_vm.sh ✅
- LLVM EXE backend: phase114_if_only_return_then_post_llvm_exe.sh ✅
- Regression: Phase 103/113 maintained ✅
Implementation: No new code required - validates existing if-only
exit line routing and post-if statement processing.
Documentation:
- docs/development/current/main/phases/phase-114/README.md
- Updated: 10-Now.md, 01-JoinIR-Selfhost-INDEX.md
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-18 02:18:57 +09:00
ba25fe6d01
test: Phase 113 if-only partial assign fixture + smokes (VM + LLVM)
...
- Add apps/tests/phase113_if_only_partial_assign_min.hako
* Pattern: x=1; if flag==1 { x=2 } print(x)
* Tests "preserve merge" on else side
- Add VM smoke: phase113_if_only_partial_assign_vm.sh
- Add LLVM EXE smoke: phase113_if_only_partial_assign_llvm_exe.sh
- Expected output: 1\n2 (flag=0 preserves, flag=1 updates)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-18 01:58:38 +09:00
9fa2f5a8ad
test: align Phase 107 object fixture expected output
2025-12-17 23:16:53 +09:00
3c934dc69d
test: Phase 107 add find_balanced_object_end fixture + smokes
2025-12-17 23:12:49 +09:00
d42117ac5f
test: Phase 107 find_balanced_array_end fixture + smokes
2025-12-17 22:47:42 +09:00
a05ce39a1f
test: add Phase104 json_cur read_digits fixture and smokes
2025-12-17 21:25:12 +09:00
e935b2324b
test(smokes): dedupe LLVM EXE scripts via llvm_exe_runner
2025-12-17 21:24:59 +09:00
950560a3d9
test(joinir): Phase 104 read_digits loop(true) parity
2025-12-17 18:29:27 +09:00
3fe92312a1
test: Phase 103 P1 if-only early return parity
2025-12-17 17:45:12 +09:00
99e1d24eaf
test: Phase 103 if-only merge fixture + VM/LLVM smokes
2025-12-17 17:41:07 +09:00
5b4f9c25e4
test: Phase 102 real-app read_quoted fixture + VM/LLVM smokes
2025-12-17 16:57:11 +09:00
b7a1cc4601
test(smoke): avoid Phase100 string accumulator LLVM EXE skip via plugin cache
2025-12-17 16:38:02 +09:00
dfc01f4dc5
test: Phase 100 string accumulator fixture+smokes (VM+LLVM)
...
- Add phase100_string_accumulator_min.hako fixture
* out = out + ch string accumulation
* print(out.length()) for stable numeric output
- Add VM smoke: phase100_string_accumulator_vm.sh
- Add LLVM EXE smoke: phase100_string_accumulator_llvm_exe.sh (Phase 97 gating)
- Regression: all phase100/97/94 tests pass
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-17 16:33:26 +09:00
43eda13b01
fix(smoke): Phase 97 LLVM EXE filter debug logs from output
...
- Filter out debug log lines (starting with '[') before numeric extraction
- grep -v '^\[' excludes debug lines like [UnifiedBoxRegistry], [TRACE]
- Ensures clean numeric output extraction for test validation
Note: Test still fails due to functional bug (returns 0,0,0 instead of 2,-1,3)
This is a separate issue requiring investigation of LLVM backend loop handling
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com >
2025-12-17 06:40:37 +09:00
cca9ce398e
test: Phase 100 mutable accumulator LLVM EXE smoke
...
- Add phase100_mutable_accumulator_llvm_exe.sh
- Plugin gating via Phase 97 pattern (dlopen cache → build-all)
- Numeric output validation (same SSOT as VM smoke)
- Regression: phase94 pass (phase97 has pre-existing issue)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-17 06:31:15 +09:00
536e6280c5
test: Phase 100 mutable accumulator fixture + smoke (numeric validation)
...
- Add apps/tests/phase100_mutable_accumulator_min.hako
* Pattern2 with break (if i >= 3 { break })
* Two accumulators: out = out + ch (string), count = count + 1 (integer)
* print(count) for stable numeric output
- Add phase100_mutable_accumulator_vm.sh smoke test
* HAKO_JOINIR_STRICT=1 validation
* Numeric-only output extraction (expected: 3)
- Regression: all phase100/96/94 tests pass
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-17 06:10:59 +09:00
82806f8f90
test: Phase 100 pinned local receiver fixture + smoke
...
- Add apps/tests/phase100_pinned_local_receiver_min.hako
* Dynamic string construction with pinned receiver usage
* Demonstrates loop-outer local as method receiver
- Add tools/smokes/v2/profiles/integration/apps/phase100_pinned_local_receiver_vm.sh
* HAKO_JOINIR_STRICT=1 validation
* Numeric output extraction for log-resistant testing
- Regression: phase96 and phase94 smoke tests pass
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com >
2025-12-17 05:43:44 +09:00
708d01d1f8
test: Phase 99 add trailing backslash escape best-effort (VM+LLVM)
...
末尾バックスラッシュ処理:
- 現行仕様: best-effort(そのまま出力)として固定
- fixture: "hello\\" → "hello\" を出力
- VM+LLVM EXE parity完全対応
Integration smokeで検証済み
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-17 04:26:05 +09:00
b23d23f11f
test: Phase 99 extend next_non_ws to 3 cases (VM+LLVM)
...
3ケース固定:
- 既存: " hi" → 2, " \t" → -1
- 新規: "\n\r\tX" → 3 (mixed newline/CR/tab)
VM+LLVM EXE parity完全対応
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-17 04:25:57 +09:00
6d73fc3404
feat(llvm): Phase 97 Box/Policy refactoring complete
...
Box化完了:
- CallRoutePolicyBox: Call routing SSoT
- PrintArgMarshallerBox: Print marshalling SSoT
- TypeFactsBox: Type propagation SSoT
- PhiSnapshotPolicyBox: PHI contract SSoT
- PluginErrorContext: Structured error reporting
📋 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-17 04:14:26 +09:00
65763c1ed6
feat(llvm): Phase 97 - Call/PHI/Plugin強化 + リファクタリング準備
...
## 概要
LLVM backend のCall処理、PHI wiring、Plugin loader を強化。
次のリファクタリング(箱化モジュール化)のための準備も含む。
## 変更内容
### LLVM Call処理強化
- `mir_call/__init__.py`: Call ルーティングロジック改善
- `mir_call/global_call.py`: print処理の marshal強化
- `mir_call/method_call.py`: メソッド呼び出し処理改善
- `boxcall.py`: BoxCall処理改善
### PHI処理強化
- `phi_manager.py`: PHI管理改善
- `phi_wiring/wiring.py`: PHI配線ロジック強化(+17行)
- `phi_wiring/tagging.py`: Type tagging改善
- `resolver.py`: Value解決ロジック強化(+34行)
### Copy伝播
- `copy.py`: Copy命令のType tag伝播追加(+10行)
### Plugin loader強化
- `library.rs`: エラー出力改善、[plugin/missing]ログ追加(+34行)
- fail-fast強化
### テスト
- `phase97_json_loader_escape_llvm_exe.sh`: Phase 97 E2Eテスト追加
- `phase97_next_non_ws_llvm_exe.sh`: Phase 97 E2Eテスト追加
### その他
- `nyash_kernel/lib.rs`: Kernel側の改善(+23行)
## 統計
- 14ファイル変更
- +256行 / -53行 = +203 net
## 次のリファクタリング準備
以下の箇所がリファクタリング対象として識別済み:
1. Call ルーティング箱の明文化
2. print の marshal 箱
3. TypeFacts/Tagging 箱の一本化
4. PHI Snapshot 契約のSSOT
5. Plugin loader のエラー出力統合
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-17 03:51:03 +09:00