cli: restrict source scope names to lexical task operands

This commit is contained in:
dev committed 2026-10-07 19:50:49 +03:00
1 parent 364eb57bbc
commit 9001e56325
32 files changed
+307 -6

No files matched your search

+10
View File
@@ -113,3 +113,13 @@ The invariant is unchanged acceptance, ownership/loan verification and determini
Compatibility review found legacy payload collisions: unsupported AIR narrowing and unknown source capability kinds each emitted a second `kind`, and unlock with a live guard borrow emitted `borrow` twice. Ordinary JSON consumers lost the stable machine kind or one identity. Spec 10 §2 requires unique names and reserves envelope fields. Capability payloads use `capability_kind`; unlock reports the selected `borrow` and its `guard` separately, retaining the borrow seen by former last-key-wins readers. Clients must read the capability payload by its new name; stable diagnostic kinds are restored rather than redefined.
These are diagnostic corrections, not new source/AIR or ownership/concurrency rules. Existing rejection codes, positions, conflict selection, guard/loan state and deterministic execution remain unchanged; valid capabilities and guard programs remain accepted. Pipeline/CLI tests reproduce the three cases, the verifier unit helper checks payload uniqueness across its existing rejection tests, and conformance validates every final mapped diagnostic's fields and serialized JSON. The invariant is an unambiguous machine diagnostic without hidden loss of context. Budget growth is recorded in docs/agent/README.md; no repair candidate or measured MCC benefit is introduced.
## DD-020 — Source scope names are lexical identifiers
Spec 15 §7 resolves Q-041: the name introduced by `scope s` is only the named first operand of `task.spawn`, not an ordinary source value. Lowering rejects plain/moved aliases and value expressions before suggesting a transfer. Ordinary lexical shadowing remains legal; block completion retains its original SSA identity independently of source lookup. This removes an apparent ownership transfer that formerly neither consumed nor changed completion of the handle.
The invariant is one retained completion obligation per source scope, with every child joined and every loan released before completion. Existing AIR verification, including E4301/E4302 and function-local scope flow (spec 04 §33), remains authoritative and unchanged. No runtime rule, instruction, feature, syntax, verifier state or interpreter behavior changes. Shield handles and lock guards already have no source value names; task values remain ordinary linear values.
Valid: `scope s { let t = task.spawn(s, work); let s = 0u64; let n = task.join(move t); }`. Rejected: `scope s { let alias = move s; }` (E7006, existing reason `invalid_expression`, fields `name`/`type: scope`); plain aliases, yields, returns, aggregates and ordinary arguments are rejected likewise. Borrowing keeps `invalid_place`, assigning the immutable identifier keeps `invalid_assignment`, and a moved/non-scope spawn operand keeps E7005. The existing structured reason plus type identifies the category without reading prose; no additional reason is needed.
Compatibility: formerly accepted scope aliases, spawning through an alias or the apparently moved original, standalone scope names and block/scope tails now reject. Accepted shadowing, nested scope lookup, cleanup at fall-through/return/break/continue, and all AIR format-0 programs retain their meanings. Public source conformance covers accepted/rejected forms, specialized bodies and live children; CLI tests cover exact reasons/locations, packages and deterministic/hosted execution. Scheduler stress and per-instruction collection check cleanup. Source documentation growth is measured in docs/agent/README.md. The change improves explicitness and repairability without an empirical MCC claim; it does not finish P6-2.