✓
Passing This code compiles and runs correctly.
Code
// probe — the failed-teardown route: discharge spec without a dispatcher.
import std/io
import std/bridge
import app/session
tor run-turn { br: *std/bridge:Bridge, source: string, label: string }
run-turn = std/bridge:run(br, source)
| result r |> std/io:print.ln(" {{ label:s }}: held={{ r.handles:d }}")
| defined d |> std/io:print.ln(" {{ label:s }}: DEFINED {{ d:s }}")
| event-denied ev |> std/io:print.ln(" {{ label:s }}: DENIED {{ ev:s }}")
| dispatch-error e |> std/io:print.ln(" {{ label:s }}: DISPATCH {{ e.message:s }}")
| parse-error e |> std/io:print.ln(" {{ label:s }}: PARSE {{ e.message:s }}")
| exhausted _ |> std/io:print.ln(" {{ label:s }}: EXHAUSTED")
| validation-error _ |> std/io:print.ln(" {{ label:s }}: VALIDATION")
| shape-error _ |> std/io:print.ln(" {{ label:s }}: SHAPE")
| scope-not-found _ |> std/io:print.ln(" {{ label:s }}: NO SCOPE")
[with]std/bridge:create(id: "probe", scope: "files"): br
|> std/io:print.ln("--- bridge open")
|> run-t(br, source: "open(path: \"a.txt\")", label: "open")
|> run-t(br, source: "query(conn: \"a.txt\", handle: \"cur1.txt\")", label: "cursor")
|> std/io:print.ln("--- hang up; close-query has NO proc — discharge must fail")
|> std/bridge:close(br)
|> std/io:print.ln("--- done")
tor run-t { br: *std/bridge:Bridge, source: string, label: string }
run-t = std/bridge:run(br, source)
| result r |> std/io:print.ln(" {{ label:s }}: held={{ r.handles:d }}")
| defined d |> std/io:print.ln(" {{ label:s }}: DEFINED {{ d:s }}")
| event-denied ev |> std/io:print.ln(" {{ label:s }}: DENIED {{ ev:s }}")
| dispatch-error e |> std/io:print.ln(" {{ label:s }}: DISPATCH {{ e.message:s }}")
| parse-error e |> std/io:print.ln(" {{ label:s }}: PARSE {{ e.message:s }}")
| exhausted _ |> std/io:print.ln(" {{ label:s }}: EXHAUSTED")
| validation-error _ |> std/io:print.ln(" {{ label:s }}: VALIDATION")
| shape-error _ |> std/io:print.ln(" {{ label:s }}: SHAPE")
| scope-not-found _ |> std/io:print.ln(" {{ label:s }}: NO SCOPE")Actual
--- bridge open
open: held=1
cursor: held=2
--- hang up; close-query has NO proc — discharge must fail
[BRIDGE] No spec for 'cur1.txt' [app.session:query], skipping
thread 338101423 panic: std/bridge:close: session 'probe' still holds 2 handle(s) after hang-up — a discharge event failed (see the [BRIDGE] lines above)
???:?:?: 0x10452c1db in _output_emitted.koru_std.koru_bridge.Bridge.dischargeAll (???)
???:?:?: 0x10452a2db in _output_emitted.koru_std.koru_bridge.close_event.handler (???)
???:?:?: 0x1045298ef in _output_emitted.main_module.flow0 (???)
???:?:?: 0x10452974f in _output_emitted.main (???)
???:?:?: 0x10452966b in _main (???)
???:?:?: 0x18eec7dff in ??? (???)
???:?:?: 0x0 in ??? (???)
Must contain:
[BRIDGE] No spec for 'cur1.txt' [app.session:query], skippingFlows
subflow ~run-turn click a branch to expand · @labels scroll to their anchor
run (br, source)
flow ~create click a branch to expand · @labels scroll to their anchor
create (id: "probe", scope: "files")
subflow ~run-t click a branch to expand · @labels scroll to their anchor
run (br, source)
Imported Files
// probe: registered + phantom-declared discharge WITHOUT a proc.
// close-query is in the register block and carries <!query>, so the
// discharge-spec table knows to call it for queried! handles — but the
// scope's dispatcher has NO entry for it (@hasDecl skips it). The
// discharge attempt must fail honestly.
~import std/runtime
const std = @import("std");
~pub tor open { path: string } -> string<open!>
~proc open|zig {
_ = path;
return "a.txt";
}
~pub tor query { conn: string, handle: string } -> string<query!>
~proc query|zig {
_ = conn;
return handle;
}
~pub tor close-file { handle: string<!open> }
~proc close-file|zig {
std.debug.print("close-file() ran for '{s}'\n", .{handle});
}
// Declared with the discharge phantom, NO proc — no dispatcher entry.
~pub tor close-query { handle: string<!query> }
~std/runtime:register(scope: "files") {
open(10)
query(10)
close-file(1)
close-query(1)
}
Test Configuration
MUST_RUN