Files
roboco/roboco/models/audit.py
T
Renn F b4c129051f chore(comms): retire remaining dead channel residue
Completes the reference cleanup with the genuinely-dead comms bits (the live
extraction pipeline + Campaign.channels marketing field are kept):

- models/audit.py: remove the dead CHANNEL_ACCESS_DENIED enum member (str-backed
  column, no migration; its do_server/flow_server map keys were removed in 925e00d4)
- panel stream.ts: remove the dead getChannelPermissions method (no matching
  backend route — routes/stream.py serves only GET /permissions). Kept the
  ChannelPermissions interface (still used by the live getPermissions) and every
  other streamApi method (submit/complete/extract/stats/permissions hit live endpoints)
- api/schemas/stream.py: reword stale 'channel' field descriptions on live
  extraction fields (Target stream / Group within stream)
- panel knowledge-base.ts: fix a mock-mode example source string

No regressions: only provably-dead code retired; extraction pipeline untouched.
2026-07-04 05:38:33 +02:00

58 lines
1.3 KiB
Python

"""
Audit Models
Data classes for audit logging and security events.
"""
from dataclasses import dataclass, field
from enum import StrEnum
from typing import Any
from uuid import UUID
class AuditEventType(StrEnum):
"""Types of audit events."""
# Permission denials
PERMISSION_DENIED = "permission_denied"
TASK_ACTION_DENIED = "task_action_denied"
NOTIFICATION_DENIED = "notification_denied"
STATE_TRANSITION_DENIED = "state_transition_denied"
# Security events
UNAUTHORIZED_ACCESS = "unauthorized_access"
INVALID_TOKEN = "invalid_token"
RATE_LIMIT_EXCEEDED = "rate_limit_exceeded"
# Administrative events
ROLE_CHANGED = "role_changed"
ACCESS_GRANTED = "access_granted"
ACCESS_REVOKED = "access_revoked"
# PM override events
PM_OVERRIDE = "pm_override"
@dataclass
class PermissionDenialContext:
"""Context for a permission denial audit log."""
agent_id: UUID | str
action: str
resource: str
resource_id: UUID | str | None = None
reason: str | None = None
details: dict[str, Any] = field(default_factory=dict)
@dataclass
class StateTransitionDenialContext:
"""Context for a state transition denial audit log."""
agent_id: UUID | str
agent_role: str
task_id: UUID | str
current_status: str
target_status: str
reason: str | None = None