Files
hakorune/tests/normalized_joinir_min.rs

112 lines
4.3 KiB
Rust
Raw Normal View History

#![cfg(all(feature = "normalized_dev", debug_assertions))]
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
2025-12-12 16:40:20 +09:00
use nyash_rust::backend::{mir_interpreter::MirInterpreter, VMValue};
use nyash_rust::mir::join_ir::normalized::dev_env::{
normalized_dev_enabled, test_ctx, NormalizedDevEnvGuard, NormalizedTestContext,
};
use nyash_rust::mir::join_ir::normalized::fixtures::{
build_jsonparser_atoi_real_structured_for_normalized_dev,
build_jsonparser_atoi_structured_for_normalized_dev,
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
2025-12-12 16:40:20 +09:00
build_jsonparser_parse_array_continue_skip_ws_structured_for_normalized_dev,
build_jsonparser_parse_number_real_structured_for_normalized_dev,
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
2025-12-12 16:40:20 +09:00
build_jsonparser_parse_object_continue_skip_ws_structured_for_normalized_dev,
build_jsonparser_skip_ws_real_structured_for_normalized_dev,
build_jsonparser_skip_ws_structured_for_normalized_dev,
build_pattern2_break_fixture_structured, build_pattern2_minimal_structured,
build_pattern3_if_sum_min_structured_for_normalized_dev,
build_pattern3_if_sum_multi_min_structured_for_normalized_dev,
build_pattern3_json_if_sum_min_structured_for_normalized_dev,
feat(joinir): Phase 48-A - P4 (continue) Normalized minimal implementation Pattern4 (continue) integration into Normalized JoinIR pipeline complete. Key changes: - P4 minimal fixture: skip i==2 pattern, single carrier (acc) - ShapeGuard: Pattern4ContinueMinimal detector (structure-based) - StepScheduleBox: ContinueCheck step (eval order: HeaderCond → ContinueCheck → Updates → Tail) - normalize_pattern4_continue_minimal(): Delegates to P2 (95% infrastructure reuse) - Tests: 4 integration tests (normalization/runner/VM Bridge comparison×2) Design validation: - P4 (continue) = reverse control flow of P2 (break) - Same loop_step(env, k_exit) skeleton - Same EnvLayout/ConditionEnv/CarrierInfo infrastructure - Only difference: evaluation order and control flow direction Architecture proof: - Normalized JoinIR successfully handles P1/P2/P3/P4 uniformly - Infrastructure reuse rate: 95%+ as designed Tests: 939/939 PASS (+1 from baseline 938, target exceeded!) Files modified: 10 files (~305 lines added, pure additive) - pattern4_continue_min.program.json (NEW +126 lines) - P4 fixture - fixtures.rs (+31 lines) - P4 fixture loader - shape_guard.rs (+60 lines) - Shape detection - step_schedule.rs (+18 lines) - Schedule + test - normalized.rs (+35 lines) - Normalization function - loop_with_break_minimal.rs (+4 lines) - ContinueCheck handler - bridge.rs (+5 lines) - VM bridge routing - ast_lowerer/mod.rs (+2 lines) - Function registration - normalized_joinir_min.rs (+84 lines) - Integration tests - CURRENT_TASK.md (+13 lines) - Phase 48-A completion Next steps: - Phase 48-B: Extended P4 (multi-carrier, complex continue) - Phase 48-C: Canonical promotion (always use Normalized for P4)
2025-12-12 06:31:13 +09:00
build_pattern4_continue_min_structured_for_normalized_dev,
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
2025-12-12 16:40:20 +09:00
build_selfhost_args_parse_p2_structured_for_normalized_dev,
build_selfhost_if_sum_p3_ext_structured_for_normalized_dev,
build_selfhost_if_sum_p3_structured_for_normalized_dev,
build_selfhost_stmt_count_p3_structured_for_normalized_dev,
build_selfhost_token_scan_p2_accum_structured_for_normalized_dev,
build_selfhost_token_scan_p2_structured_for_normalized_dev,
};
use nyash_rust::mir::join_ir::{
normalize_pattern1_minimal, normalize_pattern2_minimal, normalized_pattern1_to_structured,
normalized_pattern2_to_structured, BinOpKind, ConstValue, JoinContId, JoinFuncId, JoinFunction,
JoinInst, JoinIrPhase, JoinModule, MirLikeInst,
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
2025-12-12 16:40:20 +09:00
};
use nyash_rust::mir::join_ir_ops::JoinValue;
use nyash_rust::mir::join_ir_runner::run_joinir_function;
use nyash_rust::mir::join_ir_vm_bridge::{convert_join_module_to_mir_with_meta, run_joinir_via_vm};
use nyash_rust::mir::ValueId;
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
2025-12-12 16:40:20 +09:00
use std::collections::BTreeMap;
#[path = "normalized_joinir_min/basic.rs"]
mod basic;
#[path = "normalized_joinir_min/ownership.rs"]
mod ownership;
#[path = "normalized_joinir_min/selfhost.rs"]
mod selfhost;
#[path = "normalized_joinir_min/shapes.rs"]
mod shapes;
fn normalized_dev_test_ctx() -> NormalizedTestContext<'static> {
let ctx = test_ctx();
assert!(
normalized_dev_enabled(),
"Phase 40: normalized_dev must be enabled for normalized_* tests (feature + NYASH_JOINIR_NORMALIZED_DEV_RUN=1)"
);
ctx
}
fn assert_normalized_dev_ready() {
assert!(
normalized_dev_enabled(),
"Phase 40: normalized_dev must be enabled for normalized_* tests (feature + NYASH_JOINIR_NORMALIZED_DEV_RUN=1)"
);
}
fn run_joinir_runner(
module: &JoinModule,
entry: JoinFuncId,
args: &[JoinValue],
normalized: bool,
) -> JoinValue {
let _guard = NormalizedDevEnvGuard::new(normalized);
if normalized {
assert_normalized_dev_ready();
}
let mut vm = MirInterpreter::new();
run_joinir_function(&mut vm, module, entry, args).expect("JoinIR runner should succeed")
}
fn run_joinir_vm_bridge(
module: &JoinModule,
entry: JoinFuncId,
args: &[JoinValue],
normalized: bool,
) -> JoinValue {
let _guard = NormalizedDevEnvGuard::new(normalized);
if normalized {
assert_normalized_dev_ready();
}
run_joinir_via_vm(module, entry, args).expect("JoinIR→MIR execution should succeed")
}
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
2025-12-12 16:40:20 +09:00
fn run_joinir_vm_bridge_structured_only(
module: &JoinModule,
entry: JoinFuncId,
args: &[JoinValue],
) -> JoinValue {
let mir =
convert_join_module_to_mir_with_meta(module, &BTreeMap::new()).expect("structured bridge");
let mut vm = MirInterpreter::new();
let entry_name = format!("join_func_{}", entry.0);
let vm_args: Vec<VMValue> = args.iter().cloned().map(|v| v.into_vm_value()).collect();
let result = vm
.execute_function_with_args(&mir, &entry_name, &vm_args)
.expect("VM execution should succeed");
JoinValue::from_vm_value(&result).expect("result conversion")
}
// moved into tests/normalized_joinir_min/basic.rs
feat(joinir): Phase 54 SELFHOST-SHAPE-GROWTH - 構造軸育成 + 偽陽性観測 Phase 53 成果を踏まえ、構造シグネチャ軸を 5+ に育て、 偽陽性観測テストで name ガード縮小準備を整えた。 方針変更: 新ループ追加 → 構造軸育成 + 偽陽性率測定に焦点変更 - 理由: Phase 53 で selfhost P2/P3 実戦パターン追加済み - 焦点: 既存ループに対する構造軸拡張 + 精度測定 主な成果: 1. 構造軸 5+ 達成: - carrier 数 - carrier 型 - Compare パターン - branch 構造 - NEW: Compare op 分布 (count_compare_ops ヘルパー) 2. 偽陽性観測テスト追加: - test_phase54_structural_axis_discrimination_p2() - test_phase54_structural_axis_discrimination_p3() 3. 重要な発見 - 偽陽性率 ~50%: - P2: selfhost P2 が正しく検出されず (name ガード依存) - P3: selfhost P3 が Pattern4ContinueMinimal と誤検出 (構造的類似性) - 結論: 構造判定のみでは分離不十分、name ガード必須と判明 変更内容: - shape_guard.rs (+80 lines): - count_compare_ops() 構造軸ヘルパー追加 - detect_shapes() pub 化 (テストから呼び出し可能に) - SelfhostVerifySchemaP2/SelfhostDetectFormatP3 enum 追加 (将来用) - normalized_joinir_min.rs (+110 lines): - 偽陽性観測テスト 2 個追加 (P2/P3 各1) - canonical shapes vs selfhost shapes 構造判定精度測定 - phase49 doc (+200 lines): - Phase 54 節完成版 - 偽陽性分析結果記録 - name ガード縮小方針明記 - enum 拡張対応: - bridge.rs (+8 lines) - normalized.rs (+8 lines) - ast_lowerer/mod.rs (+2 lines) 偽陽性観測結果 (2025-12-12): - P2 構造判定: selfhost P2 検出失敗 → name ガード必須 - P3 構造判定: selfhost P3 が Pattern4 と誤判定 → 構造的類似性問題 - 総合: 偽陽性率 ~50% → 構造軸 5 本では不十分 次フェーズ方針 (Phase 55+): - Phase 55-A: 条件複雑度軸追加 (BinOp/UnaryOp ネスト深度) - Phase 55-B: 算術パターン軸追加 (Mul/Sub/Div 出現パターン) - Phase 56: selfhost 実戦ループ追加 (6 本以上蓄積) - Phase 57: 誤判定率 < 5% 達成後に name ガード縮小開始 name ガード撤去条件 (Phase 57): - 構造軸 8+ 本確立 - selfhost P2/P3 各 6 本以上蓄積 - 誤判定率 < 5% 達成 - 複合的特徴量ベース判定実装 回帰テスト: ✅ 939 PASS, 0 FAIL (既存挙動不変) Files Modified: 8 files Lines Added: ~408 lines (net) Implementation: Pure additive (feature-gated) Phase 54 完了!構造軸育成・偽陽性観測基盤確立!
2025-12-12 17:12:58 +09:00
// moved into tests/normalized_joinir_min/{selfhost.rs,shapes.rs}
feat(joinir): Phase 54 SELFHOST-SHAPE-GROWTH - 構造軸育成 + 偽陽性観測 Phase 53 成果を踏まえ、構造シグネチャ軸を 5+ に育て、 偽陽性観測テストで name ガード縮小準備を整えた。 方針変更: 新ループ追加 → 構造軸育成 + 偽陽性率測定に焦点変更 - 理由: Phase 53 で selfhost P2/P3 実戦パターン追加済み - 焦点: 既存ループに対する構造軸拡張 + 精度測定 主な成果: 1. 構造軸 5+ 達成: - carrier 数 - carrier 型 - Compare パターン - branch 構造 - NEW: Compare op 分布 (count_compare_ops ヘルパー) 2. 偽陽性観測テスト追加: - test_phase54_structural_axis_discrimination_p2() - test_phase54_structural_axis_discrimination_p3() 3. 重要な発見 - 偽陽性率 ~50%: - P2: selfhost P2 が正しく検出されず (name ガード依存) - P3: selfhost P3 が Pattern4ContinueMinimal と誤検出 (構造的類似性) - 結論: 構造判定のみでは分離不十分、name ガード必須と判明 変更内容: - shape_guard.rs (+80 lines): - count_compare_ops() 構造軸ヘルパー追加 - detect_shapes() pub 化 (テストから呼び出し可能に) - SelfhostVerifySchemaP2/SelfhostDetectFormatP3 enum 追加 (将来用) - normalized_joinir_min.rs (+110 lines): - 偽陽性観測テスト 2 個追加 (P2/P3 各1) - canonical shapes vs selfhost shapes 構造判定精度測定 - phase49 doc (+200 lines): - Phase 54 節完成版 - 偽陽性分析結果記録 - name ガード縮小方針明記 - enum 拡張対応: - bridge.rs (+8 lines) - normalized.rs (+8 lines) - ast_lowerer/mod.rs (+2 lines) 偽陽性観測結果 (2025-12-12): - P2 構造判定: selfhost P2 検出失敗 → name ガード必須 - P3 構造判定: selfhost P3 が Pattern4 と誤判定 → 構造的類似性問題 - 総合: 偽陽性率 ~50% → 構造軸 5 本では不十分 次フェーズ方針 (Phase 55+): - Phase 55-A: 条件複雑度軸追加 (BinOp/UnaryOp ネスト深度) - Phase 55-B: 算術パターン軸追加 (Mul/Sub/Div 出現パターン) - Phase 56: selfhost 実戦ループ追加 (6 本以上蓄積) - Phase 57: 誤判定率 < 5% 達成後に name ガード縮小開始 name ガード撤去条件 (Phase 57): - 構造軸 8+ 本確立 - selfhost P2/P3 各 6 本以上蓄積 - 誤判定率 < 5% 達成 - 複合的特徴量ベース判定実装 回帰テスト: ✅ 939 PASS, 0 FAIL (既存挙動不変) Files Modified: 8 files Lines Added: ~408 lines (net) Implementation: Pure additive (feature-gated) Phase 54 完了!構造軸育成・偽陽性観測基盤確立!
2025-12-12 17:12:58 +09:00
// moved into tests/normalized_joinir_min/shapes.rs
feat(joinir): Phase 54 SELFHOST-SHAPE-GROWTH - 構造軸育成 + 偽陽性観測 Phase 53 成果を踏まえ、構造シグネチャ軸を 5+ に育て、 偽陽性観測テストで name ガード縮小準備を整えた。 方針変更: 新ループ追加 → 構造軸育成 + 偽陽性率測定に焦点変更 - 理由: Phase 53 で selfhost P2/P3 実戦パターン追加済み - 焦点: 既存ループに対する構造軸拡張 + 精度測定 主な成果: 1. 構造軸 5+ 達成: - carrier 数 - carrier 型 - Compare パターン - branch 構造 - NEW: Compare op 分布 (count_compare_ops ヘルパー) 2. 偽陽性観測テスト追加: - test_phase54_structural_axis_discrimination_p2() - test_phase54_structural_axis_discrimination_p3() 3. 重要な発見 - 偽陽性率 ~50%: - P2: selfhost P2 が正しく検出されず (name ガード依存) - P3: selfhost P3 が Pattern4ContinueMinimal と誤検出 (構造的類似性) - 結論: 構造判定のみでは分離不十分、name ガード必須と判明 変更内容: - shape_guard.rs (+80 lines): - count_compare_ops() 構造軸ヘルパー追加 - detect_shapes() pub 化 (テストから呼び出し可能に) - SelfhostVerifySchemaP2/SelfhostDetectFormatP3 enum 追加 (将来用) - normalized_joinir_min.rs (+110 lines): - 偽陽性観測テスト 2 個追加 (P2/P3 各1) - canonical shapes vs selfhost shapes 構造判定精度測定 - phase49 doc (+200 lines): - Phase 54 節完成版 - 偽陽性分析結果記録 - name ガード縮小方針明記 - enum 拡張対応: - bridge.rs (+8 lines) - normalized.rs (+8 lines) - ast_lowerer/mod.rs (+2 lines) 偽陽性観測結果 (2025-12-12): - P2 構造判定: selfhost P2 検出失敗 → name ガード必須 - P3 構造判定: selfhost P3 が Pattern4 と誤判定 → 構造的類似性問題 - 総合: 偽陽性率 ~50% → 構造軸 5 本では不十分 次フェーズ方針 (Phase 55+): - Phase 55-A: 条件複雑度軸追加 (BinOp/UnaryOp ネスト深度) - Phase 55-B: 算術パターン軸追加 (Mul/Sub/Div 出現パターン) - Phase 56: selfhost 実戦ループ追加 (6 本以上蓄積) - Phase 57: 誤判定率 < 5% 達成後に name ガード縮小開始 name ガード撤去条件 (Phase 57): - 構造軸 8+ 本確立 - selfhost P2/P3 各 6 本以上蓄積 - 誤判定率 < 5% 達成 - 複合的特徴量ベース判定実装 回帰テスト: ✅ 939 PASS, 0 FAIL (既存挙動不変) Files Modified: 8 files Lines Added: ~408 lines (net) Implementation: Pure additive (feature-gated) Phase 54 完了!構造軸育成・偽陽性観測基盤確立!
2025-12-12 17:12:58 +09:00
// moved into tests/normalized_joinir_min/ownership.rs