Skip to content

Migrator contracts, step 1 (D159, #2615): the contracts artifact, beside each corpus, diffed by the drift lane - #2619

Merged
ehartford merged 4 commits into
mainfrom
migrator-contracts
Oct 25, 2026
Merged

ehartford merged 4 commits into
mainfrom
migrator-contracts

Conversation

@ehartford

Copy link
Copy Markdown
Contributor

D159 step 1 of 4 (#2615, docs/proposals/migrator-contracts-plan.md): the contracts artifact. No signature changes yet.

What a body proves (CImport.ci_body_contract_evidence, over the C AST the migrator already has): writes through a parameter, a parameter stored into a field of another, a field freed or handed to a callee, and the out-parameter proof over the body's top-level statements (a whole write *p = … before every return and before any other use of p).

The verdicts (src/CiContracts.w, a corpus-wide pass after D107's nullability and D121's ownership proofs): receiver-mut:<R> (a1, direct or through a corpus callee, a fixpoint), out:<i>:<T> / out-record:<i>:<R> (a2), owned:<i> only when a corpus function frees the field the parameter was stored into (b, both halves; store alone is stored-unknown), ret-from:<i> (c), and unproved:<i>:<why> for everything else, read-only handles included (not in the ruling).

The artifact. with migrate --emit-contracts FILE writes name<TAB>verdicts, sorted. build/corpus.w asks for it beside the generated modules; promotion copies contracts.tsv into the corpus; the drift report prints changed contract lines one by one (the ruling's second condition; the gate on a change is step 4, once promoted contracts exist).

Evidence. bs_check_migrate_contracts covers each verdict and refusal on a twelve-function corpus. A fresh STC migration (775 functions): 277 mutating receivers, 1 out-parameter, 9 borrowed returns, 0 owned (every slot push is stored-unknown: STC's i_keydrop is a no-op, the facade owns the slot, as D148 built it), 427 unproved, mostly read-only handles.

Found on the way: #2618 (a compiler module calling List[str].sort() does not link stage1).

Battery: seed-driven, posted below when green.

Eric Hartford added 4 commits October 24, 2026 21:01
…rtifact first, then emission, then the generation bump and the STC re-promotion
…at each migrated function's body proves about its pointers, drawn once per corpus, written beside the modules, diffed by the drift lane

CImport.ci_body_contract_evidence reads one body's C AST for `mutparam:` (a write through a parameter), `fieldstore:` (a parameter stored into a field of another), `freesmember:`/`memberarg:` (a field freed, or handed to a callee), and the out-parameter proof over the body's top-level statements (`outfull:` when `*p = …` precedes every return and every other use; `outcond:` with the reason otherwise). CiContracts resolves the verdicts over the whole corpus with D121's ownership proofs: receiver-mut:<R> (a1, direct or through a corpus callee, a fixpoint), out:<i>:<T> / out-record:<i>:<R> (a2), owned:<i> only when the field a parameter is stored into is freed by a corpus function (b, both halves; store alone is stored-unknown), ret-from:<i> (c), and unproved:<i>:<why> for everything else, a read-only handle included (not in the ruling). `with migrate --emit-contracts FILE` writes name<TAB>verdicts sorted; build/corpus.w asks for it beside the generated modules, promotion copies contracts.tsv, and the drift report prints changed contract lines one by one. No signature changes yet (step 2). Basic test bs_check_migrate_contracts covers each verdict and refusal. A compiler module calling List[str].sort() does not link stage1 (#2618), so the artifact sorts by insertion.
@ehartford

Copy link
Copy Markdown
Contributor Author

Seed-driven battery GREEN on 2e02048 (wall 647 s; the first run's only red was pub-lint-check on the new setter, made package-private).

@ehartford
ehartford marked this pull request as ready for review October 25, 2026 01:30
@ehartford
ehartford merged commit d88b39f into main Oct 25, 2026
@ehartford
ehartford deleted the migrator-contracts branch October 25, 2026 01:30
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