stock-bot/docs/development/ROADMAP.md

24 KiB
Raw Blame History

Revised development roadmap

Baseline b7aeca4 · reviewed 2026-10-22 · First five waves committed; next implementation policy-gated; see manifest execution_scope

Authorization update: the first five waves are independently reviewed, validated and committed. The latest “commit and continue” authorized the W04 implementation and planning closeout commits. Continuation readiness was checked: no remaining scheduled task has both code and architecture-policy prerequisites satisfied. Explicit approval is requested for ADR-002/003/004 before F01 and D01; no policy approval is inferred from a generic continuation request. Pushes, PRs and trading operations remain outside scope.

Strategy and review outcome

Use TypeScript for strategies, research and the web product; one Rust kernel owns money, risk, matching and replay. Preserve durable decisions/checkpoints, transactional execution, frozen datasets, reviewed calculations and failure-oriented tests.

The skeptical review consolidates 52 separate task definitions into 43 scheduled tasks plus 5 conditional tasks. Four old IDs remain merged redirects, not extra work. This is a smaller delivery plan, not a smaller correctness standard. See review findings and dispositions, complete index and canonical manifest.

The existing web workbench improves during engine migration. Legacy results remain labelled; fixing controls or terminal valuation does not make same-bar economics trustworthy. C06 blocks shared-runtime legacy research rather than building another soon-to-be-retired simulator runtime.

Decisions to approve

Decision Direction Approval
ADR-001 TS product/strategy code; Rust financial authority; retain monolith and workers User-mandated
ADR-002 Maintained checked decimal; 8-place half-up postings; authoritative remaining cost; owner books from day one; initial cash-funded long-only account Explicit economic approval
ADR-003 Availability/event phases; open-only next-interval matching; explicit zero-latency convention; mark-open terminal policy; account risk-session clock Explicit execution/data approval
ADR-004 NAPI pull sessions in existing workers; tagged decision barriers; IPC for untrusted code; no embedded JS Plan approval
ADR-005 One Rust transition kernel; resident research state; private staged paper state under existing SQL transactions Plan approval
ADR-006 Existing API/queue/database; immutable versions, provenance and evidence retention; no laboratory framework Plan approval
ADR-007 Isolated untrusted code, research-only permissions/budgets; human-only paper promotion; live disabled Explicit trust-model approval
ADR-008 Measure actual paths; cursor replay and bounded trials; caching/DSL only when measured Plan approval; later optimization go/no-go

Long-only is a proposed first canonical model, not deletion of short history or a silent change to current paper accounts. If first-release shorts are required, approve borrowing/margin policy and fixtures before F01. C01/C03/C04/W01 do not depend on those unresolved economic choices.

Milestones

Milestone Tasks Exit criterion
M0: safe interim behavior C01/C02/C03/C04/C06; O01; P01 Scoped terminal/funding/input fixes; failed init cleans up; shared-runtime research rejected; migration lock and honest baseline measurements
M1: usable current workbench W01–W04 Save, submit, cancel, inspect and reopen tested in browser; unsupported controls hidden; legacy economic limitations visible
M2: canonical Rust/TS research F01/F02/F04–F08, D01, S01/S02; R01/R10/W03/C06 then R05 Owner-aware finance, deterministic replay, one TS strategy and retained input provenance work through durable runs
M3: useful research product R02/R03/R04/R11/R12 Catalog/workspace/dataset selection and original reproduction; metadata/UI proceed alongside engine work
M4: batch research and validation R06–R09, P04; S05 when ready Bounded sweeps, summary comparisons, OOS/reset-segment walk-forward and measured worker scaling; regime panels only with S05
M5: paper parity and AI research S03/S04, A01–A04 Recovery parity, operator readiness, isolated bounded AI experiments and evidence-linked human paper promotion
M6: remove duplicates / optional speed S06; conditional D04/P03/P05/P06/O02 Retire duplicate economics only after cutover proof; optional work requires demonstrated need

Rows are outcomes, not a sequential waterfall. S03 does not wait for research UI or statistical reporting; basic experiments do not wait for regime models or feature caches.

Critical path and parallel lanes

flowchart LR
  F01[Contract + economic fixtures] --> F02[Owned ledger] --> F04[Risk + reservations] --> F05[Matcher]
  F05 --> F06[Deterministic cursor replay]
  D01[Availability-aware eligible datasets] --> F06
  P01[Existing-path measurements] --> F06
  F06 --> F07[Bounded NAPI sessions] --> S01[TS decisions] --> S02[One SMA]
  C02[Boundary integrity] --> F07
  F06 --> F08[Canonical projections + reviewed TS statistics]
  S02 --> R05[Durable canonical runs]
  F08 --> R05
  PRODUCT[Versions / retained artifacts / safe submission] --> R05
  C06[Runtime containment] --> R05
  R05 --> R06[Bounded experiments] --> P04[Measured parallel trials]
  R06 --> R08[Chronological validation]
  R06 --> A01[Research authorization] --> A02[Untrusted code isolation]
  R08 --> A03[AI evidence loop]
  A02 --> A03
  S01 --> S03[Durable Rust paper adapter]

The full dependency graph includes all code and decision gates. Solid task edges are implementation prerequisites. Dotted task edges are release/conditional gates, not blockers to integrating component work.

After approval, run one financial-core owner alongside one web/product owner and one data/benchmark/metadata owner. Serialize shared DTOs, migration registry, worker protocol and actual overlapping files. Core tasks F01/F02/F04/F05 must not be split among agents simultaneously.

First wave: four independent assignments

Completed wave; the table records its original rationale. Exact prompts, paths, commands, commit references and verification results: FIRST-WAVE.md.

Task Why now Ownership / unlock
C01 Final native equity currently omits liquidation costs Legacy Rust engine/results only; preserves a known arithmetic fixture for migration
C03 Existing gross-capital guard ignores fee liability TS execution model only; safer interim paper behavior without a new financing model
C04 Partially initialized runtime can retain resources ModeManager lifecycle only; unlocks C06 containment
W01 Current user-facing cancellation/status can mislead Frontend controls/hooks only; unlocks W02 and the tested workbench

Recommend 3 simultaneous implementers, reserving one slot for coordination/independent review. Start C01 + C03 + W01; rotate C04 into the first freed slot, or start C04 first if runtime containment is the immediate operational need. These four have no mutual code dependencies and disjoint writable files. Four concurrent implementers are technically possible but not recommended without separate review capacity.

O01/P01, W03 and W04 are committed. W04 adds validated real-browser end-to-end verification of the existing workbench. F01/D01 still require their ADR approvals; no subsequent implementation starts before its prerequisites are satisfied.

Second-wave handoff — 2026-10-22

All three tasks are done / validated_committed following owner approval: C02 ee670a3, C06 43ffb54, W02 fe00ecd. Worktrees are retained under /tmp/stock-bot-wave2.M9vHDK/.

Task Implemented and verified
C02 Whole-load native validation preserves previously admitted data on any invalid row. Indexed errors cover malformed rows, OHLCV/VWAP, timestamps and unsupported types. 1001ms/1999ms remain distinct. Identical/conflicting duplicates and decreasing timestamps now reject explicitly; optional VWAP and zero volume remain accepted.
C06 Default paper composition uses native research. Legacy TS requires explicit role: 'research-only'; startup and both exposed mode initializers reject cross-role activation before effects. Real paper account/ledger/checkpoint hashes and lifecycle stay unchanged through native success/cancel/failure jobs, and the paper feed continues afterward. No second execution framework was added.
W02 Saved configuration and dataset evidence are distinguished from mutable legacy display fallbacks. Missing artifact/build versions stay unknown; known metric placeholders are unavailable while measured TS zeros remain visible. Limitations appear beside performance, and mutable legacy capital cannot fabricate cash profit. No stored results or financial calculations were rewritten.

Combined integration gates:

  • CARGO_BUILD_JOBS=2 bun run check: passed all gates; 54 tooling, 43 utility, 35 calculation, 293 integration and 37 Rust tests, with no failures. Build, typecheck, contracts, lint and secret audit passed. The 47 native bridge cases are included in integration, not an additional count.
  • bun run test:postgres against disposable stock_bot_safety PostgreSQL and Redis DB15: 47 passed, 267 assertions. Includes two real-ledger research-isolation regressions. Temporary fixture containers were removed after validation; development databases/services were untouched.
  • git diff --check: passed. All 21 authored implementation/test files match reviewed worktrees; the rebuilt integration addon hash is in the manifest.

Native subprocess builds/IPC and fixture networking required sandbox escalation. Existing Rust/frontend build warnings remain. Explicit linting of the old W01 test harness still reports its unchanged test-only curly findings; the repository lint gate and new scoped code checks pass. No real-browser E2E coverage is claimed here.

Limits: composition guards are not an untrusted-code sandbox; same-bar execution, canonical Rust accounting and owner-aware funding remain future tasks. ADR-002/003/004 still gate F01, and ADR-007 gates AI isolation. No push, PR or trading operation occurred. Subsequent O01/P01 work is tracked separately in the manifest.

Third-wave handoff — 2026-10-22

O01 and P01 are independently reviewed and validated_committed: O01 bba5aa1, P01 2e851ec. Four implementation/test files were integrated from isolated worktrees under /tmp/stock-bot-wave3.VjJvWX/. The owner subsequently authorized W03 continuation.

  • O01: Startup migrations acquire one transaction-scoped advisory lock on the same client before table initialization, discovery, checks, application and recording. The additive allowlist and SQL scripts are unchanged. Real PostgreSQL tests prove competing-client blocking, SQL/record failure rollback and retry, destructive-script exclusion, and preservation of saved runs, datasets, ledger and checkpoints.
  • P01: bun run scripts/benchmark-research.ts runs a tiny deterministic self-test; --measure runs 1k/10k total-bar workloads over 1/10 assets. Three SMA configurations repeat twice per fresh process, with two processes per workload. Source/artifact/runtime/host/seed identities, raw phases, result bytes, RSS and economic hashes are retained. Existing dataset benchmarking is unchanged; no engine or financial behavior changed.

Combined gates passed: CARGO_BUILD_JOBS=2 bun run check (58 tooling, 43 utility, 35 calculation, 293 integration and 37 Rust tests; zero failures), plus bun run test:postgres (51 tests, 301 assertions). The four new migration cases and four benchmark cases are included in those totals. Explicit ESLint on all four files, standalone strict benchmark TypeScript checking and git diff --check also passed. Temporary PostgreSQL/Redis containers and their disposable data were removed afterward; development services were untouched. Worktrees and local measurement artifacts are retained.

Release measurements on Linux/x64, Ryzen 9 9950X3D, Bun 1.2.17 / rustc 1.88.0:

Total bars / assets Median whole-trial ms Median bars/s
1,000 / 1 20.4 48,962
1,000 / 10 17.4 57,419
10,000 / 1 193.7 51,631
10,000 / 10 167.3 59,769

Whole-trial timing includes native construction/load/run, JS parsing, validation and hashing, but excludes fresh-process startup and initial dataset preparation (reported separately). All 48 trials reproduced economic hashes. Release addon SHA-256: 324f1e18de495791e9e53c4e36be39d0b165a11e13e9bcd82f5ca2b22d014674. Raw timings and metadata: /tmp/stock-bot-wave3.VjJvWX/research-release.json; durable summary and hashes are in the manifest. The subsequent full check rebuilt the debug addon; its separate identity is also recorded.

These are single-host synthetic baseline measurements, not a speedup claim or financial certification. Reused JS inputs still reload the one-shot native engine each trial; native run includes serialization and logging. Native execution dominates the measured phases, but no internal bottleneck attribution is claimed. Callbacks, shared caches, queue/storage latency, allocation counts and parallel simulation remain explicitly unmeasured. 100k is opt-in and was not run. Linux peak RSS uses /proc/self/status VmHWM after Bun's maxRSS counter proved unreliable; unsupported platforms report unavailable.

No DSL, cache, scheduler or new service is justified by this wave. Same-bar execution and canonical ownership/funding remain gated future work. O01/P01 were committed with owner approval; no pushes, PRs or trading operations occurred.

Fourth-wave handoff — 2026-10-22

W03 is independently reviewed and validated_committed as 9b9403e following owner approval. Backend and frontend contributors used separate worktrees under /tmp/stock-bot-wave4.iEBUTZ/ with a pinned API contract. All 18 implementation/test files match their reviewed versions.

  • Save / Save and run: Web saves explicitly send autoStart:false. Save and run keeps the saved definition and original submission body/key through rejection or a lost response; retry does not save another definition. Immediate ref guards prevent duplicate clicks. Close waits for an unresolved definition write; closing after saving refreshes the list. Detail submissions have separate errors, explicit retry controls and late-navigation guards.
  • Durable admission: Idempotency-Key is scoped to the existing verified operator or service principal, not a caller-supplied identity or browser-session nonce. A normalized intent fingerprint distinguishes retries from conflicts. Parent-row locking, immutable request snapshots and dispatch insertion remain in one transaction; the unique principal/key constraint also covers concurrent submissions across different definitions. Matching retries return the original run; changed intent returns 409 with existing 202/Location success behavior.
  • Migration / compatibility: New additive 14-backtest-submission.sql is admitted by O01's serialized startup runner. Legacy NULL-key rows remain readable. Omitted autoStart retains legacy auto-start, and keyless clients retain non-idempotent behavior. New web paths opt into explicit save and keyed submission. No financial simulation or paper-state behavior changed.

Combined validation:

  • CARGO_BUILD_JOBS=2 bun run check: all gates passed; 60 tooling, 43 utility, 35 calculation, 310 integration and 37 Rust tests; zero failures. The 36 DOM interaction cases and 12 security cases are included in these totals, not additional suites.
  • bun run test:postgres: 58 tests, 345 assertions, zero failures against disposable PostgreSQL/Redis, including a final rerun after the combined build. A database barrier proves both cross-definition contenders reach INSERT before release; tests verify one run/outbox, rollback/retry, numbering, principal separation, cookie renewal, frozen snapshots and preserved legacy rows.
  • Explicit frontend typecheck, application-source lint, production build and git diff --check passed. Existing Rust/frontend warnings and the unchanged 12 curly findings in the old DOM test harness remain; the repository lint gate passes.

Independent review caught and corrected premature list refresh while saving and a submission error hidden after changing selected runs; dedicated real-component/route regressions cover both. Local logs and hashes are recorded in the manifest. Disposable test containers and their recreatable fixture data were removed; development services were untouched. Worktrees are retained.

Limits: UI retry identities are component-lifetime state, not recovery across reload/navigation. Definition POST response loss is not covered by run-submission idempotency. Operator/service scopes are the existing single-operator security model, not new user accounts or AI authorization. DOM tests do not prove browser layout, virtualized rows or full browser/API execution; that is W04. Existing native economic limitations remain visible and unchanged.

W03 was committed with owner approval; no push, PR or trading operation occurred. W04's subsequent execution is recorded below; canonical Rust finance still requires ADR-002/003/004 approval.

Fifth-wave handoff — 2026-10-22

W04 is independently reviewed and validated_committed as 550d8b7 on base 95842c3, following owner approval. The sole implementation owner used /tmp/stock-bot-wave5.t2GVG7/w04; the independent reviewer accepted the frozen five-file implementation and reran all browser cases. Integration and pre-commit verification preserved all five hashes. No production application source, financial behavior or business API changed.

  • Real product path: Chromium uses the built frontend, authenticated existing routes/websocket projection, SQL repository, durable dispatcher and worker against isolated fixtures. Save-only creates no run/outbox; explicit submission, persisted progress, unsupported-control absence, completion, trades, limitations, frozen inputs and reopening survive navigation/reload.
  • Failure and race evidence: Separate cases cover cancellation acknowledgement versus worker settlement, failed and zero-trade results, missing results/run, network failure/retry, actual client websocket disconnect/reconnect, and a delayed real API response after switching selected runs. The stale-response assertion waits for the exact old request to finish or fail before inspecting the selected run.
  • Native smoke: The existing Rust adapter/subprocess executes 70 synthetic bars, persists native results and dataset provenance, and renders trades/reopened results. Fixed lifecycle fixture outputs are UI test data, not an alternate financial simulator or correctness oracle.
  • Harness: bun run test:e2e requires explicit disposable stock_bot_safety* PostgreSQL, Redis DB15, a local build/addon and explicitly installed Chromium. It rebuilds the UI in production mode with same-origin API routing. It blocks external browser requests and unrelated fixture API routes, isolates schemas/queues/listeners, and reports prerequisite/readiness/cleanup failures instead of skipping tests. Playwright 1.53.2 is now an explicit dependency; no additional runner framework was introduced.

Combined validation:

  • CARGO_BUILD_JOBS=2 bun run check: all gates passed; 60 tooling, 43 utility, 35 calculation, 310 integration and 37 Rust tests, zero failures. Build, typecheck, contracts, lint and secret audit passed.
  • bun run test:postgres: 58 tests, 345 assertions, zero failures against disposable PostgreSQL/Redis after integration.
  • bun run test:e2e: 4 tests, 42 assertions, zero failures on the final main-workspace build (18.99s). Author and independent reviewer also passed all four cases on the frozen implementation. These are additional gates, not included in the repository-check totals.
  • Standalone strict TypeScript and explicit ESLint passed for all three new harness files. Frozen offline dependency installation passed. Missing fixture settings, unsafe PostgreSQL/Redis databases and a missing browser installation each failed explicitly before execution.

Logs, five reviewed file hashes and native artifact identities are recorded in the manifest. Exact disposable PostgreSQL/Redis containers and their recreatable fixture data, including leftovers from aborted diagnostic attempts, were removed after validation. Development services were untouched; worktree and local logs are retained. W04 was committed with owner approval; no push, PR or trading operation occurred.

Limits: Chromium only (138.0.7204.23). A standalone probe reproduced a Bun 1.2.17 server-initiated websocket close/reconnect shutdown hang; final coverage uses an actual client-initiated disconnect and does not suppress server cleanup failures or claim server-initiated shutdown coverage. An author-reported first clean-worktree build had a browser/logger type-resolution ordering failure; a retry and the combined check passed, but no fix or reproducible diagnosis is claimed. Existing build warnings remain. UI fixtures and native smoke do not certify same-bar execution, canonical accounting, ownership or funding semantics.

Next: approve ADR-002/003/004 before F01, ADR-003 before D01, and ADR-006 before the parallel R01 product lane. The post-commit readiness review found 32 remaining scheduled tasks and no ungated candidate. F01, D01 and R01 have satisfied code prerequisites but pending ADRs; optimization/deferred work is not a substitute. Do not start financial or trust-model changes by interpreting this test completion or the continuation request as policy approval.

Deferred and rejected

Conditional: shared feature cache D04; cross-trial resident datasets P03; large-detail pagination/storage P05; tiny DSL P06; expanded cross-service monitoring O02. Each has a measured/real-need trigger and is not a prerequisite for scheduled work.

Deferred economics: short/margin/borrow, multicurrency, full corporate actions, intrabar stops/OCO, detailed market impact and live brokers. Reject unsupported datasets/orders explicitly. The model is not generalized by pretending unsupported behavior exists.

Later product/research: embedded IDE, advanced optimizers, generalized ML training, Monte Carlo significance tooling. Basic immutable versions, chronological validation and evidence links are not deferred.

Rejected: competing TS/web simulators, wholesale Rust rewrite, hand-written decimal engine, new service/message bus/workflow framework, generic signal DSL, compatibility switches that re-enable defects, deleting reviewed calculations because they are currently unused. Keep existing local environment-file policy; no WCAG or cosmetic-dashboard scope here.

Execution governance

Only manifest.json owns status/assignment/dependencies. Task files own scope/acceptance. Read the reusable implementation, review, integration, planning briefs and quality gates.

Approval of planning artifacts is not permission to commit, push or create PRs. Historical planning-only statements refer to the original audit; later execution records and the canonical manifest identify actual implementation, authorization and validation evidence.