docs(development): accept wave12 and define canonical reporting work

This commit is contained in:
Boki 2026-10-23 11:17:36 -04:00
parent e3bd722e31
commit 1e164450c3
5 changed files with 130 additions and 28 deletions

View file

@ -1,6 +1,6 @@
# Canonical development backlog
**First eleven waves committed; F09/P07 reviewed, validated and uncommitted.** F09 adds optional compact terminal/fill projection; P07 proves matching finances and measured speedups at 10k/100k bars. F08 retains historical metrics. Consult manifest execution_scope and [handoff](../ROADMAP.md#twelfth-wave-handoff--2026-10-23). ADR-002/003/004 are approved; other policies/default cutovers remain gated.
**First twelve waves committed; F08 in progress.** F09/P07 were accepted as `e3bd722`. 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.
## One source of truth
@ -36,8 +36,8 @@ 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 / blocked | F06, F09, ADR-002, ADR-003 | — | Quant analytics/Rust integration / M |
| [F09 Return compact canonical replay projections](tasks/F09.md) | P1 / review | F07, ADR-002, ADR-003, ADR-004 | — | Rust/TypeScript financial integration / M |
| [F08 Publish canonical metrics and versioned result projections](tasks/F08.md) | P1 / in_progress | 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
@ -95,7 +95,7 @@ Relative size: S narrow correction, M coherent boundary, L sensitive owner-contr
| [P04 Schedule deterministic batches across a bounded worker pool](tasks/P04.md) | P2 / blocked | F07, R06, C06, P01, ADR-008 | — | Performance/infrastructure engineering / M |
| [P05 Separate result summaries from paged detail payloads](tasks/P05.md) | P2 / deferred | R06, P01 | — | Performance/infrastructure engineering / M |
| [P06 Conditionally add a minimal Rust-executed strategy plan](tasks/P06.md) | P2 / deferred | P04, S01, ADR-008 | — | Rust/TS performance compiler boundary / M |
| [P07 Profile representative canonical replay workloads](tasks/P07.md) | P1 / review | F07, P01 | F09 for compact comparisons | Performance/test infrastructure / M |
| [P07 Profile representative canonical replay workloads](tasks/P07.md) | P1 / done | F07, P01 | F09 for compact comparisons | Performance/test infrastructure / M |
### E8 — Authorized, isolated AI research

View file

@ -1,16 +1,16 @@
{
"schema_version": 1,
"plan_revision": "2026-10-23.28",
"plan_revision": "2026-10-23.29",
"repository_base": "b7aeca4",
"plan_status": "twelfth_wave_integrated_awaiting_acceptance",
"plan_status": "thirteenth_wave_in_progress",
"execution_authorized": true,
"execution_scope": {
"authorized_by": "User: make a story or stories for it and lets continue (2026-10-23). Authorizes performance backlog updates, compact result projection and representative profiling; no new financial policy or default cutover.",
"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.",
"tasks": [
"F09",
"P07"
"F08"
],
"permissions": [
"accepted_wave12_commits",
"isolated_implementation",
"local_tests",
"local_integration_review",
@ -21,6 +21,7 @@
"push",
"pull_requests",
"live_or_paper_operations",
"default_engine_cutover",
"other_backlog_tasks"
],
"pending_policy_decisions": [
@ -649,7 +650,7 @@
"epic": "E2",
"priority": "P1",
"severity": "High",
"status": "blocked",
"status": "in_progress",
"dependencies": [
"F06",
"F09"
@ -666,15 +667,37 @@
"complexity": "M",
"specialization": "Quant analytics/Rust integration",
"write_locks": [
"result-contract"
"result-contract",
"native-public-api",
"replay-reporting",
"canonical-analytics",
"calculation-statistics"
],
"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 native/reporting-wire owner; disjoint analytics/calculation owner consumes root-accepted frozen wire schema. No independent financial contract reinterpretation. Root owns integration/planning.",
"assignment": "/root/f08_contract_review",
"branch": "wave13/f08-reporting",
"pull_request": null,
"completed_commit": null,
"blocker": null,
"release_gates": []
"release_gates": [],
"worktree": "/tmp/stock-bot-wave13.KfvceG/f08",
"integration_base": "e3bd722e31a4e14519df543d87affd90a8103fa2",
"integration_state": "isolated_implementation",
"implementation_slices": [
{
"owner": "/root/f08_contract_review",
"scope": "Rust reporting accumulator, replay hooks, native API, strict TS native/worker contract and focused tests",
"worktree": "/tmp/stock-bot-wave13.KfvceG/f08",
"branch": "wave13/f08-reporting"
},
{
"owner": "/root/f08_benchmark_plan",
"scope": "Additive shared canonical analytics types, reviewed statistics policy extension, pure report adapter and focused tests",
"worktree": "/tmp/stock-bot-wave13.KfvceG/f08-analytics",
"branch": "wave13/f08-analytics"
}
],
"review_notes": "Root pinned reporting conventions in F08 Execution contract. Preserve financial event IDs/checkpoints/trace/projection outputs. Additive canonical analytics contract; incompatible legacy DTO/persistence/public-result migration remains R05. No default cutover."
},
{
"id": "F09",
@ -682,7 +705,7 @@
"epic": "E2",
"priority": "P1",
"severity": "High",
"status": "review",
"status": "done",
"dependencies": [
"F07"
],
@ -710,9 +733,9 @@
"branch": "wave12/f09-compact-results",
"worktree": "/tmp/stock-bot-wave12.F9Rlh4/f09",
"integration_base": "19e9dad",
"integration_state": "validated_uncommitted",
"integration_state": "validated_committed",
"pull_request": null,
"completed_commit": null,
"completed_commit": "e3bd722e31a4e14519df543d87affd90a8103fa2",
"blocker": null,
"release_gates": [],
"concrete_write_scope": [
@ -728,7 +751,7 @@
"test/fixtures/native-replay*",
"scripts/test/native-bindings.test.ts"
],
"review_notes": "Independent frozen-artifact review, exact root integration, full checks, disposable recovery tests and paired release comparisons passed. Optional compact projection preserves financial semantics/full diagnostic hashes; no default cutover or journal deletion. See twelfth_wave_validation.",
"review_notes": "Independent frozen-artifact review, exact root integration, full checks, disposable recovery tests and paired release comparisons passed. Optional compact projection preserves financial semantics/full diagnostic hashes; no default cutover or journal deletion. See twelfth_wave_validation. Owner accepted and authorized commit e3bd722 on 2026-10-23.",
"verification_reference": "ROADMAP.md#twelfth-wave-handoff--2026-10-23"
},
{
@ -1855,7 +1878,7 @@
"epic": "E7",
"priority": "P1",
"severity": "High",
"status": "review",
"status": "done",
"dependencies": [
"F07",
"P01"
@ -1875,9 +1898,9 @@
"branch": "wave12/p07-replay-profiling",
"worktree": "/tmp/stock-bot-wave12.F9Rlh4/p07",
"integration_base": "19e9dad",
"integration_state": "validated_uncommitted",
"integration_state": "validated_committed",
"pull_request": null,
"completed_commit": null,
"completed_commit": "e3bd722e31a4e14519df543d87affd90a8103fa2",
"blocker": null,
"release_gates": [],
"conditional_release_gates": [
@ -1893,7 +1916,7 @@
"scripts/benchmark-research.ts",
"scripts/test/benchmark-replay.test.ts"
],
"review_notes": "Independent financial-normalizer and measurement/provenance reviews passed; final 72-tooling gate and strict test types/lint passed. Paired final-source release benchmarks cover all three 10k profiles and sparse/turnover at 100k. Historical baseline source-retention limitation is explicit; measured final source is archived.",
"review_notes": "Independent financial-normalizer and measurement/provenance reviews passed; final 72-tooling gate and strict test types/lint passed. Paired final-source release benchmarks cover all three 10k profiles and sparse/turnover at 100k. Historical baseline source-retention limitation is explicit; measured final source is archived. Owner accepted and authorized commit e3bd722 on 2026-10-23.",
"verification_reference": "ROADMAP.md#twelfth-wave-handoff--2026-10-23"
},
{
@ -4892,5 +4915,15 @@
"Synthetic conformance workloads, not arbitrary production strategies, database/queue throughput, empty NAPI cost, parallel speedup or an isolated-host SLA. No 100k no-trade measurement is claimed."
]
}
}
},
"thirteenth_wave": [
"F08"
],
"thirteenth_wave_base": "e3bd722e31a4e14519df543d87affd90a8103fa2",
"thirteenth_wave_notes": [
"Owner accepted F09/P07 and requested commit plus continuation. Feature commit e3bd722 contains the reviewed wave12 source/tests/planning; F08 is the next satisfied code/ADR task.",
"Reporting conventions pinned in F08 Execution contract after independent Rust/quant design inspection. Separate accumulator; existing financial events/checkpoints/config/outputs retained; account-session reporting and elapsed occupancy are explicit.",
"Two isolated source owners: native/reporting wire and disjoint shared analytics/statistics adapter. Exact accepted schema is handed off before consumer integration. Independent reviewer is read-only.",
"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."
]
}

View file

@ -17,7 +17,7 @@ F09 now supplies the independently deliverable compact terminal/owned-fill proje
Use canonical Rust ledger postings, owned fills, occupied intervals and session-ending marks as the sole financial inputs. Reuse reviewed TypeScript statistical functions in `libs/calculations/src/analytics/` for return ratios and reports; do not port them to Rust merely for language uniformity. Add a small adapter for the engine-declared session calendar rather than blindly regrouping every venue by UTC date.
Version economics and metrics independently. Define sampling, annualization, benchmark and risk-free conventions in the result policy. Missing benchmark/risk-free inputs must not silently become invented measurements. Undefined or unsupported metrics are null with reasons. Adapt existing result DTOs without rewriting old rows.
Version economics and metrics independently. Define sampling, annualization, benchmark and risk-free conventions in the result policy. Missing benchmark/risk-free inputs must not silently become invented measurements. Undefined or unsupported metrics are null with reasons. Add a reusable canonical analytics DTO alongside the existing result types; R05 owns persisted/public-result cutover. Do not coerce owned financial facts into incompatible legacy position/round-trip fields or rewrite old rows.
Measurable benefit: comparable, independently checked rankings without a second ledger or a needless analytics rewrite.
@ -36,7 +36,7 @@ No accounting/fill recomputation in TypeScript, statistical library rewrite, for
- libs/calculations/src/analytics/equity.ts (review existing UTC grouping; use explicit session marks)
- libs/core/types/src/backtest-run.ts
Write locks: result-contract. One agent owns this change. Lock names do not override actual overlapping files.
Write locks: result-contract, native-public-api, replay-reporting, canonical-analytics, calculation-statistics. One owner controls the Rust/native reporting contract. A separate analytics owner may implement disjoint shared types/calculations/adapter files after root pins the contract; consume the exact accepted schema before integration. Lock names do not override actual overlapping files.
## Dependencies and blockers
@ -52,6 +52,7 @@ Parallel eligibility: only with disjoint actual files and reserved write locks;
- Sharpe uses periodic excess-return mean/std; Sortino uses downside deviation relative to the declared target; zero-variance/undefined cases are null with reasons.
- Exposure uses the union of occupied intervals; open positions count; attribution distinguishes fills and round trips.
- Reviewed calculation functions are reused where their conventions match. Any deliberate difference has a versioned policy and independent arithmetic fixture, not an unexplained second formula.
- The additive canonical analytics DTO preserves nullable/unsupported metrics and fill ownership without invoking legacy percentage conversion. Existing result mapping and frontend fixtures remain unchanged and pass. Persisted canonical rows/public DTO conversion remain R05; this story does not enable canonical web runs.
- Preserve the sequential equal-time marking policy and its material risk limitation in result provenance: intermediate valuations may latch halts despite a recovered synchronized value. Do not report such traces as atomically marked portfolio risk. Before canonical multi-asset default cutover, apply R05's explicit owner policy-review gate; component F06 acceptance does not satisfy it.
## Mandatory tests
@ -69,3 +70,58 @@ 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
Owner instruction: commit accepted F09/P07 and continue the backlog. F09/P07 are committed in `e3bd722`; F08 is the next code/ADR-ready story. These are reporting conventions, not changes to approved financial/risk policy.
### Native financial reporting owner
- Keep `Replay.events`, event indexes/IDs, `ReplayConfig`, `ReplayCheckpoint`, all financial receipts and existing trace/projection wire output unchanged. Add a small private reporting accumulator; restore already replays the retained decisions and must rebuild identical reporting facts without a new checkpoint schema.
- Periods follow the initial account risk session plus declared risk boundaries. Clip to `[tradeStart, tradeEnd]`; never infer UTC or asset venue days. At each boundary, sample the preceding period after **all** equal-time Observation events, before Decision/Execution. Risk reset still occurs in its existing earlier phase. Initial equity comes from Rust, and terminal equity is always retained.
- First periods clipped by tradeStart have `partialStart`; final periods without a declared closing boundary at tradeEnd have `partialEnd`. An exact terminal boundary emits one preceding period, not a zero-length new period. Retain partial returns/history but exclude them from full-period statistics. Last available marks remain explicit; do not claim freshness or atomic portfolio risk.
- Exposure is the union of account occupancy intervals over elapsed calendar time, including overnight/weekends. Observe actual non-replayed committed fills, then use existing `Ledger::owned_quantities().next().is_some()`; no quantity reconstruction. Merge adjacent intervals, omit zero-length intervals, and clip open holdings at tradeEnd for measurement only. No synthetic closing fill. Encode `occupiedMs`/`elapsedMs` as canonical nonnegative integer strings to preserve durations spanning the supported timestamp domain.
- Sampling failures must not reorder or mutate financial transitions or overwrite a financial failure. Report access rejects incomplete/failed/disposed or unavailable reporting state.
- Add native `report(identityJson)` beside unchanged `finalize()`/`project()`. Wire output is `format: "report"`, `reportingVersion: 1`, `projectionVersion: 1`, `financialVersion: 1`, the existing provenance/view/limitations and financial `projection`, plus `reporting` below. Keep reporting outside strategy contexts.
```ts
reporting: {
calendarId: string;
calendarRevision: string;
tradeStart: number;
tradeEnd: number;
initialEquity: FinancialDecimal;
sampling: 'account-boundary-after-observations-v1';
exposureBasis: 'elapsed-calendar-time';
sessions: {
session: RiskSessionIdentity;
periodStart: number;
periodEnd: number;
partialStart: boolean;
partialEnd: boolean;
equity: FinancialDecimal;
}[];
occupiedIntervals: { start: number; end: number }[];
occupiedMs: string;
elapsedMs: string;
}
```
- Extend the same TS native session/conformance/worker path with explicit `resultFormat: "report"`, strict parsing and captured format/identity/policy guards. Old omitted/trace/projection behavior and hashes stay stable. Root accepts the schema before the analytics consumer integrates it.
### TypeScript analytics owner
- Add application-independent `CanonicalBacktestAnalytics`/policy types adjacent to `BacktestRunResult`, without widening/reinterpreting the legacy DTO. One orchestrator adapter composes `{ financial: ReplayReportResult, analytics: CanonicalBacktestAnalytics }`.
- Adapter input requires policy version 1, positive finite `periodsPerYear`, explicit finite `annualRiskFreeRate` or `null`, and `benchmark: null`. Benchmark-dependent metrics are unavailable in v1; reject unsupported benchmark input. Output policy also records the fixed conventions, calendar identity and units. These are recorded conventions, not new configurable switches.
- Compute ratios from authoritative equity samples only. Include every session return, including partial terminal periods, with eligibility flags. Use only complete periods with defined positive baselines for periodic statistics; do not silently discard undefined full-period returns to create a different sequence.
- Reuse reviewed `returnStatistics`, equity/drawdown helpers and primitives. Extend `returnStatistics` minimally with explicit periods/year and nullable risk-free input, preserving old defaults for existing callers. Missing risk-free input leaves volatility/tail statistics available but target-dependent ratios/downside deviation null. Sample standard deviation uses n−1; downside RMS uses all n observations relative to annualRiskFreeRate/periodsPerYear. Exactly constant finite input has zero deviation; no arbitrary epsilon.
- Drawdown is explicitly session-end/terminal-sampled, not maximum intraday drawdown. Total return uses initial-to-terminal equity; CAGR may use actual elapsed calendar time with the fixed 365-day-year convention, including partial endpoints. This does not treat a partial period as a complete session. Zero/nonpositive baselines and nonfinite/undefined results produce null with reasons.
- Reuse a narrowly extracted drawdown-only helper instead of invoking unused UTC Date grouping, since native safe-integer timestamps exceed JavaScript Date's range. Positive initial equity and elapsed time with terminal equity zero has CAGR −1; negative terminal equity remains unsupported. Pin both edge cases with independent tests. Policy must state that marks are last available and per-session freshness is not certified.
- Report `fillCount` separately. Round-trip count/win rate/profit factor/average win/loss are unsupported/null; no inferred trade grouping, position marks, average cost or financial postings. Preserve exact Rust financial facts in the composed report.
- Keep legacy `BacktestReport`, normalization, stored-row mapping and UI unchanged. R05 will consume this additive contract during its separately gated persistence/public-result migration. Existing compatibility tests must pass.
### Required additional validation
- Rust: boundary sample after observations versus unchanged earlier risk reset; equal-time sequential risk halt still latched; first/final partial periods and exact terminal-boundary deduplication; exposure overlap/open positions/same-time owner handoff; no trade/stale marks; restore after every event including within observation groups; unchanged financial checkpoint/trace/project results.
- TS/native: report format/identity/calendar/terminal-value validation; worker format/cancellation/failure guards; two sessions 100 → 110 → 99 yield +10%/−10%; partial returns retained but not annualized as full sessions; missing rates/benchmark; constant negative and nonbinary constant returns; unsupported round trips remain null; genuine zero exposure survives the additive adapter.
- Run existing calculation, mapping and frontend metric/provenance fixtures, full repository checks and scoped strict test TypeScript. Worker changes require disposable PostgreSQL/Redis recovery gates. Measure reporting overhead against the accepted compact path with identical economic hashes; no timing assertions, new cache/DSL, journal deletion, or unrelated hot-loop optimization.

View file

@ -14,6 +14,8 @@ Scheduling source of truth: [manifest entry R05](../manifest.json). No task is a
Freeze strategy/model artifact IDs, parameters, seed, code/lockfile/build hashes and execution policies at submission. For a selected frozen dataset, pin its hash immediately; for a source request, retain the immutable query and atomically attach the first prepared dataset/hash before replay begins. Expose preparing versus reproducibility-finalized state. Wire the canonical Rust session with existing registered TS strategies into the durable runner and versioned result DTO. Exact reproduction API/UI is R12.
Consume F08's additive canonical analytics/report contract here. Version the persisted/public projection so canonical fractions, genuine zero exposure and null reasons bypass legacy percentage conversion/placeholder suppression. Preserve owner books and distinguish fills from round trips. Additional position valuations needed by the UI must come from Rust or be explicitly unavailable; do not invent marks, average-price basis or unrealized P&L in TypeScript merely to satisfy the old DTO. Keep historical readers unchanged and prove reopen/render compatibility during this cutover.
Measurable benefit: Creates reproducible, project-gated runs usable by humans and AI.
## Exclusions
@ -48,6 +50,7 @@ Parallel eligibility: only with disjoint actual files and reserved write locks;
- mutate_template_after_submit, freeze_before_first_decision, frozen_seed_replay, provider_change_after_dataset_bind.
- Full durable runner restart/lease/cancel suite and result contract compatibility.
- Canonical reporting fractions/zero/null reasons, owner attribution and fill-versus-round-trip semantics survive persistence/reopen/UI rendering; existing legacy rows retain their prior interpretation.
- Multi-asset default activation rejects while the mark-policy disposition is absent; accepted policy/version/limitations are frozen in provenance, with offsetting-mark regression evidence.
Apply the relevant [quality gates](../../QUALITY-GATES.md); submit exact commands, outcomes and skipped checks. Named cases above are required regression scenarios, not claims that those tests already exist.