Skip to content

fix(training-agent): wholesale feed version covers the built-in catalogue - #9190

Merged
bokelley merged 4 commits into
mainfrom
fix/training-agent-feed-version
Nov 23, 2026
Merged

bokelley merged 4 commits into
mainfrom
fix/training-agent-feed-version

Conversation

@bokelley

@bokelley bokelley commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #9175

Problem

productWholesaleFeedMeta built wholesale_feed_version as training-products-feed-v1.<cache_scope>.<digest of session-seeded products>, and pricing_version from the seeded pricing options alone. Neither digest covered the built-in catalogue from buildCatalog. When the ten creatorloop_creator_* products were added, the unseeded public version stayed training-products-feed-v1.public.base. A buyer reading wholesale conditionally then got unchanged: true and kept its old 27-product mirror while the agent served 37.

Fix

Both tokens now digest the whole served feed. The digest builds the catalogue the same way get_products does before it filters anything: getCatalog(ctx) for the request's context, with the session's seeded products and seeded prices overlaid (overlaySeededProducts), sorted by product_id.

  • wholesale_feed_version: digest of every product minus its prices and its forecast.
  • pricing_version: digest of every product's pricing_options, including the pricing_options nested in signal_targeting_options.

Which inputs move the version, and why:

Input Moves the version? Why
A change to any built-in or seeded product, or the product set yes That is the feed state the response is built from.
A price change pricing_version only The existing independent pricing layer (see pricing_version below). Seeded prices already behaved this way.
The request's context (getCatalog(ctx), e.g. the 3.3 core-gender demonstration product) yes It changes what this caller is served.
filters, targeting_overlay, pagination no They're in the token's scope tuple, so the buyer already caches per selection. A whole-feed digest is a valid version for every selection: when no product changes, no filtered view changes either.
cache_scope prefix only Tokens stay scope-keyed, as before.
Forecasts, configured-product expires_at no Per-read data, not durable offer definition. list_products.mdx: "feed_version covers the durable offer definition only."

buy_products validates feed_version and pricing_version against the same function, so it now takes ctx too. include_collections scoping (collections/include-collections.ts) is unchanged. It still appends its card digest on top.

Seeding a product now also moves pricing_version. The backfilled product carries a default price, so the pricing layer changed. The existing test that asserted otherwise is updated.

Existing normative text (no spec change in this PR)

  • media-buy/get-products-response.json wholesale_feed_version: "Opaque token representing the version of the wholesale product feed state used to compose this response. … The token is scope-keyed … Scoping dimensions: (agent, buying_mode, filters, targeting_overlay, media_buy_frequency_cap, required_overlay_support, required_media_buy_support, deprecated property_list, catalog) for cache_scope: 'public'; that tuple plus account_id for cache_scope: 'account'. pagination.cursor is NOT part of the scoping tuple."
  • media-buy/get-products-response.json unchanged: "Present and true ONLY on wholesale-mode responses when the request carried if_wholesale_feed_version (and/or if_pricing_version) matching the seller's current version for the buyer's cache_scope, in which case products[] MUST be omitted … Buyers receiving unchanged: true MUST NOT mutate their local wholesale product mirror."
  • media-buy/get-products-request.json if_wholesale_feed_version: "When provided, the seller compares against its current wholesale product feed version for the buyer's cache_scope and MAY return an unchanged: true response (with products omitted) if nothing has changed."
  • media-buy/get-products-response.json pricing_version: "When the seller supports independent pricing versioning, pricing_version changes when prices move but wholesale_feed_version changes only when structure/metadata moves. Same cache_scope keying as wholesale_feed_version. Sellers not separating these MAY omit pricing_version and use wholesale_feed_version for both."
  • docs/media-buy/task-reference/list_products.mdx: "feed_version covers the durable offer definition only. Forecast data (including availability windows) does not participate in feed-version scoping."

The spec doesn't say in so many words that wholesale_feed_version MUST change whenever the product set or any product changes. The closest wording is "the version of the wholesale product feed state used to compose this response" and "MAY return … unchanged … if nothing has changed". The pricing_version text also exempts price-only changes from the feed version when a seller versions pricing separately. That is flagged separately as a possible spec issue; this PR doesn't touch the spec.

Behavior

before after
Unseeded public version training-products-feed-v1.public.base, whatever the catalogue training-products-feed-v1.public.<digest>, moves when the catalogue changes
Probe with a token minted before a catalogue change unchanged: true, 0 products full feed with the new token
Probe with the current token unchanged: true unchanged: true
Built-in price change neither token moves pricing_version moves, wholesale_feed_version doesn't

Cost: one SHA-256 over the canonical served catalogue per wholesale read, a few milliseconds.

Tests

The new server/tests/unit/training-agent-wholesale-feed-version.test.ts wraps buildCatalog with a mutation hook. invalidateCache() then rebuilds the built-in catalogue, so each case changes the catalogue the way a deploy would:

  • Identical catalogue: two servers, or a rebuilt identical catalogue, give the same tokens. A probe with that token returns unchanged: true and no products.
  • Catalogue change: a description edit, or a dropped product, moves wholesale_feed_version. A probe with the old token gets the full feed.
  • Price-only change: only pricing_version moves. A probe with both old tokens gets the full feed.
  • Forecast-only change: neither token moves. A probe with both old tokens returns unchanged: true, and list_products' feed_version holds. Added after the cold review caught forecast still in the structural digest.
  • Filters and pagination: unfiltered, channels: ['display'] and max_results: 1 reads carry identical tokens.
  • Scope: an account-overlay.example account's tokens differ from the public ones only in the scope segment.
  • seed_pricing_option: moves pricing_version only.
  • list_products: its feed_version equals the wholesale wholesale_feed_version for the same selection.

Three existing tests in training-agent.test.ts hard-coded the .public.base tokens or the old pricing behaviour on seed_product. They now assert the token shape, or take the token from a first read.

Local: server/tests/unit/training-agent*, product-discovery* and server/src/training-agent pass 88 files and 2151 tests. tsc is clean.

No changeset: training-agent only, no protocol surface (same as #9076).

🤖 Generated with Claude Code

bokelley and others added 2 commits November 23, 2026 10:51
…ogue

productWholesaleFeedMeta digested only the controller-seeded products, so
a change to the built-in catalogue (for example the ten CreatorLoop
creator products) never moved wholesale_feed_version, and conditional
readers kept a stale mirror. Both tokens now digest the whole served feed:
the built-in catalogue as the request's context serves it, with the
session's seeded products and prices overlaid, before any filter,
targeting configuration or pagination. Prices (product and nested signal
targeting pricing_options) feed pricing_version; everything else feeds
wholesale_feed_version, keeping the independent pricing layer.

Fixes #9175

Co-Authored-By: Claude Opus 5.5 <[email protected]>
aao-secretariat[bot]
aao-secretariat Bot previously approved these changes Nov 23, 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 — feed-version digest fix in training-agent task handlers with tests.

Checked:

  • server/src/training-agent/task-handlers.ts: new servedProductFeedRevisions digests the full served feed (getCatalog(ctx) + overlaySeededProducts), split cleanly into structure (feed) and pricing digests. Every product field lands in exactly one digest, so no durable offer change escapes both tokens — closes the #9175 fail-open stale-cache gap where the built-in catalogue was uncovered. canonicalJson recursively sorts keys for stable output; both get_products/buy_products sites thread ctx consistently.
  • No protocol surface touched: no static/schemas/source/**, dist/**, normative docs/reference/**, or task-definition changes — training-agent server code only, so no changeset required (confirmed out of scope).
  • Tests added covering the new branch; no failing checks.

No critical/high/medium findings. gated_paths false, high_risk false, no author team gate. review_decision is REVIEW_REQUIRED but no hard gate applies (row 2 requires gated_paths: true). Falls through to row 9.

bokelley and others added 2 commits November 23, 2026 11:06
A forecast is per-read data, not the durable offer definition that
feed_version covers (list_products.mdx), so a forecast-only catalogue
change no longer moves wholesale_feed_version or invalidates a buyer's
buy_products feed_version.

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 pass. This PR (3 files, +292/-17) is a server-only training-agent change: it excludes forecast from the served-product feed digest in servedProductFeedRevisions and adds tests asserting forecast-only changes hold both version tokens. The behavior now aligns with list_products.mdx:129 ("forecast data does not participate in feed-version scoping"). The fields: ["forecast"] escape hatch (task-handlers.ts:11933-11940) already bypasses the unchanged arm, so no forecast-wanting caller is stranded.

No schema/protocol surface touched (no static/schemas/source/**, no docs/reference/**, no dist/**), so no changeset is required and no spec-drift or immutability gates apply. No critical/high/medium findings. Prior decision was approve with no blockers.

Gate check: gated_paths: false → row 2 does not fire despite review_decision: REVIEW_REQUIRED. high_risk: false, no no-auto-approve team match. No findings at all → falls through to row 9.

@bokelley
bokelley merged commit 064817c into main Nov 23, 2026
62 checks passed
@bokelley
bokelley deleted the fix/training-agent-feed-version branch November 23, 2026 13:48
KonstantinMirin added a commit to KonstantinMirin/adcp that referenced this pull request Nov 23, 2026
…contextprotocol#9189, adcontextprotocol#9190), mutation_outcome docs (adcontextprotocol#9191)

No conflicts. Two files changed on both sides, in separate places.

Resolution ledger:
- semantic: server/src/training-agent/task-handlers.ts -> union: this
  branch's narrow imports and first-read input schemas; main's market
  filters, which leave out uncovered products instead of refusing
  (adcontextprotocol#9189), and the wholesale feed version over the built-in catalogue
  (adcontextprotocol#9190).
- semantic: server/tests/unit/training-agent.test.ts -> union: this
  branch's @adcp/sdk subpath imports; main's feed and pricing version
  assertions.
- auto-merged, main only: creators.ts, product-factory.ts,
  publishers.ts, types.ts, the two new training-agent test files, and
  adcontextprotocol#9191's docs, decision record and test.

Checks:
- npm run typecheck: pass.
- training-agent-product-coverage, training-agent-wholesale-feed-version
  and training-agent tests: 859 pass.
- test:narrow-imports, test:test-spawn-tooling, test:test-builds,
  test:test-git-env, test:test-dynamic-imports, test:module-eval-cycles:
  pass.
- tests/mutation-outcome.test.cjs: 6 pass.
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: wholesale_feed_version doesn't change when the built-in product catalogue changes, so conditional readers keep a stale catalogue

1 participant