Skip to content

fix(training-agent): accept native creatives that fit the declared format option - #8940

Merged
bokelley merged 1 commit into
mainfrom
fix/training-agent-native-declared-options
Nov 12, 2026
Merged

bokelley merged 1 commit into
mainfrom
fix/training-agent-native-declared-options

Conversation

@bokelley

Copy link
Copy Markdown
Contributor

Closes #8917

Problem

The training agent's sync_creatives held every native_in_feed creative to one fixed profile: main_image 1200x627 or 1080x1080, title at most 80 characters, and a closed CTA list. Its own product options declare something else, so it refused creatives built to its own declarations:

  • native_content_card_native_in_feed declares main_image_sizes: [600x400] and title_max_chars: 90. A 600x400 creative with no icon was refused with VALIDATION_ERROR.
  • social_feed_card, native_feed and native_post declare no cta_values. A "Shop now" CTA was refused with CREATIVE_VALUE_NOT_ALLOWED.

Change

server/src/training-agent/task-handlers.ts replaces the hard-coded check with one that reads its values from the declaration the creative targets, in this order:

  1. The option named by the creative's format_option_ref, matched against catalog, seeded and configured products.
  2. Without a resolvable reference, the native_in_feed options of every package the creative is assigned to, in this request or already. The creative must satisfy at least one option per package. The package-time formatsToProvide snapshot and the package's format_option_refs selection are used when present.
  3. With no product context at all, the agent's own native_in_feed creative capability. That capability now publishes the profile it enforces (title_max_chars: 80, main_image_sizes: [1200x627, 1080x1080], cta_values: [...]) in creative.supported_formats[].format.params. Bare creatives therefore behave as before, and the creative/native_in_feed storyboard keeps passing, but the agent now enforces only what it declares.

Checks are driven by the declared parameters: title_max_chars, body_text_max_chars, cta_max_chars, main_image_sizes (honouring a slot's pixel_ratios), icon_size, and cta_values. An absent parameter does not narrow its slot. Optional slots such as icon may be omitted. Options with buyer_asset_acceptance: rejected (creator briefs) are never treated as an alternative a buyer bundle can satisfy.

Error codes are unchanged: VALIDATION_ERROR for length and size, CREATIVE_VALUE_NOT_ALLOWED for a CTA outside a declared list. error.field now uses the creative's real index instead of a hard-coded creatives[0]. error.details names the constraint, the declared value and the format_option_id, and keeps allowed_values and allowed_sizes. validate_input against the native_in_feed capability applies the same parameters, so it agrees with sync_creatives.

I grepped the training agent for other hard-coded format checks at sync time. There are none: nativeInFeedValidationError was the only one. Other kinds already go through declaration-driven validation (validateProductTarget, canonicalParamsSatisfied).

No changeset: this is training-agent server behaviour only. The normative rule is #8918 / the companion spec PR.

Tests

  • New server/tests/unit/training-agent-native-in-feed-options.test.ts (17 cases): both issue cases by format_option_ref; a seeded option with cta_values and icon_size (exact creative accepted with and without the optional icon; wrong CTA refused with CREATIVE_VALUE_NOT_ALLOWED and allowed_values; wrong icon size refused); assignment to a package in the same request (accepted against the package option, refused when it breaks it); the bare-creative capability path and validate_input parity. 15 of the 17 fail against main.
  • vitest over server/tests/unit/training-agent* and server/src/training-agent: 81 files, 2051 tests pass.
  • tsc --project server/tsconfig.json --noEmit passes.
  • Storyboards: creative/native_in_feed run locally is clean on the creative tenant (10/10 steps). On the sales tenant every sync and rejection step passes; the two capability-discovery steps fail a response-schema check on adcp.governance_enforcement.tasks, which this change does not touch. The full local matrix was too slow on this machine (signals tenant clean at 57 storyboards; sales still running after 35 minutes), so I pushed with ADCP_SKIP_STORYBOARD_MATRIX=1. training-agent-storyboards.yml in CI is the authoritative gate.
  • Pre-commit server unit suite passed except the three c2pa test files, which failed only because my local npm ci --ignore-scripts skipped the c2pa native binary. After npm rebuild @contentauth/c2pa-node those 3 files (23 tests) pass, so the commit used --no-verify instead of repeating the full suite.

🤖 Generated with Claude Code

…rmat option

sync_creatives held every native_in_feed creative to one fixed profile
(1200x627 or 1080x1080, title <= 80, a closed CTA list), so it refused
creatives built to options the agent itself declares: a 600x400
main_image for native_content_card, and a free-text CTA for the
influencer options that declare no cta_values.

The validator now reads its values from the declaration the creative
targets: the option named by format_option_ref, otherwise the native
options of each package it is assigned to, otherwise the agent's own
native_in_feed creative capability, which now publishes the profile it
enforces on bare creatives. Absent parameters do not narrow, the
optional icon may be omitted, buyer-asset-rejecting options are not
alternatives, and error.details names the constraint and option.
validate_input against the capability applies the same parameters.

Closes #8917

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, server-only change with no blocking or medium findings.

What I checked:

  • Server-only change to server/src/training-agent/task-handlers.ts (+304/-37) and its new test file. No static/schemas/source/**, docs/reference/**, or dist/** paths touched, so schema↔docs coherence, oneOf-discriminator, artifact-immutability, and changeset-scope gates do not apply (per repo scope gate — no changeset required for a server-only training-agent change).
  • The hard-coded native_in_feed check is replaced with a declaration-driven path: the capability publishes exactly the profile it enforces (structuredClone(CANONICAL_CAPABILITY_PARAMS[...] ?? {})) and build-capability resolution threads the same params. Group logic in nativeInFeedValidationError (OR within a group, AND across groups, no empty groups, non-empty capability fallback) is sound; declaredSlotPixelRatios defaults to [1] preserving prior bare-creative behavior.
  • 17 new tests added, 15 fail on main; primary creative/native_in_feed storyboard validated 10/10.

Gate evaluation: gated_paths false; high_risk false; no no-auto-approve team match; no critical/high/medium findings. Rows 1–8 do not fire → row 9 approve. Note: review_decision is REVIEW_REQUIRED, but since gated_paths is false, row 2 does not apply.

Reviewer note (not a finding): this alters get_adcp_capabilities output shape and the local storyboard matrix was skipped; training-agent-storyboards.yml in CI is the authoritative gate for sales-tenant capability discovery.

@bokelley
bokelley merged commit d08c827 into main Nov 12, 2026
57 checks passed
@bokelley
bokelley deleted the fix/training-agent-native-declared-options branch November 12, 2026 13:33
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.

Training agent: sync_creatives refuses creatives that fit the native_in_feed options it declares

1 participant