Repository navigation
feat: audit service client (/audit/v1 — apikeys + traces) - #85
Merged
Merged
Conversation
nycomp
force-pushed
the
feat/audit-service
branch
from
October 4, 2026 01:34
38b52ad to
180cd88
Compare
New campus_python.audit.v1 package, mounted as Campus.audit: - AuditRoot authenticates with a dedicated audit API key (AUDIT_API_KEY env var, audit_v1_...) as a Bearer token on its own CampusRequest — the audit service rejects CLIENT_ID/CLIENT_SECRET — with base URL resolved like the other services (CAMPUS_AUDIT_URL, then ENV defaults: development Railway / staging / production audit domains). - apikeys: new/list/get/update/revoke/regenerate; bool query values sent as lowercase literals (flask_campus _BOOL_LITERALS contract); update refuses empty payloads like the server; plaintext key values surface only at new()/regenerate(). - traces: ingest (batch spans), list/search with cursor pagination, trace tree get, flat spans list, single span get. Fixes #77
nycomp
force-pushed
the
feat/audit-service
branch
from
October 4, 2026 01:47
180cd88 to
1118a1c
Compare
This was referenced Oct 4, 2026
ngjunsiang
added this pull request to stack #86
October 4, 2026 03:05
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
New
campus_python.audit.v1package wired ascampus.audit, covering the audit service surface (campusweekly@ 24adffc,campus/audit/routes/) — the last uncovered Campus service.Auth mode. The audit service authenticates with its own API keys (
audit_v1_...Bearer tokens), not CLIENT_ID/CLIENT_SECRET, soCampus.auditbuilds a dedicatedCampusRequestin device mode (no app credentials required) and setsAuthorization: Bearer. Base URL resolves like the other services:CAMPUS_AUDIT_URLfirst, then ENV defaults (development Railwaycampusaudit-development, stagingaudit.campus.nyjc.dev, productionaudit.campus.nyjc.app— matchingcampus/config.py).apikeys —
audit.apikeys.new(name, owner_id, scopes, rate_limit=None, expires_at=None)(returns the record with the one-time plaintextapi_key),.list(owner_id, active_only=True, limit), and per-key.get/.update/.revoke/.regenerate. Details pinned from the server: bool query values are sent as lowercasetrue/false(flask_campus_BOOL_LITERALSrejects Python'sTruecapitalization → 422);updateraisesValueErroron an empty payload (server: "No mutable fields provided"); item routes carry trailing slashes,regenerateis a leaf.traces —
audit.traces.ingest(spans)(batch; 207 partial failure surfaces in the returned body),.list(since, until, limit, cursor)and.search(path, status, api_key_id, client_id, user_id, ...)with{traces, cursor: {next, has_more}}pagination,traces[trace_id].get()(root-span tree envelope), and.spans.list()/.spans[span_id].get().Tests
tests/unit/test_audit.py— 15 tests: every route's path (slash rules included), body/query shapes, the lowercase-bool wire contract, empty-update guard, andCampus.auditwiring (URL resolution + Bearer header + missing-key OSError). Full suite: 161 passed.Fixes #77