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:
nyash-codex
2025-12-16 23:30:39 +09:00
parent 04fdac42f2
commit 93e62b1433
13 changed files with 152 additions and 735 deletions

View File

@ -106,6 +106,7 @@ flowchart LR
- TraceJoinIR ルートの統一トレース): [`src/mir/builder/control_flow/joinir/trace.rs`](../../../../../src/mir/builder/control_flow/joinir/trace.rs)
- Error tagsSSOT: [`src/mir/join_ir/lowering/error_tags.rs`](../../../../../src/mir/join_ir/lowering/error_tags.rs)
- Loop Canonicalizer前処理 SSOT: [`src/mir/loop_canonicalizer/mod.rs`](../../../../../src/mir/loop_canonicalizer/mod.rs)
- ConditionOnly Derived SlotPhase 93: [`src/mir/join_ir/lowering/common/condition_only_emitter.rs`](../../../../../src/mir/join_ir/lowering/common/condition_only_emitter.rs)
---

View File

@ -441,115 +441,19 @@ loop(p < len) {
## 対象ループ 2: Pattern P5b - Escape Sequence HandlingPhase 91 新規)
### 目的
### 目的(要約)
エスケープシーケンス対応ループを JoinIR 対象に拡大する。JSON/CSV パーサーの文字列処理で共通パターン
エスケープ処理を含む文字列走査ループ(例: JSON/CSV の `\\`)を、**パターン増殖なし**で段階的に JoinIR に取り込む
### 対象ファイル
この系は「常に `+1` の通常進行」と「条件が真のときだけ追加で `+1`(合計 `+2` 相当」が混ざるため、Canonicalizer 側では
`UpdateKind::ConditionalStep { cond, then_delta, else_delta }` として表現し、下流の lowerer 選択は **`Pattern2Break`exit contract 優先)**に寄せる。
`tools/selfhost/test_pattern5b_escape_minimal.hako`
### SSOT詳細はここへ集約
```hako
loop(i < n) {
local ch = s.substring(i, i+1)
if ch == "\"" { break } // String boundary
if ch == "\\" {
i = i + 1 // Skip escape character (conditional +2 total)
ch = s.substring(i, i+1) // Read escaped character
}
out = out + ch // Process character
i = i + 1 // Standard increment
}
```
### Pattern P5b の特徴
| 特性 | 説明 |
|-----|------|
| **Header** | `loop(i < n)` - Bounded loop on string length |
| **Escape Check** | `if ch == escape_char { i = i + escape_delta }` |
| **Normal Increment** | `i = i + 1` (always +1) |
| **Accumulator** | `out = out + char` - String append pattern |
| **Boundary** | `if ch == boundary { break }` - String terminator |
| **Carriers** | Position (`i`), Accumulator (`out`) |
| **Deltas** | normal_delta=1, escape_delta=2 (or variable) |
### 必要 Capability (P5b 拡張)
-`ConstStepIncrement` (normal: i = i + 1)
-`SingleBreakPoint` (boundary check only)
-`NoSideEffectInHeader` (i < n pure)
- `OuterLocalCondition` (i, n は外側定義)
- **`ConstEscapeDelta`** (escape: i = i + 2, etc.) - **P5b 専用**
- **`SingleEscapeCheck`** (one escape pattern only) - **P5b 専用**
- **`ClearBoundaryCondition`** (explicit boundary detection) - **P5b 専用**
### Fail-Fast 基準 (P5b 非対応のケース)
以下のいずれかに該当する場合Fail-Fast:
1. **複数エスケープチェック**: `if ch == "\\" ... if ch2 == "'" ...`
- 理由: `CAP_MISSING_SINGLE_ESCAPE_CHECK`
2. **可変ステップ**: `i = i + var` (定数でない)
- 理由: `CAP_MISSING_CONST_ESCAPE_DELTA`
3. **無条件に近いループ**: `loop(true)` without clear boundary
- 理由: `CAP_MISSING_CLEAR_BOUNDARY_CONDITION`
4. **複数 break 点**: String boundary + escape processing exit
- 理由: `CAP_MISSING_SINGLE_BREAK`
### 認識アルゴリズム (高レベル)
```
1. Header carrier 抽出: loop(i < n) から i を取得
2. Escape check block 発見: if ch == "\" { ... }
3. Escape delta 抽出: i = i + const
4. Accumulator パターン発見: out = out + ch
5. Normal increment 抽出: i = i + 1 (escape if block 外)
6. Boundary check 発見: if ch == "\"" { break }
7. LoopSkeleton 構築
- carriers: [i (dual deltas), out (append)]
- exits: has_break=true
8. RoutingDecision: Pattern5bEscape
```
### 実装予定 (Phase 91)
**Step 1** (このドキュメント):
- [ ] Pattern P5b 設計書完成
- [ ] テストフィクスチャ作成
- [ ] Capability 定義追加
**Step 2** (Phase 91 本実装):
- [ ] `detect_escape_pattern()` in Canonicalizer
- [ ] Unit tests (P5b recognition)
- [ ] Parity verification (strict mode)
- [ ] Documentation update
**Step 3** (Phase 92 lowering):
- [ ] Pattern5bEscape lowerer 実装
- [ ] E2E test with escape fixture
- [ ] VM/LLVM parity verification
### 受け入れ基準 (Phase 91)
1. Canonicalizer escape pattern を認識
2. RoutingDecision.chosen == Pattern5bEscape
3. missing_caps == [] (すべての capability 満たす)
4. Strict parity green (`HAKO_JOINIR_STRICT=1`)
5. 既存テスト退行なし
6. Lowering Step 3 (Phase 91 では recognition のみ)
### References
- **P5b 詳細設計**: `docs/development/current/main/design/pattern-p5b-escape-design.md`
- **テストフィクスチャ**: `tools/selfhost/test_pattern5b_escape_minimal.hako`
- **Phase 91 計画**: `docs/development/current/main/phases/phase-91/README.md`
- **設計 SSOT**: `docs/development/current/main/design/pattern-p5b-escape-design.md`
- **Phaseログ認識**: `docs/development/current/main/phases/phase-91/README.md`
- **Phaseログlowering/条件式対応)**: `docs/development/current/main/phases/phase-92/README.md`
- **fixture**: `tools/selfhost/test_pattern5b_escape_minimal.hako`
---

View File

@ -218,8 +218,8 @@ If any of these are detected, Pattern P5b is rejected:
4. **Find process block**: `out = out + ch`
5. **Find normal increment**: `i = i + 1` after if
6. **Find break condition**: `if ch == "\"" { break }`
7. **Build ExitContract** with both deltas
8. **Build RoutingDecision**: Pattern5bEscape if all present
7. **Build LoopSkeleton**: `UpdateKind::ConditionalStep { cond, then_delta, else_delta }` を構築
8. **Build RoutingDecision**: `chosen = Pattern2Break`exit contract 優先。P5b 固有の構造情報は `notes` に載せる
### Pseudo-Code
@ -305,8 +305,12 @@ LoopSkeleton {
carriers: vec![
CarrierSlot {
name: "i",
deltas: [1, 2], // [normal, escape]
// ... other fields
update_kind: UpdateKind::ConditionalStep {
cond: (ch == "\\"),
then_delta: 2,
else_delta: 1,
},
// ... other fieldsrole など)
},
CarrierSlot {
name: "out",
@ -328,7 +332,7 @@ LoopSkeleton {
```rust
RoutingDecision {
chosen: Pattern5bEscape,
chosen: Pattern2Break,
missing_caps: vec![],
notes: vec![
"escape_char: \\",