Repository navigation
Modeled C stage 10: with analyze contract view (ruling §63) - #1614
Merged
Merged
Conversation
Contributor
Author
|
Iterate-tier evidence (stage1 driver in the worktree, SDKROOT=CLT 15.4):
|
added 3 commits
September 24, 2026 06:14
…ance (D51 stage 10, ruling §63) A `foreign-contract` AnalysisFactKind and a collector over Sema's facade records (resources, fn items, domains, callback parameters, `use convention`): one subject row each and one row per effective fact — production, status, destroy paths, dependency, thread capabilities, views and their invalidators; parameter effects, result origin, preservation, presentation; callback role, thread and reentrancy — each ending in its provenance, the facade clause with file and line or the conservative default that supplied it (§16.2b.2). Read-only: nothing here changes a verdict (ruling §2.3). `audit:contract` (in `audit:all`) is the ruling's suspicious-configuration list — producer with no destroy path, destroyer presented as a lend, retained parameter with no lifetime owner, illegal thread combination, and the advisory destroyer-shaped borrow that an explicit `lend` silences; the profile checks wait for stage 11. `with analyze file.w contract` prints the rows in order with the verdict, and both requests read Sema's snapshot so a refused clause is still named.
…res for the contract view (stage 10) test/contract/ok_sqlite_shaped.w is a facaded SQLite-shaped header with its `contract` view checked in (ok_sqlite_shaped.expected); each bad_*.w plants one of the ruling's suspicious configurations and states the audit lines it expects. The action analyzes fixtures by project-relative path so the snapshot's paths are stable, requires bad_ fixtures red and ok_ fixtures green under audit:contract and audit:all, and compares the view byte for byte. In :test.
…age 10's CLI spelling settled (contract)
ehartford
force-pushed
the
modeled-c-stage10
branch
from
September 24, 2026 10:15
43d9243 to
8c555cb
Compare
ehartford
marked this pull request as ready for review
September 24, 2026 14:12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stage 10 of the modeled-C campaign (
docs/modeled-c-implementation-plan.md"Stage 10"; ruling §63, §2.3; spec §16.2b.2, §18.5). Based on main, not on stage 9 (#1606).What lands
ForeignContractfact kind (AnalysisFactKind.ForeignContract = 25,foreign-contract) and a collector inanalysis_collect_sema(src/AnalysisContract.w). One subject row per resource, fn item, domain, callback parameter anduse convention; under it one row per effective fact: production and initialization state, status convention, automatic and alternate destroyers, dependency/independence, thread capabilities, the views borrowed from a resource and the operations that invalidate or preserve them; per fn item each parameter's effect (lend, consumes [+ destroyed_by], retains-by, destroys, out-slot, callback-scope borrow), the result's origin (borrow from param/domain, static, raw), invalidation and preservation, presentation (of,rename, the presented method); per callback its role (scope borrow, retained by, destroy path), thread and reentrancy; per domain its scope, library, views and invalidators. Every row ends[clause:<name>@<path>:<line>]or[default:<rule>]; subject rows carryfacade:<name>@<path>(§16.2b.2 facade identity).audit:contract(inaudit:all): producer with no destroy path; destroying operation presented as a lend; retained parameter/callback with no lifetime owner; illegal thread combination (sendwithoutdrop_any_thread;creatorwithsend/share); and the ruling's advisory — a name segment (close,free,destroy,release,finalize,unref, …) plus a signature taking a resource's representation, exposed with nothing stronger than the described-fn lend — printed in the ruling's four-line form and silenced by an explicitlend. Each violation names the clause, its line and the clause that resolves it.with analyze file.w contract: the rows in order (subject rows as headings, fact rows indented) followed by the audit's notes, violations and a verdict without the fact count, so a snapshot of it does not move with the prelude.contractandaudit:contractare semantic-snapshot requests (Compilation.w): they readlast_semawhen Sema refused a clause, sobad_no_destroy_path.w(a §16.2b.3 compile error) is still named by the audit.test/contract/and thecontract-view-testsaction (in:test).ok_sqlite_shaped.w— a facaded SQLite-shaped header (out-parameter production,SQLITE_OK,close/close_v2, dependentStatement, borrowederrmsg/column_text,db_handleborrowed resource, consume-with-destroy-callback, retained trace callback + userdata, thread capabilities,rename/ofpresentation, anerrnodomain, staticlibversion) with itscontractview checked in byte for byte; onebad_*.wper suspicious configuration, each stating the audit lines it expects (//! expect-contract:/-not:), red underaudit:contract;ok_fixtures must be green underaudit:alltoo.docs/deep-debugging-tools.md, CLAUDE.md's request list, and the plan's stage 10 paragraph (spelling settled).Derived decisions (ruling silent; each at worst removes capability)
contract— the plan's proposal, adopted;audit:contractfor the checks alone.report.violationsentry, not a note. §63: "advisory only … must not change the effective contract, classify the function as destroying, remove the operation, or grant/revoke safety capability." A red audit verdict is none of those — the compiler's verdicts are untouched — and it is the only channel that makes a tool say "review this". The text says so in the ruling's own words. An explicitlend"records that the facade author deliberately reviewed the operation" and silences it.creator+send/shareis flagged as illegal. §48:thread creatormeans operations, destruction and ownership stay on the creating thread; §49-§50 makesend/sharecapabilities beyond that. Stating both is a contradiction the compiler does not yet refuse; flagging it removes nothing.contractview, not the fullfactsTSV. The TSV is stable in format, but itsid/node/symbol/typecolumns are pool- and prelude-relative and would churn with every stdlib change; the view carries the same row text (detail) with paths and lines, and the audit needles pin the violations.facade:<name>@<path>. §16.2b B.8'sfacade:<package>@<version>needs a package-shipped facade, which Sema does not model yet (no package/version on a facade block); the block's file path identifies it honestly today and the@<version>form follows when packages ship facades.with_*, which no user program calls); every library operation is named.use conventionis present.Stage 9 tolerance
Stage 9's
callback param N userdata param Mrecords and its new Sema errors (retains … bya non-resource, consumed-and-retained userdata) are not on main. The collector reads only fields that exist on main;bad_retained_no_owner.wcompiles on main and becomes a compile error once #1606 lands — the audit still names it, because both requests read Sema's snapshot. Nothing here needs rebasing on #1606.Verification
with-stage1 check src/main.wgreen;with build :devgreen;with build :spec-inventory-checkgreen (no new CLI command:contractis ananalyzerequest, and the spec already describes the view).analyze … contract/audit:contract/audit:allon everytest/contractfixture;audit:allgreen on the stage 5-8 fixtureschild_drop_order,domain_errno,presentation_methods,text_view,facts_verify,presentation_ambiguous,dependent_ok.behav_c_facade_resource_in_place_pinned.wis red underaudit:allon main and the installed compiler too (receiver-audit and codegen-marshalling rows, not the contract audit): filed as analyze audit:all red on behav_c_facade_resource_in_place_pinned.w: receiver-audit sig mismatch and a with_free call with no Codegen marshalling fact #1613.with build :contract-view-testsand:deep-debug-tool-tests: see the battery comment below.Draft until the seed-driven battery is green (D56).