Skip to content
MSO CloudDocumentation

Add a collector feed

On this page

A collector feed lets a remote machine deliver third-party market rankings that have no vendor API. The machine signs each request with its own key, the gateway stores the compressed rows, and a promoter checks them before it writes market_intel_* for every org that subscribes to the feed (ADR 0065).

When to use#

Use a feed when a list is captured in a browser on another machine and must reach MSO Cloud every week or month without anyone uploading a file. A vendor with an API is a connector instead. A one-off file still goes through the upload on the market-intelligence data page.

Collector machine to gateway, object store and promoter, then market_intel tables per subscribed org

The contract#

  • Package packages/collector-contract/src: the manifest schema (manifest.ts, strict, no org field), the window checks in Asia/Ho_Chi_Minh (window.ts), the request signature (signature.ts), request and response schemas with error codes (api.ts) and every cap (limits.ts).
  • A batch is one feed and one closed window. Its parts are dataset kinds; each part is gzip NDJSON chunks of verbatim vendor rows, at most 8 MiB compressed each.
  • A row schema is <kind>@<n>. The server holds the minimum Zod schema (packages/connectors/core/src/collector-row-schemas.ts) and the mapper, mapRows on the source's entry in packages/connectors/core/src/market-data-registry.ts. Mapping on the server lets a mapper fix replay stored objects without a new crawl.

Steps#

  1. Add the row schema for the new kind to COLLECTOR_ROW_SCHEMAS: identity and the primary measure required, everything else passed through.
  2. Extend mapRows for that row_schema so it returns the canonical rows persistMarketIntelSnapshot writes, and add the kind's target table to TARGET_TABLE in apps/worker/src/collector/promoter/promote.ts.
  3. Check the quality gate in apps/worker/src/collector/promoter/gate.ts against real captures of the kind (the weekly product dry run is recorded in the ADR) before you change a threshold. Thresholds live in limits.ts with a row in limits and budgets.
  4. Register the feed and grant it to a collector with scripts/collector/register.ts (remote collectors runbook).
  5. Subscribe an org: its market-data connector lists the feed key in config.feeds, and its market-intelligence plugin is on. app_collector_list_feed_targets in packages/schema/sql/runtime-service-helpers.sql is the only reader of that subscription.

Rules that bind#

  • §233: the gateway role holds no grant on an org table; the promoter writes only snapshot-scoped market_intel_* tables through the persister.
  • Re-delivery writes nothing: the persister keeps a live snapshot with the same source digest, and an older capture never replaces a newer one.
  • A breaking contract change is a new contract_version, added to SUPPORTED_CONTRACT_VERSIONS.

Tests to add#

  • apps/worker/src/collector/promoter/gate.test.ts: one case per new check, where the bad part passes without it.
  • packages/connectors/core/src/collector-map-rows.test.ts: a field the persister reads survives the mapper.
  • The verify:rls leg scripts/audit/rls-collector-isolation.ts covers grants and isolation; extend it when a role gains a table.