feat(joinir): Phase 53 - SELFHOST-NORM-DEV-EXPAND implementation
Expanded selfhost dev Normalized target with 2 practical P2/P3 loop variations, strengthened structural signature axis, and implemented two-stage detection. Key Changes: 1. Documentation (phase49-selfhost-joinir-depth2-design.md +128 lines): - Added Phase 53 section with candidate selection rationale - Documented two-stage detector strategy (structural primary + dev-only name guard) - Defined structural axis strengthening (carrier count/type, branch patterns) 2. Fixtures (+210 lines): - selfhost_args_parse_p2.program.json (60 lines): P2 with String carrier + conditional branching - selfhost_stmt_count_p3.program.json (150 lines): P3 with 5 carriers + multi-branch if-else 3. Structured Builders (fixtures.rs +48 lines): - build_selfhost_args_parse_p2_structured_for_normalized_dev() - build_selfhost_stmt_count_p3_structured_for_normalized_dev() 4. ShapeGuard Two-Stage Detection (shape_guard.rs +80 lines): - Added SelfhostArgsParseP2/SelfhostStmtCountP3 to NormalizedDevShape enum - Implemented is_selfhost_args_parse_p2(): P2 core family + name guard - Implemented is_selfhost_stmt_count_p3(): 2-10 carrier check + name guard - Updated capability_for_shape() mappings 5. Bridge Integration (bridge.rs +8 lines, normalized.rs +10 lines): - Added shape handlers delegating to existing normalizers - Added roundtrip reconstruction handlers 6. Entry Point Registration (ast_lowerer/mod.rs +2 lines): - Registered selfhost_args_parse_p2/selfhost_stmt_count_p3 as LoopFrontend routes 7. Dev VM Comparison Tests (normalized_joinir_min.rs +40 lines): - normalized_selfhost_args_parse_p2_vm_bridge_direct_matches_structured() - normalized_selfhost_stmt_count_p3_vm_bridge_direct_matches_structured() 8. Test Context Fix (dev_env.rs): - Added thread-local test context depth counter - Fixed deadlock in nested test_ctx() calls via reentrant with_dev_env_if_unset() Structural Axis Growth: P2 family: - Carrier count: 1-3 (unchanged) - NEW: Type diversity (Integer/String mixed) - NEW: Conditional branching patterns (Eq-heavy comparisons) P3 family: - NEW: Carrier count upper bound: 2-10 (was 2-4) - NEW: Multi-branch if-else (5+ branches with nested structure) - NEW: Complex conditional patterns Test Results: - normalized_dev: 40/40 PASS (including 2 new tests) - lib regression: 939 PASS, 56 ignored - Existing behavior unchanged (normalized_dev feature-gated) Phase 53 Achievements: ✅ P2/P3 each gained 1 practical variation (2 total) ✅ Two-stage detection: structural primary + dev-only name guard ✅ Structural axis expanded: 4 axes (carrier count/type/Compare/branch patterns) ✅ All tests PASS, no regressions ✅ Test context deadlock fixed (0.04s for 29 tests) Files Modified: 14 files Lines Added: ~516 lines (net) Implementation: Pure additive (feature-gated) Next Phase (54+): - Accumulate 6+ loops per P2/P3 family - Achieve 5+ stable structural axes - Target < 5% false positive rate - Then shrink/remove name guard scope
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
# Phase 48: Normalized P4 (Continue) Design
|
||||
|
||||
**Status**: Design Phase (doc-only)
|
||||
**Date**: 2025-12-12
|
||||
**Status**: Phase 48-A/B/C COMPLETE (minimal + JsonParser skip_ws continue、Normalized→MIR 直経路+canonical 昇格まで完了)
|
||||
**Date**: 2025-12-12 / 2026-01-XX
|
||||
|
||||
## Goal
|
||||
|
||||
@ -213,6 +213,22 @@ struct Pattern4Env {
|
||||
|
||||
**Goal**: Prove P4 can use Normalized infrastructure with minimal additions.
|
||||
|
||||
**実装ステータス(48-A 完了サマリ)**:
|
||||
|
||||
- ✅ Fixture 追加: `pattern4_continue_min.program.json`
|
||||
- 「`i == 2` を `continue` でスキップする最小 P4 ループ」を Program(JSON) として用意。
|
||||
- ✅ ShapeGuard 拡張:
|
||||
- `NormalizedDevShape::Pattern4ContinueMinimal` を追加し、構造ベースで P4 minimal 形状を検出。
|
||||
- ✅ StepScheduleBox 拡張:
|
||||
- `StepKind::ContinueCheck` を追加し、評価順序を
|
||||
`HeaderCond → ContinueCheck → Updates → Tail` に固定。
|
||||
- ✅ Normalized lowering:
|
||||
- `normalize_pattern4_continue_minimal()` を実装し、P2 正規化ロジックを 95% 再利用した continue 対応を追加。
|
||||
- ✅ テスト:
|
||||
- Normalized dev スイートに P4 minimal 用の比較テストを 4 本追加
|
||||
(Structured→Normalized→MIR(direct) vs Structured→MIR / runner / VM bridge)。
|
||||
- `cargo test --release` ベースで **939/939 tests PASS**(Phase 48-A 実装時点)。
|
||||
|
||||
**Steps**:
|
||||
1. **ShapeGuard**: Add `Pattern4ContinueMinimal` shape
|
||||
2. **StepScheduleBox**: Add `ContinueCheck` step kind
|
||||
@ -232,7 +248,11 @@ struct Pattern4Env {
|
||||
|
||||
### Phase 48-B: _parse_object, _unescape_string (dev-only)
|
||||
|
||||
**Goal**: Extend to multiple carriers, string operations.
|
||||
**Status (dev-only)**: `_parse_array` / `_parse_object` の whitespace continue ループを Normalized→MIR(direct) で比較済み。
|
||||
Fixture を `jsonparser_parse_{array,object}_continue_skip_ws.program.json` として追加し、shape_guard / normalize_for_shape / direct bridge で dev 専用ルートを通す。
|
||||
_unescape_string は未着手(Phase 48-C 以降)。
|
||||
|
||||
**Goal**: Extend to multiple carriers, string operations (unescape) after skip_ws 系が固まったら続行。
|
||||
|
||||
**Additions**:
|
||||
- Multi-carrier EnvLayout (if needed)
|
||||
@ -319,11 +339,13 @@ count = 4 (skipped i==2, so counted 0,1,3,4)
|
||||
## Success Criteria
|
||||
|
||||
**Phase 48-A complete when**:
|
||||
1. ✅ `test_normalized_pattern4_continue_minimal` passes (dev-only)
|
||||
2. ✅ Structured→Normalized→MIR(direct) output matches Structured→MIR
|
||||
3. ✅ All 938+ tests still pass (no regressions)
|
||||
4. ✅ ShapeGuard can detect Pattern4ContinueMinimal
|
||||
5. ✅ Documentation updated (architecture overview, CURRENT_TASK)
|
||||
1. `test_normalized_pattern4_continue_minimal` passes (dev-only)
|
||||
2. Structured→Normalized→MIR(direct) output matches Structured→MIR
|
||||
3. All 938+ tests still pass (no regressions)
|
||||
4. ShapeGuard can detect Pattern4ContinueMinimal
|
||||
5. Documentation updated (architecture overview, CURRENT_TASK)
|
||||
|
||||
→ 上記 1–5 はコミット `7200309c` 時点ですべて満たされており、Phase 48-A は完了ステータスだよ。
|
||||
|
||||
**Phase 48-B complete when**:
|
||||
1. ✅ _parse_object, _unescape_string tests pass (dev-only)
|
||||
|
||||
Reference in New Issue
Block a user