feat(research): run stateful TypeScript strategies on canonical replay

This commit is contained in:
Boki 2026-10-23 13:08:24 -04:00
parent 0870b55830
commit 2bcadbd117
14 changed files with 1864 additions and 33 deletions

View file

@ -1,6 +1,6 @@
# Revised development roadmap
Baseline `b7aeca4` · execution 2026-10-23 · **F08 committed; S01 in progress**
Baseline `b7aeca4` · execution 2026-10-23 · **F08 committed; S01 validated, uncommitted**
Authorization update: the owner accepted F08 and requested “commit all of it and continue” after the handoff named S01 and linked ADR-005. F08 is committed as `3838295`; S01 is authorized under ADR-004/005. Other pending ADRs and the multi-asset mark policy are unchanged. New S01 implementation commits, pushes, PRs and trading/default-engine operations remain outside this continuation's scope.
@ -348,6 +348,29 @@ F08 was accepted and committed as `3838295`, superseding its uncommitted handoff
Recovery deliberately follows the current research job boundary: restart the whole attempt from frozen inputs and original initial states/seeds. TS snapshots are diagnostic; no incomplete mid-run resume or new native checkpoint transport. S02 owns the first real strategy and trusted worker composition; S03 preserves durable paper integration, R05 the default/public-result cutover. The active legacy registry, SQL/paper state and web runner remain unchanged.
**Validated handoff:** S01 is `review` / `validated_uncommitted`. Eight author/verification files were integrated with exact independently reviewed hashes. Root added the permanent author type-test gate. The source bundle and raw logs remain under `/tmp/stock-bot-wave14.JYfazy/`; the manifest owns the precise validation record.
Callbacks now receive frozen prefix observations, isolated typed state/positions and scoped per-owner randomness. Every due callback uses the same native portfolio view; all next states/intents are staged before admission and all feedback is validated before one committed-state swap. Rejections advance state and carry actual Rust order status. Late callback failures, ambiguous native submissions and malformed feedback dispose the attempt and retain the last confirmed diagnostic state. The original conformance driver uses the same extracted pull loop with unchanged IDs and financial hashes.
Review caught two boundary defects before integration: unhandled Promise rejections from invalid async callbacks, and empty feedback envelopes accepted by `z.unknown()` fields. Narrow fixes observe actual Promise rejection without awaiting/invoking arbitrary thenables and require present object-valued feedback tags. Regression tests cover both, including foreign-realm Promises and failure after real native admission. No Rust semantics, worker protocol, SQL or legacy registry implementation changed.
Full `CARGO_BUILD_JOBS=2 bun run check` passed build/typecheck/contracts/audit/lint plus **78 tooling, 43 utility, 44 calculation, 390 integration and 144 Rust tests**, with four existing manual Rust measurements ignored. Extra strict test TypeScript, scoped ESLint/Prettier and diff checks passed. The initial temporary strict config lacked its root-relative Bun type lookup; fixing that external config resolved it without source changes. Disposable PostgreSQL/Redis suites passed **58 tests / 345 assertions**; final release tests passed **43 tests / 568 assertions**. Independent native verification contributed 15 scenarios / 249 assertions, overlapping the integrated totals. Browser and Python boundaries did not change and those suites were not rerun.
The unchanged conformance CLI passed all six 10k workloads with identical complete result/economic hashes and the same release native artifact as F08. Historical wall-time changes track shared-host load; they are not an extraction speedup claim. A separate counterbalanced benchmark compared stateful programs with **replay of their exact captured decisions**, including IDs. This avoids treating different identity/payload sizes as callback cost.
| 10,000 total bars | Recorded decisions | Stateful programs | Added wall time |
| --- | ---: | ---: | ---: |
| No trade, 1 asset / 1 owner | 861 ms | 949 ms | 88 ms / 10.3% |
| No trade, 10 assets / 2 owners | 357 ms | 372 ms | 14 ms / 4.0% |
| Sparse, 1 asset / 1 owner | 908 ms | 1,050 ms | 143 ms / 15.7% |
| Sparse, 10 assets / 2 owners | 511 ms | 527 ms | 16 ms / 3.1% |
| Turnover, 1 asset / 1 owner | 1,569 ms | 1,881 ms | 313 ms / 19.9% |
| Turnover, 10 assets / 2 owners | 1,925 ms | 2,212 ms | 287 ms / 14.9% |
All **48 timed sessions** match complete financial hashes; repeated/reversed program order preserves diagnostic state/RNG hashes. Each fresh child first captures a reference trace, so timed sessions are in a warmed process. Medians have four samples per mode. Wall time includes construction, state validation/staging, callbacks, admission feedback, finalization and disposal; post-run oracle/hash work is separate. Each callback updates four scalar fields and draws once. This is neither pure callback overhead nor complex-strategy, database/queue or cold-start throughput. The measured 3.1–19.9% overhead is retained as a profiling baseline, without removing correctness checks or introducing a DSL/cache.
Only the two exact disposable fixture containers were stopped; development services were untouched. Worktrees, archives and measurements remain. **Next after acceptance: S02**, port one SMA strategy and wire its explicit trusted version into the existing worker. Its handoff distinguishes indicator state reconstruction from unsupported native mid-run resume. R05 still owns durable/public-result activation; paper migration and other pending decisions remain separately gated. No S01 commit, push, PR or trading operation occurred.
## 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.