Skip to content

feat(media-buy): add structured product frequency-cap constraints - #7438

Merged
bokelley merged 1 commit into
mainfrom
mesa-verde
Sep 13, 2026
Merged

bokelley merged 1 commit into
mainfrom
mesa-verde

Conversation

@bokelley

@bokelley bokelley commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes #7430. Adds a structured, independently positive product declaration for constrained or create-only package frequency-cap support, without changing the type or meaning of the legacy overlay_support.frequency_cap: true boolean.

This PR was re-scoped after review. The earlier revision bundled shared MediaBuy-level caps (#4240) and a further layer of precision (counter groups, step ranges, preset-plus-range intersection, a second mutability field). That roughly doubled the surface for no named integrator. This revision keeps the architecture (sibling field, not a union; exact constraints; location-based scope) and cuts the breadth:

  • Kept: frequency_cap_support with control modes, per units, exact count and per-unit interval constraints, create-only, constraint-aware discovery, rejection, read-back, package-qualified update_frequency_caps.
  • Cut: boolean mutable (only mutable_fields remains; [] means create-only), step, preset-plus-range intersection rules, counter groups.
  • Moved to the stacked follow-up feat(media-buy): add shared media-buy frequency cap #7449: root frequency_cap, media_buy_support, aggregate_frequency_capping, update_media_buy_frequency_cap, proposal-refinement removal.

What changes

Surface Change
Product.overlay_support.frequency_cap_support New structured declaration. Each count or duration constraint is either an exhaustive preset list or an inclusive range, never both. Omitted fields inherit seller-wide media_buy.frequency_capping.
required_overlay_support.frequency_cap_support Buyer minimums with subset containment. Window and suppression unit requirements match the resolved unit list (product list, else seller-wide supported_window_units). Legacy frequency_cap: true satisfies every requirement.
available_actions[].applicable_package_ids Names which packages currently accept a package-scoped action such as update_frequency_caps.
Compliance New frequency_cap_capability_updates scenario: inherited-unit discovery, create-only rejection, mutable update, read-back of two independent package caps.
Docs Spec section opens with a three-row "which field do I use" table.

Review follow-ups already applied

  • Rebased onto current main; the two measured MCP schema-count tests were re-pinned on top of main's values.
  • The two new constraint schemas use an undiscriminated preset-or-range oneOf; they are accepted into scripts/oneof-discriminators.baseline.json (diff limited to those two entries).
  • Compliance step reject_create_only_update now changes the count to a value the create-only product accepts, so immutability is the only violation under test.
  • The spec states what an omitted mutable_fields matches and that omitted window or suppression constraints inherit seller-wide units with no interval restriction; the "which field" table gained a buyer row for keeping a cap editable.
  • Security review: frequency_cap: true and frequency_cap_support are now mutually exclusive in both the support and requirement schemas (not: required both), which removes the "legacy wins if both appear" precedence rule and makes structured constraints always binding. The compliance scenario gained a negative step (reject_out_of_range_update, count outside allowed_values must return UNSUPPORTED_FEATURE), and applicable_package_ids has a verifier constraint that each id belongs to this buy.
  • Buyer/seller workflow review: the get_products requirement text now tells buyers to send frequency_cap_support alone; the spec says legacy true implies update support and how a create-only seller migrates, that a change to a field outside mutable_fields returns UNSUPPORTED_FEATURE, that product values outside the seller-wide declaration are invalid, that a weekly window is seven days, and that a non-empty mutable_fields should be paired with update_frequency_caps in allowed_actions.

Testing

  • tests/targeting-aware-discovery.test.cjs 23/23 and npm run test:oneof-discriminators clean, including new vectors for mutable_fields: [], preset/range mutual exclusion, no step, and the unit-inheritance rule text.
  • node tests/schema-validation.test.cjs 35/35; JSON schema block validation; enum drift, identity coherence, deprecation metadata.
  • npm run test:mcp-schema-projection 29/29 with re-measured graph counts.
  • npm run build:compliance clean; storyboard lint suite 229/229.
  • Server schema parity test 4/4.
  • Non-server precommit checks (unit 1059/1059, dynamic imports, format identity boundaries, callapi state change, typecheck) pass. The husky server-unit step fails locally in Addie router, billing admin, and session-cache tests that are unrelated to this diff and appear environmental.
  • TypeScript SDK generation from the PR bundle: see CI.

Risks and follow-ups

🤖 Generated with Claude Code

@aao-secretariat aao-secretariat Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ladon verdict: Escalate to human review

Escalate — gated schema-source paths require human/CODEOWNERS approval.

This PR modifies and adds files under static/schemas/source/**, which are under a hard, deterministic approval gate (gated_paths: true). The current review_decision is REVIEW_REQUIRED, not APPROVED, so per decision-table row 2 the outcome must be escalate — the gate is not satisfied by an automated review.

The reviewer found no Critical/High/Medium issues: the change is a clean additive Normative change adding scoped frequency-cap support (package vs. shared MediaBuy-root caps) on the 3.2 main line, with a correct minor changeset, verified schema↔docs coherence, backward-compatible legacy overlay_support.frequency_cap boolean, well-formed nullable/not constructs (no new undiscriminated oneOf), and no dist/** edits. Diff quality is not the blocker — the gate is.

Escalation reasons

  • Touches gated protocol-source files under static/schemas/source/** (e.g. core/media-buy.json, core/product.json, new core/frequency-cap-*.json) while review_decision is REVIEW_REQUIRED. Human/CODEOWNERS approval is required before merge.

No blocking findings from the reviewer; the escalation is purely the unsatisfied approval gate. Once a human/CODEOWNERS approval lands (review_decision: APPROVED), this clean diff can fall through to approval.

Why human review

  • Gated paths: PR modifies/adds files under static/schemas/source/** while review_decision is REVIEW_REQUIRED (not APPROVED) — human/CODEOWNERS review required before merge.
  • This PR touches a path under a hard, non-overridable approval gate (static/schemas/source/core/canonical-media-buy-action-fields.json (modified) matches static/schemas/source/**; static/schemas/source/core/canonical-media-buy-action.json (modified) matches static/schemas/source/**; static/schemas/source/core/canonical-product.json (modified) matches static/schemas/source/**; static/schemas/source/core/frequency-cap-constraints.json (added) matches static/schemas/source/**; static/schemas/source/core/frequency-cap-requirements.json (added) matches static/schemas/source/**; static/schemas/source/core/frequency-cap.json (modified) matches static/schemas/source/**; static/schemas/source/core/media-buy-available-action.json (modified) matches static/schemas/source/**; static/schemas/source/core/media-buy-frequency-cap.json (added) matches static/schemas/source/**; static/schemas/source/core/media-buy-support-requirements.json (added) matches static/schemas/source/**; static/schemas/source/core/media-buy-support.json (added) matches static/schemas/source/**; static/schemas/source/core/media-buy.json (modified) matches static/schemas/source/**; static/schemas/source/core/package.json (modified) matches static/schemas/source/**; static/schemas/source/core/product-identity.json (modified) matches static/schemas/source/**; static/schemas/source/core/product.json (modified) matches static/schemas/source/**; static/schemas/source/core/proposal.json (modified) matches static/schemas/source/**; static/schemas/source/core/targeting-overlay-requirements.json (modified) matches static/schemas/source/**; static/schemas/source/core/targeting-overlay-support.json (modified) matches static/schemas/source/**; static/schemas/source/enums/canonical-media-buy-action.json (modified) matches static/schemas/source/**; static/schemas/source/enums/media-buy-valid-action.json (modified) matches static/schemas/source/**; static/schemas/source/media-buy/buy-products-request.json (modified) matches static/schemas/source/**; static/schemas/source/media-buy/commercial-terms.json (modified) matches static/schemas/source/**; static/schemas/source/media-buy/control-media-buy-request.json (modified) matches static/schemas/source/**; static/schemas/source/media-buy/create-media-buy-request.json (modified) matches static/schemas/source/**; s

…(truncated)…

@aao-secretariat aao-secretariat Bot added the ladon/needs-human-review Ladon has escalated this PR for human review. label Sep 13, 2026

@aao-secretariat aao-secretariat Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ladon verdict: Escalate to human review

Escalate — gated schema paths require human/CODEOWNERS approval.

This PR modifies and adds numerous files under static/schemas/source/**, which is a hard, non-overridable approval gate (gated_paths: true). The current GitHub review decision is REVIEW_REQUIRED, not APPROVED, so decision-table row 2 fires: Ladon cannot auto-approve until a human/CODEOWNERS approval is recorded, regardless of how clean the diff is.

The reviewer's clean-delta pass found no critical/high/medium findings — the incremental change adds annotation-only title fields to array items subschemas across eight schema files, with no wire-shape, enum, const, required, or validation impact. This is a net-positive iteration on top of the prior escalated review. However, the escalation persists purely because of the unsatisfied gated-paths approval gate, not because of any code concern.

Escalation reasons

  • PR modifies/adds files under static/schemas/source/** while review_decision is REVIEW_REQUIRED (not APPROVED) — human/CODEOWNERS review required before merge. Affected files include the frequency-cap additions (frequency-cap-constraints.json, frequency-cap-requirements.json, media-buy-frequency-cap.json, media-buy-support*.json) and modifications across core/media-buy/enums/protocol schemas.

Once a human/CODEOWNERS approval is recorded, this PR would fall through to a normal approve on the current findings.

Why human review

  • Gated paths: PR modifies/adds files under static/schemas/source/** while review_decision is REVIEW_REQUIRED (not APPROVED) — human/CODEOWNERS approval required before merge.
  • This PR touches a path under a hard, non-overridable approval gate (static/schemas/source/core/canonical-media-buy-action-fields.json (modified) matches static/schemas/source/**; static/schemas/source/core/canonical-media-buy-action.json (modified) matches static/schemas/source/**; static/schemas/source/core/canonical-product.json (modified) matches static/schemas/source/**; static/schemas/source/core/frequency-cap-constraints.json (added) matches static/schemas/source/**; static/schemas/source/core/frequency-cap-requirements.json (added) matches static/schemas/source/**; static/schemas/source/core/frequency-cap.json (modified) matches static/schemas/source/**; static/schemas/source/core/media-buy-available-action.json (modified) matches static/schemas/source/**; static/schemas/source/core/media-buy-frequency-cap.json (added) matches static/schemas/source/**; static/schemas/source/core/media-buy-support-requirements.json (added) matches static/schemas/source/**; static/schemas/source/core/media-buy-support.json (added) matches static/schemas/source/**; static/schemas/source/core/media-buy.json (modified) matches static/schemas/source/**; static/schemas/source/core/package.json (modified) matches static/schemas/source/**; static/schemas/source/core/product-identity.json (modified) matches static/schemas/source/**; static/schemas/source/core/product.json (modified) matches static/schemas/source/**; static/schemas/source/core/proposal.json (modified) matches static/schemas/source/**; static/schemas/source/core/targeting-overlay-requirements.json (modified) matches static/schemas/source/**; static/schemas/source/core/targeting-overlay-support.json (modified) matches static/schemas/source/**; static/schemas/source/enums/canonical-media-buy-action.json (modified) matches static/schemas/source/**; static/schemas/source/enums/media-buy-valid-action.json (modified) matches static/schemas/source/**; static/schemas/source/media-buy/buy-products-request.json (modified) matches static/schemas/source/**; static/schemas/source/media-buy/commercial-terms.json (modified) matches static/schemas/source/**; static/schemas/source/media-buy/control-media-buy-request.json (modified) matches static/schemas/source/**; sta

…(truncated)…

@aao-secretariat aao-secretariat Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ladon verdict: Escalate to human review

Escalate — gated schema paths require human/CODEOWNERS approval.

This PR modifies and adds files under static/schemas/source/**, which is a hard, non-overridable approval gate (gated_paths: true). The current GitHub review_decision is REVIEW_REQUIRED, not APPROVED, so decision-table row 2 fires and the outcome must be escalate — Ladon cannot auto-approve regardless of how clean the diff is.

The reviewer's delta pass is clean: the changes since the prior review are a wire-preserving DRY refactor of the 3.2 frequency-cap schemas (inline enums/strings extracted into shared $ref components, two new allOf wrappers reproducing prior control-mode const and suppression-unit restrictions exactly). Verified identical enum sets, no oneOf introduced, no required/type flips, no schema↔docs drift, and test byte/definition-count assertions updated to match. No critical/high/medium findings.

Because there are no blocking findings, this is not request-changes — it is a pure gate escalation pending human/CODEOWNERS approval. The prior decision was also escalate for the same gated-paths reason. Once review_decision becomes APPROVED, this clean diff falls through to an approve.

Escalation reasons

  • PR modifies/adds files under static/schemas/source/** (hard approval gate) while review_decision is REVIEW_REQUIRED, not APPROVED. Human/CODEOWNERS approval required before merge. Gated files include canonical-product.json, media-buy.json, product.json, proposal.json, the new frequency-cap core/enum schemas, and the media-buy request/response schemas.

Why human review

  • Gated paths: PR modifies/adds files under static/schemas/source/** while review_decision is REVIEW_REQUIRED (not APPROVED) — human/CODEOWNERS approval required before merge.
  • Protocol schema surface change (static/schemas/source/**) is subject to a hard, non-overridable approval gate that only lifts on a recorded human/CODEOWNERS APPROVED review.
  • This PR touches a path under a hard, non-overridable approval gate (static/schemas/source/core/applicable-package-id.json (added) matches static/schemas/source/**; static/schemas/source/core/canonical-media-buy-action-fields.json (modified) matches static/schemas/source/**; static/schemas/source/core/canonical-media-buy-action.json (modified) matches static/schemas/source/**; static/schemas/source/core/canonical-product.json (modified) matches static/schemas/source/**; static/schemas/source/core/frequency-cap-constraints.json (added) matches static/schemas/source/**; static/schemas/source/core/frequency-cap-requirements.json (added) matches static/schemas/source/**; static/schemas/source/core/frequency-cap.json (modified) matches static/schemas/source/**; static/schemas/source/core/media-buy-available-action.json (modified) matches static/schemas/source/**; static/schemas/source/core/media-buy-frequency-cap-requirement.json (added) matches static/schemas/source/**; static/schemas/source/core/media-buy-frequency-cap-support.json (added) matches static/schemas/source/**; static/schemas/source/core/media-buy-frequency-cap.json (added) matches static/schemas/source/**; static/schemas/source/core/media-buy-support-requirements.json (added) matches static/schemas/source/**; static/schemas/source/core/media-buy-support.json (added) matches static/schemas/source/**; static/schemas/source/core/media-buy.json (modified) matches static/schemas/source/**; static/schemas/source/core/package.json (modified) matches static/schemas/source/**; static/schemas/source/core/product-identity.json (modified) matches static/schemas/source/**; static/schemas/source/core/product.json (modified) matches static/schemas/source/**; static/schemas/source/core/proposal.json (modified) matches static/schemas/source/**; static/schemas/source/core/targeting-overlay-requirements.json (modified) matches `static/schemas/source

…(truncated)…

@aao-secretariat aao-secretariat Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ladon verdict: Request changes

Request changes — 1 blocking finding.

Blocking findings

  • static/schemas/source/core/error-details/action-not-allowed.json — attempted_action still $refs the flat media-buy-valid-action enum after update_media_buy_frequency_cap was relocated into the new structured media-buy-available-action-id anyOf union. The required attempted_action field can no longer represent update_media_buy_frequency_cap, breaking the documented root-cap ACTION_NOT_ALLOWED payload (schema↔docs / wire-shape drift, high). Fix: repoint it at media-buy-available-action-id.json.

This is a high-severity finding on a load-bearing protocol wire shape, so decision-table row 1 fires (request-changes) ahead of the gated-paths escalation. Reviewer verified oneOf/anyOf audit (anyOf not walked; scalar union — clean), valid_actions/available_actions split, const→enum control-mode change, schema↔docs coherence elsewhere, and changeset scope (minor, unreleased beta line — appropriate). Note: this PR also touches gated paths under static/schemas/source/** with review_decision: REVIEW_REQUIRED, so human/CODEOWNERS approval remains required before merge regardless of the fix.

Blocking findings

  • static/schemas/source/core/error-details/action-not-allowed.json — required attempted_action still $refs flat media-buy-valid-action enum, can no longer represent update_media_buy_frequency_cap; breaks documented root-cap ACTION_NOT_ALLOWED payload (spec drift, high). Repoint at media-buy-available-action-id.json.

@aao-secretariat
aao-secretariat Bot dismissed their stale review September 13, 2026 03:06

Superseded by a later Ladon review that rechecked and resolved its blocking findings.

@aao-secretariat aao-secretariat Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ladon verdict: Request changes

Request changes — 1 blocking finding.

Blocking findings

  • static/schemas/source/core/action-not-allowed.json — The required attempted_action field still $refs the flat media-buy-valid-action enum, which cannot represent the PR's new root-cap action update_media_buy_frequency_cap. This makes the documented root-cap ACTION_NOT_ALLOWED payload unrepresentable — schema↔spec drift on a load-bearing error path (high).

Notes

  • The delta this pass (relocating frequency-cap-duration-unit.json from enums/ to core/) is clean: $id and all four $ref sites were updated in step, no dangling references or index gap. Nice iteration.
  • The prior high blocker remains unresolved and applies to the full PR, so the request-changes verdict stands.

Note: This PR also touches gated paths (static/schemas/source/**) with review_decision not APPROVED, and introduces new fields/enum values on the published protocol surface — a breaking/normative-class change that requires human/CODEOWNERS ratification before merge regardless of the schema fix above.

Blocking findings

  • static/schemas/source/core/action-not-allowed.json — required attempted_action $refs the flat media-buy-valid-action enum, cannot represent new root-cap action update_media_buy_frequency_cap, making documented ACTION_NOT_ALLOWED payload unrepresentable (high, spec drift)

@aao-secretariat
aao-secretariat Bot dismissed their stale review September 13, 2026 03:34

Superseded by a later Ladon review that rechecked and resolved its blocking findings.

@aao-secretariat aao-secretariat Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ladon verdict: Escalate to human review

Escalate — gated paths touched without an approving review.

This PR modifies/adds 40+ files under static/schemas/source/**, which is a deterministic hard approval gate (gated_paths: true). review_decision is unknown/none — not APPROVED — so per decision-table row 2 the gate is not satisfied and the outcome must be escalate.

Reviewer findings: Clean pass. The prior high blocker (error-details/action-not-allowed.json's attempted_action now $refs core/media-buy-available-action-id.json, making the root-cap ACTION_NOT_ALLOWED payload representable) is resolved. Both description sites reworded in step and a schema test locks the $ref. No new critical/high/medium findings. This is a net improvement over the prior request-changes.

Despite the clean diff, human/CODEOWNERS review is required because the schema source-of-truth files are under a hard approval gate. This is a frequency-cap capability addition (new fields, new enums, new error handling on the published protocol surface) — a substantive wire-shape change that a human must ratify before merge.

Escalation reason: Gated files under static/schemas/source/** were changed and review_decision is not APPROVED. A human/CODEOWNERS approval is required to lift the gate.

Why human review

  • Gated paths hard gate: PR changes 40+ files under static/schemas/source/** (protocol source of truth) and review_decision is not APPROVED. Human/CODEOWNERS review is required to lift the gate.
  • Substantive protocol surface change (frequency-cap capability: new fields, new enums, new error code / action-not-allowed handling) — ratification of the wire-shape change is a human act.
  • This PR touches a path under a hard, non-overridable approval gate (static/schemas/source/core/applicable-package-id.json (added) matches static/schemas/source/**; static/schemas/source/core/canonical-media-buy-action-fields.json (modified) matches static/schemas/source/**; static/schemas/source/core/canonical-media-buy-action.json (modified) matches static/schemas/source/**; static/schemas/source/core/canonical-product.json (modified) matches static/schemas/source/**; static/schemas/source/core/frequency-cap-constraints.json (added) matches static/schemas/source/**; static/schemas/source/core/frequency-cap-duration-unit.json (added) matches static/schemas/source/**; static/schemas/source/core/frequency-cap-requirements.json (added) matches static/schemas/source/**; static/schemas/source/core/frequency-cap.json (modified) matches static/schemas/source/**; static/schemas/source/core/media-buy-available-action-id.json (added) matches static/schemas/source/**; static/schemas/source/core/media-buy-available-action.json (modified) matches static/schemas/source/**; static/schemas/source/core/media-buy-frequency-cap-requirement.json (added) matches static/schemas/source/**; static/schemas/source/core/media-buy-frequency-cap-support.json (added) matches static/schemas/source/**; static/schemas/source/core/media-buy-frequency-cap.json (added) matches static/schemas/source/**; static/schemas/source/core/media-buy-support-requirements.json (added) matches static/schemas/source/**; static/schemas/source/core/media-buy-support.json (added) matches static/schemas/source/**; static/schemas/source/core/media-buy.json (modified) matches static/schemas/source/**; static/schemas/source/core/package.json (modified) matches static/schemas/source/**; static/schemas/source/core/product-identity.json (modified) matches static/schemas/source/**; static/schemas/source/core/product.json (modified) matches static/schemas/source/**; static/schemas/source/core/proposal.json (modified) matches static/schemas/source/**; static/schemas/source/core/targeting-overlay-requirements.json (modified) matches static/schemas/source/**; static/schemas/source/core/targeting-overlay-support.json (modified) matches `static/

…(truncated)…

@aao-secretariat aao-secretariat Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ladon verdict: Escalate to human review

Escalate — gated protocol source-of-truth change requires human/CODEOWNERS approval.

This PR touches 40+ files under static/schemas/source/**, which is under a hard, deterministic approval gate (gated_paths: true), and the current review_decision is not APPROVED (unknown/none). Per decision rule row 2, the outcome must be escalate until a human/CODEOWNERS approval is recorded.

Separately, this is a substantive protocol surface change (frequency-cap capability: new fields, new enums, new error code / action-not-allowed handling). Ratification of the wire-shape change is a human act per the repo's breaking-class hard gate.

The reviewer's clean delta pass found no Critical/High/Medium findings — schema↔docs coherence, changeset presence (.changeset/add-scoped-frequency-cap-support.md), allOf + additionalProperties:false composition, and the compliance scenarios were all verified. The diff is mechanically clean, but a clean diff cannot lift a deterministic path gate; only review_decision: APPROVED can.

Escalation reasons

  • Gated paths hard gate: 40+ files under static/schemas/source/** (protocol source of truth) changed and review_decision is not APPROVED. Human/CODEOWNERS review required to lift the gate.
  • Substantive protocol surface change (frequency-cap capability additions) — ratification is a human act.

Note on iteration: prior decision was also escalate; the developer has pushed a new head. The prior run had no actionable findings and this run also has none — the escalation persists solely because the gated-paths gate remains unsatisfied, not because of any new defect.

Why human review

  • Gated paths hard gate: PR changes 40+ files under static/schemas/source/** (protocol source of truth) and review_decision is not APPROVED — human/CODEOWNERS review required to lift the gate.
  • Substantive protocol surface change (frequency-cap capability: new fields, new enums, new error code / action-not-allowed handling) — ratification of the wire-shape change is a human act per the breaking-class hard gate.
  • This PR touches a path under a hard, non-overridable approval gate (static/schemas/source/core/applicable-package-id.json (added) matches static/schemas/source/**; static/schemas/source/core/canonical-media-buy-action-fields.json (modified) matches static/schemas/source/**; static/schemas/source/core/canonical-media-buy-action.json (modified) matches static/schemas/source/**; static/schemas/source/core/canonical-product.json (modified) matches static/schemas/source/**; static/schemas/source/core/frequency-cap-constraints.json (added) matches static/schemas/source/**; static/schemas/source/core/frequency-cap-duration-unit.json (added) matches static/schemas/source/**; static/schemas/source/core/frequency-cap-impression-constraints.json (added) matches static/schemas/source/**; static/schemas/source/core/frequency-cap-interval-constraints.json (added) matches static/schemas/source/**; static/schemas/source/core/frequency-cap-requirements.json (added) matches static/schemas/source/**; static/schemas/source/core/frequency-cap.json (modified) matches static/schemas/source/**; static/schemas/source/core/media-buy-available-action-id.json (added) matches static/schemas/source/**; static/schemas/source/core/media-buy-available-action.json (modified) matches static/schemas/source/**; static/schemas/source/core/media-buy-frequency-cap-capability.json (added) matches static/schemas/source/**; static/schemas/source/core/media-buy-frequency-cap-counter-group.json (added) matches static/schemas/source/**; static/schemas/source/core/media-buy-frequency-cap-requirement.json (added) matches static/schemas/source/**; static/schemas/source/core/media-buy-frequency-cap-support.json (added) matches static/schemas/source/**; static/schemas/source/core/media-buy-frequency-cap.json (added) matches `static/schemas/source/*

…(truncated)…

@bokelley bokelley changed the title feat(media-buy): add scoped frequency cap support feat(media-buy): add structured product frequency-cap constraints Sep 13, 2026
@aao-secretariat

Copy link
Copy Markdown
Contributor

Ladon cannot review this PR until merge conflicts are resolved.

@aao-secretariat aao-secretariat Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ladon verdict: Escalate to human review

Escalate — gated protocol-surface change requires human/CODEOWNERS approval.

This PR makes an additive Normative change to the protocol source of truth: structured product frequency-cap constraints (frequency_cap_support), constraint-aware discovery, and package-qualified update_frequency_caps via applicable_package_ids, leaving legacy frequency_cap: true untouched. The reviewer's pass is clean — schema↔docs coherence verified across specification/get_products/get_media_buys/get_adcp_capabilities, correct minor changeset for the additive surface, disjoint-and-baselined new oneOf schemas, identity-absence parity, and correct per-package counter modeling in the new compliance scenario. No Critical/High/Medium findings.

However, the decision table stops before row 9: this PR touches many files under static/schemas/source/**, which is a hard, non-overridable approval gate (gated_paths: true), and review_decision is not APPROVED. Row 2 fires → escalate. Ratification of a wire-shape change on the protocol source of truth is a human act; Ladon cannot auto-approve until a human/CODEOWNERS approval is recorded, regardless of how clean the diff is. This is consistent with the prior escalate decision — no blocking findings have been introduced, and the gate simply awaits human sign-off.

Escalation reasons

  • Gated paths hard gate: PR modifies/adds ~18 files under static/schemas/source/** (protocol source of truth) and review_decision is not APPROVED — human/CODEOWNERS review required to lift the gate.
  • Protocol-surface change (frequency-cap capability: new fields, new enums) — ratification of the wire-shape change is a human act.

Why human review

  • Gated paths hard gate: PR modifies/adds ~18 files under static/schemas/source/** (protocol source of truth incl. applicable-package-id.json, canonical-product.json, product.json, frequency-cap-*.json, get-adcp-capabilities-response.json) and review_decision is not APPROVED — human/CODEOWNERS review required to lift the gate.
  • Substantive protocol-surface change (frequency-cap capability: new fields, new enums, package-qualified update semantics) — ratification of the wire-shape change is a human act, not an auto-approvable event.
  • This PR touches a path under a hard, non-overridable approval gate (static/schemas/source/core/applicable-package-id.json (added) matches static/schemas/source/**; static/schemas/source/core/canonical-media-buy-action-fields.json (modified) matches static/schemas/source/**; static/schemas/source/core/canonical-product.json (modified) matches static/schemas/source/**; static/schemas/source/core/frequency-cap-constraints.json (added) matches static/schemas/source/**; static/schemas/source/core/frequency-cap-duration-unit.json (added) matches static/schemas/source/**; static/schemas/source/core/frequency-cap-impression-constraints.json (added) matches static/schemas/source/**; static/schemas/source/core/frequency-cap-interval-constraints.json (added) matches static/schemas/source/**; static/schemas/source/core/frequency-cap-requirements.json (added) matches static/schemas/source/**; static/schemas/source/core/media-buy-available-action.json (modified) matches static/schemas/source/**; static/schemas/source/core/package.json (modified) matches static/schemas/source/**; static/schemas/source/core/product-identity.json (modified) matches static/schemas/source/**; static/schemas/source/core/product.json (modified) matches static/schemas/source/**; static/schemas/source/core/targeting-overlay-requirements.json (modified) matches static/schemas/source/**; static/schemas/source/core/targeting-overlay-support.json (modified) matches static/schemas/source/**; static/schemas/source/enums/frequency-cap-control-mode.json (added) matches static/schemas/source/**; static/schemas/source/enums/frequency-cap-mutable-field.json (added) matches `static/schemas/so

…(truncated)…

@bokelley

Copy link
Copy Markdown
Contributor Author

Issue #7478 proposes consolidating the duration-unit enum — same surface as this PR (core/frequency-cap-duration-unit.json is introduced here). Consider folding two small additions before merge rather than a follow-up PR re-touching the same schemas:

  1. Add $ref from core/duration.json's unit to core/frequency-cap-duration-unit.json (non-breaking — same enum members).
  2. Add a schema-equality assertion test for get-adcp-capabilities-response.json's supported_window_units against the shared enum (rather than a hard $ref, since constraining an untyped string[] is a narrowing change and the weeks/months completeness question needs a decision first).

If scope expansion would delay review, a Blocked-on: #7438 follow-up is also fine.


Generated by Claude Code

@bokelley

Copy link
Copy Markdown
Contributor Author

Follow-up (Blocked-on: #7438) preferred for both items:

  1. Enum reference direction: core/duration.json serves a broader purpose (attribution windows, reach optimization, time budgets); making it $ref the frequency-cap-specific enum inverts the abstraction hierarchy. Issue chore: clean up local pre-commit/pre-push failures and stale test artifacts found while landing frequency-cap PRs #7478 item 4 should settle the canonical direction — most likely frequency-cap-duration-unit.json → $ref → duration.json's unit, or a neutral core/duration-unit.json that both files reference.

  2. supported_window_units assertion: Agreed on test-over-$ref. Resolving the weeks/months question first means the assertion won't need immediate revision.

The merge conflict (per Ladon's note above) is the more urgent step here. Adding Blocked-on: #7438 to Issue #7478 item 4 so it resurfaces on merge.


Generated by Claude Code

@aao-secretariat aao-secretariat Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ladon verdict: Escalate to human review

Escalate — gated protocol-source change requires human/CODEOWNERS review.

This PR adds a product frequency-cap capability to the AdCP protocol surface: new overlay_support.frequency_cap_support, package-qualified update_frequency_caps availability via applicable_package_ids, new duration/reach-unit/control-mode/mutable-field enums, and constraint-aware discovery schemas. The reviewer's pass is clean — schema↔docs coherence holds across all seven touched docs, the minor changeset is correct for additive optional fields, the two new oneOf constraint schemas are disjoint and correctly baselined, and the compliance scenario ordering (ACTION_NOT_ALLOWED vs UNSUPPORTED_FEATURE) plus per-package counter readback were verified. No Critical/High/Medium findings.

However, this PR modifies/adds ~18 files under static/schemas/source/** — the protocol source of truth, which is under a hard, deterministic approval gate (gated_paths: true). review_decision is REVIEW_REQUIRED, not APPROVED. Per decision-table row 2, the gate is not satisfied and I cannot auto-approve regardless of how clean the diff is. Ratification of a wire-shape change to the published protocol surface is a human act. This matches the prior escalate decision.

Escalation reasons

  • Gated paths hard gate: ~18 files under static/schemas/source/** (incl. applicable-package-id.json, canonical-product.json, product.json, frequency-cap-*.json, get-adcp-capabilities-response.json, and new enums) added/modified with review_decision: REVIEW_REQUIRED. Human/CODEOWNERS approval required to lift the gate.
  • Substantive additive protocol-surface change (new frequency-cap capability, new fields/enums, package-qualified update semantics) — human ratification of the wire-shape change is required even though the diff is mechanically clean.

Why human review

  • Gated paths hard gate: PR adds/modifies ~18 files under static/schemas/source/** (protocol source of truth, incl. applicable-package-id.json, canonical-product.json, product.json, frequency-cap-*.json, get-adcp-capabilities-response.json, new enums) and review_decision is REVIEW_REQUIRED, not APPROVED — human/CODEOWNERS review required to lift the gate.
  • Substantive additive protocol-surface change (frequency-cap capability: new fields, new enums, package-qualified update semantics) — ratification of the wire-shape change is a human act, not auto-approvable.
  • This PR touches a path under a hard, non-overridable approval gate (static/schemas/source/core/applicable-package-id.json (added) matches static/schemas/source/**; static/schemas/source/core/canonical-media-buy-action-fields.json (modified) matches static/schemas/source/**; static/schemas/source/core/canonical-product.json (modified) matches static/schemas/source/**; static/schemas/source/core/frequency-cap-constraints.json (added) matches static/schemas/source/**; static/schemas/source/core/frequency-cap-duration-unit.json (added) matches static/schemas/source/**; static/schemas/source/core/frequency-cap-impression-constraints.json (added) matches static/schemas/source/**; static/schemas/source/core/frequency-cap-interval-constraints.json (added) matches static/schemas/source/**; static/schemas/source/core/frequency-cap-requirements.json (added) matches static/schemas/source/**; static/schemas/source/core/media-buy-available-action.json (modified) matches static/schemas/source/**; static/schemas/source/core/package.json (modified) matches static/schemas/source/**; static/schemas/source/core/product-identity.json (modified) matches static/schemas/source/**; static/schemas/source/core/product.json (modified) matches static/schemas/source/**; static/schemas/source/core/targeting-overlay-requirements.json (modified) matches static/schemas/source/**; static/schemas/source/core/targeting-overlay-support.json (modified) matches `

…(truncated)…

Closes #7430. Adds `Product.overlay_support.frequency_cap_support`, a
structured, independently positive declaration for products whose package
frequency-cap support is constrained or create-only, without changing the
type or meaning of the legacy `frequency_cap: true` boolean.

- Constraints are exact: each count or duration constraint is either an
  exhaustive preset list or an inclusive range, never both.
- `mutable_fields` is the single mutability representation; `[]` means
  create-only and omission leaves update support undeclared.
- Product fields omitted from `frequency_cap_support` inherit the seller-wide
  `media_buy.frequency_capping` declaration; requested window and suppression
  units match against the resolved unit list.
- `required_overlay_support.frequency_cap_support` makes discovery
  constraint-aware; legacy `frequency_cap: true` satisfies every requirement.
- `available_actions[]` may carry `applicable_package_ids` so heterogeneous
  buys can name which packages accept `update_frequency_caps`.
- Adds the `frequency_cap_capability_updates` compliance scenario covering
  inherited-unit discovery, create-only rejection, mutable update, and
  read-back of independent package caps.

Shared MediaBuy-level caps (#4240) are deliberately left to a follow-up PR.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

@aao-secretariat aao-secretariat Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ladon verdict: Escalate to human review

Escalate — gated-path approval gate not satisfied.

This PR adds/modifies ~18 files under static/schemas/source/** (the protocol source of truth) — new frequency-cap capability (new fields, new enums, package-qualified update semantics) plus applicable-package-id.json, canonical-product.json, product.json, get-adcp-capabilities-response.json and related core/enum schemas. This is a substantive additive Normative-class protocol-surface change.

The reviewer's pass is clean: additivity verified, correct minor changeset, duration-unit enum coherence, mutual-exclusion/identity guards, disjoint new oneOf schemas registered in the baseline, and schema↔docs coherence across five doc pages. No critical/high/medium findings.

However, gated_paths: true and review_decision: REVIEW_REQUIRED (not APPROVED). Under decision-table row 2, the hard, non-overridable approval gate is not satisfied, so the outcome must be escalate regardless of how clean the diff is. Ratification of a wire-shape change is a human/CODEOWNERS act.

Escalation reasons

  • Gated paths: static/schemas/source/** protocol source-of-truth files added/modified with review_decision: REVIEW_REQUIRED — human/CODEOWNERS approval required to lift the gate.
  • Additive Normative protocol-surface change (frequency-cap capability) requires human ratification.

No blocking findings — this is a governance gate, not a code-correctness block. Once a human/CODEOWNERS approval is recorded, the gate lifts and this clean diff can approve.

Why human review

  • Gated paths hard gate: PR adds/modifies ~18 files under static/schemas/source/** (protocol source of truth, incl. applicable-package-id.json, canonical-product.json, product.json, frequency-cap-*.json, get-adcp-capabilities-response.json, new enums) and review_decision is REVIEW_REQUIRED, not APPROVED — human/CODEOWNERS review required to lift the gate.
  • Substantive additive Normative-class protocol-surface change (frequency-cap capability: new fields, new enums, package-qualified update semantics) — ratification of the wire-shape change is a human act, not auto-approvable.
  • This PR touches a path under a hard, non-overridable approval gate (static/schemas/source/core/applicable-package-id.json (added) matches static/schemas/source/**; static/schemas/source/core/canonical-media-buy-action-fields.json (modified) matches static/schemas/source/**; static/schemas/source/core/canonical-product.json (modified) matches static/schemas/source/**; static/schemas/source/core/frequency-cap-constraints.json (added) matches static/schemas/source/**; static/schemas/source/core/frequency-cap-duration-unit.json (added) matches static/schemas/source/**; static/schemas/source/core/frequency-cap-impression-constraints.json (added) matches static/schemas/source/**; static/schemas/source/core/frequency-cap-interval-constraints.json (added) matches static/schemas/source/**; static/schemas/source/core/frequency-cap-requirements.json (added) matches static/schemas/source/**; static/schemas/source/core/media-buy-available-action.json (modified) matches static/schemas/source/**; static/schemas/source/core/package.json (modified) matches static/schemas/source/**; static/schemas/source/core/product-identity.json (modified) matches static/schemas/source/**; static/schemas/source/core/product.json (modified) matches static/schemas/source/**; static/schemas/source/core/targeting-overlay-requirements.json (modified) matches static/schemas/source/**; static/schemas/source/core/targeting-overlay-support.json (modified) matches static/schemas/source/**; static/schemas/source/enums/frequency-cap-control-mode.json (added) matches static/schemas/source/**; static/schemas/source/enums/frequency-cap-mutable-field.json (added) matches static/schemas/source/**; static/schemas/source/enums/media-buy-valid-action.

…(truncated)…

@bokelley
bokelley merged commit d44756a into main Sep 13, 2026
59 checks passed
@bokelley
bokelley deleted the mesa-verde branch September 13, 2026 20:24
bokelley added a commit that referenced this pull request Sep 14, 2026
… caps (#7494)

* feat(training-agent): implement package and shared MediaBuy frequency caps

Closes #7488. The three frequency-cap compliance scenarios from #7438 and
#7449 were gated on capabilities the reference seller never advertised, so
they had never executed. The training agent now implements the spec section
"Frequency-cap scope and product support":

- Advertise media_buy.frequency_capping and the complete executable
  media_buy.aggregate_frequency_capping domain (sales tenant and legacy
  capabilities handler).
- Resolve product support with seller-wide inheritance for
  overlay_support.frequency_cap / frequency_cap_support and
  media_buy_support.frequency_cap (+ frequency_cap_constraints); default
  catalog products declare both legacy package support and shared-counter
  participation.
- Discovery honours required_overlay_support.frequency_cap_support,
  required_media_buy_support, and exact media_buy_frequency_cap; returned
  products carry media_buy_support regardless of fields; proposals echo the
  bound root cap.
- Create, buy, update, and control validate package caps against resolved
  product constraints and root caps against seller-wide plus every product,
  rejecting with UNSUPPORTED_FEATURE before any mutation and never clamping.
  Root caps replace or clear (null) without resetting counters; new_packages
  are checked against the resulting state; ineligible packages and
  non-mutable root caps return ACTION_NOT_ALLOWED before capability checks.
- available_actions carries update_frequency_caps with applicable_package_ids
  for heterogeneous buys and update_media_buy_frequency_cap when every active
  product can change the root cap.
- Proposal refinement clears an inherited root cap through
  remove_media_buy_frequency_cap, replaces it through
  criteria.media_buy_frequency_cap, and is unable when the revised mix cannot
  share it.
- Delivery totals report reach and frequency at or below the tightest
  enforced cap.
- Requests addressing a synced account by account_id reach the same media
  buy and fixture catalog as natural-form requests.

Compliance: add media_buy_frequency_cap_updates; give the multi-package
frequency-cap scenarios explicit bids after the first package (the runner
only injects a bid for the first) and use affected_package_ids[*] for
membership checks. Spec: state that a root-cap change without
update_media_buy_frequency_cap returns ACTION_NOT_ALLOWED ahead of the
capability check, and that mutable_fields governs changes to an existing cap.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* docs(media-buy): state frequency-cap check order explicitly for both cap levels

The package-cap paragraph never stated that available_actions authorization
runs before the capability check, so the root-cap sentence added earlier
referenced a rule the spec did not make. State the order once for package
caps (authorization, then capability, then accepted commercial terms) and
have the root-cap paragraph apply the same order.

Make the training agent honour that order for package caps on
control_media_buy as well: the cap gate now runs ahead of the accepted-
envelope REQUOTE_REQUIRED checks, so a cap that is both outside capability
and outside accepted terms reports UNSUPPORTED_FEATURE. Add unit coverage
for authorization-before-capability (out-of-range count on a create-only
package, mixed request) and capability-before-terms, and a
frequency_cap_capability_updates step that sends an out-of-range count to
the create-only package and expects ACTION_NOT_ALLOWED.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

---------

Co-authored-by: Claude Fable 5.1 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ladon/needs-human-review Ladon has escalated this PR for human review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RFC: product-scoped, constraint-aware frequency-cap capabilities

1 participant