Repository navigation
Description
The idea, in a paragraph
Delete hy-check/src/loans.rs's five depth-bounded (depth <= 4) interprocedural AST body re-walkers AND eliminate the A5 closure/callback escape blind spot (GUARANTEES.md Rows 5 & 9) in one paradigm shift: equip TypeExpr::Fn with inferred region-flow & invocation-multiplicity effect summaries (Φ = (slot_shares ⊆ k×k, ret_shares ⊆ r×r, mult ∈ {0, 1, sync*, async*})), synthesized modularly bottom-up per Tarjan SCC fixpoint with zero user annotations on .hy functions and a single 2-bit callback multiplicity tag on curated Go stdlib higher-order APIs (sort.slice = sync*, sync.once.do = 1, http.handle_func / time.after_func = async*).
Which assumption it breaks
It kills two sacred cows simultaneously:
- Whole-AST interprocedural body re-walking in
loans.rs(collect_callee_param_stores,walk_call_param_stores,callee_shared_return_pairs,collect_callee_const_return_roots,callee_spawns_or_sends_param) and itsdepth <= 4horizon (which caused liveP0go run -racedata races ondepth > 4call chains and indirectfnbindings in#1698). GUARANTEES.mdRow 5 & Row 9 ("captures without a boundary statement are outside (A5)" / "Values escaping into Go APIs (net/http handlers, callbacks): No checker claim"): today Hybrid gives up on every callback escape becausefn(...)types erase whether a callback is invoked synchronously on the caller's stack before return (sort.Slice) or concurrently across goroutines (http.HandleFunc,time.AfterFunc).
Why this is a breakthrough, not an increment
Patching loans.rs by raising depth from 4 to 8 or Conservatively linking all arguments on indirect calls (#1698) is an increment that hits a hard precision-vs-soundness wall:
- Without effect-bearing
fntypes, any safe higher-order.hyhelper (apply(cb, m, xs)) or sequential stdlib callback (sort.slice(xs, fn(i, j) { swaps += 1; ... })) must either fail open (unsoundP0race onhttp.handle_func) or fail closed on every mutating capture (forcingmanagednoise on purely sequentialsort.slice/strings.map/ iterator callbacks). - Lifting storage-flow (
slot_shares,ret_shares) and invocation multiplicity (1 | sync* | async*) into the principal signature of everyfnSCC turns interprocedural ownership checking from exponential/depth-capped AST re-traversal into modular$O(|V| \cdot k^3)$ algebraic composition — exact at depth1,000and across mutual recursion, while flippingGUARANTEES.mdRows 5 & 9 from "outside / no checker claim" to Guaranteed in the checked subset without analyzing foreign Go stdlib bodies.
How we would know it works (or doesn't)
Pre-registered falsifiable milestones (backed by an executable prototype in spikes/effect-polymorphic-fn-summaries/):
- M1 / H1 (Depth-unbounded soundness & speed): Tarjan-SCC fixpoint summary inference catches
100%of parameter-store and multi-return alias flows at call-chain depth100and across mutually recursive SCCs (ping <-> pong) in< 5 ms(< 1 msmeasured on a 102-node call graph), deletingdepth <= 4completely. - M1 / H2 (Row 5 & Row 9 differential
-raceprecision): Across a differential suite of sequential callbacks (sort.Slice,bytes.Map, userfor_each) vs concurrent/escaped callbacks (http.HandleFunc,time.AfterFunc, goroutine-spawning higher-order.hyhelpers),sync*accepts sequential mutating captures with0go run -racewarnings and0managedblocks, whileasync*rejects concurrent mutating captures withHYB-E3002. - Falsifier F1 (Stored
fnfields & contravariant subtyping): When a closure is stored into a heap struct field (h.cb = fn() { x += 1 }) rather than called immediately, call-site multiplicity is unknown at creation time. The proposal fails if storedfnfields require heavy region annotations in user code; it succeeds only if defaulting unannotated storedfnfields toasync*(with optionalsync fn(...)parameter qualifier for borrowed callbacks) keeps corpus false-positive rate<= 2%ontests/checker-corpus/(SPEC §9.7 tripwire).
Cost honesty (optional but powerful)
- Deleted (~900 LOC in
hy-check/src/loans.rs): All fivedepth <= 4recursive AST body walkers and ad-hocclosure_defsside tables are replaced by a single pre-pass (hy-check/src/summaries.rs, ~300 LOC) run betweenresolveandloans. - Changed (
hy-syntax/hy-check/src/shapes.rs):TypeExpr::Fngains an internal inferred effect summary (no mandatory surface syntax change for.hycode), and curated callback entries inshapes.rs(sort.slice,filepath.walk_dir,http.handle_func,time.after_func,sync.once.do) carry a 2-bit multiplicity tag (One,SyncMany,AsyncMany), with uncurated foreign callbacks failing closed asAsyncManyper O4.9.
Track terms
- I understand no prototype is required and failure-with-knowledge is a valid, paid outcome
- I understand all outcomes (including declines and failures) are published in MOONSHOT.md
Activity
ryder777777 commentedon Oct 25, 2026
Executable pre-registered spike with Tarjan-SCC fixpoint engine, falsifier F1, and
go run -racedifferential test is up in #1715 (spikes/effect-polymorphic-fn-summaries/).spike(wildcard): effect-polymorphic fn summaries via Tarjan SCC fixpo…
spike(wildcard): effect-polymorphic fn summaries via Tarjan SCC fixpo…
spike(wildcard): effect-polymorphic fn summaries via Tarjan SCC fixpo…
spike(wildcard): effect-polymorphic fn summaries via Tarjan SCC fixpo…
spike(wildcard): effect-polymorphic fn summaries via Tarjan SCC fixpo…
spike(wildcard): effect-polymorphic fn summaries via Tarjan SCC fixpo…
spike(wildcard): effect-polymorphic fn summaries via Tarjan SCC fixpo…