swarm-controller: end a dead replay, clamp stale resume ids, test on a real server
A replay consumer now has a 5s idle heartbeat, and the row stream ends at the first consumer error instead of skipping it. When the server drops the consumer, as on a restart, two missed heartbeats end the SSE response and the browser reconnects with Last-Event-ID. Before, the response stayed open and delivered nothing. A Last-Event-ID above the stream's newest sequence now replays as a fresh reader. The server accepts a start past the end and delivers nothing until the stream reaches it, so a stale id stalled the replay. swarm-controller's stream tests run against a real nats-server on loopback (`test_nats`, binary from HIVE_NATS_SERVER, exported by checks.nix and devshell.nix). They cover: ensuring the stream twice, an existing stream with other limits being opened as it is, the replay arriving before live rows, a reconnect getting every later row exactly once, and a dropped consumer ending the row stream. The limits test now compares against the subagent stream's own config. Two comments that described the agent's terminal route as live-only are corrected.
This commit is contained in:
parent
ae9ca4331e
commit
f08a9cadb6
10 changed files with 357 additions and 40 deletions
|
|
@ -1,11 +1,11 @@
|
|||
//! `GET /api/agents/{name}/state/stream` — a live SSE relay of one agent's
|
||||
//! turn-state header, sourced straight from the swarm queue.
|
||||
//!
|
||||
//! Sibling of [`crate::term_stream`] in every structural respect — the
|
||||
//! reasoning there for keeping the hive out of the path, and for a live tail with no replay, applies
|
||||
//! unchanged here and is not repeated. What differs is only what the two
|
||||
//! subjects carry: a terminal row is an event that happened, a header is
|
||||
//! the agent's current state.
|
||||
//! Sibling of [`crate::term_stream`]: the reasoning there for keeping the
|
||||
//! hive out of the path applies unchanged here and is not repeated. Unlike
|
||||
//! that route this one is a live tail with no replay, because no stream keeps
|
||||
//! headers. The two subjects also differ in what they carry: a terminal row
|
||||
//! is an event that happened, a header is the agent's current state.
|
||||
//!
|
||||
//! **That difference is the one thing worth reading twice.** `hive-agent`
|
||||
//! publishes a header on transition and re-sends it once a minute, to a core
|
||||
|
|
|
|||
Loading…
Reference in a new issue