Skip to content

Schema-driven validation: client hooks + opt-in server middleware #67

@bokelley

Description

@bokelley

Why

Companion to adcontextprotocol/adcp-client#688. Field-name drift between server responses and the AdCP spec is being caught late — by running storyboards, not by the SDK. Two recent examples (TS side):

  • `targeting` vs `targeting_overlay` (response drift)
  • `catalog_type` vs `type` (request drift)

The bundled JSON schemas published with each AdCP release are the source of truth. SDKs are the leveraged place to enforce them.

What

Mirror the TS validator shape so the three SDKs converge:

Core

  • Load bundled schemas from `dist/schemas//bundled/*.json` (self-contained `$ref`s).
  • Compile once (e.g. santhosh-tekuri/jsonschema), cache by task + direction.
  • Emit `VALIDATION_ERROR` with JSON Pointer, message, schema path. Match the existing AdCP L3 error envelope.
  • Non-strict on `additionalProperties` for extension safety.

Client hooks (on by default)

  • Validate outgoing requests before send.
  • Validate incoming responses on receive.
  • `strict` (error) vs `warn` (log + continue); strict in dev/test, warn in prod.

Server middleware (opt-in)

  • HTTP middleware for SDK-built agents at dispatcher layer.
  • Request rejects with `VALIDATION_ERROR` pre-handler.
  • Response validation: error in dev/test, log + metric in prod.

Async response variants

  • Select schema by response shape (`task_id`/`status`), not task name, for `-async-response-` cases.

Scope

  • Published AdCP tools only.
  • Shape validation only — does not replace semantic checks.
  • Version pinned to SDK's declared AdCP version.

Sequence

TS (adcontextprotocol/adcp-client#688) prototypes first. Go ports shape, error code, and pointer format.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions