4ecb6435d3
docs(joinir): Phase 48 - Normalized P4 (Continue) design
...
Complete design documentation for Pattern4 (continue) Normalized support,
extending unified Normalized infrastructure to all 4 loop patterns.
Design documents:
- phase48-norm-p4-design.md: Complete P4 Normalized design (380 lines)
- Key insight: continue = immediate TailCallFn(loop_step, ...) (no new instruction!)
- Infrastructure reuse: 95%+ from P2/P3 (only ContinueCheck step kind new)
- Target loops prioritized:
- ◎ _parse_array (skip whitespace) - PRIMARY (Phase 48-A)
- ○ _parse_object (skip whitespace) - Extended
- △ _unescape_string, _parse_string - Later
- Control flow: ContinueCheck before Updates (skip processing early)
- Same EnvLayout/ConditionEnv/CarrierInfo/ExitLine as P2/P3
- Implementation strategy: dev-only → canonical (proven approach)
Architecture:
- Unified Normalized for P1/P2/P3/P4 (all patterns same pipeline)
- P4 uses loop_step(env, k_exit) skeleton (same as P2/P3)
- continue semantics: TailCallFn = skip to next iteration (CPS natural fit)
Benefits:
- 95% infrastructure reuse from P2/P3
- No new JpInst needed (continue = existing TailCallFn)
- Incremental rollout (dev → canonical)
- Clear semantic: continue = immediate recursion
Implementation roadmap:
- Phase 48-A: Minimal continue (dev-only)
- Phase 48-B: Extended patterns (multi-carrier)
- Phase 48-C: Canonical promotion
Updates:
- joinir-architecture-overview.md: Added Phase 48 section
- CURRENT_TASK.md: Phase 48 entry (Design Complete)
- phase47-norm-p3-design.md: Minor formatting
Status: Design phase complete (doc-only, no implementation yet)
Next: Phase 48-A implementation (when requested)
2025-12-12 06:06:39 +09:00
99bdf93dfe
feat(joinir): Phase 47-A-LOWERING - P3 Normalized→MIR(direct)
...
Implement full Pattern3 (if-sum) Normalized→MIR(direct) support, completing
the P3 minimal implementation.
Key changes:
1. P3 Shape Detection (shape_guard.rs):
- Implemented is_pattern3_if_sum_minimal() with structure-based detection
- Detects P3 characteristics:
- Has Compare instruction (loop condition)
- Has Select instruction (conditional carrier update)
- Has tail call (Call with k_next: None)
- Reasonable param count (2-4 for i, sum carriers)
- Handles both JoinInst::Select and Compute(MirLikeInst::Select)
- Added unit test: test_detect_pattern3_if_sum_minimal_shape ✅
2. P3 Normalization Function (normalized.rs):
- Implemented normalize_pattern3_if_sum_minimal()
- Guards: Validates Structured JoinIR + P3 shape detection
- Phase 47-A minimal: Delegates to P2 normalization (works for simple cases)
- Updated normalized_dev_roundtrip_structured() integration
- Returns Result<NormalizedModule, String> for proper error handling
3. Bridge Integration (bridge.rs):
- Updated normalize_for_shape() to call P3 normalization
- No changes needed to direct.rs (already handles P3 instructions)
4. Integration Tests (normalized_joinir_min.rs):
- Added test_phase47a_pattern3_if_sum_minimal_normalization
- Tests Structured→Normalized transformation
- Verifies shape detection + normalization succeeds
- Validates function count and phase correctness
- Added test_phase47a_pattern3_if_sum_minimal_runner
- Basic smoke test for P3 fixture validity
- Verifies 3-function structure and entry point
Benefits:
- P3 now uses Normalized→MIR(direct) pipeline (same as P1/P2)
- Structure-based detection (no name-based heuristics)
- Minimal implementation (delegates to P2 for simplicity)
- Pure additive (no P1/P2 behavioral changes)
Tests: 938/938 PASS (lib), shape_guard P3 test PASS
- test_detect_pattern3_if_sum_minimal_shape ✅
- test_phase47a_pattern3_if_sum_minimal_normalization ✅
- test_phase47a_pattern3_if_sum_minimal_runner ✅
Next phase: Phase 47-B (proper P3-specific normalization, array_filter, multi-carrier)
Design note: This minimal implementation reuses P2 normalization for simplicity.
Proper P3-specific normalization (IfCond, ThenUpdates, ElseUpdates step sequence)
will be implemented in Phase 47-B when needed for more complex P3 patterns.
2025-12-12 05:53:23 +09:00
c3a26e705e
feat(joinir): Phase 47-A-IMPL - P3 Normalized infrastructure
...
Implement Pattern3 (if-sum) Normalized infrastructure, extending existing P2
StepSchedule and ShapeGuard systems.
Key changes:
1. StepSchedule generalization (P2 → P2/P3):
- Renamed: pattern2_step_schedule.rs → step_schedule.rs
- Extended StepKind enum with P3 variants:
- IfCond (if condition in body)
- ThenUpdates (carrier updates in then branch)
- ElseUpdates (carrier updates in else branch)
- Added pattern3_if_sum_schedule() function
- Added unit test: test_pattern3_if_sum_schedule()
- Updated module references (mod.rs, loop_with_break_minimal.rs)
2. ShapeGuard extension:
- Added Pattern3IfSumMinimal variant to NormalizedDevShape
- Added is_pattern3_if_sum_minimal() detector (placeholder)
- Updated shape detector table
- Extended capability_for_shape() mapping
3. Bridge integration:
- bridge.rs: Added P3 shape handling in normalize_for_shape()
- normalized.rs: Added P3 roundtrip match (uses P2 temporarily)
4. P2/P3 separation:
- loop_with_break_minimal.rs: Added panic for P3 steps in P2 lowering
- Clear boundary enforcement (P2 lowerer rejects P3 steps)
5. Documentation:
- CURRENT_TASK.md: Phase 47-A-IMPL status
- phase47-norm-p3-design.md: Implementation status section
Benefits:
- Reuses 90% of P2 infrastructure (ConditionEnv, CarrierInfo, ExitLine)
- Clean P2/P3 separation via StepKind
- Pure additive changes (no P2 behavioral changes)
- Ready for Phase 47-A-LOWERING (full P3 Normalized implementation)
Tests: 938/938 PASS (+1 from step_schedule unit test)
- All existing P1/P2 tests pass (no regressions)
- P3 test uses Structured path temporarily (proper lowering in next phase)
Next phase: Implement full P3 Normalized→MIR(direct) lowering
2025-12-12 05:23:18 +09:00
42ecd7a7e7
feat(joinir): Phase 47-A prep - P3 fixture and test stub
...
Preparation for Phase 47-A (P3 Normalized minimal implementation).
Added fixture and test stub for pattern3_if_sum_minimal.
Changes:
- fixtures.rs: Added pattern3_if_sum_minimal fixture
- Source: phase212_if_sum_min.hako
- Pattern: Single carrier (sum), simple condition (i > 0)
- Dev-only fixture for P3 Normalized development
- normalized_joinir_min.rs: Added test stub
- test_normalized_pattern3_if_sum_minimal_runner
- Currently returns early (implementation pending)
- Feature-gated: #[cfg(feature = "normalized_dev")]
- Documentation updates:
- CURRENT_TASK.md: Phase 47-A status
- PHASE_43_245B_NORMALIZED_COMPLETION.md: P3 forward reference
- joinir-architecture-overview.md: Minor formatting
- phase47-norm-p3-design.md: Implementation notes
Next steps (Phase 47-A implementation):
1. Rename pattern2_step_schedule.rs → step_schedule.rs
2. Add P3 StepKind (IfCond, ThenUpdates, ElseUpdates)
3. Implement Normalized→MIR(direct) for P3
4. Complete test implementation
Tests: 937/937 PASS (no behavioral changes yet)
2025-12-12 05:07:01 +09:00
23ebb86e6e
docs(joinir): Phase 47 - Normalized P3 (If-Sum) design
...
Complete design for extending Normalized JoinIR to Pattern3 (if-sum) loops,
reusing 90% of existing P2 infrastructure.
Key insight: P3 already uses P2's Structured JoinIR foundation (Phase 220
ConditionEnv integration), so Normalized extension is straightforward.
Design documents:
- phase47-norm-p3-design.md: Complete P3 Normalized design
- Infrastructure reuse analysis (ConditionEnv, CarrierInfo, ExitLine)
- Representative loops identified (phase212_if_sum_min primary target)
- StepScheduleBox extension (IfCond, ThenUpdates, ElseUpdates)
- JpInst reuse (If instruction already exists)
- Implementation strategy (dev-only → canonical)
- File impact estimate (~365 lines, pure additive)
- phase47-test-files-inventory.md: P3 test file catalog
- 3 P3 test files analyzed
- phase212_if_sum_min.hako: Single carrier (PRIMARY)
- phase217_if_sum_multi_min.hako: Multi-carrier (sum + count)
- phase218_json_if_sum_min.hako: Variable accumulation (sum + i)
Architecture:
- Unified Normalized for P1/P2/P3 (same pipeline)
- Conditional updates only difference vs P2
- No P2 code changes needed (pure additive)
Benefits:
- 90% infrastructure reuse from P2
- Proven incremental rollout (dev → canonical)
- Clear path to P4 (continue pattern)
Implementation roadmap:
- Phase 47-A: Minimal sum_count (dev-only)
- Phase 47-B: array_filter (body-local + method calls)
- Phase 47-C: Canonical promotion
Updates:
- joinir-architecture-overview.md: Added Phase 47 section
- CURRENT_TASK.md: Updated Phase 47 entry (Design Complete)
Status: Design phase complete, ready for implementation
2025-12-12 04:50:26 +09:00
d4b9ae3ba5
feat(joinir): Phase 46 - P2-Mid canonical Normalized promotion
...
Promote P2-Mid patterns (_atoi real, _parse_number real) to canonical
Normalized→MIR(direct) route, completing P2 line transition.
Canonical set expansion (Phase 41 → Phase 46):
- P2-Core: Pattern2Mini, skip_ws mini/real, atoi mini
- P2-Mid: atoi real, parse_number real (NEW)
All JsonParser P2 loops (_skip_whitespace, _atoi, _parse_number) now
canonical Normalized - Structured→MIR is legacy/comparison-only.
Key changes:
- shape_guard.rs: Expanded is_canonical_shape() (+2 patterns)
- JsonparserAtoiReal
- JsonparserParseNumberReal
- Made NormalizedDevShape enum public
- bridge.rs: Updated canonical routing comments (Phase 41 → 46)
- normalized.rs: Made shape_guard module public
- normalized_joinir_min.rs: Added Phase 46 canonical verification test
- phase46-norm-canon-p2-mid.md: Complete design documentation
Out of scope (deferred):
- P3/P4 Normalized support → NORM-P3/NORM-P4 phases
- Selfhost complex loops → separate phases
Benefits:
- Clear P2 boundary: All JsonParser P2 = Normalized canonical
- Infrastructure validation: Phase 43/245B proven production-ready
- Simplified mental model: P2 = Normalized-first, P3/P4 = future
Tests: 937/937 PASS (lib), 20/20 PASS (normalized_dev feature)
Phase 46 test: test_phase46_canonical_set_includes_p2_mid ✅
2025-12-12 04:40:46 +09:00
297258f963
docs(joinir): Phase 43/245B Normalized JoinIR completion summary
...
Complete documentation consolidation for Phases 26-45 Normalized JoinIR
infrastructure. All components are implemented and tested (937/937 PASS).
Key additions:
- PHASE_43_245B_NORMALIZED_COMPLETION.md: Master completion summary
- Architecture components (Mode, Capability, Carriers, DigitPos, etc.)
- Supported loop patterns (P1, P2 variants including JsonParser)
- Complete file reference guide
- Test coverage documentation
- Future expansion roadmap
Updates:
- CURRENT_TASK.md: Moved Phase 43/245B to completed section
- joinir-architecture-overview.md: Phases 43-45 marked complete
- Historical docs: Added completion banners with links
- phase223-loopbodylocal-condition-design.md
- phase223-loopbodylocal-condition-inventory.md
- PHASE_223_SUMMARY.md
- phase245b-num_str-carrier-design.md
- phase245c-function-param-capture-summary.md
Documentation hierarchy established:
- Master summary → individual design docs
- Historical docs → completion summary
- Cross-references complete across all docs
Status: Phase 43/245B Normalized infrastructure COMPLETE ✅
2025-12-12 04:19:06 +09:00
c82ae2365f
refactor(joinir): Phase 44 - Capability-based shape guard
...
Refactor shape detection from function-name-based to capability-based
architecture for better extensibility and maintainability.
Key changes:
- ShapeCapabilityKind enum: P2CoreSimple/SkipWs/Atoi/ParseNumber
- ShapeCapability: Capability descriptor with future extensibility
- Helper functions:
- capability_for_shape(): Map shape to capability
- is_canonical_shape(): Exact shape-level check
- is_p2_core_capability(): Broad capability family check
- is_supported_by_normalized(): Normalized dev support
Benefits:
- Extensibility: Easy to add new capability kinds
- Clarity: Shape purpose explicit in kind names
- Maintainability: Centralized mapping vs scattered ifs
- Future-ready: Infrastructure for carrier roles, method signatures
Backward compatibility:
- Zero behavioral changes (pure refactoring)
- Canonical set preserved: Pattern2Mini, skip_ws mini/real, atoi mini
- All existing code paths unchanged
Tests: 937/937 PASS
Files: +78 lines (shape_guard.rs), design doc created
2025-12-12 04:06:03 +09:00
2e6b731563
refactor(config): Modularize env.rs into 7 semantic flag Boxes
...
Refactored monolithic env.rs (948 lines, 106 flat functions) into 7 focused
Box modules following Box-First principles. Zero breaking changes via
backward-compatible re-exports.
**Module organization** (7 semantic Boxes):
- joinir_flags.rs (172 lines, 15 functions) - JoinIR core/experiment flags
- mir_flags.rs (227 lines, 35 functions) - MIR core/PHI/optimizer flags
- vm_backend_flags.rs (135 lines, 15 functions) - VM/Backend/LLVM flags
- parser_flags.rs (136 lines, 10 functions) - Parser stage/postfix flags
- using_flags.rs (70 lines, 7 functions) - Using/namespace system flags
- verification_flags.rs (61 lines, 7 functions) - Verification/SSA flags
- selfhost_flags.rs (98 lines, 12 functions) - Selfhost NY compiler flags
**Improvements**:
- IDE discoverability: `joinir_flags::`, `mir_flags::` in autocomplete
- Single Responsibility: Each Box handles one semantic area
- Maintainability: ~100-200 line modules instead of 948 line monolith
- Scalability: Easy to add new flags to appropriate modules
- Backward compatibility: All functions re-exported at `crate::config::env::`
**Verification**:
- 937/937 tests PASS (zero regressions)
- cargo build --release succeeds
- No code changes required in existing callsites (backward compatible)
Box-First architecture:
- 箱に切り出す: 106 functions → 7 semantic modules
- 境界をはっきりさせる: Each module has clear responsibility
- 差し替え可能: Backward-compatible re-exports
- いつでも戻せる: Original backup created, reverts are safe
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-12 03:59:00 +09:00
a763651162
refactor(joinir): Modularize function_scope_capture (1588→4 modules)
...
Break down monolithic function_scope_capture.rs into 4 focused Box-First modules:
**File structure**:
- mod.rs (57 lines): Public API and module organization
- types.rs (110 lines): CapturedVar, CapturedEnv type definitions
- helpers.rs (411 lines): 11 helper functions for AST analysis
- analyzers.rs (1015 lines): Core analysis functions and FunctionScopeCaptureAnalyzer
**Separation of concerns**:
- types.rs: Pure data structures
- helpers.rs: Reusable utility functions (find_stmt_index, ast_matches, etc.)
- analyzers.rs: High-level analysis logic and orchestration
- mod.rs: Clean public API
**Benefits**:
- Single Responsibility Principle: Each module has one clear purpose
- Maintainability: ~400 line modules instead of 1588 line monolith
- Testability: 12 tests organized by module
- Box-First design: Clear separation with well-defined boundaries
**Verification**:
- 937/937 tests PASS (no regression)
- cargo build --release succeeds
- All docs and comments preserved
- No functional changes
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-12 03:42:57 +09:00
879d3ee08e
feat(joinir): Phase 45 - JoinIR mode unification
...
Unified JoinIR routing logic through centralized JoinIrMode enum:
Key changes:
- Added JoinIrMode enum (StructuredOnly / NormalizedDev / NormalizedCanonical)
- Added current_joinir_mode() for centralized mode determination
- Refactored normalized_dev_enabled() as thin wrapper over mode enum
- Updated bridge.rs: mode-based routing with canonical P2-Core special handling
- Updated runner.rs: mode pattern matching for dev roundtrip path
Files modified:
- joinir_dev.rs: JoinIrMode enum + current_joinir_mode() (+49 lines)
- bridge.rs: Replaced boolean checks with mode pattern matching (+29 lines)
- runner.rs: Mode-based routing logic (+9 lines)
- CURRENT_TASK.md: Phase 45 implementation summary
Documentation:
- phase45-norm-mode-design.md: Complete design spec and implementation guide
Behavior preservation:
- Canonical P2-Core shapes: always Normalized→MIR(direct) (mode-independent)
- NormalizedDev mode: Structured→Normalized→MIR for supported shapes
- StructuredOnly mode: Structured→MIR direct (default)
Tests: 937/937 PASS (no regression, pure refactor)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-12 03:31:58 +09:00
ed8e2d3142
feat(joinir): Phase 248 - Normalized JoinIR infrastructure
...
Major refactoring of JoinIR normalization pipeline:
Key changes:
- Structured→Normalized→MIR(direct) pipeline established
- ShapeGuard enhanced with Pattern2 loop validation
- dev_env.rs: New development fixtures and env control
- fixtures.rs: jsonparser_parse_number_real fixture
- normalized_bridge/direct.rs: Direct MIR generation from Normalized
- pattern2_step_schedule.rs: Extracted step scheduling logic
Files changed:
- normalized.rs: Enhanced NormalizedJoinModule with DevEnv support
- shape_guard.rs: Pattern2-specific validation (+300 lines)
- normalized_bridge.rs: Unified bridge with direct path
- loop_with_break_minimal.rs: Integrated step scheduling
- Deleted: step_schedule.rs (moved to pattern2_step_schedule.rs)
New files:
- param_guess.rs: Loop parameter inference
- pattern2_step_schedule.rs: Step scheduling for Pattern2
- phase43-norm-canon-p2-mid.md: Design doc
Tests: 937/937 PASS (+6 from baseline 931)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-12 03:15:45 +09:00
59caf5864c
Document Phase 36 normalized direct bridge
2025-12-11 22:52:17 +09:00
12e2f87c6f
Refine normalized bridge direct path and env guard
2025-12-11 22:50:23 +09:00
a4756f3ce1
Add dev normalized→MIR bridge for P1/P2 mini and JP _atoi
2025-12-11 22:12:46 +09:00
af6f95cd4b
Phase 33 NORM canon test: enforce normalized dev route for P1/P2/JP mini
2025-12-11 20:54:33 +09:00
59a985b7fa
joinir: clean pattern visibility and refactor pattern2 pipeline
2025-12-11 19:11:26 +09:00
463a6240fb
chore(test): Improve phase246ex_atoi_mini test format
...
- Change from string return ("PASS"/"FAIL") to numeric RC (0=success, 1=fail)
- Add print("result = N") for stdout verification
- Update comments to reflect new test format
This makes test results verifiable via both stdout AND return code,
avoiding future confusion about RC interpretation.
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-11 17:24:32 +09:00
eb00d97fdb
feat(joinir): Phase 246-EX Part 2 - Exit PHI & step scheduling fixes
...
Phase 246-EX Part 2 completes the _atoi JoinIR integration:
Key fixes:
- Exit PHI connection: ExitLineReconnector now correctly uses exit PHI dsts
- Jump args preservation: BasicBlock.jump_args field stores JoinIR exit values
- instruction_rewriter: Reads jump_args, remaps JoinIR→HOST values by carrier order
- step_schedule.rs: New module for body-local init step ordering
Files changed:
- reconnector.rs: Exit PHI connection improvements
- instruction_rewriter.rs: Jump args reading & carrier value mapping
- loop_with_break_minimal.rs: Refactored step scheduling
- step_schedule.rs: NEW - Step ordering logic extracted
Tests: 931/931 PASS (no regression)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-11 17:16:10 +09:00
e356524b0a
feat(joinir): Phase 246-EX Part 1 - FromHost carrier infrastructure
...
Extends Phase 247-EX dual-value architecture for _atoi NumberAccumulation
support. Implements FromHost carrier handling throughout JoinIR pipeline.
## Problem Analysis
_atoi requires `result = result * 10 + digit_pos` where:
- digit_pos is promoted to dual carriers: is_digit_pos (bool) + digit_value (int)
- digit_value is used in NumberAccumulation but NOT updated itself
- Existing infrastructure filtered out carriers without updates
## Implementation
### 1. Carrier Filtering (pattern2_with_break.rs:507-514)
**Added FromHost retention**:
```rust
carrier_updates.contains_key(&carrier.name)
|| carrier.role == CarrierRole::ConditionOnly
|| carrier.init == CarrierInit::FromHost // Phase 247-EX
```
**Effect**: Keeps digit_value carrier despite no update expression
### 2. Carrier Update Passthrough (loop_with_break_minimal.rs:411-426)
**Added FromHost passthrough**:
- FromHost carriers without updates pass through from env
- Similar to Phase 227 ConditionOnly handling
- Logged as `[loop/carrier_update] Phase 247-EX: FromHost carrier passthrough`
### 3. Exit Bindings Collection (meta_collector.rs:156-172)
**Added FromHost exit_bindings inclusion**:
```rust
Some((CarrierRole::LoopState, CarrierInit::FromHost)) => {
// Include in exit_bindings for latch incoming
// Not for exit PHI or variable_map
}
```
**Effect**: digit_value gets latch incoming for header PHI
## Test Results
- **Before**: 931 tests PASS
- **After**: 931 tests PASS (0 regressions)
## Verification
**Phase 247-EX UpdateEnv working**:
```
[update_env/phase247ex] Resolved promoted 'digit_pos' → 'digit_value' (integer carrier): ValueId(111)
```
**NumberAccumulation MIR generated**:
```
%39 = %14 Mul %38 ← result * 10
%40 = %39 Add %9 ← tmp + digit_value
```
## Status
- ✅ Pattern2 classification
- ✅ NumberAccumulation detection
- ✅ dual-value carrier resolution
- ✅ FromHost carrier handling
- ⚠️ RC:0 issue (runtime value problem, Part 2)
## Related
- Phase 247-EX: DigitPos dual-value architecture (commit 8900a3cc )
- Phase 227: ConditionOnly carrier handling
- Phase 228-8: ConditionOnly exit_bindings
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-11 15:28:36 +09:00
8900a3cc44
feat(joinir): Phase 247-EX - DigitPos dual-value architecture
...
Extends DigitPos promotion to generate TWO carriers for Pattern A/B support:
- Boolean carrier (is_digit_pos) for break conditions
- Integer carrier (digit_value) for NumberAccumulation
## Implementation
1. **DigitPosPromoter** (loop_body_digitpos_promoter.rs)
- Generates dual carriers: is_<var> (bool) + <base>_value (int)
- Smart naming: "digit_pos" → "digit" (removes "_pos" suffix)
2. **UpdateEnv** (update_env.rs)
- Context-aware promoted variable resolution
- Priority: <base>_value (int) → is_<var> (bool) → standard
- Pass promoted_loopbodylocals from CarrierInfo
3. **Integration** (loop_with_break_minimal.rs)
- UpdateEnv constructor updated to pass promoted list
## Test Results
- **Before**: 925 tests PASS
- **After**: 931 tests PASS (+6 new tests, 0 failures)
## New Tests
- test_promoted_variable_resolution_digit_pos - Full dual-value
- test_promoted_variable_resolution_fallback_to_bool - Fallback
- test_promoted_variable_not_a_carrier - Error handling
## Impact
| Pattern | Before | After |
|---------|--------|-------|
| _parse_number | ✅ Works (bool only) | ✅ Works (bool used, int unused) |
| _atoi | ❌ Failed (missing int) | ✅ READY (int carrier available!) |
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-11 15:08:14 +09:00
d4597dacfa
feat(joinir): Phase 245C - Function parameter capture + test fix
...
Extend CapturedEnv to include function parameters used in loop conditions,
enabling ExprLowerer to resolve variables like `s` in `loop(p < s.length())`.
Phase 245C changes:
- function_scope_capture.rs: Add collect_names_in_loop_parts() helper
- function_scope_capture.rs: Extend analyze_captured_vars_v2() with param capture logic
- function_scope_capture.rs: Add 4 new comprehensive tests
Test fix:
- expr_lowerer/ast_support.rs: Accept all MethodCall nodes for syntax support
(validation happens during lowering in MethodCallLowerer)
Problem solved: "Variable not found: s" errors in loop conditions
Test results: 924/924 PASS (+13 from baseline 911)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-11 13:13:08 +09:00
00ecddbbc9
Add pattern router tests and tidy pattern4 lowering
2025-12-11 04:22:08 +09:00
d4f90976da
refactor(joinir): Phase 244 - ConditionLoweringBox trait unification
...
Unify condition lowering logic across Pattern 2/4 with trait-based API.
New infrastructure:
- condition_lowering_box.rs: ConditionLoweringBox trait + ConditionContext (293 lines)
- ExprLowerer implements ConditionLoweringBox trait (+51 lines)
Pattern migrations:
- Pattern 2 (loop_with_break_minimal.rs): Use trait API
- Pattern 4 (loop_with_continue_minimal.rs): Use trait API
Benefits:
- Unified condition lowering interface
- Extensible for future lowering strategies
- Clean API boundary between patterns and lowering logic
- Zero code duplication
Test results: 911/911 PASS (+2 new tests)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-11 02:35:31 +09:00
2dfe363365
refactor(joinir): Phase 242-EX-A - Delete legacy Pattern3 lowerer
...
Remove hardcoded Pattern3 PoC implementation (loop_with_if_phi_minimal.rs)
and enhance if-sum mode to handle complex conditions like `i % 2 == 1`.
Key changes:
- condition_pattern.rs: Accept BinaryOp in comparison operands (+58 lines)
- loop_with_if_phi_if_sum.rs: Dynamic complex condition lowering (+147 lines)
- pattern3_with_if_phi.rs: Remove lower_pattern3_legacy() (-130 lines)
- loop_with_if_phi_minimal.rs: Delete entire file (-437 lines)
- loop_patterns/with_if_phi.rs: Update stub (-45 lines)
- mod.rs: Remove module reference (-4 lines)
Net reduction: -664 lines of hardcoded PoC code
Test results: 909/909 PASS (legacy mode completely removed)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-11 01:27:08 +09:00
811dfebf98
fix(joinir): Phase 241-EX - Remove hardcoded 'sum' check from Pattern3
...
Remove legacy hardcoded 'sum' carrier validation that was blocking
array_filter patterns with different accumulator names (e.g., 'out').
Before: Pattern3 required carrier named 'sum' to exist
After: Pattern3 uses carrier_info generically (any carrier name works)
Test results:
- phase49_joinir_array_filter_smoke: PASS ✅
- phase49_joinir_array_filter_fallback: PASS ✅
- phase49_joinir_array_filter_ab_comparison: PASS ✅
- Full suite: 909/909 PASS, 0 FAIL
Also: Archive old roadmap documentation (67k lines moved to docs/archive/)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-11 00:48:42 +09:00
a7dbc15878
feat(joinir): Phase 240-EX - Pattern2 header condition ExprLowerer integration
...
Implementation:
- Add make_pattern2_scope_manager() helper for DRY
- Header conditions use ExprLowerer for supported patterns
- Legacy fallback for unsupported patterns
- Fail-Fast on supported patterns that fail
Tests:
- 4 new tests (all pass)
- test_expr_lowerer_supports_simple_header_condition_i_less_literal
- test_expr_lowerer_supports_header_condition_var_less_var
- test_expr_lowerer_header_condition_generates_expected_instructions
- test_pattern2_header_condition_via_exprlowerer
Also: Archive old phase documentation (34k lines removed)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-11 00:33:04 +09:00
448bf3d8c5
docs(joinir): Phase 232-239 documentation and ExprLowerer refinements
...
Documentation:
- Move completion reports to docs/archive/reports/
- Add phase232-238 design/inventory documents
- Update joinir-architecture-overview.md
- Add doc-status-policy.md
Code refinements:
- ExprLowerer: condition catalog improvements
- ScopeManager: boundary clarifications
- CarrierInfo: cleanup
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-11 00:21:29 +09:00
13a676d406
feat(joinir): Phase 231 - ExprLowerer/ScopeManager pilot implementation
...
Pilot implementation of unified expression lowering for Pattern2 break conditions:
New files:
- scope_manager.rs (280 lines) - ScopeManager trait + Pattern2ScopeManager
- expr_lowerer.rs (455 lines) - ExprLowerer with Condition context support
Features:
- Unified variable lookup across ConditionEnv/LoopBodyLocalEnv/CapturedEnv/CarrierInfo
- Pre-validation of condition AST before lowering
- Fail-safe design with fallback to legacy path
- 8 new unit tests (all pass)
Integration:
- Pattern2 break condition uses ExprLowerer for pre-validation
- Existing proven lowering path preserved
- Zero impact on existing functionality (890/897 tests pass)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-10 22:48:45 +09:00
b07329b37f
feat(joinir): Phase 224-E - DigitPos condition normalization
...
Add DigitPosConditionNormalizer to transform integer comparison to boolean:
- `digit_pos < 0` → `!is_digit_pos`
This eliminates the type error caused by comparing Bool carrier with Integer:
- Before: Bool(is_digit_pos) < Integer(0) → Type error
- After: !is_digit_pos → Boolean expression, no type mismatch
Implementation:
- New Box: digitpos_condition_normalizer.rs (173 lines)
- Pattern2 integration: normalize after promotion success
- 5 unit tests (all pass)
- E2E test passes (type error eliminated)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-10 22:10:28 +09:00
38e810d071
refactor(joinir): Phase 229 - Remove redundant ConditionAlias
...
Replace static alias mapping with dynamic condition variable resolution using:
- promoted_loopbodylocals as source of truth
- Naming conventions: is_<var> or is_<var>_match
- Pattern-aware inference during lowering
Benefits:
- Simpler data structure (6 fields → 5)
- Single source of truth
- Self-documenting with explicit naming conventions
- Fewer maintenance points
Net: -25 lines (60 additions, 85 deletions)
Tests: 877/884 PASS (no regressions)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-10 21:53:27 +09:00
717a50ceeb
feat(joinir): Phase 228-8 - ConditionOnly carrier latch incoming support
...
- ExitMetaCollector includes ConditionOnly carriers in exit_bindings (for latch)
- ExitLineReconnector skips ConditionOnly in variable_map updates
- Pattern 2/3/4 pass carrier_info to ExitMetaCollector
- Resolves "has no latch incoming set" error
Role separation:
- Header PHI: entry + latch for both LoopState and ConditionOnly
- Exit PHI: LoopState only (ConditionOnly excluded)
- variable_map: LoopState only (ConditionOnly skipped)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-10 21:30:03 +09:00
192620f842
feat(joinir): Phase 228 - CarrierInit for ConditionOnly header PHI initialization
...
- Add CarrierInit enum (FromHost/BoolConst) for explicit initialization policy
- LoopHeaderPhiBuilder generates Const instruction for BoolConst carriers
- merge/mod.rs uses carrier_info to include ALL carriers in header PHI
- Pattern 2/4 pass carrier_info to boundary builder
- ConditionOnly carriers (is_digit_pos) now included in header PHI
Remaining: latch incoming for ConditionOnly carriers (Phase 228-8)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-10 21:10:28 +09:00
478cc0012e
feat(joinir): Phase 227 - CarrierRole separation (LoopState vs ConditionOnly)
...
- Add CarrierRole enum to distinguish state carriers from condition-only carriers
- ConditionOnly carriers (is_digit_pos) skip exit PHI but keep header PHI
- Update all test struct literals with role field
- 877/884 tests PASS (7 pre-existing failures unrelated)
Remaining: ValueId(0) undefined - header PHI initialization for ConditionOnly
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-10 20:07:30 +09:00
d28e54ba06
feat(joinir): Phase 226 - Cascading LoopBodyLocal resolution
...
- Add LoopBodyLocalEnv to argument resolution in MethodCallLowerer
- Implement cascading lookup: LoopBodyLocalEnv → ConditionEnv
- Enable ch → digit_pos dependency chain in init expressions
- Resolves "Variable 'ch' not bound in ConditionEnv" error
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-10 19:29:03 +09:00
0243de871f
feat(joinir): Phase 225 - MethodCall init meta-driven lowering
...
- Remove hardcoded method whitelist from loop_body_local_init.rs
- Remove hardcoded box name matching
- Delegate to MethodCallLowerer for all MethodCall handling
- CoreMethodId metadata is now SSOT for init method validation
- substring now works in body-local init (-82 net lines)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-10 19:08:18 +09:00
4e00edcea5
feat(joinir): Phase 224-D - ConditionAlias for promoted variable resolution
...
- Add ConditionAlias type to CarrierInfo (old_name → carrier_name)
- Record aliases in DigitPosPromoter and TrimPatternInfo
- Resolve aliases in Pattern2 ConditionEnv building
- digit_pos now correctly resolves to is_digit_pos carrier
Fixes "Variable 'digit_pos' not bound in ConditionEnv" error.
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-10 18:45:04 +09:00
8e3b55ddec
feat(joinir): Phase 224-C - MethodCallLowerer with argument support
...
- Add StringIndexOf to CoreMethodId (arity=1, return IntegerBox)
- Extend MethodCallLowerer to handle methods with arguments
- Add arity checking against CoreMethodId metadata
- Recursive argument lowering via lower_value_expression
- 8 unit tests PASS (indexOf, substring, arity mismatch)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-10 18:19:14 +09:00
250555bfc0
feat(joinir): Phase 224-B - MethodCallLowerer + CoreMethodId extension
...
- Extend CoreMethodId with is_pure(), allowed_in_condition(), allowed_in_init()
- New MethodCallLowerer box for metadata-driven MethodCall lowering
- Integrate MethodCall handling in condition_lowerer
- P0: Zero-argument methods (length) supported
- Design principle: NO method name hardcoding, CoreMethodId metadata only
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-10 17:59:24 +09:00
4cddca1cae
feat(joinir): Phase 224-cont - Promoted variable tracking for lowerer
...
- Add promoted_loopbodylocals field to CarrierInfo
- Record promoted variables in Pattern2 promotion handler
- Filter promoted variables in lowerer LoopBodyLocal check
- digit_pos → is_digit_pos promotion now continues to lowering
Closes Phase 224 lowerer integration gap.
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-10 16:30:53 +09:00
00d1ec7cc5
feat(joinir): Phase 224 - DigitPosPromoter for A-4 pattern (core complete)
...
- New DigitPosPromoter Box for cascading indexOf pattern detection
- Two-tier promotion strategy: A-3 Trim → A-4 DigitPos fallback
- Unit tests 6/6 PASS (comparison operators, cascading dependency)
- Promotion verified: digit_pos → is_digit_pos carrier
⚠️ Lowerer integration gap: lower_loop_with_break_minimal doesn't
recognize promoted variables yet (Phase 224-continuation)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-10 16:21:01 +09:00
b5661c1915
feat(joinir): Phase 223.5 - LoopBodyCondPromoter Pattern2 integration
...
- Integrate LoopBodyCondPromoter into Pattern2 (break condition analysis)
- Add Pattern2 error message functions to error_messages.rs
- Create A-4 minimal test (phase2235_p2_digit_pos_min.hako)
- Unified promotion structure for Pattern2/Pattern4
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-10 16:20:44 +09:00
9b3d2bf001
refactor(joinir): Phase 223 cleanup - impl consolidation & comment cleanup
...
Improves code organization and readability after Phase 223-3 implementation.
## Task R-1: impl Block Consolidation
**loop_body_cond_promoter.rs**:
- Merged 2 separate impl blocks into single unified impl
- Added section headers for better organization:
- Public API (extract_continue_condition, try_promote_for_condition)
- Private Helpers (contains_continue)
- Improved logical flow and discoverability
## Task R-2: Phase Comment Cleanup
**pattern4_with_continue.rs**:
- Simplified Phase 223-3 comments (removed redundant phase numbers)
- Added concise section header explaining LoopBodyLocal promotion
- Clarified inline comments for better understanding
- Maintained implementation intent while reducing noise
## Impact
- No functional changes
- All tests PASS (5 cond_promoter tests, 8 pattern4 tests)
- Better code organization for future maintenance
- Cleaner git history for Phase 223
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-10 15:07:08 +09:00
89a769198a
feat(joinir): Phase 223-3 - LoopBodyCondPromoter implementation
...
Implements LoopBodyLocal condition promotion for Pattern4/continue patterns.
Previously, loops with LoopBodyLocal in conditions would Fail-Fast.
Now, safe Trim/skip_whitespace patterns (Category A-3) are promoted and lowering continues.
## Implementation
- **LoopBodyCondPromoter Box** (loop_body_cond_promoter.rs)
- extract_continue_condition(): Extract if-condition from continue branches
- try_promote_for_condition(): Thin wrapper delegating to LoopBodyCarrierPromoter
- ConditionPromotionRequest/Result API for Pattern2/4 integration
- **Pattern4 Integration** (pattern4_with_continue.rs)
- Analyze both header condition + continue condition
- On promotion success: merge carrier_info → continue lowering
- On promotion failure: Fail-Fast with clear error message
- **Unit Tests** (5 tests, all PASS)
- test_cond_promoter_skip_whitespace_pattern
- test_cond_promoter_break_condition
- test_cond_promoter_non_substring_pattern
- test_cond_promoter_no_scope_shape
- test_cond_promoter_no_body_locals
- **E2E Test** (phase223_p4_skip_whitespace_min.hako)
- Category A-3 pattern: local ch = s.substring(...); if ch == " " { continue }
- Verifies promotion succeeds and Pattern4 lowering proceeds
## Documentation
- joinir-architecture-overview.md: Updated LoopBodyCondPromoter section (Phase 223-3 完了)
- CURRENT_TASK.md: Added Phase 223-3 completion summary
- PHASE_223_SUMMARY.md: Phase overview and status tracking
- phase223-loopbodylocal-condition-*.md: Design docs and inventory
## Achievement
- **Before**: LoopBodyLocal in condition → Fail-Fast
- **Now**: Trim/skip_whitespace patterns promoted → Pattern4 lowering continues
- **Remaining**: Phase 172+ JoinIR Trim lowering for complete RC correctness
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-10 15:00:20 +09:00
9dbf053781
refactor(joinir): Phase 222.5-E - Merge/Boundary HashMap → BTreeMap
...
Convert 10 medium-priority locations to BTreeMap for determinism:
Merge System (6 locations):
- instruction_rewriter.rs: value_to_func_name, function_params,
function_entry_map, local_block_map
- value_collector.rs: value_to_func_name, function_params,
function_entry_map
ID Remapper (2 locations):
- joinir_id_remapper.rs: block_map, value_map
Boundary Injector (2 locations):
- joinir_inline_boundary_injector.rs: value_map (param & return)
Impact:
- Changed files: 4
- Changed lines: +36, -24 (net +12)
- Tests: 849/856 PASS (no regression)
- Determinism: Merge/Boundary processing now deterministic
Combined with Phase 222.5-D (13 high-priority locations),
JoinIR pipeline now uses BTreeMap uniformly across all
critical paths (Pattern/Merge/Boundary/ValueId allocation).
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-10 14:09:18 +09:00
948cc68889
refactor(joinir): Phase 222.5 - Modularization & Determinism
...
Phase 222.5-B: ConditionEnv API Unification
- Remove deprecated build_loop_param_only() (v1)
- Unify build_with_captures() to use JoinValueSpace (v2 API)
- Code reduction: -17 lines
- Tests: 5/5 PASS
Phase 222.5-C: exit_binding.rs Modularization
- Split into 4 modules following Phase 33 pattern:
- exit_binding_validator.rs (171 lines)
- exit_binding_constructor.rs (165 lines)
- exit_binding_applicator.rs (163 lines)
- exit_binding.rs orchestrator (364 lines, -71 reduction)
- Single responsibility per module
- Tests: 16/16 PASS
Phase 222.5-D: HashMap → BTreeMap for Determinism
- Convert 13 critical locations to BTreeMap:
- exit_binding (3), carrier_info (2), pattern_pipeline (1)
- loop_update_analyzer (2), loop_with_break/continue (2)
- pattern4_carrier_analyzer (1), condition_env (2)
- Deterministic iteration guaranteed in JoinIR pipeline
- Inventory document: phase222-5-d-hashmap-inventory.md
- Tests: 849/856 PASS (7 pre-existing failures)
- Determinism verified: 3-run consistency test PASS
Overall Impact:
- Code quality: Single responsibility, function-based design
- Determinism: JoinIR pipeline now uses BTreeMap uniformly
- Tests: All Phase 222.5 tests passing
- Documentation: Complete inventory & implementation plan
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-10 13:59:23 +09:00
e3b36aa83a
docs(joinir): Phase 222-5 documentation updates
...
Phase 222: If Condition Normalization - Part 5 (Documentation)
Updates:
1. joinir-architecture-overview.md:
- Section 2.2 ConditionPatternBox: Added Phase 222 normalization features
* normalize_comparison() for left-right flip (0 < i → i > 0)
* var CmpOp var support (i > j)
- Section 4.3 JsonParser constraints:
* Marked Phase 221 'if condition pattern' constraint as RESOLVED ✅
* Added Phase 222 resolution summary with test reference
2. CURRENT_TASK.md:
- Added Phase 222 completion summary (4 lines)
- ConditionPatternBox extension, if-sum integration, test results
- Phase 221 constraint resolution
Phase 222 Complete Summary:
- ✅ Design document (phase222-if-cond-normalization.md)
- ✅ Implementation (condition_pattern.rs +160 lines, 9 tests)
- ✅ Integration (pattern_pipeline.rs, loop_with_if_phi_if_sum.rs)
- ✅ E2E test (phase222_if_cond_left_literal_min.hako → RC=2)
- ✅ Documentation (architecture overview + CURRENT_TASK)
Status: Phase 222 完了 🎉
2025-12-10 09:29:32 +09:00
b77212be15
feat(joinir): Phase 222-4 E2E test for condition normalization
...
Phase 222: If Condition Normalization - Part 4 (E2E Testing)
New test: phase222_if_cond_left_literal_min.hako
- Tests condition normalization in if-sum pattern
- Loop condition: i < len (canonical form)
- If condition: i > 0 (var > literal - canonical form)
- Expected: RC=2 (i=1,2 counted, i=0 skipped)
Test results:
✅ phase222_if_cond_left_literal_min.hako: RC=2 PASS
✅ phase212_if_sum_min.hako: RC=2 PASS (regression)
✅ loop_if_phi.hako: sum=9 PASS (complex condition → legacy mode)
Status: E2E verification complete
Next: Phase 222-5 - Documentation updates
2025-12-10 09:28:08 +09:00
bcdad203f0
feat(joinir): Phase 222-3 if-sum normalization integration
...
Phase 222: If Condition Normalization - Part 3
Goal: Integrate normalization into if-sum pattern detection and lowering
Changes:
1. pattern_pipeline.rs (is_if_sum_pattern):
- Updated to use analyze_condition_pattern() + normalize_comparison()
- Added two-step validation:
(a) Pattern must be SimpleComparison
(b) Condition must be normalizable
- Replaced is_simple_comparison() with Phase 222 API
2. loop_with_if_phi_if_sum.rs (extract_loop_condition):
- Added Phase 222 normalization
- Normalize condition to canonical form (var on left)
- Support both literal and variable on right-hand side
- Added mir::CompareOp → join_ir::CompareOp conversion
- Handles:
* Phase 219: var CmpOp literal (e.g., i > 0)
* Phase 222: literal CmpOp var (e.g., 0 < i) → normalized
* Phase 222: var CmpOp var (e.g., i > j)
Status: Integration complete, ready for E2E testing
Next: Phase 222-4 - verify regression tests and add new test cases
2025-12-10 09:23:44 +09:00
f0536fa330
feat(joinir): Phase 222-2 ConditionPatternBox normalization implementation
...
Phase 222: If Condition Normalization - Part 2
Goal: Support '0 < i', 'i > j' patterns in addition to 'i > 0'
Changes:
1. condition_pattern.rs (+160 lines):
- Added ConditionValue enum (Variable | Literal)
- Added NormalizedCondition struct (left_var, op, right)
- Added flip_compare_op() for operator reversal
- Added binary_op_to_compare_op() converter
- Added normalize_comparison() main normalization function
- Extended analyze_condition_pattern() to accept 3 cases:
* Phase 219: var CmpOp literal (e.g., i > 0)
* Phase 222: literal CmpOp var (e.g., 0 < i) → normalized
* Phase 222: var CmpOp var (e.g., i > j)
- Added 9 unit tests (all passing)
2. loop_update_summary.rs (cleanup):
- Commented out obsolete test_typical_index_names
- Function is_typical_index_name() was removed in earlier phase
Test results:
- 7 normalization tests: PASS ✅
- 2 pattern analysis tests: PASS ✅
Next: Phase 222-3 - integrate normalization into is_if_sum_pattern()
Status: Ready for integration
2025-12-10 09:18:21 +09:00