stock-bot/docs/development/backlog/tasks/CL21.md

55 lines
3.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# CL21 — Extract private deterministic replay preparation when needed
Parent epic: E11. Priority/severity: P3 / Low. Complexity: M. Specialist: Rust deterministic replay.
Scheduling and commit evidence: [manifest](../manifest.json). Scope baseline: `700ee09c`. Owner authorized planning, implementation and one commit per completed task on 2026-10-26; CL21 remains conditional. Follow [quality gates](../../QUALITY-GATES.md) and [agent instructions](../../agents/implementation.md).
## Outcome and evidence
financial/replay.rs:262-641 combines canonicalization, validation and schedule creation with stateful advance/submit/restore at :642 onward.
The concrete benefit is a smaller supported execution surface with unchanged financial behavior. Findings are verified at the baseline; recheck caller/module evidence before edits. This does not imply active financial corruption.
## Scope
- Only activate when an upcoming calendar/timeframe change benefits from this split and the owner resumes it.
- Extract private preparation/schedule functions; keep existing public types and one Replay state owner.
- Preserve exact event order, input binding, barriers, financial trace and checkpoint bytes.
Likely files/modules:
- `apps/stock/engine/src/financial/replay.rs`
- `apps/stock/engine/src/financial/replay_tests.rs`
## Exclusions
No immediate implementation, new traits/managers, event framework, algorithm changes or performance work. Preserve retained strategy packages/datasets/results, useful algorithms, reviewed calculations, durable recovery and the existing .env files. No pushes, PRs or paper/live activation.
## Dependencies and ownership
Prerequisites: None; inspect existing integrated baseline rather than reopening earlier cleanup tasks.
Write locks: `native-replay`.
Parallelism: Deferred; sole replay owner when activated.
## Acceptance criteria
1. Private extraction leaves all public contracts/economic traces/checkpoints unchanged.
2. Future-suffix, equal-time permutation and restore-before/after-every-event regressions pass.
3. No additional mutable financial handle or module dependency cycle.
## Mandatory verification
- cargo test -p engine --lib --offline
- Build native addon; bun test test/integration/native-replay.test.ts test/integration/native-replay-report.test.ts
- Exact event-order/checkpoint equality fixtures
Use isolated worktrees/build outputs and disposable safety databases/Redis only. Never rebaseline financial fixtures to hide changed behavior. Integrator runs repository checks on the combined source. Performance work remains deferred; no speed claims are part of acceptance.
## Risks and definition of done
Changing economic event ordering during a cosmetic move; intentionally deferred until there is practical need.
Done requires scoped tests, independent reviewer acceptance, integration verification, and a focused commit. The manifest owns status and evidence; implementers do not edit it. Root records each completed commit in the next bookkeeping update; the task completion commit includes its tests/reviewer evidence, avoiding self-referential hashes. Unrelated prior CL01–CL13 review status remains unchanged.