diff --git a/docs/development/backlog/README.md b/docs/development/backlog/README.md index a8272193..13cfaca3 100644 --- a/docs/development/backlog/README.md +++ b/docs/development/backlog/README.md @@ -8,7 +8,7 @@ [manifest.json](manifest.json) owns scheduling metadata: status, priorities, dependencies, ADR approvals, assignments and write locks. Task Markdown owns implementation scope/evidence/acceptance. This index and the [graph](dependencies.mmd) are derived views. Only the planning/integration owner updates scheduling state. -**Current total: 96 retained IDs — 84 done, 1 in progress, 7 deferred, 4 merged.** RP18 completes the bounded October multi-session pilot; RP01–RP17 add the authorized real-data workflow and its dataset reuse, export and workflow recovery follow-ups. The earlier 68 IDs retain their state. E11 adds seven authorized cleanup tasks and one conditional replay extraction; see the manifest for current scheduling. The original backlog accounted for 55 IDs. F09/P07 added projection/profiling work; the owner deferred P08's TypeScript optimization. Merged records preserve traceability; never execute them separately. Deferred work requires its stated trigger and explicit activation. +**Current total: 97 retained IDs — 85 done, 1 ready, 7 deferred, 4 merged.** RP18 completes the bounded October multi-session pilot; RP01–RP17 add the authorized real-data workflow and its dataset reuse, export and workflow recovery follow-ups. The earlier 68 IDs retain their state. E11 adds seven authorized cleanup tasks and one conditional replay extraction; see the manifest for current scheduling. The original backlog accounted for 55 IDs. F09/P07 added projection/profiling work; the owner deferred P08's TypeScript optimization. Merged records preserve traceability; never execute them separately. Deferred work requires its stated trigger and explicit activation. States: ready, claimed, in_progress, review, done, blocked, deferred, merged. “Ready” means no code/ADR prerequisite, not execution authority. Implementation dependencies require accepted integration. `release_gates` govern enabling an end-to-end feature, not component coding or integration; conditional gates apply only to the named capability. F05 may integrate before F06, but its replay behavior is not released until F06 proves it. @@ -191,4 +191,6 @@ Owner authorized planning and per-task implementation commits. [Execution plan a - [RP19: Final risk state](tasks/RP19.md) — done, `e6616fdc`; canonical results show exact native halt flags, limits and snapshot times without inferring halt history. -- [RP20: Production research authentication](tasks/RP20.md) — in progress; repair the missing resolver in normal API startup before the next bounded AI study. +- [RP20: Production research authentication](tasks/RP20.md) — done, `7de497e9`; normal API startup uses the existing research resolver, with actual issued-credential and quota regressions. + +- [RP21: Bounded volatility-filter study](tasks/RP21.md) — ready; two fixed isolated mean-reversion configurations, retrospective September holdouts and at most ten trials. Reuses existing candidate code. diff --git a/docs/development/backlog/dependencies.mmd b/docs/development/backlog/dependencies.mmd index 2224f5c8..45fac1c4 100644 --- a/docs/development/backlog/dependencies.mmd +++ b/docs/development/backlog/dependencies.mmd @@ -318,3 +318,10 @@ flowchart TD A01 --> RP20 A03 --> RP20 + + RP20 --> RP21 + A02 --> RP21 + A03 --> RP21 + RP03 --> RP21 + R08 --> RP21 + R09 --> RP21 diff --git a/docs/development/backlog/manifest.json b/docs/development/backlog/manifest.json index 74025d5d..bca08b2a 100644 --- a/docs/development/backlog/manifest.json +++ b/docs/development/backlog/manifest.json @@ -1,8 +1,8 @@ { "schema_version": 1, - "plan_revision": "2026-10-27.113", + "plan_revision": "2026-10-27.114", "repository_base": "b7aeca4", - "plan_status": "research_auth_composition_in_progress", + "plan_status": "research_auth_complete_signal_study_ready", "execution_authorized": true, "execution_scope": { "authorized_by": "Owner: commit and continue with the rest of the tasks till 100%", @@ -3627,7 +3627,7 @@ "epic": "E12", "priority": "P1", "severity": "High", - "status": "in_progress", + "status": "done", "dependencies": [ "A01", "A03" @@ -3640,13 +3640,49 @@ "web-api-security-composition" ], "blocker": null, - "integration_state": "planned", + "integration_state": "accepted", + "completion_evidence": "real-data-research.md", + "release_gates": [], + "review_status": "accepted", + "completed_commit": "7de497e9", + "integration_base": "079d9a7c", + "authorization": "Owner commit-and-continue authorizes the bounded research follow-up and its production authentication prerequisite. No paper/live activation or deferred optimization.", + "planning_commit": "fd90d172", + "reviewer": "/root/review_recovery_changes", + "branch": "rp20/research-auth", + "worktree": "/tmp/stock-bot-rp20-auth", + "review_notes": "Independent focused tests: 21 passed / 175 assertions. Root full check: 144 tooling, 43 utility, 44 calculation, 1382 integration and 150 Rust passed (14 conditional skips, 4 ignored Rust). Disposable PostgreSQL: 13 passed / 143 assertions, verifying actual operator issuance, scoped agent identity, capacity rejection and revocation using production composition. Types/lint/format/diff passed. No development credentials, new research runs or manual process restart." + }, + { + "id": "RP21", + "title": "Run a bounded volatility-filter signal study", + "epic": "E12", + "priority": "P2", + "severity": "Medium", + "status": "ready", + "dependencies": [ + "RP20", + "A02", + "A03", + "RP03", + "R08", + "R09" + ], + "decision_dependencies": [], + "task_file": "backlog/tasks/RP21.md", + "complexity": "M", + "assignment": "/root", + "write_locks": [ + "aapl-september-signal-study" + ], + "blocker": null, + "integration_state": "predeclared", "completion_evidence": "real-data-research.md", "release_gates": [], "review_status": "pending", "completed_commit": null, - "integration_base": "079d9a7c", - "authorization": "Owner commit-and-continue authorizes the bounded research follow-up and its production authentication prerequisite. No paper/live activation or deferred optimization." + "authorization": "Owner continuation follows bounded AI signal-study recommendation. At most ten isolated research trials on fixed September partitions. No fabricated human review, paper/live activation or deferred optimization.", + "scope_notes": "Reuse unchanged bundled mean-reversion code in existing isolated-candidate mode; two fixed configurations differ only by volatility filter. No candidate source rewrite. Availability inventory only; no September prices/returns or results inspected. See task for frozen parameters, policy, windows, limits and evidence requirements." } ], "review_note": "Independent skeptical revision: four superseded tasks retain stable IDs; deferred work is not a dependency of scheduled tasks. Release gates are distinct from implementation prerequisites.", diff --git a/docs/development/backlog/tasks/RP20.md b/docs/development/backlog/tasks/RP20.md index 823dba9d..86286fb7 100644 --- a/docs/development/backlog/tasks/RP20.md +++ b/docs/development/backlog/tasks/RP20.md @@ -17,3 +17,5 @@ Acceptance and mandatory tests: - Independent review checks production wiring, shared security identity, denial-before-side-effects and whether tests actually cover the startup seam. Record exact commands and limitations before closing. Regression risks: tests reconstructing a different security object again; accidentally permitting async research identities on the privileged WebSocket path; weakening disabled-auth rules; moving startup validation without preserving failure behavior. Keep the implementation focused on composition, not authorization policy. + +Accepted October 27, 2026: plan `fd90d172`, implementation `7de497e9`. Independent security tests passed 21 tests / 175 assertions. Root full repository check passed, including 1,382 integration and 150 Rust tests. Disposable PostgreSQL proof passed 13 tests / 143 assertions for actual issuance, scope/identity, quota admission/rejection and revocation. Authored-test types, lint, formatting and diff checks passed. [Execution evidence](../../real-data-research.md#rp20--production-research-authentication) retains the failing baseline, corrected test expectations and verification limits. No development credentials, research runs or trading state changed. diff --git a/docs/development/backlog/tasks/RP21.md b/docs/development/backlog/tasks/RP21.md new file mode 100644 index 00000000..8cd8790a --- /dev/null +++ b/docs/development/backlog/tasks/RP21.md @@ -0,0 +1,60 @@ +# RP21 — Run a bounded volatility-filter signal study + +Parent E12. Priority P2 / research workflow evidence. Complexity M. Dependencies RP20, A02, A03, RP03, R08 and R09. The owner's continuation follows the recommendation for an AI-driven signal study. Use existing research APIs, isolated candidate execution and canonical Rust accounting. No new simulator, strategy framework, optimization, human catalog approval or paper/live activation. Root owns the real-data receipts; an independent reviewer audits retained inputs/results. Do not parallelize submissions or inspect holdouts before their declared phase. + +## Predeclaration before September price inspection + +Hypothesis: during positive trailing trend, buying a sufficiently negative deviation from the recent mean may recover; suppressing entries during high observed return volatility may improve cost-adjusted outcomes relative to the identical unfiltered rule. This is an unvalidated hypothesis, not discovered alpha. Compare two fixed variants without numeric optimization. Same code, dataset, native engine, risk, seed and costs; only `regimeFilter` changes. + +Use the existing `createMeanReversionStrategy` artifact produced by `scripts/package-builtin-strategies.ts`, then add `execution: { kind: 'isolated-candidate/v1', warmupBars: 60 }`. Preserve its program, parameter schema, artifact, build and source/lock identities. Publish each cycle entry as an isolated candidate. This exact adaptation already exists in `test/postgres/ai-research-workflow.test.ts`; it avoids duplicating indicator and checkpoint code. Do not create a new candidate source, narrow the known schema, or evaluate uploaded source on the host. Both entries embed the identical package. The current factory's observation-count indicators and pending-entry/exit behavior remain authoritative strategy semantics. + +Fixed parameters for both entries: + +```json +{ + "lookbackPeriod": 20, + "trendPeriod": 60, + "momentumPeriod": 3, + "volatilityPeriod": 20, + "entryZScore": 1.5, + "exitZScore": 0, + "minTrendReturn": 0, + "minMomentumReturn": -0.01, + "maxVolatility": 0.002, + "minNotionalVolume": "0", + "regimeFilter": "volatility" +} +``` + +Control changes only `regimeFilter` to `none`. Both have `grid: {}`. Fixed execution order: filtered, then control. Do not revise thresholds, windows, costs or risk after seeing outcomes. Zero trades, identical outcomes, risk halts and failed runs remain findings; they do not authorize another search. + +One asset: stored EOD `AAPL.US`, five-minute bars, September 2024 regular sessions, 13:30–20:00 UTC. Overall warmup starts September 3; trading starts September 4 and ends September 30. Split by complete sessions: + +| Phase | Warmup start UTC | Trading start UTC | Trading end UTC | Expected source bars | +| --- | --- | --- | --- | --- | +| Training | Sep 3 13:30 | Sep 4 13:30 | Sep 16 20:00 | 780 | +| Validation | Sep 16 13:30 | Sep 17 13:30 | Sep 23 20:00 | 468 | +| Test | Sep 23 13:30 | Sep 24 13:30 | Sep 30 20:00 | 468 | + +Recipe `version: 1`, `labelHorizonMs: 0`. Every phase has 78 warmup bars. Expected whole source: 1,560 bars across 20 sessions. These are expectations, not permission to repair incomplete data. Freeze the exact UTC millisecond recipe in the local execution plan before capture. Use declared half-open session queries; validate all selected rows, gaps, duplicates, identifiers and OHLCV. Preserve raw bytes, source metadata, calendar/action evidence, dataset hash and strict preview receipts. No silent null-volume coercion, resampling, interpolation or date substitution. + +Preserve RP18 financial policy: capital 10000, seed 42, ownerBudget `1000`, feeRate `0.001`, halfSpreadRate `0.0001`, slippageRate `0.0001`, latencyMs 0, participationRate `0.01`, maxOrderQuantity/maxPositionQuantity `10`, maxSymbolExposure/maxGrossExposure `1500`, maxDailyLoss `100`, maxDrawdownAmount `200`, maxMarkAgeMs 300000, periodsPerYear 252, annualRiskFreeRate 0. Owner budget remains a strategy sizing input, not a native strategy allocation limit. + +Each variant has one training run, two server-selected holdouts, then two full-template cost runs (automatic baseline and stress with feeRate `0.002`, slippageRate `0.0005`, unchanged spread). **At most ten admitted trials**, one attempt each. Failed candidates may yield fewer. Costs run only after the respective holdout report is sealed; whole-window cost diagnostics are not another untouched holdout. Accounts restart for every run, holdings may persist overnight, and terminal valuation uses native marking rather than an invented closing fill. + +## Existing workflow and acceptance + +1. Commit this predeclaration and package a clean source revision. Validate both fixed parameter sets against the retained package; assert the complete package is identical between entries. Run the existing strategy, chronological-cycle and isolated/native candidate regressions. Check the pinned sandbox is installed and usable; never fall back to host execution. No new parity implementation is needed for an unchanged bundled strategy. +2. Retain files in the new ignored `.data/research-pilots/aapl-202409-signals/` directory, without overwriting previous pilot artifacts. Create a separate project and frozen template through current APIs. The existing approved built-in may anchor the non-executed template grant; do not submit additional baseline SMA runs or manufacture another human review. Record source vintage/selection limitations before admission. +3. Provision a dedicated credential through the normal API composition fixed by RP20. Scope it to this project/template with own-candidate opt-in. Limits: maxActiveTrials 2, maxTrialsPerExperiment 3, maxBarEvaluationsPerExperiment 3120, maxAttemptWallMs 300000, maxAttempts 1. Three counts training plus both holdouts; two whole-window cost trials determine the larger bar budget. `maxTotalTrials: 10` is the local predeclared cycle bound, not a server lifetime quota. Finalize template/build inputs before granting. Keep the credential private and revoke after completion or terminal abandonment; revocation does not cancel accepted jobs. +4. Use `scripts/examples/research-cycle.ts` and its typed client, with a new private fsynced receipt journal and `validateResearchCycle` reporting ten total trials. Persist complete candidate definitions before any performance read. Drive only receipt-admitted run IDs through the existing runner; verify project/template/experiment/agent/version before execution. Never drain unrelated queues or restart the entire CLI after ambiguous non-idempotent writes. Use existing receipt recovery and exact-key retries only where supported. +5. Reopen results, sealed holdout reports and costs through APIs. Retain every failure and diagnostic. Compare net return, drawdown, fills, fees, final native risk state and metric availability. Save AI-origin findings linked to exact run/report evidence; distinguish hypothesis from observation. No significance/profitability claim or automatic promotion. Without retained as-of regime labels, report a filter ablation, not performance attribution to distinct market regimes. +6. Independent audit checks all admitted IDs against the ten-trial bound, shared artifact/financial policy, only the declared parameter/cost differences, phase data/selection hashes, no holdout-driven edits, cash/fees/owner/equity reconciliation and evidence references. Reopen the project, saved results and findings in the web app without new submissions. Record exact executed tests and limitations, then commit concise execution evidence and close the story. + +Relevant paths: `apps/stock/orchestrator/src/strategies/canonical-mean-reversion.ts`, `apps/stock/orchestrator/src/contracts/builtin-strategy.ts`, `scripts/package-builtin-strategies.ts`, `scripts/examples/research-cycle.ts`, `scripts/research-client.ts`, `apps/stock/web-api/src/services/research-agents.service.ts`, `apps/stock/web-api/src/services/validation-preview.ts`, and the existing `.data/research-pilots/aapl-202410-month/` preparation/receipt examples. Tests: `test/integration/canonical-mean-reversion.test.ts`, `test/integration/canonical-regime-research.test.ts`, `test/integration/candidate-sandbox.test.ts`, `scripts/test/research-cycle.test.ts`, `test/postgres/ai-research-workflow.test.ts`. Real fixture tests require disposable stores and the installed OS isolation profile. No benchmark work. + +## Evidence and limitations + +Availability-only inventory on October 27 read timestamps/counts/null-volume counts, not prices or returns: September contains 20 dates, each 79 raw rows from 13:30 through 20:00 UTC. Strict session capture must establish that the selected 78 rows are valid. September was chosen from coverage before its price inspection, but is earlier than the already inspected October pilots: this is **predeclared retrospective holdout research**, not prospective validation after October or a guarantee against global selection bias. Fixed AAPL selection and a dataset captured in 2026 are also retrospective. The small partitions cannot establish durable alpha. + +[Nasdaq's Labor Day notice](https://www.nasdaqtrader.com/TraderNews.aspx?id=ETA2024-49), [2024 calendar](https://www.nasdaqtrader.com/content/technicalsupport/2024tradingcalendar.pdf) and [hours](https://www.nasdaq.com/market-activity/stock-market-holiday-schedule) support the declared sessions. An action-free September is an inference from [Apple's dividend/split history](https://investor.apple.com/dividend-history/), not a certified action feed. [EOD's intraday documentation](https://eodhd.com/financial-apis/intraday-historical-data-api) describes UTC bar starts and delayed finalization/corrections: interval-end availability is a simulated zero-delay assumption, not observed vendor arrival. diff --git a/docs/development/real-data-research.md b/docs/development/real-data-research.md index fa9000d4..a00d0a8c 100644 --- a/docs/development/real-data-research.md +++ b/docs/development/real-data-research.md @@ -336,3 +336,20 @@ Root verification: The initial restricted full-check attempt timed out in native child-worker tests and was interrupted; the permitted rerun passed. The first browser rerun used a manual build without `NODE_ENV=production` and failed at authentication before reaching the panel. Rebuilding with explicit production mode and empty `VITE_API_BASE_URL` restored the existing same-origin fixture setup; the four scenarios then passed. A test-only missing-braces lint error was corrected before acceptance. No application workaround was added for those setup failures. Logs: `/tmp/stock-bot-post-rp18-result-audit.log`, `/tmp/stock-bot-rp19-red.log`, `/tmp/stock-bot-rp19-browser-red.log`, `/tmp/stock-bot-rp19-independent-ui.log`, `/tmp/stock-bot-rp19-root-check.log`, `/tmp/stock-bot-rp19-root-check-escalated.log`, `/tmp/stock-bot-rp19-browser-green.log`, `/tmp/stock-bot-rp19-browser-final.log`, `/tmp/stock-bot-rp19-root-types.log`, `/tmp/stock-bot-rp19-root-lint.log` and `/tmp/stock-bot-rp19-root-format.log`. The manifest now has 84 done, seven deferred and four merged tasks: 95 IDs. No development research runs, paper/live activation or deferred performance work occurred in RP19. + +## RP20 — Production research authentication + +The bounded AI-study preflight exposed a production composition defect: normal API startup supplied security without the research resolver, bypassing `createRoutes`' working default. Operator provisioning returned 403 and research bearer authentication was unavailable. Existing test hosts installed their own resolver and missed the startup discrepancy. + +Plan `fd90d172`; accepted implementation `7de497e9`. `createWebApiSecurity` now composes the existing resolver once for the running server's HTTP and WebSocket routes and supplies the same default for standalone routes. Explicit supplied-security capabilities remain unchanged. Configuration validation still precedes store initialization; research authentication remains asynchronous HTTP-only, without gaining browser-session, WebSocket, operator or trading privileges. Financial semantics, schemas and native code are unchanged. + +Validation: + +- Failing baseline captured the extracted production behavior: operator provisioning expected the existing policy-validation 400, but received the erroneous capability 403. Corrected composition passes 21 focused security tests / 175 assertions, independently rerun by `/root/review_recovery_changes`. +- Full `CARGO_BUILD_JOBS=2 bun run check` passed: 144 tooling, 43 utility, 44 calculation, 1,382 integration and 150 Rust tests. Fourteen existing conditional integration cases were skipped and four Rust measurement tests remained ignored; these are not evidence of new isolated-candidate execution. +- Disposable PostgreSQL `test/postgres/research-agents.test.ts`: 13 tests / 143 assertions passed. The production helper and full route factory issue a real token through the operator endpoint, retain only its hash, authenticate scoped AI writes, preserve experiment/trial agent ownership, enforce quota with 429 and no extra admission, and reject after revocation. The original broader concurrency/recovery/budget cases still pass. +- Authored-test types, scoped ESLint, Prettier and diff checks passed. The PostgreSQL container was stopped. No development database test, actual research admission, deployed-process restart or new browser E2E run was performed; existing session/CORS/WebSocket behavior was exercised through its actual route composition. + +Two new database assertions initially used the wrong existing contracts: admission is 202 rather than 201, and trial ownership uses `research_agent_id` while experiment submission uses `submission_principal`. Both were corrected against the route and SQL28 contracts; no application change followed. Logs: `/tmp/stock-bot-rp20-baseline.log`, `/tmp/stock-bot-rp20-independent-security.log`, `/tmp/stock-bot-rp20-check.log`, `/tmp/stock-bot-rp20-postgres.log`, `/tmp/stock-bot-rp20-postgres-final.log`, `/tmp/stock-bot-rp20-postgres-accepted.log`, `/tmp/stock-bot-rp20-root-types.log` and `/tmp/stock-bot-rp20-root-lint.log`. + +Next, [RP21](backlog/tasks/RP21.md) predeclares a September volatility-filter comparison using the existing bundled mean-reversion candidate and at most ten runs. Only timestamps, counts and missing-volume counts were inspected for that window so far; no September price/return analysis or research submission occurred. Reusing the already-tested isolated artifact avoids new strategy code. The plan labels the earlier-than-October window as retrospective holdout research and keeps all seven conditional tasks deferred.