Commit Graph

5 Commits

Author SHA1 Message Date
386cbc1915 Phase47-B/C: extend P3 normalized shapes and quiet dev warnings 2025-12-12 07:13:34 +09:00
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
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