stock-bot/docs/development/real-data-research.md

263 lines
44 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Real-data research workflow
Authorized follow-up to cleanup on October 26, 2026. Baseline `bd9332b2`. The manifest owns scheduling. RP01 adds read-only source inspection; RP02 exercises existing research paths with actual stored data. Performance, conditional CL21 and paper/live activation remain deferred.
## Independent cleanup reviews
- CL01/CL04: foundation reviewer accepted; CL02/CL03 required owned-cache corrections before acceptance. Real adapter probes reproduced transport leakage, cross-container endpoint reuse and ignored options. The correction owns DI/queue cache transports, preserves shared callers and namespaces, wires supported retries/TTL and diagnoses obsolete controls. Foundation reviewer accepted the fix; root scoped tests passed 38/190 assertions and application types. Expanded implementer gates passed 75/280. Three historical queue-utils expectations independently fail on the old baseline; no claim those passed.
- CL05/CL08/CL12: backend reviewer accepted; 154 domain/admission cases, 15 retained-worker cases, and 55 disposable PostgreSQL cases passed. Dataset/report moves preserve algorithms and transaction/receipt boundaries.
- CL06/CL07/CL09/CL10/CL11/CL13: frontend reviewer accepted; 390 UI/transport and 41 dataset/architecture cases passed. A pre-existing body-read abort diagnostic limitation remains nonblocking because cancelled generations are fenced.
Reviewers: `/root/review_cleanup_foundations`, `/root/review_cleanup_backend`, `/root/review_cleanup_frontend`. Exact logs under `/tmp/stock-bot-*-review*.log` and `/tmp/stock-bot-research-next-20261026/`. Combined integration evidence follows.
## Rechecked source
Read-only Mongo query reproduced the previous AAPL October 2024 snapshot exactly: 1,816 five-minute rows, 22 null volumes at 20:00 UTC, no duplicate timestamps; raw query JSON hash `a8772d01d388b8fc9bca0d2790ad0d37146570fd09d057fcf1f1fcb5e6113bde`. PostgreSQL initially contained zero retained datasets/strategy versions and no experiments; existing runs are not evidence of this pilot. The development API responds on port 2003.
## RP01 — Accepted scoped source inspection
The stored-EOD preparation panel now accepts an instrument and timeframe, explicitly loads that series' coverage, and diagnoses a selected half-open UTC window. It reports field errors, null volume and duplicate timestamps without changing rows or granting dataset eligibility. Editing these controls does not dirty or submit the enclosing backtest setup; cancellation and changed drafts fence late replies. An already dispatched Mongo query is not interrupted by the current database wrapper.
The first proposal grouped every archived row. Actual Mongo estimates were 3,402,612,960 one-minute, 1,075,367,880 five-minute and 110,450,096 hourly records, so that proposal was rejected during integration. The final query requires one instrument/timeframe and starts with an exact match. Actual Mongo explain selected `eodSearchCode_1_timestamp_1`; no index migration, cache or input cap was introduced. Coverage does not establish complete calendar sessions. Window queries cannot diagnose timestamps that cannot be located in that query; coverage counts invalid timestamps separately.
Independent backend and frontend reviewers accepted the final implementation. Corrections included BSON Decimal128 timestamp consistency, strict zero-warning lint, and preventing inspector Enter/change events from submitting or dirtying the parent setup.
Validation on the combined checkout:
- `CARGO_BUILD_JOBS=2 bun run check`: passed — 134 tooling, 43 utility, 44 calculation, 1,251 integration and 150 Rust tests; 14 conditional integration skips and 4 ignored Rust measurement tests remain.
- Disposable PostgreSQL/Redis suite: 274 passed, 2,630 assertions. The first invocation crashed inside Bun 1.2.17 after 83 seconds; the complete retry passed. This is not reported as a successful initial invocation.
- Chromium: all 18 existing scenarios passed in the full run. The new scenario initially used a draft-only navigation button on an already-configured template; after correcting that test navigation, its focused rerun passed with 20 assertions. Together these cover all 19 scenarios; no application change followed the full suite.
- Real Mongo BSON aggregation: passed, including Decimal128 rejection, supported numeric representations and missing selection. Selected AAPL coverage and inspection succeeded; the session has 78 rows with zero invalid or duplicate rows. Source history was read only.
- Implementer focused regressions: 106 tests / 521 assertions. Independent frontend: 91 / 319; backend: 6 / 46. Production frontend build, authored-test types, strict lint and diff checks passed.
Logs: `/tmp/stock-bot-research-next-20261026/combined-check-scoped.log`, `combined-postgres-retry.log`, `combined-browser.log`, `source-browser-focused.log`, `source-mongo-explain.log`. Tests used disposable stores; the development research records below were not test fixtures.
## RP02 — Completed after explicit strategy approval
The following inputs were created and reopened through existing research APIs. The owner then explicitly approved the exact SMA artifact for this bounded pilot; nine runs completed:
| Record | Identity |
| --- | --- |
| Frozen dataset | `6b72d7fc3ebf87a52aefb5683d1bdaea344546daea1a988533c66871e56ed687` |
| Raw selected-query file SHA256 | `343a025b15ffe695479f940ca7eaa6511dd4270deaeaf9bc49b4e28961c1b15c` |
| SMA strategy version | `a67fb31d-7d13-4337-91fb-b49745983160` — explicitly approved for the research pilot |
| Strategy artifact SHA256 | `008a42dc373168ba17d5e73a1cc769de6b0bc24b7e487f07a422ceaa3618aa71` |
| Clean strategy source commit | `b4ac6460efd40734f55d12bc94f1969583fd8587` |
| Draft backtest | `373e1046-64fc-409e-b414-da46fb20bea3` |
| Research project | `59027da7-4e84-4c71-ac3e-10cab219f0c4` |
| Hypothesis | `a0fb1cb7-6202-470e-aa9d-8f2f22918c6a` |
| Preparation note | `9c077001-3309-4a29-ae95-0891ec8488c5` — AI-origin, unvalidated, no performance evidence |
Local durable input package: `.data/research-pilots/aapl-20241001/`. It contains raw query bytes, complete metadata, source evidence, retained package/lock, API receipts, reopened dataset/draft, preparation scripts and `execution-plan.json`. PostgreSQL retains the canonical dataset and immutable strategy artifact. Local raw files are ignored runtime data, not Git documentation.
The declared session is October 1, 2024, 13:30–20:00 UTC. All 78 consecutive five-minute bars remain unchanged. The explicitly half-open query excludes after-hours rows; no filtering within the query, interpolation or null-volume coercion occurred. Evaluation begins at 14:30 after sufficient SMA warmup.
Evidence and limits:
- [Nasdaq's 2024 calendar](https://www.nasdaqtrader.com/content/technicalsupport/2024tradingcalendar.pdf) and [regular hours](https://www.nasdaq.com/market-activity/stock-market-holiday-schedule?display=b2b) support the declared ordinary session. The normalizer validates the declaration; it does not certify exchange evidence.
- [EOD intraday documentation](https://eodhd.com/financial-apis/intraday-historical-data-api) defines UTC Unix-second bar starts. Availability at interval end is an explicit zero-delay assumption; actual historical arrival times are unavailable.
- Action-free coverage for this one session is an inference from [Apple's dividend/split history](https://investor.apple.com/dividend-history/), not a certified complete action feed.
- [Apple's August 2024 release](https://www.apple.com/newsroom/2024/08/apple-reports-third-quarter-results/) establishes common shares before the session. The fixed AAPL universe uses that historical membership, but the asset/window were selected retrospectively for a workflow proof. This is not a point-in-time universe-selection study; the stored vendor vintage was captured in 2026.
The predeclared plan has at most nine runs: baseline SMA 3/8, its exact reproduction, two training candidates (fast 2/4, slow 8), two held-out phases for the server-selected training winner, and three cost scenarios including the automatic baseline. Capital is $10,000 with a $1,000 strategy budget and explicit native limits. Fees, spread and slippage are scenario assumptions. Training evaluates 14:30–16:00, validation 16:00–18:00 and test 18:00–20:00; each phase resets capital and has one hour of prior warmup. These tiny partial-session partitions cannot establish alpha, regime robustness or statistically meaningful out-of-sample performance. Do not interpret annualized CAGR or unavailable daily-period statistics as such evidence.
The original capability check correctly rejected execution pending human approval. The owner subsequently answered “Approve this research pilot” for the exact version/artifact above. That approval was recorded through the existing review endpoint before any submission; `owner-approval.json` and `approved-version.json` retain the scope and response. No paper/live deployment was activated.
All nine runs used the existing durable `BacktestRunner` / `RustBacktestAdapter`, invoked only for their newly admitted IDs; no generic queue was drained. The runner claimed attempts and stored canonical native results through the existing repository. All six submission operations were replayed with their original bodies, principals and idempotency keys; the pilot still has exactly nine completed runs. Results, the sealed chronological report and the cost experiment were reopened through normal APIs.
| Completed evidence | Identity / result |
| --- | --- |
| Baseline run | `3f87ca4c-b61c-4eba-996a-94fdb525369d`; 8 fills, terminal cash/equity `9994.54250007`, fees `7.20654989` |
| Reproduction run | `41ace77c-4c13-44e6-915f-593e3d914147`; exact match |
| Economic hash, both runs and cost baseline | `f1d0111dad1d33d6d53225b598ede56ecb9c31c9264436fbcf065d72f2982daa` |
| Chronological validation | `0e4a8a73-e25f-4256-82a1-905cc5d57bab`; training selected SMA 2/8, both holdouts preserved that choice |
| Sealed report | `96dff56c-1840-4925-b2b2-9edd738c694c`; hash `20ab18f465c46bbf141dee53f35c2db1652f67e8c831be2c5c11a49df770136c` |
| Cost experiment | `2a8d767f-0770-47b1-8377-2dd18d038a08`; three comparable completed trials |
| Finding | `9942626c-0684-40d3-a15b-45fb1d00579b`; 19 retained scalar references, AI-authored, unvalidated research conclusion |
| Native engine binary SHA256 | `df0ecbd5c3772d7e8aeb0226b40ae290cfaddf9d87fb3a7375f2a31c2acf05e5` |
Baseline total return was approximately -0.054575%. The fixed SMA 3/8 cost scenarios ended at `10002.46970496` with zero fees/slippage but spread retained, and `9984.45333211` with stressed fees/slippage. These are observed scenario results, not calibrated execution estimates or a general monotonicity claim. Annualized CAGR was deliberately excluded from the finding; there are zero complete daily reporting periods.
Independent reviewer `/root/review_cleanup_backend` accepted 2,374 file-only assertions across the nine results and finding: fixed-eight cash/fee/quantity/P&L/owner reconciliation, no negative cash or position quantity in the observed fills, exact artifact/lock and sliced-dataset identities, reproduction hashes, sealed report/selection hashes, training-only winner, unchanged non-cost policy and all 19 evidence references. This audit does not claim to cover every possible risk path or independently prove unrelated database state was untouched. Full failure-oriented repository/PostgreSQL tests provide the broader regression gate.
Actual development Chromium signed in and reopened the [saved baseline and trades](http://localhost:5173/backtests/373e1046-64fc-409e-b414-da46fb20bea3/run/3f87ca4c-b61c-4eba-996a-94fdb525369d) and the [project finding](http://localhost:5173/research/59027da7-4e84-4c71-ac3e-10cab219f0c4). That browser context blocked every non-read API operation except authentication. Local `browser-reopened.json`, `execution-summary.json`, `execution-status.json`, `independent-audit.json` and `independent-review.mts` retain the completion evidence. The original execution plan and pending capability snapshots remain historical records; they were not rewritten to conceal the approval sequence.
## RP03 / RP04 — Session preparation and result interpretation
Owner continuation on October 27 authorized these two follow-ups; planning commit `76eb1b12` records their scope. RP03 (`d2b78eac`) adds an explicit declared-session choice to the existing stored-EOD preparation panel and API. RP04 (`302ba60e`) shows retained UTC evaluation bounds and exact elapsed calendar duration beside canonical metrics, explains CAGR's 365-calendar-day extrapolation, and distinguishes periodic-statistics annualization. No financial calculations, dataset hash format, risk policy or native execution semantics changed.
Session selection intersects the chosen series' declared calendar with its bounds, reads each window sequentially through the existing strict reader, snapshots returned values before another read and assigns global deterministic ordinals. The default continuous query and response remain compatible. Missing sessions, invalid selected rows and partial bars fail; no rows are coerced or post-filtered. The web client checks the echoed selection, fences stale responses and retains/retries the captured input and hash without source rereads. [Usage and limitations](../backtest-datasets.md#stored-eod-preparation-across-declared-sessions-v2).
Independent backend and frontend reviews accepted RP03. The backend's 44 focused tests / 361 assertions plus eight adversarial probes covered selected-calendar identity, invalid/empty windows, cancellation and mutation isolation. Independent frontend review passed 96 tests / 361 assertions covering selection echo, stale replies and retention locking. RP04's independent review passed 21 UI tests / 157 assertions; the duration formatter uses retained reporting facts and preserves all stored metrics/null reasons and the fills-only view. Root-authored PostgreSQL/browser tests were also independently reviewed.
Actual read-only AAPL five-minute source validation used explicitly declared October 1 and 2 windows, each 13:30–20:00 UTC:
| Evidence | Result |
| --- | --- |
| Continuous source query | 157 rows; preparation rejects the interior October 1 20:00 null-volume marker |
| Declared-session preview | Exactly two strict-reader queries; 156 unchanged bars, 78 per session |
| Repeated preview | Exact input rows, global ordinals and v2 hash reproduced |
| Raw selected capture SHA256 | `7e2925c8c97bcbb01406efdb5a5a8557c2135c0a1f28aa557c7ccf0e6f8dd067` |
| Prepared dataset hash | `3b2411cecc4014e7090f04d4220732968aec1a58041fce82b7149765d9ba00a3` |
| Independent actual-source validation | 2,366 assertions passed; no retention, database writes or research runs |
Ignored local evidence and the reproducible validator are under `.data/research-pilots/aapl-20241001-02-preparation/`. The calendar/action metadata explicitly declares engineering validation scope; eligibility means contract validity, not certified market coverage. Sequential reads are not an atomic database snapshot. Captured values define the eventual dataset; cancellation fences later reads/results but does not interrupt an already dispatched Mongo query. This two-session check is not evidence of strategy performance, market-data vintage or general completeness.
Combined checkout gates:
- `CARGO_BUILD_JOBS=2 bun run check`: passed — 134 tooling, 43 utility, 44 calculation, 1,266 integration and 150 Rust tests; 14 conditional integration skips and 4 ignored Rust measurement tests remain. Build, application/contract types, lint and secret audit passed.
- Relevant disposable PostgreSQL suites (`stored-dataset-preparation`, `dataset-source-preparation`, `canonical-research`): 14 passed / 169 assertions. Preview writes nothing; retention after source changes and retries save one exact dataset, with unrelated tables unchanged.
- Full Chromium workbench: 20 passed / 685 assertions. New coverage checks both displayed UTC windows, exact source queries, captured-input retention after source removal, unchanged template/no runs or dispatch, and the actual-native result horizon/CAGR explanation.
- Authored application/test types, focused zero-warning lint, production frontend build, formatting and diff checks passed. No development data was used as a mutable test fixture.
The initial sandbox checks could not reach fixture ports/launch Chromium or complete native workers. Authorized reruns passed. One browser attempt also overlapped the general frontend build and picked up the wrong API target; it was stopped, then the complete browser suite passed after serializing builds. Those interrupted attempts are not counted as successful validation. Logs: `/tmp/stock-bot-rp03-root-check-escalated.log`, `stock-bot-rp03-postgres.log`, `stock-bot-rp03-browser-final.log`, `stock-bot-rp03-root-test-types.log` and independent `stock-bot-rp03-*-review*.log` / `stock-bot-rp04-independent-review.log`.
Both stories are accepted. All 69 scheduled tasks are complete; seven conditional tasks and four merged redirects remain in the 80-ID manifest. Performance work, CL21 and paper/live activation remain deferred.
## RP05 / RP06 — Retained dataset reuse and settings custody
Owner continuation authorized two independently verified workflow corrections, recorded in planning commit `5319bd1b`. RP05 (`6d549542`) fixes the canonical picker's first-page-only limitation; RP06 (`c838e3d0`) fixes loss of settings and preparation on same-backtest tab changes. The backend, database schema and Rust financial behavior are unchanged. [Workbench usage](../backtest-datasets.md#reusing-a-retained-dataset-in-the-web-workbench).
RP05 uses existing paginated catalog and exact-hash endpoints. Load-more preserves prior choices and retries a failed page at the same offset; refresh and retention fence stale requests. The deliberate hash action verifies identity/availability before saving. Catalog/detail parsing now rejects malformed successful responses while preserving valid unavailable entries and converted v2 manifests with parent hashes. Browsing and typing a lookup do not save a template or submit a run.
RP06 first reproduced the baseline defect: an edited name reverted after Settings → Runs → Settings. Settings now mount only after the first visit and stay hidden across tabs and index/run routes for that backtest. Captured source input and ambiguous-retention retry remain owned by the editor; changing backtest ID disposes it and fences old completions. Explicit discard and saved-definition replacement retain their behavior. Hidden controls are excluded from accessible role queries. This is in-memory same-backtest preservation, not persistent draft recovery or a general navigation guard.
Independent reviewer `/root/review_cleanup_backend` accepted both changes: RP05 29 workbench tests / 245 assertions plus eight independent transport probes; RP06 45 lifecycle tests / 279 assertions. Implementer focused suites passed 119 / 570 and 198 / 967 respectively. Reviewer `/root/review_cleanup_frontend` independently checked root's browser fixtures and usage documentation. That review caught a fixture timestamp UPDATE forbidden by the evidence-immutability trigger; the fixture now sets ordering on initial INSERT and verifies custody through the normal retention helper, without altering the trigger.
Combined validation:
- `CARGO_BUILD_JOBS=2 bun run check`: passed — 134 tooling, 43 utility, 44 calculation, 1,279 integration and 150 Rust tests; existing 14 conditional integration skips / 4 ignored Rust measurements remain. Build, types, contract checks, strict lint and secret audit passed.
- Chromium full workbench run: 20 scenarios passed. The new dataset-reuse scenario correctly remained unable to save because its test omitted the existing explicit strategy-parameter validation step. After adding that step to the test, its focused rerun passed with 13 assertions. Together these cover all 21 scenarios; no application change followed the full browser run. The initial full invocation is not reported as an all-pass run.
- The new browser scenario inserts 52 distinct valid older snapshots in its disposable schema, selects a hash absent from the first page, loads the older page, saves the verified dataset and reopens it. It asserts zero runs and dispatch records.
- The retention browser scenario commits through the actual HTTP/database route, deliberately loses the response, changes tabs and retries the identical input/hash after removing the fixture source rows. Exactly two original session reads remain; the saved template and run/dispatch counts do not change. The actual-native smoke preserves an unsaved name across index-to-run navigation while the persisted definition remains unchanged.
- Application and authored-test types, focused lint, formatting/diff checks and production frontend build passed. The browser used isolated PostgreSQL/Redis fixtures, removed after validation. No development dataset, research execution or paper/live state was changed.
Logs: `/tmp/stock-bot-rp05-root-check.log`, `/tmp/stock-bot-rp05-browser.log`, `/tmp/stock-bot-rp05-browser-focused.log`, `/tmp/stock-bot-rp05-root-test-types.log`, and `/tmp/stock-bot-rp06-baseline-regression.log`. Current manifest: 71 accepted scheduled tasks, seven deferred conditional tasks and four merged redirects, 82 IDs total. No conditional performance or monitoring work was activated.
## RP07 — Retained dataset export for local research
Owner continuation on October 27 authorized this follow-up; planning commit `43ea2cc9` records the frozen API/UI contract. Existing catalog endpoints returned descriptors without bars, forcing local exploration to reach into the database. The new `GET /api/v2/datasets/canonical/:hash/export` reuses `readCanonicalDataset` once to return the validated full v2 `{manifest,bars}` snapshot. It preserves canonical identity, converted parent hashes, timestamps, availability delays, source ordinals and null VWAP. JSON formatting and downloaded-file byte hashes are not dataset identity guarantees.
Implementation commit `b959779a` is accepted. The manifest now contains 72 completed scheduled tasks, seven deferred conditional tasks and four merged redirects: 83 IDs total.
The loader's typed rejection extends its existing request-error base, preserving admission/catalog catches and messages. Invalid, missing, corrupt/mismatched and unsupported datasets return 400, 404, 409 and 422 respectively; unexpected errors are sanitized. Route-handled responses are no-store/nosniff, and only validated success receives an attachment filename. Cancellation fences delivery. Existing authentication is unchanged; tests use the real research-credential resolver to prove dataset routes remain unavailable to research-agent tokens.
A shared download action appears for a verified setup selection and full canonical results. Result downloads use the original immutable request hash, independently of the editable template. The browser checks the response envelope/identity, preserves the received text, supports retry, prevents duplicate clicks and fences pending bodies on hash change/unmount. Full content/hash validation stays on the server; there is no browser financial engine or new export format. [Usage](../backtest-datasets.md#downloading-a-retained-snapshot-for-local-exploration) covers VS Code/notebook inspection and the existing CLI importer.
Independent backend review accepted both implementation halves: 66 focused tests / 591 assertions and 25 additional transport/authentication probes passed. The reviewer also accepted root's PostgreSQL/browser fixtures; independent frontend review accepted the usage documentation. Implementer checks passed application/authored-test types, strict lint and production builds.
Root validation:
- `CARGO_BUILD_JOBS=2 bun run check`: passed — 134 tooling, 43 utility, 44 calculation, 1,316 integration and 150 Rust tests. Existing 14 conditional integration skips and 4 ignored Rust measurements remain. Build, types, contract checks, strict lint and secret audit passed.
- Disposable PostgreSQL: 14 tests / 183 assertions across dataset-source preparation, stored-source preparation and canonical research. The actual export performs one payload read; its received JSON validates, is imported through the real CLI twice, and leaves every fixture table unchanged. Unsupported/corrupt retained rows return no attachment.
- Root-authored browser/PostgreSQL test typecheck and formatting/diff checks passed.
- Chromium: all 21 workbench scenarios passed with 721 assertions. Actual downloaded files from a verified selection and a reopened native result validate in full. The latter's template is deliberately changed to a distinct retained dataset first; export still delivers the original run dataset and leaves the replacement settings, one run and one dispatch unchanged. The fills-only view exposes no download action.
Logs: `/tmp/stock-bot-rp07-root-check.log`, `/tmp/stock-bot-rp07-postgres.log`, `/tmp/stock-bot-rp07-browser.log`, `/tmp/stock-bot-rp07-root-test-types.log`, `/tmp/stock-bot-rp07-api-independent.log` and `/tmp/stock-bot-rp07-ui-independent.log`. Tests use disposable PostgreSQL/Redis fixtures; no development research runs or paper/live operations were performed. Export retains the existing eligible single-asset/single-series gate. Performance, monitoring and conditional replay extraction remain deferred.
## RP08 — Original run result download
Implementation `e8a6b709` and fixture correction `8e9d0cf6` are accepted. The manifest now contains 73 completed scheduled tasks, seven deferred conditional tasks and four merged redirects: 84 IDs total.
Owner continuation authorized a small companion to the dataset download; planning commit `dd1545b9` records the scope. The full canonical result view now offers **Download run result**, saving its already loaded `CanonicalRunResult` as `run-<runId>.json`. It serializes the entire original object, preserving decimal strings, null metric reasons, financial views, analytics and admitted request/build provenance. There is no new API, request on click, financial calculation or upload format.
The existing results service validates stored financial content and request/analytics identity; the existing monitoring hook binds it to the selected run/backtest. The new action reuses that ownership instead of introducing another loader or validator. A private per-run component owns local error/retry state. A 15-line JSON-text download helper is shared with RP07, preserving its raw text, cancellation and resource cleanup behavior. Legacy and fills-only views remain unchanged.
Independent reviewer `/root/find_research_followup` accepted the implementation and root browser test: 64 focused UI tests / 457 assertions passed independently and in the implementer worktree. The existing canonical report fixture verifies complete JSON equality, unchanged input, distinct run filenames/contents, zero extra requests, error reset and URL/click failure retry with cleanup. No duplicate financial fixture or download framework was added. Review corrected two guide details: orders are under `financial.view`, and the button says **Retry run result download**. [Usage](../guide/backtest-walkthrough.md#take-the-result-into-a-notebook-or-local-ai-workflow) explains local inspection and the separate dataset/runtime requirements for replay.
Root validation:
- `CARGO_BUILD_JOBS=2 bun run check`: passed — 134 tooling, 43 utility, 44 calculation, 1,320 integration and 150 Rust tests. Existing 14 conditional integration skips / 4 ignored Rust measurements remain. Build, types, contracts, strict lint and secret audit passed.
- Authored Chromium-test typecheck and formatting/diff checks passed. Implementer application/authored-test types, focused strict lint and production build also passed.
- Final Chromium suite: all 21 scenarios passed with 726 assertions. An actual result file deep-equals the original API response after the editable template changes dataset. Downloading issues zero additional API requests and leaves the replacement settings, run and dispatch counts unchanged. The existing dataset download also passes through the shared helper.
The first full browser invocation passed 20 scenarios but failed the archive scenario during fixture shutdown (`pendingWebSockets=1`, no tracked sockets). All archive application assertions completed; the shutdown failure repeated in isolation. The fixture now returns WebSocket upgrades synchronously while keeping ordinary HTTP handling asynchronous. The focused archive test and then the complete suite passed; original cleanup deadlines/errors remain enforced. No timing probes or timeout increases were retained, and the production server wrapper was not changed. This is observed fixture validation, not a claim that a Bun internals defect has been proven or a production reliability issue fixed.
Logs: `/tmp/stock-bot-rp08-root-check.log`, `/tmp/stock-bot-rp08-root-test-types-final.log`, `/tmp/stock-bot-rp08-browser.log` (initial failure), `/tmp/stock-bot-rp08-browser-archive-sync.log`, `/tmp/stock-bot-rp08-browser-final.log` and `/tmp/stock-bot-rp08-independent.log`. Browser tests use disposable PostgreSQL/Redis fixtures. No development research runs, paper/live operations or deferred optimization were activated.
## RP09 / RP10 — Strategy custody and experiment recovery
Implementation commits `49da701a` (RP09) and `f0e7d074` (RP10) are accepted. The manifest now contains 75 completed scheduled tasks, seven deferred conditional tasks and four merged redirects: 86 IDs total.
Owner continuation authorized two reproduced workflow corrections; planning commit `c24410e5` freezes their scope. RP09's baseline UI tests showed **Use in backtest** navigating away during pending and lost-response clones without consulting the discard confirmation, losing the route's retry receipt. RP10's baseline hook/editor tests showed a missing linked backtest hiding a successfully loaded catalog of valid alternatives.
RP09 reuses existing parent state to block backtest handoff until publication/clone work is finished or cleared. It prevents competing publication and clone operations in both UI orders; normal validated parameter transfer and the existing metadata confirmation remain unchanged. There is no new modal, router blocker, persistence mechanism or backend change. The browser's deliberately abandoned routes retain their existing behavior; this correction is scoped to handoff and competing operations. [Usage](../guide/strategy-development.md#from-source-code-to-a-saved-candidate).
RP10 publishes the valid catalog before attempting an optional linked-template lookup and reports that lookup's failure separately. The unavailable selection remains explicit; choosing another template keeps the name and parameter grid. Retry and pagination preserve the current ownership fences and canonical eligibility filter. No automatic selection, save, preview or submission was added. [Usage](../guide/backtest-walkthrough.md#grow-one-run-into-a-research-workflow).
Independent reviewer `/root/review_recovery_changes` accepted both implementations and root's browser fixtures: RP09 29 focused tests / 199 assertions; RP10 38 / 207. RP10's implementer also passed 193 tests / 784 assertions across five suites with a temporary browser-origin preload for existing static browser-parser imports. That preload was not needed for the independent focused suite or root's full repository gate; no test harness workaround was committed.
Root validation:
- `CARGO_BUILD_JOBS=2 bun run check`: passed — 134 tooling, 43 utility, 44 calculation, 1,334 integration and 150 Rust tests. Existing 14 conditional integration skips and 4 ignored Rust measurements remain. Build, types, contracts, strict lint and secret audit passed.
- Root-authored browser tests passed TypeScript checking after correcting a fixture-only array-index assertion. Implementer application/authored types, strict lint, formatting and production builds passed.
- Chromium: 20 scenarios passed in the full invocation. The augmented clone scenario completed the receipt-recovery checks but failed a fixture assertion that assumed no earlier parent-linked revision existed. The catalog automatically links a new publication to the latest family version when no parent is supplied. The corrected test snapshots that count and requires exactly one additional version; its focused rerun passed with 50 assertions. Together these cover all 21 scenarios; the initial full invocation is not reported as all-pass. No application code changed after it.
- The clone browser regression delays the actual committed response, verifies blocked handoff, loses that response and retries through the existing route. Both attempts use the same body/key and recover the same original version; normal parameter handoff and saved-draft behavior remain covered. The independent reviewer accepted the count correction after checking the catalog's default lineage behavior.
- The experiment browser regression opens a real missing-UUID link, observes 404, keeps another valid template selectable and preserves name/grid when it is chosen. It checks unchanged template and zero experiments/runs/dispatch records before explicit preview, then completes the existing durable experiment workflow.
Logs: `/tmp/stock-bot-rp09-rp10-root-check.log`, `/tmp/stock-bot-rp09-root-test-types-final.log`, `/tmp/stock-bot-rp09-rp10-browser.log`, `/tmp/stock-bot-rp09-browser-clone-final.log`, `/tmp/stock-bot-rp09-independent.log` and `/tmp/stock-bot-rp10-independent.log`. Browser tests use disposable PostgreSQL/Redis. No development research runs, paper/live operations or conditional optimization were activated.
## RP11 / RP12 — Partial-read recovery
Planning commit `f4cee5af` scopes two verified UI defects. Implementation commits `32f40ee7` (RP11) and `a050c710` (RP12) are independently accepted. The manifest contains 77 completed tasks, seven deferred tasks and four merged redirects: 88 IDs total.
RP11 retains a verified exact hypothesis/revision link when another hypothesis history fails. An incomplete lookup without a match remains retryable through project refresh; a fully checked history without a match reports absence. Existing ownership checks and stale-response fencing remain. The browser advances the cited hypothesis, creates an unrelated hypothesis, fails only that unrelated history read, then opens the original cited revision and its original proposition.
RP12 renders current run records immediately and loads each completed result independently. Status polling preserves unchanged reads; slow or failed metrics cannot hide saved runs. Failed reads offer a row-local retry, and removed, changed-parent or unmounted requests lose ownership. A small component-local request map coordinates this lifecycle. The browser delays an actual completed result, opens another saved run while the first read remains pending and verifies unchanged saved-run IDs/statuses. No API, shared table, financial semantics or global cache changed.
Both baseline probes failed before implementation. Independent reviewer `/root/review_recovery_changes` accepted RP11 with 20 focused tests / 90 assertions and RP12 with 41 / 344, plus both browser additions. Tests include partial failure, retry, status polling, identity checks and late-response ownership.
Root validation:
- `CARGO_BUILD_JOBS=2 bun run check`: passed — 134 tooling, 43 utility, 44 calculation, 1,347 integration and 150 Rust tests. Existing 14 conditional integration skips and four ignored Rust measurements remain. Build, application types, contracts, strict lint and secret audit passed.
- Complete Chromium suite: 21 scenarios passed, zero failures, 750 assertions. Fresh disposable PostgreSQL/Redis fixtures were used. Both new regressions passed in this full invocation.
- Authored test types, scoped formatting and diff checks passed. Implementer package-local declaration checking initially encountered the existing `paperApi.ts` TS4023 issue; repository typechecking and the proper no-emit application check passed. No workaround was committed.
Logs: `/tmp/stock-bot-rp11-baseline.log`, `/tmp/stock-bot-rp12-baseline.log`, `/tmp/stock-bot-rp11-independent.log`, `/tmp/stock-bot-rp12-independent.log`, `/tmp/stock-bot-rp11-rp12-root-check.log`, `/tmp/stock-bot-rp11-rp12-browser-types.log` and `/tmp/stock-bot-rp11-rp12-browser.log`. No development research execution, paper/live activation or conditional performance work was performed.
## RP13 — Isolated candidate reproduction
Planning commit `8807d9e5` scopes the browser/backend contract mismatch; implementation `773314d2` is accepted. The manifest contains 78 completed tasks, seven deferred tasks and four merged redirects: 89 IDs total.
The backend already permits eligible isolated candidates without a human review, including reproduction with a null review receipt. The browser incorrectly required a current approval receipt for every available preview. RP13 applies that requirement only to built-ins, preserves strict candidate runtime/request validation and displays absent versus unavailable review information accurately. Backend eligibility, revocation, original input custody and financial semantics are unchanged.
The baseline actual component/transport probe failed with a schema-valid candidate preview. Independent reviewer `/root/review_recovery_changes` accepted 41 UI/API tests / 238 assertions, including reviewed/unreviewed candidates, missing built-in approval, unavailable/revoked candidates, malformed execution data, identity checks and exact-source/key retries.
Root validation:
- `CARGO_BUILD_JOBS=2 bun run check`: passed — 134 tooling, 43 utility, 44 calculation, 1,358 integration and 150 Rust tests. Existing 14 conditional integration skips and four ignored Rust measurements remain. Build, application types, contracts, strict lint and secret audit passed.
- Focused `test/postgres/isolated-candidates.test.ts` candidate retry/reproduction case: passed, 8 assertions. This exercises retained candidate inputs after template edits, null-review admission, native economic matching, revocation and recovery of an already accepted receipt. Five unrelated cases were excluded by the name filter.
- Complete Chromium suite: all 21 scenarios passed, zero failures, 770 assertions. The added flow reproduces an actually unreviewed controlled candidate through the durable isolated runner, recovers the same run from its receipt, verifies original strategy/runtime/dataset and analytics, reopens the economic-match result and confirms zero review records before and after reproduction. The existing built-in reproduction and later human-reviewed promotion fixtures also passed. These are disposable test records, not real trading activation.
- Application and authored test types, scoped lint/formatting and diff checks passed. An additional economic-comparison suite could not load `zod` in the isolated implementation worktree; all four comparison cases passed in the root full check. No dependency workaround was committed.
Logs: `/tmp/stock-bot-rp13-baseline.log`, `/tmp/stock-bot-rp13-independent.log`, `/tmp/stock-bot-rp13-comparison.log`, `/tmp/stock-bot-rp13-root-check.log`, `/tmp/stock-bot-rp13-root-test-types.log`, `/tmp/stock-bot-rp13-postgres.log` and `/tmp/stock-bot-rp13-browser.log`. PostgreSQL/Redis were fresh disposable fixtures. Conditional performance work and development/paper/live execution remain inactive.
## RP14 — Backtest creation navigation
Planning commit `cf04fb36` scopes the verified dialog-owned navigation defect; implementation `0d022ecc` is accepted. The manifest contains 79 completed tasks, seven deferred tasks and four merged redirects: 90 IDs total.
The creation dialog's Close controls already protected an edited draft or pending Save, but its immutable-strategy link bypassed both rules. A dialog-local click capture now reuses the same pending ref and discard confirmation for ordinary same-tab links. Clean and deliberately confirmed navigation still works; modified/middle clicks, explicit new contexts and already-prevented events retain their behavior. The shared selector, router, backend and financial contracts are unchanged. This correction covers links inside the creation dialog, not global navigation.
Both original baseline probes failed on `dcffa2ea`; three new regression cases also failed before the fix. Independent reviewer `/root/review_recovery_changes` accepted 72 focused backtest/strategy UI tests / 488 assertions. Coverage includes exact draft preservation, accepted/clean navigation, Save plus link before rerender, pending ownership, failed-save confirmation, new-context defaults and existing Close/unmount behavior.
Root validation:
- `CARGO_BUILD_JOBS=2 bun run check`: passed — 134 tooling, 43 utility, 44 calculation, 1,364 integration and 150 Rust tests. Existing 14 conditional integration skips and four ignored Rust measurements remain. Build, application types, contracts, strict lint and secret audit passed.
- Complete Chromium suite: 21 scenarios passed, zero failures, 783 assertions. The catalog workflow declines navigation and preserves its draft, then holds the real save response after the database commit. Clicking the strategy link while pending neither navigates nor prompts; releasing the response opens that exact saved definition with original parameters. Exactly one definition and zero runs/dispatches are verified.
- Application and authored test types, focused lint/formatting and diff checks passed. The browser fixture waits for the initial backtest catalog read to finish before delaying the save, so that unrelated read cannot consume its delay.
Logs: `/tmp/stock-bot-rp14-baseline.log`, `/tmp/stock-bot-rp14-red.log`, `/tmp/stock-bot-rp14-independent.log`, `/tmp/stock-bot-rp14-root-check.log`, `/tmp/stock-bot-rp14-root-test-types-final.log` and `/tmp/stock-bot-rp14-browser.log`. PostgreSQL/Redis were fresh disposable fixtures. No development research execution, paper/live activation or conditional performance work was performed.
## RP15 / RP16 — AI client recovery and candidate revisions
Planning commit `14b28a34`; accepted implementations `e3d6512b` (RP15) and `cc49f038` (RP16). The manifest now contains 81 completed tasks, seven deferred tasks and four merged redirects: 92 IDs total.
RP15 preserves the exact structured `ResearchCycleStopped` event at the executable error boundary when receipt persistence fails. Cleanup failure cannot replace the original recovery event. Rejected operations retain their original uncertainty; failures before admission do not invent accepted receipts. The journal remains exclusively created, execution stops with exit 1, and no automatic retry or alternate journal is introduced.
RP16 fixes a client/catalog contract mismatch: a null publication parent asks the catalog to select its latest version, rather than requiring the response parent to remain null. Explicit parents still require an exact match. Existing schema, candidate origin, family and package checks remain. Receipt retries use the original body/key and recover the original lineage even after newer publications.
Independent reviewer `/root/review_recovery_changes` accepted both patches: RP15 had 26 client/cycle tests / 164 assertions, including seven actual CLI subprocess regressions without network access; RP16 had 22 client/cycle tests / 138 assertions. These isolated counts overlap and are not additive. The real-agent PostgreSQL lineage regression failed before the fix, then the complete authenticated AI workflow suite passed **3 tests / 148 assertions**, including native execution and quota/evidence rejection. The added case verifies automatic and explicit parents, delayed receipt replay, exactly four versions and zero research runs from publication alone.
Root `CARGO_BUILD_JOBS=2 bun run check` passed: **144 tooling, 43 utility, 44 calculation, 1,364 integration and 150 Rust tests**. Existing 14 conditional integration skips and four ignored Rust measurements remain. Build, application and authored test types, contracts, lint, formatting, diff check and secret audit passed. No browser suite was rerun for these script-only changes. The PostgreSQL fixture was disposable and stopped afterward.
Evidence: `/tmp/stock-bot-cycle-journal-probe/`, `/tmp/stock-bot-rp16-regression-red.log`, `/tmp/stock-bot-rp15-independent.log`, `/tmp/stock-bot-rp16-independent.log`, `/tmp/stock-bot-rp16-postgres.log`, `/tmp/stock-bot-rp15-rp16-root-check.log`, `/tmp/stock-bot-rp15-rp16-types.log` and `/tmp/stock-bot-rp15-rp16-lint.log`. Development research execution, paper/live activation and conditional performance work remain inactive.