Skip to content

feat: remaining @rt_safe/@lifetime summary gaps (#765) - #1355

Merged
godofecht merged 10 commits into
mainfrom
cursor/rt-safe-summaries-remaining-af06
Oct 8, 2026
Merged

godofecht merged 10 commits into
mainfrom
cursor/rt-safe-summaries-remaining-af06

Conversation

@godofecht

@godofecht godofecht commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Intent

Closes #765 (remaining slice after #1342).

#1342 landed emit and import of compact $fname summaries and their use during type checking. This slice closes the gaps that PR listed:

  • @rt_safe / @lifetime(callback) reject an unknown effect summary unless the extern is on a known-safe allow-list (math, atomics, bounded copies, numeric conversions, print). Diagnostics say "unknown effect summary" and keep the call chain.
  • Uniquely resolved impl methods join the RT call graph. An ambiguous trait method stays a conservative reject.
  • LD1 rejects a reference stored through a local that holds a malloc / alloc_* result (or a cast of one), as a store into the application domain.
  • The summary refinement relation (flowc_rt_refines, flowc_rt_summaries_refine, framing validation, fingerprint) is implemented and covered by the selftest. Empty, truncated or malformed snapshots never count as refined.

Not included: the persistent RT summary cache

The earlier version of this branch stored summary snapshots under ~/.cache/flow/rt and skipped the Stage-A RT consult on a cache hit. That lets a writable cache file switch off RT checks, the key had no compiler or schema salt, and the selftest wrote to a fixed /tmp path. It is a trust decision, so commit c5d997a removes the cache I/O and the typecheck probe/save, and docs/project/Questions.md ("RT summary cache: may a stored snapshot skip RT checks?") records the options. The original commits stay in the history.

Rebase

Rebased onto main 55dc81b as a linear series (the two merge commits were dropped; their resolutions were bootstrap-only). Per-hunk resolutions:

  • sem_check.flow: main's LD5 field checks ([Flow 2.0] Sound lifetime domain propagation through struct fields and collections #684) and this PR's heap-root check both kept. The heap check runs after the static and field checks, only when the store base is not a static, so a store is reported once.
  • typecheck.flow, main.flow imports: union of both sides.
  • lifetime-domains.md: main's field bullets and table rows kept; the heap row and call/closure wording from this PR added.
  • nav.json, CHANGELOG: both sides kept. Em dashes removed from rt-summaries.md.
  • MLIR corpus: one digest re-recorded (test_typecheck_overload_integration compiles rt_summary.flow).

Evidence

On this head (macOS arm64):

  • selftest flowc: PASS, rt_summary_n=57 helper_bits=1 process_bits=1 tick_dom=0 ok=1
  • bootstrap regen fixed point at gen2, --verify ALL PASS
  • typecheck_rules 171/0 (includes rt_safe_unknown_extern, rt_safe_known_safe_math, rt_safe_method_malloc, domain_escape_heap, domain_escape_field_static), parity_typecheck pass
  • tests/scripts/rt_summary 4/0
  • test-lang 285/0, test-runtime 35/0, tests/cgen 142/0, ./flow test --tier2 --strict 991/991
  • parity_mlir PASS, parity_lowering PASS, roundtrip ALL PASS, self_host_full ALL PASS, doc_links, script_refs
  • tests/cli: only the known local jit_hello and test_mlir drift

Risk

Compatibility: an @rt_safe function that calls an unclassified extern now fails. Documented in CHANGELOG.

Remaining gaps outside #765's stated scope: closures and HOF with rt_safe (#766, in the #1348 train), escape through a call, pointer laundering.

@godofecht
godofecht marked this pull request as draft October 7, 2026 07:58
@godofecht
godofecht force-pushed the cursor/rt-safe-summaries-remaining-af06 branch from 1715534 to 38cea54 Compare October 8, 2026 00:52
@godofecht
godofecht marked this pull request as ready for review October 8, 2026 00:52
@godofecht
godofecht enabled auto-merge October 8, 2026 09:01
cursoragent and others added 10 commits October 8, 2026 10:53
…#765)

Close the remaining #765 gaps on top of the landed first slice: a
known-safe extern allow-list so unknown is a hard error from @rt_safe,
impl methods in the call graph (closures stay with #766 / PR #1348),
LD1 through static fields and malloc stores, and a refinement-keyed
incremental summary cache.

Co-authored-by: Abhishek Shivakumar <[email protected]>
The summary cache let a stored snapshot under ~/.cache/flow/rt skip the
Stage-A RT consult. A writable cache file could switch off RT checks, and
the key had no compiler or schema salt. That is a trust decision, recorded
in docs/project/Questions.md. The refinement relation stays as a tested
pure function; the cache I/O, the typecheck probe and save, and the
selftest's fixed /tmp path are removed.
@godofecht
godofecht force-pushed the cursor/rt-safe-summaries-remaining-af06 branch from 38cea54 to 52e823c Compare October 8, 2026 10:28
@godofecht
godofecht added this pull request to the merge queue Oct 8, 2026
Merged via the queue into main with commit f215e30 Oct 8, 2026
32 checks passed
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.

Feature request: make @rt_safe/@lifetime sound across imported calls

2 participants