cli: restrict source scope names to lexical task operands
This commit is contained in:
1 parent
364eb57bbc
commit
9001e56325
32 files changed
+307
-6
No files matched your search
@@ -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.
|
||||
@@ -33,7 +33,7 @@ Status values: `open`, `resolved`.
|
||||
| Q-036 | resolved | STD-6a | Dynamic initialized linear buffer storage and drain |
|
||||
| Q-038 | resolved | STD-6d.2 | Pure construction of built-in errors |
|
||||
| Q-039 | resolved | STD-6d | Explicit static function parameters |
|
||||
| Q-041 | open | P6-2 task block forms | Source scope-handle value bindings |
|
||||
| Q-041 | resolved | P6-2 task block forms | Source scope-handle value bindings |
|
||||
|
||||
## Q-001 — Text AIR grammar
|
||||
|
||||
@@ -304,3 +304,5 @@ P6-8 review found an existing parser ambiguity: `if true { *p = 2u64; } *p = *p
|
||||
Independent E7006 review found that `module scope_move fn main()->u64 effects [] { scope sc { let alias = move sc; } 42u64 }` checks and returns 42 with fuel 10,000. Its AIR contains only `task.scope.begin` and `task.scope.end` on the same SSA value; the unused alias introduces no instruction. This observation alone establishes no memory/concurrency safety defect. Spec 15 §3 excludes `scope` from source type spellings, §7 ties scope completion to the block, and spec 04 §33 permits function-local scope flow while preserving linear completion. They do not explicitly say which ordinary source value-binding forms may name that internal handle or how an explicit transfer interacts with the block's retained completion obligation.
|
||||
|
||||
Clarify whether `let`/`move` aliases and rebinding of a scope name are permitted, how their availability relates to the originating block, and which existing diagnostic applies to rejected forms. Keep AIR scope identity, live-child/loan checks, deterministic completion and the no-escape invariant intact; add source acceptance/rejection tests for the chosen contract before changing lowering. This is separate from DD-017's reason field and RFC 0038's proposed repairs; neither adopts a new scope rule.
|
||||
|
||||
**Resolved (DD-020, spec 15 §7):** a source scope name is a lexical identifier usable only as the named first operand of `task.spawn`. Ordinary `s`/`move s` value uses reject E7006 `invalid_expression`, with `name` and `type: scope`; borrowing remains E7006 `invalid_place`. Ordinary shadowing remains legal and never replaces the originating block's saved completion identity. Source/AIR tests retain existing live-child and loan rules, deterministic completion and function-local AIR scope flow. Previously accepted aliases and scope-valued expressions now reject; no new syntax, reason, code or verifier/runtime state is added. This resolves one P6-2 question, not the phase.
|
||||
Reference in new issue
Block a user