feat(archive): accept control-plane snapshot tables and policy source_cursor - #64
Conversation
…_cursor - strategy_data.market_identity + strategy_data.symbol_mapping DDL and SUPPORTED_TABLES entries (FIET-905 emitter rows) - source_cursor column on policy_evaluation_events with idempotent startup migration (ensureArchiveSchema applies ALTER ... IF NOT EXISTS) - contract fixture synced byte-for-byte with the emitter repo - unit + ClickHouse integration coverage incl. old-shape migration path
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
📜 Recent review details🧰 Additional context used🪛 ast-grep (0.44.1)test/clickhouse-schema.integration.test.ts[error] 502-510: Avoid SQL injection (sql-injection-typescript) 🔇 Additional comments (6)
WalkthroughThe ClickHouse strategy schema now stores policy provenance cursors and identity/routeability snapshots. Archive-forwarder support, schema initialization, fixtures, cleanup, migrations, and persistence tests are updated for the new tables and fields. ChangesStrategy archive support
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant ArchiveBatch
participant ArchiveForwarder
participant ClickHouse
ArchiveBatch->>ArchiveForwarder: submit policy and snapshot rows
ArchiveForwarder->>ClickHouse: archive grouped rows
ClickHouse-->>ArchiveForwarder: persist source_cursor and source_hash
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Companion to usherlabs/fiet-maker#678 — must merge and deploy before (or together with) it.
fiet-maker#678 starts emitting three row shapes the forwarder cannot accept today:
strategy_data.policy_evaluation_eventsrows stamped with a newsource_cursorcolumn (block:<n>:log:<i>replay provenance). Without the column, the JSONEachRow insert fails the whole per-table group for any batch containing a cursor-stamped row — taking down the existing policy-clock stream, not just the new data.strategy_data.market_identityandstrategy_data.symbol_mapping(FIET-905 control-plane snapshots), currently rejected as unsupported tables.Changes
schema/clickhouse/strategy_data.sql:source_cursorcolumn onpolicy_evaluation_eventsplus an idempotentALTER TABLE … ADD COLUMN IF NOT EXISTS—ensureArchiveSchemaapplies it at startup, so existing deployments migrate on the next forwarder restart with no manual DDL. NewCREATE TABLEs formarket_identity(ORDER BY (canonical_core_pool_id, event_time_ms)) andsymbol_mapping(ORDER BY (exchange, trading_pair, event_time_ms)), following the sibling tables' provenance block and partitioning.services/archive-forwarder/types.ts: the two new tables added toSUPPORTED_TABLES.source_cursor).ensureArchiveSchema→ column present) and for inserting + querying all three row shapes end to end.Verification
Full
bun testwith the compose ClickHouse up: 416 pass / 0 fail (integration suite executed against a live ClickHouse, not skipped; focused run 6 pass / 0 fail).biome checkclean on changed files.Rollout
Summary by CodeRabbit
New Features
Bug Fixes
Tests