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

@ -1,8 +1,8 @@
# Revised development roadmap
Baseline `b7aeca4` · execution 2026-10-23 · **F08 committed; S01 validated, uncommitted**
Baseline `b7aeca4` · execution 2026-10-23 · **R01 committed; R10 validated, uncommitted**
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.
Authorization update: the owner requested “commit and continue with backlog”. R01 is committed as `4a2e5ad`; R10 is authorized under ADR-006. Performance work remains paused. New R10 implementation commits, pushes, PRs and trading/default-engine operations remain outside this continuation’s scope.
## Strategy and review outcome
@ -495,3 +495,16 @@ R01 deliberately exposes no version-based execution. R02 catalog/forms can proce
Independent G1/G2/security review accepted the final implementation. Validation: build/source/contracts, 93 tooling, 43 utility, 44 calculation, 509 integration and 150 Rust tests (four manual ignored), plus lint. Full disposable PostgreSQL/Redis suite: **122 tests / 903 assertions**. Release-addon focused strategy/API suite: **65 tests / 377 assertions**, plus the final contract edge case. Browser regressions: **6 workflows / 66 assertions**. Strict new-test/script types and scoped lint/format/diff checks passed. Initial allowlist/lint/declaration errors were corrected; the browser contract boundary now builds from current type source after a combined-suite generated-file read failure. Exact commands and evidence are recorded in `manifest.json` → `twentieth_wave_validation` and `/tmp/stock-bot-wave20.XIW6lx/`.
All catalog versions remain non-runnable until retained-artifact execution is integrated; approval does not enable execution. Original TypeScript source/full-run provenance are not claimed by the bundled-JS catalog. Current legacy workflows remain qualified and reject unsupported catalog version IDs. No financial Rust changes, default cutover, real catalog seeding, trading activation, profiling or benchmarks. The release addon matches the checkout library; both exact test fixtures were stopped. No R01 commit, push or PR. **Next after acceptance/commit: R10 evidence retention; R02 catalog screens are also eligible with disjoint ownership.**
## Twenty-first-wave handoff — 2026-10-23
R01 accepted and committed as `4a2e5ad`. R10 is independently reviewed and `validated_uncommitted`; isolated API/database and frontend worktrees are retained under `/tmp/stock-bot-wave21.u7PX8e/`. All 20 implementation/test files match reviewed hashes.
- **Retained evidence:** Migration 17 replaces definition/run/result deletion cascades with restrictions and protects runs, results and frozen datasets from destructive writes. Immutable run identity/receipt/snapshot/bound dataset fields are guarded; normal progress, lease recovery, cancellation, completion and initial binding remain writable. Legacy pending NULL snapshots still backfill once. Existing R01 artifact/checksum custody is reused.
- **Template archive/restore:** The API serializes archive, edit, delete and new-run admission on the parent row. Templates with any run return 409 on deletion, with count and archive guidance; runless/missing deletion retains 204 compatibility. Idempotent accepted receipt replay precedes archive checks. A database admission trigger also covers direct repository creation. Accepted work continues after archive; no separate run-archive lifecycle or purge framework.
- **Workbench:** Confirmation-backed archive/restore, archived list filter/badge, viewable read-only settings and disabled fresh submissions. Active cancellation, selected results/trades and ambiguous submission keys survive archive; delayed navigation/filter responses cannot overwrite current state. Archived saved URLs reopen normally.
- **Validation:** Full repository gates passed: 93 tooling, 43 utility, 44 calculation, 520 integration and 150 Rust tests (4 manual ignored), plus build/types/contracts/lint/secrets. Real PostgreSQL/Redis: 131 tests / 987 assertions. Chromium: 7 workflows / 79 assertions, including archive during admitted execution/cancellation and restored submission. Strict new/modern changed tests and scoped formatting/lint passed. Full commands/logs/hashes are in the canonical manifest.
The initial sandbox run could not support native worker IPC or fixture network access; full checks were rerun successfully outside it. Optional broad strict legacy harness checks retain pre-existing errors, recorded in the manifest. Release addon is restored and matches the prior wave hash; Rust code and financial semantics were unchanged. Disposable fixture containers were removed; development services were untouched. No performance work, new R10 commit, push, PR or trading/default activation.
Legacy economic/provenance limitations remain explicit; retaining evidence does not certify its economics or create missing version history. Next: R02 strategy catalog UI and version-aware setup. R05 still owns retained-artifact execution and canonical durable cutover.

View file

@ -56,7 +56,7 @@ Relative size: S narrow correction, M coherent boundary, L sensitive owner-contr
| [S02 Adapt one SMA strategy for the first canonical path](tasks/S02.md) | P1 / done | S01 | — | TypeScript strategy/quant engineering / M |
| [S03 Adapt durable paper transactions to Rust financial reducers](tasks/S03.md) | P0 / done | S01, C06, ADR-005 | — | Durable execution/Rust integration / L |
| [S04 Establish a verified paper feed and operator safety gate](tasks/S04.md) | P1 / done | S02, S03 | — | TypeScript trading infrastructure / M |
| [S05 Add a small composable multi-signal regime example](tasks/S05.md) | P2 / review | S02, F08 | R08 | Quant strategy research / M |
| [S05 Add a small composable multi-signal regime example](tasks/S05.md) | P2 / done | S02, F08 | R08 | Quant strategy research / M |
| [S06 Retire duplicate simulator paths after cutover proof](tasks/S06.md) | P2 / blocked | S03, S04, R05 | — | TypeScript trading infrastructure / M |
### E5 — Existing web backtest vertical slice
@ -72,8 +72,8 @@ Relative size: S narrow correction, M coherent boundary, L sensitive owner-contr
| Task | Priority / status | Implementation prerequisites | Release gate | Specialist / size |
| --- | --- | --- | --- | --- |
| [R01 Persist immutable strategy versions and parameter schemas](tasks/R01.md) | P1 / blocked | O01, ADR-006 | — | Full-stack research product / M |
| [R02 Deliver strategy catalog and version-aware backtest setup](tasks/R02.md) | P1 / blocked | R01, W03, ADR-006 | W04 | Full-stack research product / M |
| [R01 Persist immutable strategy versions and parameter schemas](tasks/R01.md) | P1 / done | O01, ADR-006 | — | Full-stack research product / M |
| [R02 Deliver strategy catalog and version-aware backtest setup](tasks/R02.md) | P1 / ready | R01, W03, ADR-006 | W04 | Full-stack research product / M |
| [R03 Add projects, hypotheses and evidence-linked findings APIs](tasks/R03.md) | P1 / blocked | R01, R10, ADR-006 | — | Full-stack research product / M |
| [R04 Deliver research workspace and save-findings flow](tasks/R04.md) | P1 / blocked | R03, W02, ADR-006 | W04 | Full-stack research product / M |
| [R05 Freeze complete provenance and cut over durable canonical runs](tasks/R05.md) | P0 / blocked | F08, S02, R01, R10, D01, W03, C06, ADR-006 | Multi-asset default mark-policy disposition | Full-stack research product / M |
@ -81,8 +81,8 @@ Relative size: S narrow correction, M coherent boundary, L sensitive owner-contr
| [R07 Deliver sweep configuration and comparable-result views](tasks/R07.md) | P1 / blocked | R06, ADR-006 | W04 | Full-stack research product / M |
| [R08 Add bounded chronological and reset-segment validation](tasks/R08.md) | P1 / blocked | R06, ADR-006 | — | Quantitative research integrity / M |
| [R09 Expose validation, cost and regime evidence in the workbench](tasks/R09.md) | P1 / blocked | R07, R08, ADR-006 | S05 when Regime comparison is enabled; R03 when Saving or linking a research finding is enabled | Full-stack research product / M |
| [R10 Protect retained research evidence and artifact integrity](tasks/R10.md) | P1 / blocked | R01, ADR-006 | — | Full-stack research product / M |
| [R11 Select and reuse frozen datasets in the workbench](tasks/R11.md) | P1 / blocked | D01, O01, ADR-003, ADR-006 | W04 | Full-stack market data/research / M |
| [R10 Protect retained research evidence and artifact integrity](tasks/R10.md) | P1 / review | R01, ADR-006 | — | Full-stack research product / M |
| [R11 Select and reuse frozen datasets in the workbench](tasks/R11.md) | P1 / done | D01, O01, ADR-003, ADR-006 | W04 | Full-stack market data/research / M |
| [R12 Reproduce an original run separately from rerunning current settings](tasks/R12.md) | P1 / blocked | R05, W04, ADR-006 | — | Full-stack reproducible research / S |
### E7 — Measured research throughput
@ -118,4 +118,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 seventeen waves are committed. **S05 is validated and uncommitted; performance work remains deferred by the owner.** R01/R11 still need ADR-006; the multi-asset mark-policy gate still blocks default activation. No default/paper activation, push or PR is included in this continuation.
The first twenty waves are committed, including R01 (`4a2e5ad`). **R10 retention is validated and uncommitted; performance work remains deferred by the owner.** ADR-006 is approved; R02 is ready after R01. The multi-asset mark-policy gate still blocks default activation. No default/paper activation, push or PR is included in this continuation.

View file

@ -1,16 +1,16 @@
{
"schema_version": 1,
"plan_revision": "2026-10-23.44",
"plan_revision": "2026-10-23.46",
"repository_base": "b7aeca4",
"plan_status": "twentieth_wave_review",
"plan_status": "twenty_first_wave_review",
"execution_authorized": true,
"execution_scope": {
"authorized_by": "User: comit all and continue after validated R11 handoff named R01 next (2026-10-23). R11 accepted and committed b106c1ca85e853c7fbcd65fc54c83b9f1024f2ed.",
"authorized_by": "User: commit and continue with backlog (2026-10-23). R01 accepted and committed 4a2e5ad362f7746a45a694dbcd9c51efac390526.",
"tasks": [
"R01"
"R10"
],
"permissions": [
"R01 isolated implementation, correctness tests, independent review and planning updates; prior R11 commit authorized and completed"
"R10 isolated implementation, correctness tests, independent review and planning updates; prior R01 commit authorized and completed"
],
"excluded": [
"performance_profiling_or_optimization",
@ -1390,7 +1390,7 @@
"epic": "E6",
"priority": "P1",
"severity": "High",
"status": "review",
"status": "done",
"dependencies": [
"O01"
],
@ -1413,11 +1413,11 @@
"assignment": "/root",
"branch": null,
"pull_request": null,
"completed_commit": null,
"completed_commit": "4a2e5ad362f7746a45a694dbcd9c51efac390526",
"blocker": null,
"release_gates": [],
"integration_base": "b106c1ca85e853c7fbcd65fc54c83b9f1024f2ed",
"integration_state": "validated_uncommitted",
"integration_state": "validated_committed",
"worktree": "/home/boki/repos/stock-bot",
"implementation_slices": [
{
@ -1442,7 +1442,7 @@
"epic": "E6",
"priority": "P1",
"severity": "High",
"status": "blocked",
"status": "ready",
"dependencies": [
"R01",
"W03"
@ -1732,7 +1732,7 @@
"epic": "E6",
"priority": "P1",
"severity": "High",
"status": "blocked",
"status": "review",
"dependencies": [
"R01"
],
@ -1750,13 +1750,32 @@
"sql-migrations",
"web-backtest-service"
],
"parallel_policy": "Allowed only with satisfied dependencies/approvals and disjoint write locks AND actual files; see agents/integration.md.",
"assignment": null,
"parallel_policy": "Backend migration/API and frontend in isolated worktrees with pinned archive contract; root owns fixtures/browser integration/planning; independent read-only review.",
"assignment": "/root",
"branch": null,
"pull_request": null,
"completed_commit": null,
"blocker": null,
"release_gates": []
"release_gates": [],
"integration_base": "4a2e5ad362f7746a45a694dbcd9c51efac390526",
"integration_state": "validated_uncommitted",
"worktree": "/home/boki/repos/stock-bot",
"implementation_slices": [
{
"owner": "/root/s04_controls_audit",
"scope": "Migration 17, migration allowlist, service/routes and new PostgreSQL retention scenarios",
"worktree": "/tmp/stock-bot-wave21.u7PX8e/backend"
},
{
"owner": "/root/s04_feed_audit",
"scope": "Archive/restore API client and backtest UI with focused tests",
"worktree": "/tmp/stock-bot-wave21.u7PX8e/frontend"
},
{
"owner": "/root",
"scope": "Existing fixture migration compatibility, browser retention workflow, integration and planning"
}
]
},
{
"id": "R11",
@ -6739,5 +6758,102 @@
"51c5b994f16c6c2bc7f095d6d9946457cb62a0ac2df5f1a3a8f2be0516f4be78"
],
"next": "After acceptance/commit, R10 retained research evidence is the next foundation; R02 catalog UI can proceed in parallel only with disjoint files. Performance remains deferred."
},
"twenty_first_wave": [
"R10"
],
"twenty_first_wave_base": "4a2e5ad362f7746a45a694dbcd9c51efac390526",
"twenty_first_wave_notes": [
"Archive templates only; all retained runs/results stay readable. Restore permits new submissions/edits; already admitted work may execute, recover or cancel while archived.",
"No run-level archival or purge infrastructure. R01 artifact verification reused; legacy engine/provenance limitations remain.",
"Performance work remains paused. No R10 commits, pushes, PRs or trading/default-engine activation."
],
"twenty_first_wave_validation": {
"status": "validated_uncommitted",
"log_directory": "/tmp/stock-bot-wave21.u7PX8e",
"source_hashes": {
"apps/stock/web-api/src/migrations/migration-runner.ts": "85a1cf163c3592df6a1b8a60e536759bbf62846dde62203dd2d13569c8d8ce87",
"apps/stock/web-api/src/routes/backtests-v2.routes.ts": "3f146457a3f70835be50b50063cb4228f896800139c5a36aba7c93c7c71bf669",
"apps/stock/web-api/src/services/backtest-v2.service.ts": "039265c4ffec0fa94af4b6a73d13078fa6d7e55902b3b7af428799c51a9feb37",
"apps/stock/web-app/src/features/backtest/BacktestDetailPageV2.tsx": "8aae36399a7476a88fd487054323f9a4d283e542b70f83cfa29dc7007417a3e1",
"apps/stock/web-app/src/features/backtest/BacktestListPageV2.tsx": "fbb8a912a55a8e02b119596421dcfdadffc341734fdeb1f8fc20cd6b02091500",
"apps/stock/web-app/src/features/backtest/components/ArchiveBacktestDialog.tsx": "90de8f9b6a71a0646e88d8cd2d4c6d74799c5ab77910af344ff72d6fe321f399",
"apps/stock/web-app/src/features/backtest/components/RunControlsCompact.tsx": "caaa048e8cdd9855d5f59c7147b98d6af40ea6f9723d09e6dd6f7ca97f0428db",
"apps/stock/web-app/src/features/backtest/hooks/useBacktestV2.ts": "0d8f15496f1e51be16037df3b54f0ba1325c892c2707ed0f4055d8bbd73440ae",
"apps/stock/web-app/src/features/backtest/services/backtestApiV2.ts": "0399eeca8ed54ca927508082e3a5203c34baa9a9af45e14bdf87ede337111c5d",
"database/postgres/init/17-research-retention.sql": "f1a932eaf7fa80ed1a4f3868da4d5b5dfcd6d6b0f9de17179310a644cadae63f",
"test/e2e/fixture.ts": "922fd7725c4791ec250c06421ed0418a59e03cd72bedfae6f914e140843b0d80",
"test/e2e/workbench.test.ts": "bad834a33285b8589d5a1fd85ca68efff650e3e159d6fa5b8f57532a6f7a21c4",
"test/integration/backtest-run-controls.test.tsx": "57a6d766a2029173edce22b3d3989c42b54de44925c119e3513af810061c3158",
"test/integration/backtest-workflow.test.ts": "3775b2f34b81040e6f52be4f221714ae9ad0d74670db5728e371833be8895a77",
"test/integration/research-retention-routes.test.ts": "ad6b51c45519289e6c69758fdb1faec4857ad10d15e69f926fab08d93bb587ec",
"test/postgres/dataset-catalog.test.ts": "77e55f497c0c4cb6d952d2ab06b1716f78d700c6899edc62a2284b08b63dec7b",
"test/postgres/durable-backtest.test.ts": "96c028f76c13ac2861e325e8bb4a6fda1aace11e1cf0ce2dada4278f71169c59",
"test/postgres/migration-runner.test.ts": "39c1fb489fb9ef643e043e59a85a5e962183f7e52833feb0242f1f0db6e93a4e",
"test/postgres/research-retention.test.ts": "4bd0edbe962c188886116ab9e86d196c580b5d9405bb78fa69e0e03ae236189a",
"test/postgres/research-runtime-isolation.test.ts": "cfd5628da35fe1d84e1a4ed4bb9097f86296819884a8a94ed4f800418e830d0e"
},
"independent_review": {
"owner": "/root/s03_review",
"outcome": "No remaining must-fix findings. G1 unchanged financial semantics; G2 SQL retention/admission/recovery and migration compatibility accepted; G3 API/UI/auth accepted. Reviewer inspected source and PostgreSQL log, ran no tests. Integrator subsequently completed all full-check/browser gates with unchanged reviewed hashes.",
"backend_archive_sha256": "b71f4155502fd3db4fea130253af3d22543389a9ef1c2de9983228478f80f8be",
"frontend_archive_sha256": "914f405bfd6e616beaa06ed05e6abbdcac5a48a54bb5fff341ba5bf15b78d41e"
},
"checks": [
{
"command": "CARGO_BUILD_JOBS=2 bun run check",
"log": "/tmp/stock-bot-wave21.u7PX8e/check-final.log",
"outcome": "All repository checks passed: build, source/contracts, 93 tooling/12142 assertions, 43 utility/86, 44 calculation/2285, 520 integration/4554, 150 Rust (4 manual ignored), lint and secret audit."
},
{
"command": "PIPELINE_TEST_DATABASE_URL=postgres://fixture:fixture@127.0.0.1:32825/stock_bot_safety BACKTEST_TEST_REDIS_URL=redis://127.0.0.1:32826/15 bun run test:postgres",
"log": "/tmp/stock-bot-wave21.u7PX8e/postgres-final.log",
"outcome": "131 tests / 987 assertions passed on disposable fixtures. Includes immutable evidence, archive/admission race, accepted-run recovery/cancel/complete, missing/corrupt dataset failure without provider fallback, migration reapplication, existing paper custody/recovery and isolation."
},
{
"command": "CARGO_BUILD_JOBS=2 bun run --cwd apps/stock/engine build:release",
"log": "/tmp/stock-bot-wave21.u7PX8e/native-release-final.log",
"outcome": "Release addon restored; hash equals checkout release library and prior wave release artifact. No Rust source or economic policy changed."
},
{
"command": "PIPELINE_TEST_DATABASE_URL=postgres://fixture:fixture@127.0.0.1:32825/stock_bot_safety BACKTEST_TEST_REDIS_URL=redis://127.0.0.1:32826/15 bun run test:e2e",
"log": "/tmp/stock-bot-wave21.u7PX8e/e2e.log",
"outcome": "7 workflows / 79 assertions passed against final built UI/API and release addon. Archive/restore, accepted archived execution/cancellation, readonly settings, history/results/trades reopen, native smoke and existing dataset/submission workflows."
},
{
"command": "bunx tsc --project /tmp/stock-bot-wave21.u7PX8e/tests-tsconfig.json --noEmit",
"log": "/tmp/stock-bot-wave21.u7PX8e/strict-tests.log",
"outcome": "Passed strict new retention route/PostgreSQL tests plus modified migration/dataset/browser fixtures. Existing broad legacy harness strict errors recorded separately, not suppressed."
},
{
"command": "bunx eslint --no-ignore <new retention and modified migration/dataset/browser tests> --max-warnings 0; bunx prettier --check <all changed TS/TSX>; git diff --check",
"logs": [
"/tmp/stock-bot-wave21.u7PX8e/scoped-lint.log",
"/tmp/stock-bot-wave21.u7PX8e/scoped-format.log"
],
"outcome": "Passed. Existing legacy control-test curly findings not rewritten; new additions and application lint pass."
}
],
"native_debug_sha256": "75e33ffdd1e2738537879e62243a9d8f63665864835a58c46087bb4b78f274ff",
"native_release_sha256": "ef00eed556f5c32332d36a9a00ef710682e90deb00b54552e4b5c8bfdfbe8103",
"scope": "20 source/migration/test files; archive templates only, keep all run/result/dataset evidence. One additive migration, existing API/hooks/UI. No new services, financial changes, purge or run archive states.",
"limitations": [
"Archived history retains existing legacy-engine and incomplete-provenance qualifications; R05 still owns canonical durable cutover and full provenance.",
"Catalog versions remain non-runnable until R05/A02. Existing R01 artifact/lock checksum paths are reused, not replaced.",
"Archival does not cancel already accepted work. Restore is required for new submissions and template edits. No default automatic or operator purge workflow.",
"Browser submission receipt keys remain component-lifetime state; archive preserves them but does not add reload/navigation recovery."
],
"environment_notes": [
"Initial sandbox PostgreSQL connections failed; rerun outside sandbox passed against the same disposable fixture.",
"Initial sandbox full-check native workers timed out on IPC; interrupted that run and reran the full check outside sandbox successfully. Native release build likewise required subprocess access.",
"Optional broad strict check of existing legacy fixtures found pre-existing test-only config/undefined/type errors in backtest-workflow, durable-backtest and runtime-isolation harnesses. No new strict errors found; strict new/modern changed tests pass. See fixture-types.log.",
"All 20 final source hashes unchanged since independent review. Exact disposable containers stopped; development services untouched; worktrees/logs retained.",
"No performance profiling/benchmarks, trading/default activation, push, PR or new R10 commit."
],
"stopped_fixture_ids": [
"8b23c51e87d1363cc75571e2be24da7dc09322bf4251acbf11bae8ded982f063",
"f90476a79b0df259a204bbc2f2015b2b6a8e582a8771729f48775cb18b4bac65"
],
"next": "After acceptance/commit, R02 delivers the strategy catalog UI and version-aware backtest setup without claiming retained-artifact execution before R05. Performance remains deferred."
}
}

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.