{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "gno://schemas/search-result@1.0",
  "title": "GNO Search Result Item",
  "description": "A single search result from gno search, vsearch, or query commands",
  "type": "object",
  "required": ["docid", "score", "uri", "snippet", "source"],
  "properties": {
    "docid": {
      "type": "string",
      "description": "Document ID (short hash of source)",
      "pattern": "^#[a-f0-9]{6,8}$"
    },
    "score": {
      "type": "number",
      "description": "Relevance score (0-1 normalized)",
      "minimum": 0,
      "maximum": 1
    },
    "uri": {
      "type": "string",
      "description": "Document URI (gno://collection/path, optionally with ?index= for non-default indexes)",
      "pattern": "^gno://[^/]+/.+(\\?index=[^\\s]+)?$"
    },
    "line": {
      "type": "integer",
      "description": "Best matching/source line (1-indexed)",
      "minimum": 1
    },
    "title": {
      "type": "string",
      "description": "Extracted document title (optional)"
    },
    "contentType": {
      "type": "string",
      "description": "Canonical inferred content type"
    },
    "categories": {
      "type": "array",
      "description": "Category filters associated with the document",
      "items": {
        "type": "string"
      }
    },
    "snippetLanguage": {
      "type": "string",
      "description": "Language of snippet content (BCP-47 or 'und')"
    },
    "context": {
      "type": "string",
      "description": "Resolved user-configured retrieval guidance, ordered from global to collection to matching path prefixes"
    },
    "snippet": {
      "type": "string",
      "description": "Matching text snippet from document mirror"
    },
    "snippetRange": {
      "type": "object",
      "description": "Line range of snippet in mirror content",
      "properties": {
        "startLine": {
          "type": "integer",
          "description": "Start line (1-indexed)",
          "minimum": 1
        },
        "endLine": {
          "type": "integer",
          "description": "End line (1-indexed, inclusive)",
          "minimum": 1
        }
      },
      "required": ["startLine", "endLine"]
    },
    "source": {
      "type": "object",
      "description": "Source file metadata",
      "required": ["relPath", "mime", "ext"],
      "properties": {
        "absPath": {
          "type": "string",
          "description": "Absolute path (included with --source or in MCP)"
        },
        "relPath": {
          "type": "string",
          "description": "Path relative to collection root"
        },
        "mime": {
          "type": "string",
          "description": "MIME type of source file"
        },
        "ext": {
          "type": "string",
          "description": "File extension (including dot)",
          "pattern": "^\\.[a-zA-Z0-9]+$"
        },
        "modifiedAt": {
          "type": "string",
          "description": "Last modification time (ISO 8601)",
          "format": "date-time"
        },
        "sizeBytes": {
          "type": "integer",
          "description": "File size in bytes",
          "minimum": 0
        },
        "sourceHash": {
          "type": "string",
          "description": "SHA-256 hash of source file"
        }
      }
    },
    "conversion": {
      "type": "object",
      "description": "Conversion metadata",
      "properties": {
        "converterId": {
          "type": "string",
          "description": "Converter identifier (e.g., 'adapter/markitdown-js')"
        },
        "converterVersion": {
          "type": "string",
          "description": "Converter version"
        },
        "mirrorHash": {
          "type": "string",
          "description": "SHA-256 hash of mirror content"
        },
        "warnings": {
          "type": "array",
          "description": "Conversion warnings",
          "items": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "enum": [
                  "LOSSY",
                  "TRUNCATED",
                  "PARTIAL",
                  "UNSUPPORTED_FEATURE",
                  "LOW_CONFIDENCE"
                ]
              },
              "message": {
                "type": "string"
              }
            },
            "required": ["code", "message"]
          }
        }
      }
    },
    "record": {
      "type": "object",
      "additionalProperties": false,
      "description": "Bounded logical-record provenance for a file/export source",
      "required": ["recordKey", "sourceLocator", "anchors", "adapter"],
      "properties": {
        "recordKey": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
        "sourceLocator": { "type": "string", "minLength": 1, "maxLength": 512 },
        "anchors": {
          "type": "array",
          "maxItems": 256,
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": ["kind", "value"],
            "properties": {
              "kind": {
                "enum": [
                  "line",
                  "cue",
                  "timestamp",
                  "message",
                  "event",
                  "record"
                ]
              },
              "value": { "type": "string", "minLength": 1, "maxLength": 512 },
              "endValue": { "type": "string", "minLength": 1, "maxLength": 512 }
            }
          }
        },
        "adapter": {
          "type": "object",
          "additionalProperties": false,
          "required": ["id", "version", "fingerprint"],
          "properties": {
            "id": { "type": "string", "minLength": 1, "maxLength": 128 },
            "version": { "type": "string", "minLength": 1, "maxLength": 64 },
            "fingerprint": { "type": "string", "pattern": "^[a-f0-9]{64}$" }
          }
        },
        "author": { "type": "string", "maxLength": 2048 },
        "participants": {
          "type": "array",
          "maxItems": 256,
          "items": { "type": "string", "minLength": 1, "maxLength": 2048 }
        },
        "categories": {
          "type": "array",
          "maxItems": 256,
          "items": { "type": "string", "minLength": 1, "maxLength": 512 }
        },
        "dateFields": {
          "type": "object",
          "maxProperties": 256,
          "propertyNames": { "type": "string", "maxLength": 128 },
          "additionalProperties": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256
          }
        },
        "messageId": { "type": "string", "maxLength": 2048 },
        "inReplyTo": { "type": "string", "maxLength": 2048 },
        "references": {
          "type": "array",
          "maxItems": 256,
          "items": { "type": "string", "minLength": 1, "maxLength": 2048 }
        },
        "threadId": { "type": "string", "maxLength": 2048 },
        "eventId": { "type": "string", "maxLength": 2048 },
        "sessionId": { "type": "string", "maxLength": 2048 },
        "attachments": {
          "type": "array",
          "maxItems": 256,
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": ["name"],
            "properties": {
              "name": { "type": "string", "minLength": 1, "maxLength": 512 },
              "mime": { "type": "string", "minLength": 1, "maxLength": 256 },
              "bytes": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              "disposition": { "enum": ["inline", "attachment"] },
              "sha256": { "type": "string", "pattern": "^[a-f0-9]{64}$" }
            }
          }
        }
      }
    }
  }
}
