Skip to content

Public 3.2 leaf schemas accept protocol-invalid bidding and allocation values #2575

Description

@bokelley

Version

@adcp/sdk@14.0.0-beta.1 (ADCP_VERSION is 3.2.0-beta.0)

Problem

The runtime schemas exported from @adcp/sdk/schemas are substantially weaker than the 3.2 contract they represent. In particular, BiddingPolicySchema accepts empty policies, negative monetary values, and combinations that the protocol says MUST be rejected. CanonicalBudgetAllocationSchema accepts an empty optimization_goals array for seller_optimized allocation.

This prevents adopters from retiring local 3.2 validators in favor of the SDK schemas without losing correctness.

Reproduction

import {
  BiddingPolicySchema,
  CanonicalBudgetAllocationSchema,
} from '@adcp/sdk/schemas'

for (const value of [
  {},
  { automatic: true, max_bid: 1 },
  { bid_amount: 1, max_bid: 2 },
  { bid_amount: -1 },
  {
    cost_per: { amount: 1, strength: 'cap' },
    roas: { value: 2, strength: 'target' },
  },
]) {
  console.log(BiddingPolicySchema.safeParse(value).success)
}

console.log(
  CanonicalBudgetAllocationSchema.safeParse({
    mode: 'seller_optimized',
    optimization_goals: [],
  }).success,
)

On beta.1 every result is true.

The generated declarations also expose these as loose objects (z.core.$loose), so arbitrary keys are accepted as well.

Expected

The SDK's public runtime schemas should enforce the normative constraints encoded by the 3.2 schemas/protocol, including at least:

  • positive monetary values;
  • a non-empty bidding policy;
  • automatic as the only field when present;
  • bid_amount exclusivity relative to max_bid, cost_per, and roas;
  • cost_per / roas exclusivity;
  • non-empty seller_optimized.optimization_goals; and
  • the relevant nested cross-field rules (for example campaign duration and required custom event names).

If the generated structural schemas intentionally cannot provide semantic validation, the package should export a clearly named strict/semantic validation surface and document that the generated schemas are not safe protocol admission validators. Ideally server request validation and public leaf-schema validation should share the same refinements so they cannot drift.

Adoption impact

We currently maintain a quarantined repo-owned copy of these validators while preparing 3.2 support. The SDK now exports the desired types and shapes, but replacing the local runtime boundary with these schemas would admit invalid requests before provider mutation. This is therefore a blocker to retiring that compatibility work.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions