feat(research): archive backtests and protect retained evidence

This commit is contained in:
Boki 2026-10-23 20:18:58 -04:00
parent 4a2e5ad362
commit 8cca0ee588
25 changed files with 1550 additions and 79 deletions

View file

@ -91,3 +91,5 @@ Local commands (not run against development data in this wave):
HTTP metadata: `/api/v2/strategies`, `/strategies/:id/versions`, `/strategy-versions/:id`; full bytes use `/:id/artifact`; clone/review/parameter validation use `/:id/clone`, `/:id/reviews`, `/:id/validate`. Publication/clone require `Idempotency-Key`. Catalog mutations require actual operator/service credentials, even when other development routes permit loopback bypass; only operator may review. API-supplied names/flags cannot self-register trusted code.
Validation: 93 tooling, 509 integration, 150 Rust (four manual ignored), 122 PostgreSQL/Redis and six browser workflows passed, plus source/contracts/build/lint/strict changed-test types. Final release native regressions passed 65 tests. Exact sequencing, hashes, commands and raw logs are canonical in `manifest.json` → `twentieth_wave_validation`. R10 and R02 follow; no current engine switch, candidate execution, trading activation or performance work.
Accepted and committed as `4a2e5ad` following the owner’s “commit and continue with backlog” instruction. R10 subsequently protects existing backtest history; R02 is the next product task.

View file

@ -11,7 +11,7 @@ Scheduling source of truth: [manifest entry R10](../manifest.json). No task is a
## Intended behavior and implementation scope
Archive existing templates/runs rather than cascading deletion when they retain run history; protect immutable strategy versions, datasets and artifact references established by R01. Add checksum verification on retrieval. R03 subsequently adds finding-reference constraints using the same retention rule. No automatic purge; explicit operator purge later needs a reference check and confirmation.
Archive existing templates and retain their entire run history rather than cascading deletion; protect immutable strategy versions, datasets and artifact references established by R01. Add checksum verification on retrieval. R03 subsequently adds finding-reference constraints using the same retention rule. No automatic purge; explicit operator purge later needs a reference check and confirmation.
Measurable benefit: Prevents accidental loss of reproducibility.
@ -39,7 +39,7 @@ Parallel eligibility: only with disjoint actual files and reserved write locks;
## Acceptance criteria
- Deleting a definition with retained runs cannot cascade-delete those runs/results.
- Unreferenced legacy deletion behavior is explicitly tested/documented; archived objects remain reproducible.
- Unreferenced legacy deletion behavior is explicitly tested/documented; archived history stays readable and existing replay limitations stay explicit.
- Missing/corrupt artifact produces an actionable integrity error; no fallback to current source.
## Mandatory tests
@ -67,3 +67,19 @@ Report scope changes (if any), fixture expectations, API/schema changes, measure
## Predecessor capability — R01
R01 already protects strategy versions/review events from update/delete and verifies retained artifact/lock checksums on retrieval. Reuse those paths. R10's remaining work is existing template/run/result/dataset retention and compatibility; do not create a second artifact store or repeat the catalog implementation. R01 currently has no run-to-version link; add references only with the task that introduces them.
## Wave21 execution contract
R01 accepted in `4a2e5ad`; owner authorized R10 continuation. Archive templates only, with a reversible `archivedAt` timestamp. Do not add an independent run-archive state. `POST /api/v2/backtests/:id/archive` takes strict `{ archived: boolean }`; default lists hide archived templates and `includeArchived=true` includes both. Detail/run/result URLs stay readable.
New submissions and template edits return 409 until restored. Existing accepted jobs may finish, recover or be cancelled; idempotent receipt replay occurs before archive admission checks. Template deletion with any retained run returns409 with the retained run count and archive guidance; runless/missing deletion keeps204 compatibility. SQL guards protect runs/results/datasets without blocking leases, progress, cancellation or initial dataset binding. Keep legacy NULL snapshot backfill working.
Reuse existing R01 artifact/lock and dataset retrieval checksum verification. No full catalog payload hashing, purge framework or invented historical provenance. Corruption tests insert historical malformed records initially instead of disabling protections or editing retained evidence.
## Validated handoff — 2026-10-23
Migration 17, archive/restore API, deletion conflicts and the web workflow are integrated and independently accepted. All accepted runs/results/datasets are retained; only runless templates can be hard-deleted. Worker claims, recovery, cancellation and completion continue on archived templates. Original keyed submission receipts remain replayable.
Database tests cover raw DELETE/UPDATE/TRUNCATE protections, admission races/direct repository entry, migration repeat/backfill, terminal writes and legacy NULL history. Missing and corrupt dataset fixtures run through the actual runner and fail without provider fallback or saved results. Existing strategy artifact checksums remain in R01. Browser tests cover confirmation, read-only settings, hidden/visible archived lists, saved trades/results, cancellation and restore/new admission.
Validation: full repository check passed (520 integration,150 Rust plus supporting gates), 131 PostgreSQL tests and 7 browser workflows. Evidence, reviewed 20-file hashes, environment limitations and commands: `manifest.json` → `twenty_first_wave_validation`. Validated but uncommitted; no default-engine/trading activation or performance work.