Compound · database sync · on AlchemyBridge

High-frequency Double One-Way asymmetric database synchronization — the SymmetricDS replacement with no triggers and no JVM: cursor-based polling over masked views, positional catalog with schema versioning, hyper-compressed msgpack envelope and idempotent at-least-once delivery. All from config + rules.

2one-way channels: A (Tx→Non-Tx reporting) · B (Non-Tx→Tx updates)
15DB engines (RDBMS+NoSQL+OLAP) via db-plugins — source and target decoupled
~50SymmetricDS sym_* tables that disappear: state is ONE table (speculum_state)
136+green asserts (codec + 7 E2E suites: loop, 10k volume, heterogeneous, Windows, .nap, bidirectional)
142bytes/row on the wire (measured) — 2.1× smaller than named JSON; ~1,100-1,300 rows/s in the lab
0lines of bespoke code — rules + catalog + 2 Lua helpers of the compound

The extraction cycle (channel A or B — the same rule)

Native scheduler
tick · overlap:skip · parametry in the payload
→
Cursor + tiebreak
speculum_state · cursor_column$gte
→
Masked view
PCI · Zero-Compute Reads · epoch
→
Positional codec
order (ts,pk) · squash by PK · coercions
→
msgpack envelope
window-ready · Offset/WindowSeqID
→
@send to the peer
200 ⇒ and ONLY then ⇒ the cursor advances

The extract_window rule is GENERIC: node, channel, entity, catalog, peer and window size arrive in the scheduled_task payload — a deployment decision, never baked into the package. Any failure (catalog, DB, encode, network, status ≠ 200) leaves the cursor where it was: the next tick retransmits.

The wire — catalog-driven hyper-compression

# Window (msgpack, positional — no field names on the hot path) [ MAC, NodeID, WindowSeqID, N, [events] ] // MAC="" in Phase 1 (ArcanumVault HMAC = Phase 2) # Event [ Offset, entity_id, schema_version, Op, Timestamp, [payload] ] // Op: 1=upsert · 2=delete # payload = array of values in the catalog's positional ORDER

The catalog declares, per entity and schema version, the positional map and the per-field coercion. The target resolves (entity_id, schema_version) against ITS copy and reconstructs names+types → a DB deploy bumps the version and both ends coexist (zero-downtime, no schema drift).

In-flight coercions (config-driven)

PASS_THROUGH

no changes — types already optimal

CAST_STRICT

alphanumeric → numeric: compresses amounts/ids stored as text

FORCE_STRING

serializes as text — never truncates leading zeros (BINs, codes)

CONVERT_EPOCH

DATETIME → Int64 UNIX (~24B→8B) with a deterministic UTC inverse (exact round-trip on any host)

Delivery — at-least-once today, additive exactly-once tomorrow

Never loses

the fetch re-reads the cursor edge ($gte) and the tiebreak by PK filters out what was already emitted; full window ⇒ empty tiebreak ⇒ the next tick re-reads the WHOLE edge (may duplicate ONCE, never skips).

Idempotent by PK

the target applies upsert/delete by PK: the duplicate is absorbed. The squash collapses N versions of a PK down to the latest within the window.

Window-ready from day 1

every envelope already emits monotonic Offset/WindowSeqID; the receiver knows first/last_offset.

ACK (next phase, additive)

consume ACKs per offset → acked_offset → atomic retransmission from the point of failure. New columns in speculum_state, the wire format does not change.

PCI isolation by design

Transactional core (CDE)
sensitive data NEVER leaves
→
Thin masked views
the engine masks · no UDFs (predicate pushdown intact)
→
Reporting repos
controlled mirror of the CDE

Speculum reads EXCLUSIVELY through the views: masking happens inside the source engine. Channel B travels separately (updates/config towards the Core) — two independent flows, never a bidirectional link with locks.

Zero bespoke code

All from config + rules over existing directives: @DbFindRowsSorted (range col$op + order + limit), @DbFindRow/@DbInsertRow/@DbUpdateRow, @Concat, @CodecEncode(msgpack), @send and the native scheduler. What was added to the engine —generic and reusable— was engine.function_libs: Lua libraries that travel WITH the compound and whose functions become invocable as @functions from the rules (the positional-codec helpers, with no builtins in the core).

Two modes, three packages — distribution without recompiling

READER mode

reads updates from ITS OWN database by cursor and emits them as msgpack windows — the host activates it with scheduled_tasks + its connections. Libs are multi-variant: OPTIONAL source + .ljbc/.luac54/.luac55 — the loader picks per runtime; opaque (--no-source) = declaring supported runtimes. Auditable contract: nap variants (supported runtimes) + pack coherence (stale variant = FAIL). Tested on ALL engines (19/19).

WRITER mode

receives windows and applies them ATOMICALLY (@DbTx: one bad event = the whole window rolls back and the emitter retransmits)

3 · signed .nap

speculum-common (helpers+catalog+schema) + speculum-reader + speculum-writer, Ed25519 — any AlchemyBridge mounts common + its mode(s) and acquires the sync without recompiling; tampered or unverified does NOT start

True Double One-Way

each end runs BOTH modes for opposite channels: channel-A reader + channel-B writer next to the Core — and the mirror image on the other side

Bidirectional without loops — model: node_ts

A creates the row
origin NULL → it travels
→
B's writer applies it
and STAMPS the origin (the envelope's NodeID)
→
B's reader sees it…
foreign origin ⇒ does NOT send it back
✕
Loop DEAD
the cursor advances anyway (echoes-skipped)

The SAME table can receive updates from both sides: origin column mappable per entity (corporate naming rules), (origin, cursor) index in that order, and per-table model (ts default · node_ts · extensible). A later local edit travels again. Tested with two instances and writers on both sides: identical convergence and full quiescence with nothing circulating. The echo is cut; CONFLICTS (same PK edited on both sides at once) are a separate policy.

Status and roadmap

✅ H1 catalog + speculum_state ✅ H2a positional codec (36/36) ✅ H2b extract_window (20/20) ✅ H3 apply_window — atomic window @DbTx (full loop 19/19) ✅ 10k volume (11/11) · 142 B/row on the wire ✅ H4 heterogeneous pg→linux/arm64→amd64→mysql (19/19) ✅ Windows arm64→emulated amd64 (7/7) — 3-OS matrix ✅ Distribution 3 .nap reader/writer/common (19/19) ✅ Bidirectional node_ts anti-echo (11/11) ✅ Adaptive pacing: calendar + load (16+13) ✅ RDBMS→NoSQL: postgres→MongoDB document store (11/11) ⏳ W1 exactly-once ACK (additive) · ClickHouse (OLAP) ⏭️ Phase 2: NNG · HMAC (ArcanumVault)