Skip to content

refactor(core): establish clean deterministic Core package baseline#9

Merged
bxvtr merged 53 commits into
mainfrom
implementation/semantics
May 15, 2026
Merged

refactor(core): establish clean deterministic Core package baseline#9
bxvtr merged 53 commits into
mainfrom
implementation/semantics

Conversation

@bxvtr
Copy link
Copy Markdown
Contributor

@bxvtr bxvtr commented May 15, 2026

Summary

Refactored tradingchassis_core into a clean standalone deterministic Core package baseline.

The Core package now centers on one explicit pipeline:

EventStreamEntry
process_event_entry / process_canonical_event
→ Strategy Evaluator
→ generated Intents
→ CandidateIntentRecords
→ dominance / reconciliation
→ Policy Admission
→ ExecutionControl plan/apply
CoreStepResult.dispatchable_intents

Runtime dispatch remains outside Core.

This change removes legacy compatibility paths, cleans the public API, hardens tests and typing, improves package metadata/docs, adds a Core-only quickstart, and updates run_core_wakeup_step to reduce all events first and evaluate Strategy once on the final wakeup state.

Motivation

This change is necessary to make tradingchassis_core a clear, standalone decision-engine package instead of a mixed transitional Core/Runtime/legacy compatibility layer.

The goal is to provide a deterministic trading decision kernel that can be shared across backtest, simulation, research, and live Runtime environments. Runtime-specific concerns such as venue I/O, dispatch, Kubernetes/infrastructure, credentials, and adapter behavior stay outside Core.

The refactor reduces ambiguity, removes unused or legacy compatibility concepts, and strengthens Backtest/Live Parity by ensuring the same deterministic decision pipeline is used regardless of surrounding Runtime infrastructure.

Type of Change

  • Bug fix
  • New feature
  • Performance improvement
  • Refactor
  • Documentation
  • Breaking change

Technical Details

Key implementation decisions:

  • Removed legacy GateDecision / compat_gate_decision compatibility paths from the active Core API.
  • Removed legacy queue/gate compatibility contexts such as ControlTimeQueueReevaluationContext and CoreDecisionContext.
  • Removed snapshot-era OrderStateEvent lifecycle and related schema artifacts.
  • Removed stale JSON schema contracts and made Pydantic models the Core contract source of truth.
  • Refactored RiskEngine into a policy-only component.
  • Kept ExecutionControl responsible for queue/rate/inflight/sendability and ControlSchedulingObligation derivation.
  • Renamed/reworked old venue-policy concepts into Core-owned execution constraints terminology.
  • Cleaned public root exports in tradingchassis_core.__init__.
  • Added/updated public exports for canonical events, CoreStep/CoreWakeupStep APIs, intents, decision/result models, ExecutionControl, RiskEngine, and utilities.
  • Added a runnable Core-only quickstart using public imports only.
  • Hardened the package around pytest, mypy, build/install, and import validation.
  • Updated run_core_wakeup_step semantics:
    • Runtime supplies an ordered batch of EventStreamEntry values.
    • Core reduces all entries in order.
    • Strategy evaluates exactly once on the fully reduced wakeup state.
    • Policy Admission and ExecutionControl run once.
    • One CoreStepResult is returned.
  • Added CoreWakeupStrategyContext and CoreWakeupStrategyEvaluator.
  • Clarified ControlTimeEvent / ControlSchedulingObligation semantics:
    • Rate-limit deferral is time-dependent and may produce a scheduling obligation.
    • Inflight deferral is feedback-dependent and does not automatically produce a scheduling obligation.
  • Rewrote package documentation, README, CHANGELOG, CONTRIBUTING, SECURITY, and Core docs for the clean package baseline.
  • Reset the changelog to the new clean Core package baseline.

Determinism & Reproducibility

  • Change preserves deterministic behavior
  • Tests confirm reproducibility
  • No hidden state introduced

The Core pipeline remains deterministic. ProcessingPosition and ordered EventStreamEntry values define event order. run_core_wakeup_step now provides stronger deterministic batch semantics by reducing all entries before a single Strategy evaluation and single decision pass.

Performance Impact

  • No measurable impact
  • Benchmarks included
  • Performance improvement

No dedicated benchmarks were added. The refactor focuses on architecture, API cleanup, determinism, typing, tests, and package readiness.

Tests

  • Unit tests added/updated
  • Integration tests added/updated
  • Existing tests pass

Validation performed across the cleaned Core package included:

  • Core-only quickstart execution
  • pytest suite
  • mypy validation
  • package import validation
  • package build validation, except where local file ownership/build artifacts blocked build in one environment

Test coverage now includes:

  • public API exports
  • clean CoreStep pipeline
  • clean CoreWakeupStep final-state semantics
  • CandidateIntentRecord / dominance behavior
  • Policy Admission acceptance/rejection
  • ExecutionControl dispatchability/deferral
  • ControlSchedulingObligation semantics
  • quickstart behavior
  • no Runtime/hftbacktest dependency in Core package source

Breaking Changes

This is intentionally a breaking cleanup.

Removed or no longer supported as Core API:

  • GateDecision
  • compat_gate_decision
  • legacy decision bridge behavior
  • RiskEngine.decide_intents
  • ControlTimeQueueReevaluationContext
  • CoreDecisionContext
  • snapshot-era OrderStateEvent lifecycle
  • legacy JSON schema artifacts
  • old strategy/runtime compatibility modules
  • venue-adapter-style Core abstractions

External consumers relying on legacy Core compatibility APIs must migrate to the clean CoreStep/CoreWakeupStep API:

  • use canonical EventStreamEntry inputs
  • use run_core_step for single entries
  • use run_core_wakeup_step for ordered wakeup batches
  • provide Strategy Evaluators explicitly
  • provide Policy Admission and ExecutionControl contexts when dispatchable outputs are needed
  • consume CoreStepResult.dispatchable_intents
  • dispatch externally in Runtime, not in Core

Checklist

  • Code follows project style guidelines
  • Self-review completed
  • Documentation updated (if needed)

bxvtr added 30 commits May 6, 2026 13:04
bxvtr added 23 commits May 14, 2026 13:21
@bxvtr bxvtr self-assigned this May 15, 2026
@bxvtr bxvtr merged commit b6ea65d into main May 15, 2026
1 check passed
@bxvtr bxvtr deleted the implementation/semantics branch May 15, 2026 13:16
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