stock-bot/docs/development/cleanup-execution.md

8.7 KiB
Raw Blame History

Cleanup execution evidence

The owner authorized implementation and validated commits after plan commit 4ddffa6b. The manifest remains the task-state authority. No additional agents were launched; review here is a separate self-review pass, not an independent reviewer sign-off. Financial engine code and retained financial artifacts are unchanged.

CL01–CL04 — Configuration, startup and commands

  • CL01 replaces the mocked normalizer and success-or-error assertions with real-schema, no-network construction checks. Existing DI fixtures now supply valid database inputs.
  • CL02 shares the core database schemas, consistently applies disable options, preserves QuestDB port aliases/credentials, and maps PostgreSQL SSL/pool/timeouts and MongoDB URI/pool settings to client configuration. URI parsing remains driver-owned.
  • CL03 retains cleanup ownership of late initialization, rolls back settled resources, clears startup timers and tolerates cleanup/resolution failures without replacing the original startup error. Arbitrary hung initializers cannot be forcibly cancelled; their final cleanup stays attached until settlement.
  • CL04 adds dev:research, aligns infrastructure aliases on Compose v2/all four stores, removes three nonexistent command targets and makes shell failures propagate.

Validation:

  • bun test libs/core/di/test/container-builder.test.ts libs/core/di/test/di.test.ts libs/core/di/test/lifecycle.test.ts test/integration/service-startup-rollback.test.ts test/integration/questdb-configuration.test.ts — 41 pass.
  • bun test test/integration/store-configuration.test.ts — 5 pass.
  • bun test scripts/test/workspace.test.ts — 8 pass / 763 assertions; includes real Turbo dry runs and a fake Docker executable, with no containers started.
  • bun run --cwd libs/core/config build, bun run --cwd libs/core/di build, bun run typecheck — pass.

Configuration scope: core schemas retain settings used by other consumers. ServiceCache intentionally owns DB1 and its service/global namespace; core db/keyPrefix do not override that isolation policy. Core ttl, retry hints and QuestDB buffer/flush metadata are not claims that the shared DI client supports writer/cache tuning; those adapter APIs remain unchanged. Financial inputs, hashes and accounting were not modified.

CL05–CL13 — Shared domain and application cleanup

  • CL05 adds one @stock-bot/research workspace with browser-safe contracts, server normalization/hashing and statistical reports. Orchestrator paths re-export the one implementation. Legacy V1 adaptation stays application-owned and calls an explicit parent-hash factory; existing pure stock-config contracts are reused.
  • CL06 reuses shared manifest structures and structural eligibility policy in API/browser admission. Preparation-specific parent-hash/null and response refinements remain explicit; server content validation and client expected-identity checks remain separate.
  • CL07 shares cookie JSON transport for experiment, chronological and walk-forward clients. Domain parsing, uncertain acceptance, receipt identities and endpoint errors remain local. No automatic retry or research-token/browser credential mixing is introduced.
  • CL08 retains BacktestServiceV2 as a compatible facade over template, run/control, reproduction and result operations. Row mapping and contracts are shared locally. SQL transactions retain their original ordering and pass the same connection into result reads.
  • CL09 separates metadata presentation, version/artifact comparison and clone-receipt state from the strategy route. Publication continues using the existing CandidatePublication.
  • CL10 separates saved-template loading and the preview/submission coordinator. One phase replaces coupled ordinary-submission flags; the immediate submission lock/ref and exact frozen receipt remain necessary across ordinary/chronological/walk-forward modes.
  • CL11 separates run selection/polling/results/cancellation and submission receipt lifetime from editable-template state. The useBacktestV2 public return contract is preserved.
  • CL12 removes the impossible legacy snapshot fallback after canonical admission. Current run writes use the admitted canonical request/hash. Legacy template adapters, saved result readers, historical provenance parsing, retired REST/runner rejection and native exports remain. No algorithms, calculation library or retained executable artifacts were deleted.
  • CL13 hides only the three verified placeholder menu items; their URLs show explicit availability messages and links to existing backtest/experiment analytics. AuthGate and all working route identities remain unchanged.

Review focused on receipt lifetime and navigation races, original request/result identity, transaction ordering, single-connection reads, hash/property-order preservation, client bundle boundaries, and avoiding additional framework layers. The public facade re-exports its original contracts; internal helper/container types are not new public API.

Intermediate verification:

  • Workspace build — 28/28 tasks pass.
  • Domain/native/UI group — 174 pass; one initial architecture allowlist failed on the newly shared pure report subpath. Added the narrow allowlist plus tests verifying the new package has no application/service imports and browser contracts bundle successfully.
  • Strategy/publication/experiment/transport group — 218 pass / 931 assertions.
  • Run-control/workbench/reproduction UI group — 83 pass / 472 assertions.
  • Backend/reproduction/result/navigation group — 28 pass / 184 assertions.
  • First full check found the missing-config disabled MongoDB URI regression; corrected the schema-valid default instead of weakening validation. Store/offline/paper-composition focused group then passed 22 tests / 129 assertions.
  • Final CARGO_BUILD_JOBS=2 bun run check — pass: 132 tooling, 43 utility, 44 calculation, 1,221 integration tests (14 explicitly skipped), 150 Rust tests (4 ignored), plus build, type/contract checks, secret audit and lint. Conditional OS-isolation tests remain skipped under their existing explicit runtime gate; this cleanup does not certify live trading.
  • DI builder/general/lifecycle focused group — 32 pass; root integration separately covers startup rollback and store configuration.

The first disposable PostgreSQL suite ran concurrently with the first repository check, encountered the same pre-fix disabled-Mongo default, then Bun 1.2.17 segfaulted. That attempt is not a pass. A fresh full suite runs after the successful repository check on the corrected build; final PostgreSQL/browser outcomes are recorded below. Sandbox-restricted native worker spawning also failed initially; its rerun outside the sandbox used the assigned checkout and correctly built addon rather than weakening worker checks.

Final integration evidence:

  • PIPELINE_TEST_DATABASE_URL=<disposable PostgreSQL>/stock_bot_safety BACKTEST_TEST_REDIS_URL=<disposable Redis>/15 bun run test:postgres — 273 pass, 0 fail, 2,617 assertions, 34 files. Fresh run completed after the runtime crash noted above; it includes single-connection reproduction, concurrent receipts/outbox transactions, recovery, ownership and unchanged native economics.
  • The same fixture URLs with bun run test:e2e — 18 pass, 0 fail, 655 assertions using installed Chromium and a freshly built frontend. Includes native smoke, version clone, archived history, experiments/validation and research evidence workflows.
  • Final review added an explicit unknown-VWAP guard to createDatasetV2FromLegacy: the former private application adapter guaranteed this invariant before normalization. Its shared entrypoint now rejects contradictory provenance before returning a prepared dataset. Dataset/report focused suites passed 25 tests / 515 assertions, including detached validation, golden hashes and malformed parent hashes. Typecheck/lint passed again.
  • Temporary PostgreSQL and Redis fixture containers were removed after both suites. Existing development stores and environment files were preserved.
  • After the final boundary guard, CARGO_BUILD_JOBS=2 bun run check passed again on the final application tree: 1,222 integration tests (14 existing skips), 150 Rust tests (4 ignored), plus all build/type/contract/tooling/utility/calculation/secret/lint gates. No application edits followed that pass.

All 13 implementations are validated. Their manifest status is review, because these stories define independent review as part of done and this execution used one agent. The earlier first-four done entries were corrected to review for consistency; this is an outstanding reviewer sign-off, not unfinished implementation or a failing test gate.