Repository navigation
fix(audit): log() not log_event() in proactive messages (#374) - #416
Merged
Merged
Conversation
4 tasks
…sages (#374) _audit_send called platform_audit_service.log_event(...) which never existed — the try/except swallowed the AttributeError so every proactive message silently failed to write an audit row. Fixed by awaiting platform_audit_service.log() with the correct kwargs (actor_agent_name replaces actor_type/actor_id). _audit_send is now async; all four call sites in send_message awaited. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
can_agent_message_email crashed with AttributeError when the agent owner's users.email column was NULL — dict.get's default only applies when the key is absent, not when the value is None. Broke every proactive messaging call for admin-owned agents (admin has NULL email on fresh installs), returning generic HTTP 500 and swallowing the audit row as collateral damage. Discovered while live-verifying #374 fix in the same PR. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
dolho
force-pushed
the
fix/374-audit-log-event-method
branch
from
April 20, 2026 08:21
4b01e80 to
319e2b6
Compare
Adds a regression test that stubs db.can_agent_message_email, rate limit, and _deliver_via_channel to return success, then calls send_message and asserts platform_audit_service.log received the success=True audit. Guards against regressions where the success-branch await at the end of send_message silently drops (sync regression, forgotten await). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
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
Closes #374.
proactive_message_service._audit_sendcalledplatform_audit_service.log_event(...)— a method that does not exist onPlatformAuditService(the real method islog()). The call was wrapped intry/exceptso theAttributeErrorsurfaced only as aWARNING: Failed to audit proactive message: 'PlatformAuditService' object has no attribute 'log_event', and no audit row was ever written for a proactive message — a silent coverage hole in the SEC-001 audit trail.Fix
_audit_sendis nowasyncand awaitsplatform_audit_service.log(...).actor_agent_name="..."replaces the non-existentactor_type="agent"+actor_id=...pair (actor resolution is now delegated tolog()'s internal_resolve_actor).send_messagenowawait self._audit_send(...).Test plan
tests/test_proactive_audit_unit.pywith 3 cases:log()invoked with correct kwargs (actor_agent_name,target_type,target_id,details, no legacyactor_type/actor_id)message_previewtruncated to 100 charsaudit_logwithevent_type=proactive_message(deferred — requires rebuilt backend).🤖 Generated with Claude Code