{
  "$defs": {
    "Condition": {
      "description": "A single filter condition: `field op value`.",
      "properties": {
        "field": {
          "$ref": "#/$defs/FieldPath",
          "description": "The dotted field path being tested."
        },
        "op": {
          "$ref": "#/$defs/FilterOp",
          "description": "The filter operation and its operand(s)."
        }
      },
      "required": [
        "field",
        "op"
      ],
      "type": "object"
    },
    "EntryType": {
      "description": "The 10 OAS-aligned entry types plus 4 MAP plugin types (14 total).\n\nEach variant maps to an [`oas_did::EntityKind`] value via the\n[`oas_kind`](Self::oas_kind) method.\n\n# Serialization\n\nVariants serialize to their PascalCase name (e.g. `\"AgentDefinition\"`).",
      "oneOf": [
        {
          "const": "AgentDefinition",
          "description": "A registered autonomous agent.",
          "type": "string"
        },
        {
          "const": "ToolDefinition",
          "description": "A tool that agents can invoke.",
          "type": "string"
        },
        {
          "const": "SkillDefinition",
          "description": "A composable skill unit.",
          "type": "string"
        },
        {
          "const": "WorkflowDefinition",
          "description": "A multi-step workflow definition.",
          "type": "string"
        },
        {
          "const": "ModelDefinition",
          "description": "A machine learning model with provenance.",
          "type": "string"
        },
        {
          "const": "DatasetDefinition",
          "description": "A dataset with verified lineage.",
          "type": "string"
        },
        {
          "const": "ServiceDefinition",
          "description": "An infrastructure or API service.",
          "type": "string"
        },
        {
          "const": "OrganizationDefinition",
          "description": "An autonomous organization record.",
          "type": "string"
        },
        {
          "const": "HumanRootRecord",
          "description": "A single verified human root (HMR).",
          "type": "string"
        },
        {
          "const": "MultiHumanRootRecord",
          "description": "A threshold-group multi-human root (MHR).",
          "type": "string"
        },
        {
          "const": "MapPlugin",
          "description": "A MAP plugin definition + metadata.",
          "type": "string"
        },
        {
          "const": "MapPluginRelease",
          "description": "A specific version binary + config for a MAP plugin.",
          "type": "string"
        },
        {
          "const": "MapIntegrationSchema",
          "description": "A reusable integration type definition for MAP plugins.",
          "type": "string"
        },
        {
          "const": "MapPluginCollection",
          "description": "A curated bundle of MAP plugins.",
          "type": "string"
        }
      ]
    },
    "FederatedDiscoveryRequest": {
      "additionalProperties": false,
      "description": "Typed query transported between federation peers.",
      "properties": {
        "query": {
          "$ref": "#/$defs/MarsQuery",
          "description": "The exact MARS-QL v1 AST used for local discovery."
        }
      },
      "required": [
        "query"
      ],
      "type": "object"
    },
    "FederationMessageKind": {
      "description": "Closed message discriminator covered by every federation signature.",
      "oneOf": [
        {
          "const": "sync_request",
          "description": "Pull-based entry synchronization request.",
          "type": "string"
        },
        {
          "const": "sync_response",
          "description": "Pull-based entry synchronization response.",
          "type": "string"
        },
        {
          "const": "discovery_request",
          "description": "Typed MARS-QL discovery request.",
          "type": "string"
        },
        {
          "const": "discovery_response",
          "description": "Typed MARS-QL discovery response.",
          "type": "string"
        }
      ]
    },
    "FieldPath": {
      "description": "A dotted field path such as `\"royalty_terms.usage_fee\"`.\n\nStored as a vector of segments: `[\"royalty_terms\", \"usage_fee\"]`.",
      "items": {
        "type": "string"
      },
      "type": "array"
    },
    "FilterOp": {
      "description": "A filter operation with its operand(s).",
      "oneOf": [
        {
          "description": "`field = value`",
          "properties": {
            "op": {
              "const": "eq",
              "type": "string"
            },
            "value": {
              "$ref": "#/$defs/Value"
            }
          },
          "required": [
            "op",
            "value"
          ],
          "type": "object"
        },
        {
          "description": "`field != value`",
          "properties": {
            "op": {
              "const": "notEq",
              "type": "string"
            },
            "value": {
              "$ref": "#/$defs/Value"
            }
          },
          "required": [
            "op",
            "value"
          ],
          "type": "object"
        },
        {
          "description": "`field > value`",
          "properties": {
            "op": {
              "const": "gt",
              "type": "string"
            },
            "value": {
              "$ref": "#/$defs/Value"
            }
          },
          "required": [
            "op",
            "value"
          ],
          "type": "object"
        },
        {
          "description": "`field >= value`",
          "properties": {
            "op": {
              "const": "gte",
              "type": "string"
            },
            "value": {
              "$ref": "#/$defs/Value"
            }
          },
          "required": [
            "op",
            "value"
          ],
          "type": "object"
        },
        {
          "description": "`field < value`",
          "properties": {
            "op": {
              "const": "lt",
              "type": "string"
            },
            "value": {
              "$ref": "#/$defs/Value"
            }
          },
          "required": [
            "op",
            "value"
          ],
          "type": "object"
        },
        {
          "description": "`field <= value`",
          "properties": {
            "op": {
              "const": "lte",
              "type": "string"
            },
            "value": {
              "$ref": "#/$defs/Value"
            }
          },
          "required": [
            "op",
            "value"
          ],
          "type": "object"
        },
        {
          "description": "`field CONTAINS value` — set/string membership.",
          "properties": {
            "op": {
              "const": "contains",
              "type": "string"
            },
            "value": {
              "$ref": "#/$defs/Value"
            }
          },
          "required": [
            "op",
            "value"
          ],
          "type": "object"
        },
        {
          "description": "`field CONTAINS_ALL (v1, v2, ...)` — all values present.",
          "properties": {
            "op": {
              "const": "containsAll",
              "type": "string"
            },
            "value": {
              "items": {
                "$ref": "#/$defs/Value"
              },
              "type": "array"
            }
          },
          "required": [
            "op",
            "value"
          ],
          "type": "object"
        },
        {
          "description": "`field CONTAINS_ANY (v1, v2, ...)` — at least one value present.",
          "properties": {
            "op": {
              "const": "containsAny",
              "type": "string"
            },
            "value": {
              "items": {
                "$ref": "#/$defs/Value"
              },
              "type": "array"
            }
          },
          "required": [
            "op",
            "value"
          ],
          "type": "object"
        },
        {
          "description": "`field IN (v1, v2, ...)` — field matches one of the listed values.",
          "properties": {
            "op": {
              "const": "in",
              "type": "string"
            },
            "value": {
              "items": {
                "$ref": "#/$defs/Value"
              },
              "type": "array"
            }
          },
          "required": [
            "op",
            "value"
          ],
          "type": "object"
        }
      ]
    },
    "MarsQuery": {
      "description": "A fully-parsed MARS-QL query.\n\nRepresents the output of the recursive-descent parser operating on a\nMARS-QL string. Every clause is optional except the `DISCOVER` keyword and\nentry type.\n\n# Examples\n\n```\n# use mars_protocol::marsql::ast::*;\nlet q = MarsQuery {\n    entry_type: QueryEntryType::All,\n    conditions: vec![],\n    ordering: vec![],\n    limit: Some(10),\n    offset: None,\n};\nassert!(q.conditions.is_empty());\n```",
      "properties": {
        "conditions": {
          "description": "Zero or more filter conditions (implicit AND).",
          "items": {
            "$ref": "#/$defs/Condition"
          },
          "type": "array"
        },
        "entryType": {
          "$ref": "#/$defs/QueryEntryType",
          "description": "The entry type to discover."
        },
        "limit": {
          "description": "Optional maximum number of results.",
          "format": "uint64",
          "minimum": 0,
          "type": [
            "integer",
            "null"
          ]
        },
        "offset": {
          "description": "Optional cursor for keyset pagination.",
          "type": [
            "string",
            "null"
          ]
        },
        "ordering": {
          "description": "Zero or more ordering directives.",
          "items": {
            "$ref": "#/$defs/OrderField"
          },
          "type": "array"
        }
      },
      "required": [
        "entryType"
      ],
      "type": "object"
    },
    "OrderField": {
      "description": "An ordering directive in an `ORDER BY` clause.",
      "properties": {
        "direction": {
          "$ref": "#/$defs/SortDirection",
          "description": "Sort direction (ascending or descending)."
        },
        "field": {
          "$ref": "#/$defs/FieldPath",
          "description": "The field to order by."
        }
      },
      "required": [
        "field",
        "direction"
      ],
      "type": "object"
    },
    "QueryEntryType": {
      "anyOf": [
        {
          "$ref": "#/$defs/EntryType",
          "description": "A specific OAS entry type."
        },
        {
          "description": "Wildcard `*` — matches all entry types.",
          "type": "null"
        }
      ],
      "description": "The target entry type in a `DISCOVER` clause."
    },
    "SortDirection": {
      "description": "Sort direction for `ORDER BY` clauses.",
      "oneOf": [
        {
          "const": "asc",
          "description": "Ascending order (default).",
          "type": "string"
        },
        {
          "const": "desc",
          "description": "Descending order.",
          "type": "string"
        }
      ]
    },
    "Value": {
      "anyOf": [
        {
          "description": "A UTF-8 string value (double-quoted in source).",
          "type": "string"
        },
        {
          "description": "A 64-bit integer value.",
          "format": "int64",
          "type": "integer"
        },
        {
          "description": "A 64-bit floating-point value.",
          "format": "double",
          "type": "number"
        },
        {
          "description": "A boolean value (`true` / `false`).",
          "type": "boolean"
        }
      ],
      "description": "A literal value in a MARS-QL expression."
    }
  },
  "$id": "urn:mars:schema:v1:signed-federated-discovery-request",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "additionalProperties": false,
  "description": "JCS-canonical, detached Ed25519 envelope used for federation traffic.\n\nThe signature covers every field except `signature`, including the sender,\nrecipient, key controller, timestamp, nonce, request digest, and payload.\nRequest digests bind responses to the exact request they answer.",
  "properties": {
    "algorithm": {
      "description": "Signature algorithm. MARS federation v1 permits only `Ed25519`.",
      "type": "string"
    },
    "keyId": {
      "description": "Sender-controlled OAS DID URL used to verify the signature.",
      "type": "string"
    },
    "kind": {
      "$ref": "#/$defs/FederationMessageKind",
      "description": "Message type covered by the signature."
    },
    "nonce": {
      "description": "32 random bytes encoded as 64 lowercase hexadecimal characters.",
      "type": "string"
    },
    "payload": {
      "$ref": "#/$defs/FederatedDiscoveryRequest",
      "description": "Typed federation payload."
    },
    "recipientDid": {
      "description": "Canonical OAS service DID of the intended registry.",
      "type": "string"
    },
    "requestDigest": {
      "description": "`sha256:` digest of the request payload, or of the request envelope for\na response.",
      "type": "string"
    },
    "senderDid": {
      "description": "Canonical OAS service DID of the sending registry.",
      "type": "string"
    },
    "signature": {
      "description": "Raw Ed25519 signature encoded as canonical unpadded base64url.",
      "type": "string"
    },
    "timestamp": {
      "description": "Envelope creation time.",
      "format": "date-time",
      "type": "string"
    },
    "version": {
      "description": "Stable signing profile.",
      "type": "string"
    }
  },
  "required": [
    "version",
    "kind",
    "senderDid",
    "recipientDid",
    "keyId",
    "algorithm",
    "timestamp",
    "nonce",
    "requestDigest",
    "payload",
    "signature"
  ],
  "title": "SignedFederationEnvelope",
  "type": "object"
}
