✓
Passing This code compiles and runs correctly.
Code
// `{ policy: Name }` delegates the decision rules to a named same-module
// tor. The policy consumes the failure stream under the arm vocabulary
// (`f` = latest failure payload, `t` = retries spent — the bound channel,
// required) and produces the SAME vocabulary the arms spell:
// `| retry i64` re-enters with the payload as the child's sole input,
// `| exhausted i64` produces on the supervised branch. Here climb grants
// five re-entries (dial 8081..8085), then exhausts with 9000.
import std/io
import std/supervisor
pub tor dial { port: i64 }
| ok i64
| refused i64
proc dial|zig {
@import("std").debug.print("dial {d}...\n", .{port});
return .{ .refused = port };
}
pub tor climb { f: i64, t: i64 }
| retry i64
| exhausted i64
proc climb|zig {
if (t < 5) {
return .{ .retry = f + 1 };
}
return .{ .exhausted = 9000 };
}
pub tor connect { port: i64 }
| ok i64
| refused i64
connect = dial(port)
| ok p => ok p
| refused f |> std/supervisor:supervised { policy: climb }
connect(port: 8080)
| ok p |> std/io:print.ln("connected on {{ p:d }}")
| refused f |> std/io:print.ln("no service near {{ f:d }}")
Actual
dial 8080...
dial 8081...
dial 8082...
dial 8083...
dial 8084...
dial 8085...
no service near 9000
Expected output
dial 8080...
dial 8081...
dial 8082...
dial 8083...
dial 8084...
dial 8085...
no service near 9000
Flows
subflow ~connect click a branch to expand · @labels scroll to their anchor
dial (port)
flow ~connect click a branch to expand · @labels scroll to their anchor
connect (port: 8080)
Test Configuration
MUST_RUN