feat(etl): Wave 4C — /api/etl/status route + CLI command#78
Merged
Conversation
Single endpoint surfaces watcher health, mart watermarks vs max event id, per-provider event counts, and a `health` enum (live / syncing / stale / error) so the dashboard can show a status badge and the CLI a one-line health check. <50ms response — all counts are indexed COUNT(*) on usage_events / mart tables. - New `stackunderflow/etl/status.py` shared assembler (single source of truth for both surfaces; route + CLI never disagree). - New `stackunderflow/routes/etl.py` thin FastAPI shell. - New `etl_status_cmd` in `stackunderflow/cli.py` with text + json formats; the text render mirrors the spec example. - Watcher graceful degrade: when `deps.watcher_handle` is None (CLI, --no-watcher, or pre-server boot) status reports `running="unknown"` rather than crashing. - 17 new tests (10 route, 7 CLI) cover shape, every health transition (live → syncing → stale → error), and watcher-degrade fallback. Test count delta: 1472 → 1489 passed, 2 skipped (~+17).
48fa384 to
faa9b42
Compare
0bserver07
added a commit
that referenced
this pull request
May 6, 2026
Bumps to 0.7.0. Consolidates the [Unreleased] CHANGELOG entries from the 11 ETL PRs (#72, #73, #74, #75, #76, #79, #81, #80, #78, #77, #82) into a single [0.7.0] section. New: docs/HANDOFF.md — state-of-the-codebase walkthrough for incoming agents. Architecture map, recent history, key gotchas, what's left, files-to-read-first. End-state on the maintainer's real store: 150,337 usage_events Marts populated and watermarks in sync Dashboard cold-load 2.5s → <50ms warm Watcher 155ms end-to-end source-file-write → dashboard-data-fresh 1598 backend tests passing, 2 skipped, 11 deselected (slow suite). Frontend typecheck + build clean. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
Wave 4C ships the ETL pipeline health surface — one endpoint + one CLI
command — so the dashboard can show a status badge and CLI users get a
one-line health check.
GET /api/etl/status— watcher state, mart watermarks vs the maxusage_events.id, per-provider event counts, per-cost-sourcebreakdown, and a
healthenum (live/syncing/stale/error).<50ms response on a 200K-event store; all counts are indexed
COUNT(*).stackunderflow etl status [--format text|json]— same payload,rendered as text by default. Works without a running server.
stackunderflow/etl/status.pyso both surfacescall the same SQL. The CLI degrades gracefully when no live watcher
handle is available (reports
running=\"unknown\").Health rules (from the wave-4C spec)
error— a mart is more than 100 events behind and the watcher reportsrunning=false.stale— a mart is more than 100 events behind, watcher still alive (catch-up may still happen).syncing— lag > 0 and a refresh ran in the last 10 seconds.live— zero lag, or no events at all.Test plan
health transition, and watcher graceful-degrade.
pytest tests/ -qclean: 1489 passed, 2 skipped (was 1472 before).time end-to-end.
`stale` (watcher state unknown, marts 150K events behind) on the
user's machine where ingest is current but the marts haven't been
refreshed.
Files touched