Repository navigation
refactor: rename catalog sync to wholesale feed sync - #1932
Conversation
88169bf to
4d25b73
Compare
There was a problem hiding this comment.
Request changes. CatalogSync shipped on npm in 7.10.0 (CHANGELOG.md:194) and is still exported in 7.11.0 — renaming the class, deleting the subpath, removing the CursorStore re-exports, and dropping six @deprecated config fields is a breaking change. This PR ships all of it without a changeset.
Blockers
-
No changeset, breaking rename. Per CLAUDE.md L97: "ALWAYS create a changeset for ANY library/CLI code change." The only pending changeset is
.changeset/catalog-sync-webhook-notifications.md, which ispatchand still namesCatalogSync. The actual surface change here ismajor. CIChangeset Checkwill flag this; treat it as a block. -
Subpath delete with no shim.
package.json:48-51drops@adcp/sdk/catalog-syncand substitutes@adcp/sdk/wholesale-feed-sync. Every adopter on 7.10.x/7.11.0 withimport { CatalogSync } from '@adcp/sdk/catalog-sync'hitsERR_MODULE_NOT_FOUNDonnpm install. Keep the old subpath as a thin re-export shim (export { WholesaleFeedSync as CatalogSync } from '../wholesale-feed-sync'with@deprecated), schedule hard removal for 8.0. -
CursorStorere-exports silently dropped.src/lib/catalog-sync/index.ts:25-26exportedCursorStore,InMemoryCursorStore,FileCursorStore. The newsrc/lib/wholesale-feed-sync/index.tsdoes not. CHANGELOG.md:255 explicitly tells adopters to importFileCursorStorefrom@adcp/sdk/catalog-syncfor cursor persistence. Not mentioned in the PR body. Either restore them, or call out the deletion explicitly and accept it under the samemajorbump as everything else. -
@deprecatedfield removal in a non-major.feedOrigin,feedHeaders,maxFeedResponseBytes,pollIntervalMs,cursorStore,fetch, and thecatalogVersioningalias onResolvedCapabilitiesare all gone from the type.@deprecatedin TS JSDoc is informational, not a soft-remove — adopters compiling under--stricthitTS2353/TS2339on upgrade. The commit message callscatalogVersioning"stale." It shipped to npm three weeks ago. Not stale; published.
Major
- Signal-only bulk-change test doesn't assert the no-phantom-diff invariant.
test/lib/wholesale-feed-sync.test.js:350-389checks I/O call counts andsync.products.count === 1, but never subscribes toproduct.*events to confirm zero phantom emissions. The whole point of the newentities: 'signals'option is to avoid emitting product diffs when only signals changed — assert that. Addsync.on('event', e => productEvents.push(e))andassert.strictEqual(productEvents.filter(e => e.event.entity_type === 'product').length, 0).
Things I checked
bootstrap({ entities: 'signals' })logic atsrc/lib/wholesale-feed-sync/sync.ts:391-448is sound —refreshProducts === falseleavesthis.productIndexuntouched, andemitDiffsreads fromthis.productIndex(the live state), so no product-side phantom diffs. The wiring is right; the test just doesn't witness it.affected_entity_typemapping atsync.ts:537-540falls through to'all'on unknown/missing — safe conservative default.- Rename is otherwise thorough — no stale
CatalogSyncreferences insrc/,docs/,test/,bin/. Historical CHANGELOG references stay accurate.
Minor nits (non-blocking)
- Stale changeset prose.
.changeset/catalog-sync-webhook-notifications.md:5still says "CatalogSyncnow uses…". Whichever changeset survives the rework needs the new name and the migration callouts.
Path to ship
- Promote the changeset to
major(or add a freshmajorchangeset that supersedes). - Add a
catalog-syncre-export shim (or document the hard break explicitly). - Restore the
CursorStorere-exports on the new path. - Either restore the six
@deprecatedconfig fields as ignored pass-throughs for one cycle, or accept the break under themajor. - Strengthen the signal-only bulk-change test to assert no phantom product events.
- Add
docs/migration-7.11-to-8.0.md(or wherever the major lands) with the old→new rename table.
There was a problem hiding this comment.
Request changes: the patch changeset understates the wire impact. Either bump to major or add back-compat shims at the old paths — the rename is otherwise clean and the scoped-recovery optimization is the right call.
Things I checked
recoverFromBulkChangenow readsevent.payload.affected_entity_typeand scopes the re-bootstrap to the affected feed (src/lib/wholesale-feed-sync/sync.ts:535-540). Spec-correct per the consumer guidance intools.generated.ts:12257("MUST emit one webhook per feed") and12266("re-read the affected wholesale feed"). The previous always-rebootstrap-both was wasteful and would have clobbered the unrelatedwholesale_feed_versioncursor on a signal-only bulk_change.- Schema field
affected_entity_type: 'product' | 'signal'is required insrc/lib/types/v3-1-beta/tools.generated.ts. The SDK casts as optional and falls through to'all'. Defensive but fail-open — see follow-up. - Test
test/lib/wholesale-feed-sync.test.js:351-391assertscalls.getProducts.length === 1after a signal-only bulk_change, which is exactly the invariant. - Rename is mechanical and consistent across
package.jsonexports+typesVersions, source, types, tests, migration doc, and the v8.0-beta plan. - Tests, format check, and
git diff --checkper the PR description.
MUST FIX
-
Changeset is
patch; the change ismajor.package.jsonremoves the./catalog-syncexports entry (and itstypesVersionsentry) without an alias. TheCatalogSyncclass, theCatalogSync{Mode,State,Config,Events,Client}type aliases, theResolvedCapabilities.catalogVersioningfield (@deprecatedbut still removed), and theCursorStore/InMemoryCursorStore/FileCursorStorere-exports from the old path are all gone with no shim.CHANGELOG.mdfor 7.10.0 explicitly told adopters to importFileCursorStorefrom@adcp/sdk/catalog-sync. Adopters on 7.10.x / 7.11.0 importing any of this will hit a hard TS/build failure on 7.11.1. Per the version-bump table inCLAUDE.md("Removed/renamed export, required-param flip, dropped enum value → major"), this ismajor. The "beta" label lives in docstrings — the npm dist-tag islatestand the published export path is top-level, not under av3-1-betanamespace. There's no semver signal to adopters that the surface was unstable.Two acceptable fixes:
- Bump to
major— clean, honest, and the change is small enough that the next major being a rename is fine. - Keep the
patchand add back-compat shims — re-exportCatalogSyncas an alias forWholesaleFeedSyncfromsrc/lib/wholesale-feed-sync/index.ts; keep the./catalog-syncentry inpackage.jsonpointing at the new module; re-exportCursorStore/InMemoryCursorStore/FileCursorStorefrom the new path (the deletedsrc/lib/catalog-sync/index.ts:25-26had them); restorecatalogVersioningas a@deprecatedalias getter onResolvedCapabilities. ~15 lines, removed in the actual major bump.
- Bump to
Follow-ups (non-blocking, file as issues)
src/lib/wholesale-feed-sync/sync.ts:537—affected === 'product' ? 'products' : affected === 'signal' ? 'signals' : 'all'falls through to'all'when the schema-requiredaffected_entity_typeis missing or unknown. The surrounding webhook-validation code at L249/L252/L258 throws on shape mismatches; this one silently degrades. Match the surrounding style: throw'WholesaleFeedSync: wholesale_feed.bulk_change payload missing required affected_entity_type', or at minimum emit anerrorevent before falling through. As-is, a misbehaving 3.1-beta seller gets a silent double-feed re-read with no observability.src/lib/wholesale-feed-sync/sync.ts:391-440— whenentities === 'signals'andthis.signals.queryable === false, bothrefreshProductsandrefreshSignalsresolve tofalse. The bootstrap does no work but still emitsbootstrapand updates_lastSyncedAt. Benign but it lies about a sync that didn't happen. Either early-return or surface aserror.
Minor nits (non-blocking)
recoverFromBulkChange(event)arg. Only theaffected_entity_typeis read; consider passingaffectedEntityTypedirectly to keep the call site honest about what the helper cares about.src/lib/wholesale-feed-sync/sync.ts:535.- Signal-only bulk_change test could harden the no-product-refetch assertion.
test/lib/wholesale-feed-sync.test.js:387assertscalls.getProducts.length === 1— true becausestart()also calls it once. An explicit "phase === 'bulk' did not call getProducts" assertion would tighten the invariant. Same forcalls.getSignals.length === 2(one bootstrap, one repair).
Ship it once the changeset reflects the surface impact.
4d25b73 to
871b629
Compare
There was a problem hiding this comment.
Rename mechanics are clean and the wire posture is right. Holding for one answer on the bulk_change throw ordering before approving.
Things I checked
package.jsonexports +typesVersionsboth flipped to./wholesale-feed-sync. No stalecatalog-syncrefs in either map.src/lib/index.ts:5still re-exportsCursorStore/InMemoryCursorStore/FileCursorStorefrom the package root, so dropping them from thewholesale-feed-syncsubpath isn't a dangling consumer —RegistrySyncusers are unaffected.- All
Catalog*identifiers, generics, JSDoc, and error strings renamed insidesrc/lib/wholesale-feed-sync/. No leftovers. ad-tech-protocol-expert: sound.affected_entity_typeis non-optional on thewholesale_feed.bulk_changepayload arm (tools.generated.ts:12240-12260), and the spec mandates one webhook per affected feed — so failing closed on missing/unknown and scoping the repair to one entity track is correct. The prior product-default was fabrication.- Changeset tagged
major. Right category for removing@adcp/sdk/catalog-sync, thecatalogVersioningalias, and the deprecated direct-feed config. bootstrap({ entities: 'signals' })+emitDiffswalk: whenrefreshProducts === false, the products map is identity-stable, so every entry inpreviousProductsmatches the current index — no spuriousproduct.removedfires. Behavior is right; a one-line comment inbootstrap()noting this would save a future reader the trace.
Question before approval
src/lib/wholesale-feed-sync/sync.ts:274-276 and :538-545 — both throw paths run before markWebhookProcessed at :302.
In applyWebhook:
:274validatesaffected_entity_typeonbulk_changeand throws on malformed payloads.:280is the dedupe check;:302ismarkWebhookProcessed.
A non-conforming sender that ships a bulk_change without affected_entity_type (or with an unknown value) throws at :274 on every retry. The notification_id never enters processedWebhookKeys / webhookDedupStore, so an adopter wiring applyWebhook throws to HTTP 5xx will see the sender retry the same malformed delivery indefinitely. Same trap at :538-545 when an agent declares wholesale_feed.bulk_change but doesn't declare wholesale signal discovery — recoverFromBulkChange throws, bubbles past :302, and the dedupe table never records the rejection.
The fail-closed validation itself is right (matches the spec, witness-not-translator). The question is whether you want malformed/misrouted deliveries to be recorded as terminally-rejected (mark processed + throw, or mark processed + emit error) so they don't amplify. Two reasonable shapes: catch-mark-rethrow at the boundary, or move the validation inside the dedupe envelope.
If this is intentional ("sender conformance is out of scope; let the adopter's HTTP layer dead-letter"), say so and I'll approve.
Follow-ups (non-blocking — file as issues or fold in)
.changeset/catalog-sync-webhook-notifications.mdstill describes "CatalogSyncnow usesif_wholesale_feed_version…" Both changesets land in the same CHANGELOG; the type named there won't exist after merge. Rewrite toWholesaleFeedSync, or fold into the rename changeset and delete it.- Changeset wording. The body covers the rename + "strengthen wholesale signal webhook handling" but elides the rest of the breaking surface: removed
catalogVersioningalias, removed config keys (feedOrigin/feedHeaders/maxFeedResponseBytes/pollIntervalMs/cursorStore/fetch), tightenedbulk_changevalidation, and theCursorStorere-export drop from the subpath. The migration doc has the detail; the generated CHANGELOG entry won't, and adopters scanning the changelog will miss what to audit. - Migration doc. Add one line that
CursorStore/InMemoryCursorStore/FileCursorStoreare still available from@adcp/sdkroot forRegistrySyncusers — the subpath drop reads as a removal otherwise. src/lib/wholesale-feed-sync/sync.ts:606-611—currentWholesaleFeedVersionForEventcallsbulkChangeAffectedEntityTypeon the fall-through branch, which now throws. The:274early-throw makes this branch unreachable forbulk_changetoday, but the contract changed: malformed payloads that previously self-repaired via version-mismatch now hard-error. Worth a "behavior changes" bullet in the changeset.
Comment first — answer the dedupe-before-throw question and I'll approve.
871b629 to
535337a
Compare
There was a problem hiding this comment.
LGTM. Fail-closed plus dedupe-record-before-rethrow is the right posture once the wire makes affected_entity_type a required discriminator — over-broad re-bootstrap on ambiguous bulk_change would have doubled wholesale read cost and propagated seller schema drift into buyer caches.
Things I checked
bulkChangeAffectedEntityType()atsrc/lib/wholesale-feed-sync/sync.ts:622-628matches the generated discriminant insrc/lib/types/v3-1-beta/tools.generated.ts:12240-12260—affected_entity_type: 'product' | 'signal', non-optional. Fail-closed on missing/invalid is the schema-correct stance.- Both throw sites mark dedupe before rethrowing — version-derivation throw and signal-repair-without-queryable throw. Retries of the same malformed payload short-circuit at the dedupe guard. Test at
test/lib/wholesale-feed-sync.test.js:397-421confirms the second delivery returns silently. bootstrap()entity scoping is symmetric:refreshProducts = entities !== 'signals',refreshSignals = entities !== 'products' && this.signals.queryable. Atomic build-then-swap preserved per entity.- Rename completeness: zero orphan
CatalogSync/@adcp/sdk/catalog-syncreferences insrc/,bin/,test/,examples/. The remaining literals indocs/migration-7.11-to-8.0.mdare the migration table (intentional). OtherCatalog*symbols insrc/lib/are unrelated AdCP catalog-domain types, not the renamed mirror. - Major changeset at
.changeset/wholesale-feed-sync-rename.mdis accurate — removing exported symbols, a subpath, and thecatalogVersioningalias warrants a major. Migration guide atdocs/migration-7.11-to-8.0.mdlists every renamed type. No manualpackage.jsonversion edit. catalogVersioningalias drop is right — thev3-1-betatypes tree is opt-in pre-GA. Carrying a beta alias for a beta capability is debt, not compat.rememberWebhookVersionatsync.ts:630-641deliberately doesn't update version state onwholesale_feed.bulk_changebecause the recovery path re-derives versions from the wholesale read. Correct.
Follow-ups (non-blocking — file as issues)
currentWholesaleFeedVersionForEventatsync.ts:615-620returnssignalWholesaleFeedVersionforaffected='signal'even whensignals.queryableis false. Both throw paths still terminate correctly, but the stale-token version comparison at:292-300could fire first on a misconfigured agent. Cosmetic flow ordering — fold into the next webhook-path pass.bulkChangeAffectedEntityTypethrow message doesn't include the webhook dedupe key. Useful operationally when staring at a buyer's error log; one-line fix.
Approving on the strength of code-reviewer ship plus ad-tech-protocol-expert sound with the schema citation.
…al sweep) Foundation rebased onto main. Picks up: - Pre-mode entry (#1933) so foundation publishes under @beta - Codegen TS7056 fix (#1924) - Wholesale-feed-sync rename (#1932, replaces catalog-sync from earlier branch) - 3.1.0-beta.3 schema bundle (was beta.2 on the foundation branch) Resolutions: - .changeset/pre.json: took main's (initialVersions=8.0.0) - src/lib/version.ts: regenerated via sync-version --force - src/lib/types/schemas.generated.ts: regenerated - ADCP_VERSION: bumped 3.1.0-beta.2 → 3.1.0-beta.3 Demoted foundation changeset major → minor so the foundation merge publishes as 8.1.0-beta.0 (stays on 8.x line). The 9.0 major bump can come when v1 deprecation calendar tightens, not from this cut. Beta.3 spec changes folded in (partial): - RETENTION_EXPIRED removed from ErrorCodeValues; STALE_RESPONSE added. Updated DEFAULT_CODE_POLICY accordingly. - Envelope `status` REQUIRED on all responses — added 'failed' to two synthetic-error envelopes in response-unwrapper.ts. - ControllerError / SeedSuccess / wrapped store returns updated to carry envelope `status` (introduced wrapStoreSuccess helper in src/lib/server/test-controller.ts). - Type guards in src/lib/testing/test-controller.ts widened to handle the new union shape with envelope intersection. KNOWN ISSUE: ~45 more compile errors remain across decisioning/ adapter/middleware code from the envelope-status-required change. Each is mechanical (add `status: 'completed'` to a success-shape return) but the sweep is wider than this single merge commit. Pushed for visibility; follow-up PRs will sweep the remainder.
Summary
Validation