stock-bot/docs/development/CLEANUP.md

9 KiB
Raw Blame History

Cleanup and maintainability plan

Current acceptance: all 13 cleanup stories received independent review; the resulting cache/configuration corrections and check evidence are recorded in real-data-research.md. Earlier review-pending statements below describe the historical execution state.

Baseline: fbf2eb9e, inspected October 26, 2026. This extends the existing development backlog. The original 45 scheduled tasks remain complete; these 13 cleanup stories are new work. The owner subsequently authorized implementation and validated commits; progress and checks are recorded in cleanup-execution.md. All 13 stories are implemented and validated. They remain in review until an independent reviewer signs off; no additional agents have been launched.

manifest.json remains the scheduling source of truth. It records task states, prerequisites, priorities and write locks. This page explains the execution contract and recommended order; it is not a second status tracker. Current evidence is appended to findings.md.

Objective

Reduce the maintenance cost of the existing TypeScript research platform while preserving the canonical Rust financial core, immutable research inputs and results, candidate isolation, durable execution and reviewed calculations. This prepares stable interfaces for the agreed editor/Codex/research-tool direction without implementing MCP, notebooks or a new AI workflow yet.

Story index

Story Outcome Priority Size Implementation prerequisites
CL01 Replace permissive DI tests with production-path assertions P1 M None
CL02 Normalize connection settings and honor service-disable switches P1 M CL01
CL03 Roll back failed shared-service startup and clear timers P1 M None
CL04 Repair commands and provide one consistent research startup path P1 S None
CL05 Extract shared dataset/report logic behind one research package P2 M Completed D01, F08, R05
CL06 Share dataset response schemas and eligibility checks P2 M CL05
CL07 Share experiment/validation HTTP transport plumbing P2 M None
CL08 Split backtest application-service responsibilities P2 M CL05
CL09 Separate strategy metadata, versions and publication UI P2 M None
CL10 Separate experiment modes and submission state P2 M None
CL11 Separate template, run-monitoring and submission lifetimes P2 M None
CL12 Remove unreachable execution seams while preserving compatibility P2 M CL08
CL13 Hide placeholder navigation while preserving useful routes P2 S None

Each story contains a user outcome, verified repository evidence, intended behavior, affected paths, exclusions, ownership, acceptance criteria, mandatory verification and regression risks. Proposed new test/module names are labelled as proposed rather than claimed existing capabilities.

Dependency and integration order

flowchart LR
    CL01[CL01: trustworthy DI tests] --> CL02[CL02: configuration]
    CL03[CL03: startup rollback]
    CL04[CL04: developer commands]
    BASE[Completed D01 / F08 / R05] --> CL05[CL05: shared domain boundary]
    CL05 --> CL06[CL06: dataset response schemas]
    CL05 --> CL08[CL08: backtest application modules]
    CL08 --> CL12[CL12: retired execution seams]
    CL07[CL07: HTTP transport]
    CL09[CL09: strategy UI]
    CL10[CL10: experiment UI]
    CL11[CL11: backtest UI state]
    CL13[CL13: navigation]

Edges are code prerequisites. File locks are additional scheduling constraints: CL02 and CL03 both touch the DI builder and must not run together, even though neither needs the other's behavior. CL04 owns root scripts; CL05 uses the existing workspace glob and must coordinate any unexpectedly required root-script edits. CL07 starts with experiment clients, leaving the backtest API client to CL06.

Recommended progression:

  1. Establish the DI test baseline, repair shared startup, and remove broken development commands.
  2. Complete CL02 once CL01 is accepted and CL03 releases the DI builder lock. Begin the CL05 domain extraction independently.
  3. Follow CL05 with CL06 and CL08; keep their actual imports/contracts coordinated. CL07 can proceed independently against unchanged client contracts.
  4. Refactor one frontend workflow at a time, then simplify CL12's confirmed-unreachable execution branches. CL13 is an independent small cleanup when navigation is otherwise idle.

This is a preferred sequence, not an artificial dependency chain. Unrelated frontend work can proceed sooner when ownership and review capacity are available.

First execution wave

CL01, CL03 and CL04 are the first independent assignments. The owner has authorized implementation and validated commits. The earlier completion authorization remains historical evidence for the completed original backlog.

Story Why first Writable ownership Completion evidence
CL01 Prevents false passing configuration tests before normalization DI builder tests only Valid fixtures use production normalization; arbitrary exceptions fail; focused tests pass without stores
CL03 Fixes reproduced partial-startup resource retention DI lifecycle, builder startup and dedicated lifecycle tests Partial failure/timeout cleans up, late work retains cleanup ownership, and timers do not leak
CL04 Removes broken commands and inconsistent startup Root scripts, Docker helper, workspace tests and startup docs Existing command targets, exact three-role research dev plan, consistent store set and failure propagation

These three assignments have disjoint authored paths. For a solo maintainer, start at most two implementers concurrently and retain capacity for independent review; rotate the third task into the next free slot. Test-process module mocks, native build outputs and database fixtures must remain isolated. This plan does not launch agents.

Execution contract

  • Read the task, current manifest, approved relevant architecture decisions and QUALITY-GATES.md. Scope is the selected story, not permission to implement neighboring cleanup.
  • ready means code prerequisites are satisfied. The current top-level execution_authorized is true following the owner’s explicit cleanup implementation request. Scope remains these stories; conditional performance/product tasks are excluded.
  • Use one focused branch/worktree per implementation when multiple agents are used. Claim exact files and write locks in the manifest before edits. An unexpected overlap requires coordination before changing the shared file.
  • Preserve Rust financial semantics, strategy targets/state, exact financial output, command idempotency, receipt recovery, run/outbox atomicity, leases, paper recovery and original reproduction inputs.
  • Preserve historical result readers, retained source/build artifacts, reviewed calculation APIs and useful legacy research. No broad dead-code deletion or native-export removal follows from this plan.
  • Keep the existing .env files. Do not rotate, print or remove credentials. No development trading database is a test fixture.
  • Run the story's focused tests and type checks. The integrator runs bun run check on the combined batch and the relevant disposable PostgreSQL/browser suites when the affected boundary requires them. Report skipped/unavailable checks honestly; do not add benchmarks to a cleanup story.
  • Rebuild changed workspaces/worker artifacts in the assigned checkout before tests that consume built packages. Native/economic fixtures must not be rebaselined to conceal changed behavior.
  • Review failure behavior and compatibility independently before marking a task done. Record exact commands/results and accepted commit references in the manifest. User authorization controls commits, pushes, PRs and any subsequent implementation.

Scope deliberately left for later

The six original conditional tasks remain deferred with their existing triggers. This cleanup does not resume performance profiling, shared feature caches, result paging, a Rust strategy DSL or additional optimization.

The AI-assisted data-exploration/MCP/notebook workflow needs its own product stories after its tools and interfaces are agreed. CL05/CL06/CL07 make those clients easier to add; they do not implement or approve them. Research-page redesign, browser IDEs, fitted-model/forward-label validation, new financial policies and multi-asset/live activation are outside this cleanup epic.

The existing financial core and failure-oriented regression suites are preservation targets. Large financial modules are not split merely to reduce line counts.