Skip to content

Commit 69b0e57

Browse files
authored
feat(core): harden by removing confirmed dead code, narrow exports, and use consistent termonology (#10)
Co-authored-by: bxvtr <bxvtr@users.noreply.github.com>
1 parent b6ea65d commit 69b0e57

37 files changed

Lines changed: 770 additions & 303 deletions

.github/pull-request-template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Describe key implementation decisions.
2323

2424
- [ ] Change preserves deterministic behavior
2525
- [ ] Tests confirm reproducibility
26-
- [ ] No hidden state introduced
26+
- [ ] No hidden State introduced
2727

2828
## Performance Impact
2929

CHANGELOG.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,34 @@ This changelog starts from the clean Core package baseline.
44

55
## [Unreleased]
66

7+
### Removed
8+
9+
- `StrategyState.pop_queued_intents` (unused; Execution Control uses per-order queue helpers).
10+
- `fold_event_stream_entries` and root export (use `process_event_entry` in order).
11+
- Unused telemetry models in `core/events/events.py`.
12+
- Unused `combine_candidate_intents` helper.
13+
- Root exports for Execution Control apply detail types and `apply_execution_control_plan` (internal Execution Control apply stage).
14+
715
### Added
816

917
- Deterministic `run_core_step` and `run_core_wakeup_step` architecture.
10-
- CoreWakeupStep final-state Strategy evaluation: reduce all entries, then `CoreWakeupStrategyEvaluator` once.
18+
- CoreWakeupStep final Strategy evaluation: reduce all entries, then `CoreWakeupStrategyEvaluator` once.
1119
- Canonical Event input models and `EventStreamEntry`/`ProcessingPosition`.
12-
- Intent candidate record pipeline with dominance/reconciliation.
20+
- Intent Pipeline candidate records with dominance/reconciliation.
1321
- Risk Engine (policy-only) admission and Execution Control plan/apply integration.
1422
- `CoreStepResult.dispatchable_intents` and `ControlSchedulingObligation` outputs.
1523
- Core-only quickstart example and focused semantics test coverage.
24+
- Root export of `PolicyIntentEvaluator` and documentation of extension points vs convenience implementations.
25+
- Pipeline integration tests for `RiskEngine` as `policy_evaluator` in `run_core_step`.
26+
- `FillEvent` reducer and Pipeline tests.
27+
- Runnable Risk Engine example at `examples/core_step_with_risk_engine.py`.
28+
- Extension-point docs under `docs/` and U3 candidate list at `docs/roadmap/dead-code-cleanup-candidates.md`.
1629

1730
### Changed
1831

1932
- Package metadata, exports, and docs reset for standalone Core library identity.
2033
- Pydantic models established as contract source of truth across public API docs.
34+
- README clarifies internally wired Pipeline vs externally supplied extension points.
2135

2236
### Removed
2337

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ python -m build
4848
- Register canonical category handling in `core/domain/event_model.py`.
4949
- Update canonical reduction behavior in `core/domain/processing.py`.
5050

51-
### CoreStep/CoreWakeupStep pipeline
51+
### CoreStep/CoreWakeupStep Pipeline
5252

5353
- Update `core/domain/processing_step.py` for deterministic flow changes.
5454
- Keep reconciliation/policy/apply transitions explicit and side-effect-safe.

README.md

Lines changed: 151 additions & 96 deletions
Large diffs are not rendered by default.

SECURITY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Include:
2525
This policy covers the Core package in this repository, including:
2626

2727
- canonical Event and Intent contracts
28-
- deterministic CoreStep/CoreWakeupStep decision pipeline
28+
- deterministic CoreStep/CoreWakeupStep decision Pipeline
2929
- package integrity and dependency usage in `tradingchassis_core`
3030

3131
## Secrets and Credentials Policy

docs/code-map/core-pipeline-map.md

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Core Pipeline Map
22

3-
This map captures the only supported deterministic decision pipeline for
3+
This map captures the only supported deterministic decision Pipeline for
44
TradingChassis Core.
55

66
## Step-by-step flow
@@ -17,7 +17,7 @@ TradingChassis Core.
1717
in the current slice—see `../flows/control-time-and-scheduling.md`).
1818
9. Runtime can dispatch later and inject further canonical Events (including
1919
`ControlTimeEvent` when an obligation is realized); Core does not perform
20-
external dispatch or mutate queues outside this pipeline.
20+
external dispatch or mutate Queues outside this Pipeline.
2121

2222
## Core APIs
2323

@@ -29,7 +29,7 @@ TradingChassis Core.
2929
## Determinism notes
3030

3131
- Processing Order monotonicity is enforced by `ProcessingPosition`.
32-
- Core logic is side-effect-safe apart from deterministic state mutation.
32+
- Core logic is side-effect-safe apart from deterministic State mutation.
3333
- Runtime adapters and external dispatch concerns are outside Core.
3434

3535

@@ -44,12 +44,36 @@ Wakeup flow:
4444

4545
1. Runtime supplies an ordered batch of `EventStreamEntry` values.
4646
2. `run_core_wakeup_reduction` calls `process_event_entry` for each entry in order.
47-
3. `CoreWakeupStrategyEvaluator.evaluate` runs **once** on the fully reduced state
47+
3. `CoreWakeupStrategyEvaluator.evaluate` runs **once** on the fully reduced State
4848
(`CoreWakeupStrategyContext` carries all entries).
4949
4. `run_core_wakeup_decision` snapshots queued intents once, combines generated + queued
5050
once, applies dominance/reconciliation once, Policy Admission once, and
51-
ExecutionControl plan/apply once.
51+
Execution Control plan/apply once.
5252
5. `CoreStepResult.dispatchable_intents` is returned; Runtime dispatches later.
5353

5454
`run_core_step` remains single-entry: one reduction, one step-level Strategy evaluation,
5555
one decision pass.
56+
57+
## Internally wired vs externally supplied
58+
59+
### Internally wired
60+
61+
- Steps 1–3, 5, and 8 in the flow above (reduction, candidates, `CoreStepResult`)
62+
- Policy admission **machinery** when `CorePolicyAdmissionContext` is provided
63+
- Execution Control plan/apply **machinery** when apply context is provided
64+
65+
### Externally supplied extension points
66+
67+
- **Strategy**`CoreStepStrategyEvaluator` or `CoreWakeupStrategyEvaluator`
68+
- **Policy**`PolicyIntentEvaluator` via `CorePolicyAdmissionContext`
69+
- **Execution Control instance**`ExecutionControl` via `CoreExecutionControlApplyContext`
70+
- **Configuration** — optional `CoreConfiguration`
71+
- **Event bus**`StrategyState(event_bus=...)`; `NullEventBus` for standalone use
72+
73+
### Convenience implementations
74+
75+
- Risk Engine (`RiskEngine`) — optional built-in `PolicyIntentEvaluator` (`examples/core_step_with_risk_engine.py`)
76+
- `ExecutionControl` — default queue/rate/inflight behavior (instance still supplied by caller)
77+
- `NullEventBus` — no-op bus for tests and examples
78+
79+
See `../reference/public-api.md` and `../how-to/use-policy-evaluator.md`.

docs/code-map/repository-map.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,16 @@ High-level map for the standalone Core package.
66

77
- `tradingchassis_core/__init__.py`: public package boundary exports
88
- `tradingchassis_core/core/domain/`: canonical contracts and deterministic
9-
pipeline orchestration
9+
Pipeline orchestration
1010
- `tradingchassis_core/core/risk/`: policy-only Risk Engine evaluator/config
1111
- `tradingchassis_core/core/execution_control/`: Execution Control primitives
12-
- `tradingchassis_core/core/events/`: internal Event bus/sink utilities
12+
- `tradingchassis_core/core/events/`: Event bus/sink utilities (`NullEventBus`; `LoggingEventSink` for Runtime)
1313

1414
## Tests and examples
1515

1616
- `tests/semantics/`: focused contract and deterministic behavior tests
17-
- `examples/core_step_quickstart.py`: public-import quickstart
17+
- `examples/core_step_quickstart.py`: minimal inline-policy quickstart
18+
- `examples/core_step_with_risk_engine.py`: Risk Engine policy quickstart
1819

1920
## Top-level package docs and metadata
2021

@@ -30,7 +31,7 @@ Core owns:
3031

3132
- canonical Events and Processing Order contracts
3233
- deterministic reduction and step decisions
33-
- Intent candidate, Risk Engine (policy), Execution Control outputs
34+
- Intent candidate records, Risk Engine (policy), Execution Control outputs
3435

3536
Core does not own:
3637

docs/flows/control-time-and-scheduling.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ to Execution Control deferral.
99
- **ControlSchedulingObligation** — Non-canonical Core output: a structured hint
1010
that a **time-dependent** recheck may be useful. It is **not** part of the
1111
canonical Event Stream and does not mutate `StrategyState`.
12-
- **ControlTimeEvent** — Canonical **control** category Event. It becomes part of
12+
- **Control-Time Event** (`ControlTimeEvent`) — Canonical **control** category Event. It becomes part of the
1313
deterministic history only after the **Runtime** injects it as
1414
`EventStreamEntry` input (same ingestion path as other canonical Events).
15-
- **Inflight** — Core-side **intent-operation** gating: a sendability / operation
15+
- **Inflight** — Core-side **Intent-operation** gating: a sendability / operation
1616
slot (for example keyed by `client_order_id`) is occupied because an earlier
17-
intent operation is still awaiting **canonical execution feedback**. This is
17+
Intent operation is still awaiting **canonical execution feedback**. This is
1818
not the same as venue-side “order ownership”; Core models sendability for the
19-
decision pipeline.
20-
- **Rate-limit deferral** — Execution control blocks dispatch because the
19+
decision Pipeline.
20+
- **Rate-limit deferral** — Execution Control blocks dispatch because the
2121
configured **token / time budget** for orders or cancels is not yet available at
2222
the apply clock (`now_ts_ns_local` in `CoreExecutionControlApplyContext`).
2323
- **Inflight deferral** — Dispatch is blocked because **inflight** gating applies,
@@ -33,11 +33,11 @@ to Execution Control deferral.
3333
**Not in scope for the current contract:** inflight timeout, wall-clock recovery,
3434
or “synthetic” obligations for inflight-only waits.
3535

36-
**Not implied:** every queued intent produces a scheduling obligation or a future
36+
**Not implied:** every queued Intent produces a scheduling obligation or a future
3737
`ControlTimeEvent`. Obligations are for **rate-limit** rechecks in the current
3838
Core slice.
3939

40-
## Clean Core pipeline (unchanged)
40+
## Clean Core Pipeline (unchanged)
4141

4242
1. `EventStreamEntry`
4343
2. `process_event_entry` / `process_canonical_event`
@@ -55,9 +55,9 @@ they are selected only in the mutable **apply** stage (`apply_execution_control_
5555

5656
## Runtime ownership
5757

58-
- Runtimes **must not** mutate Core queues (`StrategyState.queued_intents`, etc.)
58+
- Runtimes **must not** mutate Core Queues (`StrategyState.queued_intents`, etc.)
5959
directly outside the normal Core step / Execution Control apply path.
60-
- Queue flush / sendability decisions remain **ExecutionControl-owned** inside
60+
- Queue flush / sendability decisions remain **Execution Control-owned** inside
6161
Core when `CoreExecutionControlApplyContext` is supplied to `run_core_step` /
6262
wakeup APIs.
6363

docs/how-to/update-core-step-pipeline.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Recommended workflow:
1919

2020
Guardrails:
2121

22-
- No Runtime dispatch logic in Core pipeline code.
22+
- No Runtime dispatch logic in Core Pipeline code.
2323
- No legacy compatibility contract restoration.
2424
- Keep deterministic behavior and public API coherence.
2525

@@ -30,6 +30,6 @@ When updating wakeup behavior:
3030

3131
1. Keep `run_core_wakeup_reduction` as reduction-only (no per-entry Strategy calls).
3232
2. Use `CoreWakeupStrategyEvaluator` and `wakeup_strategy_evaluator=` for batch evaluation.
33-
3. Preserve one Policy Admission and one ExecutionControl apply per wakeup in
33+
3. Preserve one Policy Admission and one Execution Control apply per wakeup in
3434
`run_core_wakeup_decision`.
3535
4. Add tests in `tests/semantics/test_core_wakeup_final_state.py`.

docs/how-to/update-policy-and-execution-control.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ The Risk Engine (policy) and Execution Control are separate deterministic phases
99
- Core integration:
1010
`core/domain/policy_risk_decision.py` and `run_core_step` policy phase
1111
- Built-in policy-only evaluator:
12-
`core/risk/risk_engine.py`
12+
`core/risk/risk_engine.py` (public Risk Engine class `RiskEngine`; internal `RiskPolicy` / `ExecutionConstraintsPolicy`)
13+
- User guide:
14+
`use-policy-evaluator.md`
1315

1416
When updating Risk Engine policy behavior:
1517

0 commit comments

Comments
 (0)