Skip to content

feat: settlement-journal SBE schema (id=3) + journal constants#120

Merged
emrebulutlar merged 1 commit into
mainfrom
feat/settlement-journal-schema
Jul 9, 2026
Merged

feat: settlement-journal SBE schema (id=3) + journal constants#120
emrebulutlar merged 1 commit into
mainfrom
feat/settlement-journal-schema

Conversation

@emrebulutlar

Copy link
Copy Markdown
Member

Summary

  • Adds the wire schema for the per-node settlement journal: a recorded Aeron publication that will carry every trade + every terminal order status, written from the deterministic service thread. This PR is schema/codegen/constants ONLY — the journal writer itself lands separately.
  • New match-common/src/main/resources/sbe/settlement-journal-schema.xml: sbe:messageSchema id=3, version=1, semanticVersion "0.1", package com.match.infrastructure.journal.generated (deliberately distinct from com.match.infrastructure.generated so the new codecs cannot collide with the order-schema codecs). Mirrors the messageHeader composite from order-schema.xml. Adds a BooleanType enum (uint8 FALSE=0/TRUE=1) since order-schema has no reusable boolean idiom to mirror (it uses the OrderSide enum 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: second exec-maven-plugin/SbeTool execution (generate-sbe-settlement-journal) generating from the new schema into src/main/java, mirroring the existing generate-sbe execution.
  • 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.
  • Generated codecs under match-common/src/main/java/com/match/infrastructure/journal/generated/ are committed, per this repo's convention for SBE-generated sources.
  • New JournalSchemaRoundTripTest: encodes/decodes JournalTrade (both taker-buy and taker-sell) and JournalTerminal (all three terminal statuses) through the real MessageHeaderEncoder/MessageHeaderDecoder, asserting every field round-trips, including a realistic large egressSeq near Long.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 new JournalSchemaRoundTripTest cases.
  • 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

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>
@emrebulutlar
emrebulutlar merged commit 840ae77 into main Jul 9, 2026
2 checks passed
@emrebulutlar
emrebulutlar deleted the feat/settlement-journal-schema branch July 9, 2026 23:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant