Repository navigation
fix(training-agent): wholesale feed version covers the built-in catalogue - #9190
Conversation
…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]>
…t-in catalogue Co-Authored-By: Claude Sonnet <[email protected]>
There was a problem hiding this comment.
Ladon verdict: Approve
Approve — feed-version digest fix in training-agent task handlers with tests.
Checked:
server/src/training-agent/task-handlers.ts: newservedProductFeedRevisionsdigests 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.canonicalJsonrecursively sorts keys for stable output; bothget_products/buy_productssites threadctxconsistently.- No protocol surface touched: no
static/schemas/source/**,dist/**, normativedocs/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.
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]>
…d versions Co-Authored-By: Claude Sonnet <[email protected]>
There was a problem hiding this comment.
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.
…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.
Fixes #9175
Problem
productWholesaleFeedMetabuiltwholesale_feed_versionastraining-products-feed-v1.<cache_scope>.<digest of session-seeded products>, andpricing_versionfrom the seeded pricing options alone. Neither digest covered the built-in catalogue frombuildCatalog. When the tencreatorloop_creator_*products were added, the unseeded public version stayedtraining-products-feed-v1.public.base. A buyer reading wholesale conditionally then gotunchanged: trueand 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_productsdoes before it filters anything:getCatalog(ctx)for the request's context, with the session's seeded products and seeded prices overlaid (overlaySeededProducts), sorted byproduct_id.wholesale_feed_version: digest of every product minus its prices and itsforecast.pricing_version: digest of every product'spricing_options, including thepricing_optionsnested insignal_targeting_options.Which inputs move the version, and why:
pricing_versiononlypricing_versionbelow). Seeded prices already behaved this way.getCatalog(ctx), e.g. the 3.3 core-gender demonstration product)filters,targeting_overlay, paginationcache_scopeexpires_atlist_products.mdx: "feed_versioncovers the durable offer definition only."buy_productsvalidatesfeed_versionandpricing_versionagainst the same function, so it now takesctxtoo.include_collectionsscoping (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.jsonwholesale_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.jsonunchanged: "Present andtrueONLY 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.jsonif_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.jsonpricing_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_versioncovers 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_versionMUST 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". Thepricing_versiontext 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
training-products-feed-v1.public.base, whatever the cataloguetraining-products-feed-v1.public.<digest>, moves when the catalogue changesunchanged: true, 0 productsunchanged: trueunchanged: truepricing_versionmoves,wholesale_feed_versiondoesn'tCost: 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.tswrapsbuildCatalogwith a mutation hook.invalidateCache()then rebuilds the built-in catalogue, so each case changes the catalogue the way a deploy would:unchanged: trueand no products.wholesale_feed_version. A probe with the old token gets the full feed.pricing_versionmoves. A probe with both old tokens gets the full feed.unchanged: true, andlist_products'feed_versionholds. Added after the cold review caughtforecaststill in the structural digest.channels: ['display']andmax_results: 1reads carry identical tokens.account-overlay.exampleaccount's tokens differ from the public ones only in the scope segment.seed_pricing_option: movespricing_versiononly.list_products: itsfeed_versionequals the wholesalewholesale_feed_versionfor the same selection.Three existing tests in
training-agent.test.tshard-coded the.public.basetokens or the old pricing behaviour onseed_product. They now assert the token shape, or take the token from a first read.Local:
server/tests/unit/training-agent*,product-discovery*andserver/src/training-agentpass 88 files and 2151 tests.tscis clean.No changeset: training-agent only, no protocol surface (same as #9076).
🤖 Generated with Claude Code