Skip to main content

Module realtime

Module realtime 

Source
Expand description

A2UI live-update backbone (Change 20, a2ui-realtime-backbone-from-flint-realtime-fabric).

Scope correction found during implementation: the plan frames this as “wire flint-realtime-fabric as the SSE/fan-out backbone for A2UI live updates,” but auditing the existing code first found:

  1. No A2UI emission call site exists yet. super::protocol’s A2uiMessage/CreateMessage/ComponentsMessage/DataMessage/DeleteMessage DTOs are Deserialize-only, pub(crate), and referenced nowhere else in the crate (#[expect(dead_code, ...)] on the module confirms they’re contract-validation scaffolding, not a live code path). The orchestrator does not currently create or update A2UI surfaces during a run.
  2. Multi-client fan-out (“convergence”) already exists. crate::uar::runtime::manager::RunManager broadcasts every [NormalizedEvent] to all subscribers of a run via a tokio::sync::broadcast channel (RunManager::subscribe) — multiple SSE clients on the same run_id already converge on the same event stream. This module does not need to reimplement that.
  3. The actual gap is durable, replayable fan-out for “late-join reattach.” A broadcast channel has a bounded buffer and no replay-from-start semantics — a client that connects after events have already fired gets nothing before its subscribe point, and a slow client can miss events entirely (RecvError::Lagged). This is exactly the capability flint-realtime-fabric (a durable pub/sub broker, frf-sdk-rust’s FrfClient::subscribe(..., Offset::BEGINNING)) is for.

So this module’s real, buildable scope is: (a) a conversion from A2UI wire messages to StatePatchOps so whenever a future orchestrator call site does emit A2UI surface changes, they compose with the existing NormalizedEvent::StatePatch/RunManager broadcast pipeline for free; and (b) an A2uiReplayBackbone trait with a real, tested in-process implementation (InMemoryReplayBackbone) for late-join replay. The flint-realtime-fabric-backed implementation is designed but not wired as a live Cargo dependency this pass — see “Deferred” below.

Structs§

InMemoryReplayBackbone
In-process, single-instance implementation of A2uiReplayBackbone. Retains the full patch history per run in memory for the process’s lifetime — real and useful for tests and a single-server deployment, but explicitly not durable across process restarts or usable across multiple server instances. That cross-instance/durable case is exactly what the flint-realtime-fabric-backed implementation (deferred, see module docs) is for.

Enums§

A2uiWireKind
The 4 A2UI v0.9 wire-message kinds, per docs/protocols/a2ui-profile.md and super::protocol.

Traits§

A2uiReplayBackbone
A durable-replay backbone for A2UI state patches, keyed by run_id. Distinct from RunManager’s live broadcast: this trait’s job is specifically “can a client that joins after some patches were already published still receive them,” which a tokio::sync::broadcast channel cannot do once its buffer has advanced past a slow/late subscriber.

Functions§

surface_message_to_state_patch
Converts a single A2UI wire message into a StatePatchOp rooted at /a2ui/surfaces/{surface_id}, so it can be emitted as a NormalizedEvent::StatePatch and ride the existing crate::uar::runtime::manager::RunManager broadcast/SSE pipeline.