Repository navigation
Modeled C stage 11: convention profiles (ruling §7, §59) - #1628
Merged
Merged
Conversation
ehartford
force-pushed
the
modeled-c-stage11
branch
from
September 24, 2026 16:43
25427fb to
2b34ceb
Compare
ehartford
force-pushed
the
modeled-c-stage11
branch
from
September 24, 2026 16:52
2b34ceb to
2fe62d5
Compare
ehartford
force-pushed
the
modeled-c-stage11
branch
from
September 24, 2026 17:30
2fe62d5 to
3417ff1
Compare
added 4 commits
September 24, 2026 13:32
…rofile's import (ruling §7, §59; §16.2b.12) A convention profile is the block `c convention pkg.vN:` in the module `pkg.vN`; its rules are `<name>: <template>` — a resource clause over a name pattern (`unref: drop *_unref`, `open: from *_open(out param 1)`) or an fn-item clause (`get: fn *_get lend`). `use convention pkg.vN` inside a facade is also the import `use pkg.vN` (a synthetic use decl), so the profile resolves, pins and reports through ordinary package rules and an unknown package is the unresolved-import error naming it. AST: NK_C_CONVENTION, NK_FACADE_RULE, NK_FACADE_PROFILE_MATCH; a clause a profile states carries its rule as a trailing operand (facade_clause_profile_rule), the fact's provenance.
… (ruling §7.1, §7.2) compiler/FacadeProfile.w: for each `use convention` item, every rule of the profile is matched against the imported declarations by name pattern and by the shape the clause needs (a drop takes the representation alone, a destroys/init takes it first, a from returns it or fills the named out parameter); an fn rule's candidates are the rules matching one function whose first parameter receives a resource of the facade. Exactly one valid candidate states the clause on the item; zero or several contribute nothing, and an explicit clause of the fact's class shadows the profile's. Every outcome is an NK_FACADE_PROFILE_MATCH on the item. A module that resolved but declares no such block is an error naming the package.
…he two audit:contract profile checks (ruling §8, §63) A profile-stated clause is collected and verified like any clause; its provenance prints as `profile:pkg.vN:rule@file:line` in the contract view. Sema warns on an ambiguous match, naming the profile, the rule, the item, the candidates and the clause that resolves it. audit:contract reports an ambiguous profile match as a violation and a profile fact shadowed by an explicit clause as a note; the `use convention` subject lists every rule's outcome.
…shadowed, ambiguous, unknown, bad rule), stage 11 derived decisions test/lib/gobject/v1.w is the suite's profile, reached from every fixture under test/ by the module walk. A behavior fixture proves a profile supplies production and destruction (unref exactly once); contract fixtures snapshot the profile provenance, the shadowed notes and the two ambiguous violations; compile-error fixtures pin the unknown package, the package without a block, the ambiguity that leaves a resource half-modeled, and a rule stating a clause a profile may not. The audit summary line gained profile-ambiguous/profile-shadowed counts (ok_sqlite_shaped updated).
ehartford
force-pushed
the
modeled-c-stage11
branch
from
September 24, 2026 17:32
3417ff1 to
76d4bf5
Compare
ehartford
marked this pull request as ready for review
September 24, 2026 18:50
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 11 of
docs/modeled-c-implementation-plan.md:use convention pkg.vNadopts a versioned convention profile; unique-or-nothing; explicit clauses override; provenance and the twoaudit:contractprofile checks.What lands
src/Parser.w,src/Ast.w): a profile is the blockc convention pkg.vN:in the modulepkg.vN; rules are<name>: <template>— a resource clause over a name pattern (unref: drop *_unref,new: from *_new,open: from *_open(out param 1),init: init *_init(self),free: destroys *_free) or an fn-item clause (get: fn *_get* lend,dispose: fn *_dispose destroys).use convention pkg.vNin a facade is also the importuse pkg.vN(synthetic use decl), so the profile resolves, pins and reports through ordinary package rules; an unknown package is the unresolved-import error naming it, a package that resolves but declares no block is an error naming the package.src/compiler/FacadeProfile.w, run fromFrontend.wafter c_import translation and before the facades render): candidates are judged by name pattern and by the shape the clause needs (the same shape Sema's verification reads). One valid candidate states the clause on the item, carrying its rule as a trailing operand (facade_clause_profile_rule) — the fact's provenance; zero or several contribute nothing; an explicit clause of the fact's class shadows the profile's. Every outcome is anNK_FACADE_PROFILE_MATCHrecord on theuse conventionitem.src/SemaFacade.w,src/AnalysisContract.w): profile-stated clauses are verified like any clause; the contract view printsprofile:gobject.v1:unref@test/lib/gobject/v1.w:15as the provenance of every profile-derived fact and lists each rule's outcome under theuse conventionsubject; Sema warns on an ambiguous match (profile, rule, item, candidates, fix-it);audit:contractreports "ambiguous profile match" as a violation and "profile fact shadowed" as a note (the two stage 10 stubs now fire).Fixtures
test/lib/gobject/v1.w— the suite's profile, reached from every fixture undertest/by the module walk;test/lib/noprofile/v1.w— a module with no block.test/behavior/behav_c_facade_profile_supplies_drop.w— the profile suppliesfrom obj_newanddrop obj_unref(andcounter_newmatches the name but not the shape); unref runs exactly once.test/contract/ok_profile_applied.w(+.expected),ok_profile_shadowed.w(+.expected, two shadowed notes),bad_profile_ambiguous.w(a resource rule with two candidates and two fn rules claiming one function: both contribute nothing, two violations).test/compile_errors/err_c_facade_profile_unknown.w,err_c_facade_profile_not_declared.w,err_c_facade_profile_ambiguous_no_drop.w(ambiguity leaves the resource half-modeled: the warning and the never-half-model error),err_c_convention_bad_rule.w.ok_sqlite_shapedneedle/snapshot updated for the audit summary's newprofile-ambiguous=/profile-shadowed=counts.behav_c_facade_parses.w(which already adoptsgobject.v1) now resolves the real profile; none of its rules match that fixture.Derived decisions
Recorded under Stage 11 in
docs/modeled-c-implementation-plan.mdwith the sections they read from: the profile surface (§7 "ordinary With package rules", §59's examples, §8's "rule unref" naming), what a rule may state (only clause kinds the pass can judge per candidate from the declaration's shape; parameter/origin clauses stay on the fn item), candidates and uniqueness (§7.1; a rule applying to forty operations is the intended use, two rules claiming one operation is the ambiguity), overrides (§7.2/§4: same-class clause shadows; suppression without replacement is not ruled and not invented), and where the pass runs (the renderer reads clauses off the AST).Verification (iterate tier)
check src/main.wok;with build :devgreen twice.analyze audit:allok on the new clean fixtures;with build :contract-view-tests: 9 fixtures, every audit verdict, needle and snapshot agreed.with testover everybehav_c_facade*,behav_sqlite_facade*,err_c_facade*,err_sqlite_facade*fixture and the new ones: all pass exceptbehav_c_facade_libc_system_headers.w, which fails identically on a cleanorigin/mainworktree with the same seed — it is c_import: a user module's <string.h> memchr wrapper hijacks std.re's memchr when std.re compiles from source (stage1) #1485 (stage1-only<string.h>memchrwrapper hijackingstd.re), not this change.with build :spec-inventory-checkgreen (the new words are contextual identifiers; no keyword row).No
:fixpoint/:test/drop-move audits run here (coordinator folds into the stack's battery).