Commit Graph

84 Commits

Author SHA1 Message Date
59a29a86d3 phase29ao(p33): planner-derive pattern2 loopbodylocal smokes 2025-12-30 15:58:19 +09:00
363549b152 docs(phase29ao): add p33 pattern2 loopbodylocal planner-derive instruction 2025-12-30 15:34:58 +09:00
dd7f923b88 phase29ao(p32): strict adopt pattern2 realworld from facts 2025-12-30 15:28:40 +09:00
e84739f0c0 docs(phase29ao): add p32 pattern2 realworld instruction 2025-12-30 14:54:22 +09:00
20a3a918be phase29ao(p31): ssot shadow adopt routing in composer 2025-12-30 14:47:44 +09:00
b3e2ff57d5 docs(phase29ao): add p31 shadow adopt router refactor instruction 2025-12-30 14:32:29 +09:00
a189c9e301 phase29ao(p30): move shadow adopt composer ssot 2025-12-30 14:28:42 +09:00
a352e7e800 docs(phase29ao): add p30 move shadow adopt composer ssot instruction 2025-12-30 14:15:24 +09:00
ac5231555f phase29ao(p29): require shadow adopt tags for all gate patterns 2025-12-30 14:11:17 +09:00
ac272526c1 docs(phase29ao): add p29 shadow adopt tag coverage instruction 2025-12-30 14:03:31 +09:00
ab745e958a phase29ao(p28): add shadow adopt tags + gate smokes for p6/p7 2025-12-30 13:57:07 +09:00
6acda7f15d docs(phase29ao): add p28 shadow adopt observability instruction 2025-12-30 13:47:35 +09:00
bbd1194a26 phase29ao(p27): strict/dev adopt pattern6 scan_with_init subset from facts 2025-12-30 13:41:18 +09:00
d9afc803ef docs(phase29ao): add p27 pattern6 subset strict adopt instruction 2025-12-30 13:34:29 +09:00
52fc3f9353 phase29ao(p26): strict/dev adopt pattern2 break subset from facts 2025-12-30 13:30:28 +09:00
00f824e3e5 docs(phase29ao): add p26 pattern2 subset strict adopt instruction 2025-12-30 11:03:28 +09:00
45369ba763 phase29ao(p25): strict/dev adopt pattern5 from facts 2025-12-30 10:58:08 +09:00
7556ffd8ec docs(phase29ao): add p25 pattern5 strict adopt instruction 2025-12-30 10:50:21 +09:00
e122c9a7d6 phase29ao(p24): strict/dev adopt pattern7 from facts 2025-12-30 10:34:31 +09:00
6a2a0061ec docs(phase29ao): add coreloop exitmap composition ssot (p20) 2025-12-30 09:20:24 +09:00
0e78122129 docs(phase29ao): add p1 composer api bridge roadmap 2025-12-30 04:05:49 +09:00
fceae90f63 docs(phase29an): start skeleton/feature facts phase 2025-12-29 17:20:41 +09:00
9b8673207e docs(phase29al): coreplan migration roadmap ssot 2025-12-29 16:25:34 +09:00
c53f1edf31 docs(phase29al): exitkind cleanup effect contract ssot 2025-12-29 16:21:13 +09:00
786d2f5720 docs(phase29al): effect classification ssot 2025-12-29 16:16:53 +09:00
77b488b256 docs(phase29al): post-phi final form ssot 2025-12-29 16:10:33 +09:00
e598712298 docs(phase29al): post-phi final form ssot 2025-12-29 16:06:14 +09:00
bf9a63c53f docs(phase29al): ssot skeleton/feature model; planfrag freeze tag 2025-12-29 16:01:26 +09:00
c7697edde1 phase29ai(p7): planner returns DomainPlan (no hardcoded names) 2025-12-29 08:39:33 +09:00
b8586cfaf7 docs(phase29ai): link P2 SSOT docs 2025-12-29 07:13:55 +09:00
07529d3826 docs(phase29ai): add P2 SSOT registry + freeze taxonomy 2025-12-29 07:07:39 +09:00
d8786ebab9 phase29ad(p3): finalize pattern6/7 fixture naming ssot 2025-12-28 17:51:11 +09:00
9c44e990a9 phase29ad(p0): split pattern6 ok vs contract fixtures 2025-12-28 17:30:34 +09:00
1e1679f361 phase29ac(p1): normalize pattern6 reverse scan and flip smoke to PASS 2025-12-28 16:54:01 +09:00
209b04d808 docs(phase29ab): closeout P1-P9 2025-12-28 16:36:15 +09:00
b52788b3f6 phase29ab(p6): freeze pattern6 scan-with-init near-miss with fixture+smoke 2025-12-28 15:38:19 +09:00
bea2a8d9bb phase29ab(p5): freeze pattern7 split-scan near-miss with fixture+smoke 2025-12-28 14:32:19 +09:00
630ed02c48 feat(joinir): Phase 286 P2.7 - V10不変条件追加(body_bb effects契約)
- verifier.rs: V10検証追加 - body_bbのblock_effectsは空でなければならない
  - 違反時: "[V10] Loop at depth N has non-empty block_effects for body_bb"
  - テスト: test_v10_body_bb_effects_in_block_effects_fails
- joinir-plan-frag-ssot.md: V10をPlan段階の不変条件に追加
- README.md: P2.7セクション追加

Phase 286 P2.6.1で発見した「lowererはloop_plan.bodyをemitし、
block_effectsのbody_bbは無視する」問題を契約化し再発防止。

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-26 04:55:14 +09:00
843d094598 refactor(joinir): Phase 286 P1-P3 - Boundary contract context enrichment
- P1: Add alloc_join_param()/alloc_join_local() API to JoinValueSpace
  - Prevents future API misuse (thin wrappers with explicit "JoinIR" context)
  - Updated docs with footnote-style number references

- P2: Enrich error context with host_fn for better diagnostics
  - Added context: &str parameter to verify_boundary_contract_at_creation()
  - Error format now shows: [merge_joinir_mir_blocks host=<fn> ...]

- P3: Add join-side info to error context (continuation count + boundary summary)
  - Uses boundary.continuation_func_ids.len() for join=
  - Adds [conts=X exits=Y conds=Z] suffix with fixed key names
  - Enables faster debugging with log-searchable format

Error format: [merge_joinir_mir_blocks host=X join=Y [conts=A exits=B conds=C]]

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-25 02:15:40 +09:00
2d5607930c docs(edgecfg): Phase 280 - Frag Composition SSOT Positioning (A→B→C)
## Purpose

Stop pattern number enumeration proliferation by establishing Frag composition API
as the Single Source of Truth (SSOT) for structured control flow → CFG lowering.

Pattern numbers (1-9+) are **symptom labels** for regression tests, NOT architectural
concepts. The architectural SSOT is **Frag composition rules** (seq/if/loop/cleanup).

## Changes Summary

**Phase A (Docs-only, no code)**: SSOT Positioning
- edgecfg-fragments.md: Status Draft → Active SSOT (+243 lines)
  - Added 5 sections: Composition SSOT, Rules, Laws, Fail-Fast, Ownership
  - Documented 3-tier ownership model (Normalizer/Composition/Lowerer)
  - Established composition as pattern absorption destination
- joinir-architecture-overview.md: Pattern absorption documentation (+90 lines)
  - Added Section 0.2: Pattern Number Absorption Destination
  - JoinIR vs Plan comparison (different extraction, same SSOT)
  - Pattern absorption status table (Pattern6/7 as Phase 280 targets)
- phase-280/README.md: Full roadmap (new)

**Phase B (API solidification)**: Contract Verification
- compose.rs: Module-level + function-level Phase 280 docs (+149 lines)
  - Documented composition SSOT, ownership model, usage example
  - Added constraint/composition law sections to seq/if/loop/cleanup
  - Contract verification: All seq/if/loop contracts verified (no gaps)
  - Test gap analysis: No missing tests (wires/exits separation explicitly tested)

**Phase C (Pattern preparation)**: Documentation-only
- normalizer.rs: Pattern6/7 TODO comments (+10 lines)
  - Pattern6: Early exit doesn't fit compose::if_() → cleanup() target
  - Pattern7: 挙動不変保証難 → compose::if_() migration deferred to Phase 281

## Impact

- **Net +460 lines** (docs-heavy, minimal code)
- **4 files modified**, 1 directory created
- **SSOT established**: Frag composition is now THE absorption destination
- **導線固定**: Clear migration path for Pattern6/7 (Phase 281+)
- **No behavior change**: Documentation-only for Phase C (tests not run)

## Phase 280 Goal Achieved

 SSOT positioning + 導線固定 (NOT full migration - that's Phase 281)
 Phase A complete: Docs updated to "Active SSOT"
 Phase B complete: API contract verified and documented
 Phase C complete: Pattern6/7 hand-rolled locations documented

## Next Phase (Phase 281+)

- Phase 281: Full Pattern6/7 absorption (replace hand-rolled with compose_*)
- Phase 282: Router shrinkage (pattern numbers → test labels)
- Phase 283+: Pattern8 and beyond

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

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-23 01:18:36 +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
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
1fe5be347d refactor(mir): phase260 p0.1 strangler hardening + smoke fixtures 2025-12-21 05:47:37 +09:00