{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:orbiplex:schema:signal-transform-event:v1",
  "title": "SignalTransformEvent v1",
  "description": "Machine-readable schema for auditable records of transformations applied to user signal when the output is no longer raw.",
  "x-dia-basis": [
    "doc/normative/40-constitution/pl/CONSTITUTION.pl.md",
    "doc/normative/50-constitutional-ops/pl/RAW-SIGNAL-POLICY.pl.md"
  ],
  "type": "object",
  "additionalProperties": true,
  "required": [
    "schema/v",
    "transform_id",
    "source_ref",
    "input_mode",
    "output_mode",
    "actor_type",
    "requested_by",
    "basis_ref",
    "operations",
    "created_at"
  ],
  "properties": {
    "schema/v": {
      "const": 1,
      "description": "Schema version."
    },
    "transform_id": {
      "type": "string",
      "minLength": 1,
      "description": "Stable identifier of this transformation event."
    },
    "source_ref": {
      "type": "string",
      "minLength": 1,
      "description": "Stable reference to the source message, segment, or artifact before transformation."
    },
    "output_ref": {
      "type": "string",
      "minLength": 1,
      "description": "Optional reference to the produced artifact after transformation."
    },
    "marker_ref": {
      "type": "string",
      "minLength": 1,
      "description": "Optional reference to the visible SignalMarker attached to the output."
    },
    "input_mode": {
      "type": "string",
      "enum": [
        "raw",
        "structured",
        "transformed",
        "redacted"
      ],
      "description": "Signal mode of the source artifact before the transformation step."
    },
    "output_mode": {
      "type": "string",
      "enum": [
        "structured",
        "transformed",
        "redacted"
      ],
      "description": "Signal mode of the produced artifact after the transformation step."
    },
    "actor_type": {
      "type": "string",
      "enum": [
        "ai",
        "human",
        "hybrid"
      ],
      "description": "Who materially performed the transformation."
    },
    "requested_by": {
      "type": "string",
      "enum": [
        "user",
        "user_policy",
        "safety_policy",
        "exception"
      ]
    },
    "basis_ref": {
      "type": "string",
      "minLength": 1,
      "description": "Reference to the prompt, policy, rule, exception, or other basis authorizing the transformation."
    },
    "operations": {
      "type": "array",
      "minItems": 1,
      "uniqueItems": true,
      "items": {
        "$ref": "#/$defs/operation"
      }
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    },
    "visibility_scope": {
      "type": "string",
      "enum": [
        "user-visible",
        "same-interface",
        "audit-only"
      ],
      "description": "How the fact of transformation is surfaced relative to the transformed artifact."
    },
    "content_disclosure": {
      "type": "string",
      "enum": [
        "full",
        "partial",
        "metadata-only"
      ],
      "description": "How much of the transformed content is available to a given audit path."
    },
    "policy_annotations": {
      "type": "object",
      "additionalProperties": true
    }
  },
  "$defs": {
    "operation": {
      "type": "string",
      "enum": [
        "structure_extraction",
        "summarization",
        "translation",
        "tone_shift",
        "formality_shift",
        "style_polish",
        "safety_redaction",
        "privacy_redaction"
      ]
    }
  },
  "allOf": [
    {
      "if": {
        "properties": {
          "output_mode": {
            "const": "redacted"
          }
        },
        "required": [
          "output_mode"
        ]
      },
      "then": {
        "properties": {
          "operations": {
            "contains": {
              "enum": [
                "safety_redaction",
                "privacy_redaction"
              ]
            }
          }
        }
      }
    }
  ]
}
