✓
Passing This code compiles and runs correctly.
Code
// Test: Handle pool tracks opened resources
// Resources with <state!> are added to handle pool
// Response includes active handles
~import std/runtime
~import std/io
const std = @import("std");
// Open creates an obligation on the branch payload. Two branches: a lone
// payload branch is a bare return by ruling, and a bare return's obligation
// is not seen by the registry's obligation extraction today.
~pub tor open { path: string }
| opened string<opened!>
| missing
~proc open|zig {
_ = path;
return .{ .opened = "file_1" };
}
// Close discharges the obligation
~pub tor close { handle: string<!opened> }
~proc close|zig {
}
// Register scope - compiler infers close is discharge for open
~std/runtime:register(scope: "test") {
open(10)
close(1)
}
const TEST_SOURCE = "open(path: \"test.txt\")";
// Open a file, don't close - should be in handle pool
~std/runtime:run(source: TEST_SOURCE, scope: "test", budget: 100, auto_discharge: false)
| result r |> std/io:print.ln("PASS: handles tracked: {{ r.handles:d }}")
| exhausted _ |> std/io:print.ln("FAIL: should not exhaust")
| parse-error _ |> std/io:print.ln("PARSE ERROR")
| validation-error _ |> std/io:print.ln("VALIDATION ERROR")
| shape-error _ |> std/io:print.ln("SHAPE ERROR")
| event-denied _ |> std/io:print.ln("EVENT DENIED")
| dispatch-error _ |> std/io:print.ln("DISPATCH ERROR")
| scope-not-found _ |> std/io:print.ln("SCOPE NOT FOUND")
Actual
PASS: handles tracked: 1
Expected output
PASS: handles tracked: 1
Flows
flow ~register click a branch to expand · @labels scroll to their anchor
register (scope: "test", source: open(10)
close(1))
flow ~run click a branch to expand · @labels scroll to their anchor
run (source: TEST_SOURCE, scope: "test", budget: 100, auto_discharge: false)
Test Configuration
MUST_RUN