* feat(gateway): give /status a real daemon-health surface Phase 2 of archie-core-wp9s. Phase 1 split the commands apart (health vs work) but left /status with one aggregate queue line and a static runtime block; it could not answer the questions an operator actually asks when something feels wrong. /status now reports, between the queue line and the runtime block: - Broker: the live state of this process's own NATS connection (eventbus/nats.Client.Connected), not a fresh dial -- a probe would report the probe's reachability, not the daemon's. - Containers: the pool's own active counter against the configured cap (Pool.Active/Cap), not a Docker listing, which would include containers this pool does not own. A zero cap means unlimited, so it is not shown as a ratio. - Channels: the channel manager's real lifecycle state, including a failed adapter's reason (the documented decision: read the existing manager rather than re-deriving health per adapter). - Chat model: last-known outcome of every chat-model call this process made, recorded once in sendChatTurn (the single choke point) and read back by /status. The second documented decision: never a live probe, so /status stays instant and reports what happened -- or says plainly that nothing has been attempted yet. - Last poll: when the most recent poll pass began, stamped on both poll paths (Run's single-identity loop and runIdentities' per-identity goroutines). A pass that hangs leaves the stamp stale, which is the signal; stamping completion would leave a wedged poller looking healthy. Truthful or absent: a section this process has no source for is omitted rather than rendered as a zero. The standalone Gateway owns no poll loop, pool or channel manager, so its /status reports broker and chat-model health only; aggregating across processes would need a new daemon RPC and is deliberately not built. Version stays out (/version owns it). /status and /tasks descriptions now describe what each command actually does on both published surfaces (Telegram menu/help and the shared specs), pinned by a test that also fails if the two surfaces drift. Sources are read through functions, not captured values: occupancy and channel state move, and the daemon is built after the gateways, so a source captured at construction would freeze /status on boot state. Left in place deliberately: the Runtime (provider/model) block, which Phase 1 flagged and which duplicates /model and /whoami. Removing it is a product call on a command Sam uses daily, not a mechanical follow-up. * docs(prds): record the two open /status health decisions as settled Both were flagged in PR #892 as needing the maintainer's call; both are now answered, and the PRD is the place a follow-up would look: - The Runtime (provider/model) block stays. It is the one line in /status the ticket's own rule says should not be there, but /status is read daily to see the active model at a glance, so the duplication is deliberate. Recorded as a settled product decision so it is not removed later as an oversight. - Health stays per-process. Pooling the daemon's and the Gateway's chat-model outcomes would need a new daemon<->gateway health RPC for one status line, and a per-process line is true where an aggregate would be a claim about a process the answering one cannot see. /agents' published description is still left to archie-core-mxls, unchanged.
8.8 KiB
/status health surface -- what's shipped, what's proposed
Status: Phase 1 shipped 2026-09-03 (archie-core-wp9s). Phase 2 shipped 2026-09-19: broker connectivity, container pool, last poll, provider reachability and channel state are implemented on the decisions recorded below, with the fields that had no truthful source left out rather than faked (see "Phase 2 -- shipped").
Background
archie-core-wp9s ("/status and /tasks have the wrong division of labour")
asked for two things: /tasks owning the live per-task work view, and
/status owning daemon health -- "broker connectivity, provider
reachability, channel state, container pool, queue depth, last poll,
version" -- with neither duplicating the other or static config available
elsewhere (/model already lists active provider/model).
Phase 1 -- shipped
/tasks: new command,gateway.ChatTaskSummaryextended withStage/Attempt/ParkReason/UpdatedAt(all already persisted onstore.Task, zero new instrumentation), sorted actionable-first./status: itemized per-status task counts replaced with one aggregateQueue: N in flight (...)line (running/waiting/parked only -- queued and terminal states excluded as not a health concern). Runtime (provider/model) is temporarily left in place; see "Runtime (provider/model)" under Phase 2's "Truthful or absent" for where that stands now.
Not touched: /agents (gateway.AgentReader/Router.Agents) is a separate,
pre-existing command that already has the right shape for "list active
work" but is never wired to a real implementation in any composition-root
call site (bootstrap.go, telegram_setup.go) -- it always answers "Agent
listing is not configured." in production. That is a standalone bug
(archie-core-mxls), not folded into this work: deciding whether to wire
it, repurpose it, or delete it in favor of /tasks is Sam's call, not
something to resolve by implication here.
Phase 2 -- health checks, verified against the actual tree
Each bullet below was checked against real code before being called cheap or not; nothing here is guessed. Both open questions were settled (see "The two decisions") and all five fields shipped.
Verified as cheap against the tree
- Broker connectivity.
internal/infrastructure/eventbus/nats.Clientalready exposesCoreConn() (*nats.Conn, error)(client.go:134). The underlyingnats.Conn(nats.go) has its ownStatus()/IsConnected(). AClient.Connected() boolwrapper is a few lines. - Container pool.
container.Poolalready tracksactive intunder its own mutex (pool.go:90) but has no public accessor. APool.Active() intgetter is a few lines. - Last poll. Nothing tracks this today. The daemon's poll loop
(
internal/daemon) needs onelastPollAt time.Timefield (atomic or mutex-guarded, matching the pool's own pattern) set at the top of each poll tick, with a getter. - Queue depth. Already shipped in Phase 1.
The two decisions (settled 2026-09-19, decided by position)
- Provider reachability is last-known outcome, never a live probe. A chat
command must not perform a blocking network call in its handler, and a probe
reports the probe's reachability rather than the daemon's.
/statustherefore prints what actually happened -- the last chat-model call's model, age and error, or "no calls attempted yet" when there has been none. Implemented asproviderOutcomeRecorder, written once insendChatTurn(the single point every chat-model call in the process passes through) and read back bynewStatusHealth. Nothing on this path dials a provider. The existing live model reachability check (readiness.go'smodelReachProbe) is unchanged and stays where it belongs: on/health/detailed, off the chat path. - Channel state comes from the existing ChannelManager.
/statusreadsstatus.Manager.Snapshot()-- the same ledger the dashboard and the readiness probe already use -- rather than re-deriving channel health from each adapter. No method was added to theChannel/Gatewaycontract.
Phase 2 -- shipped
- Broker connectivity.
internal/infrastructure/eventbus/nats.ClientgainedConnected() bool, which reads the connection the process already holds. The standalone Gateway (which dials NATS itself for task actions) reports the same fact from that connection. - Container pool.
container.Pool.Active()andPool.Cap()read the pool's own counter and configuredmax_concurrency-- not a Docker listing, which would include containers this pool does not own. A cap of zero means unlimited, so/statusrenders the count alone rather than "1/0 active". - Last poll.
daemon.Daemon.LastPollAt()reports when the most recent poll pass began; both poll paths (pollfor single-identityRun,pollForIdentityforrunIdentities) stamp it. A pass that hangs leaves the stamp stale, which is the signal -- stamping completion instead would leave a wedged poller looking healthy. - Queue depth. Already shipped in Phase 1.
- Rendering.
gateway.formatHealthrenders one line per reported fact (Broker:,Containers:,Channels:,Chat model:,Last poll:) between the queue line and the runtime block. The sources it reads are functions, not captured values: occupancy and channel state change over the process's life, and the daemon is built after the gateways, so a source captured at construction would freeze/statuson boot-time state.
Truthful or absent -- what is deliberately not reported
- Version. Still excluded:
/versionowns it, and duplicating it back into/statusis the exact "answers something available elsewhere in chat" complaint this ticket exists to fix. - Sections the standalone Gateway process cannot see. The daemon owns the
poll loop, the container pool and the channel manager; the Gateway process
owns none of them. Its
/statusreports broker and chat-model health and omits pool, polling and channels rather than printing zeroes. Aggregating them across processes would need a new daemon RPC -- a new subsystem, out of scope here. For the same reason the chat-model line is per process: the daemon records the turns it runs (Telegram, email, webhook), the Gateway records the web chat's, and the two do not pool outcomes. Each line is true of the process answering the command. Decided 2026-09-19: they stay per-process. Pooling them would mean a new daemon↔gateway health RPC for one status line, and a per-process line is true where an aggregate would be a claim about a process the answering one cannot see. - A channel's failure reason can outlive the failure.
status.Managerkeeps the last non-emptyDetailacross state changes, and that one field carries both a descriptor's standing caveat and a runtime failure reason, so a channel that failed and later recovered can still render the old reason. Splitting the two belongs at the producer (the manager and its descriptor), not in this reader, which reads the field exactly as the dashboard does. - Container pool when Docker is unavailable. Composition leaves
containerPoolnil, so the section is absent. Naming a reason would mean carrying Docker's startup error into the health surface. - Runtime (provider/model). Phase 1 left this block in place; it is still
here. It is static config that
/modeland/whoamialready answer, so it is the only line in/statusthat this ticket's own rule says should not be there -- but the maintainer reads/statusdaily to see the active model at a glance, and one command answering both "is archie well" and "what is it running on" is worth that duplication. Decided 2026-09-19: keep it. It is a settled product decision, not an oversight; do not remove it as a mechanical follow-up. /agentscopy. The menu still advertises "List tasks currently being worked" whileRouter.Agentsis never wired (archie-core-mxls), so that one published description does not match what its command does. Deleting, rewiring or redefining/agentsis that bead's call and is not folded in here.
Packages this touches (Phase 2, as shipped)
internal/infrastructure/eventbus/nats:Client.Connected().internal/container:Pool.Active(),Pool.Cap().internal/daemon:lastPollAt/markPoll/LastPollAt().internal/gateway:health.go(health contract + renderer),Router.Health,formatStatus.internal/app/archied:status_health.go(the composition-root bridge),ProviderOutcomesthreaded throughtelegramSetupinto every turn runner, andsendChatTurnrecording each call's outcome.internal/domain/messaging+internal/channels/telegram:/statusand/tasksdescriptions, which now describe both commands' actual jobs on both published surfaces.