Skip to main content

Module channel_route

Module channel_route 

Expand description

Real channel delivery for the approval route adapter (EPIC G follow-up).

super::broker::NoopRouteAdapter only logs; this adapter actually delivers an approval notice to a configured channel (Discord, Slack, …), so a SOP that parks at a policied gate can reach an approver OUT OF BAND - e.g. a channel-git trigger starts a triage SOP, the SOP parks for approval, and the request lands in a Discord ops channel where a maintainer approves it through the normal HTTP/WS/ tool surfaces (which already route back through the broker + chokepoint).

Layering: this lives in zeroclaw-runtime because it needs only zeroclaw_api::channel::Channel (a runtime dependency already), never the zeroclaw-channels implementations. The DAEMON builds the concrete channel map (via zeroclaw_channels::orchestrator::build_channel_map) and injects it here, so there is no runtime -> channels layering inversion.

Delivery is best-effort and fire-and-forget: ApprovalRouteAdapter::deliver is a SYNC call made under the engine Mutex (on park, and on the maintenance-tick escalation path), so it cannot .await. It spawns the async Channel::send onto a tokio [Handle] captured at construction and returns immediately. A send failure is logged inside the spawned task; it never blocks or clears the gate - the gate state is the source of truth, the notice is only a courtesy.

Structs§

ChannelRouteAdapter
A route adapter that delivers approval notices to configured channels.

Enums§

ApprovalRouteIssue
A route configuration problem reported at daemon startup before a parked gate would otherwise discover it during delivery.

Functions§

parse_approval_route
Parse a channel_key:recipient route into its two non-empty halves. Splits on the FIRST : only, so a recipient that itself contains : (e.g. a Matrix @user:server id) survives intact on the right. Channel-map keys are dot-separated (discord.ops), never colon-separated, so the first colon is unambiguously the channel/recipient boundary.
unresolvable_approval_routes
The configured approval routes (request_route + escalation_route) whose channel key is NOT among channel_keys - the channels the route adapter can actually deliver to (present in its map AND supports_outbound_send). A route names an undeliverable channel when it is absent from the map (e.g. an AMQP SOP-dispatch channel that needs runtime SOP handles the adapter lacks) OR present but inbound-only (its send is a no-op). The daemon logs these at STARTUP so the drift between “configured route” and “deliverable channel” surfaces at boot, not silently on the first parked gate. A route must have non-empty channel:recipient halves; malformed values are also surfaced at startup. Returns one ApprovalRouteIssue per invalid route.