docs: plan orchestrator and engine cleanup tasks

This commit is contained in:
Boki 2026-10-26 19:05:24 -04:00
parent 700ee09c4c
commit 7481d02c6c
13 changed files with 869 additions and 4 deletions

View file

@ -8,7 +8,7 @@
[manifest.json](manifest.json) owns scheduling metadata: status, priorities, dependencies, ADR approvals, assignments and write locks. Task Markdown owns implementation scope/evidence/acceptance. This index and the [graph](dependencies.mmd) are derived views. Only the planning/integration owner updates scheduling state.
**Current total: 45 completed original tasks + 13 implemented cleanup tasks pending independent review + 6 deferred + 4 merged IDs = 68 retained IDs.** The original backlog accounted for 55 IDs. F09/P07 added projection/profiling work; the owner deferred P08's TypeScript optimization. Merged records preserve traceability; never execute them separately. Deferred work requires its stated trigger and explicit activation.
**Current total: 76 retained IDs.** The earlier 68 IDs retain their state. E11 adds seven authorized cleanup tasks and one conditional replay extraction; see the manifest for current scheduling. The original backlog accounted for 55 IDs. F09/P07 added projection/profiling work; the owner deferred P08's TypeScript optimization. Merged records preserve traceability; never execute them separately. Deferred work requires its stated trigger and explicit activation.
States: ready, claimed, in_progress, review, done, blocked, deferred, merged. “Ready” means no code/ADR prerequisite, not execution authority. Implementation dependencies require accepted integration. `release_gates` govern enabling an end-to-end feature, not component coding or integration; conditional gates apply only to the named capability. F05 may integrate before F06, but its replay behavior is not released until F06 proves it.
@ -141,3 +141,18 @@ Scope and first execution wave: [CLEANUP.md](../CLEANUP.md). The owner has autho
Before any wave: unique IDs; existing task/ADR references; acyclic implementation graph; no scheduled task dependent on merged/deferred work; approvals/readiness; actual file locks; isolated native build outputs/workspace dependencies and test databases. Release gates are checked separately at activation.
R06/R08/R09 and the R07 comparison/measurement are complete. The default supports canonical single-asset research. Regime panels require actual retained annotations; no arbitrary candidate regime labels or profitability claims are inferred. The six conditional tasks keep their evidence/approval gates. Completing scheduled implementation does not activate paper/live trading or approve a multi-asset mark policy.
## E11 — Orchestrator and engine cleanup
Owner authorized planning and per-task implementation commits. [Execution plan](../orchestrator-engine-cleanup.md). Earlier cleanup reviews and the six original conditional tasks remain unchanged.
| Task | Priority | Dependencies |
| --- | --- | --- |
| [CL14 Require canonical capabilities in durable research contracts](tasks/CL14.md) | P1 | None |
| [CL15 Retire abandoned Rust architecture scaffolding](tasks/CL15.md) | P1 | None |
| [CL16 Give orchestrator composition an explicit shutdown owner](tasks/CL16.md) | P1 | None |
| [CL17 Separate historical reads from unused storage writes](tasks/CL17.md) | P2 | CL14 |
| [CL18 Share strict native parsing and financial view projection](tasks/CL18.md) | P2 | CL15 |
| [CL19 Share pure strategy bookkeeping and event ordering](tasks/CL19.md) | P2 | None |
| [CL20 Return validated retained results from the worker supervisor](tasks/CL20.md) | P2 | CL14 |
| [CL21 Extract private deterministic replay preparation when needed](tasks/CL21.md) | P3 | Conditional |

View file

@ -248,3 +248,19 @@ flowchart TD
CL08 --> CL12
ADR005 --> CL12
%% CL02 and CL03 also serialize on the di-container file lock; no artificial dependency edge.
subgraph E11["E11: Orchestrator and engine cleanup"]
CL14["CL14: Require canonical capabilities in durable research contracts"]
CL15["CL15: Retire abandoned Rust architecture scaffolding"]
CL16["CL16: Give orchestrator composition an explicit shutdown owner"]
CL17["CL17: Separate historical reads from unused storage writes"]
CL18["CL18: Share strict native parsing and financial view projection"]
CL19["CL19: Share pure strategy bookkeeping and event ordering"]
CL20["CL20: Return validated retained results from the worker supervisor"]
CL21["CL21: Extract private deterministic replay preparation when needed"]
end
CL14 --> CL17
CL14 --> CL20
CL15 --> CL18
class CL21 conditional
%% CL14/CL16 serialize container.ts changes; no artificial dependency.

View file

@ -1,8 +1,8 @@
{
"schema_version": 1,
"plan_revision": "2026-10-26.79",
"plan_revision": "2026-10-26.80",
"repository_base": "b7aeca4",
"plan_status": "cleanup_implemented_pending_review",
"plan_status": "orchestrator_engine_cleanup_authorized",
"execution_authorized": true,
"execution_scope": {
"authorized_by": "Owner: commit and continue with the rest of the tasks till 100%",
@ -63,6 +63,34 @@
"AI research product redesign"
]
},
"orchestrator_engine_cleanup_scope": {
"baseline_commit": "700ee09c",
"authorized_by": "Owner: make backlog tasks commit and start implementing, and commit after each is done",
"tasks": [
"CL14",
"CL15",
"CL16",
"CL17",
"CL18",
"CL19",
"CL20"
],
"conditional_tasks": [
"CL21"
],
"planning_file": "orchestrator-engine-cleanup.md",
"excluded": [
"performance optimization",
"financial policy changes",
"paper/live activation",
"pushes and PRs"
],
"first_wave": [
"CL14",
"CL15",
"CL16"
]
},
"canonical_metadata": "This manifest alone owns task status, dependency edges, approvals, assignments and write locks. Task Markdown owns scope and acceptance criteria. Index/roadmap are derived views.",
"decisions": [
{
@ -160,7 +188,8 @@
{
"id": "E10",
"title": "Cleanup and maintainability foundations"
}
},
{"id": "E11", "title": "Orchestrator and engine cleanup"}
],
"first_wave": ["C01", "C03", "C04", "W01"],
"tasks": [
@ -2670,6 +2699,304 @@
"implementation_commits": [
"8c39ccf7"
]
},
{
"id": "CL14",
"title": "Require canonical capabilities in durable research contracts",
"epic": "E11",
"priority": "P1",
"severity": "High",
"status": "ready",
"dependencies": [],
"decision_dependencies": [],
"task_file": "backlog/tasks/CL14.md",
"findings": [
"OE-14"
],
"complexity": "M",
"specialization": "TypeScript contracts and durable research",
"write_locks": [
"canonical-runner-contract",
"orchestrator-composition"
],
"parallel_policy": "May run alongside CL15. Serialize actual container.ts edits with CL16; this is a file lock, not a semantic prerequisite.",
"concrete_write_scope": [
"apps/stock/orchestrator/src/backtest/execution-engine.ts",
"apps/stock/orchestrator/src/backtest/run-repository.ts",
"apps/stock/orchestrator/src/backtest/BacktestRunner.ts",
"apps/stock/orchestrator/src/backtest/RustBacktestAdapter.ts",
"apps/stock/orchestrator/src/backtest/PostgresBacktestRunRepository.ts",
"apps/stock/orchestrator/src/container.ts",
"test/fixtures/canonical-runner.ts"
],
"assignment": null,
"branch": null,
"completed_commit": null,
"blocker": null,
"release_gates": [],
"integration_state": "not_started",
"integration_base": "700ee09c",
"completion_evidence": "orchestrator-engine-cleanup.md"
},
{
"id": "CL15",
"title": "Retire abandoned Rust architecture scaffolding",
"epic": "E11",
"priority": "P1",
"severity": "High",
"status": "ready",
"dependencies": [],
"decision_dependencies": [],
"task_file": "backlog/tasks/CL15.md",
"findings": [
"OE-15"
],
"complexity": "M",
"specialization": "Rust module graph and compatibility",
"write_locks": [
"native-module-graph"
],
"parallel_policy": "Independent of TS contract/lifecycle work. Serialize Rust module and native build output with CL18.",
"concrete_write_scope": [
"apps/stock/engine/src/lib.rs",
"apps/stock/engine/src/adapters/",
"apps/stock/engine/src/lib_new.rs",
"apps/stock/engine/src/lib_simplified.rs",
"apps/stock/engine/src/test_lib.rs",
"apps/stock/engine/src/api_new/",
"apps/stock/engine/src/domain.bak/",
"apps/stock/engine/src/events.bak/",
"apps/stock/engine/src/modes.bak/",
"apps/stock/engine/src/backtest/results.rs",
"apps/stock/engine/src/backtest/metrics_calculator.rs",
"apps/stock/engine/src/strategies/framework/",
"apps/stock/engine/MIGRATION.md"
],
"assignment": null,
"branch": null,
"completed_commit": null,
"blocker": null,
"release_gates": [],
"integration_state": "not_started",
"integration_base": "700ee09c",
"completion_evidence": "orchestrator-engine-cleanup.md"
},
{
"id": "CL16",
"title": "Give orchestrator composition an explicit shutdown owner",
"epic": "E11",
"priority": "P1",
"severity": "High",
"status": "ready",
"dependencies": [],
"decision_dependencies": [],
"task_file": "backlog/tasks/CL16.md",
"findings": [
"OE-16"
],
"complexity": "M",
"specialization": "TypeScript lifecycle and failure recovery",
"write_locks": [
"orchestrator-composition",
"di-container",
"di-service-lifecycle"
],
"parallel_policy": "Can be prepared independently; serialize container.ts with CL14 and shared DI edits with any other owner.",
"concrete_write_scope": [
"apps/stock/orchestrator/src/simple-container.ts",
"apps/stock/orchestrator/src/container.ts",
"apps/stock/orchestrator/src/index.ts",
"libs/core/di/src/container/builder.ts",
"libs/core/di/src/utils/lifecycle.ts",
"test/integration/service-startup-rollback.test.ts"
],
"assignment": null,
"branch": null,
"completed_commit": null,
"blocker": null,
"release_gates": [],
"integration_state": "not_started",
"integration_base": "700ee09c",
"completion_evidence": "orchestrator-engine-cleanup.md"
},
{
"id": "CL17",
"title": "Separate historical reads from unused storage writes",
"epic": "E11",
"priority": "P2",
"severity": "Medium",
"status": "ready",
"dependencies": [
"CL14"
],
"decision_dependencies": [],
"task_file": "backlog/tasks/CL17.md",
"findings": [
"OE-17"
],
"complexity": "M",
"specialization": "TypeScript market data and provider normalization",
"write_locks": [
"historical-storage"
],
"parallel_policy": "After CL14; independent of native boundary and strategy diagnostic cleanup.",
"concrete_write_scope": [
"apps/stock/orchestrator/src/services/StorageService.ts",
"apps/stock/orchestrator/src/data/",
"apps/stock/web-api/src/services/stored-dataset-preparation.ts",
"test/integration/intraday-storage.test.ts"
],
"assignment": null,
"branch": null,
"completed_commit": null,
"blocker": null,
"release_gates": [],
"integration_state": "not_started",
"integration_base": "700ee09c",
"completion_evidence": "orchestrator-engine-cleanup.md"
},
{
"id": "CL18",
"title": "Share strict native parsing and financial view projection",
"epic": "E11",
"priority": "P2",
"severity": "Medium",
"status": "ready",
"dependencies": [
"CL15"
],
"decision_dependencies": [],
"task_file": "backlog/tasks/CL18.md",
"findings": [
"OE-18"
],
"complexity": "M",
"specialization": "Rust canonical transport contracts",
"write_locks": [
"native-canonical-api"
],
"parallel_policy": "After CL15; no simultaneous native build or canonical Rust contract owner.",
"concrete_write_scope": [
"apps/stock/engine/src/api/replay.rs",
"apps/stock/engine/src/api/paper.rs",
"apps/stock/engine/src/api/mod.rs",
"apps/stock/engine/src/financial/mod.rs",
"scripts/test/native-bindings.test.ts"
],
"assignment": null,
"branch": null,
"completed_commit": null,
"blocker": null,
"release_gates": [],
"integration_state": "not_started",
"integration_base": "700ee09c",
"completion_evidence": "orchestrator-engine-cleanup.md"
},
{
"id": "CL19",
"title": "Share pure strategy bookkeeping and event ordering",
"epic": "E11",
"priority": "P2",
"severity": "Medium",
"status": "ready",
"dependencies": [],
"decision_dependencies": [],
"task_file": "backlog/tasks/CL19.md",
"findings": [
"OE-19"
],
"complexity": "M",
"specialization": "TypeScript strategy and durable paper parity",
"write_locks": [
"strategy-decision-helpers",
"canonical-paper-contract"
],
"parallel_policy": "Independent of CL14/CL15/CL16; reserve paper and strategy helper files.",
"concrete_write_scope": [
"apps/stock/orchestrator/src/strategies/strategy-controller.ts",
"apps/stock/orchestrator/src/strategies/strategy-decision.ts",
"apps/stock/orchestrator/src/execution/CanonicalPaperExecution.ts",
"apps/stock/orchestrator/src/execution/canonical-paper.ts",
"apps/stock/orchestrator/src/execution/strategy-recovery.ts",
"apps/stock/orchestrator/src/paper/feed.ts"
],
"assignment": null,
"branch": null,
"completed_commit": null,
"blocker": null,
"release_gates": [],
"integration_state": "not_started",
"integration_base": "700ee09c",
"completion_evidence": "orchestrator-engine-cleanup.md"
},
{
"id": "CL20",
"title": "Return validated retained results from the worker supervisor",
"epic": "E11",
"priority": "P2",
"severity": "Medium",
"status": "ready",
"dependencies": [
"CL14"
],
"decision_dependencies": [],
"task_file": "backlog/tasks/CL20.md",
"findings": [
"OE-20"
],
"complexity": "M",
"specialization": "TypeScript IPC and native worker lifecycle",
"write_locks": [
"native-worker-protocol",
"canonical-adapter"
],
"parallel_policy": "After CL14; separate from native Rust and historical storage edits.",
"concrete_write_scope": [
"apps/stock/orchestrator/src/backtest/NativeBacktestWorker.ts",
"apps/stock/orchestrator/src/backtest/RustBacktestAdapter.ts",
"apps/stock/orchestrator/src/backtest/native-worker-protocol.ts",
"test/integration/retained-strategy-worker.test.ts"
],
"assignment": null,
"branch": null,
"completed_commit": null,
"blocker": null,
"release_gates": [],
"integration_state": "not_started",
"integration_base": "700ee09c",
"completion_evidence": "orchestrator-engine-cleanup.md"
},
{
"id": "CL21",
"title": "Extract private deterministic replay preparation when needed",
"epic": "E11",
"priority": "P3",
"severity": "Low",
"status": "deferred",
"dependencies": [],
"decision_dependencies": [],
"task_file": "backlog/tasks/CL21.md",
"findings": [
"OE-21"
],
"complexity": "M",
"specialization": "Rust deterministic replay",
"write_locks": [
"native-replay"
],
"parallel_policy": "Deferred; sole replay owner when activated.",
"concrete_write_scope": [
"apps/stock/engine/src/financial/replay.rs",
"apps/stock/engine/src/financial/replay_tests.rs"
],
"assignment": null,
"branch": null,
"completed_commit": null,
"blocker": "Conditional: upcoming replay preparation change and explicit owner activation.",
"release_gates": [],
"integration_state": "not_started",
"integration_base": "700ee09c",
"completion_evidence": "orchestrator-engine-cleanup.md"
}
],
"review_note": "Independent skeptical revision: four superseded tasks retain stable IDs; deferred work is not a dependency of scheduled tasks. Release gates are distinct from implementation prerequisites.",

View file

@ -0,0 +1,61 @@
# CL14 — Require canonical capabilities in durable research contracts
Parent epic: E11. Priority/severity: P1 / High. Complexity: M. Specialist: TypeScript contracts and durable research.
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
execution-engine.ts:13 requires retired execution/playback but makes runCanonical optional. run-repository.ts:25 does the same for canonical claim/load/complete. BacktestRunner.ts:225,287,327 probes mandatory capabilities at runtime. RustBacktestAdapter.ts:35 storage and BacktestRunner.ts:60 engineName are unused.
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
- Define required canonical engine/repository capabilities for the current runner. Preserve legacy interfaces where retained consumers actually need them.
- Remove unused storage and engineName constructor requirements and their caller/fixture plumbing.
- Remove only redundant optional-capability probes; preserve parsing of untrusted input, explicit unavailable-store errors, retired queue/HTTP rejection, and every lease/terminal-write rule.
- Keep legacy repository methods in place unless a tiny interface separation suffices; physical relocation is not required.
Likely files/modules:
- `apps/stock/orchestrator/src/backtest/execution-engine.ts`
- `apps/stock/orchestrator/src/backtest/run-repository.ts`
- `apps/stock/orchestrator/src/backtest/BacktestRunner.ts`
- `apps/stock/orchestrator/src/backtest/RustBacktestAdapter.ts`
- `apps/stock/orchestrator/src/backtest/PostgresBacktestRunRepository.ts`
- `apps/stock/orchestrator/src/container.ts`
- `test/fixtures/canonical-runner.ts`
## Exclusions
No changes to financial semantics, SQL schema, lease policy, historical readers, native exports or persisted request/result shapes. 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: `canonical-runner-contract`, `orchestrator-composition`.
Parallelism: May run alongside CL15. Serialize actual container.ts edits with CL16; this is a file lock, not a semantic prerequisite.
## Acceptance criteria
1. Current runner cannot type-check against an engine/repository lacking required canonical methods.
2. Canonical success, cancellation, lease loss and unavailable storage retain their behavior; old queued requests cannot execute.
3. Existing historical writers/readers and retirement diagnostics remain available to their existing consumers.
## Mandatory verification
- bun run typecheck
- bun test test/integration/canonical-durable-runner.test.ts test/integration/backtest-workflow.test.ts test/integration/canonical-worker-lifecycle.test.ts test/integration/research-pool.test.ts test/integration/research-runtime-isolation.test.ts scripts/test/architecture.test.ts
- Disposable PostgreSQL: test/postgres/canonical-durable-backtest.test.ts
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
Weakening fail-closed boundaries or dropping compatibility methods while narrowing types.
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.

View file

@ -0,0 +1,67 @@
# CL15 — Retire abandoned Rust architecture scaffolding
Parent epic: E11. Priority/severity: P1 / High. Complexity: M. Specialist: Rust module graph and compatibility.
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
lib.rs:5 compiles adapters; adapters/mod.rs:32 fabricates price-100 fills without calling its wrapped handler, :80 reports arbitrary orders Filled. Repository references are confined to scaffold and stale MIGRATION.md. Cargo/lib.rs and module declarations do not include the alternate architecture files.
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
- Recheck module graph and repository callers; record a concise deletion/preservation inventory.
- Remove unused placeholder adapter framework and truly obsolete duplicate architecture entrypoints/backups.
- Inspect uncompiled metrics/results/framework for unique useful algorithms; preserve any such code in an explicitly retained location with honest status rather than silently deleting capability.
- Replace misleading migration guidance with current canonical versus retained-compatibility map. Keep compiled legacy constructors, indicators, analytics and meaningful regression tests.
Likely files/modules:
- `apps/stock/engine/src/lib.rs`
- `apps/stock/engine/src/adapters/`
- `apps/stock/engine/src/lib_new.rs`
- `apps/stock/engine/src/lib_simplified.rs`
- `apps/stock/engine/src/test_lib.rs`
- `apps/stock/engine/src/api_new/`
- `apps/stock/engine/src/domain.bak/`
- `apps/stock/engine/src/events.bak/`
- `apps/stock/engine/src/modes.bak/`
- `apps/stock/engine/src/backtest/results.rs`
- `apps/stock/engine/src/backtest/metrics_calculator.rs`
- `apps/stock/engine/src/strategies/framework/`
- `apps/stock/engine/MIGRATION.md`
## Exclusions
No blanket legacy API deletion, rewriting algorithms, adding a new framework, loader/provenance changes or financial-core edits. 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-module-graph`.
Parallelism: Independent of TS contract/lifecycle work. Serialize Rust module and native build output with CL18.
## Acceptance criteria
1. No compiled adapter can manufacture placeholder fills; no repository consumers lose supported APIs.
2. Every removed file is classified by module/caller evidence; unique useful calculations remain discoverable.
3. Native ESM/CJS constructors and canonical reports retain existing behavior; current docs no longer recommend abandoned scaffolding.
## Mandatory verification
- cargo test -p engine --lib --offline
- Build native addon from this checkout; bun test scripts/test/native-bindings.test.ts test/integration/native-terminal-equity.test.ts test/integration/native-market-data.test.ts
- bun test scripts/test/architecture.test.ts
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
Mistaking retained algorithms/public compatibility APIs for dead scaffolding; native rebuild/provenance required.
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.

View file

@ -0,0 +1,60 @@
# CL16 — Give orchestrator composition an explicit shutdown owner
Parent epic: E11. Priority/severity: P1 / High. Complexity: M. Specialist: TypeScript lifecycle and failure recovery.
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
simple-container.ts:46 initializes DB clients then :58 registers app services without enclosing rollback and returns only services at :68. index.ts:159 drains app work but not database/cache clients; termination uses process.exit. builder.ts:76 keeps lifecycle owner only locally.
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
- Expose an explicit owned runtime/shutdown handle while preserving compatible createContainer callers where needed.
- Reuse existing lifecycle cleanup to roll back application-registration and HTTP-bind failures after successful shared-service startup.
- Stop admission, drain durable runner/paper/queue work, then close borrowed adapters exactly once. Preserve initiating errors and attempt cleanup even if another closer fails.
- Remove now-irrelevant ModeManager cleanup from the canonical entrypoint; avoid broad app lifecycle migration.
Likely files/modules:
- `apps/stock/orchestrator/src/simple-container.ts`
- `apps/stock/orchestrator/src/container.ts`
- `apps/stock/orchestrator/src/index.ts`
- `libs/core/di/src/container/builder.ts`
- `libs/core/di/src/utils/lifecycle.ts`
- `test/integration/service-startup-rollback.test.ts`
## Exclusions
No changes to paper activation, account recovery, financial semantics, job lease policy, other application startup flows or readiness feature O02. 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: `orchestrator-composition`, `di-container`, `di-service-lifecycle`.
Parallelism: Can be prepared independently; serialize container.ts with CL14 and shared DI edits with any other owner.
## Acceptance criteria
1. Registration failure, HTTP bind failure, normal shutdown and repeated shutdown each close every owned resource once.
2. Runner terminal writes finish before PostgreSQL closure; one cleanup failure cannot skip remaining resources or mask original startup error.
3. Successful startup behavior, explicit paper composition and research isolation remain unchanged.
## Mandatory verification
- bun test libs/core/di/test/lifecycle.test.ts test/integration/service-startup-rollback.test.ts test/integration/paper-composition.test.ts test/integration/research-runtime-isolation.test.ts test/integration/canonical-worker-lifecycle.test.ts
- Add controlled orchestrator composition/startup tests for all acceptance failures; no development DB
- Build changed DI workspace; bun run typecheck
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
Double shutdown, early database closure, swallowed failures, unowned late initialization.
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.

View file

@ -0,0 +1,58 @@
# CL17 — Separate historical reads from unused storage writes
Parent epic: E11. Priority/severity: P2 / Medium. Complexity: M. Specialist: TypeScript market data and provider normalization.
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
StorageService.ts:71-193 combines mode initialization, DDL and two writers with no repository callers; historical capabilities/read/normalization start at :196/:250/:373. Current web dataset preparation uses only historical read capability.
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
- Recheck callers; remove unused writers or explicitly isolate required compatibility behavior.
- Keep the existing historical facade and move concrete provider decoding/common validation into small cohesive functions only where it improves the data flow.
- Remove unnecessary PostgreSQL/mode ownership from the current historical reader; adapt retained examples only as necessary.
- Preserve provider selection, no fallback on missing/error, explicit synthetic opt-in, date semantics and all data-quality gates.
Likely files/modules:
- `apps/stock/orchestrator/src/services/StorageService.ts`
- `apps/stock/orchestrator/src/data/`
- `apps/stock/web-api/src/services/stored-dataset-preparation.ts`
- `test/integration/intraday-storage.test.ts`
## Exclusions
No new provider framework, source cleansing, null-volume coercion, cache, throughput optimization, DB migration or changes to adjustment/calendar policy. 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: [CL14](CL14.md)
Write locks: `historical-storage`.
Parallelism: After CL14; independent of native boundary and strategy diagnostic cleanup.
## Acceptance criteria
1. Current historical reader has no unused market/performance writes or ad hoc DDL responsibilities.
2. Existing provider routing, cancellation, malformed-row rejection and duplicate/timestamp/identity handling remain unchanged.
3. Frozen V1/V2 fixtures retain exact hashes and result eligibility; useful synthetic/legacy examples still work.
## Mandatory verification
- bun test test/integration/intraday-storage.test.ts test/integration/historical-dataset-v2.test.ts test/integration/ingestion-backtest.test.ts test/integration/stored-dataset-preparation.test.ts
- bun run typecheck
- Disposable PostgreSQL: test/postgres/stored-dataset-preparation.test.ts if persistence-facing behavior/imports change
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
Accidentally changing normalization, hash inputs, explicit provider precedence or legacy initialization.
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.

View file

@ -0,0 +1,59 @@
# CL18 — Share strict native parsing and financial view projection
Parent epic: E11. Priority/severity: P2 / Medium. Complexity: M. Specialist: Rust canonical transport contracts.
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
api/replay.rs:78 and api/paper.rs:53 duplicate keys_match; replay.rs:297 and paper.rs:66 duplicate the canonical financial view.
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
- Extract small pure helpers shared by native replay and paper adapters; keep host identities/envelopes separate.
- Preserve strict recursive unknown/missing field checks including explicit required null fields.
- Preserve paper intermediate journal pre-transaction admissionRevision and final post-transaction revision.
- Retain one financial kernel; no new serializer framework or TS arithmetic.
Likely files/modules:
- `apps/stock/engine/src/api/replay.rs`
- `apps/stock/engine/src/api/paper.rs`
- `apps/stock/engine/src/api/mod.rs`
- `apps/stock/engine/src/financial/mod.rs`
- `scripts/test/native-bindings.test.ts`
## Exclusions
No wire shape/version/checkpoint changes, event order changes, economic policy or generic API framework. 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: [CL15](CL15.md)
Write locks: `native-canonical-api`.
Parallelism: After CL15; no simultaneous native build or canonical Rust contract owner.
## Acceptance criteria
1. Equivalent canonical states expose identical financial-view fields through both hosts.
2. Nested unknown/missing/null contract negatives remain rejected identically.
3. Paper retry journals and every intermediate/final revision are unchanged; existing exact replay/checkpoint fixtures pass.
## Mandatory verification
- cargo test -p engine --lib --offline
- Build native addon; bun test scripts/test/native-bindings.test.ts test/integration/native-replay.test.ts test/integration/native-replay-report.test.ts
- Add focused view parity and strict nested/null fixtures where existing tests do not establish parity
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
Weakening required nullable fields or changing journal projection revision/order.
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.

View file

@ -0,0 +1,61 @@
# CL19 — Share pure strategy bookkeeping and event ordering
Parent epic: E11. Priority/severity: P2 / Medium. Complexity: M. Specialist: TypeScript strategy and durable paper parity.
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
strategy-controller.ts:60/:186 and CanonicalPaperExecution.ts:74/:330 duplicate diagnostics/feedback. feed.ts:48 and canonical-paper.ts:199 duplicate event comparator. Canonical paper imports canonicalJson from legacy strategy-recovery.ts:6.
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
- Share pure initial-diagnostic and owner-scoped admission-feedback helpers without combining controllers.
- Use one event-key comparator with existing timestamp/phase/UTF-8/source ordering.
- Move canonicalJson unchanged to a neutral local module with compatibility re-export; preserve exact historical bytes.
- Keep research state confirmation and paper SQL transaction/recovery rules separate.
Likely files/modules:
- `apps/stock/orchestrator/src/strategies/strategy-controller.ts`
- `apps/stock/orchestrator/src/strategies/strategy-decision.ts`
- `apps/stock/orchestrator/src/execution/CanonicalPaperExecution.ts`
- `apps/stock/orchestrator/src/execution/canonical-paper.ts`
- `apps/stock/orchestrator/src/execution/strategy-recovery.ts`
- `apps/stock/orchestrator/src/paper/feed.ts`
## Exclusions
No generic state-machine framework, state serialization policy changes, checkpoint/schema version changes or replacement of canonicalJson with stricter stateCopy. 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: `strategy-decision-helpers`, `canonical-paper-contract`.
Parallelism: Independent of CL14/CL15/CL16; reserve paper and strategy helper files.
## Acceptance criteria
1. Equivalent research/paper inputs retain identical state/RNG/owner feedback; malformed ownership fails before state commit.
2. Unicode and phase ties keep Rust-compatible ordering.
3. Historical canonicalJson fixtures remain byte identical; crash/retry/partial failures retain committed state.
## Mandatory verification
- bun test test/integration/strategy-runtime.test.ts test/integration/paper-feed.test.ts scripts/test/architecture.test.ts
- bun run typecheck
- Disposable PostgreSQL: test/postgres/canonical-paper.test.ts test/postgres/canonical-paper-crash.test.ts test/postgres/strategy-recovery.test.ts
- Add parity/order/serialization fixtures that exercise public behavior
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
Moving commit boundaries, changing ordering or fingerprint serialization, sharing mutable diagnostic objects.
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.

View file

@ -0,0 +1,58 @@
# CL20 — Return validated retained results from the worker supervisor
Parent epic: E11. Priority/severity: P2 / Medium. Complexity: M. Specialist: TypeScript IPC and native worker lifecycle.
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
NativeBacktestWorker.ts:132 parses a retained result but returns the untyped string at :161; RustBacktestAdapter.ts:85 parses it again.
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
- Add a narrow typed retained execution entry or precise overload using the existing parser.
- Retain parsed result only after identity/policy/artifact checks and resolve only after successful close and candidate cleanup.
- Preserve trace callers/raw transport compatibility without a broad protocol redesign.
- Keep separate trust-boundary and persistence validations.
Likely files/modules:
- `apps/stock/orchestrator/src/backtest/NativeBacktestWorker.ts`
- `apps/stock/orchestrator/src/backtest/RustBacktestAdapter.ts`
- `apps/stock/orchestrator/src/backtest/native-worker-protocol.ts`
- `test/integration/retained-strategy-worker.test.ts`
## Exclusions
No serialization optimization, sandbox redesign, extra process/service, removal of boundary validation or premature success before worker exit. 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: [CL14](CL14.md)
Write locks: `native-worker-protocol`, `canonical-adapter`.
Parallelism: After CL14; separate from native Rust and historical storage edits.
## Acceptance criteria
1. Canonical adapter receives the already-validated typed envelope without reparsing.
2. Wrong identity/policy/artifact/analytics, nonzero exit after result, abort and cleanup failure cannot succeed.
3. Caller mutation cannot alter submitted/expected identity; trace/strategy callers retain their existing contracts.
## Mandatory verification
- bun test test/integration/retained-strategy-worker.test.ts test/integration/canonical-worker-lifecycle.test.ts test/integration/canonical-strategy-worker.test.ts test/integration/native-replay-report.test.ts
- bun run typecheck
- Existing result-before-error/close, malformed envelope, mutation, cancellation and candidate cleanup regressions; add only missing cases
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
Returning before child cleanup, accepting mutated expected input, dropping validation for another request kind.
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.

View file

@ -0,0 +1,55 @@
# 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.