13 KiB
Orchestrator and engine cleanup
Baseline: 700ee09c, inspected 2026-10-26. Owner authorized backlog creation, a planning commit, implementation, and one focused commit per completed task. The manifest is the sole scheduling source; CL14–CL21 task files define scope and acceptance.
Direction
Keep Rust authoritative for finance and replay, TypeScript for strategies and supervision, existing durable custody, and reviewed algorithms. Simplify supported interfaces and remove abandoned scaffolding. Do not reopen performance work, change economic policies, activate paper/live accounts, or replace existing services. Earlier CL01–CL13 independent-review status remains unchanged.
Sequence and ownership
- CL14 narrows canonical runner contracts and removes unused constructor requirements. CL15 independently removes verified unused Rust scaffolding after a calculation/caller inventory.
- CL16 gives application startup/shutdown an explicit resource owner. Serialize its container.ts edits after CL14; no financial contract changes.
- CL17 historical readers and CL20 typed worker results follow CL14. CL18 shared native parser/view follows CL15. CL19 pure strategy bookkeeping may proceed independently with exclusive paper/helper ownership.
- CL21 private replay preparation extraction is deferred until an actual scheduler/calendar edit warrants it and the owner activates it. It is not required to finish this cleanup wave.
Use isolated worktrees with local workspace links/build outputs. Start at most two implementation agents and reserve a slot for independent review. Root owns manifest integration and commits; each agent supplies a scoped patch and exact check evidence. A task commit contains its acceptance evidence; its SHA is recorded in the next bookkeeping update rather than embedded in itself. No commits/pushes/PRs by agents unless specifically delegated.
Gates
Run scoped tests and typechecks per story; native changes rebuild this checkout's addon and preserve existing economic fixtures. Use disposable PostgreSQL/Redis for custody boundaries. Independent review precedes completion and each task commit. Root runs combined bun run check; no benchmark or browser gate is needed for unchanged performance/UI behavior. Missing/skipped checks are explicit, never reported as passing.
Read-only audit baseline passed 17 architecture tests, 29 focused integration tests and 150 Rust tests (4 ignored). These are baseline evidence, not acceptance of future changes.
Execution evidence
Implementation records will be appended here as tasks pass review and validation.
CL15 — accepted
Removed 24 unused adapter/alternate-architecture files; moved two uncompiled reporting prototypes byte-for-byte into engine/reference/legacy-reporting/ with explicit limitations. MIGRATION.md records every removal/preservation and current boundaries. Only compiled-code change removes the unused adapter module; canonical finance, legacy algorithms and native exports are unchanged.
Implemented by /root/implement_cl15; independently reviewed/integrated by /root. Both preserved files were compared against baseline bytes. Root rebuilt the addon and ran bun test scripts/test/native-bindings.test.ts test/integration/native-terminal-equity.test.ts test/integration/native-market-data.test.ts scripts/test/architecture.test.ts: 75 passed. cargo test -p engine --lib --offline: 150 passed, 4 ignored. git diff --check passed. The sandbox initially prevented NAPI from spawning /bin/sh; the authorized rebuild succeeded. No performance claim or stored-artifact migration.
CL14 — accepted
The durable runner now requires canonical engine/repository capabilities. Legacy playback uses an explicit separate interface; concrete compatibility methods and historical formats remain. Removed unused adapter storage and runner engineName. Existing pause/resume/speed routes keep their production rejection behavior without SQL control writes. Negative type fixtures reject missing canonical capabilities.
Implemented by /root/implement_cl14; independently reviewed/integrated by /root. Root rebuilt the orchestrator and passed application typecheck/contract tests. Focused runner/workflow/worker/pool/isolation/architecture suite: 91 passed, 6,888 assertions. Disposable PostgreSQL canonical and retained durable-run suites: 33 passed, 181 assertions. No SQL/native/economic policy changes. Worker tests required execution outside the sandbox; two transient worktree Bun dependency-reading failures passed on separate reruns and root integration. Legacy-only provider-spy assertions were removed with the unused injection, not replaced with fabricated coverage. Full combined repository gate follows CL16 integration.
CL15 implementation commit: bc2b8a89.
CL16 — accepted
ServiceContainerBuilder.buildOwned() adds an explicit shared-resource lifetime while preserving build() for existing callers. Orchestrator composition returns {services, shutdown}; registration rollback and normal shutdown share idempotent application cleanup. Startup route/bind failures release the runtime. Shutdown finishes accepted HTTP requests and durable work before closing queue/database/cache adapters. The obsolete ModeManager closer and unowned delayed self-test timer are removed from the canonical entrypoint.
Implemented by /root; independently reviewed by /root/review_cl16 with no blocking findings. Focused lifecycle/composition tests: 39 passed, 166 assertions. Independent architecture rerun: 17 passed. Native worker lifecycle outside sandbox: 10 passed, 33 assertions. The new test was explicitly typechecked and linted because the default application tsconfig excludes tests; controlled fixture adapters have an explicit test-only container widening. Tests cover registration/resolution/bind failure, original-error retention, repeated stop, continued cleanup and a delayed terminal write before PostgreSQL closes.
Combined CARGO_BUILD_JOBS=2 bun run check passed on CL14+CL15+CL16: 132 tooling, 43 utility, 44 calculation, 1,231 integration and 150 Rust tests. Fourteen existing integration conditional skips and four Rust ignored tests remain. Builds, application/contract typechecks, lint and secret audit passed. Scoped disposable PostgreSQL gate remains the CL14 33-case result; no UI or financial schema/transition changed, so browser/full database suites were not rerun. Logs are under /tmp/stock-bot-engine-cleanup-20261026/ (combined-check.log, cl14-root-postgres.log, cl16-worker-accepted.log). No performance profiling or activation was performed.
CL14 implementation commit: 21666242. First wave completes CL14, CL15 and CL16; CL17–CL20 are the next ready tasks and CL21 remains conditional. Prior 68 task records retain their pre-wave state.
CL16 implementation commit: 8546fce4. Disposable test containers were stopped/removed after validation. Main checkout is the integrated source; isolated worktrees and logs are retained for inspection.
CL18 — accepted
Replay and paper hosts now share private strict parsing and financial-view helpers. Host identities/errors stay separate; required nullable fields, reservation ordering, and paper intermediate versus final admission revisions are preserved. No financial kernel, wire version or economic policy changed.
Implemented by /root/implement_cl18, independently accepted by /root/review_cl18, integrated by /root. Local and root Rust gates: 150 passed, 4 existing ignored. Root rebuilt the integrated addon and ran native-bindings/native-replay/native-replay-report: 28 passed, 227 assertions. Added replay-to-paper checkpoint/view parity at each fixture boundary and nested/missing/null negatives. Explicit authored-test types, lint, format and diff checks passed. Sandbox-blocked child-worker test was stopped; the authorized rerun passed. Logs: /tmp/stock-bot-engine-cleanup-20261026/cl18-root-{build,tests-accepted,cargo}.log. Combined repository gate follows integration of the remaining independent stories.
CL18 implementation commit: 03518c8a.
CL17 — accepted
Historical storage now borrows only its logger, MongoDB and QuestDB readers. Removed uncalled market/performance writes, ad hoc DDL, PostgreSQL injection, mode state and empty shutdown; retained ModeManager/examples no longer give this reader a resource lifecycle. Provider routing, decoding, validation and synthetic calculations stay unchanged. Pinned baseline V1/V2 hashes and malformed-volume negatives protect retained data semantics.
Implemented by /root/implement_cl17, independently reviewed/integrated by /root. Root scoped historical/dataset/mode suite: 60 passed, 519 assertions; application types passed. Expanded implementer suite: 103 passed, 895 assertions; architecture rerun: 17 passed. Root disposable stored-dataset preparation plus strategy recovery: 12 passed, 92 assertions. Authored-test types/lint and diff checks passed. Three obsolete parameterized storage-lifecycle cases were removed with the nonexistent stages; actual execution/feed/strategy rollback cases remain. Initial worktree browser bundling read errors cleared on architecture rerun. Nine pre-existing lint findings in other historical test bodies and the already-broken no-argument legacy example were not widened into this task. Logs: /tmp/stock-bot-engine-cleanup-20261026/cl17-{root-tests,root-types,postgres}.log.
CL17 implementation commit: 984dc1a9.
CL19 — accepted
Research and paper share pure diagnostic initialization and owner-feedback projection, keeping their separate confirmation/SQL commit boundaries. Feed planning and paper admission share the existing timestamp/phase/UTF-8/source comparator. canonicalJson moved unchanged to a neutral module with its legacy re-export; canonical consumers no longer depend on legacy recovery.
Implemented by /root/implement_cl19, independently accepted by /root/review_cl19, integrated by /root. Root runtime/feed/recovery/architecture suite: 60 passed, 6,959 assertions; application types passed. Root disposable canonical-paper, crash and strategy-recovery suite: 35 passed, 275 assertions. Root also compared the entire canonicalJson function/comment against baseline bytes. Tests cover research/paper state/RNG/feedback parity and detached initial state, malformed-owner atomicity, native-accepted Unicode ordering and historical serialization. Explicit authored-test types/lint/format passed. Worktree Bun browser-bundle errors cleared on separate architecture rerun; root combined focused invocation passed. Logs: /tmp/stock-bot-engine-cleanup-20261026/cl19-root-{tests,types,postgres}.log.
CL19 implementation commit: 6055aeee.
CL20 — accepted
The worker supervisor exposes a narrow typed retained-result entry while preserving raw trace/strategy callers. It retains the existing validated envelope and returns it only after successful child close and candidate cleanup; the canonical adapter no longer reparses it. Input snapshots, child error/cancellation handling, trust-boundary/persistence validation and financial semantics are unchanged.
Implemented by /root/implement_cl20, independently reviewed/integrated by /root. Root rebuilt the orchestrator and ran retained-strategy-worker, canonical-worker-lifecycle, canonical-strategy-worker and native-replay-report: 59 passed, 232 assertions. New cases prove raw/typed parity, specific malformed identity/policy/artifact/analytics failures, caller mutation isolation, cancellation/reuse and valid result followed by exit code 23. The existing supervisor cleanup-failure branch was inspected unchanged; it was not newly fault-injected. Application and explicit authored-test typechecks, lint, formatting and diff checks passed. A worktree Zod bundling failure cleared after copying that dependency locally into ignored node_modules; root checkout tests passed unchanged. Logs: /tmp/stock-bot-engine-cleanup-20261026/cl20-root-{build,tests,types}.log.
Remaining-wave integration — accepted
CARGO_BUILD_JOBS=2 bun run check passed on the integrated CL17–CL20 changes: 134 tooling, 43 utility, 44 calculation, 1,236 integration and 150 Rust tests; 14 existing conditional integration skips and 4 ignored Rust tests remain. Builds, application/contract typechecks, lint and secret audit passed. Root separately ran the disposable database suites recorded above (12 stored-source/recovery and 35 canonical-paper/crash/recovery cases, with overlapping recovery coverage). No browser E2E or full database suite was rerun; UI and financial schema/policy are unchanged. No performance claims or activation. Full log: /tmp/stock-bot-engine-cleanup-20261026/remaining-wave-check.log.
CL14–CL20, all seven scheduled cleanup stories, are complete. CL21 remains conditional on an actual replay scheduling/calendar need and explicit activation. The 72 task records outside this wave remain unchanged, including earlier CL01–CL13 review status and the six original conditional tasks. Disposable test containers were stopped/removed; isolated worktrees and logs remain for inspection.