61a3384bd2
docs(phase29aa): mark P8 complete
2025-12-28 06:32:46 +09:00
6d17a0f988
docs(phase29aa): mark P7 complete and queue P8
2025-12-28 06:00:34 +09:00
ec1a84c465
docs(phase29aa): mark P6 complete and queue P7
2025-12-28 05:21:28 +09:00
c8c99174af
docs(phase29aa): queue P6 intersection join
2025-12-28 04:44:18 +09:00
bf7b203586
phase29aa(p4): propagate rc state along jump chain to return
2025-12-28 01:56:36 +09:00
d70d9e3b89
docs(phase29aa): mark P3 complete and queue P4
2025-12-28 01:43:03 +09:00
94ad562aa5
Phase 29aa P3: Jump→Return single-pred rc propagation
2025-12-28 01:16:52 +09:00
ed68e48ed1
docs: update references after module splits
2025-12-27 21:43:47 +09:00
7be0b0c28e
phase29aa: RcPlan + guard no cleanup on jump/branch
2025-12-27 16:09:26 +09:00
b6e80943a3
phase29aa(p1): rc insertion plan/apply refactor
2025-12-27 16:02:32 +09:00
b895f67e07
docs(phase29aa): add P0 CFG-aware design and link from 29z
2025-12-27 15:38:18 +09:00
a916066631
phase29z(p2): return cleanup and null propagation doc alignment
2025-12-27 15:26:42 +09:00
084277ee18
docs(phase29z): P2 closeout markers and next steps
2025-12-27 15:21:40 +09:00
5a3d45ce53
phase29z(p1): handle explicit drop in rc insertion
2025-12-27 15:16:46 +09:00
977f105e4e
phase29z(p0): minimal RC insertion overwrite release
2025-12-27 15:03:05 +09:00
2223c1309b
docs(phase29z): Add RC insertion minimal instructions
2025-12-27 14:18:33 +09:00
292fb83dcb
docs(phase29y): Finalize P0 SSOT
2025-12-27 14:17:18 +09:00
9c6b725e3e
docs(phase29y): Add P0 docs-finalize instructions
2025-12-27 14:04:56 +09:00
60e3510b26
docs(phase287): Complete P9 closeout
2025-12-27 14:02:53 +09:00
25bd15a64c
docs(phase287): Add P9 closeout instructions
2025-12-27 13:57:33 +09:00
74c6df1acb
docs(phase287): Mark P7 complete, add P8 instructions
2025-12-27 13:39:04 +09:00
df4d0b1776
docs(phase287): Mark P6 complete, add P7 instructions
2025-12-27 13:26:33 +09:00
8d4472ddd3
docs(phase287): Mark P5 complete, add P6 instructions
2025-12-27 13:20:16 +09:00
ad5b6085c1
docs(phase287): Mark P4 complete, add P5 instructions
2025-12-27 12:50:17 +09:00
2f7061e2e5
docs(phase287): Mark P3 complete, add P4 instructions
2025-12-27 12:17:47 +09:00
fe895e8838
refactor(joinir): Phase 287 P2 - Modularize contract_checks (facade pattern)
...
- contract_checks.rs (846行) を facade 化
- 6モジュールへ分割(1 module = 1 contract):
- terminator_targets.rs (208行) - Branch/Jump検証
- exit_bindings.rs (35行) - exit_bindings ↔ exit_phis
- carrier_inputs.rs (145行) - carrier_inputs完全性
- boundary_creation.rs (160行) - B1/C2不変条件
- entry_params.rs (317行) - Entry param一貫性
- mod.rs (30行) - Facade
- Total: 846 → 895行(+49行モジュール境界オーバーヘッド)
- 意味論不変: エラータグ/ヒント文すべて保存
- Fail-Fast遵守: silent fallback追加なし
- 検証: Build 0 errors / Pattern6 RC=9 / quick 154/154 PASS
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-27 11:05:40 +09:00
26a739189d
docs(phase-29y): note pilot plumbing completion in Now/Backlog
2025-12-27 02:07:54 +09:00
348b19f42d
docs(phase-29y): self-contained consult packet + entry
2025-12-27 01:03:24 +09:00
606e236d6d
fix(phase-285): restore weak_basic_llvm + complete LLVM detection/quick SSOT
2025-12-26 16:32:37 +09:00
72552cddfb
docs(phase-285): add P3 LLVM one-pass instructions
2025-12-26 14:21:12 +09:00
fbd9c83b62
docs: reflect Phase 285 P2.2 completion (KeepAlive/ReleaseStrong)
2025-12-26 14:17:19 +09:00
22945c190c
feat(joinir): Phase 286 P3.2 - Pattern5 Plan line (loop(true) + early exit)
...
- Pattern5InfiniteEarlyExitPlan (Return/Break variants)
- extract_pattern5_plan() for loop(true) literal only
- normalize_pattern5_return(): 5 blocks CFG (header→body→found/step)
- normalize_pattern5_break(): 6 blocks CFG with carrier PHI
- NormalizationPlanBox exclusion for Pattern5-style loops
- Fixtures: phase286_pattern5_{return,break}_min.hako
- quick smoke 154/154 PASS
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-26 09:56:34 +09:00
65304ec0c4
docs(joinir): Phase 286 Pattern2調査・設計相談パケット追加
...
- phase286_pattern2_frag_poc.hako: Pattern2 PoC fixture
- phase286_pattern2_frag_poc.sh: integration smoke
- phase-286-plan-normalization-consult.md: Plan正規化の設計相談
- 10-Now.md, 30-Backlog.md: 進捗更新
- pattern2-deferred.md: 更新
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-26 04:58:38 +09:00
1d24e9a106
feat(joinir): Phase 286 P2.3 + Phase 287 - Pattern9 Plan化 + Router table-driven
...
## Phase 286 P2.3: Pattern9 AccumConstLoop Plan化 PoC
- DomainPlan::Pattern9AccumConstLoop 追加
- PlanNormalizer::normalize_pattern9_accum_const_loop() 実装
- PHI 2本(loop_var, acc_var)
- const/var 両方 OK(sum = sum + 1 または sum = sum + i)
- Pattern9 は Pattern1 より優先(より具体的なパターン)
- Integration test: phase286_pattern9_frag_poc PASS (return: 3)
- Regression: quick 154 PASS
## Phase 287: Router table-driven Plan extraction
- PLAN_EXTRACTORS static table で Pattern6/7/4/9/1 を統一管理
- PlanExtractorEntry/PlanExtractorVariant 構造体追加
- try_plan_extractors() で ~100行 → 3行に集約
- メンテナンス性向上(新 Pattern 追加はテーブル1行追加のみ)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-26 02:38:09 +09:00
2b86b658d8
docs(repl): Phase 288 documentation cleanup
...
Updated documentation to reflect actual implementation status:
- docs/reference/language/repl.md: Corrected examples (variable persistence TODO)
- docs/development/current/main/10-Now.md: Phase 288 completion noted
- docs/development/current/main/30-Backlog.md: Updated with Phase 288.1 tasks
- docs/development/current/main/phases/phase-288/: Added phase documentation
Accurate REPL behavior examples:
- x = 1 works (implicit local)
- print(x) errors (persistence in Phase 288.1)
- Expression auto-display deferred
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-25 14:01:32 +09:00
4cc324c06e
smokes(v2): Slim quick profile (Phase 287 P1)
...
Phase 287 P1 completed: Quick profile optimization
Changes:
- Moved 204 heavy tests from quick to integration profile
- Reduced execution time: 449.1s → 55.0s (88% reduction)
- Reduced test count: 651 → 447 tests (31% reduction)
- Maintained relative path structure for --filter compatibility
Moved test directories (14 total):
- phase2100, phase2211, phase2120, phase2220, phase251
- phase2160, phase2047-2051 (7 dirs), analyze
Profile responsibilities:
- quick: Fast feedback (55s, 447 tests)
- integration: Comprehensive validation (selfhost, S3, LLVM)
Documentation updates:
- tools/smokes/v2/README.md: Profile definitions
- docs/development/current/main/phases/phase-287/README.md: P1 results
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-25 07:48:18 +09:00
f740e6542f
feat(phase285): Complete weak reference implementation (VM + LLVM harness)
...
Phase 285LLVM-1.1 to 1.4 + weak reference infrastructure:
**LLVM Harness** (Phase 285LLVM-1.x):
- 285LLVM-1.1: User Box registration & debug output
- 285LLVM-1.2: WeakRef basic operations (identity deferred)
- 285LLVM-1.3: InstanceBox field access (getField/setField)
- 285LLVM-1.4: print Handle resolution (type tag propagation)
**VM Runtime** (nyash_kernel):
- FFI functions: nyrt_weak_new, nyrt_weak_to_strong, nyrt_weak_drop
(crates/nyash_kernel/src/lib.rs: +209 lines)
- WeakRef plugin invoke support
(crates/nyash_kernel/src/plugin/invoke.rs: +250 lines)
- weak_handles.rs: WeakRef handle registry (NEW)
**LLVM Python Backend**:
- WeakRef instruction lowering (weak.py: NEW)
- Entry point integration (entry.py: +93 lines)
- Instruction lowering (instruction_lower.py: +13 lines)
- LLVM harness runner script (tools/run_llvm_harness.sh: NEW)
**MIR & Runtime**:
- WeakRef emission & validation
- MIR JSON export for weak instructions
- Environment variable support (NYASH_WEAK_*, HAKO_WEAK_*)
**Documentation**:
- CLAUDE.md: Phase 285 completion notes
- LANGUAGE_REFERENCE_2025.md: Weak reference syntax
- 10-Now.md & 30-Backlog.md: Phase 285 status updates
Total: +864 lines, 24 files changed
SSOT: docs/reference/language/lifecycle.md
Related: Phase 285W-Syntax-0, Phase 285W-Syntax-0.1
2025-12-25 00:11:34 +09:00
661bbe1ab7
feat(phase284): P1 Complete - Return in Loop with Block Remap Fix
...
## Summary
Completed Phase 284 P1: Enable return statements in Pattern4/5 loops via
JoinInst::Ret infrastructure (100% pre-existing, no new infrastructure needed).
**Critical Bug Fix**: Block ID remap priority
- Fixed: local_block_map must take precedence over skipped_entry_redirects
- Root cause: Function-local block IDs can collide with global remap entries
(example: loop_step:bb4 vs k_exit:bb4 after merge allocation)
- Impact: Conditional Jump else branches were incorrectly redirected to exit
- Solution: Check local_block_map FIRST, then skipped_entry_redirects
## Implementation
### New Files
- `src/mir/join_ir/lowering/return_collector.rs` - Return detection SSOT (top-level only, P1 scope)
- `apps/tests/phase284_p1_return_in_loop_min.hako` - Test fixture (exit code 7)
- Smoke test scripts (VM/LLVM)
### Modified Files
- `loop_with_continue_minimal.rs`: Return condition check + Jump generation
- `pattern4_with_continue.rs`: K_RETURN registration in continuation_funcs
- `canonical_names.rs`: K_RETURN constant
- `instruction_rewriter.rs`: Fixed Branch remap priority (P1 fix)
- `terminator.rs`: Fixed Jump/Branch remap priority (P1 fix)
- `conversion_pipeline.rs`: Return normalization support
## Testing
✅ VM: exit=7 PASS
✅ LLVM: exit=7 PASS
✅ Baseline: 46 PASS, 1 FAIL (pre-existing emit issue)
✅ Zero regression
## Design Notes
- JoinInst::Ret infrastructure was 100% complete before P1
- Bridge automatically converts JoinInst::Ret → MIR Return terminator
- Pattern4/5 now properly merge k_return as non-skippable continuation
- Correct semantics: true condition → return, false → continue loop
## Next Phase (P2+)
- Refactor: Block remap SSOT (block_remapper.rs)
- Refactor: Return jump emitter extraction
- Scope: Nested if/loop returns, multiple returns
- Design: Standardize early exit pattern (return/break/continue as Jump with cond)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com >
2025-12-23 14:21:27 +09:00
41d92bedb9
refactor(extractors): Phase 282 P9a - CommonExtractionHelpers SSOT統合(スコープ限定版)
...
# Phase 282 P9a 完了 (Scope-Limited Integration)
## 実装内容
- **common_helpers.rs 作成**: 4グループの共通ヘルパー統合 (316行)
- Group 1: Control Flow Counting (count_control_flow - 汎用カウンター)
- Group 2: Control Flow Detection (has_break/continue/return_statement)
- Group 3: Condition Validation (extract_loop_variable, is_true_literal)
- Group 4: Pattern5専用ヘルパー (validate_continue_at_end, validate_break_in_simple_if)
- **Pattern統合完了**: Pattern5 → Pattern4 → Pattern2 → Pattern1
- Pattern5: ~90行削減 (5 tests PASS)
- Pattern4: ~66行削減 (5 tests PASS)
- Pattern2: ~67行削減 (4 tests PASS)
- Pattern1: ~28行削減 (3 tests PASS)
- Pattern3: 別フェーズに延期(pattern固有ロジック除外)
## 成果
- **コード削減**: ~251行(Pattern3除く、total ~400行見込み)
- **テスト**: 40 unit tests PASS (23 common_helpers + 17 extractors)
- **スモークテスト**: 45 PASS, 1 pre-existing FAIL(退行ゼロ)
- **ビルド警告**: 130 → 120 (-10)
## USER CORRECTIONS適用済み
1. ✅ スコープ限定(共通ロジックのみ、pattern固有除外)
2. ✅ Placeholder禁止(SSOT違反排除)
3. ✅ 統合順序変更(Pattern3を最後/別フェーズへ)
## 追加ドキュメント
- Phase 284 計画追加(Return as ExitKind SSOT)
- 10-Now.md, 30-Backlog.md 更新
🎯 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-23 11:14:28 +09:00
bfbc9b26bf
fix(joinir): Phase 283 P0 - Pattern3 Undefined ValueId Bug Fix
...
- Fix: extract_if_condition() moved after local_cond_env construction
(loop_with_if_phi_if_sum.rs:175)
- Root cause: condition extraction before i_param/sum_param creation
- Result: i % 2 referenced caller's ConditionEnv with unmapped ValueId
- Fail-Fast: Add condition_bindings validation in merge (mod.rs)
- Fixture: Update loop_if_phi.hako for C2 compatibility (sum.toString())
- Verified: VM execution outputs sum=9 ✅
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-23 08:14:27 +09:00
a744be929a
feat(edgecfg): Phase 281 P3 - cleanup Normal wiring + docs
2025-12-23 04:11:02 +09:00
960241795d
feat(mir/llvm): Phase 273 P0-P1 DomainPlan→CorePlan + LLVM arg fix
...
Phase 273 P0-P1: Two-layer plan architecture
- DomainPlan: Pattern-specific knowledge (ScanWithInit)
- CorePlan: Fixed vocabulary (Seq, Loop, If, Effect, Exit)
- ValueId references only (String expressions forbidden)
- Pipeline: Extractor→Normalizer→Verifier→Lowerer
New plan/ module:
- mod.rs: Type definitions, SSOT spec
- normalizer.rs: DomainPlan→CorePlan + ID allocation
- verifier.rs: V1-V6 invariant checks (fail-fast)
- lowerer.rs: CorePlan→MIR (pattern-agnostic)
LLVM fix (ChatGPT):
- function_lower.py: Fix argument reference bug
- Phase 258 index_of_string now PASS on LLVM backend
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-22 22:42:56 +09:00
757193891f
feat(llvm/phi): Phase 277 P1 - fail-fast validation for PHI strict mode
...
## Summary
Implemented fail-fast validation for PHI ordering and value resolution in strict mode.
## Changes
### P1-1: Strict mode for "PHI after terminator"
- File: `src/llvm_py/phi_wiring/wiring.py::ensure_phi`
- Behavior: `NYASH_LLVM_PHI_STRICT=1` → RuntimeError if PHI created after terminator
- Default: Warning only (no regression)
### P1-2: Strict mode for "fallback 0"
- File: `src/llvm_py/phi_wiring/wiring.py::wire_incomings`
- Behavior: Strict mode forbids silent fallback to 0 (2 locations)
- Location 1: Unresolvable incoming value
- Location 2: Type coercion failure
- Error messages point to next debug file: `llvm_builder.py::_value_at_end_i64`
### P1-3: Connect verify_phi_ordering() to execution path
- File: `src/llvm_py/builders/function_lower.py`
- Behavior: Verify PHI ordering after all instructions emitted
- Debug mode: Shows "✅ All N blocks have correct PHI ordering"
- Strict mode: Raises RuntimeError with block list if violations found
## Testing
✅ Test 1: strict=OFF - passes without errors
✅ Test 2: strict=ON - passes without errors (no violations in test fixtures)
✅ Test 3: debug mode - verify_phi_ordering() connected and running
## Scope
- LLVM harness (Python) changes only
- No new environment variables (uses existing 3 from Phase 277 P2)
- No JoinIR/Rust changes (root fix is Phase 279)
- Default behavior unchanged (strict mode opt-in)
## Next Steps
- Phase 278: Remove deprecated env var support
- Phase 279: Root fix - unify "2本のコンパイラ" pipelines
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-22 14:48:37 +09:00
5f891b72ad
docs(phase269): document P1 completion - SSA fix and type annotation
...
- Update 10-Now.md: Phase 269 P1 complete (SSA + type SSOT)
- Update 30-Backlog.md: Add P1.2 investigation task
- Update phases/phase-269/README.md: Document P1.0 and P1.1 details
Phase 269 P1 achievements:
- Pattern8 SSA correctness with PHI nodes
- call_method return type SSOT propagation
- Module signature as single source of truth
Known issue: this.method() in loops (pre-existing, tracked as P1.2)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-22 01:41:34 +09:00
a681298889
docs(edgecfg): define bridge-pattern removal criteria (Phase 271)
2025-12-21 23:16:44 +09:00
df715e909e
feat(edgecfg): Phase 268-270 savepoint (if_form adoption + Pattern9 minimal loop SSOT)
2025-12-21 23:12:52 +09:00
86a51cad2b
docs: Phase 267 P0 EdgeCFG Branch (BranchStub + emit_frag)
2025-12-21 20:33:24 +09:00
655a8efbc6
docs: record Phase 265/266 EdgeCFG progress and research note
2025-12-21 17:20:58 +09:00
21387f3816
feat(edgecfg): Phase 265 P2 - seq/if_ 実装(wires/exits 分離)
...
## 目的
「解決済み配線(wires)」と「未解決 exit(exits)」を分離し、
Frag 合成の基本パターンを完成させる。
## 実装内容
### 1. Frag 構造体の変更
- `wires: Vec<EdgeStub>` フィールド追加
- 不変条件:
- exits: target = None のみ(未配線、外へ出る exit)
- wires: target = Some(...) のみ(配線済み、内部配線)
### 2. loop_() の wires 対応
- Break/Continue を exits から wires に移動
- P1 テスト 3個を wires 検証に更新
### 3. seq(a, b) 実装
- a.Normal → b.entry を wires に追加(内部配線)
- seq の exits[Normal] は b の Normal のみ
- 新規テスト 2個追加
### 4. if_(header, cond, t, e, join_frag) 実装
- シグネチャ変更: join: BasicBlockId → join_frag: Frag
- t/e.Normal → join_frag.entry を wires に追加
- if の exits は join_frag.exits
- 新規テスト 2個追加
### 5. verify_frag_invariants() 強化
- wires/exits 分離契約の検証追加(警告のみ)
- Err 化は Phase 266 で実施
## テスト結果
- edgecfg::api: 13/13 PASS(frag 3 + compose 9 + verify 1)
- 全 lib テスト: 1388/1388 PASS(退行なし)
## 核心的な設計判断
1. **wires/exits 分離**:
- 問題: 解決済み配線と未解決 exit を混ぜると再配線バグ
- 解決: 分離して不変条件を強化
- 効果: Phase 266 で wires を MIR terminator に落とすだけ
2. **if_ は join_frag 受け取り**:
- 問題: join: BasicBlockId では「join block」か「join 以降」か曖昧
- 解決: join_frag: Frag で「join 以降」を明確化
- 効果: PHI 生成の柔軟性確保
3. **verify は警告のみ**:
- P2 の役割: wires/exits 分離の証明に集中
- Phase 266 で MIR 生成時に厳格化
## 次フェーズへの橋渡し
- Phase 266: wires を MIR terminator に落とす
- Phase 267: Pattern6/7/8 を Frag 化
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-21 16:47:47 +09:00
cda034fe8f
feat(edgecfg): Phase 265 P1 - compose 配線ロジック実装(test-only PoC)
...
## 目的
Frag/ExitKind が BasicBlockId 層で配線できることを証明
## 実装完了内容
- EdgeStub に target: Option<BasicBlockId> 追加
- compose::loop_() 配線ロジック実装(Continue → header, Break → after)
- verify_frag_invariants() 配線契約検証追加
- test-only PoC で実証完了(5個のテスト)
## 配線契約
- Continue(loop_id) の EdgeStub.target = Some(header)
- Break(loop_id) の EdgeStub.target = Some(after)
- Normal/Return/Unwind の EdgeStub.target = None(上位へ伝搬)
## テスト
- compose::tests: 5 PASS(既存2個更新 + 新規3個追加)
- verify::tests: 1 PASS(基本smoke test)
- cargo test -p nyash-rust --lib: SUCCESS
## 重要な制約
- MIR 命令生成はまだしない(Frag 層の配線能力証明のみ)
- NormalizedShadow/JoinIR層への適用は Phase 266 に繰り越し
- Pattern6/7/8 未改変(配線能力の証明に集中)
## 次のステップ
- Phase 265 P2: seq/if_ 実装(順次合成・条件分岐合成)
- Phase 266: JoinIR-VM Bridge 改修後、NormalizedShadow への適用
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-21 16:22:46 +09:00