Skip to content

feat(runtime): dispatch_background — fire-and-poll command dispatch with a first-class UUID handle - #1902

Merged
joelteply merged 1 commit into
canaryfrom
feat/dispatch-background-handle
Jul 7, 2026
Merged

joelteply merged 1 commit into
canaryfrom
feat/dispatch-background-handle

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

The producer for the async recency channel (#66), built RIGHT at the universal command layer so ANY client
benefits, not just personas. CommandExecutor::dispatch_background(command, params, caller) -> Uuid returns a
handle immediately and runs the dispatch on a spawned task; the caller never blocks (the fire-and-poll shape,
#86). On completion, the existing command:completed event carries the handle AND the result, so a subscriber
matches the completion to its exact dispatch and folds the outcome in without a second call.

CommandCompletedEvent gains handle: Option<Uuid> + result: Option<Value> — populated ONLY for tracked
background dispatches; synchronous commands stay thin (both None, elided on the wire — the caller already holds
the return value). The handle is a plain UUID precisely so it's reusable in a follow-up command (cancel/query/
attach) — handles + events, the pattern already under every command ([[commands-are-agency-algs-are-pathways]]).

Tested: dispatch_background returns a handle and its completion event carries that handle + the result; a
synchronous dispatch carries neither; the wire round-trip elides both when None. ts-rs binding regenerated
(handle?: string, result?: unknown).

This is the PRODUCER; the persona-side listener (subscribe command:completed → filter to this persona's handles
→ record_dispatch_event into working memory) is the final connecting slice — pure reuse of Connection::subscribe.

Co-Authored-By: Claude Opus 4.8 [email protected]
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

…ith a first-class UUID handle

The producer for the async recency channel (#66), built RIGHT at the universal command layer so ANY client
benefits, not just personas. `CommandExecutor::dispatch_background(command, params, caller) -> Uuid` returns a
handle immediately and runs the dispatch on a spawned task; the caller never blocks (the fire-and-poll shape,
#86). On completion, the existing `command:completed` event carries the handle AND the result, so a subscriber
matches the completion to its exact dispatch and folds the outcome in without a second call.

`CommandCompletedEvent` gains `handle: Option<Uuid>` + `result: Option<Value>` — populated ONLY for tracked
background dispatches; synchronous commands stay thin (both None, elided on the wire — the caller already holds
the return value). The handle is a plain UUID precisely so it's reusable in a follow-up command (cancel/query/
attach) — handles + events, the pattern already under every command ([[commands-are-agency-algs-are-pathways]]).

Tested: dispatch_background returns a handle and its completion event carries that handle + the result; a
synchronous dispatch carries neither; the wire round-trip elides both when None. ts-rs binding regenerated
(handle?: string, result?: unknown).

This is the PRODUCER; the persona-side listener (subscribe command:completed → filter to this persona's handles
→ record_dispatch_event into working memory) is the final connecting slice — pure reuse of Connection::subscribe.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply
joelteply merged commit a115781 into canary Jul 7, 2026
@joelteply
joelteply deleted the feat/dispatch-background-handle branch July 7, 2026 00:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant