symfonic.capabilities.memory.positional_audit¶
positional_audit ¶
Audit evidence for CORE-171 positional migrations and quarantine deletions.
Every operation that moves or deletes a row records itself through the
audit= logger its caller passes: any object with an async record(entry),
which is the shape of :class:symfonic.core.observability.audit.AuditLogger
and of the durable logger the scaffold registers (pass
get_audit_logger()). Without one the operation refuses before reading, so
a quarantine decision or a deletion never happens without a trail. The entry
is :class:PositionalAuditEntry, which carries the field names those loggers
read; this layer may not import the core model itself.
initiated is recorded inside the backend transaction, after the rows are
re-checked and before any of them changes; a logger that raises there aborts
the transaction and nothing moves. That entry is the justification: tenant,
each row's kind and id, its prior owner path and the reason it was moved or
deleted, and a digest binding the set. completed or failed follows
best-effort, as for every audited deletion here: a logger that fails after
commit is logged, not raised, because the rows have already changed.
Owner paths are identifiers, not memory content; record text, embeddings and backend error text are never recorded. The actor is whatever the caller names and is not authenticated here. Without one the entry says so and records only the explicit operator operation that ran. Durability is the logger's: an in-memory logger keeps nothing past the process.
PositionalAudit ¶
One operation's audit trail, bound to its logger, tenant and actor.
Source code in src/symfonic/capabilities/memory/positional_audit.py
initiated
async
¶
Record the justification; raising here must abort the operation.
Source code in src/symfonic/capabilities/memory/positional_audit.py
settled
async
¶
Record the result after commit or abort; never raises.
Source code in src/symfonic/capabilities/memory/positional_audit.py
PositionalAuditEntry
dataclass
¶
PositionalAuditEntry(tenant_id: str, user_id: str | None, action: str, resource_type: str, resource_id: str | None, metadata: dict[str, Any], timestamp: datetime = (lambda: datetime.now(UTC))(), ip_address: str | None = None, user_agent: str | None = None)
One audit event, field-compatible with the core AuditLogEntry.
to_dict ¶
A JSON-safe dict, as AuditLogEntry.to_dict returns.
Source code in src/symfonic/capabilities/memory/positional_audit.py
prior_owner ¶
The owner path a quarantine key replaced; a malformed key names itself.
Source code in src/symfonic/capabilities/memory/positional_audit.py
row_digest ¶
A digest of exactly the rows an operation named, in order.