{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://agenarys.com/schemas/agenarys-trust-manifest.schema.json",
  "title": "Agenarys Verified Trust Manifest",
  "type": "object",
  "required": [
    "schema_version",
    "issuer",
    "subject",
    "agenarys_verification_id",
    "agenarys_verification_date",
    "expires_at",
    "security_score",
    "mcp_reliability_rating",
    "last_automated_audit_hash",
    "capability_manifest",
    "registry_verification_url"
  ],
  "properties": {
    "schema_version": {
      "type": "string",
      "const": "agenarys-trust-manifest.v1"
    },
    "issuer": {
      "type": "object",
      "required": ["name", "url"],
      "properties": {
        "name": { "type": "string", "const": "Agenarys" },
        "url": { "type": "string", "format": "uri" }
      },
      "additionalProperties": false
    },
    "subject": {
      "type": "object",
      "required": ["name", "legal_name", "homepage_url", "manifest_url"],
      "properties": {
        "name": { "type": "string" },
        "legal_name": { "type": "string" },
        "homepage_url": { "type": "string", "format": "uri" },
        "manifest_url": { "type": "string", "format": "uri" }
      },
      "additionalProperties": false
    },
    "agenarys_verification_id": {
      "type": "string",
      "pattern": "^agv_[a-z0-9_]{6,80}$"
    },
    "agenarys_verification_date": {
      "type": "string",
      "format": "date-time"
    },
    "expires_at": {
      "type": "string",
      "format": "date-time"
    },
    "security_score": {
      "type": "integer",
      "minimum": 0,
      "maximum": 100
    },
    "mcp_reliability_rating": {
      "type": "string",
      "enum": ["A", "B", "C", "limited", "unverified"]
    },
    "last_automated_audit_hash": {
      "type": "string",
      "pattern": "^sha256:[a-f0-9]{64}$"
    },
    "capability_manifest": {
      "type": "array",
      "items": {
        "type": "string",
        "pattern": "^[a-z][a-z0-9_]{2,80}$"
      },
      "uniqueItems": true
    },
    "supported_auth": {
      "type": "array",
      "items": {
        "type": "string",
        "enum": ["OAuth2", "APIKey", "Token", "WalletSession", "MCP-Delegated-OAuth"]
      },
      "uniqueItems": true
    },
    "payment_protocols": {
      "type": "array",
      "items": { "type": "string" },
      "uniqueItems": true
    },
    "code_quality": {
      "type": "object",
      "required": ["gate_name", "provider", "verdict", "code_integrity_passed", "last_audit_hash"],
      "properties": {
        "gate_name": {
          "type": "string",
          "const": "Agenarys CodeProof"
        },
        "provider": { "type": "string", "const": "fallow" },
        "command": {
          "type": "string",
          "examples": ["npx fallow audit --format json --quiet --explain"]
        },
        "verdict": {
          "type": "string",
          "enum": ["pass", "warn", "fail"]
        },
        "code_integrity_passed": {
          "type": "boolean"
        },
        "dead_code_has_errors": {
          "type": "boolean"
        },
        "duplication_clone_groups": {
          "type": "integer",
          "minimum": 0
        },
        "max_cyclomatic": {
          "type": ["integer", "null"],
          "minimum": 0
        },
        "last_audit_hash": {
          "type": "string",
          "pattern": "^sha256:[a-f0-9]{64}$"
        },
        "audited_at": {
          "type": "string",
          "format": "date-time"
        }
      },
      "additionalProperties": false
    },
    "spending_guard_required": {
      "type": "boolean"
    },
    "autonomous_approval_required": {
      "type": "boolean"
    },
    "registry_verification_url": {
      "type": "string",
      "format": "uri"
    },
    "signature": {
      "type": "object",
      "required": ["algorithm", "value"],
      "properties": {
        "algorithm": { "type": "string", "enum": ["ed25519", "none-dev"] },
        "value": { "type": "string" }
      },
      "additionalProperties": false
    }
  },
  "additionalProperties": false
}
