Skip to content

Fix cross-instance nondeterminism in order matching callbacks and add deterministic replay coverage#24

Merged
geseq merged 6 commits into
mainfrom
copilot/add-coverage-for-determinism
May 11, 2026
Merged

Fix cross-instance nondeterminism in order matching callbacks and add deterministic replay coverage#24
geseq merged 6 commits into
mainfrom
copilot/add-coverage-for-determinism

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 11, 2026

  • Review unresolved PR comments and confirm required fixes
  • Run existing build/tests to capture baseline status before edits
  • Apply minimal fixes for review comments in determinism and orderbook tests
  • Re-run build/tests to verify no regressions
  • Run parallel code review and CodeQL validation

…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>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 (no static locals capturing this).
  • Add new test/determinism_test.cpp with multi-instance determinism, midpoint split/replay, and interleaved multi-market coverage.
  • Update test/orderbook_test.cpp includes 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 thread test/determinism_test.cpp Outdated
Comment on lines +276 to +280

int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
Comment thread test/determinism_test.cpp
Comment on lines +1 to +9
#include <gtest/gtest.h>

#include <algorithm>
#include <cstdint>
#include <tuple>
#include <vector>

#include "util.cpp"

Comment thread test/orderbook_test.cpp
Comment on lines 1 to 8
#include <gtest/gtest.h>

#include <cstdint>
#include <string>
#include <tuple>
#include <vector>

#include "util.cpp"
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comment thread test/orderbook_test.cpp
#include <cstdint>
#include <memory>
#include <string>
#include <tuple>
@geseq geseq marked this pull request as ready for review May 11, 2026 17:29
@geseq geseq merged commit be0ae6b into main May 11, 2026
6 checks passed
@geseq geseq deleted the copilot/add-coverage-for-determinism branch May 11, 2026 17:29
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.

3 participants