This repository was archived by the owner on May 19, 2026. It is now read-only.
core: harden deterministic contracts and public API surface#13
Merged
Conversation
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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
Hardens the TradingChassis Core baseline by making key deterministic contracts explicit across Strategy boundaries, Market Events, Order Lifecycle handling, Runtime/Core obligations, and the public API surface.
This change introduces a read-only
StrategyStateViewfor Strategy evaluation, formalizes the current book-onlyMarketEventreduction contract, adds explicit terminal Order Lifecycle canonical Events, clarifies Runtime/Core feedback obligations, and locks/classifies the public Core API surface through docs and tests.Motivation
Why is this change necessary?
Core is intended to be a deterministic standalone package with clear boundaries between Core and Runtime. Several contracts were previously implicit or under-specified:
StrategyState.MarketEventallowed trade-shaped payloads even though canonical reduction was book-only.This PR hardens those contracts without broad Runtime changes or large architectural refactors.
Type of Change
Technical Details
Describe key implementation decisions.
StrategyStateViewand wired Strategy contexts so Strategy evaluators receive a read-only State view instead of the live mutableStrategyState.context.stateshape while changing the object exposed through it to a read-only view.MarketEventcanonical reduction contract as book-only.MarketEvent(event_type="trade")remains constructible at the schema level.MarketEvents are explicitly rejected by canonical reduction.OrderCanceledEventOrderRejectedEventOrderExpiredEventCoreStepResult.dispatchable_intents.ControlSchedulingObligationis a non-canonical output and must be realized later asControlTimeEvent.OrderExecutionFeedbackEventis account-level feedback, not aFillEventreplacement.Determinism & Reproducibility
The changes make deterministic boundaries more explicit. State mutation remains owned by Core reducers and Execution Control. Strategy evaluation now receives a read-only State view, and Runtime/Core feedback obligations are documented as canonical Event contracts.
Performance Impact
No performance-oriented changes were introduced. The
StrategyStateViewadds read-only boundary protection at Strategy evaluation time; no benchmark-relevant hot-path optimization was part of this PR.Tests
Added/updated tests cover:
MarketEventreduction contract,MarketEventrejection,OrderExecutionFeedbackEventaccount-only behavior,ControlSchedulingObligationnon-canonical behavior,Validation performed:
Breaking Changes
CoreStepStrategyContext.stateandCoreWakeupStrategyContext.statenow exposeStrategyStateViewinstead of the live mutableStrategyState.Migration impact:
context.state, called reducer methods, accessed queue/inflight internals, or relied on mutableStrategyStatemethods must be updated.StrategyStateViewand return Intents.Other notes:
MarketEvents are still constructible but are explicitly unsupported for canonical reduction in the current Core baseline.Checklist