Skip to content

llm.redact — Redaction Audit Record

Note: This namespace records metadata about a redaction operation — for example, which PII categories were detected and which fields were affected. It is distinct from the runtime spanforge.redact module that performs the actual field-level redaction.

Auto-documented module: spanforge.namespaces.redact

The llm.redact.* namespace provides payload dataclasses for PII and PHI detection events and redaction audit records (RFC-0001 §2).

Payload classes

ClassEvent typeDescription
RedactPiiDetectedPayloadllm.redact.pii.detectedPII was detected in event fields
RedactPhiDetectedPayloadllm.redact.phi.detectedPHI was detected in event fields
RedactAppliedPayloadllm.redact.appliedA redaction policy was applied

RedactPiiDetectedPayload — key fields

FieldTypeRequiredDescription
detected_categorieslist[str]PII category strings detected (e.g. ["email", "phone"]). Minimum 1.
field_nameslist[str]Payload field paths where PII was found. Minimum 1.
sensitivity_levelstrHighest level encountered: "LOW", "MEDIUM", "HIGH", "PII", or "PHI"
detection_countint | NoneTotal number of individual PII instances found
detectorstr | NoneDetector identifier (e.g. "presidio-v2")
subject_event_idstr | NoneULID of the event containing PII

Example

from spanforge import Event, EventType
from spanforge.namespaces.redact import RedactPiiDetectedPayload

payload = RedactPiiDetectedPayload(
    detected_categories=["email", "phone"],
    field_names=["payload.prompt", "payload.completion"],
    sensitivity_level="PII",
    detection_count=3,
    detector="presidio-v2",
)

event = Event(
    event_type=EventType.REDACT_PII_DETECTED,
    source="redactor@1.0.0",
    org_id="org_01HX",
    payload=payload.to_dict(),
)