openapi: "3.1.0"
info:
  title: Universal AI Discovery Protocol (DUADP)
  version: "0.1.3"
  description: |
    Decentralized, hybrid-federated protocol for the discovery, validation,
    publishing, and exchange of AI Agents, Skills, Tools, and Marketplaces.
    Built on the Open Standard for Agent Systems (OSSA).
  license:
    name: Apache-2.0
    url: https://www.apache.org/licenses/LICENSE-2.0
  contact:
    name: OSSA Project
    url: https://openstandardagents.org

servers:
- url: https://{domain}
  description: Any DUADP node
  variables:
    domain:
      default: example.com

security: []

paths:
  /.well-known/duadp.json:
    get:
      operationId: getDuadpManifest
      summary: DUADP Node Discovery Manifest
      description: Returns the node's discovery manifest with endpoint URLs and 
        capabilities.
      tags: [Discovery]
      responses:
        "200":
          description: DUADP node manifest
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DuadpManifest"
        "400":
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"

        '404':
          $ref: '#/components/responses/NotFound'
  /.well-known/webfinger:
    get:
      operationId: resolveWebFinger
      summary: WebFinger Resource Resolution
      description: Resolves a GAID URI to DUADP endpoint links.
      tags: [Discovery]
      parameters:
      - name: resource
        in: query
        required: true
        schema:
          type: string
        description: "GAID URI (e.g., agent://acme.com/skills/code-review)"
      responses:
        "200":
          description: WebFinger response with resource links
          content:
            application/jrd+json:
              schema:
                $ref: "#/components/schemas/WebFingerResponse"
        "404":
          description: Resource not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"

  /api/v1/skills:
    get:
      operationId: listSkills
      summary: List Skills
      description: Returns a paginated list of OSSA-compliant skill manifests.
      tags: [Skills]
      parameters:
      - $ref: "#/components/parameters/Search"
      - $ref: "#/components/parameters/Category"
      - $ref: "#/components/parameters/TrustTier"
      - $ref: "#/components/parameters/Tag"
      - $ref: "#/components/parameters/Runtime"
      - $ref: "#/components/parameters/Action"
      - $ref: "#/components/parameters/ProjectPath"
      - $ref: "#/components/parameters/GroupPath"
      - $ref: "#/components/parameters/Frameworks"
      - $ref: "#/components/parameters/SecurityAttributes"
      - $ref: "#/components/parameters/Federated"
      - $ref: "#/components/parameters/Page"
      - $ref: "#/components/parameters/Limit"
      responses:
        "200":
          description: Paginated skills list
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SkillsResponse"
        '404':
          $ref: '#/components/responses/NotFound'
    post:
      operationId: publishSkill
      summary: Publish a Skill
      description: Publish a new skill to this node.
      tags: [Skills]
      security:
      - bearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/OssaSkill"
      responses:
        "201":
          description: Skill published
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PublishResponse"
        "400":
          description: Invalid manifest
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
        "401":
          description: Authentication required
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"

  /api/v1/skills/{name}:
    get:
      operationId: getSkill
      summary: Get Skill by Name
      description: Returns a single skill by name.
      tags: [Skills]
      parameters:
      - name: name
        in: path
        required: true
        schema:
          type: string
      responses:
        "200":
          description: Skill resource
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/OssaSkill"
        "404":
          description: Skill not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
    put:
      operationId: updateSkill
      summary: Update a Skill
      tags: [Skills]
      security:
      - bearerAuth: []
      parameters:
      - name: name
        in: path
        required: true
        schema:
          type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/OssaSkill"
      responses:
        "200":
          description: Skill updated
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PublishResponse"
        '400':
          $ref: '#/components/responses/BadRequest'
    delete:
      operationId: deleteSkill
      summary: Delete a Skill
      tags: [Skills]
      security:
      - bearerAuth: []
      parameters:
      - name: name
        in: path
        required: true
        schema:
          type: string
      responses:
        "204":
          description: Skill deleted

        '400':
          $ref: '#/components/responses/BadRequest'
  /api/v1/agents:
    get:
      operationId: listAgents
      summary: List Agents
      description: Returns a paginated list of OSSA-compliant agent manifests.
      tags: [Agents]
      parameters:
      - $ref: "#/components/parameters/Search"
      - $ref: "#/components/parameters/Category"
      - $ref: "#/components/parameters/TrustTier"
      - $ref: "#/components/parameters/Tag"
      - $ref: "#/components/parameters/Runtime"
      - $ref: "#/components/parameters/Action"
      - $ref: "#/components/parameters/ProjectPath"
      - $ref: "#/components/parameters/GroupPath"
      - $ref: "#/components/parameters/Frameworks"
      - $ref: "#/components/parameters/SecurityAttributes"
      - $ref: "#/components/parameters/Federated"
      - $ref: "#/components/parameters/Page"
      - $ref: "#/components/parameters/Limit"
      responses:
        "200":
          description: Paginated agents list
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AgentsResponse"
        '404':
          $ref: '#/components/responses/NotFound'
    post:
      operationId: publishAgent
      summary: Publish an Agent
      tags: [Agents]
      security:
      - bearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/OssaAgent"
      responses:
        "201":
          description: Agent published
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PublishResponse"

        '400':
          $ref: '#/components/responses/BadRequest'
  /api/v1/agents/{name}:
    get:
      operationId: getAgent
      summary: Get Agent by Name
      tags: [Agents]
      parameters:
      - name: name
        in: path
        required: true
        schema:
          type: string
      responses:
        "200":
          description: Agent resource
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/OssaAgent"
        "404":
          description: Agent not found

  /api/v1/agents/{gaid}/card:
    get:
      operationId: getAgentCard
      summary: Get Universally Compatible Agent Card
      description: |
        Returns the Agent Card representation of the OSSA manifest.
        The Agent Card is a universally understood format (similar to Google A2A format)
        containing capabilities, endpoints, UUID constraints, and trust tiers.
        Suitable for fast out-of-band vetting and cross-registry handshakes.
      tags: [Agents, Identity]
      parameters:
      - name: gaid
        in: path
        required: true
        description: The Global Agent Identifier (DID) or UUID of the agent.
        schema:
          type: string
      responses:
        "200":
          description: Signed Agent Card
          content:
            application/agent-card+json:
              schema:
                $ref: "#/components/schemas/AgentCard"
            application/json:
              schema:
                $ref: "#/components/schemas/AgentCard"
        "404":
          description: Agent not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"

  /api/v1/tools:
    get:
      operationId: listTools
      summary: List Tools
      description: Returns a paginated list of OSSA-compliant tool manifests 
        (MCP, A2A, function-calling).
      tags: [Tools]
      parameters:
      - $ref: "#/components/parameters/Search"
      - $ref: "#/components/parameters/Category"
      - $ref: "#/components/parameters/TrustTier"
      - $ref: "#/components/parameters/Tag"
      - $ref: "#/components/parameters/Federated"
      - $ref: "#/components/parameters/Page"
      - $ref: "#/components/parameters/Limit"
      - name: protocol
        in: query
        schema:
          type: string
          enum: [mcp, a2a, function, rest]
        description: Filter by tool protocol type.
      responses:
        "200":
          description: Paginated tools list
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ToolsResponse"
        '404':
          $ref: '#/components/responses/NotFound'
    post:
      operationId: publishTool
      summary: Publish a Tool
      tags: [Tools]
      security:
      - bearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/OssaTool"
      responses:
        "201":
          description: Tool published
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PublishResponse"

        '400':
          $ref: '#/components/responses/BadRequest'
  /api/v1/tools/{name}:
    get:
      operationId: getTool
      summary: Get Tool by Name
      tags: [Tools]
      parameters:
      - name: name
        in: path
        required: true
        schema:
          type: string
      responses:
        "200":
          description: Tool resource
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/OssaTool"
        "404":
          description: Tool not found

  /api/v1/control-plane/authorize:
    post:
      operationId: authorizeGitLabContext
      summary: Authorize GitLab runtime context
      description: >-
        Resolves GitLab-aware DUADP tools and skills, evaluates Cedar policy
        for the current MR or pipeline context, and returns the approved catalog,
        allowed hosts, and required reporting checks.
      tags: [Control Plane, GitLab]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/GitLabRequestContext"
      responses:
        "200":
          description: Authorization decision for the GitLab context
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AuthorizationDecision"
        "400":
          description: Invalid authorization request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"

  /api/v1/publish:
    post:
      operationId: publishResource
      summary: Publish Any Resource
      description: Generic publish endpoint — accepts any OSSA-formatted 
        resource (Skill, Agent, Tool, or custom kind).
      tags: [Publishing]
      security:
      - bearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/OssaResource"
      responses:
        "201":
          description: Resource published
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PublishResponse"
        "400":
          description: Invalid resource
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
        "401":
          description: Authentication required

  /api/v1/policies:
    get:
      operationId: listPolicies
      summary: List Cedar Policies
      description: Returns the Cedar policy catalog with filtering and 
        pagination.
      tags: [Policies]
      parameters:
      - name: tag
        in: query
        schema:
          type: string
      - name: framework
        in: query
        schema:
          type: string
      - $ref: "#/components/parameters/Search"
      - $ref: "#/components/parameters/Page"
      - name: per_page
        in: query
        schema:
          type: integer
          default: 20
          maximum: 100
      responses:
        "200":
          description: Paginated Cedar policy list
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/CedarPolicyResource"
                  pagination:
                    $ref: "#/components/schemas/PaginationMeta"

        '404':
          $ref: '#/components/responses/NotFound'
  /api/v1/policies/{name}:
    get:
      operationId: getPolicy
      summary: Get Cedar Policy by ID
      tags: [Policies]
      parameters:
      - name: name
        in: path
        required: true
        schema:
          type: string
      responses:
        "200":
          description: Cedar policy resource
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CedarPolicyResource"
        "404":
          description: Policy not found

  /api/v1/policies/evaluate:
    post:
      operationId: evaluateCedarPolicy
      summary: Evaluate Cedar Authorization Request
      description: |
        Evaluates a Cedar authorization request against provided policies.
        Returns Allow or Deny with diagnostics. Used for testing policies
        before deployment or for runtime authorization checks.
      tags: [Policies]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CedarEvaluationRequest"
      responses:
        "200":
          description: Cedar evaluation result
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CedarEvaluationResult"
        "400":
          description: Invalid request (missing fields or unparseable policies)
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"

  /api/v1/validate:
    post:
      operationId: validateManifest
      summary: Validate Manifest
      description: Validates any OSSA manifest and returns errors/warnings.
      tags: [Validation]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [manifest]
              properties:
                manifest:
                  type: string
                  description: YAML or JSON string of the OSSA manifest.
      responses:
        "200":
          description: Validation result
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ValidationResult"
        "400":
          description: Missing manifest field
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"

  /api/v1/federation:
    get:
      operationId: listPeers
      summary: List Federation Peers
      description: Returns this node's peer list and federation metadata.
      tags: [Federation]
      responses:
        "200":
          description: Federation peer list
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/FederationResponse"
        '404':
          $ref: '#/components/responses/NotFound'
    post:
      operationId: registerPeer
      summary: Register as Federation Peer
      description: Another DUADP node requests to register as a peer.
      tags: [Federation]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [url, name]
              properties:
                url:
                  type: string
                  format: uri
                  description: Base URL of the registering DUADP node.
                name:
                  type: string
                  description: Human-readable name of the registering node.
                node_id:
                  type: string
                  description: DID of the registering node.
                hop:
                  type: integer
                  description: Gossip hop count (0 = direct registration).
                  default: 0
      responses:
        "201":
          description: Peer registered successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  peer:
                    $ref: "#/components/schemas/Peer"
                  peers:
                    type: array
                    description: This node's peer list (for gossip propagation).
                    items:
                      $ref: "#/components/schemas/Peer"
        "400":
          description: Invalid peer URL or unreachable node
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"

  /api/v1/health:
    get:
      operationId: getHealth
      summary: Node Health Check
      description: |
        Returns node health, version, uptime, and resource counts.
        Peers SHOULD poll this to update peer status.
      tags: [Discovery]
      responses:
        "200":
          description: Node is healthy
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/NodeHealth"

        '404':
          $ref: '#/components/responses/NotFound'
  /api/v1/search:
    get:
      operationId: unifiedSearch
      summary: Unified Search
      description: |
        Search across skills, agents, AND tools in a single call.
        Returns mixed results with type discrimination via `kind`.
        Supports protocol filtering, capability matching, and federated search.
      tags: [Discovery]
      parameters:
      - $ref: "#/components/parameters/Search"
      - $ref: "#/components/parameters/Category"
      - $ref: "#/components/parameters/TrustTier"
      - $ref: "#/components/parameters/Tag"
      - $ref: "#/components/parameters/Federated"
      - $ref: "#/components/parameters/Page"
      - $ref: "#/components/parameters/Limit"
      - name: kind
        in: query
        schema:
          type: array
          items:
            type: string
            enum: [Skill, Agent, Tool]
        description: "Filter by resource kind(s). Omit to search all."
      - name: protocol
        in: query
        schema:
          type: string
          enum: [mcp, a2a, function, rest, openai, langchain, crewai, autogen, 
              grpc]
        description: "Filter by protocol (tools only)."
      - name: capability
        in: query
        schema:
          type: array
          items:
            type: string
        description: "Filter by standardized capability tags."
      - name: status
        in: query
        schema:
          type: string
          enum: [active, deprecated, suspended]
        description: "Filter by operational status."
      - name: min_trust
        in: query
        schema:
          type: string
          enum: [official, verified-signature, signed, community, experimental]
        description: "Minimum trust tier (inclusive upward)."
      - name: sort
        in: query
        schema:
          type: string
          enum: [relevance, name, created, updated, reputation, trust_tier]
        description: "Sort order (default: relevance when search is present, name
          otherwise)."
      responses:
        "200":
          description: Unified search results
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/OssaResource"
                  meta:
                    $ref: "#/components/schemas/PaginationMeta"
                  facets:
                    $ref: "#/components/schemas/SearchFacets"

        "404":
          $ref: '#/components/responses/NotFound'
  /api/v1/resolve/{gaid}:
    get:
      operationId: resolveGaid
      summary: Resolve a GAID to a DUADP resource
      description: |
        Resolves a GAID from the local node first and then healthy peers.
        Returns the matching DUADP resource and the node that resolved it.
      tags: [Discovery]
      parameters:
      - name: gaid
        in: path
        required: true
        schema:
          type: string
      responses:
        "200":
          description: GAID resolved successfully
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/GaidResolveResponse"
        "404":
          description: GAID not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"

  /api/v1/inspect:
    get:
      operationId: inspectGaid
      summary: Inspect a GAID
      description: |
        Resolves a GAID and returns a consolidated inspection payload:
        resource, DID state, trust verification, signature verification,
        provenance links, revocation state, and publish policy outcomes.
      tags: [Discovery, Governance]
      parameters:
      - name: gaid
        in: query
        required: true
        schema:
          type: string
      responses:
        "200":
          description: Aggregated inspection payload
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/InspectorResponse"
        "400":
          description: Missing GAID query parameter
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
        "404":
          description: GAID not found on this node or healthy peers
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  gaid:
                    type: string
                  resolved:
                    type: boolean
                  resolution_trace:
                    type: array
                    items:
                      $ref: "#/components/schemas/ResolutionTraceStep"

  # ─── Agent JSON Index (.ajson) ─────────────────────────────
  /api/v1/index/{gaid}:
    get:
      operationId: getAgentIndex
      summary: Get Agent JSON Index Record
      description: |
        Returns a lightweight `.ajson` index record for any resource.
        The index record is a universal discovery card linking to full
        specifications in any protocol format (A2A, MCP, OSSA, OpenAPI).
        Designed for fast indexing, caching, and cross-registry aggregation.
      tags: [Discovery]
      parameters:
      - name: gaid
        in: path
        required: true
        schema:
          type: string
      responses:
        "200":
          description: Agent JSON index record
          content:
            application/agent+json:
              schema:
                $ref: "#/components/schemas/AgentIndexRecord"
            application/json:
              schema:
                $ref: "#/components/schemas/AgentIndexRecord"
        "404":
          description: Resource not found

  /api/v1/governance:
    get:
      operationId: getGovernance
      summary: Node Governance Declaration
      description: |
        Returns this node's governance policies, compliance frameworks,
        and NIST AI RMF alignment. GOVERN 1.1, GOVERN 1.2.
      tags: [Governance]
      responses:
        "200":
          description: Governance declaration
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/NodeGovernance"

        '404':
          $ref: '#/components/responses/NotFound'
  /api/v1/governance/risk/{gaid}:
    get:
      operationId: getRiskAssessment
      summary: Get Risk Assessment for Resource
      description: |
        NIST-aligned risk assessment for an agent, skill, or tool.
        MAP 5.1 (impact), MEASURE 1.1 (metrics).
      tags: [Governance]
      parameters:
      - name: gaid
        in: path
        required: true
        schema:
          type: string
      responses:
        "200":
          description: Risk assessment
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ResourceRisk"
        "404":
          description: Resource not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"

  /api/v1/governance/audit:
    get:
      operationId: getAuditLog
      summary: Audit Log
      description: |
        Governance-relevant audit trail. NIST AU-2, AU-3.
      tags: [Governance]
      parameters:
      - name: event_type
        in: query
        schema:
          type: string
          enum: [publish, revoke, update, peer_added, peer_removed, access, 
              validation, risk_change]
      - name: since
        in: query
        schema:
          type: string
          format: date-time
      - $ref: "#/components/parameters/Page"
      - $ref: "#/components/parameters/Limit"
      responses:
        "200":
          description: Audit events
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/AuditEvent"
                  meta:
                    $ref: "#/components/schemas/PaginationMeta"

        '404':
          $ref: '#/components/responses/NotFound'
  /api/v1/provenance/{gaid}:
    get:
      operationId: getProvenance
      summary: Get Provenance Chain
      description: |
        Full supply chain provenance — publisher, signature, SBOM, build info.
        NIST SP 800-218A, EO 14110 Section 4.1.
      tags: [Provenance]
      parameters:
      - name: gaid
        in: path
        required: true
        schema:
          type: string
      responses:
        "200":
          description: Provenance chain
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ResourceProvenance"
        "404":
          description: Resource not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"

  /api/v1/revocations:
    get:
      operationId: listRevocations
      summary: List Revoked Resources
      description: |
        Revoked GAIDs with reason and timestamp.
        Peers SHOULD check during sync. NIST SI-7, CM-3.
      tags: [Governance]
      parameters:
      - name: since
        in: query
        schema:
          type: string
          format: date-time
      - $ref: "#/components/parameters/Page"
      - $ref: "#/components/parameters/Limit"
      responses:
        "200":
          description: Revocation list
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/Revocation"
                  meta:
                    $ref: "#/components/schemas/PaginationMeta"

        '404':
          $ref: '#/components/responses/NotFound'
  /api/v1/federation/sync:
    get:
      operationId: incrementalSync
      summary: Incremental Sync
      description: |
        Resources changed since timestamp. Efficient peer-to-peer sync.
        NIST MANAGE 4.1 (post-deployment monitoring).
      tags: [Federation]
      parameters:
      - name: since
        in: query
        required: true
        schema:
          type: string
          format: date-time
      - name: types
        in: query
        schema:
          type: array
          items:
            type: string
            enum: [skills, agents, tools, revocations]
      - $ref: "#/components/parameters/Limit"
      responses:
        "200":
          description: Changed resources
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SyncResponse"

        '404':
          $ref: '#/components/responses/NotFound'
  /api/v1/events/subscribe:
    post:
      operationId: subscribe
      summary: Subscribe to Events
      description: |
        Webhook subscription for resource changes. NIST MANAGE 4.1.
      tags: [Events]
      security:
      - bearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/WebhookSubscription"
      responses:
        "201":
          description: Subscription created
          content:
            application/json:
              schema:
                type: object
                properties:
                  subscription_id:
                    type: string
                    format: uuid
                  status:
                    type: string
                    const: active

        '400':
          $ref: '#/components/responses/BadRequest'
  /api/v1/identity/{gaid}:
    get:
      operationId: getAgentIdentity
      summary: Get Agent Identity
      description: |
        Returns the identity record for an agent — DID, DNS records,
        service accounts, and key material. Each agent gets a unique
        identity tied to a domain via did:web and DNS TXT records.
      tags: [Identity]
      parameters:
      - name: gaid
        in: path
        required: true
        schema:
          type: string
      responses:
        "200":
          description: Agent identity
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AgentIdentity"
        "404":
          description: Agent not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"


  /api/v1/context/negotiate:
    post:
      operationId: negotiateContext
      summary: Negotiate Context Delivery
      description: |
        Negotiate how context is delivered to an agent before task execution.
        Returns prioritized context layers, knowledge source references,
        and cache entries. Agents request only what they need.
      tags: [Context]
      security:
      - bearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [agent_gaid, task]
              properties:
                agent_gaid:
                  type: string
                task:
                  type: object
                  required: [type]
                  properties:
                    type:
                      type: string
                    scope:
                      type: array
                      items:
                        type: string
                    max_tokens:
                      type: integer
      responses:
        "200":
          description: Context negotiation result
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ContextNegotiation"

        '400':
          $ref: '#/components/responses/BadRequest'
  /api/v1/context/summary:
    get:
      operationId: getContextSummary
      summary: Get Cached Context Summary
      description: Returns pre-computed context summary for a domain with 
        adaptive cache layers.
      tags: [Context]
      parameters:
      - name: domain
        in: query
        required: true
        schema:
          type: string
      - name: task_type
        in: query
        schema:
          type: string
      responses:
        "200":
          description: Context summary
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ContextNegotiation"

        '404':
          $ref: '#/components/responses/NotFound'
  /api/v1/analytics/tokens:
    post:
      operationId: reportTokenUsage
      summary: Report Token Usage
      description: Report token consumption for an agent execution.
      tags: [Analytics]
      security:
      - bearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/TokenAnalytics"
      responses:
        "204":
          description: Token usage recorded

        '400':
          $ref: '#/components/responses/BadRequest'
  /api/v1/analytics/tokens/{gaid}:
    get:
      operationId: getTokenAnalytics
      summary: Get Token Analytics
      description: Returns aggregate token analytics for an agent with period 
        filtering.
      tags: [Analytics]
      parameters:
      - name: gaid
        in: path
        required: true
        schema:
          type: string
      - name: period
        in: query
        schema:
          type: string
          enum: [hour, day, week, month, all_time]
      responses:
        "200":
          description: Token analytics aggregate
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/TokenAnalyticsAggregate"

        '404':
          $ref: '#/components/responses/NotFound'
  /api/v1/analytics/fingerprint/{gaid}:
    get:
      operationId: getCapabilityFingerprint
      summary: Get Capability Fingerprint
      description: Returns empirical capability fingerprint computed from actual
        execution data.
      tags: [Analytics]
      parameters:
      - name: gaid
        in: path
        required: true
        schema:
          type: string
      responses:
        "200":
          description: Capability fingerprint
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CapabilityFingerprint"

        '404':
          $ref: '#/components/responses/NotFound'
  /api/v1/feedback:
    post:
      operationId: submitFeedback
      summary: Submit Agent Feedback
      description: Submit 360-degree feedback on an agent execution from any 
        source.
      tags: [Feedback]
      security:
      - bearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/AgentFeedback"
      responses:
        "201":
          description: Feedback recorded
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AgentFeedback"

        '400':
          $ref: '#/components/responses/BadRequest'
  /api/v1/feedback/{gaid}:
    get:
      operationId: getAgentFeedback
      summary: Get Agent Feedback
      tags: [Feedback]
      parameters:
      - name: gaid
        in: path
        required: true
        schema:
          type: string
      - name: type
        in: query
        schema:
          type: string
          enum: [rating, correction, reward, penalty, observation]
      - name: since
        in: query
        schema:
          type: string
          format: date-time
      - $ref: "#/components/parameters/Limit"
      responses:
        "200":
          description: Feedback list
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/AgentFeedback"

        '404':
          $ref: '#/components/responses/NotFound'
  /api/v1/feedback/{gaid}/reputation:
    get:
      operationId: getAgentReputation
      summary: Get Agent Reputation Score
      description: Returns computed reputation from feedback, rewards, and 
        attestations.
      tags: [Feedback]
      parameters:
      - name: gaid
        in: path
        required: true
        schema:
          type: string
      responses:
        "200":
          description: Agent reputation
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AgentReputation"

        '404':
          $ref: '#/components/responses/NotFound'
  /api/v1/feedback/rewards:
    post:
      operationId: recordReward
      summary: Record Agent Reward
      tags: [Feedback]
      security:
      - bearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/RewardEvent"
      responses:
        "201":
          description: Reward recorded
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/RewardEvent"

        '400':
          $ref: '#/components/responses/BadRequest'
  /api/v1/attestations:
    post:
      operationId: submitAttestation
      summary: Submit Outcome Attestation
      description: Submit a signed, verifiable attestation of a task outcome.
      tags: [Attestations]
      security:
      - bearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/OutcomeAttestation"
      responses:
        "201":
          description: Attestation recorded
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/OutcomeAttestation"

        '400':
          $ref: '#/components/responses/BadRequest'
  /api/v1/attestations/{gaid}:
    get:
      operationId: getAttestations
      summary: Get Agent Attestations
      tags: [Attestations]
      parameters:
      - name: gaid
        in: path
        required: true
        schema:
          type: string
      - name: outcome
        in: query
        schema:
          type: string
          enum: [success, partial_success, failure, timeout]
      - name: since
        in: query
        schema:
          type: string
          format: date-time
      - $ref: "#/components/parameters/Limit"
      responses:
        "200":
          description: Attestation list
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/OutcomeAttestation"

        '404':
          $ref: '#/components/responses/NotFound'
  /api/v1/delegate:
    post:
      operationId: delegateTask
      summary: Delegate Task to Agent
      description: |
        Delegate work with compressed context transfer. The delegating agent
        passes minimal state — the delegate starts smart, not from scratch.
      tags: [Orchestration]
      security:
      - bearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/DelegationRequest"
      responses:
        "200":
          description: Delegation result
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DelegationResult"

        '400':
          $ref: '#/components/responses/BadRequest'
  /api/v1/delegate/plans:
    post:
      operationId: createOrchestrationPlan
      summary: Create Orchestration Plan
      description: |
        Create a multi-step plan distributing work across agent types
        (orchestrator, worker, specialist, critic, monitor, gateway).
      tags: [Orchestration]
      security:
      - bearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/OrchestrationPlan"
      responses:
        "201":
          description: Plan created
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/OrchestrationPlan"

        '400':
          $ref: '#/components/responses/BadRequest'
  /api/v1/delegate/plans/{planId}:
    get:
      operationId: getOrchestrationPlan
      summary: Get Orchestration Plan
      tags: [Orchestration]
      parameters:
      - name: planId
        in: path
        required: true
        schema:
          type: string
      responses:
        "200":
          description: Orchestration plan
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/OrchestrationPlan"


        '404':
          $ref: '#/components/responses/NotFound'
  /api/v1/publish/batch:
    post:
      operationId: batchPublish
      summary: Batch Publish Resources
      description: |
        Publish multiple resources in a single request. Supports atomic mode
        (all-or-nothing) for CI/CD pipelines. Maximum 100 resources per batch.
      tags: [Publishing]
      security:
      - bearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [resources]
              properties:
                resources:
                  type: array
                  items:
                    $ref: "#/components/schemas/OssaResource"
                  maxItems: 100
                atomic:
                  type: boolean
                  default: false
                  description: If true, all resources must succeed or the entire
                    batch fails.
      responses:
        "200":
          description: Batch publish results
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BatchPublishResponse"
        "207":
          description: Partial success (non-atomic mode)
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BatchPublishResponse"
        "400":
          description: Validation errors
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"

  /api/v1/validate/batch:
    post:
      operationId: batchValidate
      summary: Batch Validate Manifests
      description: Validate multiple manifests in a single request. Maximum 100 
        manifests per batch.
      tags: [Validation]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [manifests]
              properties:
                manifests:
                  type: array
                  items:
                    type: string
                  maxItems: 100
      responses:
        "200":
          description: Batch validation results
          content:
            application/json:
              schema:
                type: object
                properties:
                  results:
                    type: array
                    items:
                      $ref: "#/components/schemas/ValidationResult"


        '400':
          $ref: '#/components/responses/BadRequest'
  /api/v1/agents/{name}/a2a-card:
    get:
      operationId: getA2AAgentCard
      summary: A2A Agent Card
      description: |
        Returns a Google A2A-compatible Agent Card for the named agent.
        Maps DUADP agent data to the A2A Agent Card schema, enabling
        interoperability with A2A-native clients and infrastructure.
      tags: [Interop]
      parameters:
      - name: name
        in: path
        required: true
        schema:
          type: string
      responses:
        "200":
          description: A2A Agent Card
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/A2AAgentCard"
        "404":
          description: Agent not found

  /api/v1/tools/mcp-manifest:
    get:
      operationId: getMcpManifest
      summary: MCP Server Manifest
      description: |
        Returns an MCP-compatible server manifest listing all tools
        with protocol=mcp. Enables MCP clients to discover DUADP-registered
        tools natively without DUADP-specific client code.
      tags: [Interop]
      responses:
        "200":
          description: MCP server manifest
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/McpServerManifest"

        '404':
          $ref: '#/components/responses/NotFound'
  /.well-known/mcp:
    get:
      operationId: getMcpWellKnown
      summary: MCP Well-Known Manifest
      description: Alias for /api/v1/tools/mcp-manifest for MCP client 
        auto-discovery.
      tags: [Interop]
      responses:
        "200":
          description: MCP server manifest
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/McpServerManifest"


        '404':
          $ref: '#/components/responses/NotFound'
  /api/v1/query:
    post:
      operationId: structuredQuery
      summary: Structured Query
      description: |
        Advanced query endpoint supporting structured filters, sorting, and field
        selection. Use this for complex discovery queries that can't be expressed
        with simple search parameters.
      tags: [Discovery]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/StructuredQuery"
      responses:
        "200":
          description: Query results
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/OssaResource"
                  meta:
                    $ref: "#/components/schemas/PaginationMeta"

        '400':
          $ref: '#/components/responses/BadRequest'
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Bearer token for write operations (publishing, updating, 
        deleting).
    oauth2AuthorizationCode:
      type: oauth2
      description: OAuth2 authorization code flow for user-delegated operations.
      flows:
        authorizationCode:
          authorizationUrl: https://auth.example.com/authorize
          tokenUrl: https://auth.example.com/token
          scopes:
            read: Read access to resources
            write: Publish and update resources
            admin: Administrative operations
    oauth2ClientCredentials:
      type: oauth2
      description: OAuth2 client credentials flow for service-to-service 
        (agent-to-agent) operations.
      flows:
        clientCredentials:
          tokenUrl: https://auth.example.com/token
          scopes:
            read: Read access to resources
            write: Publish and update resources
            federation: Federation peer operations

  parameters:
    Search:
      name: search
      in: query
      schema:
        type: string
      description: Full-text search across name and description.
    Category:
      name: category
      in: query
      schema:
        type: string
      description: Filter by category.
    TrustTier:
      name: trust_tier
      in: query
      schema:
        type: string
        enum: [official, verified-signature, signed, community, experimental]
      description: Filter by trust tier.
    Tag:
      name: tag
      in: query
      schema:
        type: string
      description: Filter by tag (comma-separated for multiple).
    Federated:
      name: federated
      in: query
      schema:
        type: boolean
        default: false
      description: Include results from federated peers.
    Page:
      name: page
      in: query
      schema:
        type: integer
        minimum: 1
        default: 1
      description: Page number (1-indexed).
    Limit:
      name: limit
      in: query
      schema:
        type: integer
        minimum: 1
        maximum: 100
        default: 20
      description: Items per page.
    Runtime:
      name: runtime
      in: query
      schema:
        type: string
        enum: [gitlab]
      description: Runtime-specific query mode.
    Action:
      name: action
      in: query
      schema:
        type: string
      description: GitLab action being evaluated, such as pipeline or 
        merge_request.
    ProjectPath:
      name: project_path
      in: query
      schema:
        type: string
      description: GitLab project path used to scope GitLab-aware catalog 
        results.
    GroupPath:
      name: group_path
      in: query
      schema:
        type: string
      description: GitLab namespace or group path used to scope GitLab-aware 
        catalog results.
    Frameworks:
      name: frameworks
      in: query
      schema:
        type: string
      description: Comma-separated compliance frameworks such as 
        hipaa,fedramp_high.
    SecurityAttributes:
      name: security_attributes
      in: query
      schema:
        type: string
      description: JSON-encoded GitLab security attributes object.

  schemas:
    DuadpManifest:
      type: object
      required: [protocol_version, node_name, endpoints]
      properties:
        protocol_version:
          type: string
          pattern: "^\\d+\\.\\d+\\.\\d+$"
        node_id:
          type: string
          description: "DID or URI uniquely identifying this node"
        node_name:
          type: string
        node_description:
          type: string
        contact:
          type: string
        endpoints:
          type: object
          properties:
            skills:
              type: string
            agents:
              type: string
            tools:
              type: string
            federation:
              type: string
            validate:
              type: string
            publish:
              type: string
            control_plane:
              type: string
          additionalProperties:
            type: string
          anyOf:
          - required: [skills]
          - required: [agents]
          - required: [tools]
        capabilities:
          type: array
          items:
            type: string
        profiles:
          type: object
          properties:
            gitlab:
              type: object
              properties:
                discovery_did:
                  type: string
                runtime:
                  type: string
                  enum: [gitlab]
                authorization_endpoint:
                  type: string
                required_checks:
                  type: array
                  items:
                    type: string
        identity:
          type: object
          properties:
            did:
              type: string
            public_key:
              type: string
        ossa_versions:
          type: array
          items:
            type: string
        federation:
          type: object
          properties:
            gossip:
              type: boolean
            max_hops:
              type: integer
              default: 2
        governance:
          $ref: "#/components/schemas/NodeGovernance"
          description: "Inline governance summary (NIST GOVERN 1.1)."

    OssaMetadata:
      type: object
      required: [name]
      properties:
        name:
          type: string
        version:
          type: string
        description:
          type: string
        uri:
          type: string
          description: "GAID — agent://namespace/type/name"
        category:
          type: string
        trust_tier:
          type: string
          enum: [official, verified-signature, signed, community, experimental]
        tags:
          type: array
          items:
            type: string
        created:
          type: string
          format: date-time
        updated:
          type: string
          format: date-time
      additionalProperties: true

    ResourceSignature:
      type: object
      properties:
        algorithm:
          type: string
          enum: [Ed25519, ES256]
        value:
          type: string
          description: Base64url-encoded signature
        signer:
          type: string
          description: DID of the signer
        timestamp:
          type: string
          format: date-time

    ResourceIdentity:
      type: object
      required: [did, gaid]
      description: |
        Comprehensive agent/resource identity. Covers DID, DNS binding,
        cryptographic keys, service accounts, provenance, lifecycle,
        operational context, relationships, compliance, and reputation.
      properties:
        did:
          type: string
          description: "W3C DID for this resource (e.g., did:web:example.com:agents:my-agent)."
        gaid:
          type: string
          description: "Global Agent Identifier (agent://namespace/type/name)."
        dns:
          type: object
          properties:
            record:
              type: string
              description: "DNS TXT record name."
            verified:
              type: boolean
        keys:
          type: object
          properties:
            signing:
              type: object
              required: [id, type, public_key_multibase]
              properties:
                id:
                  type: string
                type:
                  type: string
                public_key_multibase:
                  type: string
            encryption:
              type: object
              properties:
                id:
                  type: string
                type:
                  type: string
                public_key_multibase:
                  type: string
            rotation:
              type: object
              properties:
                next_key_hash:
                  type: string
                rotation_policy:
                  type: string
        service_account:
          type: object
          properties:
            id:
              type: string
            type:
              type: string
              enum: [bot, service, system]
            provider:
              type: string
            scopes:
              type: array
              items:
                type: string
            token_endpoint:
              type: string
              format: uri
            client_id:
              type: string
        provenance:
          type: object
          properties:
            creator:
              type: string
            publisher:
              type: string
            created:
              type: string
              format: date-time
            published:
              type: string
              format: date-time
            source_repository:
              type: string
              format: uri
            commit_hash:
              type: string
            build_system:
              type: string
            attestations:
              type: array
              items:
                type: object
                properties:
                  type:
                    type: string
                  uri:
                    type: string
                    format: uri
        lifecycle:
          type: object
          properties:
            status:
              type: string
              enum: [draft, active, suspended, deprecated, revoked]
            activated:
              type: string
              format: date-time
            expires:
              type: [string, "null"]
              format: date-time
            suspended:
              type: [string, "null"]
              format: date-time
            revoked:
              type: [string, "null"]
              format: date-time
            deprecation:
              type: [string, "null"]
              format: date-time
            successor:
              type: [string, "null"]
        operational:
          type: object
          properties:
            endpoint:
              type: string
              format: uri
            protocol:
              type: string
              enum: [mcp, a2a, rest, grpc, websocket]
            transport:
              type: string
              enum: [https, sse, stdio, websocket]
            health_check:
              type: string
              format: uri
            rate_limit:
              type: object
              properties:
                requests_per_minute:
                  type: integer
                concurrent_sessions:
                  type: integer
            availability:
              type: object
              properties:
                sla:
                  type: string
                regions:
                  type: array
                  items:
                    type: string
        relationships:
          type: object
          properties:
            parent_agent:
              type: string
            skills:
              type: array
              items:
                type: string
            tools:
              type: array
              items:
                type: string
            depends_on:
              type: array
              items:
                type: string
            delegates_to:
              type: array
              items:
                type: string
            registered_nodes:
              type: array
              items:
                type: string
        compliance:
          type: object
          properties:
            nist_controls:
              type: array
              items:
                type: string
            safety:
              type: object
              properties:
                human_oversight:
                  type: string
                  enum: [none, optional, recommended, required]
                max_autonomy_level:
                  type: string
                  enum: [autonomous, supervised, human-in-loop, view-only]
                restricted_actions:
                  type: array
                  items:
                    type: string
                safety_policy:
                  type: string
            data_handling:
              type: object
              properties:
                pii_access:
                  type: boolean
                data_retention:
                  type: string
                  enum: [none, session, 30d, 365d, permanent]
                data_residency:
                  type: array
                  items:
                    type: string
                encryption_at_rest:
                  type: boolean
                encryption_in_transit:
                  type: boolean
            audit:
              type: object
              properties:
                log_endpoint:
                  type: string
                  format: uri
                log_format:
                  type: string
                  enum: [OTEL, CEF, JSON, syslog]
                retention_days:
                  type: integer
        reputation:
          type: object
          properties:
            trust_tier:
              type: string
              enum: [official, verified-signature, signed, community, 
                  experimental]
            verification_date:
              type: string
              format: date-time
            verified_by:
              type: string
            attestations_count:
              type: integer
            usage_count:
              type: integer
            nodes_registered:
              type: integer
            community_rating:
              type: number
            incidents:
              type: integer

    # ─── Agent Card v1.0 (DUADP extension) ──────────────────────────────────
    AgentCard:
      allOf:
        # --- Agent Card v1.0 fields (canonical, from api-schema-registry) ---
        # Inline rather than $ref to keep the DUADP spec self-contained and
        # avoid external bundle resolution issues during lint. Field set exactly
        # mirrors api-schema-registry/openapi/openstandardagents/schemas/agent-card.schema.yaml
      - type: object
        required:
        - schemaVersion
        - humanReadableId
        - agentVersion
        - name
        - description
        - url
        - capabilities
        - authSchemes
        properties:
          schemaVersion:
            type: string
            description: Version of the Agent Card schema.
            enum: ["1.0"]
            example: "1.0"
          humanReadableId:
            type: string
            description: Unique namespace/agent identifier (e.g. 
              "acme/weather-reporter").
            pattern: '^[a-z0-9][a-z0-9._-]*/[a-z0-9][a-z0-9._-]*$'
            example: "acme/weather-reporter"
          agentVersion:
            type: string
            description: Semantic version (MAJOR.MINOR.PATCH) of the agent 
              software.
            example: "2.1.0"
          name:
            type: string
            description: Human-readable display name.
            example: "Advanced Weather Reporter"
          description:
            type: string
            description: Purpose and capabilities of the agent.
          url:
            type: string
            format: uri
            description: Primary A2A endpoint URL (HTTPS required except 
              localhost).
          provider:
            type: object
            required: [name]
            properties:
              name:
                type: string
              url:
                type: string
                format: uri
              support_contact:
                type: string
          capabilities:
            type: object
            required: [a2aVersion]
            properties:
              a2aVersion:
                type: string
                example: "1.0"
              mcpVersion:
                type: string
                example: "0.6"
              supportedMessageParts:
                type: array
                items:
                  type: string
                  enum: [text, file, data, image, audio, video]
              supportsPushNotifications:
                type: boolean
                default: false
              teeDetails:
                type: object
                required: [type]
                properties:
                  type:
                    type: string
                  attestationEndpoint:
                    type: string
                    format: uri
                  publicKey:
                    type: string
                  description:
                    type: string
          authSchemes:
            type: array
            minItems: 1
            items:
              type: object
              required: [scheme]
              properties:
                scheme:
                  type: string
                  enum: [apiKey, oauth2, bearer, none]
                description:
                  type: string
                tokenUrl:
                  type: string
                  format: uri
                scopes:
                  type: array
                  items:
                    type: string
                service_identifier:
                  type: string
          skills:
            type: array
            items:
              type: object
              required: [id, name, description]
              properties:
                id:
                  type: string
                  pattern: '^[a-z][a-z0-9_-]*$'
                name:
                  type: string
                description:
                  type: string
                input_schema:
                  type: object
                  additionalProperties: true
                output_schema:
                  type: object
                  additionalProperties: true
          tags:
            type: array
            items:
              type: string
          privacyPolicyUrl:
            type: string
            format: uri
          termsOfServiceUrl:
            type: string
            format: uri
          iconUrl:
            type: string
            format: uri
          lastUpdated:
            type: string
            format: date-time

        # --- DUADP-native identity and trust fields ---
      - type: object
        description: |
          DUADP extensions on top of Agent Card v1.0.
          These fields provide DUADP-specific identity, cryptographic verification,
          and trust tier metadata.
        required: [uuid, gaid, trust_tier]
        properties:
          uuid:
            type: string
            format: uuid
            description: Version 5 UUID derived from the agent GAID namespace 
              and name.
          gaid:
            type: string
            format: uri
            description: Global Agent Identifier (DID) for verifiable identity 
              tracing.
          trust_tier:
            type: string
            enum: [tier_1_read, tier_2_write_limited, tier_3_write_elevated, 
                tier_4_system_admin]
            description: Evaluated DUADP security trust tier.
          signature:
            type: string
            description: Base64-encoded cryptographic signature of this card 
              payload.
          endpoints:
            type: object
            description: Additional DUADP multi-protocol endpoint map 
              (complements url field).
            properties:
              a2a:
                type: string
                format: uri
              mcp:
                type: string
                format: uri
              ossa:
                type: string
                format: uri
              openapi:
                type: string
                format: uri


    OssaResource:
      type: object
      required: [apiVersion, kind, metadata]
      description: Generic OSSA resource — can be Skill, Agent, Tool, or custom 
        kind.
      properties:
        apiVersion:
          type: string
          pattern: "^ossa/v\\d+\\.\\d+$"
        kind:
          type: string
        metadata:
          $ref: "#/components/schemas/OssaMetadata"
        identity:
          $ref: "#/components/schemas/ResourceIdentity"
          description: "Comprehensive resource identity (DID, keys, service account,
            lifecycle)."
        spec:
          type: object
        signature:
          $ref: "#/components/schemas/ResourceSignature"
        provenance:
          $ref: "#/components/schemas/ResourceProvenance"
          description: "Supply chain provenance (NIST SP 800-218A)."
        risk:
          $ref: "#/components/schemas/ResourceRisk"
          description: "Risk assessment (NIST AI RMF MAP 5.1)."
        content_hash:
          type: string
          description: "SHA-256 of canonical manifest. Content-addressed dedup."
        endpoints:
          $ref: "#/components/schemas/ProtocolEndpoints"
          description: "Multi-protocol endpoint map (A2A, MCP, OSSA, OpenAPI, REST,
            etc.)."
        pricing:
          $ref: "#/components/schemas/PricingInfo"
          description: "Cost/pricing metadata."
        sla:
          $ref: "#/components/schemas/SLAInfo"
          description: "Service level agreement."
        status:
          type: string
          enum: [active, deprecated, suspended, sunset]
          description: "Operational status."
        sunset_date:
          type: string
          format: date-time
          description: "Planned decommissioning date (NIST MG-4.1)."

    OssaSkill:
      allOf:
      - $ref: "#/components/schemas/OssaResource"
      - type: object
        properties:
          kind:
            type: string
            const: Skill

    OssaAgent:
      allOf:
      - $ref: "#/components/schemas/OssaResource"
      - type: object
        properties:
          kind:
            type: string
            const: Agent

    OssaTool:
      allOf:
      - $ref: "#/components/schemas/OssaResource"
      - type: object
        properties:
          kind:
            type: string
            const: Tool

    PaginationMeta:
      type: object
      required: [total, page, limit, node_name]
      properties:
        total:
          type: integer
        page:
          type: integer
        limit:
          type: integer
        node_name:
          type: string
        node_id:
          type: string
        federated:
          type: boolean
        sources:
          type: array
          items:
            type: object
            properties:
              node_id:
                type: string
              node_name:
                type: string
              count:
                type: integer
        next_cursor:
          type: string
          description: Cursor for the next page (cursor-based pagination).
        prev_cursor:
          type: string
          description: Cursor for the previous page (cursor-based pagination).

    SkillsResponse:
      type: object
      required: [data, meta]
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/OssaSkill"
        meta:
          $ref: "#/components/schemas/PaginationMeta"

    AgentsResponse:
      type: object
      required: [data, meta]
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/OssaAgent"
        meta:
          $ref: "#/components/schemas/PaginationMeta"

    ToolsResponse:
      type: object
      required: [data, meta]
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/OssaTool"
        meta:
          $ref: "#/components/schemas/PaginationMeta"

    FederationResponse:
      type: object
      required: [protocol_version, node_name, peers]
      properties:
        protocol_version:
          type: string
        node_id:
          type: string
        node_name:
          type: string
        gossip:
          type: boolean
        max_hops:
          type: integer
        peers:
          type: array
          items:
            $ref: "#/components/schemas/Peer"

    Peer:
      type: object
      required: [url, name, status]
      properties:
        url:
          type: string
          format: uri
        node_id:
          type: string
        name:
          type: string
        status:
          type: string
          enum: [healthy, degraded, unreachable]
        last_synced:
          type: [string, "null"]
          format: date-time
        capabilities:
          type: array
          items:
            type: string
        skill_count:
          type: integer
        agent_count:
          type: integer
        tool_count:
          type: integer

    PublishResponse:
      type: object
      required: [success]
      properties:
        success:
          type: boolean
        resource:
          $ref: "#/components/schemas/OssaResource"

    GitLabSecurityAttributes:
      type: object
      additionalProperties:
        oneOf:
        - type: string
        - type: array
          items:
            type: string

    GitLabToolMetadata:
      type: object
      properties:
        component:
          type: string
        stage:
          type: string
        required_variables:
          type: array
          items:
            type: string
        external_status_check:
          type: string
        external_control:
          type: string
        allowed_hosts:
          type: array
          items:
            type: string
        frameworks:
          type: array
          items:
            type: string
        actions:
          type: array
          items:
            type: string

    GitLabRequestContext:
      type: object
      required: [runtime, action, project_path]
      properties:
        runtime:
          type: string
          enum: [gitlab]
        action:
          type: string
        project_path:
          type: string
        group_path:
          type: string
        project_id:
          oneOf:
          - type: string
          - type: integer
        merge_request_iid:
          oneOf:
          - type: integer
          - type: "null"
        pipeline_id:
          oneOf:
          - type: string
          - type: integer
        sha:
          type: string
        source_branch:
          type: string
        target_branch:
          type: string
        pipeline_source:
          type: string
        labels:
          type: array
          items:
            type: string
        frameworks:
          type: array
          items:
            type: string
        security_attributes:
          $ref: "#/components/schemas/GitLabSecurityAttributes"
        actor:
          type: object
          properties:
            id:
              type: string
            type:
              type: string
              enum: [token, gitlab-job, gitlab-webhook, system]

    AuthorizationDecision:
      type: object
      required: [decision, decision_id, actor, frameworks, approved_tools, 
          approved_skills, allowed_hosts, required_checks, evidence_obligations, 
          cedar]
      properties:
        decision:
          type: string
          enum: [Allow, Deny]
        decision_id:
          type: string
        actor:
          type: string
        frameworks:
          type: array
          items:
            type: string
        approved_tools:
          type: array
          items:
            type: object
            properties:
              name:
                type: string
              kind:
                type: string
                enum: [Tool, Skill]
              description:
                type: string
              gitlab:
                $ref: "#/components/schemas/GitLabToolMetadata"
        approved_skills:
          type: array
          items:
            type: object
            properties:
              name:
                type: string
              kind:
                type: string
                enum: [Tool, Skill]
              description:
                type: string
              gitlab:
                $ref: "#/components/schemas/GitLabToolMetadata"
        allowed_hosts:
          type: array
          items:
            type: string
        required_checks:
          type: array
          items:
            type: object
            properties:
              id:
                type: string
              mode:
                type: string
                enum: [advisory, blocking]
              description:
                type: string
        evidence_obligations:
          type: array
          items:
            type: object
            properties:
              id:
                type: string
              framework:
                type: string
              required:
                type: boolean
              description:
                type: string
        cedar:
          type: object
          properties:
            decision:
              type: string
              enum: [Allow, Deny]
            reasons:
              type: array
              items:
                type: string
            errors:
              type: array
              items:
                type: string
            evaluation_ms:
              type: number

    WebFingerResponse:
      type: object
      required: [subject, links]
      description: |
        RFC 7033 WebFinger response with protocol-specific link relations.
        A GAID query returns links to ALL supported protocol endpoints.
      properties:
        subject:
          type: string
          description: The queried GAID URI
        aliases:
          type: array
          items:
            type: string
          description: "Alternative URIs (e.g., agent://, did:web:, duadp://)"
        links:
          type: array
          items:
            $ref: "#/components/schemas/WebFingerLink"
        properties:
          type: object
          additionalProperties:
            type: string
      example:
        subject: "duadp://acme.com/agents/code-reviewer"
        aliases:
        - "agent://acme.com/agents/code-reviewer"
        - "did:web:acme.com:agents:code-reviewer"
        links:
        - rel: "https://duadp.dev/rel/self"
          type: "application/json"
          href: "https://acme.com/api/v1/agents/code-reviewer"
        - rel: "https://duadp.dev/rel/a2a"
          type: "application/json"
          href: "https://acme.com/.well-known/agent.json"
          titles:
            default: "A2A Agent Card"
        - rel: "https://duadp.dev/rel/mcp"
          type: "application/json"
          href: "mcp://acme.com/tools/code-reviewer"
          titles:
            default: "MCP Server"
        - rel: "https://duadp.dev/rel/ossa"
          type: "application/yaml"
          href: "https://acme.com/manifests/code-reviewer.ossa.yaml"
          titles:
            default: "OSSA Manifest"
        - rel: "https://duadp.dev/rel/openapi"
          type: "application/openapi+yaml"
          href: "https://acme.com/api/code-reviewer/openapi.yaml"
        - rel: "https://duadp.dev/rel/identity"
          type: "application/json"
          href: "https://acme.com/api/v1/identity/duadp://acme.com/agents/code-reviewer"
        - rel: "https://duadp.dev/rel/provenance"
          type: "application/json"
          href: "https://acme.com/api/v1/provenance/duadp://acme.com/agents/code-reviewer"
        properties:
          "https://duadp.dev/ns/trust_tier": "verified-signature"
          "https://duadp.dev/ns/version": "1.2.0"
          "https://duadp.dev/ns/status": "active"

    WebFingerLink:
      type: object
      required: [rel, href]
      description: |
        WebFinger link with DUADP-defined link relations.
        Standard link relations:
          - `https://duadp.dev/rel/self` — DUADP resource endpoint
          - `https://duadp.dev/rel/a2a` — A2A Agent Card (Google A2A protocol)
          - `https://duadp.dev/rel/mcp` — MCP server manifest (Anthropic MCP)
          - `https://duadp.dev/rel/ossa` — OSSA governance manifest
          - `https://duadp.dev/rel/openapi` — OpenAPI specification
          - `https://duadp.dev/rel/identity` — Agent identity record
          - `https://duadp.dev/rel/provenance` — Supply chain provenance
          - `https://duadp.dev/rel/health` — Health check endpoint
          - `https://duadp.dev/rel/ajson` — Agent JSON index record
      properties:
        rel:
          type: string
          description: "Link relation type (IANA or DUADP namespace)"
        type:
          type: string
          description: "MIME type of the linked resource"
        href:
          type: string
          format: uri
          description: "URL of the linked resource"
        titles:
          type: object
          additionalProperties:
            type: string
          description: "Human-readable titles keyed by language tag"
        properties:
          type: object
          additionalProperties:
            type: string
          description: "Additional metadata about this link"

    ValidationResult:
      type: object
      required: [valid]
      properties:
        valid:
          type: boolean
        errors:
          type: array
          items:
            type: string
        warnings:
          type: array
          items:
            type: string

    GaidResolveResponse:
      type: object
      required: [resource, source_node, resolved]
      properties:
        resource:
          $ref: "#/components/schemas/OssaResource"
        source_node:
          type: string
        source_url:
          type: string
          format: uri
        resolved:
          type: boolean

    ResolutionTraceStep:
      type: object
      required: [step, status, detail]
      properties:
        step:
          type: string
        status:
          type: string
          enum: [passed, failed]
        detail:
          type: string

    RevocationRecord:
      type: object
      required: [gaid, kind, name, reason]
      properties:
        gaid:
          type: string
        kind:
          type: string
        name:
          type: string
        reason:
          type: string
        revoked_by:
          type: string
        origin_node:
          type: string
        created_at:
          type: string
          format: date-time

    InspectorDidState:
      type: object
      required: [resolved, self_verifying, verification_method_count]
      properties:
        value:
          type: string
        method:
          type: string
        resolved:
          type: boolean
        self_verifying:
          type: boolean
        document_url:
          type: string
          format: uri
        document:
          type: object
          additionalProperties: true
        verification_method_count:
          type: integer
        error:
          type: string

    PublishAuthorizationResult:
      type: object
      required: [principal_id, context, global_policy, effective_decision]
      properties:
        principal_id:
          type: string
        context:
          type: object
          additionalProperties: true
        global_policy:
          $ref: "#/components/schemas/CedarEvaluationResult"
        manifest_policy:
          oneOf:
          - $ref: "#/components/schemas/CedarEvaluationResult"
          - type: "null"
        effective_decision:
          type: string
          enum: [Allow, Deny]

    InspectorProvenance:
      type: object
      properties:
        publisher:
          type: object
          additionalProperties: true
        license:
          type: string
        source_url:
          type: string
          format: uri
        links:
          type: array
          items:
            type: object
            required: [rel, href]
            properties:
              rel:
                type: string
              href:
                type: string
              label:
                type: string

    InspectorResponse:
      type: object
      required:
      - gaid
      - resolved
      - resolved_via
      - source_node
      - resource_kind
      - resource_name
      - resource
      - did
      - trust_verification
      - signature_verification
      - revocation
      - provenance
      - policy
      properties:
        gaid:
          type: string
        resolved:
          type: boolean
        resolved_via:
          type: string
          enum: [local, peer]
        source_node:
          type: string
        source_url:
          type: string
          format: uri
        resource_kind:
          type: string
        resource_name:
          type: string
        resource_url:
          type: string
          format: uri
        resource:
          $ref: "#/components/schemas/OssaResource"
        did:
          $ref: "#/components/schemas/InspectorDidState"
        trust_verification:
          type: object
          additionalProperties: true
        signature_verification:
          type: object
          additionalProperties: true
        revocation:
          type: object
          required: [revoked]
          properties:
            revoked:
              type: boolean
            record:
              oneOf:
              - $ref: "#/components/schemas/RevocationRecord"
              - type: "null"
        provenance:
          $ref: "#/components/schemas/InspectorProvenance"
        policy:
          type: object
          required: [anonymous_publish, claimed_publisher_publish]
          properties:
            anonymous_publish:
              $ref: "#/components/schemas/PublishAuthorizationResult"
            claimed_publisher_publish:
              $ref: "#/components/schemas/PublishAuthorizationResult"
        resolution_trace:
          type: array
          items:
            $ref: "#/components/schemas/ResolutionTraceStep"

    Error:
      type: object
      required: [error]
      properties:
        error:
          type: string
        code:
          type: string

    # ─── NIST AI RMF Aligned Types (v0.2.1) ──────────────────

    NodeGovernance:
      type: object
      description: |
        Governance declarations for a DUADP node.
        Maps to NIST AI RMF GOVERN function.
      properties:
        compliance_frameworks:
          type: array
          items:
            type: string
          description: "Frameworks: NIST-AI-RMF, SOC2, FedRAMP, ISO-42001, EU-AI-Act"
        risk_tolerance:
          type: string
          enum: [strict, moderate, permissive]
          description: "NIST GOVERN 1.2 — risk tolerance level."
        data_classification:
          type: string
          enum: [public, internal, confidential, restricted]
        review_policy:
          type: string
          enum: [manual, automated, hybrid]
          description: "How resources are reviewed before publication."
        audit_retention_days:
          type: integer
          description: "Audit log retention in days (NIST AU-11)."

    ResourceProvenance:
      type: object
      description: |
        Supply chain provenance. Maps to NIST SP 800-218A and EO 14110.
      properties:
        publisher:
          type: object
          properties:
            name:
              type: string
            url:
              type: string
              format: uri
            organization:
              type: string
            verified:
              type: boolean
        build:
          type: object
          description: "Build provenance (SLSA-style)."
          properties:
            builder:
              type: string
            source_repo:
              type: string
              format: uri
            commit_sha:
              type: string
            build_time:
              type: string
              format: date-time
            reproducible:
              type: boolean
        sbom:
          type: object
          description: "Software Bill of Materials (NIST SP 800-218A)."
          properties:
            format:
              type: string
              enum: [spdx, cyclonedx]
            components:
              type: array
              items:
                type: object
                properties:
                  name:
                    type: string
                  version:
                    type: string
                  type:
                    type: string
                    enum: [model, library, framework, tool, dataset, runtime]
                  supplier:
                    type: string
                  license:
                    type: string
                  hash:
                    type: string
        attestations:
          type: array
          items:
            $ref: "#/components/schemas/Attestation"

    Attestation:
      type: object
      description: |
        Third-party attestation. Maps to NIST GOVERN 1.7.
      properties:
        type:
          type: string
          enum: [security-audit, compliance-review, performance-test, 
              safety-evaluation, red-team]
        issuer:
          type: string
        issued_at:
          type: string
          format: date-time
        expires_at:
          type: string
          format: date-time
        result:
          type: string
          enum: [pass, conditional-pass, fail]
        details_url:
          type: string
          format: uri

    ResourceRisk:
      type: object
      description: |
        NIST AI RMF risk assessment. Maps to MAP 5.1, MEASURE 1.1.
      properties:
        level:
          type: string
          enum: [critical, high, moderate, low, minimal]
        impact:
          type: object
          description: "NIST MAP 5.1 impact categories."
          properties:
            people:
              type: string
              enum: [critical, high, moderate, low, none]
            organizations:
              type: string
              enum: [critical, high, moderate, low, none]
            ecosystems:
              type: string
              enum: [critical, high, moderate, low, none]
        autonomy_level:
          type: string
          enum: [fully-autonomous, supervised, human-in-the-loop, advisory]
          description: "NIST GOVERN 1.3 — human oversight level."
        data_sensitivity:
          type: string
          enum: [public, internal, confidential, restricted]
        known_limitations:
          type: array
          items:
            type: string
          description: "NIST MAP 2.3 — known failure modes."
        mitigations:
          type: array
          items:
            type: string
          description: "NIST MANAGE 2.2 — risk mitigations."
        nist_controls:
          type: array
          items:
            type: object
            properties:
              control_id:
                type: string
                description: "e.g., AC-6, SA-4, SR-3"
              status:
                type: string
                enum: [implemented, partially-implemented, planned, 
                    not-applicable]
              evidence:
                type: string

    Revocation:
      type: object
      required: [gaid, reason, revoked_at]
      description: "NIST SI-7 (integrity), CM-3 (change control)."
      properties:
        gaid:
          type: string
        resource_name:
          type: string
        reason:
          type: string
          enum: [security-vulnerability, policy-violation, publisher-request, 
              expired, superseded]
        severity:
          type: string
          enum: [critical, high, moderate, low]
        revoked_at:
          type: string
          format: date-time
        revoked_by:
          type: string
        superseded_by:
          type: string
          description: "GAID of replacement resource."

    AuditEvent:
      type: object
      required: [event_type, timestamp]
      description: "NIST AU-2, AU-3 audit trail."
      properties:
        event_id:
          type: string
          format: uuid
        event_type:
          type: string
          enum: [publish, revoke, update, peer_added, peer_removed, access, 
              validation, risk_change]
        timestamp:
          type: string
          format: date-time
        actor:
          type: string
        gaid:
          type: string
        details:
          type: object
          additionalProperties: true

    SyncChange:
      type: object
      required: [action, resource_type, gaid, timestamp]
      properties:
        action:
          type: string
          enum: [created, updated, revoked, deleted]
        resource_type:
          type: string
          enum: [skill, agent, tool]
        gaid:
          type: string
        timestamp:
          type: string
          format: date-time
        content_hash:
          type: string
        resource:
          $ref: "#/components/schemas/OssaResource"

    SyncResponse:
      type: object
      required: [changes]
      properties:
        changes:
          type: array
          items:
            $ref: "#/components/schemas/SyncChange"
        sync_token:
          type: string
          description: "Opaque token for next incremental sync."
        has_more:
          type: boolean

    WebhookSubscription:
      type: object
      required: [callback_url, events]
      properties:
        callback_url:
          type: string
          format: uri
        events:
          type: array
          items:
            type: string
            enum: [resource.published, resource.updated, resource.revoked, 
                peer.added, peer.removed]
        secret:
          type: string
          description: "HMAC-SHA256 shared secret."
        filter:
          type: object
          properties:
            resource_types:
              type: array
              items:
                type: string
                enum: [skill, agent, tool]
            trust_tiers:
              type: array
              items:
                type: string

    AgentIdentity:
      type: object
      required: [gaid, did]
      description: |
        Agent identity record. Each agent gets a unique DID (did:web),
        DNS TXT record, and optional service account for authenticated operations.
      properties:
        gaid:
          type: string
          description: "Global Agent Identifier (agent://namespace/type/name)."
        did:
          type: string
          description: "Decentralized Identifier (did:web:domain:path)."
        dns_record:
          type: object
          description: "DNS TXT record for domain-level identity binding."
          properties:
            domain:
              type: string
            record_name:
              type: string
              description: "TXT record name (e.g., _duadp.agent-name.example.com)."
            record_value:
              type: string
              description: "TXT record value (duadp=v1;gaid=agent://...;key=...)."
        service_account:
          type: object
          description: "Bot/service account for authenticated operations."
          properties:
            type:
              type: string
              enum: [bot, service-account, machine-identity]
            provider:
              type: string
              description: "Identity provider (e.g., gitlab, github, entra-id, okta)."
            username:
              type: string
            scopes:
              type: array
              items:
                type: string
              description: "Granted permissions/scopes."
        keys:
          type: array
          items:
            type: object
            properties:
              id:
                type: string
                description: "Key identifier (kid)."
              type:
                type: string
                enum: [Ed25519, ES256, RSA]
              public_key:
                type: string
                description: "PEM or JWK encoded public key."
              purpose:
                type: string
                enum: [signing, authentication, encryption]
              created:
                type: string
                format: date-time
              expires:
                type: string
                format: date-time
        verification_methods:
          type: array
          items:
            type: string
          description: "DID verification methods (e.g., did:web resolution, DNS TXT
            lookup)."

    # ─── Node Health ───────────────────────────────────────────────

    NodeHealth:
      type: object
      required: [status, protocol_version, node_name, uptime_seconds]
      properties:
        status:
          type: string
          enum: [healthy, degraded, maintenance]
        protocol_version:
          type: string
        node_name:
          type: string
        node_id:
          type: string
        uptime_seconds:
          type: integer
        resource_counts:
          type: object
          properties:
            skills:
              type: integer
            agents:
              type: integer
            tools:
              type: integer
            peers:
              type: integer
        federation:
          type: object
          properties:
            peer_count:
              type: integer
            healthy_peers:
              type: integer
            last_sync:
              type: string
              format: date-time
        version:
          type: string
          description: "Implementation version (not protocol version)"

    # ─── Search Facets ───────────────────────────────────────────

    SearchFacets:
      type: object
      description: "Faceted search metadata for filtering refinement."
      properties:
        kinds:
          type: object
          additionalProperties:
            type: integer
          description: "Count per resource kind (e.g., {Skill: 12, Agent: 5, Tool:
            8})"
        categories:
          type: object
          additionalProperties:
            type: integer
        trust_tiers:
          type: object
          additionalProperties:
            type: integer
        protocols:
          type: object
          additionalProperties:
            type: integer
          description: "Count per protocol (tools only)"
        tags:
          type: object
          additionalProperties:
            type: integer
          description: "Top tags with counts"

    # ─── Agent JSON Index Record (.ajson) ────────────────────────

    AgentIndexRecord:
      type: object
      required: [gaid, kind, name, endpoints]
      description: |
        Lightweight, universal discovery index record.
        Links to full specifications in any protocol format.
        Designed as the "index card" for cross-registry aggregation.
        Content-Type: application/agent+json
      properties:
        gaid:
          type: string
          description: "Global Agent Identifier (duadp://namespace/kind/name)"
        kind:
          type: string
          enum: [Skill, Agent, Tool, Workflow]
        name:
          type: string
        version:
          type: string
        description:
          type: string
          maxLength: 500
        status:
          type: string
          enum: [active, deprecated, suspended, sunset]
        trust_tier:
          type: string
          enum: [official, verified-signature, signed, community, experimental]
        capabilities:
          type: array
          items:
            type: string
          description: "Standardized capability tags from DUADP taxonomy"
        tags:
          type: array
          items:
            type: string
        endpoints:
          $ref: "#/components/schemas/ProtocolEndpoints"
        identity:
          type: object
          properties:
            did:
              type: string
            node_id:
              type: string
            publisher:
              type: string
        pricing:
          $ref: "#/components/schemas/PricingInfo"
        sla:
          $ref: "#/components/schemas/SLAInfo"
        content_hash:
          type: string
          description: "SHA-256 hash for dedup and integrity verification"
        updated:
          type: string
          format: date-time
        sunset_date:
          type: string
          format: date-time
          description: "NIST MG-4.1 — planned decommissioning date"
      example:
        gaid: "duadp://acme.com/agents/code-reviewer"
        kind: Agent
        name: code-reviewer
        version: "1.2.0"
        description: "Reviews code for quality, security, and style"
        status: active
        trust_tier: verified-signature
        capabilities: [code-review, security-analysis, style-check]
        tags: [security, quality, devops]
        endpoints:
          duadp: "https://acme.com/api/v1/agents/code-reviewer"
          a2a: "https://acme.com/.well-known/agent.json"
          mcp: "mcp://acme.com/tools/code-reviewer"
          ossa: "https://acme.com/manifests/code-reviewer.ossa.yaml"
          openapi: "https://acme.com/api/code-reviewer/openapi.yaml"
          health: "https://acme.com/agents/code-reviewer/health"
        identity:
          did: "did:web:acme.com:agents:code-reviewer"
          publisher: "Acme Corp"
        pricing:
          model: free
        sla:
          availability: "99.9%"
          max_latency_ms: 5000
        content_hash: "sha256:a1b2c3d4e5f6..."
        updated: "2026-03-05T10:00:00Z"

    ProtocolEndpoints:
      type: object
      description: |
        Multi-protocol endpoint map. Each key is a protocol identifier,
        the value is the endpoint URL or URI for that protocol.
        This is what makes DUADP a universal discovery layer — a single
        record links to every protocol endpoint for a resource.
      properties:
        duadp:
          type: string
          format: uri
          description: "DUADP resource endpoint"
        a2a:
          type: string
          format: uri
          description: "Google A2A Agent Card endpoint"
        mcp:
          type: string
          description: "MCP server URI (mcp:// or https://)"
        ossa:
          type: string
          format: uri
          description: "OSSA manifest URL"
        openapi:
          type: string
          format: uri
          description: "OpenAPI specification URL"
        rest:
          type: string
          format: uri
          description: "REST API base URL"
        grpc:
          type: string
          description: "gRPC endpoint"
        graphql:
          type: string
          format: uri
          description: "GraphQL endpoint"
        health:
          type: string
          format: uri
          description: "Health check endpoint"
      additionalProperties:
        type: string
        description: "Custom protocol endpoints"

    PricingInfo:
      type: object
      description: "Cost/pricing metadata for the resource."
      properties:
        model:
          type: string
          enum: [free, metered, subscription, enterprise, contact]
        currency:
          type: string
          default: "USD"
        per_request:
          type: number
          description: "Cost per API call (metered model)"
        per_token:
          type: number
          description: "Cost per token (metered model)"
        monthly:
          type: number
          description: "Monthly subscription cost"
        free_tier:
          type: object
          properties:
            requests_per_month:
              type: integer
            tokens_per_month:
              type: integer

    SLAInfo:
      type: object
      description: "Service Level Agreement metadata."
      properties:
        availability:
          type: string
          description: "Uptime SLA (e.g., 99.9%)"
        max_latency_ms:
          type: integer
          description: "Maximum P99 latency in milliseconds"
        rate_limit:
          type: object
          properties:
            requests_per_minute:
              type: integer
            requests_per_day:
              type: integer
            tokens_per_minute:
              type: integer
        support:
          type: string
          enum: [community, email, priority, dedicated]

    # ─── OSSA Agent Types (aligned with openstandardagents spec) ───

    AgentType:
      type: string
      enum: [orchestrator, worker, specialist, critic, monitor, gateway, 
          agentscope]
      description: OSSA agent type classification (agentscope = AgentScope 
        framework agent)

    # ─── Context Awareness & Token Efficiency ──────────────────────

    ContextNegotiation:
      type: object
      description: Context delivery negotiation for agent task execution
      properties:
        max_context_tokens:
          type: integer
        delivery_mode:
          type: string
          enum: [layered, flat, streaming]
        layers:
          type: array
          items:
            $ref: "#/components/schemas/ContextLayer"
        knowledge_sources:
          type: array
          items:
            $ref: "#/components/schemas/KnowledgeSource"
        cache_refs:
          type: array
          items:
            $ref: "#/components/schemas/ContextCacheRef"

    ContextLayer:
      type: object
      required: [name, priority]
      properties:
        name:
          type: string
        priority:
          type: integer
        max_tokens:
          type: integer
        content_type:
          type: string
          enum: [code, documentation, schema, config, embedding, summary]
        required:
          type: boolean

    KnowledgeSource:
      type: object
      required: [type, endpoint]
      properties:
        type:
          type: string
          enum: [qdrant, neo4j, weaviate, pinecone, meilisearch, elasticsearch, 
              custom]
        endpoint:
          type: string
          format: uri
        collection:
          type: string
        auth:
          type: string
          enum: [bearer, api-key, none]
        embedding_model:
          type: string
        embedding_dimensions:
          type: integer

    ContextCacheRef:
      type: object
      required: [cache_id, domain, content_hash, computed_at]
      properties:
        cache_id:
          type: string
        domain:
          type: string
        content_hash:
          type: string
        computed_at:
          type: string
          format: date-time
        ttl:
          type: integer

    # ─── Token Analytics ───────────────────────────────────────────

    TokenAnalytics:
      type: object
      required: [total_tokens, input_tokens, output_tokens, task_completed, 
          timestamp]
      properties:
        total_tokens:
          type: integer
        input_tokens:
          type: integer
        output_tokens:
          type: integer
        cost_usd:
          type: number
        model:
          type: string
        task_completed:
          type: boolean
        duration_ms:
          type: integer
        efficiency_score:
          type: number
        context_utilization:
          type: number
        timestamp:
          type: string
          format: date-time

    TokenAnalyticsAggregate:
      type: object
      required: [gaid, period, execution_count, avg_tokens_per_task, 
          success_rate]
      properties:
        gaid:
          type: string
        period:
          type: string
          enum: [hour, day, week, month, all_time]
        execution_count:
          type: integer
        avg_tokens_per_task:
          type: number
        median_tokens_per_task:
          type: number
        p95_tokens_per_task:
          type: number
        avg_cost_per_task_usd:
          type: number
        total_cost_usd:
          type: number
        success_rate:
          type: number
        avg_efficiency_score:
          type: number
        by_task_type:
          type: object
          additionalProperties:
            type: object
            properties:
              count:
                type: integer
              avg_tokens:
                type: number
              success_rate:
                type: number
              avg_cost_usd:
                type: number
        by_domain:
          type: object
          additionalProperties:
            type: object
            properties:
              count:
                type: integer
              avg_tokens:
                type: number
              success_rate:
                type: number

    CapabilityFingerprint:
      type: object
      required: [agent_gaid, sample_size, updated_at]
      properties:
        agent_gaid:
          type: string
        domains:
          type: object
          additionalProperties:
            type: object
            properties:
              accuracy:
                type: number
              avg_tokens:
                type: number
              sample_size:
                type: integer
              avg_cost_usd:
                type: number
        task_types:
          type: object
          additionalProperties:
            type: object
            properties:
              accuracy:
                type: number
              avg_cost_usd:
                type: number
              avg_tokens:
                type: number
              sample_size:
                type: integer
              avg_duration_ms:
                type: number
        model_affinity:
          type: object
          additionalProperties:
            type: object
            properties:
              efficiency:
                type: number
              quality:
                type: number
        sample_size:
          type: integer
        updated_at:
          type: string
          format: date-time

    # ─── Feedback & Rewards ────────────────────────────────────────

    AgentFeedback:
      type: object
      required: [agent_gaid, source, type, timestamp]
      properties:
        feedback_id:
          type: string
        agent_gaid:
          type: string
        task_ref:
          type: string
        source:
          $ref: "#/components/schemas/FeedbackSource"
        type:
          type: string
          enum: [rating, correction, reward, penalty, observation]
        rating:
          type: number
        rating_scale:
          type: string
          enum: ["1-5", "0-1", percentage]
        comment:
          type: string
        dimensions:
          $ref: "#/components/schemas/FeedbackDimensions"
        timestamp:
          type: string
          format: date-time
        signature:
          $ref: "#/components/schemas/ResourceSignature"

    FeedbackSource:
      type: object
      required: [type, id]
      properties:
        type:
          type: string
          enum: [human, agent, system, automated-test]
        id:
          type: string
        role:
          type: string
          enum: [user, reviewer, peer-agent, supervisor-agent, qa, admin]

    FeedbackDimensions:
      type: object
      properties:
        accuracy:
          type: number
        efficiency:
          type: number
        instruction_following:
          type: number
        quality:
          type: number
        helpfulness:
          type: number
        scope_adherence:
          type: number
        custom:
          type: object
          additionalProperties:
            type: number

    RewardEvent:
      type: object
      required: [agent_gaid, trigger, type, timestamp]
      properties:
        reward_id:
          type: string
        agent_gaid:
          type: string
        trigger:
          type: string
          enum: [task_completion, quality_threshold, efficiency_bonus, streak, 
              peer_endorsement, manual]
        type:
          type: string
          enum: [reputation_boost, priority_increase, capability_unlock, 
              token_credit, badge]
        value:
          type: number
        badge:
          type: string
        timestamp:
          type: string
          format: date-time
        task_ref:
          type: string

    AgentReputation:
      type: object
      required: [agent_gaid, overall_score, feedback_count, feedback_summary, 
          reward_count, computed_at]
      properties:
        agent_gaid:
          type: string
        overall_score:
          type: number
        feedback_count:
          type: integer
        feedback_summary:
          type: object
          properties:
            positive:
              type: integer
            neutral:
              type: integer
            negative:
              type: integer
        dimension_averages:
          $ref: "#/components/schemas/FeedbackDimensions"
        reward_count:
          type: integer
        badges:
          type: array
          items:
            type: string
        trend:
          type: string
          enum: [improving, stable, declining]
        computed_at:
          type: string
          format: date-time

    # ─── Outcome Attestations ──────────────────────────────────────

    OutcomeAttestation:
      type: object
      required: [agent_gaid, task_hash, outcome, metrics, attester, timestamp]
      properties:
        attestation_id:
          type: string
        agent_gaid:
          type: string
        task_hash:
          type: string
        outcome:
          type: string
          enum: [success, partial_success, failure, timeout]
        metrics:
          type: object
          required: [tokens_used, duration_ms, human_override]
          properties:
            tokens_used:
              type: integer
            duration_ms:
              type: integer
            cost_usd:
              type: number
            human_override:
              type: boolean
            confidence:
              type: number
        attester:
          type: string
        timestamp:
          type: string
          format: date-time
        signature:
          $ref: "#/components/schemas/ResourceSignature"

    # ─── Multi-Agent Orchestration ─────────────────────────────────

    DelegationRequest:
      type: object
      required: [from_agent, to_agent, task]
      properties:
        from_agent:
          type: string
        to_agent:
          type: string
        task:
          $ref: "#/components/schemas/DelegationTask"
        context_transfer:
          $ref: "#/components/schemas/ContextTransfer"
        budget:
          $ref: "#/components/schemas/TaskBudget"
        callback_url:
          type: string
          format: uri
        depth:
          type: integer
        max_depth:
          type: integer

    DelegationTask:
      type: object
      required: [type]
      properties:
        type:
          type: string
        description:
          type: string
        scope:
          type: array
          items:
            type: string
        inputs:
          type: object
          additionalProperties: true
        expected_output:
          type: string
        priority:
          type: string
          enum: [critical, high, normal, low]
        deadline:
          type: string
          format: date-time

    ContextTransfer:
      type: object
      properties:
        compressed_state:
          type: string
        encoding:
          type: string
          enum: [base64, gzip+base64, json]
        tokens_used_so_far:
          type: integer
        findings:
          type: array
          items:
            type: object
            properties:
              type:
                type: string
              content:
                type: string
              confidence:
                type: number
        cache_refs:
          type: array
          items:
            $ref: "#/components/schemas/ContextCacheRef"
        knowledge_access:
          type: array
          items:
            $ref: "#/components/schemas/KnowledgeSource"

    TaskBudget:
      type: object
      properties:
        max_tokens:
          type: integer
        max_cost_usd:
          type: number
        max_duration_ms:
          type: integer
        max_delegation_depth:
          type: integer

    DelegationResult:
      type: object
      required: [status]
      properties:
        status:
          type: string
          enum: [completed, failed, partial, timeout, rejected]
        result:
          type: object
          additionalProperties: true
        analytics:
          $ref: "#/components/schemas/TokenAnalytics"
        delegate_feedback:
          type: string
        delegation_chain:
          type: array
          items:
            type: object
            properties:
              agent_gaid:
                type: string
              task_type:
                type: string
              tokens_used:
                type: integer
              status:
                type: string

    OrchestrationPlan:
      type: object
      required: [orchestrator_gaid, task, steps, strategy]
      properties:
        plan_id:
          type: string
        orchestrator_gaid:
          type: string
        task:
          $ref: "#/components/schemas/DelegationTask"
        steps:
          type: array
          items:
            $ref: "#/components/schemas/OrchestrationStep"
        strategy:
          type: string
          enum: [sequential, parallel, dag, adaptive]
        budget:
          $ref: "#/components/schemas/TaskBudget"
        status:
          type: string
          enum: [planning, executing, completed, failed, cancelled]
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time

    OrchestrationStep:
      type: object
      required: [step_id, name, task]
      properties:
        step_id:
          type: string
        name:
          type: string
        agent_type:
          $ref: "#/components/schemas/AgentType"
        agent_gaid:
          type: string
        task:
          $ref: "#/components/schemas/DelegationTask"
        depends_on:
          type: array
          items:
            type: string
        budget:
          $ref: "#/components/schemas/TaskBudget"
        status:
          type: string
          enum: [pending, running, completed, failed, skipped]
        result:
          $ref: "#/components/schemas/DelegationResult"

    # ─── Batch Operations ──────────────────────────────────────

    BatchPublishResponse:
      type: object
      properties:
        total:
          type: integer
        succeeded:
          type: integer
        failed:
          type: integer
        results:
          type: array
          items:
            type: object
            properties:
              index:
                type: integer
              success:
                type: boolean
              resource:
                $ref: "#/components/schemas/OssaResource"
              error:
                type: string

    # ─── Protocol Compatibility ────────────────────────────────

    A2AAgentCard:
      type: object
      description: |
        Google A2A-compatible Agent Card generated from DUADP agent data.
        Enables interoperability with A2A clients and infrastructure.
      required: [name, url]
      properties:
        name:
          type: string
        description:
          type: string
        url:
          type: string
          format: uri
        version:
          type: string
        provider:
          type: object
          properties:
            organization:
              type: string
            url:
              type: string
              format: uri
        capabilities:
          type: object
          properties:
            streaming:
              type: boolean
            pushNotifications:
              type: boolean
            stateTransitionHistory:
              type: boolean
        authentication:
          type: object
          properties:
            schemes:
              type: array
              items:
                type: string
        skills:
          type: array
          items:
            type: object
            properties:
              id:
                type: string
              name:
                type: string
              description:
                type: string
              tags:
                type: array
                items:
                  type: string
              examples:
                type: array
                items:
                  type: string
        defaultInputModes:
          type: array
          items:
            type: string
            enum: [text, file, data]
        defaultOutputModes:
          type: array
          items:
            type: string
            enum: [text, file, data]
        _duadp:
          type: object
          description: DUADP-specific extensions (prefixed per A2A convention).
          properties:
            gaid:
              type: string
            trust_tier:
              type: string
            content_hash:
              type: string
            node_name:
              type: string

    McpServerManifest:
      type: object
      description: |
        MCP-compatible server manifest listing tools with protocol=mcp.
        Served at both /api/v1/tools/mcp-manifest and /.well-known/mcp.
      required: [name, version, tools]
      properties:
        name:
          type: string
        version:
          type: string
        description:
          type: string
        tools:
          type: array
          items:
            type: object
            required: [name]
            properties:
              name:
                type: string
              description:
                type: string
              inputSchema:
                type: object
                additionalProperties: true
              _duadp:
                type: object
                properties:
                  gaid:
                    type: string
                  trust_tier:
                    type: string
                  content_hash:
                    type: string

    # ─── Structured Query ──────────────────────────────────────

    StructuredQuery:
      type: object
      description: |
        Structured query for advanced resource discovery. Supports
        compound filters, sorting, and field selection without requiring
        a full GraphQL implementation.
      properties:
        filters:
          type: array
          items:
            type: object
            required: [field, operator, value]
            properties:
              field:
                type: string
                description: "Dot-notation field path (e.g., metadata.category, risk.level)"
              operator:
                type: string
                enum: [eq, ne, gt, gte, lt, lte, in, contains, exists, 
                    not_exists]
              value:
                description: Filter value (type depends on field and operator)
        sort:
          type: array
          items:
            type: object
            required: [field]
            properties:
              field:
                type: string
              order:
                type: string
                enum: [asc, desc]
                default: asc
        fields:
          type: array
          items:
            type: string
          description: "Field projection — return only these fields. Empty = all fields."
        kinds:
          type: array
          items:
            type: string
            enum: [Skill, Agent, Tool]
          description: "Resource types to include. Empty = all types."
        federated:
          type: boolean
          default: false
        page:
          type: integer
          default: 1
        limit:
          type: integer
          default: 20
          maximum: 100
        cursor:
          type: string
          description: "Cursor-based pagination token (alternative to page/limit)."

    CedarPolicyResource:
      type: object
      description: A Cedar policy resource from the catalog
      properties:
        kind:
          type: string
          enum: [Policy]
        metadata:
          type: object
          properties:
            name:
              type: string
            version:
              type: string
            description:
              type: string
            tags:
              type: array
              items:
                type: string
            complianceFrameworks:
              type: array
              items:
                type: string
            classification:
              type: string
            authors:
              type: array
              items:
                type: string
        spec:
          type: object
          properties:
            format:
              type: string
              enum: [cedar]
            statementCount:
              type: integer
            url:
              type: string
              format: uri

    CedarEvaluationRequest:
      type: object
      required: [principal, action, resource, policies]
      properties:
        principal:
          type: object
          required: [type, id]
          properties:
            type:
              type: string
            id:
              type: string
        action:
          type: object
          required: [type, id]
          properties:
            type:
              type: string
            id:
              type: string
        resource:
          type: object
          required: [type, id]
          properties:
            type:
              type: string
            id:
              type: string
        context:
          type: object
          additionalProperties: true
        policies:
          type: string
          description: Cedar policy source text
        schema:
          type: string
          description: Cedar schema text (optional)
        entities:
          type: array
          items:
            type: object
            properties:
              uid:
                type: object
                properties:
                  type:
                    type: string
                  id:
                    type: string
              attrs:
                type: object
                additionalProperties: true
              parents:
                type: array
                items:
                  type: object
                  properties:
                    type:
                      type: string
                    id:
                      type: string

    CedarEvaluationResult:
      type: object
      required: [decision, diagnostics, evaluation_ms]
      properties:
        decision:
          type: string
          enum: [Allow, Deny]
        diagnostics:
          type: object
          properties:
            reason:
              type: array
              items:
                type: string
            errors:
              type: array
              items:
                type: string
        evaluation_ms:
          type: number
          description: Policy evaluation time in milliseconds
  responses:
    BadRequest:
      description: Bad request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    NotFound:
      description: Resource not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
