Fix cross-instance nondeterminism in order matching callbacks and add deterministic replay coverage#24
Merged
Merged
Conversation
Agent-Logs-Url: https://github.com/geseq/cpp-orderbook/sessions/39161e46-dfa5-4aa5-bd63-791f5f7f951c Co-authored-by: geseq <5458743+geseq@users.noreply.github.com>
Agent-Logs-Url: https://github.com/geseq/cpp-orderbook/sessions/39161e46-dfa5-4aa5-bd63-791f5f7f951c Co-authored-by: geseq <5458743+geseq@users.noreply.github.com>
…or interleaved/midpoint replay paths Agent-Logs-Url: https://github.com/geseq/cpp-orderbook/sessions/6250214d-2e8b-4074-a54f-6f5e322cfefe Co-authored-by: geseq <5458743+geseq@users.noreply.github.com>
Agent-Logs-Url: https://github.com/geseq/cpp-orderbook/sessions/e32f7d1c-6fe3-42f9-b4b8-fae6bcce69e3 Co-authored-by: geseq <5458743+geseq@users.noreply.github.com>
Agent-Logs-Url: https://github.com/geseq/cpp-orderbook/sessions/e32f7d1c-6fe3-42f9-b4b8-fae6bcce69e3 Co-authored-by: geseq <5458743+geseq@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Fixes cross-instance nondeterminism in the order matching callbacks by removing static lambdas that capture this, and adds a dedicated determinism test suite to validate identical execution traces/state across multiple interleaved OrderBook instances (including split-point replay validation).
Changes:
- Fix
OrderBook::processOrder()callback binding to be per-instance (nostaticlocals capturingthis). - Add new
test/determinism_test.cppwith multi-instance determinism, midpoint split/replay, and interleaved multi-market coverage. - Update
test/orderbook_test.cppincludes to support moved/expanded test utilities.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
include/orderbook.hpp |
Removes static local lambdas capturing this in processOrder() to prevent cross-instance callback/state leakage. |
test/determinism_test.cpp |
Adds new determinism-focused tests (trace/state equality, midpoint split replay, multi-book interleaving). |
test/orderbook_test.cpp |
Adjusts includes (test scaffolding moved/expanded). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+276
to
+280
|
|
||
| int main(int argc, char** argv) { | ||
| ::testing::InitGoogleTest(&argc, argv); | ||
| return RUN_ALL_TESTS(); | ||
| } |
Comment on lines
+1
to
+9
| #include <gtest/gtest.h> | ||
|
|
||
| #include <algorithm> | ||
| #include <cstdint> | ||
| #include <tuple> | ||
| #include <vector> | ||
|
|
||
| #include "util.cpp" | ||
|
|
Comment on lines
1
to
8
| #include <gtest/gtest.h> | ||
|
|
||
| #include <cstdint> | ||
| #include <string> | ||
| #include <tuple> | ||
| #include <vector> | ||
|
|
||
| #include "util.cpp" |
Agent-Logs-Url: https://github.com/geseq/cpp-orderbook/sessions/5c7b4556-fcf4-4c84-88c9-bf03728728a9 Co-authored-by: geseq <5458743+geseq@users.noreply.github.com>
| #include <cstdint> | ||
| #include <memory> | ||
| #include <string> | ||
| #include <tuple> |
geseq
approved these changes
May 11, 2026
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.
Uh oh!
There was an error while loading. Please reload this page.