You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Migrator stage: emit safe signatures where a migrated function's body proves its contract (D159) #2615
Ruled D159 (2026-10-24, docs/meetings/2026-10-24-D159-*.md). The migrator gains a stage, after translation and before emission, that emits a safe signature for a migrated function when its body proves the contract:
(a) a pointer parameter the body mutates in place is a mut receiver / inout;
(b) a pointer argument the body stores into the engine's own storage is an ownership transfer ONLY when a destroyer in the same corpus frees it along that path; store alone is "stored, ownership unknown" and the function stays unsafe (Eric's first condition: TommyDS intrusive links and user-data pointers are stored but not owned);
(c) a returned pointer derived from a parameter is a view with that parameter's origin (-> &T from <param>).
An unproved point keeps pub unsafe fn with the unproved point named in the generated comment. Contracts are emitted into the generated source, never hand-edited.
Second condition: the inferred contracts are body-derived facts, so the drift lane (wo-drift) diffs them as their own artifact and a contract change is red until a human has looked (the §3.4 origin-inference lesson).
This is a migrator generation bump: under D112 promoted corpora are not re-promoted until their pin or a ruling moves them; new corpora and re-promotions get contracts. The STC facades (lib/std/collections/*.w) drop their engine-call unsafe at the STC corpus's next re-promotion (18–39 sites per facade today, after #2614's slot API).
Acceptance: the proof reads the C AST the migrator already has; c-migrator-basic-tests cases for each inference and each refusal; a contract diff in the drift lane; a facade calling a proved engine function without unsafe compiles under :user-programs-safe-style scrutiny; D51's test holds for every inference (a wrong one can at worst reject a valid program).
D159 amended (Eric, 2026-10-24): inference (a) uses only the spec's spellings, no new parameter mode. Receiver (mut self) when the engine handle is the first parameter and the body mutates through it; a second pointer parameter the body writes on EVERY returning path is an out-parameter presented as a returned value, T or (status, T) (the modeled-C out param N / ok pattern), sound only when the written record is plain data (Copy, or a copy class rt_core can produce); a record holding an owned pointer falls under inference (b)'s stored-and-freed rule; a conditional write (partial fill, write guarded by the status) stays unsafe fn with "out-parameter written conditionally"; everything else (a second pointer read and written in place, an input/output pointer, a mutated array) is unproved. STC's _insert result record is the motivating out-parameter case.
Step 1 landed: #2619, main d88b39f. with migrate --emit-contracts FILE; every corpus promotion now carries contracts.tsv and the drift report prints changed contract lines. STC fresh (775 functions): 277 receiver-mut, 1 out-parameter, 9 ret-from, 0 owned (slot pushes are stored-unknown: STC's i_keydrop is a no-op, the facade owns the slot), 427 unproved, mostly read-only handles (not in the ruling). Next: step 2 (emission), then the generation bump and the STC re-promotion (step 3), then the contract diff as a gate (step 4). Follow-up brief candidates recorded in the plan: a &self receiver for read-only handles, a consumed receiver for destroyers, owned-through-a-local-alias (TommyDS/STC free via a walked local).
step 2 (c841754, Migrator contracts, step 2 (D159, #2615): a proved function is printed as a method of its record #2623): a proved function is printed as pub mut fn of its record; out-parameters return (T / (status, T)); return self is -> &R from self; corpus calls print as method calls; refusals: NULL-accepting handle, NULL-returning path, unit static, multi-definer header, variadic, name collision; every corpus lane green, pcre2test passes upstream RunTest;
Left as briefs for a ruling (docs/proposals/migrator-contracts-plan.md): a &self receiver for the read-only surface (343 STC rows; the facades' remaining 93 read calls), and an owned parameter stored into a record ((b) emission, a representation change).
Activity
docs: D157 (List stays rt_core; STC vec a comparison engine), D158 (n…
ehartford commentedon Oct 25, 2026
D159 amended (Eric, 2026-10-24): inference (a) uses only the spec's spellings, no new parameter mode. Receiver (
mut self) when the engine handle is the first parameter and the body mutates through it; a second pointer parameter the body writes on EVERY returning path is an out-parameter presented as a returned value,Tor(status, T)(the modeled-Cout param N/okpattern), sound only when the written record is plain data (Copy, or a copy class rt_core can produce); a record holding an owned pointer falls under inference (b)'s stored-and-freed rule; a conditional write (partial fill, write guarded by the status) staysunsafe fnwith "out-parameter written conditionally"; everything else (a second pointer read and written in place, an input/output pointer, a mutated array) is unproved. STC's_insertresult record is the motivating out-parameter case.Migrator contracts, step 1 (D159, #2615): the contracts artifact, bes…
ehartford commentedon Oct 25, 2026
Step 1 landed: #2619, main d88b39f.
with migrate --emit-contracts FILE; every corpus promotion now carriescontracts.tsvand the drift report prints changed contract lines. STC fresh (775 functions): 277 receiver-mut, 1 out-parameter, 9 ret-from, 0 owned (slot pushes are stored-unknown: STC's i_keydrop is a no-op, the facade owns the slot), 427 unproved, mostly read-only handles (not in the ruling). Next: step 2 (emission), then the generation bump and the STC re-promotion (step 3), then the contract diff as a gate (step 4). Follow-up brief candidates recorded in the plan: a&selfreceiver for read-only handles, a consumed receiver for destroyers, owned-through-a-local-alias (TommyDS/STC free via a walked local).Migrator contracts, step 2 (D159, #2615): a proved function is printe…
Migrator contracts, step 3 (D159, #2615): STC re-promoted, the facade…
Migrator contracts, step 4 (D159, #2615): the contracts artifact unde…
ehartford commentedon Oct 25, 2026
Done, in four steps on main:
--emit-contracts,contracts.tsvbeside each promoted corpus, the drift report diffs it);pub mut fnof its record; out-parameters return (T/(status, T));return selfis-> &R from self; corpus calls print as method calls; refusals: NULL-accepting handle, NULL-returning path, unit static, multi-definer header, variadic, name collision; every corpus lane green, pcre2test passes upstream RunTest;migrator-pin:#2615; an indexed handle is an array, never a receiver; iterator functions are named after the iterator; the facades call the methods, engine-call unsafe 370 -> 318 across lib/std/collections;contracts.tsvunder the corpus integrity hash (a hand edit is refused), a promotion prints the proofs it moves.Left as briefs for a ruling (docs/proposals/migrator-contracts-plan.md): a
&selfreceiver for the read-only surface (343 STC rows; the facades' remaining 93 read calls), and an owned parameter stored into a record ((b) emission, a representation change).STC re-promoted under migrator-pin:#2615 (Amendment 2): the facades c…
Migrator contracts, step 5 (D159 Amendment 2): the read receiver; own…