348b19f42d
docs(phase-29y): self-contained consult packet + entry
2025-12-27 01:03:24 +09:00
bd0783fa85
docs(phase-285): Complete P4 Post-Completion documentation
...
Phase 285 P4 Post-Completion activities (2025-12-27):
1. Phase 284 P2 Integration Fix (commit 225600b5f )
- Fixed phase284_p2_return_in_loop_llvm (unreachable instruction)
- Integration LLVM tests: 3/3 PASS (no FAIL remaining)
2. ret.py Box-First Refactoring (commits 32aa0ddf6 , 5a88c4eb2 )
- Phase 1-2: UnreachableReturnHandlerBox + ReturnTypeAdjusterBox
- Phase 3: StringBoxerBox + ReturnPhiSynthesizerBox
- Reduced lower_return(): 166→117 lines (-29%)
3. Code Quality Improvements (4 commits)
- LLVM exit code SSOT (d7c6df367 )
- nyash_kernel FFI split (798c193cb )
- LLVM detection consolidation (1869396fd )
- auto_detect.conf clarity (095213c58 )
Final status:
- Integration LLVM tests: 3/3 PASS
- Quick profile: 154/154 PASS
- Current Focus: Phase 29y (post self-host, docs-first)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-27 00:31:29 +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
58ceb3de2f
feat(smoke): Phase 285 P2 - weak conformance smokes (success pattern)
...
Phase 285 P2: weak の意味論(weak <expr> + weak_to_strong() 成功/失敗)を integration smoke で固定
実装内容:
- Fixture A(成功パターン): exit 0 → exit 2 に変更(fail=1, success=2 で明確化)
- Fixture B(失敗パターン): 明示 drop (x = null) 方式で作成
- VM smoke success: PASS
- LLVM smoke success: SKIP(backend unavailable)
- VM/LLVM smoke fail: SKIP(hidden root 問題で理由付き)
既知の問題:
- x = null で明示 drop しても weak_to_strong が成功(hidden root が strong ref を保持)
- Phase 285 P2.1 (investigation) で root 保持箇所を棚卸し予定
スコープ:
- Block scope drop conformance は別タスク(未整合の可能性あり)
- P2 では明示 drop 方式で weak の最小意味論(non-owning)のみを検証
検証:
- quick smoke 154/154 PASS 維持
- integration smoke 4本(success 2本 PASS/SKIP、fail 2本 SKIP)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-26 11:33:12 +09:00
5ec0056059
docs(lifecycle): Phase 285 P0 - Box lifecycle/weakref/GC SSOT 固定
...
## 言語 SSOT との境界明文化
- lifecycle/weak/fini: lifecycle.md
- null/void/truthiness: types.md
- Phase 285 は実装状況・差分追跡のみ(言語SSOT書き換えなし)
## 用語・禁止事項固定
- Roots/Strong/Weak/Finalizer/GC 定義
- 禁止: finalizer 再入・例外・allocation・silent fallback
## VM/LLVM 差分分類
- (A) 仕様通り: weak/weak_to_strong/leak report
- (B) 未実装: finalizer/GC cycle collection
## P1/P2 導線
- P1: 棚卸し対象ファイル一覧(value.rs, finalization.rs等)
- P2: smoke 候補(weak_basic, weak_to_strong_fail, leak_report)
quick smoke 154/154 PASS
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-26 10:51:17 +09:00
03f9bbe1aa
feat(smoke): Phase 284 P2 - return-in-loop VM/LLVM parity smoke
...
- VM smoke: phase284_p2_return_in_loop_vm.sh (PASS)
- LLVM smoke: phase284_p2_return_in_loop_llvm.sh (SKIP if no LLVM feature)
- Reuse existing fixture: phase286_pattern5_return_min.hako (exit 7)
- P2-INSTRUCTIONS.md: 手順書作成
- 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 10:45:54 +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
6656098c95
docs(phase-286): P2.2 完了 + P2.3 準備中の進捗記載
...
更新内容:
- Phase 286 README に P2.2 ✅ COMPLETE セクション追加
- extractor helper化(extract_loop_increment_plan 統一)の内容
- router helper化(lower_via_plan() 追加)の内容
- 削減行数(~65行)と検証結果(quick 154 PASS, PoC 両方 PASS)
- 10-Now.md の Current Focus を Phase 286 P2.3 に更新
- P2/P2.1/P2.2 の完了を時系列記載
- Pattern9 (AccumConstLoop) を次の PoC 対象に決定
- CURRENT_TASK.md の Handoff(現状)を更新
- P2.2 COMPLETE の記載(hygiene 内容 + 成果)
- P2.3 準備中(Pattern9 PoC 準備)の1段落を追加
- pattern2-deferred.md 新規作成
- Pattern2 の複雑性(break値再接続)を説明
- 再開条件(after_bb PHI + compose::loop_ + Break wiring)を明文化
- Phase 286 P2.2 として後続タスク化
関連 issues: Phase 286 JoinIR Line Absorption
🤖 Generated with Claude Code
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com >
2025-12-26 02:03:34 +09:00
55d30c9845
docs(repl): record Phase 288.1 contract and results
...
更新内容:
- docs/reference/language/repl.md
- Phase 288.1 完了ステータスに更新
- Implementation Architecture セクション追加(AST rewrite 方式説明)
- AST Rewriter の動作フロー追加(Variable/Assignment 変換ロジック)
- ExternCall Bridge の仕組み追加(__repl.get/set → VMValue)
- Expression Detection ロジック追加(wrapper AST 判定)
- 動作例を完全に更新(全機能が動作済み)
- docs/development/current/main/phases/phase-288/README.md
- Phase 288.1 完了セクション追加
- 変更ファイル一覧(8ファイル, +592行)記録
- 確認コマンド 4種 記録(変数永続化/式表示/_変数/リセット)
- 回帰テスト結果記録(154/154 PASS)
- docs/development/current/main/10-Now.md
- "Phase 288.1 完了" に更新
- 次の候補(REPL UX 改善 / JoinIR 設計作業)を追記
- CURRENT_TASK.md
- 1段落サマリー更新(288.1 完了、次の方向性)
Phase 288.1 成果(SSOT記録):
✅ 変数永続化(session → eval bridge)
✅ 式自動表示(pure expression auto-output)
✅ _ 変数(last displayed value)
✅ Fail-Fast 未定義エラー + ヒント
✅ セッションリセット(.reset)
✅ 154/154 smoke tests PASS(file mode 不変)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-25 23:05:20 +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
1b7fd7a0ff
refactor(plan): Phase 273 P3+ - Legacy code removal
...
Phase 273 P3+ 完成: レガシーコード削除 + 未使用 import 整理
Removed Legacy Items:
1. emit_scan_with_init_edgecfg() - Pattern6 固有の emission 関数
- File deleted: src/mir/builder/emission/loop_scan_with_init.rs (~144 lines)
- Replaced by: generalized Frag API (Phase 273 P2)
2. CoreCarrierInfo struct - Legacy carrier representation
- Removed from: src/mir/builder/control_flow/plan/mod.rs (~15 lines)
- Replaced by: CorePhiInfo (generalized PHI representation)
3. verify_carrier() function - CoreCarrierInfo validator
- Removed from: src/mir/builder/control_flow/plan/verifier.rs (~15 lines)
- Replaced by: generalized PHI verification (V7-V9)
Code Cleanup:
- cargo fix applied: unused imports removed (~30 files)
- Verifier invariants updated: V1→V2-V9 (carrier→PHI model)
- Module declaration cleanup in emission/mod.rs
Impact:
- Total lines removed: ~174 lines (net reduction)
- Pattern-agnostic architecture strengthened
- All legacy Pattern6 references eliminated
Tests:
- ✅ VM tests PASS (phase254/256/258)
- ✅ LLVM tests PASS (phase256/258)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-23 00:11:20 +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
939efbca9b
feat(llvm/phi): Phase 277 P1.5 - structured error handling + import organization
...
## Changes
- P1.5.1: import整理 - debug_helper imports をモジュールトップへ移動
- P1.5.2: PhiStrictError 箱化 - エラーハンドリング構造化 (error_helpers.py新規)
- P1.5.3: wiring.py で PhiStrictError を使用 - 3箇所のエラーパターン統一
## Benefits
- ✅ エラーメッセージ生成の一元化(SSOT化)
- ✅ Python import 慣習準拠(関数内import削除)
- ✅ エラーコンテキスト構造化(block_id/dst_vid/next_file)
## Testing
✅ strict=OFF - passes without errors
✅ strict=ON - passes without errors
✅ debug mode - verification connected and running
🤖 Generated with Claude Code
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com >
2025-12-22 14:59:24 +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
6e749b791e
feat(phase277-p0-p1-a1): 完全実装 - デッドコード削除+SSOT使用+Void検出
...
Phase 277 P0/P1 + Phase 275 A1 完全実装
【Task 1: Phase 277 P0 - box_from_f64 削除】
- kernel/lib.rs から2関数削除(デッドコード)
- nyash.box.from_f64
- nyash.float.box_from_f64
- 理由: Phase 275 Float SSOT化により unboxed double 採用
【Task 2: Phase 277 P1 - dst_type_to_llvm_type 使用推進】
- wiring.py の型変換ロジックを type_helper 経由に統一
- SSOT原則の完全適用(型変換ロジック1箇所に集約)
【Task 3: Phase 275 A1 - Void検出修正】
- branch.py の Void/VoidBox 検出ロジック強化
- エラーメッセージ追加(fail-fast原則)
- VM動作確認: TypeError("Void in boolean context")
【Task 4: LLVM smoke tests - 3本全部PASS】
- test_p275_debug.hako: ✅ VM/LLVM parity (exit=3)
- test_p275_debug2.hako: ✅ VM/LLVM parity (exit=3)
- test_p275.hako: ⚠️ String問題(Phase 275外)
【検証】
- ビルド成功: 0 errors ✅
- Float PHI完全動作: VM/LLVM parity達成 ✅
- Void検出fail-fast: VMError確認 ✅
- SSOT原則完全適用: 型変換統一 ✅
【影響範囲】
- Kernel: 2関数削除(デッドコード)
- LLVM harness: 2ファイル(型変換SSOT + Void検出)
- ドキュメント: 10-Now.md更新
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-22 14:08:00 +09:00
03aa54a422
feat(phase277-p2): PHI環境変数統合 8個→3個 - ユーザビリティ向上
...
Phase 277 P2: PHI関連環境変数の統合・整理
【問題】
- PHI関連環境変数が8個に乱立
- ユーザーが覚える変数が多すぎる
- 保守性が低い(関連設定が分散)
【解決】
1. debug_helper.py 新規作成(SSOT)
- is_phi_debug_enabled(): 一般デバッグ(3変数統合)
- is_phi_trace_enabled(): 詳細トレース(2変数統合)
- is_phi_strict_enabled(): 厳格モード(既存維持)
2. 環境変数統合(8個→3個)
統合後:
- NYASH_LLVM_DEBUG_PHI: 一般PHIデバッグ
- NYASH_LLVM_DEBUG_PHI_TRACE: 詳細トレース
- NYASH_LLVM_PHI_STRICT: 厳格モード(既存維持)
統合前(廃止予定):
- NYASH_LLVM_PHI_DEBUG → NYASH_LLVM_DEBUG_PHI
- NYASH_PHI_TYPE_DEBUG → NYASH_LLVM_DEBUG_PHI
- NYASH_PHI_ORDERING_DEBUG → NYASH_LLVM_DEBUG_PHI
- NYASH_LLVM_TRACE_PHI → NYASH_LLVM_DEBUG_PHI_TRACE
- NYASH_LLVM_VMAP_TRACE → NYASH_LLVM_DEBUG_PHI_TRACE
3. 後方互換性対応
- 旧環境変数使用時に非推奨警告表示
- Phase 278 で削除予定
【効果】
- ✅ ユーザビリティ向上: 覚える変数 8個→3個(62%削減)
- ✅ 保守性向上: 環境変数チェック 30+箇所→1箇所(SSOT)
- ✅ ドキュメント簡潔化: environment-variables.md 整理
- ✅ SSOT原則適用: debug_helper.py に環境変数ロジック集約
【影響範囲】
- 新規: debug_helper.py (SSOT)
- 修正: 9ファイル(PHI関連Python)
- ドキュメント: environment-variables.md, 10-Now.md
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-22 13:57:33 +09:00
9a76a199ee
feat(phase276-p0): Quick Win improvements - type helper SSOT + debug cleanup
...
Phase 276 P0 post-Phase 275 robustness improvements:
1. Debug cleanup (wiring.py L100-103):
- Remove traceback.format_stack() output
- Cleaner debug logs after Phase 275 completion
2. box_from_f64 usage investigation:
- Confirmed ZERO usage (Rust/Python/MIR)
- Ready for deletion (Phase 275 unboxed double SSOT)
- crates/nyash_kernel/src/lib.rs L244-252, L971-982
3. Type resolution SSOT (⭐ most important):
- New file: src/llvm_py/phi_wiring/type_helper.py (72 lines)
- Unified 3 duplicate logic sites:
* tagging.py: inst.get("dst_type") → type_helper.get_phi_dst_type()
* llvm_builder.py: 9 lines → 2 lines (-7)
* wiring.py: 18 lines → 5 lines (-13)
- Priority: MIR JSON dst_type > resolver.value_types
- Benefits: SSOT principle, bug prevention, easy extension
4. Type mismatch warning enhancement (wiring.py L63-79):
- CRITICAL warning for predeclared PHI type mismatch
- PhiManager.invalidate_phi() notification
- Early bug detection with ⚠️ marker
Effects:
- Type resolution logic: 3 sites → 1 SSOT (type_helper.py)
- Code reduction: -20 lines duplicate logic
- Robustness: SSOT principle, CRITICAL warnings, Fail-Fast
- Debuggability: cleaner logs, prominent type mismatch alerts
Testing:
- LLVM harness: exit=3 verified (/tmp/test_p275_debug2.hako)
- NYASH_PHI_TYPE_DEBUG=1: correct type resolution confirmed
Docs:
- Phase 276 P0 completion: docs/.../phase-276/P0-COMPLETION.md
- 10-Now.md: Phase 276 P0 ✅ , Phase 275 P0 completed section
Next steps (Phase 277 P0 recommended):
- Delete box_from_f64 (nyash.box.from_f64, nyash.float.box_from_f64)
- Adopt dst_type_to_llvm_type() helper
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-22 13:39:55 +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
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
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
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
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