status command: api-rs /api/status endpoint + discordbot channel-gated fast-path - #18
Draft
oponder wants to merge 10 commits into
Draft
status command: api-rs /api/status endpoint + discordbot channel-gated fast-path#18oponder wants to merge 10 commits into
oponder wants to merge 10 commits into
Conversation
A "@bot status" (or "health") mention now gets an instant reply built from api-rs /healthz + /readyz and the shared session database (recent turns with errors, 24h tally, in-flight executions, active sandboxes, warm pool) — no sandbox turn involved, so the command keeps working when the agent pipeline itself is what's broken. Mentions with any other words ("status of the deploy") fall through to a normal agent turn, so real questions are never hijacked. Every status source is fetched independently and best-effort: api-rs down still reports DB data and vice versa. Co-Authored-By: Claude Fable 5 <[email protected]>
Discord has no table markup; a monospace code block with padded columns is the idiomatic substitute. Header (bold + emoji health marks) stays outside the block, rows use short ASCII tags (ok/FAIL/run) since emoji are double-width in code blocks and wreck alignment. In-flight turns fold into the same table as settled ones; errors get their own indented line so the columns stay ~45 chars and portrait mobile doesn't wrap. Co-Authored-By: Claude Fable 5 <[email protected]>
…abels
Timing columns were ambiguous — add a THREAD/WHO/AGE/TOOK heading row
(AGE = when requested, TOOK = runtime). Rows now prefer the session title
(the conversation name the bots already set) over raw thread keys, fall
back to a friendly rendering for untitled management turns
("GH PR splits-teams#1799"), and carry the requester from the execute
metadata's user_name. Truncation keeps both ends readable (middle
ellipsis) except names, which head-cut.
Co-Authored-By: Claude Fable 5 <[email protected]>
Claimed/failed warm-sandbox rows are never deleted — an unfiltered count
reads like a leak ("868 claimed"). Window them to 24h and split the line
into current pool (ready/evicting) vs churn. Discord sessions store their
conversation name in metadata (discord_conversation_name), not title —
coalesce it in so Discord rows show thread names instead of raw ids. Widen
WHO to 10 and alias github-pr-manager to gerard.
Co-Authored-By: Claude Fable 5 <[email protected]>
Linear and Slack sessions store their conversation names under their own metadata keys (linear_conversation_name / slack_conversation_name), same pattern as discord — fold them into the title coalesce so those rows show issue/channel names instead of raw UUIDs. Co-Authored-By: Claude Fable 5 <[email protected]>
Unicode bar chart per UTC day (zero-filled week, bars scaled to the busiest day), with failures as their own labeled column — one measure per bar, no second scale, no color-alone signal — and a 7d totals/failure-rate stat line beneath. Co-Authored-By: Claude Fable 5 <[email protected]>
Keep the first block exactly as it was (tally, turn table, sandboxes) and append the 7-day histogram as a second fenced block, budgeting the live view's truncation around the fixed-size histogram. Co-Authored-By: Claude Fable 5 <[email protected]>
"warm 24h: 3 failed" next to a histogram FAIL column reads like failed turns; it's warm-sandbox provisioning failures (the next session just cold-starts). Rename the display label so the two failure domains can't be conflated. Co-Authored-By: Claude Fable 5 <[email protected]>
Rework of the status fast-path after an adversarial review: - Data now comes from api-rs's read-only /api/status over HTTP with timeouts — no SQL from the ingress bot, no bot-side DB pool to hang the per-thread handler lock, and the service-ownership boundary holds. - The feature is opt-in per channel (DISCORDBOT_STATUS_CHANNEL_IDS; unset = disabled): the report exposes cross-platform activity, so where it may be seen is a deployment decision, not a default. - Header names the configured bot userName (no hardcoded deployment name); the actor alias map is gone. - Backticks/newlines in interpolated titles/errors are neutralized so a hostile title can't break out of the code block; failures post a generic line with internals kept to logs. - Mention-created threads are subscribed before the fast-path replies; unreachable (❓) is distinguished from unhealthy (❌). Co-Authored-By: Claude Fable 5 <[email protected]>
GET /api/status returns a JSON snapshot for status surfaces (chat-bot status commands, dashboards): recent and in-flight executions (with session title, requester, truncated error), a 24h status tally, active session sandboxes, warm-pool state (current ready/evicting plus 24h claimed/failed churn — those rows are lifetime history), and a 7-calendar- day UTC run histogram. api-rs owns the session schema, so the SQL lives here instead of in every ingress service that wants a status view. The report is cached in-process for 10s so scripted callers cost at most one scan set per TTL, and a new migration indexes session_executions(created_at) for the global recency scans. Co-Authored-By: Claude Fable 5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A bare
@bot status(orhealth) mention gets an instant reply from the discordbot service — health tiles, a 24h tally, recent/in-flight turns (with requester and one-line errors), sandbox/warm-pool state, and a 7-day run histogram with failure rate — with no sandbox turn involved, so it keeps working when the agent pipeline itself is broken.The reply data comes from a new read-only
GET /api/statusendpoint on api-rs (this PR adds it): api-rs owns the session schema, so the SQL lives there, and the ingress bot only speaks HTTP. The endpoint caches its report in-process for 10s, windows warm-pool claimed/failed rows to 24h (they're lifetime history), buckets the histogram by UTC calendar day, and a new migration givessession_executions(created_at)an index for the global recency scans.Security posture (adversarially reviewed)
An independent review pass drove the current shape:
DISCORDBOT_STATUS_CHANNEL_IDS; unset disables the feature entirely.allowed_mentions: []).userName; no actor aliases.Other review fixes: mention-created threads are subscribed before the fast-path replies (no orphaned threads);
unreachable(❓) is distinguished fromunhealthy(❌); histogram fetch window matches its calendar-day buckets exactly.Testing
pnpm --filter discordbot test— 152 pass (keyword matcher incl. mention markup; collect under partial outages — api down / report down / malformed body; fence-injection neutralization; formatting + Discord 2000-char cap).pnpm --filter discordbot run check:types— clean.cargo check -p centaur-api-server+cargo fmt --check— clean (viarust:latestcontainer, matching the Dockerfile'srust:1-bookworm).Deploy notes
deploy-centaur -f services="api-rs discordbot". The api-rs migration (0049,create index if not exists) runs on boot.DISCORDBOT_STATUS_CHANNEL_IDS(comma/space-separated channel or thread ids) on the discordbot deployment to enable the command.🤖 Generated with Claude Code