Add the source-aligned CDC template, and key the canonical template's topics

The first template of the source-aligned family: one data product per source
system, capturing a database by CDC and turning what it emits into what a
canonical product accepts. It runs on the Integration Bus, not in a domain, and
is deployed with the `data-bus` CLI.

What it produces, and what its tests hold it to: raw topics in the source's own
shape; deterministic identity, so a re-snapshot upserts rather than duplicating;
validation against the canonical product's rules before publishing, with what
fails going to the product's own dead-letter topic with the reason; keying by the
canonical identifier; provenance in headers; and an archive in the bus object
store that can be replayed back onto the raw topic.

The worked example captures an ERP customer table and delivers into Canonical
Party in the digital-core domain: 12 smoke checks, 37 unit tests, including a
poison record that is quarantined while the next record still arrives.

The canonical template's topics now declare the key producers must set, which is
the other half of that contract.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
paulandClaude Opus 5 committed 2026-09-18 10:54:39 +12:00
1 parent ca6bea351a
commit 866bcfe238
44 files changed
+2505 -11

No files matched your search

@@ -0,0 +1,27 @@
-- The ERP's customer table, as the ERP wrote it: its own names, its own codes, its own key.
-- A source-aligned product never asks a source system to change; this is what it is given.
CREATE TABLE {{source_schema}}.{{source_object}} (
id integer PRIMARY KEY,
cust_name text, -- the ERP allows this to be empty; Party does not
cust_type char(1), -- I = individual, O = organisation
status_code text, -- A active, P prospect, S suspended, I inactive, C closed
birth_date date, -- individuals only
trading_name text, -- organisations only
updated timestamptz DEFAULT now()
);
COMMENT ON TABLE {{source_schema}}.{{source_object}} IS 'ERP customers. Captured by the {{product_name}} source-aligned data product.';
-- Four rows that map cleanly, and two that must not: a source system always has both.
INSERT INTO {{source_schema}}.{{source_object}} (id, cust_name, cust_type, status_code, birth_date, trading_name) VALUES
(1, 'Ada Lovelace', 'I', 'A', DATE '1815-12-10', NULL),
(2, 'Grace Hopper', 'I', 'P', DATE '1906-12-09', NULL),
(3, 'Semprini Holdings Ltd','O', 'A', NULL, 'Semprini'),
(4, 'Northwind Trading Co', 'O', 'C', NULL, 'Northwind'),
(5, 'Bad Status Ltd', 'O', 'Z', NULL, NULL), -- Z is not a Party Status
(6, 'Bad Type Ltd', 'X', 'A', NULL, NULL); -- X is neither I nor O
-- Debezium replicates by logical decoding and needs the whole row, not just the key, to
-- publish updates and deletes the transform can read.
ALTER TABLE {{source_schema}}.{{source_object}} REPLICA IDENTITY FULL;