Skip to content
MSO CloudDocumentation

ADR 0049 — Dataset connector contract

On this page
  • Status: Accepted. Batch 3 (2026-09-10), Track A-2.
  • Owners: Platform (site programme).
  • Extends: ADR 0048 (vertical registry — the dataset ingest family this ADR gives a real contract to), ADR 0038 (tenant dataset semantic layer — amendment (b): "a live Google Sheet is the ingest front"), ADR 0017 (unified mapping contract — the one ingest path this ADR routes onto, never a second one).
  • Related: ADR 0008 (marketing connector family — amended 2026-09-10: Google Sheets is also the ingest front of the dataset plane; dataset is a family of its own, never a marketing member).

Context#

ADR 0048 named dataset as a vertical's ingest family (hr, finance) but did not give it a contract: the only working ingest for a tenant dataset was a live Google Sheet, one tab per dataset, riding the marketing-family sheet driver's dataset_record template path — real, but not a type a second implementer (an HRM, an ERP, an accounting system) could satisfy. The investigation that led to ADR 0048 framed the choice as "generalize ApiConnector/produces OR lean into ADR 0038-0041"; this ADR is the answer, and it is not a compromise between the two — each applies at a different layer.

Decisions#

C1 — ApiConnector and FileConnector are NOT widened

ApiConnector is the eCom-shaped contract: three abstract sync methods over UnifiedOrder/UnifiedCreator/UnifiedInventoryItem, nine optional ones, and manifest.produces as the admin sync-control vocabulary for that family. Forcing an HRM connector to implement syncOrders as a no-op — or turning produces into free strings — would make the type say nothing about what either connector actually does. Both existing classes are unchanged. ConnectorManifestSchema.produces gains exactly ONE additive member, 'dataset_records', and .kind gains exactly one, 'dataset' — packages/connectors/core/src/manifest.ts. packages/plugin-host/src/connector-family.ts gains a fourth family, 'dataset': always 1st-party (the DATA gate covers it, chat may read it, ADR 0048 D2/ §57/§58), never thirdPartyData — a member of this family is a category error if it is ever routed through the market-intel plane.

C2 — DatasetConnector, the base contract for every non-eCom-shaped 1st-party system

packages/connectors/core/src/dataset-connector.ts:

abstract class DatasetConnector {
  abstract readonly manifest: ConnectorManifest; // kind:'dataset', produces:['dataset_records']
  abstract authenticate(creds: ConnectorCredentials): Promise<void>;
  abstract healthCheck(): Promise<ConnectorHealth>;
  /** The source's own units of data (a sheet tab, an Odoo model, a ledger export). */
  abstract listSources(ctx: SyncContext): Promise<DatasetSourceDescriptor[]>;
  /** Rows of ONE source, as the flat {column: cell} grid the mapping template consumes. */
  abstract readSource(
    ctx: SyncContext,
    sourceKey: string,
    opts: DatasetReadOptions,
  ): Promise<DatasetSourceRead>;
  async refreshCredentials(creds: ConnectorCredentials): Promise<Record<string, string> | null> {
    return null;
  }
}

It produces GRIDS, never silver: the existing path — a per-source ImportTemplateSpec (buildDatasetSheetTemplate, ADR 0038 amendment (b)), applyTemplate, import_staging_rows, the dataset_record promoter, agg_org_dataset_period — stays the ONE ingest for tenant datasets (§49). The Google Sheets driver's dataset_record path is the reference implementation of this shape today; this ADR names the contract it already follows and gives a second implementer a type to satisfy, rather than a bespoke ETL script per connector.

Routing. DATASET_CONNECTOR_TYPES + isDatasetConnectorType sit beside MARKETING_CONNECTOR_TYPES, in the same lean module (packages/connectors/core/src/dataset-connectors.ts) and for the same reason: the worker's queue classifier must decide a connector type's family WITHOUT pulling the plugin registry into its hot path. A sync_dataset job name rides the EXISTING dataset queue (no new queue — the queue already exists for dataset.rollup.refresh/dataset.backfill, ADR 0040 D5); the worker driver is apps/worker/src/processors/sync-dataset.ts.

Google Sheets stays a marketing-family connector. Its manifest family is marketing and must stay that way — a marketing tenant reaches its marketing surfaces through exactly that entitlement — and its dataset_record tabs already ride the marketing processor's staging path (sheet-staging.ts). The dataset family is for connectors whose ONLY output is dataset grids; Google Sheets is deliberately ABSENT from DATASET_CONNECTOR_TYPES. See ADR 0008's amendment for the fuller statement of this split.

The closed-routing guard. Decision C2 names a class-of-bug audit, connector-family-routing-closed.py: every kind:'connector' plugin's providerId is a member of exactly one family routing list (MARKETING_CONNECTOR_TYPES / DATASET_CONNECTOR_TYPES / the marketplace and market-intel equivalents) AND has an implemented worker driver — closing the exact gap the investigation named ("routing by list membership, not by type"), turning it into a gate rather than a habit that has to be remembered per connector.

Plugin manifest. ReportSurface.requiresConnectorFamily needed real changes in three places to accept 'dataset': the literal union in editor-route-map.ts, the Zod enum in report-surface-schema.ts, and dropping the Exclude<…,'dataset'> in surface-gate.ts. No surface declares dataset yet, so until one does the field fails CLOSED (hidden), which is safe but not the same as "already accepted."

C3 — reference implementer: connector-odoo-hr

packages/connectors/odoo/ (package @yng/connector-odoo): Odoo JSON-RPC (/web/session/authenticate, /web/dataset/call_kw search_read) over hr.employee, hr.contract, hr.applicant, hr.leave, hr.attendance as sources; fixture-tested offline; defaultEnabled:false; in no shipped blueprint's plugins — listed under hr-workspace as optional once its manifest ships there (ADR 0048 D3 already states this: "connector-odoo-hr is not listed: its contract had not shipped, and a blueprint may not name a plugin the registry does not carry"). Live readiness is UNVERIFIED until a credentialed probe exists against a real Odoo instance — stated on the connector's own manifest doc exactly as ADR 0008 stated it for its Wave 2 connectors, never implied by the fixture tests passing. Secrets: api_key/session credentials envelope-encrypted like every connector (root invariant 4 / §4); never logged.

Alternatives considered#

  • A generic "any-API" connector, configured by JSON. Rejected: schema-on-read, no compile-time consumer — the SaaS-architect argument ADR 0020 already adopted against a config-driven connector layer. A connector's shape is a fact about the vendor's API, not something an admin form should be able to redefine at runtime.
  • Widening ApiConnector's produces to free strings. Rejected: it would make the admin sync-control vocabulary for the eCom family say nothing — the whole point of a closed enum is that every member has a real, typed consumer.
  • Routing dataset connectors through Cube. Rejected for the same reason ADR 0038 D5 rejected it for tenant datasets generally: a tenant dataset's schema changes at runtime, per org and per brand: moving ingest through Cube would also move tenancy enforcement from Postgres RLS to Cube's securityContext at exactly the moment the data gets sensitive (compensation-class fields, ADR 0038 D6).

Consequences#

  • A department-shaped system that is not eCom-shaped (HRM, ERP, accounting, a ledger export) has a real type to satisfy instead of a bespoke onboarding script per customer — the same promise ADR 0042 D2/D5 makes for the pack side, now made for the ingest side.
  • The worker's queue routing is closed and audited: a connector plugin with no family list membership or no driver fails a static gate, rather than silently never syncing.
  • Google Sheets keeps exactly one identity (marketing family) even though it is also how HR and finance data arrives — the family names WHO enforces the entitlement, not every surface the rows end up feeding.

Implementation status (declared 2026-09-10)#

This batch's docs were written CONCURRENTLY with the code (a disjoint-files split, per the programme's batch sequence); the table below reflects what this document's author could verify in the shared tree at write time, not a separate code review. Anything not directly verified is flagged.

Decision Status Evidence
C1 produces/kind additive members Landed (batch 3) packages/connectors/core/src/manifest.ts (kind: z.enum(['api','file','dataset']), produces gains 'dataset_records')
C1 connectorFamily gains 'dataset' Landed (batch 3) packages/plugin-host/src/connector-family.ts
C2 DatasetConnector base class Landed (batch 3) packages/connectors/core/src/dataset-connector.ts
C2 routing list + sync_dataset driver Landed (batch 3) packages/connectors/core/src/dataset-connectors.ts (DATASET_CONNECTOR_TYPES, isDatasetConnectorType); apps/worker/src/processors/sync-dataset.ts
C2 connector-family-routing-closed.py guard Landed (batch 3) scripts/audit/connector-family-routing-closed.py, wired into audit:all; confirmed passing (23 connector plugins: 16 routed, 7 deliberately unrouted)
C2 ReportSurface.requiresConnectorFamily accepts it Landed (batch 3) Required real changes in three places, not zero: the literal union in editor-route-map.ts, the Zod enum in report-surface-schema.ts, and dropping the Exclude<…,'dataset'> in surface-gate.ts — no surface declares dataset yet, so it fails CLOSED (hidden) until one does
C3 connector-odoo-hr implementer Landed (batch 3) packages/connectors/odoo/ (@yng/connector-odoo: client.ts, connector.ts, config.ts, sources.ts); fixture-tested offline in connector.test.ts
C3 live-readiness probe UNVERIFIED No credentialed probe against a real Odoo instance exists yet — stated as a live gap on the connector's manifest doc, not a claim this ADR makes
hr-workspace lists connector-odoo-hr as optional Not done this batch Out of this ADR's scope; a blueprint change once the connector's plugin manifest ships in plugin-host/registry.ts (excluded from this batch's touched files)

Note to the concurrent code worker (batch 3, Track A-2): this ADR was written against the tree state at commit time of this batch's docs pass, reading dataset-connector.ts, dataset-connectors.ts, sync-dataset.ts and packages/connectors/odoo/ as they existed at that moment — your work may still be in flight. If any of the following changed after this document was written, reconcile this ADR (file paths, the routing-guard status row, and the produces/kind member names) rather than treating it as frozen: the connector-family-routing-closed.py audit's exact location or name, whether sync_dataset ended up on the existing dataset queue or a new one, and whether connector-odoo-hr's manifest actually shipped (which would make the last table row obsolete).

Amendment — 2026-09-10: the BINDING step generalised past Google Sheets#

Batch 3 shipped DatasetConnector and connector-odoo-hr, but connectors.bindDatasetTab — the mutation that mints a mapping template and points a connector's dataset_record binding at it — stayed hardcoded to Google Sheets: its input schema carried a sheet-specific sheetRange (an A1 range), and four sibling procedures early-returned on connectorType !== 'google-sheets'. connector-odoo-hr could be created and synced (the worker driver landed in batch 3), but nobody could BIND an Odoo model to a dataset from /connectors — the contract had a producer and a consumer (the worker) but no way for an operator to wire the two together for a second transport. This amendment closes that gap.

What changed. bindDatasetTab's input field is now sourceKey (generic: an A1 range for Google Sheets, an Odoo model name for connector-odoo-hr, whatever a future transport's own source picker offers), and the four !== 'google-sheets' guards are gone. The seam is one adapter interface, DatasetBindingAdapter (apps/web/src/server/routers/connectors-dataset-binding.ts): label, sourceNoteVi, displayLabel(sourceKey), sameSource(a, b), listBindings(config), mergeBinding(config, sourceKey, templateId). DATASET_BINDING_ADAPTERS is typed Record<'google-sheets' | DatasetConnectorType, DatasetBindingAdapter> — a DATASET_CONNECTOR_TYPES member with no adapter here fails to COMPILE, the same closure discipline connector-family-routing-closed.py already enforces for queue routing, one layer up (a type, not a test). bindDatasetTab itself now reads: resolve the connector's adapter (BAD_REQUEST + unsupported_connector_type_for_dataset_binding when none exists), build the spec through the SAME buildDatasetSheetTemplate every transport has always shared, publish the template, adapter.mergeBinding the connector's config, validate (Google Sheets keeps its own broader validateSheetTemplateBindings — it covers non-dataset streams too; every other transport gets the adapter-generic validateDatasetSourceBindings), write, audit-log.

A new procedure, connectors.listDatasetSources, is the sniffSheetRange/sheetTabTitles twin for a DatasetConnector-family connector: decrypts the connector's credentials, authenticates, and calls listSources(ctx) — the exact call the router's binder and the worker's sync-dataset.ts both make against the contract. Phased the same way (brandOrchestratedProcedure, rate-limited, RLS phase to decrypt, external phase for the vendor call), same ADR 0007 demo-mode guard before any real request. pingConnector (the connectors page's "Test" button) gained an odoo-hr factory too: ApiConnector and DatasetConnector share the exact authenticate/healthCheck shape, so it is ONE Pingable structural interface and one factory map, not a third branch.

UI. dataset-tab-binder.tsx (Google Sheets) is UNCHANGED behaviourally — its sheetRange prop still reads an A1 range, it still calls sniffSheetRange, and it now calls bindDatasetTab with that value under the field name sourceKey. A new sibling, dataset-connector-source-binder.tsx, is the listDatasetSources-driven twin: pick a source from the live list, pick an EXISTING dataset (never a new one — listSources() returns column keys/labels but no sample ROWS, deliberately: an HR source's cells can be compensation-classified, connectors area map §44, so there is nothing here to profile a new schema from), map columns, bind. Both panels share their pure matching helpers (dataset-binder-shared.ts: autoMatch, packColumnMap, normalizeHeader) so the same header→field guess and the same pack-declared column map apply on either transport — one rule, not two copies drifting. Mounted on the connector card for any connectorType in DATASET_FAMILY_TYPES (picker-groups.ts, already the client-side mirror of DATASET_CONNECTOR_TYPES).

The template lineage identity did NOT change, on purpose. datasetTabSourceKind(datasetKey) still returns gsheet-dataset-<datasetKey> for EVERY transport, including an Odoo-bound tab. That prefix reads as sheets-specific, but it was already transport-neutral in effect: the lineage (import_mapping_templates versions on (org, brand, source_kind)) has only ever been keyed on the DATASET, never on which connector fed it — bindPackTabs and bindDatasetTab already shared one lineage per dataset before this amendment, and an Odoo source bound to the same dataset a sheet used to feed now republishes into that SAME lineage (version N+1), never a second competing one. Renaming the prefix to something transport-neutral (dataset-<key>) would cost a migration/backfill for a purely cosmetic identity string and zero functional change — rejected for that reason. The 7 live google-sheets bindings on the younet-hr production org are UNTOUCHED: same function, same input (datasetKey), same output. No migration, no backfill note needed — this is the "existing rows are untouched" outcome the programme's non-negotiables ask for, achieved by NOT changing the identity scheme rather than by adding a compatibility shim to one.

No capability widening. connector-odoo-hr is still defaultEnabled:false and still in no shipped blueprint's plugins — nothing in this amendment touches the plugin manifest, a blueprint, or org_blueprint_applications. The new procedures sit behind the SAME requireOrgCapability({capability: 'manage_connectors'}) gate every sibling procedure already carries; an org whose blueprint does not enable connector-odoo-hr has no such connector row to call listDatasetSources/bindDatasetTab against in the first place (NOT_FOUND, the same as today for any connector id outside the caller's org).

Live-credential probe. scripts/connectors/probe-odoo-hr.ts — authenticates against a real Odoo instance from environment variables only (ODOO_BASE_URL/ODOO_DATABASE/ODOO_LOGIN/ODOO_API_KEY, never a file, never a CLI arg), calls listSources() (the exact contract path), then — because listSources() alone never queries a FIELD, only mirrors ODOO_HR_SOURCES' static declaration back and tolerates a missing model by omitting its row-count hint rather than failing — runs a one-row search_read per declared source over its FULL declared field list, the read that actually proves every field the manifest promises exists on the instance. Prints source keys, the column names a passing read accepted, and row counts (from search_count) — never a cell value. Exits non-zero with a named reason on any mismatch. Not run against a real instance by this batch (no credentials were available, none were requested — root invariant 5 / §4 forbids asking); "LIVE READINESS UNVERIFIED" on connector-odoo-hr's manifest doc stands exactly as C3 declared it. This probe is what a later batch runs to flip that note.

Deliberately unchanged. connectors.bindPackTabs (bind every tab a pack declares in one action) stays Google-Sheets-only: it matches a pack's declared sheet.title against a workbook's real tab titles, a discovery mechanism a DatasetConnector's listSources() has no analogue of (there is no "workbook" to list titles from). Generalising it would need a second discovery contract this batch does not invent; bindDatasetTab/listDatasetSources is the one seam every transport shares today.

Amendment (a) — 2026-09-12: one connector, many domains#

A DatasetConnector serves as many product DOMAINS as its credential reaches, and an org activates each one separately (substrate design 7, docs/plans/vertical-industry-architecture-2026-09-substrate-design.md).

Manifest. pluginManifestSchema gains servesDomains: DomainKey[], additive and defaulted to [], declarable only on a kind: 'connector' plugin and only as registry keys (packages/plugin-host/src/manifest.ts). vertical keeps its catalog-grouping job unchanged; a connector declaring both must list its own vertical among its served domains. connectorServedDomains is the ONE reading: the explicit list, else [vertical], else nothing — so connector-odoo-hr declares ['hr'] and connector-google-sheets, which states no vertical on purpose, offers no activation.

Descriptors. DatasetSourceDescriptor gains domain?: string (packages/connectors/core/src/dataset-connector.ts's listSources contract, typed in core/src/types.ts). Unset means "the connector's only domain", so every shipped descriptor keeps its meaning; connectors.listDatasetSources applies that default once, server-side, and returns the connector's servedDomains beside the sources. readSource and the grid path onward are unchanged — the one ingest for tenant datasets does not branch on domain (§49).

Activation. connectors.activateDomain (org-capability manage_connectors, Zod input, rate limited) refuses a domain the connector does not serve (refuseUnservedDomain, a pure decision) and otherwise calls activateDomainLayer (org-blueprints/apply.ts) — the ONE writer of org_domain_activations, shared with the blueprint apply. It writes one domain layer with source_blueprint_key = NULL at the next sequence and installs that domain's packs through the existing propose->confirm flow. Two domains from one credential are TWO activation rows and ONE connector_credentials row: nothing here writes a credential, so connector_credentials_active_source_uq (root invariant 4) is untouched. No nav write: the sidebar folds the stored stack on every read (nav-grants.ts).

The warehouse domain's pack ships as data: apps/web/src/server/dataset-packs/warehouse-ops.json (v1, vertical: 'warehouse') — stock by location and SKU, reorder point and safety stock, pick accuracy, on-time delivery, backorder rate, outsourced logistics cost per order, and inter-warehouse movement, over three record datasets and two derived ones. Every stock measure reaches a card through period_end, never a sum (design doc R3). verticals.ts warehouse.packs = ['warehouse-ops']; the pack is registered in repo-packs.ts and in the dataset-pack-registry-validity.ts baseline, and no org installs it.

Guards. apps/web/src/__tests__/connector-serves-domains.test.ts (14): every shipped manifest parses unchanged, a non-registry domain and a feature-plugin declaration are both refused, the descriptor default resolves one way only, the refusal fires in both directions, and one credential's two domains fold as two layers carrying both packs. dataset-pack-registry-validity.ts, dataset-stock-flow-reduction.py and measure-entity-declared.py cover the pack; connector-family-routing-closed.py is unaffected — a connector serving several domains still rides exactly one family.