feat(webui): deliver live dashboard events by polling the State Store cursor
archie-core-za9f. The UI process owns no event bus, so after the .5.4 cutover the activity feed would show history at page load and then go silent: live delivery is a Server.Broadcast call made only from the daemon's bus subscription. Decided against the push-subscription RPC the bead assumed, on three findings: * store.Open sets SetMaxOpenConns(1), so writes serialise and the event id is assigned in commit order. The gap-skipping failure that normally rules out polling an autoincrement cursor cannot happen here, and SSE catch-up already depends on the same property. * sseStream.drain treats a broadcast as a wakeup, not a payload: it fills the persisted gap via catchUp and delivers the event only if catch-up missed it, deduplicating on the since watermark. A poller substitutes for the bus with no change to sse.go and no new SSE semantics. * The events table is the only complete fan-out point. ArchiveTask writes an audit event inside its transaction and daemon.go inserts binding-dispatch failures directly, neither touching the bus. A push hub needs a hook at every write site and misses any added later. So: no proto change, no new auth surface, no backpressure policy. The pump primes past existing history (a client's own catch-up serves that), then ticks EventsSince into Broadcast. One pump serves every browser. A failed fetch leaves the watermark intact, so a State Store restart costs latency, not events. Wired into archieui.Run in the background so priming a large events table cannot delay the listener, with -event-poll-interval (default 1s). Decision recorded in migration-decisions.md; ui-service-boundary.md's /events route-owner row moves to RESOLVED, and /api/logs splits out of it as still unresolved and host-local.
This commit is contained in:
1 parent
ac7b4492a2
commit
536fa20254
9 files changed
+407
-1
No files matched your search
@@ -308,6 +308,54 @@ selection, failure/readiness behavior, and deletion of the shared-holder and
|
||||
direct-access paths. The extraction cutover removes the in-process UI
|
||||
listener in the same change; there is no dual-live UI authority.
|
||||
|
||||
**Dashboard live event delivery — DECIDED (2026-09-09, `archie-core-za9f`).**
|
||||
The extracted UI receives live activity by polling the State Store's existing
|
||||
`EventsSince` cursor, not by a new push-subscription RPC. No proto change, no
|
||||
contract amendment beyond this record.
|
||||
|
||||
The UI process runs one event pump. It primes its watermark by paging
|
||||
`EventsSince` to the end at startup without delivering, then polls
|
||||
`EventsSince(watermark, limit)` on an interval and hands each new event to
|
||||
`webui.Server.Broadcast`, exactly where `internal/app/archied/main.go`'s
|
||||
`persistAndBroadcastEvents` hands events to it today. One pump serves every
|
||||
connected browser, so cost is one indexed query per interval regardless of
|
||||
viewer count, and `Broadcast` is a no-op when nobody is watching.
|
||||
|
||||
Three properties make the cursor sufficient, and a push hub unnecessary:
|
||||
|
||||
- **The cursor cannot skip.** `internal/store/store.go` opens the database with
|
||||
`SetMaxOpenConns(1)`, so writes serialise and a row's `id` is assigned in
|
||||
commit order. There is no window in which a lower id becomes visible after a
|
||||
higher one, which is the failure mode that normally rules out polling an
|
||||
autoincrement cursor. SSE catch-up already depends on this same property.
|
||||
- **A broadcast is a wakeup, not the payload.** `sseStream.drain` treats each
|
||||
broadcast event as a signal to fill the persisted gap ahead of it via
|
||||
`catchUp`, then delivers the event only if catch-up did not already cover
|
||||
it, deduplicating on the `since` watermark. Substituting a poller for the
|
||||
in-process bus therefore changes no SSE semantics, and needs no change to
|
||||
`internal/webui/sse.go`. It also means a broadcast dropped to a stalled
|
||||
client self-heals on the next one.
|
||||
- **The table is the only complete fan-out point.** Events reach the store
|
||||
through several paths that never touch the daemon's bus, including the
|
||||
audit event `store.ArchiveTask` writes inside its transaction
|
||||
(`internal/store/store.go`) and the binding-dispatch failure
|
||||
`internal/daemon/daemon.go` inserts directly. A push hub would have to be
|
||||
hooked at every write site and at post-commit, and would silently miss any
|
||||
site added later that forgets to notify. Reading the table misses nothing.
|
||||
|
||||
The cost is one poll interval of latency on the activity feed, default 1s and
|
||||
operator-tunable. That is accepted: the feed reports task lifecycle history,
|
||||
and an operator action already gets its own synchronous HTTP response.
|
||||
|
||||
This resolves the `/events` row of the route-owner inventory in
|
||||
[`ui-service-boundary.md`](../prds/ui-service-boundary.md). `/api/logs` and
|
||||
`/api/logs/stream` are not resolved by it, they read the daemon's in-process
|
||||
diagnostic feed and remain host-local (see `archie-core-8cda.5.4`).
|
||||
|
||||
Revisit only if sub-second feed latency becomes a requirement, or if a second
|
||||
consumer needs the same stream, at which point the fan-out belongs in the State
|
||||
Store process behind a `SubscribeEvents` RPC and this record is superseded.
|
||||
|
||||
### 7. Shared mechanics
|
||||
|
||||
The following cross-domain mechanics require exact contracts before dependent
|
||||
|
||||
@@ -64,7 +64,8 @@ cutover.
|
||||
|---|---|---|
|
||||
| `/api/chat/*` | Gateway `ChatContract` and its versioned client | contract seam exists; DTO and stream parity remain |
|
||||
| `/api/tasks/*`, `/api/workflows`, `/api/setup` | State Store read/action contracts plus an explicit execution/admin action contract | State Store adapter exists; UI-facing narrow surface remains |
|
||||
| `/api/logs`, `/events` | State/event and log contracts with replay cursor and backpressure rules | local bus/feed only today; contract remains to define |
|
||||
| `/events` | State Store `EventsSince`, polled by one UI-process pump feeding `Server.Broadcast` | RESOLVED (`archie-core-za9f`): see migration-decisions, "Dashboard live event delivery". No new RPC; replay cursor and drop-recovery are the existing `since` watermark in `sse.go` |
|
||||
| `/api/logs`, `/api/logs/stream` | daemon diagnostic feed, host-local | unresolved: `logging.Feed` is in-process on the daemon host and has no contract |
|
||||
| `/api/captures`, `/api/mappings`, `/api/bindings` | State Store contracts, with webhook verification owned by Work Intake/Messaging | local adapter exists; remote UI surface remains to define |
|
||||
| `/api/config` | daemon/config owner through a versioned admin contract | current app callbacks; shared holder must be removed |
|
||||
| `/api/channels`, reload, curators, memory, skills, version/update | owning capability contract or an explicitly removed route | owner and failure semantics remain to define |
|
||||
|
||||
Reference in new issue
Block a user