feat: settlement-journal SBE schema (id=3) + journal constants#120
Merged
Conversation
Adds the wire schema for the per-node settlement journal: a recorded Aeron publication carrying every trade + every terminal order status, written from the deterministic service thread. This is schema-only (id=3, package com.match.infrastructure.journal.generated, distinct from the order-schema codecs) plus the journal's stream/channel/port constants; the journal writer itself lands separately. - match-common/src/main/resources/sbe/settlement-journal-schema.xml: JournalTrade (id=1) and JournalTerminal (id=2) messages, carrying egressSeq as the log-position order key (sparse, non-unique). - match-common/pom.xml: second SbeTool execution to codegen the new schema into src/main/java (committed-generated, per convention). - InfrastructureConstants: SETTLEMENT_JOURNAL_STREAM_ID, SETTLEMENT_JOURNAL_CHANNEL, JOURNAL_ARCHIVE_CONTROL_PORT_OFFSET. - JournalSchemaRoundTripTest: encode/decode round-trip for both messages via the real MessageHeaderEncoder/Decoder. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
match-common/src/main/resources/sbe/settlement-journal-schema.xml:sbe:messageSchemaid=3, version=1, semanticVersion "0.1", packagecom.match.infrastructure.journal.generated(deliberately distinct fromcom.match.infrastructure.generatedso the new codecs cannot collide with the order-schema codecs). Mirrors themessageHeadercomposite fromorder-schema.xml. Adds aBooleanTypeenum (uint8 FALSE=0/TRUE=1) since order-schema has no reusable boolean idiom to mirror (it uses theOrderSideenum for direction and raw uint8 for flags).JournalTrade(id=1): egressSeq, tradeId, marketId, takerOrderId, takerUserId, makerOrderId, makerUserId, price, quantity, takerIsBuy, timestamp. One entry per trade execution, tradeId-dense in engine order.JournalTerminal(id=2): egressSeq, orderId, userId, marketId, status (TerminalStatus: FILLED=2/CANCELLED=3/REJECTED=4), timestamp. Terminal statuses only; consumers release the order's residual hold; unknown orders are a no-op.match-common/pom.xml: secondexec-maven-plugin/SbeTool execution (generate-sbe-settlement-journal) generating from the new schema intosrc/main/java, mirroring the existinggenerate-sbeexecution.InfrastructureConstants:SETTLEMENT_JOURNAL_STREAM_ID(4001),SETTLEMENT_JOURNAL_CHANNEL(aeron:ipc?term-length=64m),JOURNAL_ARCHIVE_CONTROL_PORT_OFFSET(10, giving 9010/9110/9210 for nodes 0/1/2 alongside the consensus archive's offset=1), with a comment explaining the settlement journal is a per-node, disk-backed second archive on a money-loss surface, designed to be lossless by construction.match-common/src/main/java/com/match/infrastructure/journal/generated/are committed, per this repo's convention for SBE-generated sources.JournalSchemaRoundTripTest: encodes/decodesJournalTrade(both taker-buy and taker-sell) andJournalTerminal(all three terminal statuses) through the realMessageHeaderEncoder/MessageHeaderDecoder, asserting every field round-trips, including a realistic largeegressSeqnearLong.MAX_VALUE.Test plan
mvn -pl match-common package -DskipTests— generates the new codecs cleanly, no collisions with the existing order-schema package.mvn -pl match-common test— 172/172 tests green, including the 4 newJournalSchemaRoundTripTestcases.mvn -pl match-cluster -am test -Dtest=DeterminismCorpusTest -Dsurefire.failIfNoSpecifiedTests=false— 54/54 green, confirming no cross-schema interference with the cluster's determinism corpus.🤖 Generated with Claude Code