feat(audit): log_action_safe + V22 blocks_stale + citation resolver (FU-7)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-30 21:29:26 +00:00
parent bffd2ec701
commit a121f79d6a
2 changed files with 61 additions and 1 deletions

View File

@@ -44,6 +44,26 @@ async def log_action(
json.dumps(details or {}, ensure_ascii=False)[:200])
async def log_action_safe(
action: str,
case_id: "UUID | None" = None,
document_id: "UUID | None" = None,
details: dict | None = None,
user: str = "system",
) -> None:
"""Non-fatal audit: never let an audit-log failure break the caller's action.
The authoritative integrity trail is git (X5 §2.1); audit_log is the
'who/what/when' observability layer, so a write failure is logged as a
warning and swallowed.
"""
try:
await log_action(action, case_id=case_id, document_id=document_id,
details=details, user=user)
except Exception as e: # noqa: BLE001 — observability must not break the op
logger.warning("audit log_action failed (non-fatal) for %s: %s", action, e)
async def get_audit_log(
case_id: UUID | None = None,
action: str | None = None,