Skip to content

refactor: rename catalog sync to wholesale feed sync - #1932

Merged
bokelley merged 1 commit into
mainfrom
bokelley/wholesale-feed-sync-rename
May 22, 2026
Merged

bokelley merged 1 commit into
mainfrom
bokelley/wholesale-feed-sync-rename

Conversation

@bokelley

Copy link
Copy Markdown
Contributor

Summary

  • replace the beta CatalogSync export/path with WholesaleFeedSync and @adcp/sdk/wholesale-feed-sync
  • remove the stale catalogVersioning compatibility alias and beta-era direct feed no-op config
  • add explicit signal created/updated/removed coverage plus signal-only bulk-change repair

Validation

  • npm run build:lib
  • node --test test/lib/wholesale-feed-sync.test.js test/lib/account-notification-config-projection.test.js test/lib/schema-loader-per-version.test.js test/lib/v3-1-beta-notification-types.test.js
  • npm run format:check
  • git diff --check
  • npm test

@bokelley
bokelley enabled auto-merge (squash) May 22, 2026 13:05
@bokelley
bokelley force-pushed the bokelley/wholesale-feed-sync-rename branch from 88169bf to 4d25b73 Compare May 22, 2026 13:07

@aao-ipr-bot aao-ipr-bot 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.

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

  1. 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 is patch and still names CatalogSync. The actual surface change here is major. CI Changeset Check will flag this; treat it as a block.

  2. Subpath delete with no shim. package.json:48-51 drops @adcp/sdk/catalog-sync and substitutes @adcp/sdk/wholesale-feed-sync. Every adopter on 7.10.x/7.11.0 with import { CatalogSync } from '@adcp/sdk/catalog-sync' hits ERR_MODULE_NOT_FOUND on npm 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.

  3. CursorStore re-exports silently dropped. src/lib/catalog-sync/index.ts:25-26 exported CursorStore, InMemoryCursorStore, FileCursorStore. The new src/lib/wholesale-feed-sync/index.ts does not. CHANGELOG.md:255 explicitly tells adopters to import FileCursorStore from @adcp/sdk/catalog-sync for cursor persistence. Not mentioned in the PR body. Either restore them, or call out the deletion explicitly and accept it under the same major bump as everything else.

  4. @deprecated field removal in a non-major. feedOrigin, feedHeaders, maxFeedResponseBytes, pollIntervalMs, cursorStore, fetch, and the catalogVersioning alias on ResolvedCapabilities are all gone from the type. @deprecated in TS JSDoc is informational, not a soft-remove — adopters compiling under --strict hit TS2353/TS2339 on upgrade. The commit message calls catalogVersioning "stale." It shipped to npm three weeks ago. Not stale; published.

Major

  1. Signal-only bulk-change test doesn't assert the no-phantom-diff invariant. test/lib/wholesale-feed-sync.test.js:350-389 checks I/O call counts and sync.products.count === 1, but never subscribes to product.* events to confirm zero phantom emissions. The whole point of the new entities: 'signals' option is to avoid emitting product diffs when only signals changed — assert that. Add sync.on('event', e => productEvents.push(e)) and assert.strictEqual(productEvents.filter(e => e.event.entity_type === 'product').length, 0).

Things I checked

  • bootstrap({ entities: 'signals' }) logic at src/lib/wholesale-feed-sync/sync.ts:391-448 is sound — refreshProducts === false leaves this.productIndex untouched, and emitDiffs reads from this.productIndex (the live state), so no product-side phantom diffs. The wiring is right; the test just doesn't witness it.
  • affected_entity_type mapping at sync.ts:537-540 falls through to 'all' on unknown/missing — safe conservative default.
  • Rename is otherwise thorough — no stale CatalogSync references in src/, docs/, test/, bin/. Historical CHANGELOG references stay accurate.

Minor nits (non-blocking)

  1. Stale changeset prose. .changeset/catalog-sync-webhook-notifications.md:5 still says "CatalogSync now 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 fresh major changeset that supersedes).
  • Add a catalog-sync re-export shim (or document the hard break explicitly).
  • Restore the CursorStore re-exports on the new path.
  • Either restore the six @deprecated config fields as ignored pass-throughs for one cycle, or accept the break under the major.
  • 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.

@aao-ipr-bot aao-ipr-bot 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.

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

  • recoverFromBulkChange now reads event.payload.affected_entity_type and scopes the re-bootstrap to the affected feed (src/lib/wholesale-feed-sync/sync.ts:535-540). Spec-correct per the consumer guidance in tools.generated.ts:12257 ("MUST emit one webhook per feed") and 12266 ("re-read the affected wholesale feed"). The previous always-rebootstrap-both was wasteful and would have clobbered the unrelated wholesale_feed_version cursor on a signal-only bulk_change.
  • Schema field affected_entity_type: 'product' | 'signal' is required in src/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-391 asserts calls.getProducts.length === 1 after a signal-only bulk_change, which is exactly the invariant.
  • Rename is mechanical and consistent across package.json exports + typesVersions, source, types, tests, migration doc, and the v8.0-beta plan.
  • Tests, format check, and git diff --check per the PR description.

MUST FIX

  1. Changeset is patch; the change is major. package.json removes the ./catalog-sync exports entry (and its typesVersions entry) without an alias. The CatalogSync class, the CatalogSync{Mode,State,Config,Events,Client} type aliases, the ResolvedCapabilities.catalogVersioning field (@deprecated but still removed), and the CursorStore / InMemoryCursorStore / FileCursorStore re-exports from the old path are all gone with no shim. CHANGELOG.md for 7.10.0 explicitly told adopters to import FileCursorStore from @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 in CLAUDE.md ("Removed/renamed export, required-param flip, dropped enum value → major"), this is major. The "beta" label lives in docstrings — the npm dist-tag is latest and the published export path is top-level, not under a v3-1-beta namespace. 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 patch and add back-compat shims — re-export CatalogSync as an alias for WholesaleFeedSync from src/lib/wholesale-feed-sync/index.ts; keep the ./catalog-sync entry in package.json pointing at the new module; re-export CursorStore/InMemoryCursorStore/FileCursorStore from the new path (the deleted src/lib/catalog-sync/index.ts:25-26 had them); restore catalogVersioning as a @deprecated alias getter on ResolvedCapabilities. ~15 lines, removed in the actual major bump.

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-required affected_entity_type is 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 an error event 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 — when entities === 'signals' and this.signals.queryable === false, both refreshProducts and refreshSignals resolve to false. The bootstrap does no work but still emits bootstrap and updates _lastSyncedAt. Benign but it lies about a sync that didn't happen. Either early-return or surface as error.

Minor nits (non-blocking)

  1. recoverFromBulkChange(event) arg. Only the affected_entity_type is read; consider passing affectedEntityType directly to keep the call site honest about what the helper cares about. src/lib/wholesale-feed-sync/sync.ts:535.
  2. Signal-only bulk_change test could harden the no-product-refetch assertion. test/lib/wholesale-feed-sync.test.js:387 asserts calls.getProducts.length === 1 — true because start() also calls it once. An explicit "phase === 'bulk' did not call getProducts" assertion would tighten the invariant. Same for calls.getSignals.length === 2 (one bootstrap, one repair).

Ship it once the changeset reflects the surface impact.

@bokelley
bokelley force-pushed the bokelley/wholesale-feed-sync-rename branch from 4d25b73 to 871b629 Compare May 22, 2026 13:17

@aao-ipr-bot aao-ipr-bot 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.

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.json exports + typesVersions both flipped to ./wholesale-feed-sync. No stale catalog-sync refs in either map.
  • src/lib/index.ts:5 still re-exports CursorStore / InMemoryCursorStore / FileCursorStore from the package root, so dropping them from the wholesale-feed-sync subpath isn't a dangling consumer — RegistrySync users are unaffected.
  • All Catalog* identifiers, generics, JSDoc, and error strings renamed inside src/lib/wholesale-feed-sync/. No leftovers.
  • ad-tech-protocol-expert: sound. affected_entity_type is non-optional on the wholesale_feed.bulk_change payload 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, the catalogVersioning alias, and the deprecated direct-feed config.
  • bootstrap({ entities: 'signals' }) + emitDiffs walk: when refreshProducts === false, the products map is identity-stable, so every entry in previousProducts matches the current index — no spurious product.removed fires. Behavior is right; a one-line comment in bootstrap() 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:

  • :274 validates affected_entity_type on bulk_change and throws on malformed payloads.
  • :280 is the dedupe check; :302 is markWebhookProcessed.

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.md still describes "CatalogSync now uses if_wholesale_feed_version…" Both changesets land in the same CHANGELOG; the type named there won't exist after merge. Rewrite to WholesaleFeedSync, 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 catalogVersioning alias, removed config keys (feedOrigin / feedHeaders / maxFeedResponseBytes / pollIntervalMs / cursorStore / fetch), tightened bulk_change validation, and the CursorStore re-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 / FileCursorStore are still available from @adcp/sdk root for RegistrySync users — the subpath drop reads as a removal otherwise.
  • src/lib/wholesale-feed-sync/sync.ts:606-611 — currentWholesaleFeedVersionForEvent calls bulkChangeAffectedEntityType on the fall-through branch, which now throws. The :274 early-throw makes this branch unreachable for bulk_change today, 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.

@bokelley
bokelley force-pushed the bokelley/wholesale-feed-sync-rename branch from 871b629 to 535337a Compare May 22, 2026 13:28

@aao-ipr-bot aao-ipr-bot 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.

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() at src/lib/wholesale-feed-sync/sync.ts:622-628 matches the generated discriminant in src/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-421 confirms 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-sync references in src/, bin/, test/, examples/. The remaining literals in docs/migration-7.11-to-8.0.md are the migration table (intentional). Other Catalog* symbols in src/lib/ are unrelated AdCP catalog-domain types, not the renamed mirror.
  • Major changeset at .changeset/wholesale-feed-sync-rename.md is accurate — removing exported symbols, a subpath, and the catalogVersioning alias warrants a major. Migration guide at docs/migration-7.11-to-8.0.md lists every renamed type. No manual package.json version edit.
  • catalogVersioning alias drop is right — the v3-1-beta types tree is opt-in pre-GA. Carrying a beta alias for a beta capability is debt, not compat.
  • rememberWebhookVersion at sync.ts:630-641 deliberately doesn't update version state on wholesale_feed.bulk_change because the recovery path re-derives versions from the wholesale read. Correct.

Follow-ups (non-blocking — file as issues)

  • currentWholesaleFeedVersionForEvent at sync.ts:615-620 returns signalWholesaleFeedVersion for affected='signal' even when signals.queryable is false. Both throw paths still terminate correctly, but the stale-token version comparison at :292-300 could fire first on a misconfigured agent. Cosmetic flow ordering — fold into the next webhook-path pass.
  • bulkChangeAffectedEntityType throw 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.

@bokelley
bokelley merged commit 93d390d into main May 22, 2026
11 checks passed
@bokelley
bokelley deleted the bokelley/wholesale-feed-sync-rename branch May 22, 2026 13:37
bokelley added a commit that referenced this pull request May 22, 2026
…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.
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