c522d22daa
feat(control_tree): Phase 128 - add Assign(int literal) to Normalized builder (dev-only)
2025-12-18 07:03:57 +09:00
44762a2467
refactor(control_tree): Phase 128 - add value_ast to Assign for Normalized lowering
2025-12-18 07:01:39 +09:00
72f2c1f64d
feat(joinir/dev): Phase 126 wire available_inputs into normalized builder
...
- AvailableInputsCollectorBox::collect() called in lower_function_body (dev-only)
- try_lower_if_only() signature extended (accepts available_inputs)
- EnvLayout::from_contract() now uses real available_inputs (not empty stub)
- Unit tests updated (empty BTreeMap for backward compat)
- All 23 normalized_shadow tests PASS
2025-12-18 06:45:23 +09:00
89c2915fa0
feat(control_tree): Phase 126 AvailableInputsCollectorBox
...
- Collect available_inputs from function params + CapturedEnv (SSOT)
- BTreeMap for deterministic order
- Box-first modularization with unit tests (5 tests PASS)
- Source priority: params > CapturedEnv
- No AST inference (only pre-computed sources)
2025-12-18 06:43:27 +09:00
4c98313b58
refactor(control_tree): Phase 125 P2-P4 introduce EnvLayout (writes+inputs) + Return(Variable) from inputs
...
Phase 125 P2: EnvLayout introduction
- Add EnvLayout struct (writes + inputs)
- from_contract() creates layout from StepTreeContract + available_inputs
- SSOT: inputs = reads ∩ available_inputs (deterministic order)
- No AST inference (don't capture from AST, use provided available_inputs)
Phase 125 P2: Builder env mapping
- lower_if_only_to_normalized: Use EnvLayout to create env map
- writes: Generate ValueId (as before)
- inputs: Reference ValueId from available_inputs (placeholder for P3)
- Function params: writes only (inputs come from outer scope)
Phase 125 P4: Return(Variable) resolution extended
- lower_return_value: Check env (writes + inputs)
- If found: return it (Phase 124 for writes, Phase 125 for inputs)
- If not found: Fail-Fast with structured error + hint
- Hint: "Pass as param, add to pinned capture, or define before if"
- Phase 125 errors return Ok(None) (out of scope, graceful degradation)
Unit tests:
- test_return_variable_from_env: PASS (Phase 124 regression)
- test_return_variable_out_of_scope: PASS (updated for Phase 125)
- test_return_variable_from_inputs_stub: PASS (P3 not wired yet)
- All 1160 lib tests PASS (no regression)
Note:
- P3 (available_inputs wiring) not implemented yet
- available_inputs is empty BTreeMap (stub)
- EnvLayout.inputs will be empty until P3 is wired
- Structured error tags: [phase125/return/var_not_in_env]
Ref: docs/development/current/main/phases/phase-125/README.md
2025-12-18 06:30:55 +09:00
c40971dc74
feat(control_tree): Phase 124 return variable from env (dev-only)
...
Phase 124-P3:
- Add env: BTreeMap<String, ValueId> from writes in lower_if_only_to_normalized
- Pass env and contract to lower_return_from_tree, lower_if_node, lower_return_value
- Implement Return(Variable) support:
- If variable in env (writes): Ret(Some(vid))
- If variable not in env: Err (out of scope, phase124 error)
- Add phase124 errors to Ok(None) conversion (dev-only compatibility)
- Add unit test: test_return_variable_from_env (verifies Ret(Some(ValueId(1))))
- All 1159 tests PASS
2025-12-18 06:05:18 +09:00
320a23e3d1
refactor(control_tree): include reads in StepTreeContract signature
...
Phase 124-P2:
- Add reads: BTreeSet<String> to StepTreeContract
- Include reads in signature_basis_string (format: ...;reads=...;...)
- Update from_facts() to copy reads from StepTreeFacts
- Update all StepTreeContract construction sites (builder.rs, parity.rs tests)
- Update test expected signature to include reads field
- Maintains determinism: BTreeSet guarantees stable iteration order
2025-12-18 06:00:21 +09:00
95b25e54ad
feat(control_tree): Phase 124 add reads to StepTreeFacts
...
- Add reads: BTreeSet<String> to StepTreeFacts
- Add add_read() API and merge_reads() in merge()
- Add extract_variables_from_ast() helper for AST traversal
- Extract reads from:
- If/Loop condition AST
- Return value AST
- All Variable nodes recursively (BinaryOp, UnaryOp, FunctionCall, MethodCall, FieldAccess, Index, Assignment RHS, Print)
- SSOT: extract_variables_from_ast() is the single source for reads collection
2025-12-18 05:58:08 +09:00
7eec4ec0c8
feat(control_tree): Phase 123 if-only compare+return lowering (Normalized, dev-only)
...
Implements Phase 123 P3: If(cond_ast) minimal lowering with graceful degradation.
**What's Implemented**:
- If node lowering with minimal binary comparison (Variable op Integer)
- Supported operators: ==, !=, <, <=, >, >=
- Generates: Compare + Const + Ret structure
- Graceful degradation: returns Ok(None) for unsupported patterns
**Key Design Decisions**:
1. **Graceful Degradation**: Phase 123 limitations return `Ok(None)` instead of failing
- Allows dev-only mode to coexist with legacy code
- Error messages prefixed with `[phase123/...]` are caught
2. **Fail-Fast with Structured Errors**: All limitations use structured error codes
- Format: `[phase123/category/specific]`
3. **Box-First Principles**:
- `parse_minimal_compare`: Single responsibility parser
- `verify_branch_is_return_literal`: Branch validation box
- `lower_if_node`: If lowering box
**Implementation**:
- Added `lower_if_node`: If lowering with minimal compare
- Added `parse_minimal_compare`: Binary comparison parser
- Added `verify_branch_is_return_literal`: Branch validator
- Updated `lower_if_only_to_normalized` return type: `Result<Option<...>, ...>`
- Updated `test_return_variable_out_of_scope`: Verifies graceful degradation
- Added `test_if_minimal_compare`: Verifies If lowering structure
**Tests**: 8 passed (including graceful degradation test)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-18 05:50:09 +09:00
f72064f35a
feat(control_tree): Phase 123 P1 return integer literal in Normalized if-only
...
- Add value_ast to StepStmtKind::Return for payload tracking
- Implement lower_return_value for Integer literal → Compute(Const) + Ret
- Add 3 unit tests: integer literal, void, variable fail-fast
- All tests passing (7 passed)
2025-12-18 05:37:13 +09:00
cc1a0946b0
feat(joinir/dev): build Normalized if-only module with structure verification (no behavior change)
...
Phase 122 P2-P3: Dev-only wiring + structure verification
- Wire Phase 122 emission into existing Phase 121 dev path
- Add verify_normalized_structure() for module validation
- Check: phase, function count, entry point, env args count
- Strict mode: fail-fast on structure mismatch
- No behavior change to existing execution path
2025-12-18 04:52:09 +09:00
7603ef8a6a
feat(control_tree): emit Normalized JoinModule for if-only (dev-only)
...
Phase 122 P1: StepTree→Normalized JoinModule generation
- Generate env layout from writes (SSOT, deterministic)
- Minimal implementation: main function + Ret only
- Full If/Assign/Return lowering in future P2-P4
- Dev-only: no behavior change to existing path
2025-12-18 04:50:32 +09:00
89b868703f
feat(joinir/dev): wire Phase 121 StepTree shadow lowering (strict fail-fast)
2025-12-18 04:34:43 +09:00
1e5432f61a
feat(control_tree): add StepTree→Normalized shadow lowerer (if-only, dev-only)
2025-12-18 04:31:41 +09:00
dd125cb700
test(control_tree): cover facts→contract determinism
2025-12-18 04:19:14 +09:00
43d3e7c935
refactor(control_tree): split StepTree facts vs contract boxes
2025-12-18 04:18:37 +09:00
98061260a0
refactor(control_tree): store AST cond handles in StepTree (dev-only)
...
Phase 119: StepTree cond SSOT (AST handle)
- Add AstNodeHandle to StepNode::If and StepNode::Loop
- cond_ast holds Box<ASTNode> clone (dev-only, acceptable overhead)
- cond_sig (AstSummary) remains signature/log material
- signature_basis_string() unchanged (Span-free, deterministic)
- Tests: cond_ast population + signature stability confirmed
2025-12-18 04:09:00 +09:00
052040e59c
refactor(joinir): extract ExitArgsCollectorBox for jump_args SSOT
...
Phase 118 refactoring: Box modularization for exit value collection.
# Changes
- Created `exit_args_collector.rs` with ExitArgsCollectorBox
- Extracted jump_args processing logic from instruction_rewriter.rs
- Implemented SSOT for offset calculation (0 vs 1 legacy layout)
- Added comprehensive unit tests (6 tests, all passing)
# Design
- **Responsibility**: Collects exit PHI inputs + carrier inputs from jump_args
- **SSOT**: Centralized offset calculation logic
- **Fail-Fast**: Validates jump_args length against exit_bindings
- **Phase 118 P2 Contract**: Uses boundary.exit_bindings as SSOT
# Key Features
- Filters ConditionOnly carriers (no exit PHI needed)
- Handles both direct mapping (offset=0) and legacy layout (offset=1)
- Strict mode: Fail-Fast on validation errors
- Non-strict mode: Warns and continues with best effort
# Test Results
- Unit tests: 6/6 PASS
- Phase 118 smoke tests: PASS (VM + LLVM)
- Phase 117 regression: PASS
# Reduced Code Complexity
- instruction_rewriter.rs: ~90 lines → ~25 lines (box call)
- Offset logic: Centralized in ExitArgsCollectorBox
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-18 03:56:21 +09:00
432fc96082
refactor(joinir): extract IfSumExitMetaBuilderBox for Fail-Fast carrier binding
...
Phase 118 refactoring: Box modularization for ExitMeta generation.
# Changes
- Created `exit_meta_builder.rs` with IfSumExitMetaBuilderBox
- Extracted ExitMeta generation logic from loop_with_if_phi_if_sum.rs
- Implemented Fail-Fast contract (carrier name validation)
- Added comprehensive unit tests (5 tests, all passing)
# Design
- **Responsibility**: Builds ExitMeta from carrier name + ValueId
- **Fail-Fast**: Validates carrier names immediately
- **Reusability**: Can be used by other patterns (Pattern 4, etc.)
# Test Results
- Unit tests: 5/5 PASS
- Phase 118 smoke tests: PASS (VM + LLVM)
- Phase 117 regression: PASS
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-18 03:56:10 +09:00
1080dee58f
fix(joinir): Phase 118 Pattern3 exit carrier PHI SSOT
2025-12-18 03:43:00 +09:00
ce7e2c1b91
refactor(env): centralize NYASH_JOINIR_STRUCTURE_ONLY flag
...
Moved NYASH_JOINIR_STRUCTURE_ONLY environment variable handling
from inline std::env::var() in routing.rs to a centralized helper
function in src/config/env/joinir_flags.rs.
Changes:
- Added joinir_structure_only_enabled() helper function
- Replaced direct env::var() call in routing.rs with helper
- Maintains existing behavior: default ON, NYASH_JOINIR_STRUCTURE_ONLY=0/off to disable
- Follows env module centralization pattern (Box Theory: separation of concerns)
Testing:
- cargo test --lib: 1126 passed ✅
- Regression: Phase 107 VM smoke ✅
- Phase 113/114 maintained ✅
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-18 02:19:14 +09:00
09ce24e132
feat(joinir): Phase 112 strict guard for StepTree required_caps
...
- Add control_tree_capability_guard.rs with check(tree, func_name, strict, dev)
- Allowlist: If, NestedIf, Loop, Return, Break, Continue
- Deny (strict): NestedLoop, TryCatch, Throw, Lambda, While, ForRange, Match, Arrow
- Wire into lower_function_body() (strict-only check)
- Error format: [joinir/control_tree/cap_missing/<Cap>] with 1-line Hint
- Unit tests: nested_loop_rejects, if_only_passes, strict_false_passes
- Default behavior unchanged (strict=false always Ok)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-18 01:38:25 +09:00
14730c227f
feat(control_tree): add StepTreeContract and signature (dev-only)
2025-12-18 00:57:58 +09:00
9bcda215f8
refactor(joinir): split Pattern2 orchestrator into smaller steps
2025-12-18 00:44:31 +09:00
e4735f4054
refactor(control_tree): use ASTNode::span SSOT
2025-12-18 00:32:23 +09:00
3987aa5b06
refactor(joinir): drop unused break helper wrappers
2025-12-18 00:30:01 +09:00
e65bb791b9
refactor(builder): route debug logs via trace
2025-12-18 00:29:57 +09:00
2b5c141e22
feat(control_tree): add StepTree builder (dev-only)
2025-12-18 00:22:21 +09:00
a9f92f8f1a
refactor(joinir): add hints for Phase107/104/100 policy rejects
...
- balanced_depth_scan: missing_tail_inc, missing_return_i hints
- read_digits: missing_eos_guard, digit_set_mismatch hints
- pinned: missing_host_id hint
- Gradual migration (representative cases only)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-17 23:45:49 +09:00
2ab460f0a8
feat(joinir): error_tags freeze_with_hint
...
- Add freeze_with_hint(tag, msg, hint) API
- Format: "[joinir/<tag>] <msg> Hint: <hint>"
- Panic on empty hint (must provide actionable suggestion)
- Keep existing freeze() for backward compatibility
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-17 23:45:40 +09:00
27e8e0f16a
refactor(joinir): Phase 108 unify Pattern2 policy routing
2025-12-17 23:30:08 +09:00
3c1d8a824d
feat(joinir): extend balanced depth-scan policy to object family
2025-12-17 23:09:19 +09:00
09dd10349f
refactor(joinir): make Pattern2 body-local handling policy-driven
2025-12-17 23:00:26 +09:00
10a2f3b48b
refactor(joinir): centralize balanced depth-scan policy decision
2025-12-17 22:59:27 +09:00
6036627920
fix(joinir): avoid false rejects in balanced depth-scan policy
2025-12-17 22:52:29 +09:00
d8ce9fdb99
fix(joinir): wire balanced depth-scan policy through Pattern2
2025-12-17 22:47:36 +09:00
9ec2e28b6a
feat(joinir): add Pattern2 post-loop early return step
2025-12-17 22:32:55 +09:00
aa29dc8085
feat(joinir): emit balanced depth-scan derived vars
2025-12-17 22:32:50 +09:00
bf80789757
feat(joinir): route balanced depth-scan via Pattern2 policy
2025-12-17 22:32:43 +09:00
f1a570fd45
feat(joinir): Phase 107 balanced depth-scan policy (analysis-only)
2025-12-17 22:25:34 +09:00
5f4d8ba112
refactor(joinir): Phase 106 Pattern2 step boxes
2025-12-17 22:01:19 +09:00
368b363694
refactor(joinir): split Pattern2 facts from lowering orchestration
2025-12-17 21:34:11 +09:00
ae2a1d4339
refactor(joinir): boxify Pattern2 routing and schedule facts
2025-12-17 21:24:46 +09:00
950560a3d9
test(joinir): Phase 104 read_digits loop(true) parity
2025-12-17 18:29:27 +09:00
d859e46163
fix(llvm_py): tag stringish across copy/phi for concat
2025-12-17 16:57:06 +09:00
27fd9720d0
feat(joinir): string accumulator emitter (JoinIR)
...
- Add StringAccumulatorEmitter in join_ir/lowering/common/
- Emit string concat as BinOp(Add) for polymorphic VM/LLVM handling
- Ensure VM/LLVM same semantics
- Fail-Fast: RHS must be Variable (not Literal/MethodCall)
- Pattern2 wiring: string carrier昇格 + type refinement + validation
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-17 16:33:18 +09:00
ad072e5e09
feat(joinir): string accumulator analyzer/spec
...
- Add AccumulatorKind::{Int, String} to MutableAccumulatorSpec
- Detect string accumulator pattern: out = out + ch (ch is Variable)
- Delegate string-ish type check to existing box facts
- Unit tests for Int vs String accumulator detection
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-17 16:33:11 +09:00
1b83a92aed
test(llvm_py): cover duplicate incoming per pred
2025-12-17 16:12:22 +09:00
0ea2b7d2cb
fix(llvm_py): stabilize PHI incoming selection (no overwrite by failed candidate)
2025-12-17 16:12:16 +09:00
468977e9b3
feat(joinir): allow accumulator as LoopState carrier (Pattern2 + ScopeManager delegation)
...
- Integrate MutableAccumulatorAnalyzer into pattern2_with_break.rs
- Delegate read-only check to ScopeManager (SSOT search order)
- Promote valid accumulators to mutable LoopState carriers
- Accumulator updates handled by existing carrier mechanism
- Fail-Fast: mutable RHS (not supported yet)
- Allow LoopBodyLocal RHS (validated later in lowering)
- loop_body_local_init.rs: Align receiver search order with SSOT (ConditionEnv first)
- Error prefix: [joinir/mutable-acc]
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-17 06:10:50 +09:00