Skip to content

Record an audit log of key and deletion actions - #365

Merged
dipeshbabu merged 2 commits into
mainfrom
feat/audit-log
Nov 20, 2026
Merged

dipeshbabu merged 2 commits into
mainfrom
feat/audit-log

Conversation

@dipeshbabu

Copy link
Copy Markdown
Owner

A shared server now has security-relevant actions (key creation/revocation, trace deletion, retention purges) but kept no record of who did them.

  • Migration 6 `audit_log`: `audit_events` (id, occurred_at, project_id, action, actor, target, details_json) + index, SQLite and Postgres; idempotent like the others.
  • Store: `create_api_key`, `revoke_api_key`, `delete_trace`, `purge_traces` take an `actor` (default `local`) and append an event in the same transaction. No-op revokes and purges record nothing. `list_audit_events(project_id=None, limit=100)` returns newest first. Key values are never recorded (only prefixes).
  • Actors: `admin-api`, `api-key:` (project-key trace deletes), `cli`, `retention:AGENTLOOP_RETENTION_DAYS` (purges without an explicit age, e.g. the cloud retention service), `dashboard` / `dashboard:api-key:`.
  • Read access (admin only): `GET /v1/audit-events`, `AgentLoopClient.list_audit_events`, `agentloop audit-log`, `agentloop remote-audit-log`.

Tests: store contract (both backends in CI) incl. ordering, no-op actions, project filter and no secrets; API admin-only access and actors; CLI; client URL/header scope; migration version sets updated. 246 related tests pass locally. Docs: PRODUCTION (Audit log), CLOUD_DEPLOY, API_VERSIONING, changelog.

🤖 Generated with Claude Code

A shared server had no record of who created or revoked API keys,
deleted traces or purged them. Migration 6 adds an audit_events table in
both stores, written in the same transaction as each action: API keys
created and revoked, traces deleted, and retention purges that removed
traces, with project, target, counts and the acting identity. Admins
read it through GET /v1/audit-events, AgentLoopClient.list_audit_events
and the audit-log and remote-audit-log commands. Key values are never
recorded.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

AgentLoop replay self-test

This required repository check evaluates generated synthetic demo traces. It tests the replay and CI machinery; it does not show that this PR improves application performance.

AgentLoop CI Report

  • Status: passed
  • Replay: Replay passed: latency improvement 69.67%, cost improvement 78.82%, retry delta -1.
  • Merge recommendation: synthetic self-test only; assess application traces before merge
  • Findings: 1 total, 0 high severity, 1 patchable

Performance Gates

Gate Status Detail
latency_regression pass 0.00% regression <= 0.00% allowed
cost_regression pass 0.00% regression <= 0.00% allowed
latency_improvement pass 69.67% improvement >= 20.00% required
cost_improvement pass 78.82% improvement >= 5.00% required
retry_non_increase pass 0 candidate retries <= 1 baseline retries

Trace inputs

This comparison includes synthetic data. It does not establish application performance gains from a pull request.

Side Run ID Path Synthetic marker Source
baseline run_bc45194e63a243c5 runs/research_agent_baseline.json yes agentloop_demo
candidate run_0877b7272b9145c4 runs/research_agent_optimized.json yes agentloop_demo

Metric Impact

Metric Impact
Latency improvement 69.67%
Cost improvement 78.82%
Retry delta -1
Candidate schema validity not provided
Candidate quality score not provided

Top Findings

Finding Severity Type Rewrite
al_cache_context_d810b76d9dd0: Cache repeated prompt/context prefix medium cache_context Move stable instructions into cached prefixes, summaries, or framework-level memory instead of resending full text.

The Postgres fixtures truncated every table except the new audit_events, so events from earlier tests leaked into the audit-log test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dipeshbabu
dipeshbabu merged commit f8dfe7c into main Nov 20, 2026
27 checks passed
@dipeshbabu
dipeshbabu deleted the feat/audit-log branch November 20, 2026 16:22
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