feat(traffic): read endpoints + CLI status/sources/events (Phase 2 slice 2)#431
Open
feat(traffic): read endpoints + CLI status/sources/events (Phase 2 slice 2)#431
Conversation
…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+.
ac7bd6a to
c3e3a5a
Compare
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
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/:idwith last-24h totals + latest run,/traffic/eventswithkind/since/until/limit/sourceIdfilters), 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 throwproviderError()(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 whenlimittruncates 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 typecheckcleanpnpm lintclean (pre-commit hook ran)canonry traffic events <project> --kind crawler --format jsonagainst a synced project