Files
hakorune/docs/development/current/main/phases/phase-130/README.md

88 lines
3.3 KiB
Markdown
Raw Normal View History

# Phase 130: if-only Normalized “Small Expr/Assign” Expansion (dev-only)
Status: PLAN (P0P3)
Scope: if-only NormalizedStepTree → Normalized shadow pipeline
Related:
- Entry: `docs/development/current/main/10-Now.md`
- Phase 129 (join_k/post_k): `docs/development/current/main/phases/phase-129/README.md`
- ControlTree SSOT: `docs/development/current/main/design/control-tree.md`
## Goal
Increase usefulness of the if-only Normalized path without touching loop lowering yet:
- Enable minimal post-if computation (`x = x + 3`) and returns via env.
- Keep **PHI禁止**: merge via env + continuations only.
- Keep **dev-only** and **既定挙動不変**: unmatched shapes fall back (strict can Fail-Fast for fixtures).
## Non-Goals
- No loops (Loop/Break/Continue still rejected by capability guard).
- No general expression lowering (start with one narrow shape only).
- No new env vars (use existing `joinir_dev_enabled()` / `joinir_strict_enabled()`).
## Work Items (P0P3)
### P0: Fixtures + Smokes (VM + LLVM EXE)
Add a “post-if update then return” fixture that forces post_k to execute and tests env updates:
- New fixture: `apps/tests/phase130_if_only_post_if_add_min.hako`
- Case A: `flag=1` → expected `5`
- Case B: `flag=0` → expected `4`
- Output: `5\n4`
- Smokes (integration):
- `tools/smokes/v2/profiles/integration/apps/phase130_if_only_post_if_add_vm.sh`
- `tools/smokes/v2/profiles/integration/apps/phase130_if_only_post_if_add_llvm_exe.sh`
- Use `output_validator.sh` numeric-line assertion.
- LLVM EXE smoke uses `llvm_exe_runner.sh` + plugin gating.
Acceptance:
- `phase130_*_vm.sh` PASS
- `phase130_*_llvm_exe.sh` PASS (SKIP allowed only if LLVM prerequisites missing; plugin prerequisites should be satisfied via existing runner)
### P1: Assign(Variable) minimal
Support `x = y` inside post_k (and/or inside branches) for if-only:
- Only local variables (no field/property assign).
- RHS must resolve from env (`writes` or `inputs`).
- strict: unsupported shapes → `freeze_with_hint("phase130/assign/var/unsupported", ...)`.
### P2: Assign(Add) minimal for integers
Support `x = x + <int literal>` (exact shape) in post_k:
- Strictly `Var + IntLiteral` with `lhs_var == dst_var` (no commutation, no general binop).
- Type: integer only (string concat stays out-of-scope; Fail-Fast under strict).
### P3: Verifier tightening (env writes-only discipline)
Add a structural check to ensure env updates only target `writes` fields:
- In Normalized emission, any “env update” must update a field that exists in `EnvLayout.writes`.
- Writing to an `inputs` field is prohibited (strict Fail-Fast).
## Verification
Commands:
```bash
cargo test --lib
# New Phase 130 smokes
bash tools/smokes/v2/profiles/integration/apps/phase130_if_only_post_if_add_vm.sh
bash tools/smokes/v2/profiles/integration/apps/phase130_if_only_post_if_add_llvm_exe.sh
# Regressions (minimum)
bash tools/smokes/v2/profiles/integration/apps/phase129_if_only_post_if_return_var_vm.sh
bash tools/smokes/v2/profiles/integration/apps/phase129_join_k_as_last_vm.sh
bash tools/smokes/v2/profiles/integration/apps/phase128_if_only_partial_assign_normalized_vm.sh
```
## Notes
- Phase 130 intentionally stays “if-only” to keep the change-set small and correctness-focused.
- Loop lowering in Normalized is a separate phase; do not mix scopes.