Repository navigation
feat: cross-module @rt_safe/@lifetime summaries (#765) - #1342
Merged
Merged
Conversation
godofecht
marked this pull request as ready for review
October 4, 2026 20:18
cursor
Bot
force-pushed
the
cursor/rt-lifetime-import-summaries-64d0
branch
from
October 4, 2026 20:41
109a0a8 to
9e2ef6a
Compare
Add a compact $fname effect/lifetime summary for public functions (callback/frame safety, alloc/free, block/lock, I/O, declared domain, one provenance edge) and consult it during type checking so imported calls compose. Summaries ride in the module effect table and are erased before codegen. Co-authored-by: Abhishek Shivakumar <[email protected]>
The edited compiler rejected immutable reassignment and a bare null string in the new summary worklist and selftest. Co-authored-by: Abhishek Shivakumar <[email protected]>
typecheck and sem_check import the new module, so per-module compile and the frontend link need its object. The overload-integration lang test imports typecheck.flow, so its recorded MLIR digest picks up the new module. Co-authored-by: Abhishek Shivakumar <[email protected]>
cursor
Bot
force-pushed
the
cursor/rt-lifetime-import-summaries-64d0
branch
from
October 4, 2026 21:23
fd69831 to
b308094
Compare
Rebased onto #1337 string/IO (7b2dccb). Bootstrap C is the fixed point of compiler/src including concatn lowering and the cross-module RT/lifetime summary slice. Co-authored-by: Abhishek Shivakumar <[email protected]>
8 tasks done
cursor Bot
pushed a commit
that referenced
this pull request
Oct 4, 2026
Rebased onto ee7432b (#1342). Source keeps FLOWC_PROFILE plus rt_summary/type_id selftests. Regen fixed point at gen2; --verify matches compiler/src. Co-authored-by: Abhishek Shivakumar <[email protected]>
7 of 8 tasks
cursor Bot
pushed a commit
that referenced
this pull request
Oct 4, 2026
Fixed-point C after rebasing onto #1342 and linking noalias into the stage-A frontend. bootstrap_from_c.sh --regen (FIXED POINT at gen3) then --verify PASS. Co-authored-by: Abhishek Shivakumar <[email protected]>
7 of 8 tasks
cursor Bot
pushed a commit
that referenced
this pull request
Oct 5, 2026
{llvm.noalias} and // flowc.noalias comments change normalized MLIR
digests. Refresh via parity_mlir.flow --record (also records newly
accepted programs from #1341/#1342 and the noalias fixtures).
Co-authored-by: Abhishek Shivakumar <[email protected]>
cursor Bot
pushed a commit
that referenced
this pull request
Oct 5, 2026
{llvm.noalias} and // flowc.noalias comments change normalized MLIR
digests. Refresh via parity_mlir.flow --record (also records newly
accepted programs from #1341/#1342 and the noalias fixtures).
Co-authored-by: Abhishek Shivakumar <[email protected]>
godofecht
added a commit
that referenced
this pull request
Oct 5, 2026
* perf: emit proven restrict/noalias in C and MLIR backends (#731) Add a fail-closed provenance certificate for local arrays and constant slices, then mark only proven-disjoint internal pointer parameters and unique local pointers with C restrict and MLIR {llvm.noalias}. Co-authored-by: Abhishek Shivakumar <[email protected]> * fix: link noalias into stage-A frontend (#731) cgen calls flowc_noalias_* but the module was missing from frontend_modules, the self-emit plan, roundtrip compile_module, and the g2 fixed-point list. Same inventory pattern as type_id / rt_summary. Co-authored-by: Abhishek Shivakumar <[email protected]> * test: re-record parity_mlir corpus after noalias metadata (#731) {llvm.noalias} and // flowc.noalias comments change normalized MLIR digests. Refresh via parity_mlir.flow --record (also records newly accepted programs from #1341/#1342 and the noalias fixtures). Co-authored-by: Abhishek Shivakumar <[email protected]> * fix: regenerate bootstrap C after noalias rebase onto #1343 Fixed-point C after rebasing onto phase timing (#1343 / c5332d7). bootstrap_from_c.sh --regen (FIXED POINT at gen3) then --verify PASS. Co-authored-by: Abhishek Shivakumar <[email protected]> * test: retarget mlir_defer_addr golden for flowc.noalias (#731) flowc now emits // flowc.noalias on proven-local MLIR allocas. Re-record the mlir_commands expected text so the check matches without weakening noalias/restrict emission. Co-authored-by: Abhishek Shivakumar <[email protected]> --------- Co-authored-by: Cursor Agent <[email protected]>
This was referenced Oct 5, 2026
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.
Intent
Linked issue: #765
First useful slice of modular RT-safety / lifetime-domain contracts: emit and import a compact effect/lifetime summary for public functions, and consult it during type checking so
@rt_safe/@lifetimecompose across modules.The summary is a may-effect bitset plus declared domain plus one provenance edge:
@lifetimedomainunknownfor unprovable externs (recorded; not yet a hard error)Local summaries are the least fixed point
E_f = L_f ∪ ⋃ E_callee. Imported$fnameentries are leaves. Diagnostics keep the existing call-chain wording (because it calls 'malloc'). No runtime metadata; summaries ride in the compile-time effect table and are erased before codegen.Overlap check
Overlap / dependency notes:
7b2dccb231df9b40f098bf940675cb551d7b4ce5(and earlier feat: stable type identity, schema IDs, and alignof (Part of #775) #1340 type identity). The only conflict was CHANGELOG Unreleased bullets; kept both. Bootstrap regenerated from the new base. Roundtrip#747__flowc_str_concatnchecks and the#765rt_summarycompile_module wiring both remain.--lifetimes), plus affine/AoSoA/async CLI slices. None implement Feature request: make @rt_safe/@lifetime sound across imported calls #765 summaries.with rt_safe). This PR is the imported-named-call / domain-summary slice, not another callable-type contract.Evidence
Baseline before this change:
Lifetime-domain docs listed cross-module domains as unchecked. Imported helpers were only as sound as the whole-program body walk; there was no serialized public contract.
Targeted proof that exercises the changed behaviour:
test_rt_summaryincompiler/src/main.flow:rt_summary_n=57 helper_bits=1 process_bits=1 tick_dom=0 ok=1thenflowc: PASS(alsotype_id_ok=1).tests/scripts/rt_summary.flow(3/3):heap_touch→mallocrejected from@rt_safewith the existing chain wording@lifetime(session) reload_presetrejected from@lifetime(callback)RT-safety violation: 'process' is marked '@rt_safe' but calls 'heap_touch', which is not RT-safe because it calls 'malloc'lifetime domain violation: 'process' is in the \callback` domain but calls 'reload_preset', which is in the `session` domain`Why that proof would detect the old failure or regression:
The script fixtures are two-module programs. A checker that does not seed or consult summaries cannot name the imported helper's heap/domain contract. The selftest fails if the worklist does not fold
mallocthroughhelperintoprocess.Repository gate(s) run after rebase onto
7b2dccb2:env -u FLOWC_IN -u FLOWC_OUT "$(./flow tool compiler/scripts/flowc_host.flow)"→flowc: PASS(type_id_ok=1,rt_summary_ok=1)./flow tool compiler/scripts/typecheck_rules.flow→ 125 passed, 0 failed./flow test-lang tests/lang/test_lifetime_domains.flow tests/lang/test_rt_safe_indirect.flow→ both passed./flow tool tests/scripts/rt_summary.flow→ 3 passedFLOWC_PHASE_A_ONLY=1 ./flow tool compiler/scripts/roundtrip.flow→PASS flowc Phase-A roundtrip(includescompile_module rt_summary/typecheck/sem_checkand#747strcat)./compiler/scripts/bootstrap_from_c.sh --regen→ fixed point at gen2./compiler/scripts/bootstrap_from_c.sh --verify→PASS bootstrap C matches compiler/srcGenerated/bootstrap state:
compiler/bootstrap/flowc_stage_a.cregenerated in a separate commit after the rebase. Verify matchescompiler/src.Risk
Compatibility, performance, security, lifetime, backend, or release implications:
Checking still rejects only the known unsafe names from
@rt_safe/callback. The newunknownbit is recorded on unclassified externs but is not a hard error in this slice (existing@rt_safe+print/ math externs stay accepted).Summaries are compile-time only; C output is unchanged when programs typecheck.
Worklist is bounded by
5|F|bit insertions.No unresolved language/API design decision is being implemented implicitly.
No unrelated generated artifacts or local state are included.
Docs changed when user-visible behaviour or syntax changed.
docs/project/Questions.mdupdated if this needs a language-design decision.Compatibility
docs/project/CHANGELOG.md.Documented as new checking, not a break: CHANGELOG notes the summary contract and that
unknownis not yet rejected.Agent handoff
Agent/provider/session: Cursor cloud agent, first slice of #765. Rebased onto #1337 (
7b2dccb2) after #1340. Head:6168c2c79be6b91960756cd84ba9c7635b8ecd9a.Remaining gaps (not this PR):
unknownfrom@rt_safeonce a known-safe extern allow-list exists.with rt_safebindings).Any remaining blocker is recorded in GitHub rather than only in local/session state.