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

@ -73,3 +73,11 @@ The owner accepted F08 and requested continuation after the handoff explicitly n
- Direct trusted program objects suffice here. S02 supplies the first real SMA strategy and trusted worker composition; R01/A02 own immutable/untrusted artifacts and isolation. Keep the existing legacy `StrategyRegistry` instead of broadening its execution-service factory into the canonical author API.
Required regression scenarios include mixed owner cadence/warmup, reversed callback order and independent RNG draws, prefix/future-suffix integrity, late callback failure after a committed barrier, ambiguous post-native-submit failure, risk-rejection feedback with state advancement, repeated/partial targets, owned cancellation feedback, frozen/retained-reference isolation, invalid state/Promise/mode rejection, and compile-time absence of financial mutation services. Fresh retries must equal uninterrupted decision/state/RNG/economic results. Preserve existing conformance/result hashes and paper recovery tests. Measure deterministic strategy staging on representative release workloads without a DSL/cache or an unrelated hot-loop optimization.
## Reviewed implementation handoff — 2026-10-23
Implemented the pinned contract in `contracts/canonical-strategy.ts`, `backtest/strategy-runtime.ts`, the shared native replay loop and a narrow native order-feedback decoder. The exact architecture allowlist adds only the new trusted host runtime; direct native entry points remain unchanged. `tsconfig.contracts.json` permanently includes the author type tests.
Independent review found and fixed two issues before acceptance: rejected async callbacks could leave unhandled rejections, and optional-looking Zod unknown fields accepted an empty feedback tag. Actual Promises are now observed without awaiting; arbitrary thenables remain invalid and uninvoked. Feedback tags require object payloads while nested financial diagnostics stay opaque. Subprocess regressions cover immediate, delayed and foreign-realm rejection; native failure tests prove all-owner atomic diagnostic state.
Full repository checks passed (78 tooling, 43 utility, 44 calculation, 390 integration, 144 Rust tests), plus 58 disposable recovery tests, 43 focused release tests and extra strict test TypeScript/lint/formatting. The 48-session paired benchmark preserves every financial ID/hash; measured stateful overhead is 14–313 ms across six 10,000-total-bar workloads. This includes validation/staging/feedback, not pure callback cost. See the [wave handoff](../../ROADMAP.md#fourteenth-wave-execution--2026-10-23) and canonical manifest for exact commands, hashes and measurement limitations. New S01 implementation remains uncommitted.