feat: add agent API key lifecycle - #6071
Conversation
|
|
Running ultrareview automatically — This PR introduces a complete agent API-key lifecycle with delegated policy, atomic rotation, expiry enforcement, and audit, spanning authentication, database, and generated API layers — a subtle bug could break authorization or leak credentials, so it warrants a deep multi-pass review.. I'll post findings when complete. |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Ultrareview completed in 13m 9s
All reported issues were addressed across 25 files
Linked issue analysis
Linked issue: AIM-194: feat: add agent API-key lifecycle on existing API keys
| Status | Acceptance criteria | Notes |
|---|---|---|
| Agent keys use ordinary api_keys rows and existing key generation, hashing, lookup, one-time display, and revocation behavior without a new key format. | The PR adds agent-key persistence alongside existing API-key flows and documents reuse of the existing format, but the provided diff does not show all generation and display paths. | |
| ✅ | Issue, list, rotate, and direct-revoke lifecycle operations are available for first-class agent keys. | The PR adds agent-aware payloads, a rotate endpoint, generated client/server support, and an agent-key implementation covering the lifecycle. |
| Agent-key issuance enforces agent identity, tenant and owner eligibility, caller authority, delegated-policy constraints, supported version, and required expiry with a 90-day default and one-year maximum. | The agent-key implementation and expanded request types indicate these validations, but the supplied diff does not expose enough validation code or test cases to verify every rejection condition. | |
| Owner and exact agent:authorize caller matrices deny unauthorized callers, including agents, ordinary API keys, support sessions, and cross-tenant callers, without existence disclosure. | Dedicated agent-key tests and authorization dependencies are present, but the provided excerpts do not show the complete denial matrix or response behavior. | |
| Rotation atomically creates a replacement with newly approved delegation and authorizer while directly revoking the old key. | The PR explicitly claims transactional replacement and direct revocation, and adds the rotate endpoint, but the transaction and old-row revocation details are not visible in the supplied excerpts. | |
| Authentication uses live agent admission and rejects malformed, expired, revoked, cross-tenant, or parent-blocked agent keys while preserving legacy null-principal behavior. | The PR describes parent-authoritative runtime admission and isolates legacy queries from principal-backed rows, but the supplied diff does not show the full authentication-path checks. | |
| ✅ | Agent credential management is gated for issuance, listing, and rotation, while direct revocation remains available with the gate disabled and production rollout waits for the integrated safety gate. | The PR explicitly describes the M2 gate behavior and adds the corresponding feature flag. |
Tip: instead of fixing issues one by one fix them all with cubic
Re-trigger cubic
There was a problem hiding this comment.
All reported issues were addressed across 25 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
|
|
||||||||||||||||
|
|
||||||||||||||||
Summary
Adds issue, list, rotate, and direct revoke lifecycle support for first-class agent API keys through the existing keys API and
api_keysmodel. Agent keys carry immutable delegated policy and authorizer attribution, required expiry, one-time secrets, transactional audit history, and parent-authoritative runtime admission.Motivation
AIM-194 requires independently revocable, least-privilege credentials for first-class agents without introducing a parallel credential model or transport.
Impact
Agent credential issuance, listing, and rotation remain behind the M2 organization feature gate; direct revocation remains available when the gate is disabled. Legacy API-key creation, listing, authentication, and revocation remain isolated from principal-backed rows.
Technical details
Atomic replacement
Rotation revokes the old key before creating its replacement in one transaction, which supports same-name replacement while rolling back revocation and audit writes if creation fails.
Stacked dependency
Depends on #6068 for live parent, owner, and delegated-policy admission semantics.
Summary by cubic
Adds agent API-key issue, list, rotate, and revoke lifecycle through the existing keys API, satisfying AIM-194. Agent keys reuse the
api_keysmodel as ordinary rows with immutable delegated policy, required expiry, and parent-authoritative admission.POST /rpc/keys.rotate) revokes the old row and creates a replacement in one atomic operation with freshly approved delegation.agent/agent_usertransport scopes keep prior behavior.Written for commit c3b93e1. Summary will update on new commits.