✓
Passing This code compiles and runs correctly.
Code
// TEST: prose on the wire is residue — bound into the session, never
// destroyed. A turn that is all prose comes back `residue` (nothing ran)
// carrying one binding — even a MULTI-LINE prose turn coalesces into a
// single `residue bound: r{N}` (the model meant one utterance, and
// redelivery must not take N calls). The bound text is a scalar `r{N}`
// value, so `echo(text: r1)` re-emits the model's own words through a
// real verb. In a mixed turn a refused item is a `step N/M residue
// bound:` line inside `partial`. A malformed invocation is NOT residue:
// it lexed as a call and broke inside the arguments — a plain parse-error.
import std/io
import std/bridge
import std/runtime
tor echo { text: string }
proc echo|zig {
_ = @import("std").posix.write(1, text) catch {};
_ = @import("std").posix.write(1, "\n") catch {};
}
std/runtime:register(scope: "api") {
echo(1)
}
tor turn { br: *std/bridge:Bridge, src: string }
turn = std/bridge:run(br, source: src)
| result r |> std/io:print.ln("RESULT bound={{ r.bound:s }}")
| partial p |> std/io:print.ln("{{ p.report:s }}")
| unhandled-branch ub |> std/io:print.ln("FAIL unhandled {{ ub.branch:s }}")
| event-denied ev |> std/io:print.ln("FAIL denied {{ ev:s }}")
| residue r |> std/io:print.ln("RESIDUE {{ r.report:s }}")
| parse-error p |> std/io:print.ln("PARSE {{ p.message:s }}")
| validation-error v |> std/io:print.ln("FAIL invalid {{ v:s }}")
| shape-error sh |> std/io:print.ln("FAIL shape {{ sh.message:s }}")
| dispatch-error e |> std/io:print.ln("FAIL dispatch {{ e.message:s }}")
| defined d |> std/io:print.ln("FAIL defined {{ d:s }}")
| exhausted _ |> std/io:print.ln("FAIL exhausted")
| scope-not-found s2 |> std/io:print.ln("FAIL noscope {{ s2:s }}")
[with]std/bridge:create(id: "rs", scope: "api"): br
|> turn(br, src: "I cannot delete files for you.")
|> turn(br, src: "echo(text: r1)")
|> turn(br, src: "echo(text: \"a\")\nlet me apologize properly")
|> turn(br, src: "echo(text: r4)")
|> turn(br, src: "echo(text: oops x)")
|> turn(br, src: "first apology\nsecond apology")
|> turn(br, src: "echo(text: r6)")
Actual
RESIDUE residue bound: r1 — your reply was not wire; nothing reached the user, but the observer kept it. To deliver it, call say(text: r1); to keep thinking out loud, call note(text: ...)
I cannot delete files for you.
RESULT bound=r2
a
step 1/2 result: {"branch":""} bound: r3
step 2/2 residue bound: r4 — your reply was not wire; nothing reached the user, but the observer kept it. To deliver it, call say(text: r4); to keep thinking out loud, call note(text: ...)
let me apologize properly
RESULT bound=r5
PARSE after the value of 'text' comes ',' or ')' — text must be "double-quoted"; a bare word reads as a bound name
RESIDUE residue bound: r6 — your reply was not wire; nothing reached the user, but the observer kept it. To deliver it, call say(text: r6); to keep thinking out loud, call note(text: ...)
first apology
second apology
RESULT bound=r7
Expected output
RESIDUE residue bound: r1 — your reply was not wire; nothing reached the user, but the observer kept it. To deliver it, call say(text: r1); to keep thinking out loud, call note(text: ...)
I cannot delete files for you.
RESULT bound=r2
a
step 1/2 result: {"branch":""} bound: r3
step 2/2 residue bound: r4 — your reply was not wire; nothing reached the user, but the observer kept it. To deliver it, call say(text: r4); to keep thinking out loud, call note(text: ...)
let me apologize properly
RESULT bound=r5
PARSE after the value of 'text' comes ',' or ')' — text must be "double-quoted"; a bare word reads as a bound name
RESIDUE residue bound: r6 — your reply was not wire; nothing reached the user, but the observer kept it. To deliver it, call say(text: r6); to keep thinking out loud, call note(text: ...)
first apology
second apology
RESULT bound=r7
Flows
flow ~register click a branch to expand · @labels scroll to their anchor
register (scope: "api", source: echo(1))
subflow ~turn click a branch to expand · @labels scroll to their anchor
run (br, source: src)
flow ~create click a branch to expand · @labels scroll to their anchor
create (id: "rs", scope: "api")
Test Configuration
MUST_RUN