{
  "handle": "OutputGuard",
  "mechanism": "Post-generation content filter. Scans candidate {{solution}} against PII patterns and Toxicity Classifiers. If Score > Threshold, triggers mitigation (Redact/Reject). It mirrors the logic of input guard but applied to egress traffic, scanning for leakage or toxicity.",
  "gloss": "Final egress filter for safety and privacy",
  "failure_modes": [
    "Scunthorpe {{problem}}: Over-censorship blocking valid words containing restricted substrings.",
    "Semantic context blindness: Guard blocks necessary medical terms misclassified as toxicity.",
    "Redaction Leak: [REDACTED] markers revealing the location/length of hidden secrets."
  ],
  "invariants": [
    "Fail-Safe: If Scanner fails (timeout/error), Output is BLOCKED (not passed).",
    "Privacy First: detected PII must not reach egress unmitigated. Which mitigation applies — redaction, blocking, or hashing — is the caller's `pii_mode` choice; what is mandatory is that one of them runs, since blocking is stronger than redaction where the content cannot be safely salvaged."
  ],
  "preconditions": [
    "Candidate solution generated",
    "Safety policies active"
  ],
  "postconditions": [
    "Safe output delivered OR Block signal returned"
  ],
  "parameters": [
    {
      "name": "pii_mode",
      "type": "Enum",
      "range": "{Redact, Block, Hash}",
      "description": "Default: Redact"
    },
    {
      "name": "scan_timeout",
      "type": "Duration",
      "range": "unspecified",
      "description": "Default: 500ms"
    },
    {
      "name": "toxicity_threshold",
      "type": "Float",
      "range": "[0.0, 1.0]",
      "description": "Default: 0.8"
    }
  ],
  "_meta": {
    "tier": 2,
    "ring": 0,
    "supersedes": [
      "sema:OutputGuard#mh:SHA-256:eb44b7e751219a94f752bb8827843ede1045bc1a4195d9d0db3648f9ae097bb0",
      "sema:OutputGuard#mh:SHA-256:32b0ffd08f916d61a677af7d82c53feb8a4019baab1bd86622a853aafa91ed2f",
      "sema:OutputGuard#mh:SHA-256:1396cd3b7d51a56b178382a521d22ae7f478d4681ea7e31d5af1d625857ad315",
      "sema:OutputGuard#mh:SHA-256:fa36290c5575e62bc35a5196e93536286575b2c6dbeb13db64e000bbd487e8d3"
    ],
    "path": [
      "Infrastructure",
      "Verification"
    ]
  },
  "sema_id": "sema:OutputGuard#mh:SHA-256:3618ee4d6aa243c10c16af73e4a385a6fa0c60ee193edb0a67d23e2c8d57f93e",
  "sema_ref": "OutputGuard#3618",
  "sema_stub": "3618",
  "dependencies": {
    "accepts": {
      "solution": "sema:Solution#mh:SHA-256:8d55004ffa8f61d6e7d12d588ae4baa9723296dd7fa501759b5e6b1b97e7c9ab"
    },
    "references": {
      "problem": "sema:Problem#mh:SHA-256:2580c43677ec78ee7ee428d200662c6096e4eab38c2c5a868154979074cc0f08"
    }
  },
  "sema_layer": "Infrastructure",
  "sema_category": "Verification",
  "used_by": {
    "composes_with": {
      "AgentSandbox": "sema:AgentSandbox#mh:SHA-256:1594a10a882956e4b8501764091e1d5025ba0b405cce34b7ef931bb17e5c634a"
    },
    "references": {
      "FailClosed": "sema:FailClosed#mh:SHA-256:dfbcf50c68d036ae4f18719bf59f41eddd83b5510bd60ff1326f8854240d8066"
    }
  }
}
