Commit Graph

546 Commits

Author SHA1 Message Date
375bb66b41 feat(phi_core): Phase 69-4.2 Trio公開面削減方針明文化
## 変更内容

### src/mir/phi_core/mod.rs
- Trio Legacy Boxes (3箱) の削除方針をコメント追加
  - LoopVarClassBox (578行)
  - LoopExitLivenessBox (414行)
  - LocalScopeInspectorBox (361行)
- 外部依存2箇所を明記:
  1. loop_form_intake.rs (~30行)
  2. loop_snapshot_merge.rs (~60行)
- TODO(Phase 70) マーカー設置(削減見込み ~1,443行)

### docs/development/current/main/phase69-4-trio-deletion-plan.md
- Phase 69-4 全体計画文書作成
- Phase 69-4.1: Trio callsite 棚卸し結果記録 
- Phase 69-4.2: phi_core 公開面削減完了記録 
- Phase 69-4.3-5: 未実施タスク整理 

## Phase 69-4.2 達成内容

**達成**:
-  Trio 削除計画の明文化
-  外部依存箇所の記録
-  Phase 70 削除条件の TODO 化

**未達成(Phase 70 で実施)**:
-  pub 公開除去(外部依存残存のため継続)
-  phi_core 内部化(LoopScopeShape 移行後に実現)

## 次のステップ

Phase 69-4.3: json_v0_bridge の Trio 依存を LoopScopeShape に寄せる設計

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-30 10:01:49 +09:00
58c5d8c9bc feat(joinir): Phase 66-68 GenericTypeResolver + JoinIR First Chapter Wrap
Phase 66: P3-C ジェネリック型推論箱化
- generic_type_resolver.rs 新設 (180行)
  - is_generic_method(): ArrayBox.get/pop/first/last, MapBox.get 判定
  - resolve_from_phi(): PHI解析によるジェネリック型推論
- TypeHintPolicy::is_p3c_target() 追加
  - P1/P2/P3-A/P3-B 以外を P3-C 候補として判定

Phase 67: P3-C 実利用への一歩
- phase67_generic_type_resolver.rs テスト追加 (3テスト)
- lifecycle.rs に P3-C 経路フック追加
  - GenericTypeResolver を P3-C 対象関数で優先使用
- A/B テストで旧経路との一致確認 (11 tests PASS)

Phase 68: JoinIR First Chapter Wrap (ドキュメント整理)
- 68-1: phase-30 README.md に Section 9 追加 (JoinIR 第1章完了サマリー)
- 68-2: README.md に JoinIR status セクション追加
- 68-3: CURRENT_TASK.md スリム化 (351→132行, 62%削減)
- 68-4: PHI_BOX_INVENTORY.md に Phase 66-67 完了セクション追加

Phase 69-1: Trio 棚卸し
- phase69-1-trio-inventory.md 作成
- Trio 使用箇所の完全棚卸し完了 (削減見込み 457-707行)

🐱 JoinIR 第1章完了!4つの柱確立:
- Structure (LoopForm)
- Scope (LoopScopeShape)
- JoinIR (Select/IfMerge/Loop)
- Type Hints (P1-P3-C)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-30 08:54:18 +09:00
13340c1de8 chore: Update docs/private submodule (Phase 65 完了) 2025-11-30 06:27:50 +09:00
41ce55fa53 chore: Update docs/private submodule (Phase 61-7 docs) 2025-11-29 16:27:45 +09:00
1855ed70b9 chore: Update docs/private submodule and CURRENT_TASK (Phase 61-5)
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 15:57:19 +09:00
0c23bc0788 docs: Phase 61-5 If PHI 棚卸し完了
Phase 61-5: If PHI 残りパターン棚卸しと削減計画策定

New docs:
- phase61-5-3-if-phi-priority-table.md: P1/P2/P3 優先度表
  - P1: 18関数(薄いラッパー削除候補)
  - P2: 5関数(JoinIR 拡張統合候補)
  - P3: 3関数(型システム統合待ち)

- phase61-5.4-next-phase-candidates.md: Phase 61-6 削減候補(3個)
  - Wave 1: set_if_context 削除(11行)、dev フラグ削除(15行)
  - Wave 2: A/B テスト削除(50行)
  - 合計削減見込み: 76行

- phase61-5-summary.md: Phase 61-5 全体サマリー
  - JoinIR カバー率: 完全28.6% + 部分57.1% = 85.7%
  - Phase 61-6 実装準備完了

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 15:57:14 +09:00
f4044c56cb refactor(phase62): Delete phi_input_collector.rs (-384 lines)
Phase 62前倒し: PhiInputCollectorの物理削除

Changes:
- Delete src/mir/phi_core/phi_input_collector.rs (-384 lines)
- Inline PhiInputCollector logic in json_v0_bridge/lowering/loop_.rs
  - sanitize: BTreeMap dedup + sort
  - optimize_same_value: check all inputs for same value
- Remove mod declaration in phi_core/mod.rs

Rationale:
- PhiInputCollector already inlined in Phase 59 (loopform_builder.rs)
- Last remaining usage was in JSON v0 Bridge
- Simple inline preserves exact behavior

Impact:
- -384 lines (Box + tests)
- No behavior change (inline equivalent)
- Build & test pass 

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 15:42:30 +09:00
7e045f61e2 chore: Update docs/private submodule (Phase 61-3 docs)
Phase 61-3 IfInLoopPhiEmitter箱化ドキュメント更新

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 14:42:36 +09:00
c584599ea9 chore: Update docs/private submodule (Phase 61-2 docs) 2025-11-29 12:26:11 +09:00
f104725a81 chore: Update docs/private submodule (Phase 61-1 docs)
Phase 61-1 If-in-loop JoinIR化ドキュメント追加
- Phase 61関連ドキュメント5個
- Phase 53-63新規Phase追加
- 既存Phase更新

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 11:54:28 +09:00
3af98964ed feat(joinir): Phase P2-P4 Loop Pattern boxification
- P2: Create loop_patterns/ module structure
  - common.rs: shared helpers (ParsedProgram, LoopContext, etc.)
  - simple.rs: generic loop lowering
  - filter.rs, print_tokens.rs: delegate to simple
  - break_pattern.rs, continue_pattern.rs: new modules

- P3: Create LoopFrontendBinding layer
  - Separate function name detection from pattern lowering
  - detect_loop_pattern() for pattern classification

- P4: Break/Continue pattern migration
  - Move Break/Continue handling from loop_patterns_old.rs
  - Add LoopPattern::Break and LoopPattern::Continue variants

- Design: 3-layer architecture
  - LoopFrontendBinding: function name → LoopPattern
  - loop_patterns: LoopPattern → JoinIR
  - Bridge/VM: Box semantics

All 56 JoinIR tests pass.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 09:04:18 +09:00
fd83903f87 feat(joinir): Phase P1 If Handler boxification - 40% code reduction
## Summary
Refactored loop-internal If statement handling into a boxified module
structure, achieving 154-line reduction (40%) from stmt_handlers.rs
with zero regression.

## Implementation
- Created if_in_loop/ module (9 files, ~480 lines)
  - pattern.rs: IfInLoopPattern enum (5 variants)
  - lowering/{empty,single_var_then,single_var_both,conditional_effect,unsupported}.rs
- Replaced lower_if_stmt_in_loop() (154 lines) with lower_if_stmt_in_loop_boxified()
- Made StatementEffect pub(crate) for module visibility

## Pattern Classification
1. Empty: condition-only check (no side effects)
2. SingleVarThen: if { x = a } → x = cond ? a : x
3. SingleVarBoth: if { x = a } else { x = b } → x = cond ? a : b
4. ConditionalEffect: if pred(v) { acc.push(v) } (filter pattern)
5. Unsupported: complex cases (Phase 54+)

## Test Results
 56 JoinIR tests PASSED (0 failed, 0 regression)
 Build successful (1m 02s)
 Improved maintainability (easier to add new patterns)

## Files Changed
- src/mir/join_ir/frontend/ast_lowerer/
  - if_in_loop/ (9 new files)
  - mod.rs (+2 lines: module + pub use)
  - stmt_handlers.rs (-154 lines: 40% reduction)
- CURRENT_TASK.md (+5 lines: Phase P1 記録)
- docs/development/refactoring/p1-if-handler-boxification-plan.md (new)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 07:20:56 +09:00
6bb6f38a1c feat(joinir): Phase 51 Field access / NewBox 式タイプ拡張
JoinIR Frontend の式タイプを拡張し、Field access と NewBox のパースと
MIR 変換をサポート。

## 新機能

### Field access (me.tokens 等)
- expr.rs に "Field" タイプハンドラ追加
- JoinInst::FieldAccess バリアント追加
- MIR 変換: FieldAccess → BoxCall (getter pattern)

### NewBox (new ArrayBox() 等)
- expr.rs に "NewBox" タイプハンドラ追加
- JoinInst::NewBox バリアント追加
- MIR 変換: NewBox → MirInstruction::NewBox

## 修正ファイル

- src/mir/join_ir/mod.rs: JoinInst 拡張
- src/mir/join_ir/frontend/ast_lowerer/expr.rs: パース対応
- src/mir/join_ir_vm_bridge/convert.rs: MIR 変換
- src/mir/join_ir_runner.rs: ハンドラ追加
- src/mir/join_ir/json.rs: JSON シリアライズ

## 注意

print_tokens/array_filter の JoinIR 完走には Phase 52 で
JSON 生成側 (LoopFrontendBinding) の修正が必要。

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 21:10:30 +09:00
3dc691d39f feat(joinir): Phase 50 Loop Frontend Binding layer
Phase 50 implements the Loop Frontend Binding layer that maps
actual loop variables to JoinIR Frontend's expected names (i, acc, n).

## Changes

- Add loop_frontend_binding.rs module with:
  - LoopFrontendBinding struct for variable mapping
  - for_print_tokens() and for_array_filter() factory methods
  - generate_local_declarations() for JSON v0 format
  - rename_body_variables() for out → acc renaming

- Integrate binding with cf_loop_joinir_impl:
  - Create binding based on function name
  - Inject i/acc/n Local declarations into JSON v0
  - Use correct JoinIR Frontend type names (Int/Var/Method)

## Limitations Found

JoinIR Frontend doesn't support:
- Field access (me.tokens) - blocks print_tokens
- NewBox (new ArrayBox()) - blocks array_filter

These will be addressed in Phase 51.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 20:59:54 +09:00
fb1b3132dd chore: Update docs/private submodule (Phase 49-4 docs)
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 20:12:45 +09:00
5819423e25 chore: Update docs/private submodule (Phase 49-3.2 docs)
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 19:45:32 +09:00
736df58b29 chore: Update docs/private submodule (Phase 49-3 docs)
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 19:29:53 +09:00
7cca67a7af chore: Update docs/private submodule (Phase 49 docs)
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 19:13:06 +09:00
9f5876083d chore: Update docs/private submodule (Phase 48-2 docs)
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 19:00:09 +09:00
66097f7553 chore: Update docs/private submodule (Phase 47-48 docs)
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 18:46:13 +09:00
8dc1d3bb99 feat(phi): Phase 47-2 compute_modified_names削除(33行削減)
- if_phi.rs から compute_modified_names を削除
- conservative.rs::ConservativeMerge::analyze 内にロジックをインライン化
- if_phi.rs 累計削減: 348行(Phase 38: 90行, 40-4.1: 35行, 41-1: 99行, 47: 33行)

テスト: conservative 3/3 PASS

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 18:40:47 +09:00
ac921b4188 chore: Update docs/private submodule (Phase 47-49 docs)
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 18:28:51 +09:00
31472cb171 chore: Update docs/private submodule (Phase 45-46 docs)
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 17:14:40 +09:00
1b9589e9a3 chore: Update docs/private submodule (Phase 41-3 design)
Phase 41-3 complete: JoinIR extension design for nested if
- NestedIfMerge JoinInst variant
- Stack-based PHI generation algorithm
- Implementation roadmap (41-3a/3b/4)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 12:23:54 +09:00
f97e6ad6af chore: Update docs/private submodule (Phase 41-2 docs)
Phase 41-2 complete: Representative If function selection
- Primary: ParserControlBox.parse_loop()
- Secondary: JsonTokenizer.print_tokens()

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 12:12:54 +09:00
73c305c453 docs(phase41): Phase 41-1 completion documentation
- Update CURRENT_TASK.md with Phase 41-1 results
- Update docs/private submodule (Phase 41-1 inventory tables)

Phase 41-1 Results:
- Dead code deletion: 147 lines (bonus discovery)
- Inventory tables for if_phi.rs (4 functions) and conservative.rs (2 functions)
- Level 3 Callsite Overview section added

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 12:08:54 +09:00
b53a2972db docs: Phase 40-4.2 documentation finalization
- CURRENT_TASK.md: Add Phase 40-4.1 section with deletion results
- docs/private submodule: Update all Phase 40 documentation

Phase 40 status: "Level 2 first deletion complete (51 lines),
remaining items await JoinIrConservativeAnalyzer implementation"

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 11:34:23 +09:00
6fa2a95bdf chore(joinir): Phase 40-4.1.1 dead code cleanup (16 lines)
- Remove use_joinir_for_array_filter() from env.rs (9 lines)
  Route B is now default, env flag no longer needed

- Remove next_var_id() from ast_lowerer.rs (7 lines)
  Duplicate of alloc_var() method

Cumulative deletion: 51 lines (35 + 16)
Tests: 5/5 Phase 40 PASS

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 11:31:18 +09:00
59f7f03efb feat(joinir): Phase 40-4.1 delete collect_assigned_vars (35 lines)
Breaking: collect_assigned_vars function removed from if_phi.rs

Changes:
- Delete collect_assigned_vars() function (35 lines)
- Make JoinIR route the default in loop_builder.rs
- Rewrite collect_assigned_vars_via_joinir() with ast_to_json support
  - Now detects both Local declarations and Assignment nodes
  - Add extract_vars_from_json_stmts/stmt helpers
- Update tests to use new implementation
  - phase40_joinir_detects_local_declarations
  - phase40_joinir_nested_if_local

Test results: 407 passed, 11 failed (same as before, no regression)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 11:07:01 +09:00
c7975d4bd9 feat(joinir): Phase 40-3.5 route switching implementation
- Add collect_assigned_vars_via_joinir() in if_phi.rs (65 lines)
  - Wrapper using Phase 40-1 JoinIR infrastructure
  - Converts ASTNode to JSON and calls JoinIR analysis
- Add route switching in loop_builder.rs
  - Check HAKO_JOINIR_ARRAY_FILTER env flag
  - Route A: Legacy collect_assigned_vars path
  - Route B: JoinIR collect_assigned_vars_via_joinir path
- Add A/B tests in phase40_array_ext_filter_test.rs
  - phase40_ab_route_switching: Basic assignment detection
  - phase40_ab_nested_if: Nested if assignment detection
- All 5 Phase 40 tests PASS

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 10:51:34 +09:00
29058d2c9a feat(phase40-3): dev flag実装 + テストインフラ準備
Phase 40-3成果:
- dev flag追加: use_joinir_for_array_filter() (env.rs)
- テストドキュメント更新 (phase40_array_ext_filter_test.rs)

フルパイプライン統合はPhase 40-3.5+に延期

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 10:34:50 +09:00
aa0b3972b9 docs(phase40-2): CURRENT_TASK.md Phase 40-2セクション追加
Phase 40-2設計フェーズ完了記録:
- パイプライン移行設計(現状→目標)
- 対象関数確定(array_ext.filter)
- 経路切替ポイント(loop_builder.rs:1069, 1075)
- A/Bテスト方針
- 削除条件(3条件)

コード変更: なし(docs-only)
次のステップ: Phase 40-3マイグレーションフェーズ

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 10:13:53 +09:00
88358a4086 feat(joinir): Phase 40-1 JoinFuncMetaインフラ構築
Phase 40-1成果:
- JoinFuncMeta構造体 + JoinFuncMetaMap型(func_meta.rs)
- lower_loop_with_if_meta() 実験用API
- convert_join_module_to_mir_with_meta() MIRラッパ
- extract_if_in_loop_modified_vars() helper methods
- Integration tests 3/3 PASS

削減: 0行(レガシー経路が現役のため保留)
成果: JoinIR SSOTへの橋を架けた

新規ファイル:
- src/mir/join_ir/frontend/func_meta.rs (25行)
- src/tests/joinir_frontend_if_in_loop_test.rs (160行)
- src/tests/phase40_array_ext_filter_test.rs (135行)

変更ファイル:
- src/mir/join_ir/frontend/ast_lowerer.rs (+89行)
- src/mir/join_ir_vm_bridge.rs (+80行)
- src/tests/mod.rs (+2行)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 09:26:28 +09:00
9e97e114eb chore: Update docs/private submodule (Phase 39 Level 2 preparation)
Phase 39 documentation complete:
- Stage-1/Stage-B representative function selection (5 candidates → top 2)
  - Primary: array_ext.filter (8/10 score, if-in-loop with conditional push)
  - Secondary: json_cur.read_quoted_from (7/10 score, comprehensive validation)
- JoinIR Frontend extension design (AST lowering, MIR lowering, ~120 lines)
  - if-in-loop AST lowering with variable tracking (~80 lines)
  - Loop exit PHI generation (~40 lines)
  - A/B test plan with 5 test fixtures
- Deletion criteria refinement (abstract → concrete checklist)
  - Verification Procedures: 3 procedures defined
  - Deletion sequence: Phase 40-1 through 40-4 roadmap
- Gap analysis (JoinIR Frontend coverage gaps identified)
  - collect_assigned_vars: 30% coverage (70% gap: if-in-loop variable capture)
  - compute_modified_names: 50% coverage (50% gap: conservative strategy)
  - merge_with_reset_at_merge_with: 80% coverage (20% gap: reset semantics)

CURRENT_TASK.md updated with Phase 39 completion
Zero functional code changes (docs-only phase)

Phase 39 complete: Level 2 deletion concrete implementation plan established
Total planned deletion: 115 lines (Phase 40)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 06:08:10 +09:00
bec2e2ffe6 feat(joinir): Phase 38 If-side PHI Level 1 deletion (90 lines, LOW safety)
Phase 38: Level 1 deletion complete (exceeded target by 22 lines)
- Deleted merge_modified_with_control (51 lines, dead code, 0 callsites)
- Deleted extract_assigned_var (39 lines, JoinIR AST lowering replacement)
- Updated callsites: if_form.rs (2), phi.rs (2) → replaced with None

File changes:
- if_phi.rs: 315 → 225 lines (90 lines, 28.6% reduction)
- Callsites updated: 4 sites (if_form.rs, phi.rs)

Technical achievements:
 JoinIR coverage verification (None replacement passes all tests)
 Dead code elimination (merge_modified_with_control 0 callsites)
 Staged deletion strategy validation (Phase 37 3-level plan works)

Test results:
 cargo build --release: Clean
 PHI tests: 58/58 PASS (no regression)
 JoinIR Frontend tests: 37/38 PASS (1 failure pre-existing test ordering)
 Full lib tests: 399-400/460 PASS (10-12 non-deterministic failures baseline)

Phase 35-38 cumulative: 605 lines deleted (430+107+90)
Phase 39+ potential: 415 lines (Level 2: 115, Level 3: 300)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 05:01:04 +09:00
616767ca06 chore: Update docs/private submodule (Phase 37 If-side PHI design)
Phase 37 documentation complete:
- If/PHI responsibility inventory (12 critical callsites)
- JoinIR coverage mapping (Phase 33-34)
- 3-level deletion criteria (Level 1/2/3)
- Deletion sequence plan (Phase 38/39/40+)

CURRENT_TASK.md updated with Phase 37 completion:
- Section 1-00j added with full design summary
- 483 lines deletion potential (Phase 38/39/40+)
- Zero functional code changes (docs-only phase)

Phase 35-37 cumulative: 537 lines deleted + 483 lines planned

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 04:41:44 +09:00
1beb9181cd chore: Update docs/private submodule (Phase 36 final docs)
Phase 36 documentation completion:
- PHI_BOX_INVENTORY.md updated with reduction records
- README.md/TASKS.md completion status
- CURRENT_TASK.md Phase 36 section added

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 04:29:04 +09:00
5cdf84248f chore: Update docs/private submodule (Phase 35-4 completion) 2025-11-28 01:19:14 +09:00
c2fb9dab6b feat(joinir): Phase 35-5 PHI box deletion (430 lines HIGH safety)
Phase 35-5: First wave deletion
- Deleted if_body_local_merge.rs (339 lines, 0 external calls)
  - Inlined logic into PhiBuilderBox::compute_modified_names_if()
  - Absorbed into PhiBuilderBox (isolated box with no external dependencies)
- Deleted phi_invariants.rs (91 lines, moved to JoinIR Verifier)
  - Removed ensure_if_values_exist() call from phi_builder_box.rs
  - Validation responsibility transferred to JoinIR Verifier
- Updated PHI_BOX_INVENTORY.md with deletion records

Phase 35-3/4: Documentation and route unification
- Added frontend_covered column to PHI_BOX_INVENTORY.md
- Documented JoinIR Runner routes (Route A: SSOT, Route B: structure validation)
- Updated join_ir_runner.rs module docstring with clear route guidelines

Build and test status:
 cargo build --release: Clean
 Phase 34 tests: All PASS (no regression)
 JoinIR tests: joinir_frontend_if_select, test_if_merge_simple_pattern PASS

Total reduction: 430 lines (HIGH safety achieved)
Phase 36+ potential: ~3,275 lines (MEDIUM/LOW safety)

Related docs:
- docs/private/roadmap2/phases/phase-35-phi-reduction/README.md
- docs/private/roadmap2/phases/phase-35-phi-reduction-investigation-report.md
- docs/private/roadmap2/phases/phase-30-final-joinir-world/PHI_BOX_INVENTORY.md

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 01:18:57 +09:00
853d80ba74 feat(joinir): Phase 34-7.5 helpers + Phase 34-8 Break/Continue implementation
Phase 34-7.5: Code organization improvements
- Added type conversion helpers (as_cont/as_func) in join_ir/mod.rs
- Enhanced docstrings for JoinCall/JoinJump with usage examples
- Improved error messages in join_ir_vm_bridge.rs

JoinIrFrontendTestRunner box implementation
- Created src/tests/helpers/joinir_frontend.rs (119 lines)
- Reduced test code by 83% (70 lines → 12 lines per test)
- 26% overall reduction in test file (284 → 209 lines)

Phase 34-8: Break/Continue pattern implementation
- Extended ast_lowerer.rs (+630 lines)
  - lower_loop_break_pattern(): Break as Jump (early return)
  - lower_loop_continue_pattern(): Continue as Select + Call
  - Added Bool literal support in extract_value()
- Created 2 fixtures: loop_frontend_{break,continue}.program.json
- Added 2 A/B tests (all 6 Phase 34 tests PASS)

Technical achievements:
- Break = Jump (early return pattern)
- Continue = Select + Call (NOT Jump) - critical discovery
- 3-function structure sufficient (no k_continue needed)
- SSA-style re-assignment with natural var_map updates

Test results:
 joinir_frontend_if_select_simple_ab_test
 joinir_frontend_if_select_local_ab_test
 joinir_frontend_json_shape_read_value_ab_test
 joinir_frontend_loop_simple_ab_test
 joinir_frontend_loop_break_ab_test
 joinir_frontend_loop_continue_ab_test

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 01:02:49 +09:00
a22726934d chore: Update docs/private submodule (Phase 34-6 docs)
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 17:06:17 +09:00
588129db65 feat(joinir): Phase 34-6 MethodCall 構造と本物の substring 意味論
**Phase 34-6 実装完了**: MethodCall 構造を JoinIR に追加し、本物の substring
呼び出しを通すことに成功。

## 主要変更

### 1. MethodCall 構造追加 (34-6.1)
- `src/mir/join_ir/mod.rs`: JoinInst::MethodCall バリアント (+8 lines)
  - 構造: `{ dst, receiver, method, args }`
  - 設計原則: JoinIR は構造のみ、意味論は MIR レベル

### 2. extract_value 更新 (34-6.2)
- `src/mir/join_ir/frontend/ast_lowerer.rs`: Method 処理本物化 (+37 lines)
  - receiver/args を extract_value で再帰処理
  - ダミー Const(0) 削除 → 本物の MethodCall 生成
  - cond 処理修正: ValueId(0) ハードコード → extract_value で取得

### 3. JoinIR→MIR 変換実装 (34-6.3)
- `src/mir/join_ir_vm_bridge.rs`: MethodCall → BoxCall 変換 (+12 lines)
- `src/mir/join_ir/json.rs`: MethodCall JSON シリアライゼーション (+16 lines)
- `src/mir/join_ir_runner.rs`: MethodCall 未対応エラー (+7 lines)

### 4. テスト更新 (34-6.4)
- `docs/.../fixtures/json_shape_read_value.program.json`: 本物の substring 構造
- `src/tests/joinir_frontend_if_select.rs`: run_joinir_via_vm 使用
- テスト成功: v="hello", at=3 → "hel" 

## 成果

-  テスト全通過(1 passed; 0 failed)
-  設計原則確立: JoinIR = 構造 SSOT、意味論 = MIR レベル
-  Phase 33-10 原則との整合性: Method でも同じ原則適用

**ドキュメント更新**: CURRENT_TASK.md + TASKS.md(Phase 34-6 完了記録)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 17:05:46 +09:00
6a5701ead9 feat(joinir): Phase 34-4 & 34-5 — JoinIR Frontend Stage-1/meta 対応 & extract_value 汎用化
Phase 34-4: Stage-1/meta 実用関数対応
- 対象関数: JsonShapeToMap._read_value_from_pair/1
- フィクスチャ簡略化(Int 10/20 ダミー値)
- match 分岐に "_read_value_from_pair" 追加(1行変更)
- テスト追加: joinir_frontend_json_shape_read_value_ab_test
- DRY 原則維持(Phase 34-3 refactoring の完全勝利)

Phase 34-5: extract_value 汎用化 & 実用 if の意味論対応
- ExtractCtx 構造体追加(ValueId カウンタ + 変数名マップ)
- extract_value 実装(Int/Var/Method 対応)
- lower_if_return_pattern を extract_value ベースに統一
- extract_int_value 削除(重複コード削減)
- コメント更新(Phase 34-5 反映)

変更ファイル:
- src/mir/join_ir/frontend/ast_lowerer.rs: +248 -62 lines (ExtractCtx + extract_value)
- src/tests/joinir_frontend_if_select.rs: +66 lines (json_shape テスト)
- CURRENT_TASK.md: Phase 34-4 & 34-5 記録追加
- docs/private: Phase 34 ドキュメント追加(README/TASKS/fixtures)

テスト結果: 3 passed; 0 failed
- joinir_frontend_if_select_simple_ab_test (Phase 34-2)
- joinir_frontend_if_select_local_ab_test (Phase 34-3)
- joinir_frontend_json_shape_read_value_ab_test (Phase 34-4)

技術的成果:
- Int ダミー値 → 本物の式(Var)への段階的移行成功
- extract_value 統一により、今後の expr 拡張が容易に
- Method 呼び出し pattern match 実装(Phase 34-6 への準備完了)
- DRY 原則遵守(extract_int_value 削除、重複コード削減)

ガードレール完全遵守:
- Phase 34 frontend テスト専用(既定経路不変)
- JoinIR = PHI 生成器の原則維持
- 未対応パターンは panic(tiny テスト専用で合理的)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 16:31:06 +09:00
9e9e08eb84 feat(joinir): Phase 33-9.1 Loop/If lowering responsibility separation
Implement clear separation between Loop and If lowering responsibilities:

**Guard Implementation:**
- Add is_loop_lowered_function() to identify 6 Loop-dedicated functions
- Exclude Loop functions from If lowering path in try_lower_if_to_joinir()
- Enforce "1 function → 1 lowering" principle

**Documentation:**
- Add responsibility comments to loop_to_join.rs
- Add responsibility comments to if_select.rs and if_merge.rs
- Update if_joinir_design.md with Phase 33-9.1 section

**Testing:**
- Add unit test test_is_loop_lowered_function() (PASS)
- Verify no regression in existing JoinIR tests

**Loop-dedicated functions (6):**
- Main.skip/1
- FuncScannerBox.trim/1
- FuncScannerBox.append_defs/2
- Stage1UsingResolverBox.resolve_for_source/5
- StageBBodyExtractorBox.build_body_src/2
- StageBFuncScannerBox.scan_all_boxes/1

This prevents future conflicts when both Loop and If lowering expand.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 10:58:56 +09:00
2d379692e3 chore: Update docs/private submodule (Phase 33-5 docs) 2025-11-27 05:42:27 +09:00
4fd013d9c7 Phase 33-5 preparation complete: Documentation updates
Submodule update: Phase 33 exit criteria & deletion roadmap documented

## Changes (docs/private)
- PHI_BOX_INVENTORY.md: Phase 33 progress section added
- phase-33-joinir-if-phi-cleanup/README.md: Exit criteria defined

## Key Points
- Deletion estimates: ~600 lines (if_phi, phi_invariants, conservative)
- Prerequisites: 5 conditions documented
- Stage-1/Stage-B application needed before full deletion
- Phase 33-4 complete, ready for Phase 33-5
2025-11-27 05:13:07 +09:00
c604402ea4 Phase 33-4.4 complete: Documentation + developer notes
## Documentation updates (docs/private submodule)
- TASKS.md: Phase 33-4.4 marked complete
- if_joinir_design.md: Section 10 added (A/B validation results)

## Developer convenience
- tools/smokes/v2/README.md: Added JoinIR If/Select smoke note
- One-liner for dev-only A/B verification (not CI-required)

Phase 33-4 fully complete. Next: Phase 33-5 preparation.
2025-11-27 05:05:01 +09:00
79cbf26f98 Phase 33-4: Stage-1/Stage-B expansion complete (33-4.1 to 33-4.3)
## Code Changes
- Extended function name whitelist in try_lower_if_to_joinir()
- Added: JsonShapeParser._read_value_from_pair/1 (Stage-1)
- Added: Stage1JsonScannerBox.value_start_after_key_pos/2 (Stage-B)

## Validation
- A/B testing: Route A (if_phi) vs Route B (Select) → identical results (RC 0)
- Test cases: joinir_if_select_simple.hako, joinir_if_select_local.hako
- Build: cargo build --release successful

## Documentation (docs/private submodule)
- TASKS.md: Phase 33-4.1 to 33-4.3 marked complete
- if_joinir_design.md: Section 9 added (candidate analysis)

## Next Steps
- Phase 33-4.4: CI/smoke test updates (pending)
2025-11-27 04:58:01 +09:00
bb4e3044a8 test(joinir): fix Phase 33-3.2 test flakiness by unifying env-dependent tests
Phase 33-3.2 test stabilization:
- Unified 4 env-dependent tests into 1 (test_if_select_pattern_matching)
- Eliminated race condition from parallel test execution
- All 5 tests now pass consistently (5/5 stable PASS)

Before: 8 tests (flaky 7-8/8 due to env var race)
After: 5 tests (stable 5/5, no flakiness)

Test coverage maintained:
- Simple pattern lowering (env ON)
- Local pattern lowering (env ON)
- Disabled by default (env OFF)
- Wrong function name filter (env ON)
- 4 verify tests (env-independent, kept separate)

Documentation:
- Updated TASKS.md with test flake resolution notes
- Updated docs/private submodule to 81ec67f

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 04:27:57 +09:00
4ba3fcd615 Phase 33-3.2: phi_invariants/conservative の JoinIR 側への移譲
実装内容:
- verify_select_minimal() 実装(Select 命令の最小 invariant チェック)
- phi_invariants.rs / conservative.rs のエッセンス抽出・移譲
- 4 テスト追加(simple/local with verify, reject multiple selects, check invariants)

移譲した責務:
- phi_invariants.rs::ensure_if_values_exist() → 型一貫性・完全性チェック
- conservative.rs::ConservativeMerge → 単一 PHI チェック

テスト結果:
-  8/8 tests PASS
-  simple/local パターン: Verifier PASS
-  不正パターン(複数 Select): Verifier REJECT
-  invariant ログ: conservative.rs / phi_invariants.rs からの移譲を明記

制限事項:
- IfSelectTest.* のみ対象、本線 if_phi は保持
- 削除は Stage-1/Stage-B/selfhost への適用後に行う

Phase 33-3.2 完了(2025-11-27)
2025-11-27 03:55:45 +09:00