docs(joinir): Phase 201 implementation status and key insights

Added Section 8 to phase201-join-value-space-design.md:

- 8.1: Completed tasks summary table (all 7 tasks done)
- 8.2: Key implementation insight
  - Original plan: all params from alloc_local()
  - Actual: loop_step params use ConditionEnv's ValueIds
  - Reason: condition lowering needs matching ValueIds
- 8.3: Test results (821 tests pass, E2E verified)

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
nyash-codex
2025-12-09 18:56:51 +09:00
parent 17152bafff
commit 8d5ecef04f

View File

@ -258,8 +258,64 @@ They are complementary:
| `loop_header_phi_builder.rs` | Call reserve_phi() |
| `merge/mod.rs` | Create JoinValueSpace, pass down |
## 8. References
## 8. Implementation Status (2025-12-09)
### 8.1 Completed Tasks
| Task | Status | Notes |
|------|--------|-------|
| 201-1: Design document | ✅ Complete | This document |
| 201-2: JoinValueSpace box | ✅ Complete | 10 unit tests, all passing |
| 201-3: Param region migration | ✅ Complete | ConditionEnvBuilder v2 API |
| 201-4: PHI reservation | ✅ Skipped | Not needed - lowerer uses ConditionEnv's ValueIds directly |
| 201-5: Local region migration | ✅ Complete | Pattern 2 lowerer updated |
| 201-6: Testing | ✅ Complete | 821 tests pass, E2E verified |
| 201-7: Documentation | ✅ Complete | This section |
### 8.2 Key Implementation Insight
The original plan assumed lowerers would allocate ALL ValueIds from JoinValueSpace.
The actual implementation is smarter:
```
Original Plan:
- main params: alloc_local() → 1000+
- loop_step params: alloc_local() → 1000+
- intermediates: alloc_local() → 1000+
Actual Implementation:
- main params: alloc_local() → 1000+ (entry point slots)
- loop_step params: USE ConditionEnv's ValueIds → 100+ (CRITICAL!)
- intermediates: alloc_local() → 1000+
```
Why? Because `lower_condition_to_joinir` uses ConditionEnv to resolve variable names.
If `loop_step.params[0]` (i_param) doesn't match `env.get("i")`, condition lowering fails.
### 8.3 Test Results
```
# Library tests
$ cargo test --release --lib
test result: ok. 821 passed; 0 failed
# E2E tests
$ ./target/release/hakorune apps/tests/phase200d_capture_minimal.hako
30 # ✓ Expected output
$ ./target/release/hakorune apps/tests/loop_continue_pattern4.hako
25 # ✓ Expected output
$ ./target/release/hakorune apps/tests/loop_continue_multi_carrier.hako
100
10 # ✓ Expected output (two carriers)
```
## 9. References
- Phase 201-A analysis: carrier PHI dst overwrite bug
- joinir-architecture-overview.md: JoinIR invariants
- value_id_ranges.rs: Module-level ValueId isolation
- Commits:
- `1af53f82` feat(joinir): Phase 201 JoinValueSpace - unified ValueId allocation
- `17152baf` feat(joinir): Phase 201-5 Pattern 2 lowerer uses JoinValueSpace