Skip to content

Admin audit: server-side filters + per-grant use counts - #719

Open
time-attack wants to merge 32 commits into
yc-software:mainfrom
time-attack:grant-usage-audit-ready
Open

Admin audit: server-side filters + per-grant use counts#719
time-attack wants to merge 32 commits into
yc-software:mainfrom
time-attack:grant-usage-audit-ready

Conversation

@time-attack

@time-attack time-attack commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

Supersedes #713 (closed, unmerged) — same change, now with the missing test coverage and the one stray comment removed.

Backs the admin per-grant usage view with real Postgres queries instead of the 200-event tail:

  • `AuditLog.tail` gains `resourceContains`; new optional `tallyByResource(action)`
  • Postgres impl: `LIKE` filter, grouped count query, `(action, at DESC)` index
  • `GET /v1/admin/audit` accepts `?action=&resource=&limit=` (cap 2000 when filtered, 200 unfiltered as before)
  • `GET /v1/admin/keychain` grants now carry `useCount` derived from `keychain.materialize` audit rows

New in this PR over #713

  • Removed a docblock in `audit-log.ts` that violated the zero-comments rule.
  • Tests covering the new behavior:
    • unit + pg: `tail` `resourceContains` substring filter; `tallyByResource` per-resource counts for one action
    • `/v1/admin/audit`: action / resource / limit filters constrain results
    • `/v1/admin/keychain`: `useCount` counts `(grant )` rows only, ignoring owner-auth rows and unrelated grant ids

Verified: tsc + eslint clean; the 5 Postgres tests pass against real Postgres; 30 non-pg tests pass. Also exercised end-to-end live (filters + useCount) against a booted instance.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

open-swe and others added 30 commits August 2, 2026 21:12
…oarding

Under HARNESS=claude with only CLAUDE_CODE_OAUTH_TOKEN (or ANTHROPIC_AUTH_TOKEN),
turns work but the deployment reported itself unconfigured: surface-config's
modelProviderConfigured only consulted the credential store, and the admin
onboarding badge said 'Needs a key'.

harnessCarriedModelAuth(config) names the provider a harness authenticates on
its own (claude -> anthropic via OAuth/auth token, codex -> openai via
CODEX_ACCESS_TOKEN). It is OR'd into modelProviderConfigured and exposed to the
admin as a sibling harnessAuth field on GET /v1/admin/model-providers. The
credential-store statuses stay untouched: anthropic still reports absent,
because those keys feed pi-transport calls and deleting or adding them is
independent of harness OAuth.
Co-Authored-By: QM <qm@ycombinator.com>
Invert PR 690's auth flow: the subscription login is a per-user keychain
credential, core is the single custodian and refresher, and harnesses
receive derived ephemeral material at spawn (Codex: minimal auth.json
without the refresh token; Claude: injected env token).

- CodexAuthStore abstraction: keychainCodexAuthStore (production,
  CODEX_AUTH_CREDENTIAL) and fileCodexAuthStore (local dev, CODEX_AUTH_FILE),
  both with central refresh and single-flight rotation
- claude harness authEnv hook + keychainHarnessAuthEnv (CLAUDE_AUTH_CREDENTIAL)
- child auth.json never carries the refresh token; no sync-back path,
  so the lock-file persistence machinery and JWKS re-verification are gone
- production ban now applies only to the file path; keychain path is the
  supported production route
ReganBell and others added 2 commits August 28, 2026 15:34
- AuditLog.tail gains resourceContains; optional tallyByResource(action)
- Postgres impl: LIKE filter, grouped count query, (action, at) index
- /v1/admin/audit accepts ?action=&resource=&limit= (cap 2000 when filtered)
- /v1/admin/keychain grants now carry useCount from keychain.materialize audit rows
Adds the missing coverage for 499cc64 and removes the one comment that
violated the repo's zero-comments rule:

- audit-log unit + pg: tail resourceContains substring filter, tallyByResource
  per-resource counts scoped to one action
- admin/audit route: action / resource / limit filters constrain results
- admin/keychain route: grant useCount counts (grant <id>) materialize rows,
  ignoring owner-auth rows and unrelated grant ids

pg tests are DATABASE_URL-gated (green locally against real Postgres); tsc + eslint clean.
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.

6 participants