{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/sarnai-dev/json-schema/sarnai-dev-trust-score-response-schema.json",
  "title": "TrustScoreResponse",
  "x-generated": "2026-10-30",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/verify-openapi.json#/components/schemas/TrustScoreResponse",
  "properties": {
    "agent_id": {
      "type": "string",
      "title": "Agent Id",
      "description": "Identifies the AI agent that produced the output checked by the /verify/schema calls this score is built from (for example, the seller): this record belongs to that producer."
    },
    "identity_verified": {
      "type": "boolean",
      "title": "Identity Verified",
      "description": "Whether agent_id is bound to a proven identity. Currently always false: agent_id is an unauthenticated label chosen by whoever called /verify/schema, so this history may include calls made by anyone under that id, and the score says nothing about who the AI agent really is. It flips to true only if and when identity is actually authenticated."
    },
    "trust_score": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "type": "null"
        }
      ],
      "title": "Trust Score",
      "description": "Recency-weighted pass rate as a raw float in [0.0, 1.0]; null when there is nothing meaningful to report (see `reason`). A statistical summary of structural verification history, not a measure of overall trustworthiness and not a prediction of future behavior."
    },
    "sample_size": {
      "type": "integer",
      "title": "Sample Size",
      "description": "Total verification calls on record for this agent_id."
    },
    "confidence_interval_95": {
      "anyOf": [
        {
          "items": {
            "type": "number"
          },
          "type": "array",
          "maxItems": 2,
          "minItems": 2
        },
        {
          "type": "null"
        }
      ],
      "title": "Confidence Interval 95",
      "description": "[lower, upper] 95% Wilson score interval around trust_score, computed from the effective (recency-discounted) sample size. Wide = little recent evidence."
    },
    "basis": {
      "type": "string",
      "title": "Basis",
      "description": "Names the formula behind trust_score. Its meaning never changes under the same name; a different formula gets a different basis."
    },
    "reason": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Reason",
      "description": "null when scored. 'no_data': no verification history at all. 'insufficient_recent_data': history exists but has decayed to under 0.05 effective observations."
    },
    "factors": {
      "items": {
        "$ref": "#/$defs/ScoreFactor"
      },
      "type": "array",
      "title": "Factors",
      "description": "The inputs behind trust_score. v1 has one entry; consumers should ignore entries they don't recognize, so factors can be added without breaking them."
    },
    "verified_count": {
      "type": "integer",
      "title": "Verified Count",
      "description": "Raw number of /verify/schema calls on record for this agent_id (all history, no recency weighting). Equals sample_size."
    },
    "passed_count": {
      "type": "integer",
      "title": "Passed Count",
      "description": "How many of those calls returned result 'pass'."
    },
    "failed_count": {
      "type": "integer",
      "title": "Failed Count",
      "description": "How many of those calls returned result 'fail'."
    },
    "last_seen": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Last Seen",
      "description": "ISO-8601 UTC time of the most recent verification on record; null when there is none. Like agent_id itself, this reflects calls made under this label by anyone."
    },
    "computed_at": {
      "type": "string",
      "title": "Computed At",
      "description": "ISO-8601 UTC time the score was computed; ages are measured from here."
    },
    "verify": {
      "$ref": "#/$defs/VerifySection",
      "description": "How to verify this attestation and receipt without any other lookup than this response and public_key_url: canonicalization and hash algorithm, this service's name, and its MCP endpoint."
    },
    "attestation": {
      "$ref": "#/$defs/Attestation",
      "description": "Ed25519 signature over this response (every field above) with the same key as /verify/schema, under the context 'json-schema-verifier/trust-score-attestation/v1'. Verification steps: /.well-known/agent-card.json."
    }
  },
  "type": "object",
  "required": [
    "agent_id",
    "identity_verified",
    "trust_score",
    "sample_size",
    "confidence_interval_95",
    "basis",
    "reason",
    "factors",
    "verified_count",
    "passed_count",
    "failed_count",
    "last_seen",
    "computed_at",
    "verify",
    "attestation"
  ],
  "$defs": {
    "Attestation": {
      "properties": {
        "algorithm": {
          "type": "string",
          "const": "Ed25519",
          "title": "Algorithm"
        },
        "key_version": {
          "type": "string",
          "title": "Key Version"
        },
        "timestamp": {
          "type": "string",
          "title": "Timestamp"
        },
        "signature": {
          "type": "string",
          "title": "Signature"
        }
      },
      "type": "object",
      "required": [
        "algorithm",
        "key_version",
        "timestamp",
        "signature"
      ],
      "title": "Attestation"
    },
    "ScoreFactor": {
      "properties": {
        "name": {
          "type": "string",
          "title": "Name",
          "description": "Stable identifier of this factor."
        },
        "value": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Value",
          "description": "Factor value in [0, 1]; null when it cannot be computed (see the response's `reason`)."
        },
        "confidence_interval_95": {
          "anyOf": [
            {
              "items": {
                "type": "number"
              },
              "type": "array",
              "maxItems": 2,
              "minItems": 2
            },
            {
              "type": "null"
            }
          ],
          "title": "Confidence Interval 95",
          "description": "[lower, upper] 95% Wilson score interval; null when value is null."
        },
        "sample_size": {
          "type": "integer",
          "title": "Sample Size",
          "description": "Raw number of verification calls behind this factor, all history."
        },
        "effective_sample_size": {
          "type": "number",
          "title": "Effective Sample Size",
          "description": "Sum of the recency weights: how many 'recent-equivalent' observations the history is worth. This, not sample_size, is what the interval is computed from."
        },
        "parameters": {
          "additionalProperties": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "integer"
              },
              {
                "type": "string"
              }
            ]
          },
          "type": "object",
          "title": "Parameters",
          "description": "Parameters in force, so the value can be reproduced."
        }
      },
      "type": "object",
      "required": [
        "name",
        "value",
        "confidence_interval_95",
        "sample_size",
        "effective_sample_size",
        "parameters"
      ],
      "title": "ScoreFactor",
      "description": "One input to the score. v1 has exactly one; later versions add entries here."
    },
    "VerifySection": {
      "properties": {
        "public_key_url": {
          "type": "string",
          "title": "Public Key Url",
          "description": "Agent-card URL listing the public key for key_version below, and every key this service has ever signed with."
        },
        "key_version": {
          "type": "string",
          "title": "Key Version",
          "description": "Matches attestation.key_version."
        },
        "canonicalization": {
          "type": "string",
          "title": "Canonicalization",
          "description": "How every hash below, and the signed bytes themselves, are computed."
        },
        "hash_algorithm": {
          "type": "string",
          "title": "Hash Algorithm",
          "description": "Algorithm behind every *_hash field in this response."
        },
        "service": {
          "type": "string",
          "title": "Service",
          "description": "This service's name."
        },
        "mcp": {
          "type": "string",
          "title": "Mcp",
          "description": "This service's MCP (Model Context Protocol) endpoint."
        }
      },
      "type": "object",
      "required": [
        "public_key_url",
        "key_version",
        "canonicalization",
        "hash_algorithm",
        "service",
        "mcp"
      ],
      "title": "VerifySection",
      "description": "Compact, self-describing block every signed attestation and receipt carries (2026-09-30,\nverifier_version 0.4.0) - inside the signature, alongside `attestation` itself - so a\nverifier needs nothing but this response and the URL below, not a separate lookup or\nprior knowledge of this service's conventions."
    }
  }
}