feat: Cave oversight dashboard endpoints — routing + audit (#18)#63
Merged
Conversation
…dashboard (#18) Config::routing_view resolves an installation's effective familiars, trigger lanes, and per-repo overrides (open / listed / fail-closed) as a serializable view. Store::audit_events assembles a tenant-scoped, newest-first task-lifecycle stream from ignored deliveries, task attempts (execution/retries/timeout), and opened PRs — the data behind the dashboard's routing and audit views. Signed-off-by: Val Alexander <bunsthedev@gmail.com>
Adds the two data endpoints Cave still needed, tenant-scoped and audited like the rest: GET /api/github/routing (effective familiars + trigger lanes + repo overrides per installation) and GET /api/github/audit (task-lifecycle stream — acceptance, execution/retries/timeout, PR creation). With the existing task and usage endpoints, Cave's four oversight views are all backed. README updated. Closes #18. Signed-off-by: Val Alexander <bunsthedev@gmail.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds the remaining backend endpoints needed for Cave’s oversight dashboard in coven-github, exposing tenant-scoped routing policy and a task-lifecycle audit stream alongside the existing tasks/usage views.
Changes:
- Adds
GET /api/github/routingandGET /api/github/auditAxum handlers and wires them into the server router. - Introduces
Config::routing_view(serializedRoutingView) andStore::audit_events(serializedAuditEvent) to provide dashboard-ready data. - Updates README capabilities table to include the Cave oversight dashboard feature row.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Documents the Cave oversight dashboard capability and the four endpoints it uses. |
| crates/webhook/src/routes.rs | Adds the new /api/github/audit and /api/github/routing handlers plus tenancy tests. |
| crates/store/src/lib.rs | Adds AuditEvent and Store::audit_events to assemble a lifecycle stream from durable sources. |
| crates/server/src/main.rs | Registers the new routes on the Axum router. |
| crates/config/src/lib.rs | Adds RoutingView and Config::routing_view to expose effective installation routing configuration. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+458
to
+463
| let view = state.config.routing_view(installation_id); | ||
| let _ = state | ||
| .store | ||
| .record_api_read(&caller, &installation_id.to_string(), action, "ok") | ||
| .await; | ||
| Json(json!({ "ok": true, "routing": view })).into_response() |
Comment on lines
+440
to
+443
| ApiCaller::Tenant(tenant) => ( | ||
| format!("tenant:{}", tenant.installation_id), | ||
| tenant.installation_id, | ||
| ), |
Comment on lines
+530
to
+536
| pub async fn audit_events(&self, scope: Option<ApiScope>, limit: u32) -> Result<Vec<AuditEvent>> { | ||
| let conn = self.conn.clone(); | ||
| tokio::task::spawn_blocking(move || { | ||
| let conn = conn.lock().expect("store mutex poisoned"); | ||
| let inst = scope.as_ref().map(|s| s.installation_id); | ||
| let mut events: Vec<AuditEvent> = Vec::new(); | ||
|
|
Comment on lines
+444
to
+456
| ApiCaller::Service | ApiCaller::Open => { | ||
| match params.get("installation_id").and_then(|s| s.parse::<u64>().ok()) { | ||
| Some(id) => ("service".to_string(), id), | ||
| None => { | ||
| return ( | ||
| StatusCode::BAD_REQUEST, | ||
| Json(json!({"ok": false, "error": "installation_id required"})), | ||
| ) | ||
| .into_response() | ||
| } | ||
| } | ||
| } | ||
| }; |
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.
Closes #18. The coven-github data behind Cave's four oversight views. Two of the four already had endpoints from earlier work; this adds the two that were missing.
The four dashboard views
GET /api/github/tasksGET /api/github/usageGET /api/github/routingGET /api/github/auditWhat's new
GET /api/github/routing[?installation_id=N]—Config::routing_viewresolves an installation's effective familiars, trigger lanes, and per-repo overrides (open routing / listed allow-list / fail-closed), mirroring Add installation-scoped familiar routing and repository policy #7'sscope_forat the installation level. A tenant sees its own installation; the service token names one via the query string.GET /api/github/audit—Store::audit_eventsassembles a tenant-scoped, newest-first task-lifecycle stream from three durable sources: ignored deliveries (acceptance rejections), task attempts (execution / retries / timeout / failure), and opened PRs (publication) — exactly the audit events Build Cave oversight dashboard for task history, routing, usage, and audit #18 asks for.Both endpoints use the same tenant boundary as the rest of the API (
tokenmode fails closed, tenant tokens are installation-scoped, every read audited), and the Cave UI (coven-cave repo) consumes them. README's capabilities table gains a Cave-oversight-dashboard row.Scope
This is the adapter's data side. The dashboard rendering lives in coven-cave. "Human intervention" audit events (cancel/deepen commands) are already recorded via
api_audit; the stream here focuses on task lifecycle.Local gates:
cargo check --all-targets+cargo clippy --all-targets -- -D warnings+cargo test --all(228 passed, 0 failed).🤖 Generated with Claude Code