You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Feature request: make @rt_safe/@lifetime sound across imported calls #765
flow-audio needs hard real-time contracts to remain valid when a callback calls helpers imported from other Flow modules/packages.
Current lifetime-domain documentation explicitly says cross-module domains are not consulted. That prevents a library from making an end-to-end guarantee: an @lifetime(callback) function in one module can call an imported helper whose implementation allocates or blocks without the caller's checker necessarily seeing the imported domain/call graph.
Requested capability: emit/import a compact effect/lifetime summary for public functions and use it during type checking. At minimum the summary should say whether a callable is callback-safe, frame-safe, may allocate/free, may block/lock, may do device/file/network I/O, and its declared lifetime domain. Transitive diagnostics should preserve the useful call-chain explanation.
This should not require runtime metadata and should erase before codegen, like the current annotations.
Why this matters beyond audio: any reusable hard-deadline library, game callback, embedded interrupt-ish path, or low-latency service boundary needs contracts to compose across packages.
flow-audio will avoid depending on this until implemented; its RT core will use direct named calls with locally visible implementations.
Worked through the cross-module contract and archived the full derivation + Flow semantic model in godofecht/OpenProjects as compilers/modular-rt-safety-effect-summaries.md / .flow.
The minimal exported contract is a transitive may-effect bitset plus declared lifetime domain for each public callable. Local summaries are the least fixed point
E_f = L_f ∪ ⋃ E_callee
with imported summaries treated as leaves. Because the effect lattice is finite, a worklist terminates after at most |Effects| * |Functions| successful bit insertions, including recursive SCCs. If imported summaries are sound upper bounds, the client's computed summary is a sound upper bound across module boundaries.
There is also a useful incremental result. If a new dependency contract refines the old one (effects_new ⊆ effects_old and domain_new <= domain_old), every caller previously accepted under the old contract remains accepted and sound. Only effect growth / movement to a longer-lived domain can invalidate prior accepted clients. So RT/lifetime cache invalidation can key on public semantic summaries rather than full dependency source hashes.
An unprovable imported/extern callable should carry an explicit unknown effect bit rather than silently getting an empty summary. Diagnostics can preserve one provenance edge per newly introduced forbidden bit to retain transitive call-chain explanations.
Local validation: randomized recursive call graphs up to 11 functions matched direct reachability union; the five-bit worklist never exceeded the 5|F| insertion bound. The refinement theorem was exhaustively checked over 9,720 valid effect/domain combinations. No hosted CI was used.
2026-10-07: Extended draft PR #1355 with a cache-correctness hardening. An empty/truncated prior RT-summary snapshot previously refined trivially, which could set rt_cache_hit=1 and skip imported RT/lifetime checks. The branch now validates serialized framing, RT bit/domain ranges and loaded snapshots; rejects empty old/new summaries and non-hex/traversal-like cache keys; bounds malformed entry walking; and adds self-tests for zero-length/truncated snapshots. 10/10 source invariants pass. Native flowc/bootstrap fixed-point verification is still required.
2026-10-08 hardening supplement: serialized imported RT/lifetime summaries now fail closed before refinement. flowc_rt_summary_buffer_valid validates complete kind/name/value NUL framing and bounds RT bit/domain fields; truncated/empty/malformed prior state can no longer count as a reusable/refining contract. Added tests/lang/test_rt_summary_cache_validation.flow and wired it into tests/scripts/rt_summary.flow; docs now reflect the current six-domain lattice (callback < frame < request < session < application < persistent). 10/10 committed-source invariants pass. Native ./flow test-lang / script-suite execution is still required before merge; no claim that this closes all #765 gaps.
Activity
godofecht commentedon Aug 27, 2026
Worked through the cross-module contract and archived the full derivation + Flow semantic model in
godofecht/OpenProjectsascompilers/modular-rt-safety-effect-summaries.md/.flow.The minimal exported contract is a transitive may-effect bitset plus declared lifetime domain for each public callable. Local summaries are the least fixed point
E_f = L_f ∪ ⋃ E_calleewith imported summaries treated as leaves. Because the effect lattice is finite, a worklist terminates after at most
|Effects| * |Functions|successful bit insertions, including recursive SCCs. If imported summaries are sound upper bounds, the client's computed summary is a sound upper bound across module boundaries.There is also a useful incremental result. If a new dependency contract refines the old one (
effects_new ⊆ effects_oldanddomain_new <= domain_old), every caller previously accepted under the old contract remains accepted and sound. Only effect growth / movement to a longer-lived domain can invalidate prior accepted clients. So RT/lifetime cache invalidation can key on public semantic summaries rather than full dependency source hashes.An unprovable imported/extern callable should carry an explicit
unknowneffect bit rather than silently getting an empty summary. Diagnostics can preserve one provenance edge per newly introduced forbidden bit to retain transitive call-chain explanations.Local validation: randomized recursive call graphs up to 11 functions matched direct reachability union; the five-bit worklist never exceeded the
5|F|insertion bound. The refinement theorem was exhaustively checked over 9,720 valid effect/domain combinations. No hosted CI was used.feat: emit and consult cross-module RT/lifetime summaries (#765)
feat: emit and consult cross-module RT/lifetime summaries (#765)
feat: cross-module @rt_safe/@Lifetime summaries (#765) (#1342)
fix: regenerate bootstrap C after remaining #765 RT summary work
Merge origin/main (7cd0ce3) into the #765 remaining-slice branch
Merge origin/main (4609f80) into the #765 remaining-slice branch
fix(rt-cache): reject empty/truncated summaries and unsafe cache keys (…
fix(rt-cache): keep key validation on plain integer control flow (#765)
test(rt-cache): malformed/empty snapshots cannot suppress RT checks (#…
godofecht commentedon Oct 7, 2026
2026-10-07: Extended draft PR #1355 with a cache-correctness hardening. An empty/truncated prior RT-summary snapshot previously refined trivially, which could set
rt_cache_hit=1and skip imported RT/lifetime checks. The branch now validates serialized framing, RT bit/domain ranges and loaded snapshots; rejects empty old/new summaries and non-hex/traversal-like cache keys; bounds malformed entry walking; and adds self-tests for zero-length/truncated snapshots. 10/10 source invariants pass. Native flowc/bootstrap fixed-point verification is still required.feat: reject unknown RT summaries, method/heap escapes, summary cache (…
fix(rt-cache): reject empty/truncated summaries and unsafe cache keys (…
2 remaining items
fix(rt): land the #765 summary gaps without the persistent RT cache
tests: re-record the MLIR corpus digest for test_typecheck_overload_i…
fix: regenerate bootstrap C after the remaining #765 RT summary work
feat: reject unknown RT summaries, method/heap escapes, summary cache (…
fix(rt-cache): reject empty/truncated summaries and unsafe cache keys (…
fix(rt-cache): keep key validation on plain integer control flow (#765)
test(rt-cache): malformed/empty snapshots cannot suppress RT checks (#…
fix(rt): land the #765 summary gaps without the persistent RT cache
tests: re-record the MLIR corpus digest for test_typecheck_overload_i…
test(rt-summary): malformed caches must fail closed (#765)
test(rt-summary): malformed caches must fail closed (#765)
test(rt-summary): execute malformed cache validation in script suite (#…
docs(rt-summary): current lifetime lattice and fail-closed serializat…
godofecht commentedon Oct 8, 2026
2026-10-08 hardening supplement: serialized imported RT/lifetime summaries now fail closed before refinement.
flowc_rt_summary_buffer_validvalidates complete kind/name/value NUL framing and bounds RT bit/domain fields; truncated/empty/malformed prior state can no longer count as a reusable/refining contract. Addedtests/lang/test_rt_summary_cache_validation.flowand wired it intotests/scripts/rt_summary.flow; docs now reflect the current six-domain lattice (callback < frame < request < session < application < persistent). 10/10 committed-source invariants pass. Native./flow test-lang/ script-suite execution is still required before merge; no claim that this closes all #765 gaps.