Skip to content

feat(traffic): read endpoints + CLI status/sources/events (Phase 2 slice 2)#431

Open
arberx wants to merge 1 commit intomainfrom
arberx/post-pr429-next-stage
Open

feat(traffic): read endpoints + CLI status/sources/events (Phase 2 slice 2)#431
arberx wants to merge 1 commit intomainfrom
arberx/post-pr429-next-stage

Conversation

@arberx
Copy link
Copy Markdown
Member

@arberx arberx commented May 8, 2026

Summary

Adds the read surface that slice 1 deferred so an agent can see what syncs ingested without a DB query: three GET routes (/traffic/sources, /traffic/sources/:id with last-24h totals + latest run, /traffic/events with kind/since/until/limit/sourceId filters), three matching CLI commands (traffic status, traffic sources, traffic events) all with --format json, plus ApiClient methods and OpenAPI entries. Folds in the two correctness fixes flagged in the slice 1 review: upstream and auth-token failures now throw providerError() (502) so CLI exits 2 (system error, retryable) rather than 1 (user error), and the failed-run + source updates share a transaction so a mid-handler crash can't leave the run failed but the source still "connected". Events totals reflect the full window even when limit truncates the rows array, so a paginated query never undercounts. MCP toolkit and UI remain deferred to slice 3+.

Test plan

  • pnpm test — 2138 tests pass workspace-wide (+18 new: 13 route tests, 5 CLI tests)
  • pnpm typecheck clean
  • pnpm lint clean (pre-commit hook ran)
  • Smoke canonry traffic events <project> --kind crawler --format json against a synced project

…ice 2)

Adds the read surface that slice 1 deferred so an agent can see what
syncs ingested without a DB query. Three new GET routes (`/traffic/sources`,
`/traffic/sources/:id` with last-24h totals + latest run, `/traffic/events`
with kind/since/until/limit/sourceId filters), three matching CLI commands
(`traffic status`, `traffic sources`, `traffic events`) all with --format
json, and ApiClient methods + OpenAPI entries.

Folds in the two correctness fixes flagged in the slice 1 review:
upstream and auth-token failures now throw providerError() (502) so CLI
exits 2 (system error, retryable) rather than 1 (user error), and the
failed-run + source updates share a transaction so a mid-handler crash
can't leave the run failed but the source still "connected".

Events totals reflect the full window even when limit truncates the rows
array, so a paginated query never undercounts. MCP toolkit and UI remain
deferred to slice 3+.
@arberx arberx force-pushed the arberx/post-pr429-next-stage branch from ac7bd6a to c3e3a5a Compare May 8, 2026 02:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant