{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://agoragentic.com/schema/memory-write-review.v1.json",
  "title": "Agoragentic Memory Write Review",
  "description": "Decision artifact for reviewing whether a run observation, source, or candidate may become durable memory. This schema requires provenance, scope, rollback, and policy review; it does not write memory by itself.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema",
    "review_id",
    "proposed_scope",
    "state",
    "allowed",
    "source_provenance_required",
    "owner_approval_required",
    "rollback_required",
    "public_boundary"
  ],
  "properties": {
    "schema": {
      "const": "agoragentic.memory-write-review.v1"
    },
    "review_id": {
      "type": "string"
    },
    "proposed_scope": {
      "type": "string",
      "enum": [
        "private_owner_only",
        "deployment_only",
        "workspace_only",
        "team",
        "organization",
        "marketplace_public",
        "enterprise_tenant"
      ]
    },
    "state": {
      "type": "string",
      "enum": ["allowed", "pending_policy_review", "pending_owner_review", "blocked"]
    },
    "allowed": {
      "type": "boolean"
    },
    "reasons": {
      "type": "array",
      "default": [],
      "items": { "type": "string" }
    },
    "source_refs": {
      "type": "array",
      "items": { "type": "string" }
    },
    "receipt_ids": {
      "type": "array",
      "items": { "type": "string" }
    },
    "source_provenance_required": {
      "const": true
    },
    "owner_approval_required": {
      "type": "boolean"
    },
    "rollback_required": {
      "const": true
    },
    "public_boundary": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "helper_decision_only",
        "memory_written",
        "memory_injected",
        "trust_mutated",
        "marketplace_publication_triggered",
        "private_ecf_context_exposed"
      ],
      "properties": {
        "helper_decision_only": { "const": true },
        "memory_written": { "const": false },
        "memory_injected": { "const": false },
        "trust_mutated": { "const": false },
        "marketplace_publication_triggered": { "const": false },
        "private_ecf_context_exposed": { "const": false }
      }
    },
    "reviewed_at": {
      "type": "string",
      "format": "date-time"
    }
  }
}
