docs: plan cleanup and maintainability backlog

This commit is contained in:
Boki 2026-10-26 13:17:01 -04:00
parent fbf2eb9e0c
commit 4ddffa6b67
19 changed files with 1743 additions and 7 deletions

View file

@ -1,12 +1,14 @@
# Canonical development backlog
**All 45/45 scheduled tasks are complete (100%).** The canonical Rust engine, TypeScript research/workbench, bounded worker pool, isolated candidates, AI evidence workflow and human-reviewed paper promotion are validated. Implementation commits: `bbf0dd4`, `26b9726`, `25b5cbf` (R07 measurement `ab08db8`). Six conditional tasks remain deferred; four merged IDs remain redirects. This is scheduled-backlog completion, not live-trading activation.
**The original 45/45 scheduled tasks are complete.** The canonical Rust engine, TypeScript research/workbench, bounded worker pool, isolated candidates, AI evidence workflow and human-reviewed paper promotion are validated. Implementation commits: `bbf0dd4`, `26b9726`, `25b5cbf` (R07 measurement `ab08db8`). Six conditional tasks remain deferred; four merged IDs remain redirects. This is scheduled-backlog completion, not live-trading activation.
**New work:** [13 cleanup stories](../CLEANUP.md) were proposed on October 26, 2026. Their implementation has not been requested; the manifest's current execution authorization is false. The first independent group is CL01, CL03 and CL04.
## One source of truth
[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.
**45 scheduled + 6 deferred + 4 merged IDs = 55 retained IDs.** F09/P07 add 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: 45 completed original tasks + 13 proposed cleanup tasks + 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.
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.
@ -114,6 +116,26 @@ Relative size: S narrow correction, M coherent boundary, L sensitive owner-contr
| [O01 Serialize additive schema migrations safely](tasks/O01.md) | P1 / done | None | — | PostgreSQL/backend infrastructure / S |
| [O02 Expose truthful research and paper readiness diagnostics](tasks/O02.md) | P1 / deferred | S04 | — | Infrastructure/observability / M |
### E10 — Cleanup and maintainability foundations
Scope and first execution wave: [CLEANUP.md](../CLEANUP.md). Ready is code readiness only; all new implementation is planning-only until requested.
| Task | Priority / status | Implementation prerequisites | Release gate | Specialist / size |
| --- | --- | --- | --- | --- |
| [CL01 Replace permissive DI configuration tests with production-path assertions](tasks/CL01.md) | P1 / ready | None | — | TypeScript infrastructure testing / M |
| [CL02 Normalize database configuration once and enforce consistent service switches](tasks/CL02.md) | P1 / blocked | CL01 | — | TypeScript configuration and database adapters / M |
| [CL03 Roll back failed shared-service startup and clear initialization timers](tasks/CL03.md) | P1 / ready | None | — | TypeScript resource lifecycle and concurrency / M |
| [CL04 Provide one consistent research startup path and repair stale commands](tasks/CL04.md) | P1 / ready | None | — | Bun/Turbo developer tooling / S |
| [CL05 Extract shared dataset and reporting logic behind a research library boundary](tasks/CL05.md) | P2 / ready | D01, F08, R05 | — | TypeScript domain boundaries and package migration / M |
| [CL06 Use shared dataset response schemas and eligibility checks in the workbench](tasks/CL06.md) | P2 / blocked | CL05 | — | Shared contracts and frontend validation / M |
| [CL07 Share JSON transport handling across experiment and validation clients](tasks/CL07.md) | P2 / ready | None | — | Frontend HTTP contracts and retry semantics / M |
| [CL08 Split backtest template, run and reproduction responsibilities behind the existing service](tasks/CL08.md) | P2 / blocked | CL05 | — | TypeScript application services and PostgreSQL transactions / M |
| [CL09 Separate strategy metadata, version inspection and publication UI](tasks/CL09.md) | P2 / ready | None | — | React strategy workflows / M |
| [CL10 Separate experiment modes and make draft/submission state explicit](tasks/CL10.md) | P2 / ready | None | — | React experiment workflow state / M |
| [CL11 Separate backtest template loading, run monitoring and submission state](tasks/CL11.md) | P2 / ready | None | — | React asynchronous state and durable-run UX / M |
| [CL12 Simplify retired execution seams while preserving historical reads](tasks/CL12.md) | P2 / blocked | CL08 | — | Compatibility cleanup and execution boundaries / M |
| [CL13 Hide placeholder navigation while preserving useful product routes](tasks/CL13.md) | P2 / ready | None | — | React navigation and product clarity / S |
## Scheduling checks
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.

View file

@ -219,3 +219,32 @@ flowchart TD
classDef conditional stroke-dasharray: 5 5,fill:#fff3cd,color:#222
class D04,P03,P05,P06,P08,O02 conditional
%% Merged traceability only: C05 -> F01; F03 -> F02; D03 -> D01; P02 -> F06.
subgraph E10["E10: Cleanup and maintainability foundations"]
CL01["CL01: Replace permissive DI configuration tests with production-path assertions"]
CL02["CL02: Normalize database configuration once and enforce consistent service switches"]
CL03["CL03: Roll back failed shared-service startup and clear initialization timers"]
CL04["CL04: Provide one consistent research startup path and repair stale commands"]
CL05["CL05: Extract shared dataset and reporting logic behind a research library boundary"]
CL06["CL06: Use shared dataset response schemas and eligibility checks in the workbench"]
CL07["CL07: Share JSON transport handling across experiment and validation clients"]
CL08["CL08: Split backtest template, run and reproduction responsibilities behind the existing service"]
CL09["CL09: Separate strategy metadata, version inspection and publication UI"]
CL10["CL10: Separate experiment modes and make draft/submission state explicit"]
CL11["CL11: Separate backtest template loading, run monitoring and submission state"]
CL12["CL12: Simplify retired execution seams while preserving historical reads"]
CL13["CL13: Hide placeholder navigation while preserving useful product routes"]
end
CL01 --> CL02
D01 --> CL05
F08 --> CL05
R05 --> CL05
ADR001 --> CL05
ADR003 --> CL05
ADR004 --> CL05
CL05 --> CL06
CL05 --> CL08
ADR005 --> CL08
ADR006 --> CL08
CL08 --> CL12
ADR005 --> CL12
%% CL02 and CL03 also serialize on the di-container file lock; no artificial dependency edge.

View file

@ -1,5 +1,7 @@
# Revalidated audit findings
The original findings below describe their stated historical baseline. For the current cleanup extension, see [Cleanup audit 2026-10-26](#cleanup-audit-2026-10-26); completed financial migration findings must not be mistaken for newly reopened defects.
Baseline: `b7aeca4`, inspected 2026-10-22. No standalone structured audit/backlog was found in existing docs; this matrix reconciles the supplied audit concerns against current code. Existing informal docs remain historical context, not a second task tracker.
**Verified** means the cited implementation establishes the behavior or gap. **Likely** would mean an inference not yet reproduced; none is promoted to a confirmed defect here. **Needs Investigation** marks runtime/coverage questions that source alone cannot certify. No full application test suite or new performance benchmark was run during this planning-only task. Numeric acceptance examples are new test requirements, not fabricated passing tests.
@ -222,3 +224,67 @@ Disposition: [S04](tasks/S04.md), [A04](tasks/A04.md), [O02](tasks/O02.md).
- No runtime evidence here establishes real broker reliability. Live-disabled guards remain intact.
- Exact hardware throughput, storage hot spots, memory limits and sandbox availability require P01/A02 measurements, not architectural confidence.
- Preservation rules in [cleanup audit](../../cleanup-audit.md) remain: reviewed calculations, restored helpers and useful research prototypes are not disposable dead code.
## Cleanup audit 2026-10-26
Baseline: `fbf2eb9e`. The read-only audit passed `bun run typecheck`, `bun run lint:check`, and 39 focused tests / 384 assertions across canonical SMA, strategy-runtime, canonical-durable-runner, QuestDB configuration and chart lifecycle suites. It did not rerun the complete PostgreSQL/browser suites or performance measurements. The planning stories below do not claim additional implementation or test completion.
### CL-F01 — High / Verified — Configuration precedence and field loss
A no-connection probe supplied enabled PostgreSQL/MongoDB/cache configuration and explicitly disabled those services through builder options. The resolved configurations stayed enabled; QuestDB's disable option behaved differently. PostgreSQL SSL/pool/timeout fields also exist in the core schema but are omitted by the DI schema/registration path.
Evidence: [builder precedence](../../../libs/core/di/src/container/builder.ts#L88), [core PostgreSQL schema](../../../libs/core/config/src/schemas/database.schema.ts#L4), [DI PostgreSQL schema](../../../libs/core/di/src/config/schemas/postgres.schema.ts#L3), [registration](../../../libs/core/di/src/registrations/database.registration.ts#L43). Story: [CL02](tasks/CL02.md).
### CL-F02 — High / Verified — Partial shared startup retains resources
An isolated cache-success/mongo-failure probe recorded cache connection and startup rejection without cache disconnection. Shared initialization uses Promise.all without rollback; timeout timers are not cleared on settled initialization. This differs from C04's completed ModeManager-specific recovery scope.
Evidence: [shared lifecycle](../../../libs/core/di/src/utils/lifecycle.ts#L24), [timeout creation](../../../libs/core/di/src/utils/lifecycle.ts#L97), [builder startup](../../../libs/core/di/src/container/builder.ts#L74). Story: [CL03](tasks/CL03.md).
### CL-F03 — High / Verified — Older infrastructure tests can pass without proving production behavior
DI success tests accept any exception as a passing result and replace production normalization with a module-local implementation. The older QuestDB client suite exercises a SimpleQuestDBClient defined in the test file; it is not production client transport coverage. Existing newer real-path tests remain valuable.
Evidence: [permissive assertions](../../../libs/core/di/test/container-builder.test.ts#L114), [test client](../../../libs/data/questdb/test/questdb.test.ts#L9), [instantiation](../../../libs/data/questdb/test/questdb.test.ts#L121). Story: [CL01](tasks/CL01.md). CL02 extends real wire-configuration coverage; this finding is not authority for an unrelated test-suite rewrite.
### CL-F04 — High / Verified — Shared research logic is imported from application internals
The web API imports orchestrator dataset validation, reporting and host build/sandbox helpers through source-relative paths. Reusable pure domain code and runtime integration are mixed in the import boundary. Only the pure subset should move; runtime adapters retain their process responsibilities.
Evidence: [admission imports](../../../apps/stock/web-api/src/services/canonical-research.service.ts#L31), [report import](../../../apps/stock/web-api/src/services/backtest-v2.service.ts#L37), [dataset implementation](../../../apps/stock/orchestrator/src/data/historical-dataset-v2.ts#L1). Story: [CL05](tasks/CL05.md).
### CL-F05 — Medium / Verified — Dataset response structures are maintained independently
The browser backtest client contains a large manifest/preparation schema overlapping backend dataset structures and workbench eligibility checks. Shared structures can be consolidated while full content/hash verification remains server-owned.
Evidence: [browser manifest](../../../apps/stock/web-app/src/features/backtest/services/backtestApiV2.ts#L113), [dataset metadata](../../../apps/stock/orchestrator/src/data/historical-dataset-v2.ts#L34), [eligibility](../../../apps/stock/web-api/src/services/canonical-research.service.ts#L51). Story: [CL06](tasks/CL06.md).
### CL-F06 — Medium / Verified — Repeated experiment-client transport plumbing
Experiment and durable validation clients separately implement fetch, abort handling, JSON parsing, expected-status checks and domain-error wrapping. A small common transport layer can remove repetition while domain parsers and uncertain-acceptance rules remain explicit.
Evidence: [experiments](../../../apps/stock/web-app/src/features/experiments/services/experimentApi.ts#L44), [validation](../../../apps/stock/web-app/src/features/experiments/services/chronologicalValidationDurableApi.ts#L29). Story: [CL07](tasks/CL07.md).
### CL-F07 — Medium / Verified — Application modules combine independent lifetimes
At this baseline BacktestServiceV2 is 1,071 lines, StrategyDetailPage 796, ExperimentEditor 623, BacktestDetailPageV2 645 and useBacktestV2 571. The finding is mixed responsibility/state ownership, not a line-count rule: template operations, run admission, reproduction, version publication, preview ownership and selected-run monitoring have different lifetimes.
Evidence: [backtest service](../../../apps/stock/web-api/src/services/backtest-v2.service.ts#L167), [strategy detail](../../../apps/stock/web-app/src/features/strategies/StrategyDetailPage.tsx#L20), [experiment editor](../../../apps/stock/web-app/src/features/experiments/components/ExperimentEditor.tsx#L49), [backtest hook](../../../apps/stock/web-app/src/features/backtest/hooks/useBacktestV2.ts#L34). Stories: [CL08](tasks/CL08.md), [CL09](tasks/CL09.md), [CL10](tasks/CL10.md), [CL11](tasks/CL11.md).
### CL-F08 — Medium / Verified — Developer commands are inconsistent or stale
Root db:setup-ib, db:init and proxy commands point at absent files. docker:start omits MongoDB while infra:up includes it. These are command/configuration defects, not evidence that missing setup capabilities should be reimplemented from scratch.
Evidence: [root commands](../../../package.json#L55), [Docker helper](../../../scripts/docker.sh#L93). Story: [CL04](tasks/CL04.md).
### CL-F09 — Medium / Verified — Retired execution seams remain in current control flow
Current admission rejects non-catalog execution, but later retains a legacy snapshot fallback. The runner retains an explicit retired entrypoint, and the native wrapper exposes old and canonical exports together. Their presence is verified; unused/deletable status is not inferred. Historical readers, artifacts and useful old algorithms must survive.
Evidence: [canonical guard](../../../apps/stock/web-api/src/services/backtest-v2.service.ts#L461), [fallback](../../../apps/stock/web-api/src/services/backtest-v2.service.ts#L486), [retired entry](../../../apps/stock/orchestrator/src/backtest/BacktestRunner.ts#L70), [native exports](../../../apps/stock/engine/index.mjs#L28). Story: [CL12](tasks/CL12.md), limited to proven control-flow cleanup and boundary checks.
### CL-F10 — Low / Verified — Primary navigation advertises placeholder pages
Portfolio, Analytics and Settings appear in navigation while their routes only render Coming Soon. Existing run/experiment analytics are separate working capabilities and must remain accessible.
Evidence: [navigation](../../../apps/stock/web-app/src/lib/constants.ts#L32), [placeholder routes](../../../apps/stock/web-app/src/app/App.tsx#L34). Story: [CL13](tasks/CL13.md).

View file

@ -1,9 +1,9 @@
{
"schema_version": 1,
"plan_revision": "2026-10-24.78",
"plan_revision": "2026-10-26.79",
"repository_base": "b7aeca4",
"plan_status": "scheduled_backlog_complete",
"execution_authorized": true,
"plan_status": "cleanup_backlog_proposed",
"execution_authorized": false,
"execution_scope": {
"authorized_by": "Owner: commit and continue with the rest of the tasks till 100%",
"tasks": ["R05", "R07", "S06", "A01", "A02", "A03", "A04", "P04"],
@ -25,6 +25,44 @@
"Conditional DSL/cache/distributed optimization go/no-go"
]
},
"cleanup_scope": {
"requested_on": "2026-10-26",
"requested_by": "Owner: come up with stories for it",
"baseline_commit": "fbf2eb9e",
"planning_file": "CLEANUP.md",
"tasks": [
"CL01",
"CL02",
"CL03",
"CL04",
"CL05",
"CL06",
"CL07",
"CL08",
"CL09",
"CL10",
"CL11",
"CL12",
"CL13"
],
"first_wave": [
"CL01",
"CL03",
"CL04"
],
"authorization": "Stories and planning artifacts only. Top-level execution_authorized is false; historical execution_scope applies to the completed original backlog.",
"preserved_original_tasks": 55,
"preserved_original_completed_tasks": 45,
"excluded": [
"application implementation",
"agent launch",
"Git commits or pushes",
"performance work",
"financial policy changes",
"historical artifact or calculation deletion",
"AI research product redesign"
]
},
"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": [
{
@ -118,6 +156,10 @@
{
"id": "E9",
"title": "Migration and operational safeguards"
},
{
"id": "E10",
"title": "Cleanup and maintainability foundations"
}
],
"first_wave": ["C01", "C03", "C04", "W01"],
@ -2037,6 +2079,524 @@
"completed_commit": null,
"blocker": "Optional cross-service monitoring expansion; required run diagnostics belong to W01/F07 and paper readiness to S04.",
"release_gates": []
},
{
"id": "CL01",
"title": "Replace permissive DI configuration tests with production-path assertions",
"epic": "E10",
"priority": "P1",
"severity": "High",
"status": "ready",
"dependencies": [],
"decision_dependencies": [],
"task_file": "backlog/tasks/CL01.md",
"findings": [
"CL-F03"
],
"complexity": "M",
"specialization": "TypeScript infrastructure testing",
"write_locks": [
"di-builder-tests"
],
"parallel_policy": "Ready independently. Can run with CL03 and CL04 in isolated worktrees; do not share test-process module mocks. CL02 waits for this test baseline.",
"assignment": null,
"branch": null,
"pull_request": null,
"completed_commit": null,
"blocker": null,
"release_gates": [],
"integration_state": "planned",
"integration_base": "fbf2eb9e",
"review_notes": "Planning-only cleanup story requested 2026-10-26. Current implementation authorization is false. No implementation, tests or completion are claimed by this entry.",
"concrete_write_scope": [
"libs/core/di/test/container-builder.test.ts",
"libs/core/di/test/di.test.ts"
]
},
{
"id": "CL02",
"title": "Normalize database configuration once and enforce consistent service switches",
"epic": "E10",
"priority": "P1",
"severity": "High",
"status": "blocked",
"dependencies": [
"CL01"
],
"decision_dependencies": [],
"task_file": "backlog/tasks/CL02.md",
"findings": [
"CL-F01"
],
"complexity": "M",
"specialization": "TypeScript configuration and database adapters",
"write_locks": [
"di-configuration",
"di-container",
"di-builder-tests"
],
"parallel_policy": "After CL01. Must be serialized with CL03 because both can edit container/builder.ts; this is an actual-file lock, not an additional code dependency.",
"assignment": null,
"branch": null,
"pull_request": null,
"completed_commit": null,
"blocker": "Waiting for implementation prerequisites: CL01.",
"release_gates": [],
"integration_state": "planned",
"integration_base": "fbf2eb9e",
"review_notes": "Planning-only cleanup story requested 2026-10-26. Current implementation authorization is false. No implementation, tests or completion are claimed by this entry.",
"concrete_write_scope": [
"libs/core/config/src/schemas/database.schema.ts",
"libs/core/config/src/schemas/unified-app.schema.ts",
"libs/core/di/src/config/schemas/",
"libs/core/di/src/container/builder.ts",
"libs/core/di/src/registrations/database.registration.ts",
"libs/core/di/src/registrations/cache.registration.ts",
"test/integration/questdb-configuration.test.ts",
"libs/core/di/test/container-builder.test.ts",
"test/integration/store-configuration.test.ts"
]
},
{
"id": "CL03",
"title": "Roll back failed shared-service startup and clear initialization timers",
"epic": "E10",
"priority": "P1",
"severity": "High",
"status": "ready",
"dependencies": [],
"decision_dependencies": [],
"task_file": "backlog/tasks/CL03.md",
"findings": [
"CL-F02"
],
"complexity": "M",
"specialization": "TypeScript resource lifecycle and concurrency",
"write_locks": [
"di-container",
"di-service-lifecycle"
],
"parallel_policy": "Ready independently and disjoint from CL01/CL04. Serialize with CL02 on di-container; use separate test files from CL01.",
"assignment": null,
"branch": null,
"pull_request": null,
"completed_commit": null,
"blocker": null,
"release_gates": [],
"integration_state": "planned",
"integration_base": "fbf2eb9e",
"review_notes": "Planning-only cleanup story requested 2026-10-26. Current implementation authorization is false. No implementation, tests or completion are claimed by this entry.",
"concrete_write_scope": [
"libs/core/di/src/utils/lifecycle.ts",
"libs/core/di/src/container/builder.ts",
"libs/core/di/test/lifecycle.test.ts",
"test/integration/service-startup-rollback.test.ts"
]
},
{
"id": "CL04",
"title": "Provide one consistent research startup path and repair stale commands",
"epic": "E10",
"priority": "P1",
"severity": "Medium",
"status": "ready",
"dependencies": [],
"decision_dependencies": [],
"task_file": "backlog/tasks/CL04.md",
"findings": [
"CL-F08"
],
"complexity": "S",
"specialization": "Bun/Turbo developer tooling",
"write_locks": [
"root-scripts",
"docker-startup",
"startup-documentation"
],
"parallel_policy": "Ready independently. Can run with CL01/CL03. CL05 uses the existing libs/* workspace glob and must not edit root scripts concurrently.",
"assignment": null,
"branch": null,
"pull_request": null,
"completed_commit": null,
"blocker": null,
"release_gates": [],
"integration_state": "planned",
"integration_base": "fbf2eb9e",
"review_notes": "Planning-only cleanup story requested 2026-10-26. Current implementation authorization is false. No implementation, tests or completion are claimed by this entry.",
"concrete_write_scope": [
"package.json",
"scripts/docker.sh",
"scripts/test/workspace.test.ts",
"README.md",
"apps/stock/README.md",
"apps/stock/web-app/README.md"
]
},
{
"id": "CL05",
"title": "Extract shared dataset and reporting logic behind a research library boundary",
"epic": "E10",
"priority": "P2",
"severity": "High",
"status": "ready",
"dependencies": [
"D01",
"F08",
"R05"
],
"decision_dependencies": [
"ADR-001",
"ADR-003",
"ADR-004"
],
"task_file": "backlog/tasks/CL05.md",
"findings": [
"CL-F04"
],
"complexity": "M",
"specialization": "TypeScript domain boundaries and package migration",
"write_locks": [
"research-domain-package",
"dataset-domain",
"research-architecture-tests"
],
"parallel_policy": "Code-ready against completed D01/F08/R05. Independent of the DI stories. Serialize exact API file edits with CL08 and dataset-client edits with CL06; CL06/CL08 depend on this boundary.",
"assignment": null,
"branch": null,
"pull_request": null,
"completed_commit": null,
"blocker": null,
"release_gates": [],
"integration_state": "planned",
"integration_base": "fbf2eb9e",
"review_notes": "Planning-only cleanup story requested 2026-10-26. Current implementation authorization is false. No implementation, tests or completion are claimed by this entry.",
"concrete_write_scope": [
"apps/stock/orchestrator/src/data/historical-dataset-v2.ts",
"apps/stock/orchestrator/src/backtest/canonical-result.ts",
"apps/stock/web-api/src/services/canonical-research.service.ts",
"apps/stock/web-api/src/services/backtest-v2.service.ts",
"apps/stock/web-api/src/services/dataset-preparation.service.ts",
"apps/stock/web-api/src/services/validation-preview.ts",
"apps/stock/web-api/src/services/chronological-validation.service.ts",
"scripts/test/architecture.test.ts",
"tsconfig.check.json",
"libs/research/package.json",
"libs/research/tsconfig.json",
"libs/research/src/dataset-contracts.ts",
"libs/research/src/datasets.ts",
"libs/research/src/results.ts"
]
},
{
"id": "CL06",
"title": "Use shared dataset response schemas and eligibility checks in the workbench",
"epic": "E10",
"priority": "P2",
"severity": "Medium",
"status": "blocked",
"dependencies": [
"CL05"
],
"decision_dependencies": [],
"task_file": "backlog/tasks/CL06.md",
"findings": [
"CL-F05"
],
"complexity": "M",
"specialization": "Shared contracts and frontend validation",
"write_locks": [
"dataset-response-contracts",
"web-backtest-api"
],
"parallel_policy": "After CL05. Disjoint from CL07, which initially excludes backtestApiV2.ts; reserve this client file explicitly.",
"assignment": null,
"branch": null,
"pull_request": null,
"completed_commit": null,
"blocker": "Waiting for implementation prerequisites: CL05.",
"release_gates": [],
"integration_state": "planned",
"integration_base": "fbf2eb9e",
"review_notes": "Planning-only cleanup story requested 2026-10-26. Current implementation authorization is false. No implementation, tests or completion are claimed by this entry.",
"concrete_write_scope": [
"apps/stock/web-app/src/features/backtest/services/backtestApiV2.ts",
"apps/stock/web-api/src/services/canonical-research.service.ts",
"apps/stock/config/src/contracts/canonical-research.ts",
"libs/research/src/dataset-contracts.ts",
"test/integration/dataset-source-preparation-ui.test.tsx",
"test/integration/canonical-workbench.test.tsx"
]
},
{
"id": "CL07",
"title": "Share JSON transport handling across experiment and validation clients",
"epic": "E10",
"priority": "P2",
"severity": "Medium",
"status": "ready",
"dependencies": [],
"decision_dependencies": [],
"task_file": "backlog/tasks/CL07.md",
"findings": [
"CL-F06"
],
"complexity": "M",
"specialization": "Frontend HTTP contracts and retry semantics",
"write_locks": [
"web-experiment-transport"
],
"parallel_policy": "Ready independently. It can run with CL05/CL06 and frontend component stories only when actual client/test files are disjoint.",
"assignment": null,
"branch": null,
"pull_request": null,
"completed_commit": null,
"blocker": null,
"release_gates": [],
"integration_state": "planned",
"integration_base": "fbf2eb9e",
"review_notes": "Planning-only cleanup story requested 2026-10-26. Current implementation authorization is false. No implementation, tests or completion are claimed by this entry.",
"concrete_write_scope": [
"apps/stock/web-app/src/lib/api.ts",
"apps/stock/web-app/src/features/experiments/services/experimentApi.ts",
"apps/stock/web-app/src/features/experiments/services/chronologicalValidationDurableApi.ts",
"apps/stock/web-app/src/features/experiments/services/walkForwardApi.ts",
"apps/stock/web-app/src/lib/requestJson.ts",
"test/integration/research-http-transport.test.ts"
]
},
{
"id": "CL08",
"title": "Split backtest template, run and reproduction responsibilities behind the existing service",
"epic": "E10",
"priority": "P2",
"severity": "Medium",
"status": "blocked",
"dependencies": [
"CL05"
],
"decision_dependencies": [
"ADR-005",
"ADR-006"
],
"task_file": "backlog/tasks/CL08.md",
"findings": [
"CL-F07"
],
"complexity": "M",
"specialization": "TypeScript application services and PostgreSQL transactions",
"write_locks": [
"web-backtest-service",
"web-run-reproduction"
],
"parallel_policy": "After CL05. Must not overlap CL12 or another backtest service owner. Can run with disjoint frontend work.",
"assignment": null,
"branch": null,
"pull_request": null,
"completed_commit": null,
"blocker": "Waiting for implementation prerequisites: CL05.",
"release_gates": [],
"integration_state": "planned",
"integration_base": "fbf2eb9e",
"review_notes": "Planning-only cleanup story requested 2026-10-26. Current implementation authorization is false. No implementation, tests or completion are claimed by this entry.",
"concrete_write_scope": [
"apps/stock/web-api/src/services/backtest-v2.service.ts",
"apps/stock/web-api/src/services/run-reproduction.ts",
"apps/stock/web-api/src/services/reproduction-comparison.ts",
"apps/stock/web-api/src/routes/backtests-v2.routes.ts",
"apps/stock/web-api/src/services/backtests/templates.ts",
"apps/stock/web-api/src/services/backtests/runs.ts",
"apps/stock/web-api/src/services/backtests/reproduction.ts",
"apps/stock/web-api/src/services/backtests/results.ts"
]
},
{
"id": "CL09",
"title": "Separate strategy metadata, version inspection and publication UI",
"epic": "E10",
"priority": "P2",
"severity": "Medium",
"status": "ready",
"dependencies": [],
"decision_dependencies": [],
"task_file": "backlog/tasks/CL09.md",
"findings": [
"CL-F07"
],
"complexity": "M",
"specialization": "React strategy workflows",
"write_locks": [
"web-strategy-detail"
],
"parallel_policy": "Ready independently; disjoint from DI, CL06 and CL07. Reserve strategy detail/panel/test files against any other frontend owner.",
"assignment": null,
"branch": null,
"pull_request": null,
"completed_commit": null,
"blocker": null,
"release_gates": [],
"integration_state": "planned",
"integration_base": "fbf2eb9e",
"review_notes": "Planning-only cleanup story requested 2026-10-26. Current implementation authorization is false. No implementation, tests or completion are claimed by this entry.",
"concrete_write_scope": [
"apps/stock/web-app/src/features/strategies/StrategyDetailPage.tsx",
"apps/stock/web-app/src/features/strategies/components/",
"apps/stock/web-app/src/features/strategies/services/candidatePublication.ts",
"test/integration/strategy-workbench.test.tsx",
"apps/stock/web-app/src/features/strategies/components/StrategyVersionPanel.tsx",
"apps/stock/web-app/src/features/strategies/hooks/useStrategyClone.ts"
]
},
{
"id": "CL10",
"title": "Separate experiment modes and make draft/submission state explicit",
"epic": "E10",
"priority": "P2",
"severity": "Medium",
"status": "ready",
"dependencies": [],
"decision_dependencies": [],
"task_file": "backlog/tasks/CL10.md",
"findings": [
"CL-F07"
],
"complexity": "M",
"specialization": "React experiment workflow state",
"write_locks": [
"web-experiment-editor"
],
"parallel_policy": "Ready independently. Can run alongside CL07 only with disjoint authored client/test files and preserved public client contracts. Integration checks must cover their combination.",
"assignment": null,
"branch": null,
"pull_request": null,
"completed_commit": null,
"blocker": null,
"release_gates": [],
"integration_state": "planned",
"integration_base": "fbf2eb9e",
"review_notes": "Planning-only cleanup story requested 2026-10-26. Current implementation authorization is false. No implementation, tests or completion are claimed by this entry.",
"concrete_write_scope": [
"apps/stock/web-app/src/features/experiments/components/ExperimentEditor.tsx",
"apps/stock/web-app/src/features/experiments/components/ChronologicalValidationPreflight.tsx",
"apps/stock/web-app/src/features/experiments/components/WalkForwardPreflight.tsx",
"test/integration/experiments-ui.test.tsx",
"apps/stock/web-app/src/features/experiments/hooks/useExperimentSubmission.ts",
"apps/stock/web-app/src/features/experiments/components/ExperimentDraftForm.tsx"
]
},
{
"id": "CL11",
"title": "Separate backtest template loading, run monitoring and submission state",
"epic": "E10",
"priority": "P2",
"severity": "Medium",
"status": "ready",
"dependencies": [],
"decision_dependencies": [],
"task_file": "backlog/tasks/CL11.md",
"findings": [
"CL-F07"
],
"complexity": "M",
"specialization": "React asynchronous state and durable-run UX",
"write_locks": [
"web-backtest-monitor"
],
"parallel_policy": "Ready independently. Can run with CL08 because UI/client contracts remain stable. Serialize with other backtest page/hook owners; keep CL06 API-client edits separate.",
"assignment": null,
"branch": null,
"pull_request": null,
"completed_commit": null,
"blocker": null,
"release_gates": [],
"integration_state": "planned",
"integration_base": "fbf2eb9e",
"review_notes": "Planning-only cleanup story requested 2026-10-26. Current implementation authorization is false. No implementation, tests or completion are claimed by this entry.",
"concrete_write_scope": [
"apps/stock/web-app/src/features/backtest/hooks/useBacktestV2.ts",
"apps/stock/web-app/src/features/backtest/BacktestDetailPageV2.tsx",
"test/integration/backtest-run-controls.test.tsx",
"test/integration/canonical-workbench.test.tsx",
"apps/stock/web-app/src/features/backtest/hooks/useRunMonitoring.ts",
"apps/stock/web-app/src/features/backtest/hooks/useRunSubmission.ts"
]
},
{
"id": "CL12",
"title": "Simplify retired execution seams while preserving historical reads",
"epic": "E10",
"priority": "P2",
"severity": "Medium",
"status": "blocked",
"dependencies": [
"CL08"
],
"decision_dependencies": [
"ADR-005"
],
"task_file": "backlog/tasks/CL12.md",
"findings": [
"CL-F09"
],
"complexity": "M",
"specialization": "Compatibility cleanup and execution boundaries",
"write_locks": [
"web-backtest-service",
"legacy-execution-boundaries"
],
"parallel_policy": "After CL08. One owner for the affected execution/API seams. This is not authority to remove unrelated code merely because static imports look absent.",
"assignment": null,
"branch": null,
"pull_request": null,
"completed_commit": null,
"blocker": "Waiting for implementation prerequisites: CL08.",
"release_gates": [],
"integration_state": "planned",
"integration_base": "fbf2eb9e",
"review_notes": "Planning-only cleanup story requested 2026-10-26. Current implementation authorization is false. No implementation, tests or completion are claimed by this entry.",
"concrete_write_scope": [
"apps/stock/web-api/src/services/backtest-v2.service.ts",
"apps/stock/web-api/src/services/backtest-result.ts",
"apps/stock/orchestrator/src/backtest/BacktestRunner.ts",
"apps/stock/orchestrator/src/backtest/execution-engine.ts",
"apps/stock/orchestrator/src/api/rest/backtest.ts",
"scripts/test/architecture.test.ts"
]
},
{
"id": "CL13",
"title": "Hide placeholder navigation while preserving useful product routes",
"epic": "E10",
"priority": "P2",
"severity": "Low",
"status": "ready",
"dependencies": [],
"decision_dependencies": [],
"task_file": "backlog/tasks/CL13.md",
"findings": [
"CL-F10"
],
"complexity": "S",
"specialization": "React navigation and product clarity",
"write_locks": [
"web-navigation"
],
"parallel_policy": "Ready independently but lower priority than the first cleanup wave. Reserve route/navigation files against any concurrent product work.",
"assignment": null,
"branch": null,
"pull_request": null,
"completed_commit": null,
"blocker": null,
"release_gates": [],
"integration_state": "planned",
"integration_base": "fbf2eb9e",
"review_notes": "Planning-only cleanup story requested 2026-10-26. Current implementation authorization is false. No implementation, tests or completion are claimed by this entry.",
"concrete_write_scope": [
"apps/stock/web-app/src/lib/constants.ts",
"apps/stock/web-app/src/app/App.tsx",
"apps/stock/web-app/README.md",
"docs/guide/README.md",
"test/integration/navigation.test.tsx"
]
}
],
"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,64 @@
# CL01 — Replace permissive DI configuration tests with production-path assertions
Parent epic: E10. Priority/severity: P1 / High. Complexity: M. Specialization: TypeScript infrastructure testing.
Scheduling metadata: [manifest](../manifest.json). Read the [cleanup execution contract](../../CLEANUP.md#execution-contract). This story defines planned work; implementation has not been requested.
## User story and outcome
As a maintainer, I want configuration tests to fail when a valid configuration stops working, so subsequent cleanup has a trustworthy safety net.
Expected benefit: Removes false passing coverage before changes to configuration and startup.
## Verified evidence
- **Verified — CL-F03:** Several success tests also pass when any exception is thrown; the test file supplies its own toUnifiedConfig implementation through a module mock. [libs/core/di/test/container-builder.test.ts:114](../../../../libs/core/di/test/container-builder.test.ts#L114).
## Implementation scope
- Replace the locally reimplemented config normalizer with the real configuration path for builder tests. Use complete, valid fixtures and skip external initialization.
- Make successful construction assert actual registered configuration/services. Make invalid input assert the specific expected rejection.
- Remove success-or-error catch blocks and prevent module mocks from contaminating other suites. Keep tests for current supported behavior; CL02 owns regressions for currently broken options/settings.
Likely existing files/modules:
- `libs/core/di/test/container-builder.test.ts`
- `libs/core/di/test/di.test.ts`
## Exclusions
- No production configuration behavior changes.
- No blanket replacement of every infrastructure test or rewrite of the test runner.
## Dependencies and ownership
Implementation prerequisites: None.
Write locks: `di-builder-tests`.
Parallel execution: Ready independently. Can run with CL03 and CL04 in isolated worktrees; do not share test-process module mocks. CL02 waits for this test baseline.
## Acceptance criteria
1. Every success case fails if its production builder call throws; no assertion treats an arbitrary error as success.
2. Tests use the actual toUnifiedConfig and DI schemas and check resulting values, not only container existence.
3. Invalid fixtures have explicit rejection assertions; valid fixtures do not depend on network access, local credentials, or running stores.
4. Tests pass individually and alongside the existing real-path QuestDB configuration regression without leaking mocks.
## Mandatory verification
Use existing workspace builds. Tests requiring PostgreSQL/Redis must use explicitly disposable safety fixtures.
```sh
bun test libs/core/di/test/container-builder.test.ts
bun test test/integration/questdb-configuration.test.ts
bun run typecheck
```
Required regression cases: valid full config, invalid required fields, nested/flat normalization, QuestDB credential propagation, and module-mock isolation.
## Risks and definition of done
Removing permissive assertions may expose old invalid fixtures. Repair fixtures against the supported schema; do not weaken validation or rewrite expectations to conceal production defects.
Done means the acceptance criteria and relevant checks pass, an independent review accepts the focused diff, and the integrator records exact test results and a commit/reference in the manifest. Preserve the compatibility and financial invariants in the cleanup execution contract.

View file

@ -0,0 +1,79 @@
# CL02 — Normalize database configuration once and enforce consistent service switches
Parent epic: E10. Priority/severity: P1 / High. Complexity: M. Specialization: TypeScript configuration and database adapters.
Scheduling metadata: [manifest](../manifest.json). Read the [cleanup execution contract](../../CLEANUP.md#execution-contract). This story defines planned work; implementation has not been requested.
## User story and outcome
As a developer, I want my connection settings and explicit service-disable choices to reach the intended clients unchanged, so configuration cannot silently enable services or discard settings.
Expected benefit: Addresses a reproduced enable/disable defect and the same multi-stage mapping pattern that caused the QuestDB credential failure.
## Verified evidence
- **Verified — CL-F01:** An isolated probe with supplied enabled configurations and all three enable options false still resolves enabled PostgreSQL, MongoDB and cache configurations. [libs/core/di/src/container/builder.ts:88](../../../../libs/core/di/src/container/builder.ts#L88).
- **Verified — CL-F01:** The canonical PostgreSQL schema accepts SSL, pool size and timeouts, while the DI schema and registration omit them. [libs/core/config/src/schemas/database.schema.ts:4](../../../../libs/core/config/src/schemas/database.schema.ts#L4).
- **Verified — CL-F01:** Client registration reconstructs only part of the accepted PostgreSQL configuration. [libs/core/di/src/registrations/database.registration.ts:43](../../../../libs/core/di/src/registrations/database.registration.ts#L43).
## Implementation scope
- Use the existing core configuration schemas as the canonical database representation; keep compatibility aliases in a single boundary adapter rather than multiple reconstruction passes.
- Define consistent precedence: an explicit service option false disables that service; true permits but does not override an explicitly disabled configured service. Preserve documented defaults when neither is specified.
- Carry supported credentials, SSL, pool and timeout settings into client-specific configuration, including explicit ilpPort/influxPort translation. Audit accepted fields for silent loss and document supported mappings.
- Add real-path tests with distinctive nondefault values for each store. Update configuration types and DI registration together.
Likely existing files/modules:
- `libs/core/config/src/schemas/database.schema.ts`
- `libs/core/config/src/schemas/unified-app.schema.ts`
- `libs/core/di/src/config/schemas/`
- `libs/core/di/src/container/builder.ts`
- `libs/core/di/src/registrations/database.registration.ts`
- `libs/core/di/src/registrations/cache.registration.ts`
- `test/integration/questdb-configuration.test.ts`
- `libs/core/di/test/container-builder.test.ts`
Proposed new files/modules (names may be adjusted within this scope):
- `test/integration/store-configuration.test.ts`
## Exclusions
- No credential rotation, environment-file deletion, new configuration framework or database replacement.
- No connection to development trading state in automated tests; no financial-policy changes.
## Dependencies and ownership
Implementation prerequisites: [CL01](CL01.md).
Write locks: `di-configuration`, `di-container`, `di-builder-tests`.
Parallel execution: After CL01. Must be serialized with CL03 because both can edit container/builder.ts; this is an actual-file lock, not an additional code dependency.
## Acceptance criteria
1. The audit probe with configured stores enabled and explicit options false resolves disabled/null PostgreSQL, MongoDB and cache services without opening sockets.
2. Configured enabled=false remains disabled when the corresponding service option is true.
3. Nondefault PostgreSQL SSL, pool size and connection/idle timeouts reach final wire settings; QuestDB credentials and ports retain their existing regression guarantees.
4. Each supported database field has one explicit translation to the client representation; no accepted setting silently disappears during schema conversion.
5. Existing nested and flat configuration callers remain compatible, including intentional precedence when both appear.
## Mandatory verification
store-configuration.test.ts is a proposed new test file. Capture real client/wire configuration without connecting to stores; substitute external transports only where necessary.
```sh
bun run --cwd libs/core/di build
bun test libs/core/di/test/container-builder.test.ts
bun test test/integration/store-configuration.test.ts test/integration/questdb-configuration.test.ts
bun run typecheck
```
Required regression cases: all explicit disable switches, configured disable with option true, absent defaults, nested/flat precedence, optional credentials, SSL and nondefault pool/timeouts.
## Risks and definition of done
Configuration precedence and client SSL representations differ today. Preserve existing defaults, reject unsupported combinations explicitly, and do not make a broad strict-schema change that rejects unrelated process environment variables.
Done means the acceptance criteria and relevant checks pass, an independent review accepts the focused diff, and the integrator records exact test results and a commit/reference in the manifest. Preserve the compatibility and financial invariants in the cleanup execution contract.

View file

@ -0,0 +1,73 @@
# CL03 — Roll back failed shared-service startup and clear initialization timers
Parent epic: E10. Priority/severity: P1 / High. Complexity: M. Specialization: TypeScript resource lifecycle and concurrency.
Scheduling metadata: [manifest](../manifest.json). Read the [cleanup execution contract](../../CLEANUP.md#execution-contract). This story defines planned work; implementation has not been requested.
## User story and outcome
As a developer restarting services, I want a failed or timed-out initialization to release resources it acquired, so a retry starts from a clean state.
Expected benefit: Fixes a reproduced resource-ownership gap in shared DI startup without changing trading recovery.
## Verified evidence
- **Verified — CL-F02:** Initialization awaits Promise.all without rolling back earlier successful connections; an isolated cache-success/mongo-failure probe records no cache disconnect. [libs/core/di/src/utils/lifecycle.ts:24](../../../../libs/core/di/src/utils/lifecycle.ts#L24).
- **Verified — CL-F02:** Timeout promises retain timers after successful initialization. [libs/core/di/src/utils/lifecycle.ts:97](../../../../libs/core/di/src/utils/lifecycle.ts#L97).
- **Verified — CL-F02:** A failed lifecycle call rejects build before the caller receives a container to clean up. [libs/core/di/src/container/builder.ts:74](../../../../libs/core/di/src/container/builder.ts#L74).
## Implementation scope
- Track the resources and initialization work owned by a build attempt. Clean up acquired resources when initialization or service resolution fails.
- Clear initialization timeout handles when work settles. Keep startup failure bounded and retain cleanup ownership of any late-settling initializer.
- Reuse the existing lifecycle manager and client cleanup methods. Ensure cleanup errors do not hide the original startup failure and repeated cleanup is safe.
- Add failure-oriented tests with controlled deferred promises and fake/controlled timers; do not depend on live stores.
Likely existing files/modules:
- `libs/core/di/src/utils/lifecycle.ts`
- `libs/core/di/src/container/builder.ts`
- `libs/core/di/test/lifecycle.test.ts`
Proposed new files/modules (names may be adjusted within this scope):
- `test/integration/service-startup-rollback.test.ts`
## Exclusions
- No changes to ModeManager, strategy checkpoints, paper recovery, research leases or financial execution.
- No new lifecycle framework or blanket migration of all application shutdown handlers.
## Dependencies and ownership
Implementation prerequisites: None.
Write locks: `di-container`, `di-service-lifecycle`.
Parallel execution: Ready independently and disjoint from CL01/CL04. Serialize with CL02 on di-container; use separate test files from CL01.
## Acceptance criteria
1. When one service connects and another initialization fails, the connected service is cleaned up and build rejects with the original failure.
2. Resolution failures and timeouts also release resources acquired by that attempt; late successful initialization cannot leave an orphaned connection after failure.
3. Successful initialization leaves no pending startup timeout handles; failure paths clear settled-work timers.
4. Cleanup failure does not prevent remaining cleanup or conceal the initiating failure. Repeated shutdown is safe.
5. Existing successful startup and shutdown contracts remain covered; no tests require waiting for the production 30-second timeout.
## Mandatory verification
service-startup-rollback.test.ts is a proposed new test file. Use simulated services and controlled clocks; no databases or native builds are needed.
```sh
bun test libs/core/di/test/lifecycle.test.ts
bun test test/integration/service-startup-rollback.test.ts
bun run typecheck
```
Required regression cases: partial success followed by failure, dependency-resolution exception, timeout, late completion, cleanup exception, repeated cleanup and successful timer disposal.
## Risks and definition of done
A timeout does not cancel an arbitrary promise. The implementation must retain responsibility for pending work and clean up late resources, rather than assuming Promise.race cancelled initialization.
Done means the acceptance criteria and relevant checks pass, an independent review accepts the focused diff, and the integrator records exact test results and a commit/reference in the manifest. Preserve the compatibility and financial invariants in the cleanup execution contract.

View file

@ -0,0 +1,71 @@
# CL04 — Provide one consistent research startup path and repair stale commands
Parent epic: E10. Priority/severity: P1 / Medium. Complexity: S. Specialization: Bun/Turbo developer tooling.
Scheduling metadata: [manifest](../manifest.json). Read the [cleanup execution contract](../../CLEANUP.md#execution-contract). This story defines planned work; implementation has not been requested.
## User story and outcome
As a developer, I want documented startup commands to launch the required research services on predictable ports, so getting the workbench running does not require debugging obsolete scripts.
Expected benefit: Removes three broken command targets and inconsistent infrastructure startup.
## Verified evidence
- **Verified — CL-F08:** db:setup-ib, db:init and proxy reference files absent at the audit baseline; docker:start and infra:up use different paths. [package.json:55](../../../../package.json#L55).
- **Verified — CL-F08:** docker:start starts Dragonfly, PostgreSQL and QuestDB but omits MongoDB, unlike infra:up. [scripts/docker.sh:93](../../../../scripts/docker.sh#L93).
## Implementation scope
- Offer one clearly named research development command selecting web-api, orchestrator and web-app through existing tooling; reuse the current build dependencies.
- Make the documented infrastructure-start aliases agree on required stores and the supported Docker Compose invocation.
- Remove obsolete missing-file aliases or redirect them only to existing, reviewed equivalents. Preserve migration safeguards; ordinary startup must never execute destructive init/reset scripts.
- Document ports 2003/2004/5173 and required authentication configuration without printing or generating new secrets. Add dry-run/command-target checks to existing tooling tests.
Likely existing files/modules:
- `package.json`
- `scripts/docker.sh`
- `scripts/test/workspace.test.ts`
- `README.md`
- `apps/stock/README.md`
- `apps/stock/web-app/README.md`
## Exclusions
- No new process supervisor, deployment stack or package manager.
- No automatic reset, credential changes, provider ingestion, paper/live activation or startup of optional monitoring/admin services.
## Dependencies and ownership
Implementation prerequisites: None.
Write locks: `root-scripts`, `docker-startup`, `startup-documentation`.
Parallel execution: Ready independently. Can run with CL01/CL03. CL05 uses the existing libs/* workspace glob and must not edit root scripts concurrently.
## Acceptance criteria
1. Every retained script alias resolves to an existing executable target or documented installed tool; the three identified missing-file commands are repaired or removed.
2. The research dev task plan contains exactly the three intended application dev roles plus required build tasks; it does not start ingestion or activate paper/live accounts.
3. Infrastructure aliases agree on their store set and propagate failures instead of printing success after a failed Compose command.
4. Documentation matches actual commands and fixed ports. Existing .env files and contents remain intact.
5. Tests can verify task selection and command targets without starting services or provisioning containers.
## Mandatory verification
Use existing workspace builds. Tests requiring PostgreSQL/Redis must use explicitly disposable safety fixtures.
```sh
bun test scripts/test/workspace.test.ts
bun run build --dry=json
git diff --check
```
Required regression cases: missing command targets, exact dev task selection, startup failure exit propagation, and exclusion of reset/init/activation commands.
## Risks and definition of done
Changing convenience aliases can break local habits. Keep safe compatibility aliases where useful and make intentionally removed aliases explicit in documentation.
Done means the acceptance criteria and relevant checks pass, an independent review accepts the focused diff, and the integrator records exact test results and a commit/reference in the manifest. Preserve the compatibility and financial invariants in the cleanup execution contract.

View file

@ -0,0 +1,84 @@
# CL05 — Extract shared dataset and reporting logic behind a research library boundary
Parent epic: E10. Priority/severity: P2 / High. Complexity: M. Specialization: TypeScript domain boundaries and package migration.
Scheduling metadata: [manifest](../manifest.json). Read the [cleanup execution contract](../../CLEANUP.md#execution-contract). This story defines planned work; implementation has not been requested.
## User story and outcome
As a backend or research-tool developer, I want reusable dataset and reporting logic to have a stable package interface, so clients do not import another application implementation directory.
Expected benefit: Creates a small shared boundary for the API, workers and future research clients while preserving existing behavior.
## Verified evidence
- **Verified — CL-F04:** Web admission imports worker-application implementation modules directly. [apps/stock/web-api/src/services/canonical-research.service.ts:31](../../../../apps/stock/web-api/src/services/canonical-research.service.ts#L31).
- **Verified — CL-F04:** Result reading imports the orchestrator reporting implementation. [apps/stock/web-api/src/services/backtest-v2.service.ts:37](../../../../apps/stock/web-api/src/services/backtest-v2.service.ts#L37).
- **Verified — CL-F04:** V2 validation mixes reusable normalization/hashing with a legacy conversion dependency. [apps/stock/orchestrator/src/data/historical-dataset-v2.ts:1](../../../../apps/stock/orchestrator/src/data/historical-dataset-v2.ts#L1).
## Implementation scope
- Introduce one focused libs/research workspace, @stock-bot/research, using the existing libs/* workspace pattern. Publish explicit browser-safe dataset-contract, server dataset-validation and pure result-analysis subpaths.
- Move only reusable V2 normalization/validation/hash and canonical statistical-report code. Keep provider IO, legacy source adaptation, worker supervision, build-file inspection and sandbox execution in application adapters.
- Keep thin compatibility re-exports at existing imports during migration; establish one implementation, not duplicate helpers. Do not relocate every historical contract or create a package per concept.
- Replace the API imports of these moved pure helpers and add import/bundle boundaries. Existing stock-config contract subpaths may remain dependencies when they load no configuration manager or application runtime.
Likely existing files/modules:
- `apps/stock/orchestrator/src/data/historical-dataset-v2.ts`
- `apps/stock/orchestrator/src/backtest/canonical-result.ts`
- `apps/stock/web-api/src/services/canonical-research.service.ts`
- `apps/stock/web-api/src/services/backtest-v2.service.ts`
- `apps/stock/web-api/src/services/dataset-preparation.service.ts`
- `apps/stock/web-api/src/services/validation-preview.ts`
- `apps/stock/web-api/src/services/chronological-validation.service.ts`
- `scripts/test/architecture.test.ts`
- `tsconfig.check.json`
Proposed new files/modules (names may be adjusted within this scope):
- `libs/research/package.json`
- `libs/research/tsconfig.json`
- `libs/research/src/dataset-contracts.ts`
- `libs/research/src/datasets.ts`
- `libs/research/src/results.ts`
## Exclusions
- No NAPI/Rust financial changes, new API routes, generic plugin/DI framework or relocation of provider adapters.
- No persisted schema/hash changes, edited historical artifact bytes, new feature caching, DSL or performance work.
## Dependencies and ownership
Implementation prerequisites: [D01](D01.md), [F08](F08.md), [R05](R05.md).
Write locks: `research-domain-package`, `dataset-domain`, `research-architecture-tests`.
Parallel execution: Code-ready against completed D01/F08/R05. Independent of the DI stories. Serialize exact API file edits with CL08 and dataset-client edits with CL06; CL06/CL08 depend on this boundary.
## Acceptance criteria
1. There is one implementation of moved V2 and report behavior; the old entrypoints are compatibility facades rather than copies.
2. The new library has no imports of apps/*/src implementation paths, service containers, databases, native bindings or application entrypoints.
3. The dataset-contract subpath bundles for the browser without node:crypto, filesystem access or native code; server hashing stays outside that entrypoint.
4. Existing dataset hash fixtures, acceptance/rejection cases and canonical analytics outputs remain identical.
5. The web API uses the shared package for moved helpers. Native-worker bundling and original-result reading still pass; old retained artifacts are preserved.
## Mandatory verification
Build the changed package and worker artifacts in the assigned checkout before integration tests. Preserve existing retained artifact fixtures rather than rebaselining economic output.
```sh
bun run build
bun test scripts/test/architecture.test.ts test/integration/historical-dataset-v2.test.ts test/integration/canonical-result.test.ts
bun test test/integration/canonical-sma.test.ts test/integration/retained-strategy-worker.test.ts
bun run typecheck
```
Required regression cases: browser-safe imports, one validation implementation, golden dataset hashes, metadata round trips, canonical analytics equivalence and retained-worker execution.
## Risks and definition of done
Hash property order, module-local prepared-object caches and worker build identities can change accidentally during moves. Preserve semantic outputs and retained executable bytes; new current builds must not overwrite original reproduction artifacts.
Done means the acceptance criteria and relevant checks pass, an independent review accepts the focused diff, and the integrator records exact test results and a commit/reference in the manifest. Preserve the compatibility and financial invariants in the cleanup execution contract.

View file

@ -0,0 +1,74 @@
# CL06 — Use shared dataset response schemas and eligibility checks in the workbench
Parent epic: E10. Priority/severity: P2 / Medium. Complexity: M. Specialization: Shared contracts and frontend validation.
Scheduling metadata: [manifest](../manifest.json). Read the [cleanup execution contract](../../CLEANUP.md#execution-contract). This story defines planned work; implementation has not been requested.
## User story and outcome
As a researcher, I want the browser and API to interpret dataset responses consistently, so valid datasets do not fail because independent schema copies drift.
Expected benefit: Removes a large inline manifest schema and repeated eligibility rules from the backtest client.
## Verified evidence
- **Verified — CL-F05:** The client defines a second substantial dataset manifest schema and preparation-response validation. [apps/stock/web-app/src/features/backtest/services/backtestApiV2.ts:113](../../../../apps/stock/web-app/src/features/backtest/services/backtestApiV2.ts#L113).
- **Verified — CL-F05:** The server defines overlapping calendar, series, bounds and corporate-action structures. [apps/stock/orchestrator/src/data/historical-dataset-v2.ts:34](../../../../apps/stock/orchestrator/src/data/historical-dataset-v2.ts#L34).
- **Verified — CL-F05:** Workbench dataset eligibility is enforced separately at admission. [apps/stock/web-api/src/services/canonical-research.service.ts:51](../../../../apps/stock/web-api/src/services/canonical-research.service.ts#L51).
## Implementation scope
- Reuse the CL05 browser-safe structural schemas in dataset catalog/preparation response parsing.
- Centralize workbench-specific structural eligibility checks used by response consistency checks and admission, without broadening the single-asset/single-series policy.
- Keep expected-request/hash identity checks at the client boundary and full dataset-byte/hash validation at execution. Shared shape validation must not pretend to authenticate dataset content.
- Preserve existing prepared/stored-source response contracts, explicit unavailable reasons and immutable retained inputs.
Likely existing files/modules:
- `apps/stock/web-app/src/features/backtest/services/backtestApiV2.ts`
- `apps/stock/web-api/src/services/canonical-research.service.ts`
- `apps/stock/config/src/contracts/canonical-research.ts`
- `test/integration/dataset-source-preparation-ui.test.tsx`
- `test/integration/canonical-workbench.test.tsx`
Prerequisite output: `libs/research/src/dataset-contracts.ts` is proposed by CL05 and must exist before this story begins; it is not present at this audit baseline.
## Exclusions
- No new datasets UI, automatic calendar assumptions, changed content hashes or wider execution eligibility.
- No browser hashing of full datasets, client-authoritative eligibility or weakened worker checks.
## Dependencies and ownership
Implementation prerequisites: [CL05](CL05.md).
Write locks: `dataset-response-contracts`, `web-backtest-api`.
Parallel execution: After CL05. Disjoint from CL07, which initially excludes backtestApiV2.ts; reserve this client file explicitly.
## Acceptance criteria
1. Calendar/series/bounds/action response structures have one shared schema definition used by the server and browser.
2. Valid server preparation and catalog fixtures are accepted by the browser; malformed or mismatched identities still fail.
3. Eligibility and unavailable-reason consistency match between UI response parsing and server admission for supported and unsupported fixtures.
4. A browser build of this client contains no native/file/database or Node hashing dependencies.
5. Stored snapshots, normalized bars, v1/v2 hash fixtures and exact run provenance remain unchanged.
## Mandatory verification
Use existing workspace builds. Tests requiring PostgreSQL/Redis must use explicitly disposable safety fixtures.
```sh
bun test test/integration/dataset-source-preparation-ui.test.tsx test/integration/canonical-workbench.test.tsx
bun test test/integration/dataset-source-preparation.test.ts test/integration/historical-dataset-v2.test.ts
bun test scripts/test/architecture.test.ts
bun run typecheck
```
Required regression cases: eligible/unsupported series, missing calendars/actions, malformed fields, corrupt response hashes, expected-request mismatch and browser dependency boundaries.
## Risks and definition of done
Manifest validation and full content integrity are different boundaries. Consolidate shared structures without dropping contextual checks or treating a catalog entry as proof that retained bars are valid.
Done means the acceptance criteria and relevant checks pass, an independent review accepts the focused diff, and the integrator records exact test results and a commit/reference in the manifest. Preserve the compatibility and financial invariants in the cleanup execution contract.

View file

@ -0,0 +1,75 @@
# CL07 — Share JSON transport handling across experiment and validation clients
Parent epic: E10. Priority/severity: P2 / Medium. Complexity: M. Specialization: Frontend HTTP contracts and retry semantics.
Scheduling metadata: [manifest](../manifest.json). Read the [cleanup execution contract](../../CLEANUP.md#execution-contract). This story defines planned work; implementation has not been requested.
## User story and outcome
As a frontend maintainer, I want one small transport helper for repeated experiment request handling, so error and cancellation behavior stays consistent.
Expected benefit: Removes duplicated request/JSON/status handling without combining independent domain workflows.
## Verified evidence
- **Verified — CL-F06:** Experiment requests implement fetch, abort handling, JSON decoding, expected-status checks and uncertainty classification. [apps/stock/web-app/src/features/experiments/services/experimentApi.ts:44](../../../../apps/stock/web-app/src/features/experiments/services/experimentApi.ts#L44).
- **Verified — CL-F06:** Chronological validation repeats the same transport sequence with a different domain parser/error type. [apps/stock/web-app/src/features/experiments/services/chronologicalValidationDurableApi.ts:29](../../../../apps/stock/web-app/src/features/experiments/services/chronologicalValidationDurableApi.ts#L29).
## Implementation scope
- Extract a small browser JSON request helper and apply it first to ordinary/cost experiment, durable chronological-validation and walk-forward clients.
- Keep endpoint schemas, request identity comparisons and operation-specific error messages beside each domain client. Preserve cancellation as cancellation and existing ambiguous-acceptance classifications.
- Keep browser cookie transport separate from ResearchClient bearer credentials; reuse shared response parsers already present.
- Avoid hidden retries, generalized request managers, new state libraries or a policy-heavy client framework.
Likely existing files/modules:
- `apps/stock/web-app/src/lib/api.ts`
- `apps/stock/web-app/src/features/experiments/services/experimentApi.ts`
- `apps/stock/web-app/src/features/experiments/services/chronologicalValidationDurableApi.ts`
- `apps/stock/web-app/src/features/experiments/services/walkForwardApi.ts`
Proposed new files/modules (names may be adjusted within this scope):
- `apps/stock/web-app/src/lib/requestJson.ts`
- `test/integration/research-http-transport.test.ts`
## Exclusions
- No backtestApiV2.ts migration in this story; CL06 owns its dataset parser cleanup.
- No auth weakening, new automatic retries, endpoint/receipt changes, or mandatory conversion of every HTTP client.
## Dependencies and ownership
Implementation prerequisites: None.
Write locks: `web-experiment-transport`.
Parallel execution: Ready independently. It can run with CL05/CL06 and frontend component stories only when actual client/test files are disjoint.
## Acceptance criteria
1. The selected clients share fetch/JSON/status plumbing while retaining their public method and error contracts.
2. Aborted reads remain distinguishable from failed writes; no retry occurs unless explicitly requested by the caller.
3. Lost responses, malformed accepted responses and server failures preserve the current uncertain-submission behavior and receipt inputs.
4. Unexpected success statuses, invalid envelopes and wrong response identities still reject.
5. Browser requests include cookies; research-agent tokens are neither introduced into the browser nor routed through this helper.
## Mandatory verification
research-http-transport.test.ts is a proposed new test file. Substitute only HTTP responses; exercise the production helper and existing domain clients.
```sh
bun test test/integration/research-http-transport.test.ts
bun test test/integration/experiments-ui.test.tsx test/integration/chronological-validation-durable-ui.test.tsx test/integration/walk-forward-ui.test.tsx
bun test test/integration/experiment-retries-ui.test.tsx test/integration/cost-sensitivity-ui.test.tsx
bun run typecheck
```
Required regression cases: abort, network loss, invalid JSON, wrong 2xx status, 4xx/5xx domain errors, identity mismatch, cookie forwarding and absence of implicit POST retries.
## Risks and definition of done
A generic helper can erase distinctions between uncertain acceptance and definitive rejection. Keep those policies explicit in the domain client and preserve existing race/retry tests.
Done means the acceptance criteria and relevant checks pass, an independent review accepts the focused diff, and the integrator records exact test results and a commit/reference in the manifest. Preserve the compatibility and financial invariants in the cleanup execution contract.

View file

@ -0,0 +1,76 @@
# CL08 — Split backtest template, run and reproduction responsibilities behind the existing service
Parent epic: E10. Priority/severity: P2 / Medium. Complexity: M. Specialization: TypeScript application services and PostgreSQL transactions.
Scheduling metadata: [manifest](../manifest.json). Read the [cleanup execution contract](../../CLEANUP.md#execution-contract). This story defines planned work; implementation has not been requested.
## User story and outcome
As a backend developer, I want coherent backtest application modules, so changing reproduction or run admission does not require navigating a thousand-line service.
Expected benefit: Reduces the number of unrelated behaviors sharing one class while preserving existing API and transaction contracts.
## Verified evidence
- **Verified — CL-F07:** BacktestServiceV2 combines template CRUD, run admission, controls, results, reproduction and row mapping in 1,071 lines at the audit baseline. [apps/stock/web-api/src/services/backtest-v2.service.ts:167](../../../../apps/stock/web-api/src/services/backtest-v2.service.ts#L167).
## Implementation scope
- Keep BacktestServiceV2 as a compatible facade while extracting focused template operations, run submission/control operations and reproduction/result readers within the same application.
- Move logic with its existing transaction boundaries, identity checks and error types. Pass the existing query/transaction client through helpers; do not open nested pool transactions.
- Use the shared CL05 report/domain helpers. Keep schema mappings explicit and avoid a new generic repository/service layer for each table.
- Preserve idempotent receipt lookup before current eligibility checks and keep run/outbox insertion atomic.
Likely existing files/modules:
- `apps/stock/web-api/src/services/backtest-v2.service.ts`
- `apps/stock/web-api/src/services/run-reproduction.ts`
- `apps/stock/web-api/src/services/reproduction-comparison.ts`
- `apps/stock/web-api/src/routes/backtests-v2.routes.ts`
Proposed new files/modules (names may be adjusted within this scope):
- `apps/stock/web-api/src/services/backtests/templates.ts`
- `apps/stock/web-api/src/services/backtests/runs.ts`
- `apps/stock/web-api/src/services/backtests/reproduction.ts`
- `apps/stock/web-api/src/services/backtests/results.ts`
## Exclusions
- No schema migration, endpoint redesign, new simulator, financial calculations or receipt-key changes.
- No cleanup of legacy execution branches in this extraction; CL12 follows it.
## Dependencies and ownership
Implementation prerequisites: [CL05](CL05.md).
Write locks: `web-backtest-service`, `web-run-reproduction`.
Parallel execution: After CL05. Must not overlap CL12 or another backtest service owner. Can run with disjoint frontend work.
## Acceptance criteria
1. Existing service callers and routes retain method signatures, HTTP behavior and persisted result shapes.
2. Templates, admission/controls and reproduction/results have focused implementation modules; the facade does not duplicate extracted logic.
3. Same-key retries after edits/archive or eligibility changes recover the original admitted request; conflicting key reuse still fails.
4. Run and dispatch writes remain atomic; single-connection transactions do not acquire another pool client.
5. Reproduction pins retained original inputs/builds, and result reading still verifies provenance and reports missing canonical data explicitly.
## Mandatory verification
PostgreSQL tests require disposable stock_bot_safety* and Redis DB15 fixtures under the existing harness; never run them on development research or paper state. Extend existing admission/reproduction transaction tests.
```sh
bun test test/integration/run-reproduction-api.test.ts test/integration/reproduction-comparison.test.ts test/integration/canonical-durable-runner.test.ts
bun test test/integration/canonical-workbench.test.tsx test/integration/backtest-run-controls.test.tsx
bun run test:postgres
bun run typecheck
```
Required regression cases: receipt replay/conflicts, concurrent submission, archive races, cancellation, one-connection transaction behavior, result corruption and unavailable original builds.
## Risks and definition of done
Splitting code can accidentally move a check outside a lock or create nested transactions. Review operation order and test actual concurrent SQL behavior, not just mocked method calls.
Done means the acceptance criteria and relevant checks pass, an independent review accepts the focused diff, and the integrator records exact test results and a commit/reference in the manifest. Preserve the compatibility and financial invariants in the cleanup execution contract.

View file

@ -0,0 +1,73 @@
# CL09 — Separate strategy metadata, version inspection and publication UI
Parent epic: E10. Priority/severity: P2 / Medium. Complexity: M. Specialization: React strategy workflows.
Scheduling metadata: [manifest](../manifest.json). Read the [cleanup execution contract](../../CLEANUP.md#execution-contract). This story defines planned work; implementation has not been requested.
## User story and outcome
As a strategy developer, I want version inspection, parameter editing and publication to be understandable independent workflows, so changes to one do not disturb the others.
Expected benefit: Reduces the responsibilities and coupled state in StrategyDetailPage without changing strategy authoring semantics.
## Verified evidence
- **Verified — CL-F07:** One 796-line file contains metadata editing, version selection, parameters, publication, cloning, history and comparison. [apps/stock/web-app/src/features/strategies/StrategyDetailPage.tsx:20](../../../../apps/stock/web-app/src/features/strategies/StrategyDetailPage.tsx#L20).
## Implementation scope
- Extract focused version inspection/comparison, metadata, and publication/clone panels or hooks as justified by their state ownership.
- Keep the route component responsible for selected strategy/version identity and composing panels. Reuse existing CandidatePublication, BuiltinReview and parameter components.
- Preserve exact clone/publication receipts, dirty-draft protection, parent/version identity checks and stale-response rejection.
- Use explicit local action states where they replace coupled Boolean flags; do not add a global state framework.
Likely existing files/modules:
- `apps/stock/web-app/src/features/strategies/StrategyDetailPage.tsx`
- `apps/stock/web-app/src/features/strategies/components/`
- `apps/stock/web-app/src/features/strategies/services/candidatePublication.ts`
- `test/integration/strategy-workbench.test.tsx`
Proposed new files/modules (names may be adjusted within this scope):
- `apps/stock/web-app/src/features/strategies/components/StrategyVersionPanel.tsx`
- `apps/stock/web-app/src/features/strategies/hooks/useStrategyClone.ts`
## Exclusions
- No browser IDE, new strategy/package format, review-policy changes or activation controls.
- No redesign of the future AI research workspace or removal of version/evidence history.
## Dependencies and ownership
Implementation prerequisites: None.
Write locks: `web-strategy-detail`.
Parallel execution: Ready independently; disjoint from DI, CL06 and CL07. Reserve strategy detail/panel/test files against any other frontend owner.
## Acceptance criteria
1. The route composes focused components instead of defining the complete version comparison/publication workflow inline.
2. Changing routes/versions cannot apply an old response to a new selection or lose an unacknowledged receipt silently.
3. Metadata, parameter, clone and candidate drafts preserve their current unsaved-change and retry behavior.
4. Archived/read-only/missing-version states, clone recovery and immutable version links remain functional.
5. Existing catalog review and candidate-isolation distinctions remain visible and unchanged.
## Mandatory verification
Use existing workspace builds. Tests requiring PostgreSQL/Redis must use explicitly disposable safety fixtures.
```sh
bun test test/integration/strategy-workbench.test.tsx test/integration/candidate-publication-ui.test.tsx
bun test test/integration/canonical-workbench.test.tsx
bun run typecheck
```
Required regression cases: version navigation races, dirty draft confirmation, ambiguous clone/publication response, archived family, review failure and immutable version reopen.
## Risks and definition of done
Extracted panels can reset state by remounting or keep state under the wrong version. Preserve the deliberate keyed identity boundaries and ownership checks.
Done means the acceptance criteria and relevant checks pass, an independent review accepts the focused diff, and the integrator records exact test results and a commit/reference in the manifest. Preserve the compatibility and financial invariants in the cleanup execution contract.

View file

@ -0,0 +1,75 @@
# CL10 — Separate experiment modes and make draft/submission state explicit
Parent epic: E10. Priority/severity: P2 / Medium. Complexity: M. Specialization: React experiment workflow state.
Scheduling metadata: [manifest](../manifest.json). Read the [cleanup execution contract](../../CLEANUP.md#execution-contract). This story defines planned work; implementation has not been requested.
## User story and outcome
As a researcher configuring experiments, I want parameter sweeps, cost studies and validation recipes to have clear action ownership, so switching modes cannot lose or duplicate work.
Expected benefit: Makes the 623-line ExperimentEditor easier to maintain while retaining its important receipt and race protections.
## Verified evidence
- **Verified — CL-F07:** The editor combines multiple experiment kinds, template loading, candidate state, preview revisions and mutually exclusive submission owners. [apps/stock/web-app/src/features/experiments/components/ExperimentEditor.tsx:49](../../../../apps/stock/web-app/src/features/experiments/components/ExperimentEditor.tsx#L49).
- **Verified — CL-F07:** Chronological and walk-forward preflight components share draft fields and submission ownership through the same parent. [apps/stock/web-app/src/features/experiments/components/ExperimentEditor.tsx:589](../../../../apps/stock/web-app/src/features/experiments/components/ExperimentEditor.tsx#L589).
## Implementation scope
- Extract focused template/candidate selection, ordinary/cost preview-submission, and validation recipe composition at coherent state boundaries.
- Represent each action as an explicit draft/preview/submitting/uncertain/accepted state where that replaces coupled refs and Booleans. Keep concurrency coordination local to this workspace.
- Retain a single coordinator for mutually exclusive submissions and exact frozen key/body custody after an ambiguous response.
- Keep current response parsers, reset-segment validation semantics, invalidation rules and unsaved-change behavior.
Likely existing files/modules:
- `apps/stock/web-app/src/features/experiments/components/ExperimentEditor.tsx`
- `apps/stock/web-app/src/features/experiments/components/ChronologicalValidationPreflight.tsx`
- `apps/stock/web-app/src/features/experiments/components/WalkForwardPreflight.tsx`
- `test/integration/experiments-ui.test.tsx`
Proposed new files/modules (names may be adjusted within this scope):
- `apps/stock/web-app/src/features/experiments/hooks/useExperimentSubmission.ts`
- `apps/stock/web-app/src/features/experiments/components/ExperimentDraftForm.tsx`
## Exclusions
- No new optimizer, validation policy, data model or financial behavior.
- No HTTP client/transport edits owned by CL07 and no global workflow/state-machine framework.
## Dependencies and ownership
Implementation prerequisites: None.
Write locks: `web-experiment-editor`.
Parallel execution: Ready independently. Can run alongside CL07 only with disjoint authored client/test files and preserved public client contracts. Integration checks must cover their combination.
## Acceptance criteria
1. The parent composes coherent workflows and owns one explicit submission coordinator; it no longer manages all request and form transitions inline.
2. Changing template, candidate, grid or mode invalidates only the matching preview and cannot submit stale data.
3. An uncertain accepted request keeps its exact body/key and blocks conflicting ordinary/chronological/walk-forward submission until resolved or explicitly abandoned.
4. Late responses after navigation or newer edits cannot overwrite current preview, errors or receipts.
5. Saved experiment IDs, validation reports, failed-trial visibility and current comparison links remain unchanged.
## Mandatory verification
Use existing workspace builds. Tests requiring PostgreSQL/Redis must use explicitly disposable safety fixtures.
```sh
bun test test/integration/experiments-ui.test.tsx test/integration/cost-sensitivity-ui.test.tsx
bun test test/integration/chronological-validation-durable-ui.test.tsx test/integration/walk-forward-ui.test.tsx
bun test test/integration/experiment-retries-ui.test.tsx
bun run typecheck
```
Required regression cases: mode switching, edited-after-preview, candidate parameter changes, concurrent clicks, ambiguous response, exact receipt retry, navigation races and explicit discard.
## Risks and definition of done
A visually cleaner form can accidentally weaken mutual exclusion or regenerate a receipt. Preserve the current race tests and test transitions rather than only rendered snapshots.
Done means the acceptance criteria and relevant checks pass, an independent review accepts the focused diff, and the integrator records exact test results and a commit/reference in the manifest. Preserve the compatibility and financial invariants in the cleanup execution contract.

View file

@ -0,0 +1,74 @@
# CL11 — Separate backtest template loading, run monitoring and submission state
Parent epic: E10. Priority/severity: P2 / Medium. Complexity: M. Specialization: React asynchronous state and durable-run UX.
Scheduling metadata: [manifest](../manifest.json). Read the [cleanup execution contract](../../CLEANUP.md#execution-contract). This story defines planned work; implementation has not been requested.
## User story and outcome
As a researcher, I want saved-template editing, run selection and job submission to remain independent, so navigation and retries behave predictably.
Expected benefit: Reduces the responsibilities of the 571-line backtest hook without discarding its existing correctness protections.
## Verified evidence
- **Verified — CL-F07:** The hook owns template CRUD, eligibility, selected-run request chains, polling, submission receipts and cancellation. [apps/stock/web-app/src/features/backtest/hooks/useBacktestV2.ts:34](../../../../apps/stock/web-app/src/features/backtest/hooks/useBacktestV2.ts#L34).
- **Verified — CL-F07:** A 645-line page composes template configuration, controls, run history and result presentation. [apps/stock/web-app/src/features/backtest/BacktestDetailPageV2.tsx:1](../../../../apps/stock/web-app/src/features/backtest/BacktestDetailPageV2.tsx#L1).
## Implementation scope
- Extract focused template state, selected-run monitoring and submission/cancellation helpers behind the current useBacktestV2 facade.
- Keep one owner for the selected status-then-results request chain. Generation checks and AbortControllers must still reject stale responses.
- Keep template archival, browser monitoring stop and server job cancellation distinct. Preserve exact in-memory receipt custody through ambiguous submissions.
- Reduce page wiring only where this extraction makes it redundant; reuse current result/configuration components.
Likely existing files/modules:
- `apps/stock/web-app/src/features/backtest/hooks/useBacktestV2.ts`
- `apps/stock/web-app/src/features/backtest/BacktestDetailPageV2.tsx`
- `test/integration/backtest-run-controls.test.tsx`
- `test/integration/canonical-workbench.test.tsx`
Proposed new files/modules (names may be adjusted within this scope):
- `apps/stock/web-app/src/features/backtest/hooks/useRunMonitoring.ts`
- `apps/stock/web-app/src/features/backtest/hooks/useRunSubmission.ts`
## Exclusions
- No browser-persistent receipt journal, new backend controls, pause/resume support or financial result reconstruction.
- No dataset/HTTP parser edits owned by CL06 and no general hook framework.
## Dependencies and ownership
Implementation prerequisites: None.
Write locks: `web-backtest-monitor`.
Parallel execution: Ready independently. Can run with CL08 because UI/client contracts remain stable. Serialize with other backtest page/hook owners; keep CL06 API-client edits separate.
## Acceptance criteria
1. useBacktestV2 retains its public return contract while delegating distinct lifetimes to focused helpers.
2. Only the selected run/backtest identity can update status, errors or results; changing the parent route fences earlier requests.
3. Polling, WebSocket refresh and cancellation acknowledgement share one serialized refresh chain without overlapping result requests.
4. Uncertain submissions reuse the original key/body even after template edits or archival; creating a new logical request remains explicit.
5. Leaving a page stops browser observation without cancelling server work. Completed/cancelled/failed/missing results stay distinct and reopen correctly.
## Mandatory verification
Use existing workspace builds. Tests requiring PostgreSQL/Redis must use explicitly disposable safety fixtures.
```sh
bun test test/integration/backtest-run-controls.test.tsx test/integration/canonical-workbench.test.tsx
bun test test/integration/run-reproduction-ui.test.tsx
bun run typecheck
```
Required regression cases: selected-run and parent navigation races, reload, late status/results, WebSocket invalidation during a poll, cancellation failure, archive while pending and exact receipt retry.
## Risks and definition of done
Moving refs between hooks can change their lifetime or create stale closures. Preserve identity ownership and existing interaction tests; do not replace this with several independent polling effects.
Done means the acceptance criteria and relevant checks pass, an independent review accepts the focused diff, and the integrator records exact test results and a commit/reference in the manifest. Preserve the compatibility and financial invariants in the cleanup execution contract.

View file

@ -0,0 +1,73 @@
# CL12 — Simplify retired execution seams while preserving historical reads
Parent epic: E10. Priority/severity: P2 / Medium. Complexity: M. Specialization: Compatibility cleanup and execution boundaries.
Scheduling metadata: [manifest](../manifest.json). Read the [cleanup execution contract](../../CLEANUP.md#execution-contract). This story defines planned work; implementation has not been requested.
## User story and outcome
As a strategy developer, I want the supported execution path to be obvious, so obsolete APIs and impossible fallback branches do not look like alternative financial authorities.
Expected benefit: Removes confirmed-unreachable new-run code and sharpens supported-versus-compatibility boundaries without deleting useful history.
## Verified evidence
- **Verified — CL-F09:** New run admission rejects non-catalog requests before retaining legacy snapshot fallback branches later in the same method. [apps/stock/web-api/src/services/backtest-v2.service.ts:461](../../../../apps/stock/web-api/src/services/backtest-v2.service.ts#L461).
- **Verified — CL-F09:** The legacy runBacktest entry exists only to reject execution. [apps/stock/orchestrator/src/backtest/BacktestRunner.ts:70](../../../../apps/stock/orchestrator/src/backtest/BacktestRunner.ts#L70).
- **Verified — CL-F09:** Legacy and canonical native exports remain adjacent; this alone does not prove legacy exports are unused. [apps/stock/engine/index.mjs:28](../../../../apps/stock/engine/index.mjs#L28).
## Implementation scope
- Inventory the callers of touched legacy seams and classify each as supported execution, historical result compatibility, preserved research, or explicit retired-API rejection in the story handoff.
- Remove branches proved unreachable after canonical admission and stop carrying their legacy input requirements through current run helpers.
- Keep explicit retired-API responses small and truthful. Preserve their current HTTP/status behavior unless a separately approved API change is required.
- Extend existing architecture checks so canonical entrypoints cannot regain legacy accounting/fill fallback dependencies. Preserve compatibility result readers and retained artifacts.
Likely existing files/modules:
- `apps/stock/web-api/src/services/backtest-v2.service.ts`
- `apps/stock/web-api/src/services/backtest-result.ts`
- `apps/stock/orchestrator/src/backtest/BacktestRunner.ts`
- `apps/stock/orchestrator/src/backtest/execution-engine.ts`
- `apps/stock/orchestrator/src/api/rest/backtest.ts`
- `scripts/test/architecture.test.ts`
## Exclusions
- No mass deletion or rewrite of old strategies, calculation APIs, legacy Rust exports, short-trade examples, financial fixtures or stored results.
- No changes to historical request/result formats, economic policies, original reproduction artifacts or supported risk controls.
## Dependencies and ownership
Implementation prerequisites: [CL08](CL08.md).
Write locks: `web-backtest-service`, `legacy-execution-boundaries`.
Parallel execution: After CL08. One owner for the affected execution/API seams. This is not authority to remove unrelated code merely because static imports look absent.
## Acceptance criteria
1. Current run submission contains no fallback branch that its admission guard makes impossible.
2. Canonical entrypoint dependency checks forbid legacy financial execution; retired APIs still return their documented rejection rather than starting work.
3. Existing legacy result mapping and historical reads pass unchanged; callers of every removed branch are documented and verified.
4. Native financial output, strategy decisions, fees and equity remain identical on existing deterministic fixtures.
5. No preserved calculation capability, retained artifact or compatibility reader is removed without separate evidence and scope approval.
## Mandatory verification
Use existing workspace builds. Tests requiring PostgreSQL/Redis must use explicitly disposable safety fixtures.
```sh
bun test scripts/test/architecture.test.ts
bun test test/integration/canonical-durable-runner.test.ts test/integration/backtest-result-mapping.test.ts
bun test test/integration/canonical-sma.test.ts test/integration/strategy-runtime.test.ts
bun run typecheck
```
Required regression cases: retired entry rejection, canonical-only admission, historical result reads, no legacy fallback and unchanged economic fixtures.
## Risks and definition of done
Runtime exports and retained artifacts have consumers beyond simple source imports. Keep native exports and preserved algorithms out of this story; distinguish unreachable control flow from merely old code.
Done means the acceptance criteria and relevant checks pass, an independent review accepts the focused diff, and the integrator records exact test results and a commit/reference in the manifest. Preserve the compatibility and financial invariants in the cleanup execution contract.

View file

@ -0,0 +1,72 @@
# CL13 — Hide placeholder navigation while preserving useful product routes
Parent epic: E10. Priority/severity: P2 / Low. Complexity: S. Specialization: React navigation and product clarity.
Scheduling metadata: [manifest](../manifest.json). Read the [cleanup execution contract](../../CLEANUP.md#execution-contract). This story defines planned work; implementation has not been requested.
## User story and outcome
As a user, I want navigation to lead to functioning workflows, so unfinished pages do not imply capabilities the product does not have.
Expected benefit: Immediately reduces misleading navigation without committing to a new AI research interface.
## Verified evidence
- **Verified — CL-F10:** Portfolio, Analytics and Settings are top-level navigation items. [apps/stock/web-app/src/lib/constants.ts:32](../../../../apps/stock/web-app/src/lib/constants.ts#L32).
- **Verified — CL-F10:** Those destinations currently render Coming Soon placeholders. [apps/stock/web-app/src/app/App.tsx:34](../../../../apps/stock/web-app/src/app/App.tsx#L34).
## Implementation scope
- Remove placeholder destinations from primary navigation while keeping existing direct URLs readable with a clear unavailable message.
- Keep working strategy, backtest, experiment, research, market-data, system and paper-review navigation intact.
- Update current product documentation to match the visible menu and add focused route/navigation coverage.
- Do not relabel completed backtest analytics as a new standalone Analytics capability.
Likely existing files/modules:
- `apps/stock/web-app/src/lib/constants.ts`
- `apps/stock/web-app/src/app/App.tsx`
- `apps/stock/web-app/README.md`
- `docs/guide/README.md`
Proposed new files/modules (names may be adjusted within this scope):
- `test/integration/navigation.test.tsx`
## Exclusions
- No deletion of portfolio/analytics domain code or existing run/experiment analytics.
- No redesign of Research around chat, MCP, notebooks or an unapproved product workflow; no deployment activation changes.
## Dependencies and ownership
Implementation prerequisites: None.
Write locks: `web-navigation`.
Parallel execution: Ready independently but lower priority than the first cleanup wave. Reserve route/navigation files against any concurrent product work.
## Acceptance criteria
1. The primary menu contains no links to pages that only say Coming Soon.
2. Existing placeholder URLs remain explicit and safe to open; working deep links and authentication boundaries remain unchanged.
3. Implemented run/experiment analytics, research-agent access and paper-review pages remain discoverable.
4. Navigation tests cover desktop/mobile data sources or their shared navigation model and direct-route behavior.
## Mandatory verification
navigation.test.tsx is a proposed new test file. Test the shared navigation model and route output without provisioning application infrastructure.
```sh
bun test test/integration/navigation.test.tsx
bun test test/integration/canonical-workbench.test.tsx
bun run typecheck
```
Required regression cases: placeholder visibility, working link targets, retained deep links, authenticated routing and existing analytics access.
## Risks and definition of done
A menu cleanup can accidentally make a working capability inaccessible. Hide only verified placeholders and preserve existing route identities.
Done means the acceptance criteria and relevant checks pass, an independent review accepts the focused diff, and the integrator records exact test results and a commit/reference in the manifest. Preserve the compatibility and financial invariants in the cleanup execution contract.