Skip to content

D30: runtime definitions inherit their extern's declared contract; runtime libc blocks are not program facades - #2482

Merged
ehartford merged 3 commits into
mainfrom
d30-runtime-contracts
Oct 20, 2026
Merged

ehartford merged 3 commits into
mainfrom
d30-runtime-contracts

Conversation

@ehartford

Copy link
Copy Markdown
Contributor

D30: the last lane red closed without a seed cut, plus a lane regression #2481 introduced.

Under the lane, all fresh: behavior (non-spawning) 1701/1701, compile_errors 1790/1790, spec + internals 282/282.

Battery GREEN on 288a2bd (with run tools/battery.w, rc=0, 248 s).

Eric Hartford added 3 commits October 19, 2026 23:48
… extern it replaces

std.thread declares `@[effect(fn_ptr: escape_value, ctx: escape_value)] extern fn with_thread_spawn`: the thread keeps the closure. Under WITH_RT_IN_UNIT the runtime's definition won and the extern was dropped with its pins, and the definition's own inference cannot see retention through a raw pointer (a pointer parameter's inferred effects are read-only by design), so a closure holding a view of its frame was spawned unrefused (err_thread_spawn_closure_captures_ref, red under the lane). The frontend keeps a dropped pinned extern for its runtime definition (Zcu.note_runtime_contract_extern, in the prelude tier where std's externs drop and in the program tiers); Sema applies its pins to the definition's signature as an extern's, and they survive that body's inference. One fact in one place: no seed-compiled source changes, so #2481's seed-gated rule for pins on runtime definitions is removed unused.
Two places treated the in-unit runtime's `c facade libc` blocks as the program's: inject_toolchain_facades counted them as claims, so the toolchain libc facade's text lost `domain environ` while its getenv row still named it, and every program using getenv failed under WITH_RT_IN_UNIT (61 lane files, after #2481's domain rule made the omission visible); and the domain rule judged a facade block by current_module_path, which names whatever module was checked last when facade items are collected. Claims skip `<embedded-rt>/` facades, and a block is the runtime's by its own declaration's path.
@ehartford
ehartford merged commit 1fea661 into main Oct 20, 2026
@ehartford
ehartford deleted the d30-runtime-contracts branch October 20, 2026 07:24
ehartford added a commit that referenced this pull request Oct 20, 2026
… seed nightly-20261020-local-1-e1d2b25e6d04 (#2492)

* D30 step 2 (part 2): the runtime definitions declare their own contracts; seed nightly-20261020-local-1-e1d2b25e6d04

The @[effect] pins move from lib/std's and src/'s externs onto the rt/
definitions — with_thread_spawn (fn_ptr, ctx: escape_value),
with_vec_push_str (val: escape_value), with_vec_append_bytes (v: write) —
and #2482's extern-inheritance (Zcu.note_runtime_contract_extern,
Sema.runtime_contract_externs) goes: one fact in one place, the
definition, which is what the runtime bundle's interface carries.

A runtime ABI definition's pin is applied at declaration, as an extern's
pin is, and kept through the body's inference: applied only after the
body check it was too late — std.thread's spawn_os is checked before the
runtime's body, and read `worker` as consume alone, so the lane twin of
err_thread_spawn_closure_captures_ref stayed green by accident of the
inherited extern and red without it. Under the lane spawn_os.worker now
reads escape_value exactly as in the object world.

tools/rt_decl_audit.w compares @[effect] pins beside parameter types: on
the tree before this commit it reports the five pinned externs against
their unpinned definitions (the gate on deleting the externs, plan §10
correction 3); here 0 divergent over 1216 definitions.

seed.lock: nightly-20261020-local-1-e1d2b25e6d04, the first seeds whose
Sema accepts the pins on rt/ (the seed compiles rt/ for stage1): darwin
cut on the laptop (fixpoint over 16 units, :release-checks green),
linux-x86_64 on eric-5090, windows-x86_64 on win10 (fixpoints).
linux-aarch64 is held on the 10-15 release (#2490: its seed cannot
bootstrap main) and windows-aarch64 until the dispatched cross seed is
pinned (D137). Workflow pins moved with tools/bump_seed_pins.w.

* D30 plan §10: step 2 landed; handoff: the darwin host is the laptop (studio128 is gone, Eric 2026-10-20)

---------

Co-authored-by: Eric Hartford <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant