feat(research): reproduce retained canonical runs with economic comparison

This commit is contained in:
Boki 2026-10-24 10:02:21 -04:00
parent e3bd708838
commit 30accfcf43
31 changed files with 2969 additions and 28 deletions

View file

@ -31,7 +31,7 @@ Write locks: web-backtest-service, web-backtest-detail. One agent owns this chan
## Dependencies and blockers
Implementation requires [R05](R05.md), [W04](W04.md) integrated.
Implementation requires the accepted retained-input/single-asset durable execution component of [R05](R05.md) (`618fb9e`), plus [W04](W04.md) and the integrated R01/R10/F08/S02/D01/W03/C06 prerequisites. Provider-to-v2 preparation and broader R05 cutover are independent; R05 remains incomplete. This component dependency was verified and recorded by the planning owner on 2026-10-24 under the owner's continuation authorization.
Architecture decisions: ADR-006. Agents may not independently amend their policies.
@ -65,3 +65,21 @@ 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.
## Pinned execution scope — 2026-10-24
Reproduce completed retained canonical single-asset built-in runs on the exact installed worker/native/runtime build. Add immutable `original_run_id` lineage; use the existing durable runner, submission receipts and outbox. Missing/corrupt inputs or unsupported historical builds fail explicitly. No historical executable provisioning, source inference or default activation.
A fresh reproduction requires active parent/original strategy family and current approval of the **original** version, even if the template now selects another version. Copy the original request, changing only fresh run/session/account identities and the current approval receipt. Preserve all economic inputs. Receipt retries precede current eligibility checks; ordinary and reproduction intents use distinct hashes under the same principal/key uniqueness. SQL must enforce the source-copy relationship and retained identity alongside ordinary admission.
Expose read-only preview, POST reproduction and read-only result comparison. Compare versioned canonical hashes of the complete validated frozen request, financial envelope and analytics, normalizing only run/account identity and admission-review fields. Keep real market-session IDs, ownership, ordered fills, monetary strings, nulls and limitations. Do not recalculate finances or rewrite retained results. The UI separates original reproduction from current-settings submission, preserves retry keys after ambiguous responses and shows lineage/comparison after reload.
Root owns shared DTO/comparison and integration; backend/frontend worktrees have disjoint actual files. Current assignment, authority and validation live in the manifest.
## Implemented handoff — 2026-10-24
The pinned scope is implemented and independently reviewed; scheduling remains `review` / `validated_uncommitted` in the manifest. Shared preview/comparison DTOs live in `apps/stock/config/src/contracts/canonical-research.ts`; `run-reproduction.ts` checks retained admission eligibility and `reproduction-comparison.ts` hashes validated economic inputs/outputs. Migration 21 protects source-copy lineage and financial identity. GET `/api/v2/runs/:id/reproduction`, POST `/api/v2/runs/:id/reproduce` and GET `/api/v2/runs/:id/reproduction-comparison` are authenticated. POST accepts only an empty object plus an idempotency key; it returns 202 and Location for the new or previously accepted run.
`RunReproduction.tsx` consumes the same APIs, shows exact retained inputs, preserves keys after ambiguous submissions and displays source lineage and comparison. Current-settings submission is separate. The expanded Chromium research flow mutates the template, reproduces the original native result, retries the same receipt, reopens lineage, then proves a new ordinary run uses changed settings. PostgreSQL tests cover current original-version approval, direct SQL guards, retention, upgrade, corruption, concurrent receipts and economic parity/mismatch. Full gate outcomes and source hashes are recorded in the twenty-sixth-wave roadmap/manifest handoff.
No old binary provisioning or inference of missing provenance was added. R05 remains partial and R06/S06 gates remain intact.