docs(phase93): Phase 93 P0完了記録 & ドキュメント整理
## 追加 - docs/development/current/main/phases/phase-93/README.md - Phase 93 P0 (ConditionOnly Derived Slot) 完了記録 - 実装内容・テスト結果の詳細 ## 更新 - CURRENT_TASK.md: Phase 93 P0完了に伴う更新 - 10-Now.md: 現在の進捗状況更新 - 30-Backlog.md: Phase 92/93関連タスク整理 - phase-91/92関連ドキュメント: historical化・要約化 ## 削減 - 735行削減(historical化により詳細をREADMEに集約) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@ -9,13 +9,14 @@
|
||||
|
||||
## Executive Summary
|
||||
|
||||
**Current JoinIR Readiness**: 47% (16/30 loops in selfhost code)
|
||||
**Inventory snapshot**: 47% (16/30 loops in selfhost code)
|
||||
この数値は Phase 91 開始時点の棚卸しメモで、Phase 91 自体では「P5b の認識(canonicalizer)まで」を完了した。
|
||||
|
||||
| Category | Count | Status | Effort |
|
||||
|----------|-------|--------|--------|
|
||||
| Pattern 1 (simple bounded) | 16 | ✅ Ready | None |
|
||||
| Pattern 2 (with break) | 1 | ⚠️ Partial | Low |
|
||||
| Pattern P5b (escape handling) | ~3 | ❌ Blocked | Medium |
|
||||
| Pattern P5b (escape handling) | ~3 | ✅ Recognized (canonicalizer) | Medium |
|
||||
| Pattern P5 (guard-bounded) | ~2 | ❌ Blocked | High |
|
||||
| Pattern P6 (nested loops) | ~8 | ❌ Blocked | Very High |
|
||||
|
||||
@ -32,7 +33,7 @@
|
||||
|
||||
#### File: `apps/selfhost-vm/json_loader.hako` (3 loops)
|
||||
- Lines 16-22: ✅ Pattern 1 (simple bounded)
|
||||
- **Lines 30-37**: ❌ Pattern P5b **CANDIDATE** (escape sequence handling)
|
||||
- **Lines 30-37**: ✅ Pattern P5b (escape skip; canonicalizer recognizes)
|
||||
- Lines 43-48: ✅ Pattern 1 (simple bounded)
|
||||
|
||||
#### File: `apps/selfhost-vm/boxes/mini_vm_core.hako` (9 loops)
|
||||
@ -222,197 +223,12 @@ This would make each sub-loop Pattern 1-compatible immediately.
|
||||
|
||||
## Design: Pattern P5b (Escape Sequence Handling)
|
||||
|
||||
### Motivation
|
||||
Pattern P5b の詳細設計は重複を避けるため、設計 SSOT に集約する。
|
||||
|
||||
String parsing commonly requires escape sequence handling:
|
||||
- Double quotes: `"text with \" escaped quote"`
|
||||
- Backslashes: `"path\\with\\backslashes"`
|
||||
- Newlines: `"text with \n newline"`
|
||||
- **設計 SSOT**: `docs/development/current/main/design/pattern-p5b-escape-design.md`
|
||||
- **Canonicalizer SSOT(語彙/境界)**: `docs/development/current/main/design/loop-canonicalizer.md`
|
||||
|
||||
Current loops handle this with conditional increment:
|
||||
```rust
|
||||
if ch == "\\" {
|
||||
i = i + 1 // Skip escape character itself
|
||||
ch = next_char
|
||||
}
|
||||
i = i + 1 // Always advance
|
||||
```
|
||||
|
||||
This variable-step pattern is **not JoinIR-compatible** because:
|
||||
- Loop increment is conditional (sometimes +1, sometimes +2)
|
||||
- Canonicalizer expects constant-delta carriers
|
||||
- Lowering expects uniform update rules
|
||||
|
||||
### Solution: Pattern P5b Definition
|
||||
|
||||
#### Header Requirement
|
||||
```
|
||||
loop(i < n) // Bounded loop on string length
|
||||
```
|
||||
|
||||
#### Escape Check Requirement
|
||||
```
|
||||
if ch == "\\" {
|
||||
i = i + delta_skip // Skip character (typically +1, +2, or variable)
|
||||
// Optional: consume escape character
|
||||
ch = s.substring(i, i+1)
|
||||
}
|
||||
```
|
||||
|
||||
#### After-Escape Requirement
|
||||
```
|
||||
// Standard character processing
|
||||
out = out + ch
|
||||
i = i + delta_normal // Standard increment (typically +1)
|
||||
```
|
||||
|
||||
#### Skeleton Structure
|
||||
```
|
||||
LoopSkeleton {
|
||||
steps: [
|
||||
HeaderCond(i < n),
|
||||
Body(escape_check_stmts),
|
||||
Body(process_char_stmts),
|
||||
Update(i = i + normal_delta, maybe(i = i + skip_delta))
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
#### Carrier Configuration
|
||||
- **Primary Carrier**: Loop variable (`i`)
|
||||
- `delta_normal`: +1 (standard case)
|
||||
- `delta_escape`: +1 or +2 (skip escape)
|
||||
- **Secondary Carrier**: Accumulator (`out`)
|
||||
- Pattern: `out = out + value`
|
||||
|
||||
#### ExitContract
|
||||
```
|
||||
ExitContract {
|
||||
has_break: true, // Break on quote detection
|
||||
has_continue: false,
|
||||
has_return: false,
|
||||
carriers: vec![
|
||||
CarrierInfo { name: "i", deltas: [+1, +2] },
|
||||
CarrierInfo { name: "out", pattern: Append }
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
#### Routing Decision
|
||||
```
|
||||
RoutingDecision {
|
||||
chosen: Pattern5bEscape,
|
||||
structure_notes: ["escape_handling", "variable_step"],
|
||||
missing_caps: [] // All required capabilities present
|
||||
}
|
||||
```
|
||||
|
||||
### Recognition Algorithm
|
||||
|
||||
#### AST Inspection Steps
|
||||
|
||||
1. **Find escape check**:
|
||||
- Pattern: `if ch == "\\" { ... }`
|
||||
- Extract: Escape character constant
|
||||
- Extract: Increment inside if block
|
||||
|
||||
2. **Extract skip delta**:
|
||||
- Pattern: `i = i + <const>`
|
||||
- Calculate: `skip_delta = <const>`
|
||||
|
||||
3. **Find normal increment**:
|
||||
- Pattern: `i = i + <const>` (after escape if block)
|
||||
- Calculate: `normal_delta = <const>`
|
||||
|
||||
4. **Validate break condition**:
|
||||
- Pattern: `if <char> == "<quote>" { break }`
|
||||
- Required for string boundary detection
|
||||
|
||||
5. **Build LoopSkeleton**:
|
||||
- Carriers: `[{name: "i", deltas: [normal, skip]}, ...]`
|
||||
- ExitContract: `has_break=true`
|
||||
- RoutingDecision: `chosen=Pattern5bEscape`
|
||||
|
||||
### Implementation Plan
|
||||
|
||||
#### Canonicalizer Extension (`src/mir/loop_canonicalizer/canonicalizer.rs`)
|
||||
|
||||
Add `detect_escape_pattern()` recognition:
|
||||
```rust
|
||||
fn detect_escape_pattern(
|
||||
loop_expr: &Expr,
|
||||
carriers: &[String]
|
||||
) -> Option<EscapePatternInfo> {
|
||||
// Step 1-5 as above
|
||||
// Return: { escape_char, skip_delta, normal_delta, carrier_name }
|
||||
}
|
||||
```
|
||||
|
||||
Priority: Call before `detect_skip_whitespace_pattern()` (more specific pattern first)
|
||||
|
||||
#### Pattern Recognizer Wrapper (`src/mir/loop_canonicalizer/pattern_recognizer.rs`)
|
||||
|
||||
Expose `detect_escape_pattern()`:
|
||||
```rust
|
||||
pub fn try_extract_escape_pattern(
|
||||
loop_expr: &Expr
|
||||
) -> Option<(String, i64, i64)> { // (carrier, normal_delta, skip_delta)
|
||||
// Delegate to canonicalizer detection
|
||||
}
|
||||
```
|
||||
|
||||
#### Test Fixture (`tools/selfhost/test_pattern5b_escape_minimal.hako`)
|
||||
|
||||
Minimal reproducible example:
|
||||
```nyash
|
||||
// Minimal escape sequence parser
|
||||
local s = "\\"hello\\" world"
|
||||
local n = s.length()
|
||||
local i = 0
|
||||
local out = ""
|
||||
|
||||
loop(i < n) {
|
||||
local ch = s.substring(i, i+1)
|
||||
|
||||
if ch == "\"" {
|
||||
break
|
||||
}
|
||||
|
||||
if ch == "\\" {
|
||||
i = i + 1 // Skip escape character
|
||||
if i < n {
|
||||
ch = s.substring(i, i+1)
|
||||
}
|
||||
}
|
||||
|
||||
out = out + ch
|
||||
i = i + 1
|
||||
}
|
||||
|
||||
print(out) // Should print: hello" world
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Files to Modify (Phase 91)
|
||||
|
||||
### New Files
|
||||
1. `docs/development/current/main/phases/phase-91/README.md` ← You are here
|
||||
2. `docs/development/current/main/design/pattern-p5b-escape-design.md` (new - detailed design)
|
||||
3. `tools/selfhost/test_pattern5b_escape_minimal.hako` (new - test fixture)
|
||||
|
||||
### Modified Files
|
||||
1. `docs/development/current/main/design/loop-canonicalizer.md`
|
||||
- Add Pattern P5b to capability matrix
|
||||
- Add recognition algorithm
|
||||
- Add routing decision table
|
||||
|
||||
2. (Phase 91 Step 2+) `src/mir/loop_canonicalizer/canonicalizer.rs`
|
||||
- Add `detect_escape_pattern()` function
|
||||
- Extend `canonicalize_loop_expr()` to check for escape patterns
|
||||
|
||||
3. (Phase 91 Step 2+) `src/mir/loop_canonicalizer/pattern_recognizer.rs`
|
||||
- Add `try_extract_escape_pattern()` wrapper
|
||||
この Phase 91 README は「在庫分析 + 実装完了の記録」に徹し、アルゴリズム本文や疑似コードは上記 SSOT を参照する。
|
||||
|
||||
---
|
||||
|
||||
@ -438,9 +254,8 @@ print(out) // Should print: hello" world
|
||||
## Next Steps (Future Sessions)
|
||||
|
||||
### Phase 92: Lowering
|
||||
- Implement Pattern5bEscape lowerer in JoinIR
|
||||
- Handle ConditionalStep carrier updates with PHI composition
|
||||
- E2E test with `test_pattern5b_escape_minimal.hako`
|
||||
- 進捗は Phase 92 で実施済み(ConditionalStep lowering + body-local 条件式サポート + 最小E2E smoke)。
|
||||
- 入口: `docs/development/current/main/phases/phase-92/README.md`
|
||||
|
||||
### Phase 93: Pattern P5 (Guard-Bounded)
|
||||
- Implement Pattern5 for `mini_vm_core.hako:541`
|
||||
@ -466,7 +281,7 @@ print(out) // Should print: hello" world
|
||||
**Phase 91** establishes the next frontier of JoinIR coverage: **Pattern P5b (Escape Handling)**.
|
||||
|
||||
This pattern unlocks:
|
||||
- ✅ All string escape parsing loops
|
||||
- ✅ escape skip を含む “条件付き増分” 系ループの取り込み足場(recognizer + contract)
|
||||
- ✅ Foundation for Pattern P5 (guard-bounded)
|
||||
- ✅ Preparation for Pattern P6 (nested loops)
|
||||
|
||||
|
||||
@ -1,161 +1,10 @@
|
||||
# Phase 92 P4: E2E固定+回帰最小化 - 完了報告
|
||||
# Phase 92 P4: E2E固定+回帰最小化 - 完了報告(Historical)
|
||||
|
||||
**実装日**: 2025-12-16
|
||||
**戦略**: 3レベルテスト戦略(P4-E2E-PLAN.md参照)
|
||||
Status: Historical
|
||||
Scope: Phase 92 P4 の完了ログ。現行の要約・入口は `README.md` を SSOT とする。
|
||||
Related:
|
||||
- `docs/development/current/main/phases/phase-92/README.md`
|
||||
- `docs/development/current/main/phases/phase-92/P4-E2E-PLAN.md`
|
||||
|
||||
---
|
||||
|
||||
## ✅ 完了タスク
|
||||
|
||||
### P4-1: E2E固定戦略(3レベル実装)
|
||||
|
||||
#### Level 1: 既存Pattern2Breakテストで退行確認
|
||||
- **テスト**: `apps/tests/loop_min_while.hako`
|
||||
- **結果**: ✅ PASS(出力: 0, 1, 2)
|
||||
- **確認内容**: Phase 92の変更で既存Pattern2機能が壊れていないことを確認
|
||||
|
||||
#### Level 2: Unit Test追加(Phase 92核心機能検証)
|
||||
- **ファイル**: `src/mir/join_ir/lowering/condition_lowerer.rs`
|
||||
- **追加テスト**:
|
||||
1. `test_body_local_variable_resolution` - body-local変数(`ch`)の条件式での解決
|
||||
2. `test_variable_resolution_priority` - ConditionEnv優先度の検証
|
||||
3. `test_undefined_variable_error` - 未定義変数のエラーメッセージ検証
|
||||
- **結果**: ✅ 全7テストPASS(`cargo test --release condition_lowerer::tests`)
|
||||
|
||||
#### Level 3: P5b完全E2E
|
||||
- **状態**: ⏸️ 延期(body-local promotion実装後)
|
||||
- **理由**: P5bパターン認識は厳密な要件があり、Phase 92スコープ外
|
||||
- 要件: 特定構造(break check + escape check)
|
||||
- `flag`ベースの条件は認識されない
|
||||
- body-local promotion システムの拡張が必要
|
||||
|
||||
---
|
||||
|
||||
### P4-2: Integration Smoke Test追加 ✅
|
||||
|
||||
**ファイル**: `tools/smokes/v2/profiles/integration/apps/phase92_pattern2_baseline.sh`
|
||||
|
||||
**テストケース**:
|
||||
- **Case A**: `loop_min_while.hako` - Pattern2 breakベースライン
|
||||
- 期待出力: `0\n1\n2\n`
|
||||
- 結果: ✅ PASS
|
||||
- **Case B**: `phase92_conditional_step_minimal.hako` - 条件付きインクリメント
|
||||
- 期待出力: `3\n`
|
||||
- 結果: ✅ PASS
|
||||
|
||||
**発見可能性**: ✅ Integration profileで正常に発見
|
||||
```bash
|
||||
tools/smokes/v2/run.sh --profile integration --filter "phase92*" --dry-run
|
||||
# → profiles/integration/apps/phase92_pattern2_baseline.sh
|
||||
```
|
||||
|
||||
**実行結果**:
|
||||
```
|
||||
[INFO] PASS: 2, FAIL: 0
|
||||
[PASS] phase92_pattern2_baseline: All tests passed
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### P4-3: Fail-Fast契約確認 ✅
|
||||
|
||||
**結論**: 追加不要(80/20ルール適用)
|
||||
|
||||
**既存実装確認**:
|
||||
1. **`conditional_step_emitter.rs`**:
|
||||
- Delta equality check実装済み
|
||||
- 条件分岐の両方のパスで同じdelta値を生成することを検証
|
||||
|
||||
2. **`ConditionEnv`**:
|
||||
- 変数解決失敗時のエラーメッセージ実装済み
|
||||
- `Variable '{name}' not found in ConditionEnv or LoopBodyLocalEnv`
|
||||
|
||||
3. **新規unit test**:
|
||||
- `test_undefined_variable_error` - エラーハンドリングを検証
|
||||
|
||||
**判断**: 現状の実装で十分。追加のcontract_checks実装は不要。
|
||||
|
||||
---
|
||||
|
||||
## ✅ 受け入れ基準確認
|
||||
|
||||
### Phase 92 E2E smokeがPASS
|
||||
- ✅ **Case A**: Pattern2 breakベースライン(既存テスト退行なし)
|
||||
- ✅ **Case B**: 条件付きインクリメント(Phase 92最小テスト)
|
||||
|
||||
### 既存integration smokesで退行なし
|
||||
- ✅ **Phase 135**: `trim_mir_verify.sh` - PASS確認済み
|
||||
- ✅ **Phase 132/133**: デフォルト動作変更なし(フラグOFF時)
|
||||
|
||||
### デフォルト動作変更なし
|
||||
- ✅ Phase 92の変更は既存コード経路に影響なし
|
||||
- ✅ `lower_condition_to_joinir_no_body_locals`ラッパーで後方互換性確保
|
||||
- ✅ body-local環境は`Option`で必要時のみ渡される
|
||||
|
||||
---
|
||||
|
||||
## Phase 92の成果まとめ
|
||||
|
||||
### 実装済み機能
|
||||
1. **Body-local変数サポート**: 条件式で`ch`などのbody-local変数を参照可能
|
||||
2. **変数解決優先度**: ConditionEnv → LoopBodyLocalEnv の明確な優先順位
|
||||
3. **Break condition順序修正**: body-local init後にbreak conditionを評価
|
||||
4. **ConditionalStep emission**: body-local環境を渡してJoinIR Select命令を生成
|
||||
|
||||
### テスト体制
|
||||
- **Unit tests**: 7個(condition_lowerer.rs)- Phase 92核心機能を検証
|
||||
- **Integration smoke**: 1個(phase92_pattern2_baseline.sh)- 2ケース
|
||||
- **既存テスト**: 退行なし確認済み
|
||||
|
||||
### 将来の拡張(Phase 92スコープ外)
|
||||
- Body-local promotionシステム拡張(Pattern2で一般的なbody-local変数を扱う)
|
||||
- P5bパターン認識の汎化(`flag`ベース条件もサポート)
|
||||
- 完全なP5b E2Eテスト
|
||||
|
||||
---
|
||||
|
||||
## 技術的詳細
|
||||
|
||||
### 変数解決メカニズム
|
||||
```rust
|
||||
// Phase 92 P2-2: Variable resolution priority
|
||||
// 1. ConditionEnv (loop parameters, captured variables)
|
||||
if let Some(value_id) = env.get(name) {
|
||||
return Ok(value_id);
|
||||
}
|
||||
// 2. LoopBodyLocalEnv (body-local variables like `ch`)
|
||||
if let Some(body_env) = body_local_env {
|
||||
if let Some(value_id) = body_env.get(name) {
|
||||
return Ok(value_id);
|
||||
}
|
||||
}
|
||||
Err(format!("Variable '{}' not found...", name))
|
||||
```
|
||||
|
||||
### 後方互換性ラッパー
|
||||
```rust
|
||||
pub fn lower_condition_to_joinir_no_body_locals(
|
||||
cond_ast: &ASTNode,
|
||||
alloc_value: &mut dyn FnMut() -> ValueId,
|
||||
env: &ConditionEnv,
|
||||
) -> Result<(ValueId, Vec<JoinInst>), String> {
|
||||
lower_condition_to_joinir(cond_ast, alloc_value, env, None)
|
||||
}
|
||||
```
|
||||
|
||||
全7ファイルで使用されている(header condition、legacy carrier update等)。
|
||||
|
||||
---
|
||||
|
||||
## 結論
|
||||
|
||||
**Phase 92 P4完了!**
|
||||
|
||||
Phase 92は「条件式でbody-local変数を使えるようにする基盤」を完成させました。
|
||||
|
||||
- ✅ **P4-1**: 3レベルテスト戦略完了(Level 1-2実装、Level 3延期)
|
||||
- ✅ **P4-2**: Integration smoke test 1本追加(2ケースPASS)
|
||||
- ✅ **P4-3**: Fail-Fast契約確認(追加不要)
|
||||
- ✅ **受け入れ基準**: 全達成
|
||||
|
||||
完全なP5b E2E動作は将来のPhaseで、body-local promotion実装時に達成します。
|
||||
Moved summary:
|
||||
- P4 の結果(unit / integration smoke / 残タスク)は `docs/development/current/main/phases/phase-92/README.md` の `P4` 節へ統合した。
|
||||
|
||||
@ -1,93 +1,9 @@
|
||||
# Phase 92 P4: E2E固定+回帰最小化
|
||||
# Phase 92 P4: E2E固定+回帰最小化(Historical)
|
||||
|
||||
## Phase 92の範囲と成果
|
||||
Status: Historical
|
||||
Scope: Phase 92 P4 の当時メモ。現行の要約・入口は `README.md` を SSOT とする。
|
||||
Related:
|
||||
- `docs/development/current/main/phases/phase-92/README.md`
|
||||
|
||||
**Phase 92の実装範囲**:
|
||||
- P0-P2: ConditionalStepのJoinIR生成とbody-local変数サポート
|
||||
- **完了した機能**: `lower_condition_to_joinir`でbody-local変数解決をサポート
|
||||
|
||||
**Phase 92の範囲外**:
|
||||
- P5bパターン認識の拡張(escape_pattern_recognizerは既存のまま)
|
||||
- body-local variable promotionシステムの拡張
|
||||
|
||||
## P4-1: E2E固定戦略
|
||||
|
||||
### 問題
|
||||
P5bパターン認識は厳密な要件があり、テストケースが認識されない:
|
||||
- 要件: 特定の構造(break check + escape check)
|
||||
- 現状: `flag`ベースの条件は認識されない
|
||||
|
||||
### 解決策: 段階的アプローチ
|
||||
|
||||
**Level 1: 最小E2E(既存Pattern2Break)**
|
||||
```bash
|
||||
# 既存のPattern2Breakテストを使用
|
||||
NYASH_DISABLE_PLUGINS=1 ./target/release/hakorune apps/tests/loop_min_while.hako
|
||||
# Expected: 正常動作(退行なし)
|
||||
```
|
||||
|
||||
**Level 2: Unit Test(Phase 92の核心)**
|
||||
```bash
|
||||
# condition_lowerer.rsのunit testでbody-local変数サポートを検証
|
||||
cargo test --release condition_lowerer::tests
|
||||
# Expected: body-local変数の変数解決優先度が正しく動作
|
||||
```
|
||||
|
||||
**Level 3: Integration(将来のP5b完全実装時)**
|
||||
```bash
|
||||
# P5bパターン完全実装後のE2E
|
||||
NYASH_JOINIR_DEV=1 NYASH_DISABLE_PLUGINS=1 ./target/release/hakorune apps/tests/phase92_p5b_full.hako
|
||||
# Note: body-local promotion実装が必要
|
||||
```
|
||||
|
||||
## P4-2: Integration Smoke
|
||||
|
||||
最小限のsmoke testを追加:
|
||||
|
||||
```bash
|
||||
# tools/smokes/v2/profiles/integration/rust-vm/phase92_pattern2_baseline.sh
|
||||
# 既存のPattern2Breakテストで退行確認
|
||||
```
|
||||
|
||||
## P4-3: Fail-Fast契約
|
||||
|
||||
現状のFail-Fast実装は十分:
|
||||
- `conditional_step_emitter.rs`: delta equality check
|
||||
- `ConditionEnv`: 変数解決失敗時のエラーメッセージ
|
||||
|
||||
追加不要(80/20ルール)。
|
||||
|
||||
## 受け入れ基準
|
||||
|
||||
✅ **Level 1完了**: 既存Pattern2Breakテストが動作(退行なし)
|
||||
✅ **Level 2完了**: Unit testでbody-local変数サポート検証
|
||||
- `test_body_local_variable_resolution` - body-local変数解決
|
||||
- `test_variable_resolution_priority` - 変数解決優先度(ConditionEnv優先)
|
||||
- `test_undefined_variable_error` - 未定義変数エラーハンドリング
|
||||
- 全7テストPASS確認済み(`cargo test --release condition_lowerer::tests`)
|
||||
✅ **P4-2完了**: Integration smoke test追加
|
||||
- `tools/smokes/v2/profiles/integration/apps/phase92_pattern2_baseline.sh`
|
||||
- Case A: `loop_min_while.hako` (Pattern2 baseline)
|
||||
- Case B: `phase92_conditional_step_minimal.hako` (条件付きインクリメント)
|
||||
- 両テストケースPASS、integration profileで発見可能
|
||||
✅ **P4-3完了**: Fail-Fast契約確認(追加不要と判断)
|
||||
- `conditional_step_emitter.rs`: delta equality check実装済み
|
||||
- `ConditionEnv`: 変数解決失敗時のエラーメッセージ実装済み
|
||||
- 80/20ルール適用: 現状の実装で十分と判断
|
||||
⏸️ **Level 3延期**: P5b完全E2E(body-local promotion実装後)
|
||||
|
||||
## Phase 92の価値
|
||||
|
||||
**実装済み**:
|
||||
1. `lower_condition_to_joinir`でbody-local変数解決(priority: ConditionEnv → LoopBodyLocalEnv)
|
||||
2. `conditional_step_emitter.rs`でbody-local環境を渡す
|
||||
3. Break condition loweringの順序修正(body-local init後に実行)
|
||||
|
||||
**将来の拡張**:
|
||||
- body-local promotionシステム拡張(Pattern2で一般的なbody-local変数を扱う)
|
||||
- P5bパターン認識の汎化
|
||||
|
||||
## 結論
|
||||
|
||||
Phase 92は「条件式でbody-local変数を使えるようにする基盤」を完成させました。
|
||||
E2E完全動作は将来のPhaseで、body-local promotion実装時に達成します。
|
||||
Moved summary:
|
||||
- P4 の要点(unit / integration smoke / 残タスク)は `docs/development/current/main/phases/phase-92/README.md` の `P4` 節へ統合した。
|
||||
|
||||
@ -3,8 +3,10 @@
|
||||
## Status
|
||||
- ✅ P0: Contract + skeleton-to-lowering wiring (foundations)
|
||||
- ✅ P1: Boxification / module isolation (ConditionalStep emitter)
|
||||
- 🔶 P2: Wire emitter into Pattern2 + enable E2E
|
||||
- ✅ P2: Pattern2 へ配線 + body-local 条件式サポート
|
||||
- ✅ P3: BodyLocal 1変数(read-only)を Pattern2 条件で許可(Fail-Fast)
|
||||
- ✅ P4: E2E固定(最小)+ 回帰最小化(unit + integration smoke)
|
||||
- ⏸️ P5: P5b “完全E2E” は promotion 拡張後
|
||||
|
||||
## Goal
|
||||
- Phase 91 で認識した P5b(escape skip: +1 / +2 の条件付き更新)を、JoinIR lowering まで落とせるようにする。
|
||||
@ -14,7 +16,7 @@
|
||||
|
||||
- P0-1: ConditionalStep 契約(SSOT)
|
||||
- 実装/記録: `src/mir/loop_canonicalizer/skeleton_types.rs`(契約コメント)
|
||||
- 記録: `docs/development/current/main/phases/phase-92/p0-2-skeleton-to-context.md`
|
||||
- 記録(歴史): `docs/development/current/main/phases/phase-92/p0-2-skeleton-to-context.md`
|
||||
- P0-2: Skeleton → lowering への配線(Option A)
|
||||
- `LoopPatternContext` に skeleton を optional に通した(後に P1 で境界を整理)
|
||||
- P0-3: ConditionalStep を JoinIR(Select 等)で表現する基盤を追加
|
||||
@ -31,19 +33,13 @@
|
||||
- E2E fixture
|
||||
- `test_pattern5b_escape_minimal.hako` は用意済み(body-local 対応後に実行固定)
|
||||
|
||||
## P2(次): E2E を通す(最小1本)
|
||||
## P2(完了): Pattern2 へ配線 + 条件式の body-local 対応
|
||||
|
||||
### P2-1: Pattern2 で emitter を実際に使用する
|
||||
- Pattern2 lowerer の update emission で `ConditionalStep` を検出したら emitter に委譲する
|
||||
- AST 再検出を増やさない(canonicalizer/recognizer の SSOT を使う)
|
||||
- `ConditionalStep` の lowering を Pattern2 から emitter に委譲(Pattern2 の肥大化を防ぐ)
|
||||
- 条件式の値解決に `LoopBodyLocalEnv` を追加し、`ConditionEnv → LoopBodyLocalEnv` の優先順位で解決
|
||||
- break guard の lowering 順序を修正し、body-local 初期化の後に条件式を lower(`ch == ...` などを解決)
|
||||
|
||||
### P2-2: body-local 変数(`ch`)問題を解く
|
||||
- recognizer は cond/delta 抽出に限定し、スコープ/寿命の扱いは Skeleton 側へ寄せる
|
||||
|
||||
### P2-3: E2E fixture を 1 本だけ通す
|
||||
- `test_pattern5b_escape_minimal.hako`(Phase 91 の最小fixture)
|
||||
|
||||
## P3(完了): BodyLocal 1変数対応(Fail-Fast付き)
|
||||
## P3(完了): BodyLocal 1変数(read-only)を条件式で許可(Fail-Fast)
|
||||
|
||||
- 目的: `ch` のような read-only body-local(毎回再計算)を Pattern2 の break/escape 条件で参照できるようにする
|
||||
- 新規箱: `src/mir/join_ir/lowering/common/body_local_slot.rs`
|
||||
@ -51,7 +47,22 @@
|
||||
- 禁止: 複数、代入あり、定義が break guard より後、top-level 以外(分岐内など)
|
||||
- 破ると `error_tags::freeze(...)` で理由付き停止
|
||||
|
||||
## P4(完了): E2E固定(最小)+ 回帰最小化
|
||||
|
||||
- unit: `src/mir/join_ir/lowering/condition_lowerer.rs` に body-local 解決のユニットテストを追加
|
||||
- integration smoke: `tools/smokes/v2/profiles/integration/apps/phase92_pattern2_baseline.sh`
|
||||
- Case A: `apps/tests/loop_min_while.hako`(既存 Pattern2Break の退行チェック)
|
||||
- Case B: `apps/tests/phase92_conditional_step_minimal.hako`(ConditionalStep の最小確認)
|
||||
- 詳細ログ(歴史):
|
||||
- `docs/development/current/main/phases/phase-92/P4-E2E-PLAN.md`
|
||||
- `docs/development/current/main/phases/phase-92/P4-COMPLETION.md`
|
||||
|
||||
## Follow-up(Phase 93)
|
||||
|
||||
- Trim の `is_ch_match` など「ConditionOnly(PHIで運ばない派生値)」を毎イテレーション再計算する Derived Slot を追加(初回値固定の根治)。
|
||||
- `docs/development/current/main/phases/phase-93/README.md`
|
||||
|
||||
## Acceptance
|
||||
- `NYASH_JOINIR_DEV=1 HAKO_JOINIR_STRICT=1` で parity が green のまま
|
||||
- E2E が 1 本通る(まずは VM でOK)
|
||||
- E2E が 1 本通る(最初は VM でOK)
|
||||
- 既定挙動不変(フラグOFFで無影響)
|
||||
|
||||
@ -1,5 +1,10 @@
|
||||
# Phase 92 P0-2: Skeleton Integration to LoopPatternContext (Option A)
|
||||
|
||||
Status: Historical
|
||||
Scope: Phase 92 P0-2 の試行配線ログ(Option A)。現行の入口は `docs/development/current/main/phases/phase-92/README.md`。
|
||||
Related:
|
||||
- `docs/development/current/main/phases/phase-92/README.md`
|
||||
|
||||
## 概要
|
||||
|
||||
ConditionalStep情報をPattern2 lowererに渡すため、LoopPatternContextにSkeletonフィールドを追加しました。
|
||||
|
||||
38
docs/development/current/main/phases/phase-93/README.md
Normal file
38
docs/development/current/main/phases/phase-93/README.md
Normal file
@ -0,0 +1,38 @@
|
||||
# Phase 93: ConditionOnly Derived Slot(Trim / body-local)
|
||||
|
||||
Status: Active
|
||||
Scope: Pattern2(Loop with Break)で「ConditionOnly(PHIで運ばない派生値)」を毎イテレーション再計算できるようにする。
|
||||
Related:
|
||||
- 設計地図(入口): `docs/development/current/main/design/joinir-design-map.md`
|
||||
- Phase 92(ConditionalStep / body-local 条件式): `docs/development/current/main/phases/phase-92/README.md`
|
||||
- ExitLine/Boundary 契約(背景): `docs/development/current/main/joinir-boundary-builder-pattern.md`
|
||||
|
||||
## 目的
|
||||
|
||||
Trim 系で使う `is_ch_match` のような「body-local から再計算できる bool」を **ConditionOnly** として扱い、
|
||||
JoinIR で “初回の計算値が固定される” 事故を避ける。
|
||||
|
||||
- ConditionOnly は loop carrier(LoopState)ではない(header PHI で運ばない)
|
||||
- 代わりに **毎イテレーション**で Derived slot として再計算する(SSOT: Recipe)
|
||||
|
||||
## 成果(P0)
|
||||
|
||||
コミット: `04fdac42 feat(mir): Phase 93 P0 - ConditionOnly Derived Slot実装`
|
||||
|
||||
- 新規: `src/mir/join_ir/lowering/common/condition_only_emitter.rs`
|
||||
- `ConditionOnlyRecipe`: 再計算レシピ(運搬禁止のSSOT)
|
||||
- `ConditionOnlyEmitter`: `LoopBodyLocalEnv` を使って毎イテレーション再計算
|
||||
- schedule: `src/mir/join_ir/lowering/step_schedule.rs`
|
||||
- ConditionOnly がある場合に `body-init → derived → break` を強制(評価順のSSOT)
|
||||
- Trim: `src/mir/builder/control_flow/joinir/patterns/trim_loop_lowering.rs`
|
||||
- ConditionOnly 用 break 生成(反転の有無を明示)
|
||||
|
||||
## 受け入れ基準(P0)
|
||||
|
||||
- `apps/tests/loop_min_while.hako` が退行しない(Pattern2 baseline)
|
||||
- `/tmp/test_body_local_simple.hako` が “毎イテレーション再計算” で期待通り動く
|
||||
- ConditionOnly を `ConditionBinding`(join input)で運ばない(初回値固定を禁止)
|
||||
|
||||
## 次
|
||||
|
||||
- P5b の完全E2E(escape skip)に進む場合も、ConditionOnly と schedule の契約は再利用できる
|
||||
Reference in New Issue
Block a user