← Files ClaraARCHIVED FILE

contracts/preparation_audit_envelope.v2.schema.json

7.96 KB · Oct 5, 2026 · 00:02 UTC

↓ Download file

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://mparanza.com/schemas/clara/preparation-audit-envelope-v2.json",
  "title": "Clara preparation audit envelope — exact local source profile",
  "description": "A narrow v2 profile of the preparation audit envelope for exact local-source pilots. Artifacts are addressed below caller-supplied plugin and pilot roots; remote source receipts are prohibited. This contract proves exact local bytes and mechanical consistency at validation time, not source authority, semantic correctness, report readiness, or publication eligibility.",
  "$comment": "validate_audit_envelope_v2 is authoritative for named-root containment and identity, exact artifact replay, cross-artifact root capabilities, digest closure, references, lineage, and status consistency.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_version",
    "case",
    "adapter",
    "local_artifacts",
    "remote_sources",
    "reviewed_decisions",
    "execution",
    "numeric_policy",
    "reconciliation",
    "lineage",
    "statuses",
    "report_ready",
    "limitations"
  ],
  "properties": {
    "schema_version": {
      "const": "clara.preparation_audit_envelope.v2"
    },
    "case": {
      "$ref": "https://mparanza.com/schemas/clara/preparation-audit-envelope-v1.json#/$defs/case"
    },
    "adapter": {
      "$ref": "https://mparanza.com/schemas/clara/preparation-audit-envelope-v1.json#/$defs/adapter"
    },
    "local_artifacts": {
      "type": "array",
      "minItems": 1,
      "uniqueItems": true,
      "items": {
        "$ref": "#/$defs/named_root_artifact_receipt"
      },
      "allOf": [
        {
          "contains": {
            "type": "object",
            "required": [
              "root_id"
            ],
            "properties": {
              "root_id": {
                "const": "plugin"
              }
            }
          },
          "minContains": 1
        },
        {
          "contains": {
            "type": "object",
            "required": [
              "root_id"
            ],
            "properties": {
              "root_id": {
                "const": "pilot"
              }
            }
          },
          "minContains": 1
        },
        {
          "contains": {
            "type": "object",
            "required": [
              "root_id",
              "role"
            ],
            "properties": {
              "root_id": {
                "const": "pilot"
              },
              "role": {
                "const": "authorized_local_source"
              }
            }
          },
          "minContains": 1
        }
      ]
    },
    "remote_sources": {
      "const": [],
      "description": "V2 binds authorized local source bytes as named-root artifacts and forbids fabricated remote receipts."
    },
    "reviewed_decisions": {
      "type": "array",
      "minItems": 1,
      "uniqueItems": true,
      "items": {
        "$ref": "https://mparanza.com/schemas/clara/preparation-audit-envelope-v1.json#/$defs/reviewed_decision_receipt"
      }
    },
    "execution": {
      "$ref": "https://mparanza.com/schemas/clara/preparation-audit-envelope-v1.json#/$defs/execution"
    },
    "numeric_policy": {
      "$ref": "https://mparanza.com/schemas/clara/preparation-audit-envelope-v1.json#/$defs/numeric_policy"
    },
    "reconciliation": {
      "$ref": "https://mparanza.com/schemas/clara/preparation-audit-envelope-v1.json#/$defs/reconciliation"
    },
    "lineage": {
      "$ref": "https://mparanza.com/schemas/clara/preparation-audit-envelope-v1.json#/$defs/lineage"
    },
    "statuses": {
      "$ref": "#/$defs/statuses"
    },
    "report_ready": {
      "const": false
    },
    "limitations": {
      "type": "array",
      "minItems": 1,
      "uniqueItems": true,
      "items": {
        "$ref": "https://mparanza.com/schemas/clara/preparation-audit-envelope-v1.json#/$defs/limitation"
      }
    }
  },
  "allOf": [
    {
      "if": {
        "properties": {
          "statuses": {
            "properties": {
              "reconciliation": {
                "properties": {
                  "status": {
                    "const": "passed"
                  }
                },
                "required": [
                  "status"
                ]
              }
            },
            "required": [
              "reconciliation"
            ]
          }
        },
        "required": [
          "statuses"
        ]
      },
      "then": {
        "properties": {
          "reconciliation": {
            "properties": {
              "checks": {
                "items": {
                  "properties": {
                    "status": {
                      "const": "passed"
                    }
                  }
                }
              },
              "errors": {
                "maxItems": 0
              }
            }
          }
        }
      }
    }
  ],
  "$defs": {
    "id": {
      "type": "string",
      "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]*$(?![\\s\\S])"
    },
    "sha256": {
      "type": "string",
      "pattern": "^[0-9a-f]{64}$(?![\\s\\S])"
    },
    "relative_path": {
      "type": "string",
      "pattern": "^(?=\\S)(?!/)(?!.*(?:^|/)\\.\\.(?:/|$))(?!.*\\\\)(?!.*(?:^|/)\\.(?:/|$))[^\\r\\n]*\\S$(?![\\s\\S])"
    },
    "named_root_artifact_receipt": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "artifact_id",
        "root_id",
        "role",
        "path",
        "byte_count",
        "sha256"
      ],
      "properties": {
        "artifact_id": {
          "$ref": "#/$defs/id"
        },
        "root_id": {
          "enum": [
            "pilot",
            "plugin"
          ]
        },
        "role": {
          "type": "string",
          "pattern": "^(?:\\S|\\S[\\s\\S]*\\S)$(?![\\s\\S])"
        },
        "path": {
          "$ref": "#/$defs/relative_path"
        },
        "byte_count": {
          "type": "integer",
          "minimum": 0
        },
        "sha256": {
          "$ref": "#/$defs/sha256"
        },
        "media_type": {
          "type": "string",
          "pattern": "^(?:\\S|\\S[\\s\\S]*\\S)$(?![\\s\\S])"
        }
      }
    },
    "source_status": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "status",
        "basis",
        "evidence_refs"
      ],
      "properties": {
        "status": {
          "const": "local_receipt_only"
        },
        "basis": {
          "type": "string",
          "pattern": "^(?:\\S|\\S[\\s\\S]*\\S)$(?![\\s\\S])"
        },
        "evidence_refs": {
          "$ref": "https://mparanza.com/schemas/clara/preparation-audit-envelope-v1.json#/$defs/reference_set"
        }
      }
    },
    "statuses": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "validation",
        "preparation",
        "reconciliation",
        "semantic",
        "source",
        "downstream",
        "publication"
      ],
      "properties": {
        "validation": {
          "$ref": "https://mparanza.com/schemas/clara/preparation-audit-envelope-v1.json#/$defs/mechanical_status"
        },
        "preparation": {
          "$ref": "https://mparanza.com/schemas/clara/preparation-audit-envelope-v1.json#/$defs/mechanical_status"
        },
        "reconciliation": {
          "$ref": "https://mparanza.com/schemas/clara/preparation-audit-envelope-v1.json#/$defs/mechanical_status"
        },
        "semantic": {
          "$ref": "https://mparanza.com/schemas/clara/preparation-audit-envelope-v1.json#/$defs/semantic_status"
        },
        "source": {
          "$ref": "#/$defs/source_status"
        },
        "downstream": {
          "$ref": "https://mparanza.com/schemas/clara/preparation-audit-envelope-v1.json#/$defs/downstream_status"
        },
        "publication": {
          "$ref": "https://mparanza.com/schemas/clara/preparation-audit-envelope-v1.json#/$defs/publication_status"
        }
      }
    }
  }
}

SHA-256: 8502465c354afbbff6071e52b99caabc3a46e52409896a996aa37bdc9e993b02