feat(strategies): add canonical regime-aware mean reversion

This commit is contained in:
Boki 2026-10-23 17:10:08 -04:00
parent 75abae2cfc
commit 6a67ae8683
24 changed files with 1910 additions and 88 deletions

View file

@ -1,20 +1,16 @@
{
"schema_version": 1,
"plan_revision": "2026-10-23.38",
"plan_revision": "2026-10-23.40",
"repository_base": "b7aeca4",
"plan_status": "seventeenth_wave_review",
"plan_status": "eighteenth_wave_review",
"execution_authorized": true,
"execution_scope": {
"authorized_by": "User: commit and continue after validated S03 handoff (2026-10-23). S03 accepted/committed c01e96e; S04 prerequisites satisfied. Performance work remains deferred.",
"tasks": [
"S04"
"S05"
],
"permissions": [
"accepted_wave16_commits",
"isolated_implementation",
"local_correctness_tests",
"local_integration_review",
"planning_progress_updates"
"S05 isolated implementation, correctness tests, independent review and planning updates; S04 commit authorized and completed"
],
"excluded": [
"performance_profiling_or_optimization",
@ -30,6 +26,12 @@
"ADR-006",
"ADR-007",
"ADR-008"
],
"exclusions": [
"Performance profiling/optimization/benchmarks",
"New-wave commits, push, PR or trading activation",
"Default cutover or unapproved ADR policies",
"Other backlog tasks"
]
},
"canonical_metadata": "This manifest alone owns task status, dependency edges, approvals, assignments and write locks. Task Markdown owns scope and acceptance criteria. Index/roadmap are derived views.",
@ -1091,7 +1093,7 @@
"epic": "E4",
"priority": "P1",
"severity": "High",
"status": "review",
"status": "done",
"dependencies": [
"S02",
"S03"
@ -1111,12 +1113,12 @@
"assignment": "/root/s04_controls_audit",
"branch": "wave17/s04-control",
"pull_request": null,
"completed_commit": null,
"completed_commit": "75abae2cfc65229f65273bebc2ea9ef3148cce60",
"blocker": null,
"release_gates": [],
"worktree": "/tmp/stock-bot-wave17.JfETUx/control",
"integration_base": "c01e96e4dd2879d0c728e57b48f5b6172adecd0f",
"integration_state": "validated_uncommitted",
"integration_state": "validated_committed",
"implementation_slices": [
{
"owner": "/root/s04_feed_audit",
@ -1142,7 +1144,7 @@
"epic": "E4",
"priority": "P2",
"severity": "Medium",
"status": "ready",
"status": "review",
"dependencies": [
"S02",
"F08"
@ -1159,14 +1161,33 @@
"write_locks": [
"example-strategy"
],
"parallel_policy": "Allowed only with satisfied dependencies/approvals and disjoint write locks AND actual files; see agents/integration.md.",
"assignment": null,
"branch": null,
"parallel_policy": "Root owns shared contracts/dispatcher and one durable restart test; strategy owner owns new program/direct tests; verifier owns disjoint replay fixture/native-worker tests; independent read-only review.",
"assignment": "/root/s04_controls_audit",
"branch": "wave18/s05-strategy",
"pull_request": null,
"completed_commit": null,
"blocker": null,
"release_gates": [
"R08"
],
"worktree": "/tmp/stock-bot-wave18.V1G17v/strategy",
"integration_base": "75abae2cfc65229f65273bebc2ea9ef3148cce60",
"integration_state": "validated_uncommitted",
"implementation_slices": [
{
"owner": "/root/s04_controls_audit",
"scope": "canonical-mean-reversion.ts and direct strategy tests",
"worktree": "/tmp/stock-bot-wave18.V1G17v/strategy"
},
{
"owner": "/root/s04_feed_audit",
"scope": "canonical-regime-research fixture and native replay/worker verification",
"worktree": "/tmp/stock-bot-wave18.V1G17v/verification"
},
{
"owner": "/root",
"scope": "shared selection contract, dispatcher/import seam, durable restart test, example recipe and integration/planning"
}
]
},
{
@ -6093,7 +6114,7 @@
"Explicit recoverPending acknowledgement permits original-time replay of already-admitted work; activation succeeds only after recovery and final readiness. No silent skipping or restamping."
],
"seventeenth_wave_validation": {
"state": "validated_uncommitted",
"state": "validated_committed",
"work_root": "/tmp/stock-bot-wave17.JfETUx",
"committed_before_implementation": {
"S03": "c01e96e4dd2879d0c728e57b48f5b6172adecd0f"
@ -6226,6 +6247,156 @@
"d96d9a126e665226aeebc191b5b58e25eb29165cbabb4c099201f01e6364ef7f"
]
},
"next": "Accept/commit S04, then S05 composable multi-signal/regime example. R01/R11 still need ADR-006; performance remains deferred."
"next": "Accept/commit S04, then S05 composable multi-signal/regime example. R01/R11 still need ADR-006; performance remains deferred.",
"completed_commit": "75abae2cfc65229f65273bebc2ea9ef3148cce60"
},
"eighteenth_wave": [
"S05"
],
"eighteenth_wave_base": "75abae2cfc65229f65273bebc2ea9ef3148cce60",
"eighteenth_wave_notes": [
"User commit-and-continue authorizes S05 after S04 acceptance; performance remains deferred.",
"Small second trusted TS built-in on the unchanged canonical Rust financial core; no general signal/regime framework or alpha claim.",
"Source and decision tests may integrate before R08; research validation conclusions remain gated."
],
"eighteenth_wave_validation": {
"state": "validated_uncommitted",
"work_root": "/tmp/stock-bot-wave18.V1G17v",
"committed_before_implementation": {
"S04": "75abae2cfc65229f65273bebc2ea9ef3148cce60"
},
"scope": [
"Distinct versioned trusted long-only mean-reversion strategy with ordinary trend/momentum/reversion/volatility functions",
"Small exhaustive canonical built-in dispatcher; unchanged SMA semantics and shared exact desired-share sizing",
"Existing native worker and opt-in paper composition accept either trusted built-in",
"Four explicit regime/no-regime and alternative-cost diagnostic requests, retaining exact inputs/results",
"Independent native ownership/risk/worker fixtures, public-schema matrix and one durable fractional recovery regression"
],
"source_integration": {
"files": 20,
"exact_hashes": {
"apps/stock/orchestrator/examples/canonical-regime-research.ts": "e8dfb0868c01eeaa2477b4b9508fe0e3f43c0b2d8fdcf1d27eb6faffdcfe73c2",
"apps/stock/orchestrator/src/backtest/native-worker.ts": "740bf6ba6f7a871a7e87efa53320cc93052cc5e7b8f7256417a40bfff2880435",
"apps/stock/orchestrator/src/container.ts": "06b011668f39eefa62c1c94a3770af926ca8f30ceef9fc9cbc7f6d63c1c0ea45",
"apps/stock/orchestrator/src/contracts/builtin-strategy.ts": "11f0be101bee4d7515de84fcb730e502f4f5092f6747f6edb0594e29f9335e00",
"apps/stock/orchestrator/src/strategies/canonical-builtins.ts": "a91af8965c3e414c47a0d991e8fb4a5a784454c0a4c71dcb4cfbde884ab8c510",
"apps/stock/orchestrator/src/strategies/canonical-mean-reversion.ts": "8ebd12b41e6e1d3e088d0a5309978986b45fc28ab3b1789394fc782149b65eaa",
"apps/stock/orchestrator/src/strategies/canonical-sizing.ts": "cbc33976d2a5a94cfb676aedd510e327e740da19d8f8ca8a455447f73d5fb858",
"apps/stock/orchestrator/src/strategies/canonical-sma.ts": "03a15b17537abca285e6082cc1da8f62c7be42a453cc69f32b7c378f9b888176",
"test/fixtures/canonical-regime-research.ts": "49a03799c10b8731efc76b18cc81a166de66501cbb3a40e6a2dfbbd6c90d2e40",
"test/fixtures/canonical-sma.ts": "bd1de6c04a70f82cda805e6f3b9703e5cbc9f79d7db8c118baaa10043b754928",
"test/fixtures/canonical-strategy-worker.ts": "764e1b18980bec563803f8520552513cb50bcbc1cc0c3d1f4735f43f74468f32",
"test/integration/canonical-builtins.test.ts": "57c65793f28ecb99aafe94998001cb0b3bd049bbafc8bb8aaceabbeef350dd0e",
"test/integration/canonical-mean-reversion.test.ts": "be7be4a596dcefa4e58daec7a1ad9ef9fa941a809195c5787594f8900dc66026",
"test/integration/canonical-regime-research.test.ts": "425b04ebd2d2beaf747a751b0b1cdc495000a4f1eabd4f9ca572bc2c21ebceea",
"test/integration/canonical-sma.test.ts": "de2c27a56d7462ed7c979547adaee94172da275c1e16de73bcc89dea796b2953",
"test/integration/canonical-strategy-worker.test.ts": "8ba7c2b087c5407719eb72942f1af28f6c79da82557dbf2a3f218cfa8771caf8",
"test/integration/regime-research-example.test.ts": "e4037292c735aaae14e0a8052c45fff77c33e95ba21439fabf773dca1af645a6",
"test/postgres/canonical-paper.test.ts": "8c3016116d6c32bb75becacf8e1ba8a850693cb4914df9a44867a8c3833f13e8",
"test/postgres/paper-http.test.ts": "c944c207f325de5389732385446dcf741fecf9955635ea8937f8938f05a37c90",
"tsconfig.check.json": "1e62c41351267b3690a00463f96300287a3e9bc88529ebd8d533289942a56589"
},
"source_archive": "/tmp/stock-bot-wave18.V1G17v/s05-integrated-source.tar",
"source_archive_sha256": "a35ee1607ec524a49e1390b007cca9e5b034209812f14026c1da3adfab760570",
"strategy_archive_sha256": "b3ab174254c2976c7ad8a24725dc5de5871e1d7a3780596525d8fa312cfce5b6",
"verification_archive_sha256": "b652be55f6e22716fa7d29f6b370dd88ca486899ef22c919adb0a0912480d34a"
},
"review": {
"reviewer": "/root/s03_review",
"result": "G1/G2 accepted; pending strict test types subsequently passed",
"findings_resolved": [
"Persistent exit target0 precedes entry filters",
"Fractional owned targets survive partial entry cancellation without rounding",
"Blocked entry remainder is abandoned, not rebuilt while holding",
"Both ablation modes retain identical observation-count warmup",
"Exact new strategy version and malformed parameter/code rejection matrix"
]
},
"checks": [
{
"command": "CARGO_BUILD_JOBS=2 bun run check",
"result": "passed; before final additional schema-matrix test and test-only assertion typing cleanup",
"counts": {
"tooling": 82,
"utilities": 43,
"calculations": 44,
"integration": 479,
"rust": 150,
"rust_manual_ignored": 4
},
"log": "/tmp/stock-bot-wave18.V1G17v/integration-check.log"
},
{
"command": "PIPELINE_TEST_DATABASE_URL=postgres://fixture:fixture@127.0.0.1:32819/stock_bot_safety BACKTEST_TEST_REDIS_URL=redis://127.0.0.1:32820/15 bun run test:postgres",
"result": "passed",
"tests": 105,
"assertions": 728,
"log": "/tmp/stock-bot-wave18.V1G17v/integration-postgres.log"
},
{
"command": "bunx tsc --project /tmp/stock-bot-wave18.V1G17v/root-tests-tsconfig.json --noEmit",
"result": "passed on final integrated tests including public schema matrix",
"log": "/tmp/stock-bot-wave18.V1G17v/root-tests-typecheck-final.log"
},
{
"command": "Scoped ESLint --no-ignore --max-warnings0, Prettier --check and git diff --check; final schema-matrix test separately formatted/linted",
"result": "passed",
"logs": [
"/tmp/stock-bot-wave18.V1G17v/integration-lint.log",
"/tmp/stock-bot-wave18.V1G17v/integration-format.log"
]
},
{
"command": "CARGO_BUILD_JOBS=2 bun run --cwd apps/stock/engine build:release",
"result": "passed; addon equals local target/release/libengine.so",
"log": "/tmp/stock-bot-wave18.V1G17v/integration-release-build.log"
},
{
"command": "PIPELINE_TEST_DATABASE_URL=postgres://fixture:fixture@127.0.0.1:32819/stock_bot_safety bun test test/integration/canonical-builtins.test.ts test/integration/canonical-mean-reversion.test.ts test/integration/canonical-regime-research.test.ts test/integration/regime-research-example.test.ts test/integration/canonical-sma.test.ts test/integration/canonical-strategy-worker.test.ts test/postgres/canonical-paper.test.ts scripts/test/native-bindings.test.ts",
"result": "passed on final release addon and final source/tests",
"tests": 98,
"assertions": 580,
"log": "/tmp/stock-bot-wave18.V1G17v/integration-release-focused.log"
}
],
"native": {
"rust_source_unchanged": true,
"final_profile": "release",
"final_addon_sha256": "ef00eed556f5c32332d36a9a00ef710682e90deb00b54552e4b5c8bfdfbe8103",
"local_library_matches": true,
"performance_measurements": false
},
"economic_evidence": [
"Two MR owners on one asset retain distinct grossPnl40/10 and fees1.80/1.00 under the explicit fixture",
"Mixed SMA/MR real worker trace, projection and report equal direct native replay",
"Insufficient funding and position limits still reject via Rust; no strategy bypass",
"Partial native entries/exits and same-bar prevention match declared capacity/timing policies",
"Every-step durable replacement preserves fractional0.5 holding, target cancellation, final cash1001.91 and fees0.09 exactly",
"Four-trial illustrative comparison yields exact native accounting under explicit fee/slippage inputs; no alpha evidence claimed"
],
"environment_notes": [
"Independent native build required escalation after sandbox spawnSync EPERM.",
"Verifier sandbox IPC run stalled; exact identified processes3710409/3710825 stopped; outside-sandbox rerun passed.",
"Verification fixture expectations corrected to existing terminal-bar no-callback and previous-completed-volume liquidity policies.",
"Root example test changed malformed-rate fixture from semantic negative to malformed decimal: native remains financial-policy authority; test-only optional/decimal branding corrections passed strict compilation.",
"No frontend or Python source changes; browser/Python gates not rerun. No profiling, benchmarks, optimization or trading operations."
],
"limitations": [
"Illustrative fixed-threshold long-only strategy, not a fitted model or validated alpha; R08 gates walk-forward/holdout conclusions.",
"Volatility uses per-observation adjacent simple returns; gaps are not filled or elapsed-time normalized.",
"Owner budget sizes initial desired whole shares, not a guaranteed realized spend after gaps/fees; Rust account risk/cash remains authoritative.",
"Example returns exact in-memory inputs/results but adds no durable experiment/artifact framework; R01/R05/R06 still own immutable code provenance and saved experiments.",
"Legacy/default research paths and web selection remain unchanged; canonical paper is opt-in and still needs an external verified feed producer."
],
"cleanup": {
"status": "completed",
"development_resources_untouched": true,
"worktrees_and_logs_retained": true,
"stopped_container_ids": [
"68be5fd0dd5266a8c45dafe6f0a00c74ac0a51ae269e626ad7faa2820f5e3ac0",
"02b1fad58921c72a907668a0b46d10bbc26ecddbf6481e3bd6643026f9085927"
]
},
"next": "Accept/commit S05; next product work R01/R11 requires pending ADR-006. Performance remains deferred; no other code/ADR-ready execution task is authorized by this handoff."
}
}