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

17 KiB
Raw Blame History

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 and regular hours support the declared ordinary session. The normalizer validates the declaration; it does not certify exchange evidence.
  • EOD intraday documentation 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, not a certified complete action feed.
  • Apple's August 2024 release 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 and the project finding. 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.

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.