Repository navigation
fix(audit): attribute manual agent-token management to the user (#149) - #157
Merged
Merged
Conversation
Creating or revoking an agent token is performed by the human user; the configured agent name only identifies the connection. The audit table already stored the user as actor, but the audit log renderer showed "User, via Agent" for any event carrying metadata.agentName, which made manual token management look agent-performed. - Add shared audit metadata helpers: agent-performed actions are marked viaAgent, manual connection management is marked managedConnection. - Mark MCP and collaboration agent edits with viaAgent; mark token created/revoked with managedConnection and record the agent name on revocation too. - Render ", via Agent" only for viaAgent events; manual token events show the agent as a separate "For agent:" detail. Refs #149 Signed-off-by: Leo Stehlik <[email protected]>
Signed-off-by: Leo Stehlik <[email protected]>
Signed-off-by: Leo Stehlik <[email protected]>
…ution Signed-off-by: Leo Stehlik <[email protected]> # Conflicts: # apps/client/src/wrenlore/audit/components/audit-logs-table.tsx
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 #149
Fixes: audit entries for manually created/revoked agent tokens rendered as "Leo, via Francis" although the agent performed no action.
Findings
The stored row was already correct (
actorId= the human,actorType: 'user'); the defect was in rendering: the audit table appended ", via " for any event carryingmetadata.agentName, which includes token-management events where the name merely identifies the connection being created. Genuine agent actions (MCP tools, agent page edits) carry the same field, so display text alone couldn't distinguish them.Changes
apps/server/src/common/audit/agent-audit.ts:agentPerformedAuditMetadata()→viaAgent: true(used byagent.create_page,agent.add_comment,agent.page_edited);agentConnectionManagedAuditMetadata()→managedConnection: true(used byagent.token_created, and now alsoagent.token_revoked, which previously stored no metadata at all).getAuditAttribution()renders ", via Agent" only forviaAgentevents; manual token events show the agent as a separate dimmed "For agent: …" detail under the human actor. Stored metadata and rendering now both encode the distinction.agentNameon genuinely agent-performed actions — unchanged.Tests
managedConnectionand noviaAgent; token secrets never reach audit rows; helper semantics pinned. Full server suite: 32 suites / 226 tests pass; clienttscclean.QA Leo+For agent: Francis(no "via"); a realcreate_pagecall with the token showsQA Leo, via Francis; manual revocation showsFor agent: Francis.Compatibility note
Historical
agent.token_createdrows (pre-this-change) haveagentNamebut noviaAgent, so they will render as "For agent: …" — the conservative direction (never over-attribute to the agent).Review follow-up: preserve historical attribution for the known agent.create_page, agent.add_comment and agent.page_edited events that predate viaAgent. Unknown metadata is not treated as either actor or connection attribution. Added client-helper regression tests and CI coverage for both stored metadata and presentation. No historical rows are rewritten.