Skip to content

feat(training-agent): creative library for the inventory tenants - #9116

Merged
bokelley merged 4 commits into
mainfrom
feat/inventory-creatives
Nov 20, 2026
Merged

bokelley merged 4 commits into
mainfrom
feat/inventory-creatives

Conversation

@bokelley

@bokelley bokelley commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Why

A storefront's certification run against /inventory-adserver gets past accounts, then stops at creative sync with MCP error -32602: Tool sync_creatives not found. Both inventory tenants claim sales-guaranteed, and inventory-adserver also claims sales-non-guaranteed. Both specialisms' storyboards call sync_creatives without a requires_tool gate. A storefront also has to traffic its creatives to the packages it buys. Until now, inline creatives on create_media_buy were silently ignored.

What

Both inventory tenants now keep a creative library per account, inside the caller's simulated market (inventory-sim/creatives.ts).

sync_creatives

  • Creatives are checked against the seed's formats.
  • assignment_operations supports assign, unassign and replace. A request's operations apply together or not at all.
  • The deprecated assignments field still works; each failed assignment is reported in that creative's assignment_errors.
  • Strict and lenient validation_mode, dry_run and delete_missing are supported.
  • Merges, assignment trackers, landing pages, installment_refs and placement routing are rejected with UNSUPPORTED_FEATURE rather than dropped.

list_creatives reads back assignments, and filters by creative, format, status, package, media buy or unassigned.

list_creative_formats returns the training creative catalogue, limited to the formats the seed serves.

create_media_buy / update_media_buy take a package's inline creatives and creative_assignments; on update they replace the package's assignments. A creative is only assigned to a package whose product serves its format; otherwise the request fails with FORMAT_NOT_SUPPORTED.

get_media_buys lists each package's creative_approvals.

get_adcp_capabilities declares creative.has_creative_library and the supported assignment operations.

pending_creatives. A buy reports pending_creatives while none of its live packages has a creative (AdCP's definition: no package can begin delivery for want of creative coverage), then pending_start or active as before. Packages without a creative carry no creative_approvals.

Every creative is approved as soon as it arrives, and delivery does not wait for one: the engine is untouched, so seeded delivery is unchanged. There is no "deliver only once a creative is assigned" gate.

Canonical format resolution

A storefront may name a creative's format only canonically, with format_kind and params and no format_id. This works on sync_creatives and on inline creatives:

  • Exact match. A format that declares the same params values wins.
  • Compatible match. Failing that, any format whose declared params don't contradict them. The unsized takeover image accepts any size.
  • No params. The size of the creative's first image or video asset is used instead.
  • Outcomes. One match is accepted. Several are refused with INVALID_REQUEST, naming them. None gives FORMAT_NOT_SUPPORTED.

format_option_ref with the product's format_option_id and a named format_id also resolve. params is not a field of core/creative-asset.json; it is accepted because that schema allows additional properties.

Design notes

  • Canonical identity. The library keys formats by canonical format_option_id, taken from the seed's product format declarations. The named-format wire (format_id, format_ids) is translated only in inventory-sim/creative-wire.ts, which is added to tests/lint-format-identity-boundaries.test.cjs.
  • Raw handlers. sync_creatives, list_creatives and list_creative_formats register as raw legacyHandlers.mediaBuy handlers. The SDK's sales.syncCreatives receives only the creatives, never the assignments or assignment_operations.
  • Format projection. The SDK canonicalizes inline creatives on create_media_buy before the platform sees them, and rejected formats missing from the sales catalogue (email_sponsored, audio_spot, creator_brief). The inventory tenants now pass creativeProjectionAdapters() their seed's format declarations. A canonical creative then resolves to the product's format, by format_option_ref or by a format_kind that only one of the product's formats has.
  • Size caps. Each account holds up to 200 creatives of up to 32 KiB each, which keeps the per-caller session document small. reset_state clears them with the market.

The docs page docs/building/verification/simulated-inventory-agents.mdx gains a Creatives section. No changeset: there is no protocol change.

Tests

The follow-up commit 16deb86a1f was made with --no-verify, approved by the maintainer. Its pre-commit hook failed twice on unrelated suites, creative33-buyer (20/20 when run alone) and Addie's exact-inference workers. CI is the gate.

training-agent-inventory-tenants: 22/22, including 9 new cases, plus status checks for pending_creatives and a lenient delete_missing regression. The ninth covers canonical resolution alone: 728x90 versus 300x250 on a ROS display product, size from the asset, the ambiguity refusal, and an inline 728x90 on create_media_buy.

  • tools/list and capabilities.
  • The format list, including a format the seed doesn't serve.
  • Sync with an assignment to a booked package, read back through list_creatives and get_media_buys.
  • All-or-nothing failure on an unknown package; format mismatch; merge rejected.
  • Replace, the deprecated assignments errors, and dry_run.
  • Strict versus lenient validation.
  • Inline creatives and replacement assignments on create and update.
  • A newsletter sponsorship read on the content tenant.

Also passing:

  • lint-format-identity-boundaries, the engine suite, the creative33 suites and the tenant smoke tests.
  • The type check.
  • The pre-commit hook, apart from two unrelated Addie statistics suites (exact-inference, matched-v4-evaluation) that fail under host load.

🤖 Generated with Claude Code

A storefront's certification run on /inventory-adserver stopped at
creative sync ("Tool sync_creatives not found"). Both inventory tenants
claim sales-guaranteed, whose storyboards call sync_creatives, and a
storefront has to traffic its creatives to the packages it buys.

Both tenants now keep a creative library per account in the caller's
market (inventory-sim/creatives.ts):

- sync_creatives: creatives checked against the seed's formats; the
  deprecated assignments (errors reported per package) and
  assignment_operations assign, unassign and replace (all or nothing);
  strict and lenient validation, dry_run and delete_missing. Merges,
  assignment trackers, landing pages, installment scoping and placement
  routing are rejected with UNSUPPORTED_FEATURE.
- list_creatives with assignment readback and the creative, format,
  status, package and media-buy filters.
- list_creative_formats limited to the formats the seed serves.
- create_media_buy and update_media_buy take a package's inline
  creatives and creative_assignments (update replaces). A creative is
  only assigned to a package whose product serves its format.
- get_media_buys lists each package's creative_approvals.

Every creative is approved on arrival and delivery does not wait for
one, so seeded delivery is unchanged.

The library keys formats by canonical format_option_id. The named-format
wire (format_id, format_ids) is translated only in
inventory-sim/creative-wire.ts, registered as a compatibility boundary.
sync_creatives registers as a raw media-buy handler because the SDK
passes sales.syncCreatives only the creatives, not the assignments. The
tenants' creative format projection includes the seed's own formats, so
canonical inline creatives on create_media_buy resolve to them. The docs
page now describes the library.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
aao-secretariat[bot]
aao-secretariat Bot previously approved these changes Nov 20, 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: Approve

Approve — server-side creative library additions to the inventory simulation tenants, no blocking findings.

What I checked:

  • No static/schemas/source/**, docs/reference/**, or dist/** changes — schema↔docs coherence, changeset scope, oneOf discriminator, and artifact-immutability governance rules do not apply.
  • Not based on 3.1.x; no transport/auth/signing changes.
  • Account isolation is sound (per-principal market doc with account_id filters); all-or-nothing semantics hold via the structuredClone-then-save pattern.
  • Building-guide docs are coherent with the implementation.
  • Well-tested: six new adserver cases plus a content-tenant inline case.

Gate checks: No no-auto-approve team match. gated_paths is false. high_risk is false. No prior decision. Only one medium finding (not data-loss/schema/infra category), so no escalation trigger fires and the count is below the row-8 threshold of three.

Medium findings (non-blocking):

  • server/src/training-agent/inventory-sim/creatives.ts:226 — delete_missing in lenient mode deletes a resent creative that failed validation.

Single medium finding, no blocking issues → row 9 approve.

Medium findings

  • server/src/training-agent/inventory-sim/creatives.ts:226 — delete_missing in lenient mode deletes a resent creative that failed validation

…arams

A storefront names creative formats canonically: a URL-free format_kind
with params (for example image at 728x90), never a format_id. The ROS
display products serve both a 728x90 and a 300x250 image, so format_kind
alone was ambiguous there and creatives on sync_creatives could not
resolve at all.

Match format_kind with params against the product's format_options, or,
without params, with the size of the creative's first image or video
asset. A format that declares the same values wins; failing that, one
whose declared params do not contradict them (the unsized takeover image
takes any size). One match is accepted, several are refused naming them,
none is FORMAT_NOT_SUPPORTED. This applies to sync_creatives and to
inline creatives on create_media_buy and update_media_buy. The docs page
says so, and links the creative tasks and error codes.

Committed with --no-verify (maintainer-approved): the hook failed twice on
unrelated suites (creative33-buyer, exact-inference) that pass alone.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
aao-secretariat[bot]
aao-secretariat Bot previously approved these changes Nov 20, 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: Approve

Approve — subsequent pass over a 3-file delta (how-to mdx, creative-wire.ts format resolution, and its test) with no blocking or medium findings.

What I checked:

  • The new format_kind + params/sizeHints resolution in creative-wire.ts is sound and fails closed: ambiguity resolves to an INVALID_REQUEST naming candidates rather than a wrong assignment.
  • Doc prose in simulated-inventory-agents.mdx matches resolveCreativeFormat branch-for-branch.
  • No changes to static/schemas/source/, normative docs/reference/, or other published protocol surface, so no changeset is required (changeset-scope gate not triggered).
  • No oneOf/discriminator, released-artifact, or 3.1.x patch-eligibility concerns in the delta.

Iteration note: the prior run's single medium (creatives.ts:226 delete_missing in lenient mode) is outside this delta and not rechecked per scope rules; no new blocking or medium findings surfaced. The lone quirk (extra params key collapsing to a spurious ambiguity when an unsized same-kind format exists) fails closed with an actionable message and is Low.

No team gate, not high-risk, gated_paths false. Falls through to row 9 → approve.

With delete_missing and lenient validation, a creative the request resent
but that failed validation was left out of the kept set, so its library
version was deleted and its failed row overwritten as deleted. Keep every
creative the request names; only ones it omits are deleted.

Committed with --no-verify (maintainer-approved): the hook failed on
stripe-client and compliance-authored-tool-gates under host load; both
pass alone.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…creative

A buy with no creatives reported pending_start, which tells a buyer
nothing is missing. AdCP's media-buy-status defines pending_creatives as
no package able to begin delivery for want of creative coverage. Report it
while no live package of the buy has a creative assigned, then
pending_start, active or the other states as before. Seeded delivery is
not gated on creatives; the docs page says so.

Committed with --no-verify (standing approval for #9116 until merge).

Co-Authored-By: Claude Opus 5.5 <[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: Approve

Approve — clean delta pass over PR #9116.

The code change narrows a real bug in syncCreatives' delete_missing branch: kept now derives from the raw request creatives (every named creative_id) rather than parsed (only successfully-validated ones), so a resent creative that fails lenient validation is preserved with its existing library version instead of being wrongly deleted. The fix is correct — strict mode still fails fast before delete_missing, no row collision occurs, and the added test (banner_keep→failed/kept, banner_a→deleted) covers the fixed path.

Checks applied:

  • No static/schemas/source/** changes → no schema↔docs coherence or oneOf discriminator concerns.
  • Training-agent app surface (not static/schemas/source/task defs/reference docs) → no changeset required; scope gate not triggered.
  • No high-risk paths, no gated paths, no no-auto-approve team match.
  • review_decision is REVIEW_REQUIRED but gated_paths: false, so row 2 does not fire.
  • Prior decision was approve; no blocker recurs.

Decision table: no critical/high/medium findings, no escalation triggers, no team gate → falls through to row 9 (approve).

@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: Approve

Approve — clean subsequent pass, no blocking findings.

This is a follow-up pass on a prior approve decision. The delta is 3 files: the pending_creatives status addition in inventory-sim/platform.ts, one docs line, and test updates. The new status logic (live.length > 0 && live.every(pkg => !pkg.creative_assignments?.length) → pending_creatives, checked before pending_start/active) is correct — pending_creatives is a valid media-buy-status enum value, and the schema's definition matches the implementation. Tests cover both transition directions.

No changeset required: this is training-agent simulation code with no change to static/schemas/source/**, task definitions, normative reference docs, or published artifacts.

Decision table: no critical/high/medium findings (row 1 N/A); gated_paths false (row 2 N/A); high_risk false (rows 3,5 N/A); no medium data-loss/schema/infra findings (row 4 N/A); prior decision was approve so row 6 sticky-escalation does not apply; no no-auto-approve team match (row 7 N/A); fewer than three medium findings (row 8 N/A). Falls through to row 9 → approve.

@bokelley
bokelley enabled auto-merge (squash) November 20, 2026 19:35
@bokelley
bokelley merged commit 515fbce into main Nov 20, 2026
62 checks passed
@bokelley
bokelley deleted the feat/inventory-creatives branch November 20, 2026 19:35
KonstantinMirin added a commit to KonstantinMirin/adcp that referenced this pull request Nov 21, 2026
Brings in 23 commits from main, among them the 3.2.12 hosted registration,
the @adcp/sdk 17.0.0-beta.31 bump (adcontextprotocol#9132), the inventory-tenant creative
library (adcontextprotocol#9116, adcontextprotocol#9143), the macOS runner tools for the release tests (adcontextprotocol#9138)
and the hook split in adcontextprotocol#9126.

The hooks stay as this branch has them: pre-commit runs the root suite, the
staged-file-scoped server suite, the checks and the node:test files as one
vitest run under a 120 s budget, and pre-push runs the storyboard queue under
180 s. With the shared workers, caches and queue, both fit in about 200 s on
an M4 Pro, so this branch keeps the suites in the hooks. adcontextprotocol#9126's additive
pieces stay: npm run verify:local and precommit-server-unit.cjs --full.

Resolution ledger:
- mechanical: package-lock.json -> main's (identical to main after the merge).
- semantic:
  - package.json -> this branch's precommit script, plus main's verify:local.
  - .husky/pre-push (auto-merged) -> this branch's storyboard block; the
    matrix runs when its sources change, ADCP_SKIP_STORYBOARD_MATRIX=1 skips it.
  - .agents/playbook.md -> this branch's Local Hooks text, plus a
    verify:local paragraph; main's auto-merged hook description removed.
  - scripts/precommit-server-unit.cjs -> union: main's --full switch runs
    this branch's single-run full plan.
  - scripts/verify-local.cjs -> main's, with its header no longer saying the
    hooks run only fast checks.
  - server/tests/unit/training-agent-inventory-tenants.test.ts -> union:
    main's new cases with this branch's static import and state resets.
  - tests/cdn-artifacts, changesets-fence, maintenance-release-publication,
    release-publication-ordering -> union: this branch's git-env isolation,
    main's runnerPath() as the one GNU-tools mechanism; this branch's
    tests/helpers/gnu-tools.cjs and its shims are removed as unused.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant