docs(development): accept F08 and pin stateful strategy runtime scope

This commit is contained in:
Boki 2026-10-23 12:17:07 -04:00
parent 3838295eec
commit 0870b55830
5 changed files with 76 additions and 28 deletions

View file

@ -1,8 +1,8 @@
# Revised development roadmap
Baseline `b7aeca4` · execution 2026-10-23 · **F09/P07 committed; F08 validated, uncommitted**
Baseline `b7aeca4` · execution 2026-10-23 · **F08 committed; S01 in progress**
Authorization update: the owner accepted the validated performance work and requested commit plus backlog continuation. F09/P07 are committed as `e3bd722`; F08 historical reporting is now authorized under ADR-002/003/004. No other ADR or multi-asset mark policy is approved. New implementation commits, pushes, PRs and trading/default-engine operations remain outside this continuation's scope.
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.
## Strategy and review outcome
@ -20,7 +20,7 @@ The existing web workbench improves during engine migration. Legacy results rema
| [ADR-002](architecture/decisions/002-financial-policy.md) | Maintained checked decimal; 8-place half-up postings; authoritative remaining cost; owner books from day one; initial cash-funded long-only account | Approved by owner, 2026-10-22 |
| [ADR-003](architecture/decisions/003-time-and-datasets.md) | Availability/event phases; open-only next-interval matching; explicit zero-latency convention; mark-open terminal policy; account risk-session clock | Approved by owner, 2026-10-22 |
| [ADR-004](architecture/decisions/004-strategy-boundary.md) | NAPI pull sessions in existing workers; tagged decision barriers; IPC for untrusted code; no embedded JS | Approved by owner, 2026-10-22 |
| [ADR-005](architecture/decisions/005-durable-cutover.md) | One Rust transition kernel; resident research state; private staged paper state under existing SQL transactions | Plan approval |
| [ADR-005](architecture/decisions/005-durable-cutover.md) | One Rust transition kernel; resident research state; private staged paper state under existing SQL transactions | Approved by owner continuation, 2026-10-23; paper activation separately gated |
| [ADR-006](architecture/decisions/006-research-product.md) | Existing API/queue/database; immutable versions, provenance and evidence retention; no laboratory framework | Plan approval |
| [ADR-007](architecture/decisions/007-ai-boundary.md) | Isolated untrusted code, research-only permissions/budgets; human-only paper promotion; live disabled | Explicit trust-model approval |
| [ADR-008](architecture/decisions/008-performance.md) | Measure actual paths; cursor replay and bounded trials; caching/DSL only when measured | Plan approval; later optimization go/no-go |
@ -340,6 +340,14 @@ Raw samples, source/artifact hashes, commands and review evidence are in `manife
Limits: sampled drawdown is not intraday maximum; marks are last available without per-session freshness certification; benchmark-dependent and round-trip statistics remain null with reasons. Sequential equal-time marks can still latch intermediate risk halts. R05 retains its owner policy gate and public/persisted result cutover. **Next after acceptance: S01 stateful TypeScript strategy decisions**, requiring ADR-005 approval; R01/R11 require ADR-006. No pending decision, default cutover, push, PR or trading operation was implicitly approved.
## Fourteenth-wave execution — 2026-10-23
F08 was accepted and committed as `3838295`, superseding its uncommitted handoff above. S01 is the next satisfied task under ADR-004/005. Isolated runtime and verification worktrees start at that commit under `/tmp/stock-bot-wave14.JYfazy/`; root owns planning/integration and a separate reviewer checks the result.
[S01's execution contract](backlog/tasks/S01.md#execution-contract--2026-10-23) pins one shared pull loop, typed synchronous state-in/state-out strategy programs, per-owner observation/decision/RNG cursors, atomic staging around native submission and truthful admission feedback. Different strategy cadences must not lose another owner's observations. Rust remains the only financial authority.
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.
## 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.

View file

@ -1,6 +1,6 @@
# ADR-005 — Shared kernel, distinct persistence boundaries
Status: proposed for approval; preservation of existing recovery is required.
Status: **approved by owner continuation, 2026-10-23**. After the handoff named S01 and linked this pending decision, the owner instructed “commit all of it and continue.” This approves the documented direction for the next task; paper migration/default activation remain separately gated. Preservation of existing recovery is required.
## One implementation
@ -23,3 +23,7 @@ All currently supported paper order policies must be preserved or a migration ex
C06 contains unsafe legacy research/paper composition; it does not build a temporary second worker framework. F02 builds owner accounting once. S03 adopts the kernel and durable recovery without waiting for Sharpe/Sortino or web pages. S04 verifies paper feed/readiness. S06 retires competing active execution after those gates, retaining result readers/research algorithms.
Compare financial transitions for the **same event and intent trace**. Research and paper receive different real-world prices/availability; identical P&L is not promised for different inputs. Broker fills remain future external facts to reconcile, not simulated orders that can be rejected after occurrence.
## S01 retry scope
The existing durable research runner retries whole attempts. S01 follows that boundary: create a fresh native session from frozen data/configuration, clone original strategy states and restore original per-owner seeds, then recompute observations, decisions and RNG cursors. Per-barrier TypeScript diagnostic snapshots are not independently resumable financial checkpoints. Do not add a native checkpoint wire or accept a TS-only mid-run resume merely for S01. Existing Rust checkpoint reconstruction and paper SQL checkpoints remain preserved; S03 owns their durable integration.

View file

@ -1,6 +1,6 @@
# Canonical development backlog
**First twelve waves committed; F08 validated and awaiting acceptance.** F09/P07 were accepted as `e3bd722`; `1e16445` records their completion and the F08 contract. F08 adds account-session equity, occupied-time exposure and explicit statistical policies on the same financial core. Consult manifest execution_scope and [current wave](../ROADMAP.md#thirteenth-wave-execution--2026-10-23). ADR-002/003/004 are approved; other policies/default cutovers remain gated.
**First thirteen waves committed; S01 in progress.** F08 is accepted as `3838295`. S01 adds stateful TypeScript decisions over Rust sessions with per-owner cursors and staged state. Consult manifest execution_scope and [current wave](../ROADMAP.md#fourteenth-wave-execution--2026-10-23). ADR-002/003/004/005 are approved; other policies/default cutovers remain gated.
## One source of truth
@ -36,7 +36,7 @@ Relative size: S narrow correction, M coherent boundary, L sensitive owner-contr
| [F05 Unify matching and order lifecycle on the ledger](tasks/F05.md) | P0 / done | F04, ADR-003 | F06 | Rust execution semantics / L |
| [F06 Implement deterministic replay once, with linear historical traversal](tasks/F06.md) | P0 / done | F05, D01, P01, ADR-003 | — | Rust deterministic replay / M |
| [F07 Expose bounded Rust step sessions through existing NAPI workers](tasks/F07.md) | P0 / done | F06, C02, ADR-004 | — | Rust/TypeScript integration / M |
| [F08 Publish canonical metrics and versioned result projections](tasks/F08.md) | P1 / review | F06, F09, ADR-002, ADR-003 | — | Quant analytics/Rust integration / M |
| [F08 Publish canonical metrics and versioned result projections](tasks/F08.md) | P1 / done | F06, F09, ADR-002, ADR-003 | — | Quant analytics/Rust integration / M |
| [F09 Return compact canonical replay projections](tasks/F09.md) | P1 / done | F07, ADR-002, ADR-003, ADR-004 | — | Rust/TypeScript financial integration / M |
### E3 — Point-in-time datasets and features
@ -52,7 +52,7 @@ Relative size: S narrow correction, M coherent boundary, L sensitive owner-contr
| Task | Priority / status | Implementation prerequisites | Release gate | Specialist / size |
| --- | --- | --- | --- | --- |
| [S01 Run deterministic TypeScript decisions on Rust sessions](tasks/S01.md) | P0 / blocked | F07, ADR-004, ADR-005 | — | TypeScript trading infrastructure / M |
| [S01 Run deterministic TypeScript decisions on Rust sessions](tasks/S01.md) | P0 / in_progress | F07, ADR-004, ADR-005 | — | TypeScript trading infrastructure / M |
| [S02 Adapt one SMA strategy for the first canonical path](tasks/S02.md) | P1 / blocked | S01 | — | TypeScript strategy/quant engineering / M |
| [S03 Adapt durable paper transactions to Rust financial reducers](tasks/S03.md) | P0 / blocked | S01, C06, ADR-005 | — | Durable execution/Rust integration / L |
| [S04 Establish a verified paper feed and operator safety gate](tasks/S04.md) | P1 / blocked | S02, S03 | — | TypeScript trading infrastructure / M |
@ -117,4 +117,4 @@ Relative size: S narrow correction, M coherent boundary, L sensitive owner-contr
Before any wave: unique IDs; existing task/ADR references; acyclic implementation graph; no scheduled task dependent on merged/deferred work; approvals/readiness; actual file locks; isolated native build outputs/workspace dependencies and test databases. Release gates are checked separately at activation.
The first twelve waves are committed. **F08 is independently reviewed and validated, with new implementation changes uncommitted.** Its reporting facts and statistics preserve authoritative Rust financial output; R05 retains persistence and public-result migration. Next, S01 needs ADR-005 approval; R01/R11 need ADR-006. The unresolved multi-asset mark-policy gate still blocks default activation. No further task, new commit, push, PR or trading operation is included in this continuation.
The first thirteen waves are committed. **S01 is authorized and in progress** after the owner continued from the named next step and linked ADR-005. One owner implements the runtime/feedback contract; disjoint tests consume the pinned API. R01/R11 still need ADR-006; the multi-asset mark-policy gate still blocks default activation. New S01 commits, other tasks, push, PR or trading operations are outside this continuation.

View file

@ -1,16 +1,16 @@
{
"schema_version": 1,
"plan_revision": "2026-10-23.30",
"plan_revision": "2026-10-23.31",
"repository_base": "b7aeca4",
"plan_status": "thirteenth_wave_in_review",
"plan_status": "fourteenth_wave_in_progress",
"execution_authorized": true,
"execution_scope": {
"authorized_by": "User: lets commit and continue with the backlog (2026-10-23). Accepted F09/P07 commit and authorizes F08 canonical historical reporting under approved ADR002/003/004; no default cutover or new financial policy.",
"authorized_by": "User: commit all of it and continue (2026-10-23), after handoff explicitly named S01 and linked pending ADR-005. F08 accepted and committed as 3838295; continue with S01 under ADR-004/005. No paper/default cutover or unrelated ADR approval.",
"tasks": [
"F08"
"S01"
],
"permissions": [
"accepted_wave12_commits",
"accepted_wave13_commits",
"isolated_implementation",
"local_tests",
"local_integration_review",
@ -25,7 +25,6 @@
"other_backlog_tasks"
],
"pending_policy_decisions": [
"ADR-005",
"ADR-006",
"ADR-007",
"ADR-008"
@ -62,7 +61,9 @@
{
"id": "ADR-005",
"file": "architecture/decisions/005-durable-cutover.md",
"status": "proposed_for_plan_approval"
"status": "approved",
"approved_by": "Owner instructed commit all of it and continue after handoff explicitly named S01 and linked pending ADR-005; direction approved, paper migration/default activation remain separate.",
"approved_on": "2026-10-23"
},
{
"id": "ADR-006",
@ -650,7 +651,7 @@
"epic": "E2",
"priority": "P1",
"severity": "High",
"status": "review",
"status": "done",
"dependencies": [
"F06",
"F09"
@ -677,12 +678,12 @@
"assignment": "/root/f08_contract_review",
"branch": "wave13/f08-reporting",
"pull_request": null,
"completed_commit": null,
"completed_commit": "3838295eec8e84a46115462ca6c5d5c8c7fab66b",
"blocker": null,
"release_gates": [],
"worktree": "/tmp/stock-bot-wave13.KfvceG/f08",
"integration_base": "e3bd722e31a4e14519df543d87affd90a8103fa2",
"integration_state": "validated_uncommitted",
"integration_state": "validated_committed",
"implementation_slices": [
{
"owner": "/root/f08_contract_review",
@ -699,7 +700,8 @@
],
"review_notes": "Independent reviews accepted native/reporting and analytics slices. 22 owner files integrated with exact hashes plus root native/worker/analytics composition tests. Repository gates, disposable recovery and release comparisons pass; shared-host drift checked against unchanged release control. Financial event IDs/checkpoints/trace/projection and legacy paths retained. See thirteenth_wave_validation; R05 owns persisted/public-result cutover.",
"reviewed_by": ["/root/wave12_review", "/root"],
"verification_reference": "ROADMAP.md#thirteenth-wave-execution--2026-10-23"
"verification_reference": "ROADMAP.md#thirteenth-wave-execution--2026-10-23",
"accepted_by": "Owner: commit all of it and continue (2026-10-23). Accepted source hashes reverified before commit 3838295."
},
{
"id": "F09",
@ -902,7 +904,7 @@
"epic": "E4",
"priority": "P0",
"severity": "Critical",
"status": "blocked",
"status": "in_progress",
"dependencies": [
"F07"
],
@ -920,15 +922,24 @@
"specialization": "TypeScript trading infrastructure",
"write_locks": [
"strategy-contract",
"worker-protocol"
"replay-driver",
"native-admission-feedback"
],
"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": "One runtime/native-feedback contract owner; disjoint verification owner consumes the pinned contract. Root owns metadata/integration; independent reviewer is read-only. No worker request or financial-engine change.",
"assignment": "/root/s01_contract",
"branch": "wave14/s01-runtime",
"pull_request": null,
"completed_commit": null,
"blocker": null,
"release_gates": []
"release_gates": [],
"worktree": "/tmp/stock-bot-wave14.JYfazy/s01",
"integration_base": "3838295eec8e84a46115462ca6c5d5c8c7fab66b",
"integration_state": "isolated_implementation",
"implementation_slices": [
{ "owner": "/root/s01_contract", "scope": "Typed strategy contract, shared pull driver, staged per-owner runtime, native admission-feedback parser and focused tests", "worktree": "/tmp/stock-bot-wave14.JYfazy/s01", "branch": "wave14/s01-runtime" },
{ "owner": "/root/s01_test_review", "scope": "Disjoint real-native multi-owner failure/retry/integrity tests and measured strategy fixture after pinned API handoff", "worktree": "/tmp/stock-bot-wave14.JYfazy/verification", "branch": "wave14/s01-verification" }
],
"review_notes": "Whole-attempt restart from frozen inputs/initial states/seeds; diagnostic TS snapshots are not resumable financial checkpoints. Per-owner observation cursors and RNG/decision sequences; native Order effects supply admission feedback. Direct trusted host programs only; S02 owns built-in/worker wiring, S03 paper recovery, R05 default/persistence cutover."
},
{
"id": "S02",
@ -4929,7 +4940,8 @@
"Legacy positions and round-trip DTOs cannot truthfully represent the new facts without further work. F08 publishes an additive canonical analytics DTO; R05 retains persisted/public-result/default cutover with existing approval gates."
],
"thirteenth_wave_validation": {
"state": "validated_uncommitted",
"state": "validated_committed",
"accepted_commit": "3838295eec8e84a46115462ca6c5d5c8c7fab66b",
"work_root": "/tmp/stock-bot-wave13.KfvceG",
"committed_before_implementation": [
"e3bd722e31a4e14519df543d87affd90a8103fa2",
@ -5201,6 +5213,14 @@
"Legacy financial paths/results/UI remain active until separately gated migration. No DSL/cache/journal deletion or unrelated hot-loop rewrite."
],
"cleanup": "Stopped only exact --rm fixture containers a4edf7d7b61f944d9b42f93fe2fb77c9be565efabfa9292aeb8d34de3d1c8c85 and 604c940db286ab408bd60963116355428f0efa216725ca2e269639e1572fc1dd. Development services untouched; isolated worktrees/logs retained.",
"next": "After acceptance, S01 stateful TS decisions requires ADR-005 approval; R01/R11 require ADR-006. No pending ADR implicitly approved."
}
"next": "At handoff S01 required ADR-005; the next owner instruction accepted F08 and continued the explicitly named S01/ADR-005 direction. See fourteenth_wave_notes. R01/R11 remain gated by ADR-006."
},
"fourteenth_wave": ["S01"],
"fourteenth_wave_base": "3838295eec8e84a46115462ca6c5d5c8c7fab66b",
"fourteenth_wave_notes": [
"Owner: commit all of it and continue, after the handoff named S01 and linked pending ADR-005. F08 committed after exact accepted-source hash verification; S01 is now authorized under ADR-004/005.",
"Root pinned S01 whole-attempt restart and per-owner state/RNG/observation semantics after independent runtime/recovery inspection. Existing native API has no checkpoint wire; do not introduce a partial TS-only resume.",
"One implementation owner controls strategy contract/shared driver/native admission feedback. Disjoint verification owner waits for pinned API. Root owns metadata/integration; independent review checks both slices.",
"Trusted direct programs only. S02 owns real-strategy/worker composition, S03 paper migration, R05 durable canonical/default cutover. Other ADRs, untrusted-code isolation, financial policy and existing active runtimes remain unchanged."
]
}

View file

@ -57,3 +57,19 @@ Keep migrations additive and previous results readable. Do not add a switch that
## Handoff
Report scope changes (if any), fixture expectations, API/schema changes, measurements, remaining limitations and commit/PR references once authorized. Request independent review; only the integration/planning owner may mark the manifest done.
## Execution contract — 2026-10-23
The owner accepted F08 and requested continuation after the handoff explicitly named S01 and linked ADR-005. Base `3838295`; manifest revision `2026-10-23.31`. Root reserves the strategy contract/shared pull driver/native feedback parser to one owner; independent test author owns disjoint test/measurement files after the API is pinned. No Rust financial semantics, worker request protocol, active legacy registry, SQL/paper operation or default cutover changes.
- Add `runStrategyReplay(load, programs, options)` as a trusted host primitive. Programs have owner ID, strategy ID/version, fixed target/orders mode, explicit uint32 seed, initial JSON state and a synchronous `decide(context) -> {nextState, intent}`. Owner IDs are unique and exactly match native configuration; strategy IDs/versions may repeat for independent instances. Capture/detach inputs at attempt creation. Do not pass execution services, native handles, future data or state belonging to other owners into author callbacks.
- Context contains the engine time/barrier, the same frozen portfolio view for every due callback, owned positions, newly available observations since that owner's prior decision, previous admission feedback, readonly typed state and a scoped `random()`. Cadence controls scheduling; it must not discard another owner's pending observations. Warmup is consumed through the same prefix. Account information remains visible for portfolio-aware strategies; isolated state/feedback belongs only to its owner.
- Extract one internal pull loop used by the existing conformance wrapper and the new runtime. Keep existing trace IDs, output hashes, observation delivery and format defaults stable for conformance. The runtime stages all due decisions/states before one native batch; only a validated successful response commits all prepared state/RNG/observation/sequence slots. A native risk rejection is a valid state transition; a failed/ambiguous submit disposes the attempt.
- Per-owner RNG uses versioned `lcg32-v1`, the existing unsigned 32-bit `Math.imul(state,1664525)+1013904223` recurrence, divided by 2^32. Track state/draw count and safe decision counters. Invalidate the scoped RNG function immediately after the synchronous callback, including exceptions. This is reproducible fixture randomness, not a cryptographic or statistical-independence claim.
- Reject non-JSON, lossy/nonfinite state, async outputs, invalid intents and wrong modes before admission. Detach/freeze input and returned state; do not let caller mutation or retained callback references rewrite a committed snapshot. Copying small strategy state is acceptable; never clone native financial history per observation.
- Admission feedback copies validated native `Order` effects for the owner, including native rejection reasons and cancellation of that owner's earlier decisions. `Running` is not proof of order acceptance. Feedback is available at that owner's next decision and retained in terminal diagnostics. This is not a complete fill-event stream: subsequent fills appear in authoritative positions/open orders; S01 does not invent execution events or accounting.
- Return `{result, metrics, diagnostics}`. Versioned diagnostic snapshots contain identity, committed barrier count/last ID, sorted owner records with state, next decision sequence, RNG state/draw count, consumed observation count and previous admission feedback. `StrategyReplayError` carries the last confirmed committed diagnostics and cause, never a successful financial result. Fault tests may spy on the native host submit method; no generic session factory is needed.
- Retry means an entirely fresh native session with the original frozen inputs, detached initial states and per-owner seeds. Recompute every cursor and decision. Diagnostic TS snapshots are **not resumable financial checkpoints**. Do not expose a TS-only restore API or add native checkpoint transport for this task. Existing Rust reconstruction and paper checkpoints remain intact.
- 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.