T-204: Audit M2 completion status and M3 readiness
This commit is contained in:
commit
7ef7671a34
3 changed files with 298 additions and 0 deletions
|
|
@ -14,6 +14,7 @@ Start here. Every document below has a single responsibility; historical sprint
|
|||
| **[VALIDATION-AND-RIGOR.md](VALIDATION-AND-RIGOR.md)** | Canonical metric definitions, `trial_ledger` schema, effective-trials DSR ($\hat{N}$), CSCV PBO, Purged CPCV/Walk-Forward, rolling 6-month Vault + Post-2023 Recency Gate, lifecycle gates, and Dual Live Drift + IB/TSX execution rules | Before touching `libs/calculations`, `libs/research`, validation workflows, or paper/live execution |
|
||||
| **[servers.md](servers.md)** | Host roles (`quant` `12900K` research/data server, `9900K` isolated IB live/paper host, `TrueNAS` cold storage, dev workstation) and port/storage layout | Infrastructure, deployment, and worker sizing |
|
||||
| **[data-pipeline/rust-migration-evaluation.md](data-pipeline/rust-migration-evaluation.md)** | Evidence-based evaluation of keeping `apps/stock/data-pipeline` in TypeScript vs. moving bulk MongoDB streaming or the full pipeline into Rust (`tools/curate-etl`) | Before `M2` adds PIT fundamentals, `ceoPosts`, or `bars_1m` QuestDB ingestion |
|
||||
| **[m2-completion-audit.md](m2-completion-audit.md)** | Read-only Milestone `M2` completion audit, gate results & pending host checks, candidate Auto Mode parking causes, director decisions, and `M3` readiness mapping (`T-204`) | Before closing `M2`, queuing remaining `M2` tasks, or starting `M3` |
|
||||
|
||||
---
|
||||
|
||||
|
|
|
|||
122
design/m2-completion-audit.md
Normal file
122
design/m2-completion-audit.md
Normal file
|
|
@ -0,0 +1,122 @@
|
|||
# Milestone M2 Completion Audit & M3 Readiness Report (T-204)
|
||||
|
||||
**Verdict:** **HOLD M3 — M2 is ~70% complete on the audited `feat/audit-m2-completion-status-m3` checkout (branched from `master`; exact `master` commit SHA pending host-side `git` verification), with 7 concrete wiring/contract gaps remaining before M2 closure.**
|
||||
|
||||
All sandbox-runnable TypeScript, ESLint, contract, and Rust native gates passed in the programmer's sandboxed run on the review checkout (`0` errors, `0` warnings), and Studio's unsandboxed review-branch runs (`#1597` build and `#1598` test suite) passed. Core M2 building blocks — `send-ilp` (`T-190`), the 6-tool MCP copilot server, file-mode PIT fundamentals/`ceoPosts`/`teData` curaters, QuestDB `10.2.0` schemas, and the TypeScript Feature Library — are landed and tested. However, desktop Claude Code cannot launch the MCP server end-to-end (`T-196` entrypoint is absent from the checkout), `ceoPosts` writes `"post"` instead of `"ceo_post"`, `MarketDataStore` rejects `crossSection`/`macroAsOf`/`fx('1m')`, `curate-qm-bars-1m` has no CLI subcommand, Python `stockbot` lacks `register_signal` and M2 store methods, and the live `quant` QuestDB `10.2.0` preflight, observed split-boundary check, and latency gates remain unverified.
|
||||
|
||||
> **Scope & Provenance Notes**
|
||||
> - **Audit-only:** Zero production code, build config, or CI changes (project CI is off).
|
||||
> - **Audited checkout & `master` relationship:** Audited in the task worktree on branch `feat/audit-m2-completion-status-m3` (branched from `master` for `T-204`). Because worktree `.git` metadata lives outside the agent sandbox, the exact `master` commit SHA and `studio/auto-*` branch history could not be read here and remain **PENDING** host-side verification. Every deliverable below was verified directly from source files, exports, CLI parsers, and test execution in this checkout.
|
||||
> - **Documentation path drift:** Milestone and contract docs moved from `docs/` to `design/`, while `AGENTS.md` (lines 43–48), `CLAUDE.md` (lines 3, 7–11), `README.md` (lines 7, 9, 11–13, 142, 264, 435), and `studio.config.json` still reference `docs/*.md`.
|
||||
> - **Prior M1 deferral:** Per settled director decision (`d52aa20`), M1 equity eligibility classification and cutoff-separated Parquet benchmarking stay deferred in the backlog and do not block M2.
|
||||
|
||||
---
|
||||
|
||||
## 1. Verification Gate Results & Pending Host Checks
|
||||
|
||||
### 1.1 Programmer Sandbox Runs (Review Worktree `feat/audit-m2-completion-status-m3`)
|
||||
|
||||
Executed inside the agent sandbox (network disabled; zero contact with QA MongoDB `27017/stock` or QA PostgreSQL `5432/trading_bot`; counts below are attributed to the programmer's sandbox execution without retained log files on disk):
|
||||
|
||||
| Gate / Suite | Command | Exit | Programmer-Observed Outcome & Counts |
|
||||
| --- | --- | :---: | --- |
|
||||
| Typecheck | `bun run typecheck` | `0` | **PASS** — `0` errors (`tsc --project tsconfig.check.json --noEmit`) |
|
||||
| Contracts | `bun run test:contracts` | `0` | **PASS** — `0` errors (`tsc --project tsconfig.contracts.json --noEmit`) |
|
||||
| Lint | `bun run lint:check` | `0` | **PASS** — `0` errors, `0` warnings (`--max-warnings 0`) |
|
||||
| Utils | `bun run test:utils` | `0` | **PASS** — `32` pass, `0` fail (`59` expects, `3` files) |
|
||||
| Calculations | `bun run test:calculations` | `0` | **PASS** — `144` pass, `0` fail (`76,602` expects, `12` files) |
|
||||
| Native Rust | `CARGO_BUILD_JOBS=2 bun run test:native` | `0` | **PASS** — `1,548` passed, `0` failed, `4` ignored across `57` suites (`engine` + `curate-etl`, incl. `tcp_sends_separate_shards_and_half_closes`, `restatement_of_q1_after_q2_updates_q1_and_ttm_without_overwriting_q2`, and the synthetic `split_boundary_nvda_and_nexm_match_raw_bars_1d_closes` fixture) |
|
||||
| M2 Research, DuckDB, QuestDB & Scripts | `bun test libs/research/ libs/data/duckdb/ libs/data/questdb/ scripts/test/security.test.ts scripts/test/workspace.test.ts` | `0` | **PASS** — `1,032` pass, `0` fail (`80,869` expects, `63` files; includes real-DuckDB `fundamentalsAsOf` restatement fixture and MCP Vault-fence suite) |
|
||||
| Postgres Copilot Executor & Unit Suites | `bun test libs/data/postgres/test/research-copilot-executor.test.ts libs/data/postgres/test/research-copilot-executor-edge.test.ts test/unit/` | `0` | **PASS** — `640` pass, `0` fail (`734,988` expects, `44` files) |
|
||||
| Python SDK (`python/tests/`) | `python3 -m pytest` | N/A | **SKIPPED (env)** — `pytest` / `python/.venv` not installed in the sandbox |
|
||||
|
||||
### 1.2 Studio Unsandboxed Runs & Remaining Host Verification
|
||||
|
||||
| Verification | Scope / Command | Status | Notes |
|
||||
| --- | --- | :---: | --- |
|
||||
| **Studio Build `#1597`** | `bun run build` on review branch `feat/audit-m2-completion-status-m3` | **PASS** | Reported green by Studio on the review branch. |
|
||||
| **Studio Test Run `#1598`** | `bun --env-file=/home/boki/.studio/test-env/stock-bot.env test && CARGO_BUILD_JOBS=2 cargo test --workspace --lib --offline` on review branch `feat/audit-m2-completion-status-m3` | **PASS** | Reported green by Studio on the review branch (covers Bun test suites including isolated `stock_bot_safety*` PostgreSQL tests, plus Rust workspace `--lib` tests). |
|
||||
| **Full Host Check & `master` Provenance** | Record `master` SHA, inspect `studio/auto-*` branches, and run `CARGO_BUILD_JOBS=2 bun run check` (incl. `audit:secrets`, `test:tooling`, `test:integration`, `lint:check`) + `bun --env-file=/home/boki/.studio/test-env/stock-bot.env test test/postgres/` with retained logs | **PENDING** | Not covered by Studio runs `#1597`/`#1598`; must be executed on the host against the confirmed `master` revision before M2 closure (see `design/m2-gap-audit.md:118-122`). |
|
||||
|
||||
**Research & Financial Invariants Verified Across Passing Suites**
|
||||
- **Economic ownership & durable inputs:** Quant data curation owns immutable Zstd Parquet partitions (`bars_1d`, `adj_factors`, `events`, `shorts`, `fx_1d`, `fundamentals_pit`, `macro`) and QuestDB ILP v2 shards; PostgreSQL owns append-only `trial_ledger`, `findings`, and `provider_caveats` (`database/postgres/init/37-research-findings.sql:81-99`).
|
||||
- **Holdout Vault fence:** `createQueryDataTool` (`libs/research/src/mcp/tools/query-data.ts`) and `openResearchCopilotStore` (`libs/data/duckdb/src/research-copilot-store.ts:40`) hardcode `vaultOperatorAuthorized: false`, reject `scope`/`vault_evaluation_only` keys, clamp bounds strictly below `vaultCutoffTs`, and drop post-cutoff rows (`libs/research/test/mcp-query-data.test.ts`).
|
||||
- **PIT & synthetic split conservation:** Both Rust (`tools/curate-etl/src/fundamentals_tests.rs:104`) and real-DuckDB TypeScript (`libs/data/duckdb/test/duckdb-market-data-store.test.ts:251,601-626`) prove `known_at <= asOf` and Q1-after-Q2 restatement non-overwrite. **Synthetic** Rust fixtures (`tools/curate-etl/src/bars_1m_tests.rs:107,220` and `tools/curate-etl/src/run_curate_bars_1m_tests.rs:377-402`) prove `NEXM.V` (`1:20`) and `NVDA.US` (`10:1`) split arithmetic and ex-date boundary handling within `0.5%`, while observed-data comparison against retained raw `bars_1d` closes remains open (`run_curate_bars_1m_tests.rs:396-400`).
|
||||
- **Database & execution safety:** Read-only MongoDB/Postgres adapters verified; zero paper/live execution write access in research/MCP surfaces.
|
||||
|
||||
---
|
||||
|
||||
## 2. M2 Deliverables & Exit Criteria Matrix
|
||||
|
||||
### 2.1 Deliverables (`design/MILESTONES.md` lines 87–98)
|
||||
|
||||
| Area | Status | Landed in Checkout (Exact Evidence) | Concrete Gaps Remaining |
|
||||
| --- | :---: | --- | --- |
|
||||
| **M2.1** Research Copilot MCP & Notebook Snapshots | **PARTIAL** | All 6 tools wired in `createResearchCopilotMcpServer` (`libs/research/src/mcp/copilot-server.ts:13-20,48`); stdio host (`libs/research/src/mcp/host/stdio-host.ts`); Postgres adapters (`libs/research/src/mcp/adapters/postgres-copilot.ts`, `postgres-trial-ref.ts`, `library-cards.ts`, `exchange-calendars.ts`, `bar-session-dates.ts`); `openResearchCopilotExecutor` (`libs/data/postgres/src/research-copilot-executor.ts`); `openResearchCopilotStore` (`libs/data/duckdb/src/research-copilot-store.ts:33`); SQL schema (`database/postgres/init/37-research-findings.sql`); `exportNotebookSnapshot` (`libs/research/src/notebook-snapshot.ts:594`, `notebook-snapshot-node.ts:67`). | **(1)** `T-196` desktop entrypoint `scripts/research-copilot-mcp.ts` and `"mcp:research-copilot"` in `package.json` are missing; `apps/stock/web-api/src/` has no optional SSE wrapper. **(2)** `openResearchCopilotStore` (`libs/data/duckdb/src/research-copilot-store.ts:37`) opens daily DuckDB only instead of composing `createRoutedMarketDataStore` + `createQuestDbIntradayBarsReader` for `1m` queries. **(3)** `analyze_signal` (`libs/research/src/mcp/tools/analyze-signal.ts:121-123`) restricts `signal.source` to `'shorts' \| 'fundamentals'` (no `ceoPosts`, `macro`, or materialized `features`). **(4)** `exportNotebookSnapshot` has no CLI or MCP entrypoint and no end-to-end MCP study + `marimo check`-clean HTML + `file_finding` verification test. |
|
||||
| **M2.2** PIT Fundamentals, `ceoPosts` & Lagged `teData` | **PARTIAL** | File-mode CLIs `curate-fundamentals`, `curate-posts`, and `curate-macro` wired in `tools/curate-etl/src/cli.rs:99-101,1295,1573,1684` and `main.rs:228,238,250`; Rust Q1-after-Q2 restatement test (`tools/curate-etl/src/fundamentals_tests.rs:104`); real-DuckDB TS `fundamentalsAsOf` implementation & restatement test (`libs/research/src/market-data-store-duckdb.ts:2287`, `libs/data/duckdb/test/duckdb-market-data-store.test.ts:251`). | **(1)** `EVENT_KIND_POST = "post"` (`tools/curate-etl/src/parquet_posts.rs:22`) mismatches `'ceo_post'` required by `libs/research/src/market-data-store-duckdb.ts:108`, `libs/research/src/event-panel.ts:63`, and `python/stockbot/data.py:21`, and `run_curate_posts` fails closed (`EventsDatasetExists`, `tools/curate-etl/src/run_curate_posts.rs:133,389`) if `<out>/events` already exists from `curate-events`; both TS (`market-data-store-duckdb.ts:1448`) and Python (`python/stockbot/data.py:71`) only glob `events/year=*/part.parquet`. **(2)** `createDuckDbMarketDataStore().macroAsOf` (`libs/research/src/market-data-store-duckdb.ts:2294-2296`) throws `MarketDataStoreNotImplementedError`, blocking read-back of `macro/part.parquet` (note: per `design/DATA-CONTRACTS.md:26`, `teData` holds final-revised values only and must remain restricted to coarse lagged regime filters, not historical release signals without vintage data). **(3)** `SourceCollection` (`tools/curate-etl/src/mongo_stream.rs:53-62`) allowlists only the 8 M1 collections — no `--from-mongo` streaming for `qmFinancials`, `qmFinancials-old`, `ceoPosts`, or `teData`, and `curate-fundamentals` lacks `--qm-financials-old` merging. **(4)** Python `stockbot.data.MarketDataStore` (`python/stockbot/data.py`) lacks `fundamentals_as_of` and `macro_as_of`. |
|
||||
| **M2.3** QuestDB `10.2.0` Intraday & `send-ilp` (`T-190`) | **PARTIAL** | `T-190` `send-ilp` CLI landed (`tools/curate-etl/src/cli.rs:102,2290`, `main.rs:260`, `ilp_send.rs`, `ilp_send_tests.rs` loopback `TcpListener` tests); `curate-bars-1m` and `curate-fx-1m` CLIs wired (`cli.rs:97-98`, `main.rs:208,218`); `M2_INTRADAY_SCHEMAS` (`libs/data/questdb/src/schema.ts:13-63`) with `PARTITION BY MONTH`, `WAL`, `SYMBOL CAPACITY 65536 NOCACHE`, `DEDUP UPSERT KEYS`; `docker-compose.quant.yml:35-39,52-53` (`nofile: 1048576`, `QDB_RAM_USAGE_LIMIT_BYTES=21474836480`); synthetic `NEXM.V` (`1:20`) and `NVDA.US` (`10:1`) split fixtures (`bars_1m_tests.rs:107,220`, `run_curate_bars_1m_tests.rs:377-402`). | **(1)** `run_curate_qm_bars_1m` (`tools/curate-etl/src/run_curate_qm_bars_1m.rs`, `T-185`) is not wired into `cli.rs`/`main.rs` (no `curate-qm-bars-1m` subcommand). **(2)** `MarketDataStore.fx({ timeframe: '1m' })` throws `MarketDataStoreNotImplementedError` in TS (`libs/research/src/market-data-store-duckdb.ts:1529-1530`, delegated unchanged by `createRoutedMarketDataStore` at `libs/research/src/market-data-store-routed.ts:184-186`) and `NotImplementedError` in Python (`python/stockbot/data.py:259`). **(3)** No `--from-mongo` streaming for `eodIntraday1M` (`3.40B` docs) or `qmIntraday` (`173.3M` docs). **(4)** Live `quant` preflight (`vm.max_map_count >= 1048576`, effective container `nofile = 1048576`, WAL DDL), binary-double (`0x10`) TCP ILP v2 acceptance (`tools/curate-etl/src/ilp_send.rs:15-21`), observed `NEXM.V`/`NVDA.US` comparison against retained raw `bars_1d`, and pinned PGWire 1-year `1m` read benchmark (`< 250 ms` warm / `< 1 s` cold) are all unverified. |
|
||||
| **M2.4** Versioned Feature Library (`D04` / `D11`) | **PARTIAL** | TS `registerSignal`, `runFeatureBatch`, and Zstd Parquet writer landed (`libs/research/src/feature-library.ts`); built-in `RET_1D_V1` (`feature-library.ts:2166`). | **(1)** `createDuckDbMarketDataStore().crossSection` (`libs/research/src/market-data-store-duckdb.ts:2283-2285`) throws `MarketDataStoreNotImplementedError`, blocking read-back of materialized `features/<name>/v<version>/` Parquet. **(2)** `FEATURE_INPUT_DATASETS` (`libs/research/src/feature-library.ts:61-68`) omits `'macro'` (coarse regime filters only per `DATA-CONTRACTS.md:26`) and `'corporate_actions'`, and registers only `'RET_1D_V1'`. **(3)** Python `stockbot` (`python/stockbot/__init__.py`, `data.py`, `signals.py`) lacks `cross_section` and `register_signal` (`D04`/`D11`). |
|
||||
|
||||
### 2.2 Exit Criteria (`design/MILESTONES.md` lines 100–103)
|
||||
|
||||
| Exit Criterion | Status | Evidence & Remaining Blocker |
|
||||
| --- | :---: | --- |
|
||||
| **EC-1:** Desktop Claude Code via MCP runs a fundamental + alt-data signal study and event study end-to-end, exports a `marimo check`-clean static HTML snapshot, and files a finding. | **OPEN** | All 6 MCP tools and `exportNotebookSnapshot` exist as libraries, but `scripts/research-copilot-mcp.ts` / `"mcp:research-copilot"` (`T-196`) is missing, `ceoPosts` cannot be read via `event_study` (`"post"` vs `"ceo_post"`), and no end-to-end MCP → HTML snapshot → `file_finding` verification exists. |
|
||||
| **EC-2:** Restatement fixture test proves a restated Q1 (`known_at > Q2`) never overwrites Q2 in `fundamentalsAsOf`. | **SATISFIED (Offline Fixture)** | Proven in both Rust (`tools/curate-etl/src/fundamentals_tests.rs:104`) and real-DuckDB TypeScript (`libs/data/duckdb/test/duckdb-market-data-store.test.ts:251,601-626`), both passing in sandbox and Studio test run `#1598`. |
|
||||
| **EC-3:** Split-boundary test on `NEXM.V` (`1:20`) and `NVDA.US` (`10:1`) confirms `bars_1m` session closes match raw `bars_1d` closes within `0.5%`, and 1y of `1m` bars loads in `< 250 ms` warm / `< 1 s` cold. | **OPEN (Synthetic Only)** | **Synthetic** Rust fixtures (`tools/curate-etl/src/bars_1m_tests.rs:107,220`, `run_curate_bars_1m_tests.rs:377-402`) pass for split arithmetic only and explicitly leave observed comparison against retained raw `bars_1d` open (`run_curate_bars_1m_tests.rs:396-400`). Still open on `quant`: (1) effective `vm.max_map_count >= 1048576` & container `nofile = 1048576` preflight before bulk load; (2) live QuestDB `10.2.0` binary-double (`0x10`) TCP ILP v2 acceptance; (3) observed `NEXM.V` + `NVDA.US` `bars_1m` vs. retained raw `bars_1d` close check (`<= 0.5%`); and (4) pinned 1-year single-listing PGWire benchmark (`QuestDBClient.query` → `createQuestDbIntradayBarsReader`) recording listing ID, date range, cache conditions, and expected vs. actual row counts against `< 250 ms` warm / `< 1 s` cold. |
|
||||
|
||||
---
|
||||
|
||||
## 3. Candidate Causes: Why M2 Auto Mode May Have Parked 3 Consecutive Tasks
|
||||
|
||||
No parked task receipts or Auto Mode run logs are available inside the sandbox, so **none of the four items below can be attributed to a specific parked task yet**. Separating what is directly observed in the checkout from what remains inferred pending host history/log inspection:
|
||||
|
||||
1. **Missing `T-196` desktop MCP entrypoint *(observed in checkout; branch-reset cause inferred/unverified)*:** `scripts/research-copilot-mcp.ts` and `"mcp:research-copilot"` in `package.json` are absent from the checkout, whereas `T-190` (`send-ilp`) and `curate-macro` are present. Any Auto Mode task expecting a runnable desktop MCP entrypoint would hit an immediate blocker. Whether `T-196` was dropped during a `studio/auto-*` branch reset remains **unverified** until host-side branch history is inspected (`design/m2-gap-audit.md:119`).
|
||||
2. **`docs/*` → `design/*` path drift *(observed in checkout; park attribution unverified)*:** `AGENTS.md` (L43–48), `CLAUDE.md` (L3, L7–11), `README.md` (L7, L9, L11–13, L142, L264, L435), `studio.config.json`, and older task prompts still point to `docs/*.md`, which can cause agents to fail path checks against the renamed `design/` directory.
|
||||
3. **Sandbox boundary friction for `.git`, PostgreSQL, and `quant` *(observed environment constraint; park attribution unverified)*:** Running `bun run check`, `audit:secrets`, worktree-git tests (`scripts/test/`), `PIPELINE_TEST_DATABASE_URL` (`127.0.0.1:5432`) suites, or live `quant` QuestDB checks inside the agent sandbox fails by design; tasks without explicit host/sandbox separation can park on those expected errors.
|
||||
4. **Unqueued Option B `--from-mongo` extension for M2 collections *(observed in checkout; park attribution unverified)*:** The `2026-11-30` addendum in `design/data-pipeline/rust-migration-evaluation.md` (lines 253–294) locked Option B (`tools/curate-etl --from-mongo`) for M1 and scoped M2's 6 collections (`qmFinancials`, `qmFinancials-old`, `ceoPosts`, `teData`, `eodIntraday1M`, `qmIntraday`) to M2, but `SourceCollection` (`tools/curate-etl/src/mongo_stream.rs:53-62`) still allowlists only the 8 M1 collections.
|
||||
|
||||
---
|
||||
|
||||
## 4. Concrete Blockers Needing Director Decisions
|
||||
|
||||
1. **Option B `--from-mongo` for M2 collections vs. `.bson` staging:** Should we extend `tools/curate-etl` `SourceCollection` with `--from-mongo` streaming for the 6 M2 collections (`qmFinancials`, `qmFinancials-old`, `ceoPosts`, `teData`, `eodIntraday1M`, `qmIntraday`), or close M2 in file-mode `.bson` staging?
|
||||
- *Recommended:* Extend `--from-mongo` to the 6 M2 collections (reusing the M1 `ReadOnlyMongoClient` + `ChunkedMongoRawDocumentSource` pattern) so `3.40B` `eodIntraday1M` docs never require `~500–832 GiB` of intermediate `.bson` scratch files.
|
||||
2. **Canonical `ceoPosts` event `kind` & `<out>/events` co-publishing:** Should `tools/curate-etl/src/parquet_posts.rs` switch `EVENT_KIND_POST` from `"post"` to `"ceo_post"` and co-publish alongside `curate-events` under `<out>/events/year=YYYY/` (either by writing `part-posts.parquet` **and updating both readers** — `libs/research/src/market-data-store-duckdb.ts:1448` and `python/stockbot/data.py:71` — from `events/year=*/part.parquet` to `events/year=*/*.parquet`, or by merging posts into yearly `part.parquet`), or keep posts in a separate curated root?
|
||||
- *Recommended:* Change `EVENT_KIND_POST` to `"ceo_post"`, write `events/year=YYYY/part-posts.parquet`, **and update both TS (`market-data-store-duckdb.ts:1448`) and Python (`python/stockbot/data.py:71`) readers to glob `events/year=*/*.parquet`** (verified by a combined read-back fixture with filings, earnings, and an edited CEO post in the same curated root) so `curate-events` and `curate-posts` remain independently re-runnable without hiding posts from either reader.
|
||||
3. **Live `quant` QuestDB `10.2.0` preflight, observed split check & latency gate for M2 closure:** Should M2 closure require an operator-run `quant` QuestDB `10.2.0` verification covering host/container limits (`vm.max_map_count`, `nofile`), binary-double (`0x10`) TCP ILP v2 acceptance, observed `NEXM.V` + `NVDA.US` `bars_1m` vs. retained raw `bars_1d` closes (`<= 0.5%`), and a pinned 1-year single-listing PGWire latency benchmark (`< 250 ms` warm / `< 1 s` cold), or accept synthetic-fixture closure and defer all live `quant` checks to an ops follow-up (matching the M1 `d52aa20` precedent)?
|
||||
- *Recommended:* Require a small-slice (`NEXM.V` + `NVDA.US`, 1 year) operator verification on `quant` covering all four checks above before closing M2, while deferring full `3.40B`-row backfill to an ops runbook.
|
||||
|
||||
---
|
||||
|
||||
## 5. M3 Readiness Mapping & Recommended Task Order
|
||||
|
||||
**Verdict: Do not start M3 yet.** M2 must close first, and M3's core engine, screener, and validation deliverables are unstarted on this checkout.
|
||||
|
||||
### 5.1 M3 Deliverables & Exit Criteria Readiness Map (`design/MILESTONES.md` lines 111–128)
|
||||
|
||||
| M3 Item | Status | Target Files & Current Checkout Evidence |
|
||||
| --- | :---: | --- |
|
||||
| **Tier 1 Columnar Screener** (`MILESTONES.md:112-113`) | **NOT STARTED** | Append-only `trial_ledger` SQL exists (`database/postgres/init/36-trial-ledger.sql`), and `libs/calculations/src/index.ts` exports `deflatedSharpeRatio`, `effectiveIndependentTrials`, `analyzeSignalPanel`, `eventStudy`, `evaluateRecencyGate`. No Polars/DuckDB portfolio sweep, $M_{T \times N}$ writer, or CSCV `PBO` ($S = 16$) yet. |
|
||||
| **Tier 2 Rust `financial/` Multi-Asset Upgrades** (`MILESTONES.md:114-119`) | **NOT STARTED** | `apps/stock/engine/Cargo.toml` has no `parquet`/`arrow-rs` crates yet; `apps/stock/orchestrator/src/backtest/{native-worker,candidate-sandbox}.ts` still use the single-series JSON/IPC path. Task 1 (retire `backtest_datasets` JSONB/IPC/N-API bar path), atomic timestamp-slice marks (`F06`), simultaneous `Target` sell-netting, feature side-channel, and `USD`/`CAD` Margin + corporate actions/delisting in `apps/stock/engine/src/financial/*` are all unstarted. |
|
||||
| **Validation Suite & Engine Consolidation** (`MILESTONES.md:120-123`) | **PARTIAL (SQL only)** | `vault_evaluations` table with `<= 10/year` cap & append-only triggers exists (`database/postgres/init/36-trial-ledger.sql:44-138`), and `apps/stock/analytics` / `SimulationExecution` are already absent from the repo. Purged Walk-Forward/CPCV, stability surface, ADV capacity, US/CA factor exposure, human Vault Holdout Gate workflow, and retirement of legacy `f64` `BacktestEngine` (`apps/stock/engine/src/backtest/engine.rs:17`, `apps/stock/engine/src/api/backtest.rs:13`) remain **NOT STARTED**. |
|
||||
| **M3 EC-1:** Rust unit + differential accounting fixtures (`MILESTONES.md:126`) | **OPEN** | Atomic hedged mark neutrality, 100%-invested `Sell A + Buy B` target rotation, split + dividend 8-decimal conservation, USD/CAD margin interest, TSX board-lot sizing, and `SIVB` delisting liquidation fixtures are not yet implemented. |
|
||||
| **M3 EC-2:** 20y US+CA daily backtest (`~5,000+` listings) in `< 30 s` on `quant` (`MILESTONES.md:127`) | **OPEN** | Blocked on Tier 2 Parquet/Arrow-rs path + multi-asset engine upgrades. |
|
||||
| **M3 EC-3:** Real M2 signal via `register_signal` end-to-end (`MILESTONES.md:128`) | **OPEN** | Blocked on M2 Python `register_signal` + `crossSection` read-back and M3 Tier 1/Tier 2/CPCV/Vault gate. |
|
||||
|
||||
### 5.2 Ordered Task List to Finish M2 (8 Tasks)
|
||||
|
||||
1. **Restore `T-196` desktop MCP entrypoint & wire routed intraday store:** Add `scripts/research-copilot-mcp.ts` + `"mcp:research-copilot"` in `package.json`, and update `openResearchCopilotStore` (`libs/data/duckdb/src/research-copilot-store.ts`) to compose `createRoutedMarketDataStore` + `createQuestDbIntradayBarsReader` when QuestDB config is present.
|
||||
2. **Fix `ceoPosts` `kind = 'ceo_post'`, `<out>/events` co-publishing & reader globs:** Change `EVENT_KIND_POST` in `tools/curate-etl/src/parquet_posts.rs` to `"ceo_post"`, co-publish `ceoPosts` under `<out>/events/year=YYYY/` (either writing `part-posts.parquet` and updating both `libs/research/src/market-data-store-duckdb.ts:1448` and `python/stockbot/data.py:71` to glob `events/year=*/*.parquet`, or merging into yearly `part.parquet`), and add a combined read-back fixture containing filings, earnings, and an edited CEO post in the same curated root.
|
||||
3. **Implement `MarketDataStore.macroAsOf`, `crossSection`, and `fx('1m')`:** Implement DuckDB read-back for `macro/part.parquet` (`macroAsOf`, enforcing/documenting the `design/DATA-CONTRACTS.md:26` coarse lagged regime-filter-only limit since `teData` lacks release vintages) and versioned `features/<name>/v<version>/` (`crossSection`) in `libs/research/src/market-data-store-duckdb.ts`, and route `fx({ timeframe: '1m' })` to QuestDB `fx_1m` in `libs/research/src/market-data-store-routed.ts`.
|
||||
4. **Wire `curate-qm-bars-1m` CLI & expand Feature Library inputs:** Expose `curate-qm-bars-1m` in `tools/curate-etl/src/{cli,main}.rs`, add `'macro'` (restricted to lagged regime filters per `DATA-CONTRACTS.md:26` until vintage data exists) and `'corporate_actions'` to `FEATURE_INPUT_DATASETS` in `libs/research/src/feature-library.ts`, and extend MCP `analyze_signal` to support materialized `features` (and `ceoPosts` / regime-only `macro` as needed).
|
||||
5. **Add Python `stockbot` M2 parity & `register_signal` (`D04`/`D11`):** Expose `fundamentals_as_of`, `macro_as_of` (regime-only), `cross_section`, `fx(..., timeframe='1m')`, and `register_signal(...)` in `python/stockbot/` with offline `pytest` coverage.
|
||||
6. **Extend `curate-etl --from-mongo` to the 6 M2 collections (subject to Director Decision 1):** Add `qmFinancials`, `qmFinancials-old` (with `--qm-financials-old` merge), `ceoPosts`, `teData`, `eodIntraday1M`, and `qmIntraday` to `SourceCollection` in `tools/curate-etl/src/mongo_stream.rs`.
|
||||
7. **Add M2 Exit Criterion 1 end-to-end verification & doc path cleanup:** Add a CLI/MCP wrapper + end-to-end test covering MCP study → `marimo check`-clean HTML snapshot (`exportNotebookSnapshot`) → `file_finding`, and update stale `docs/` links in `AGENTS.md`, `CLAUDE.md`, `README.md`, and `studio.config.json` to `design/`.
|
||||
8. **Operator `quant` QuestDB `10.2.0` preflight, observed split check & latency benchmark (Exit Criterion 3):** Before bulk load, verify on `quant` effective `vm.max_map_count >= 1048576`, container `ulimits.nofile = 1048576`, memory limits, and `getM2IntradayDDL()` WAL tables; run `send-ilp` on a small `NEXM.V` + `NVDA.US` 1-year slice to verify `0x10` binary-double acceptance and `wal_tables()` health via PGWire; compare observed `NEXM.V` (`1:20`) and `NVDA.US` (`10:1`) `bars_1m` session closes against retained raw `bars_1d` closes (`<= 0.5%`); and run a pinned 1-year single-listing `1m` benchmark through `QuestDBClient.query` → `createQuestDbIntradayBarsReader` (re-verifying via `createRoutedMarketDataStore` once wired) recording listing ID, date range, cache conditions, and expected vs. actual row counts against `< 250 ms` warm / `< 1 s` cold.
|
||||
|
||||
### 5.3 Initial M3 Prerequisite Sequence (Once M2 Closes)
|
||||
|
||||
1. **Retire JSON-over-Postgres/IPC/N-API bar path (M3 Task 1):** Add `parquet`/`arrow-rs` to `apps/stock/engine/Cargo.toml`, store `(hash, manifest, parquet_paths)` in `backtest_datasets`, and lift single-series TS gates in `native-worker.ts`.
|
||||
2. **Tier 1 Columnar Screener & CSCV PBO (`S = 16`):** Implement CSCV `PBO` and Purged Walk-Forward/CPCV in `libs/calculations`, plus vectorized Polars/DuckDB portfolio sweeps logging $M_{T \times N}$ matrices to `trial_ledger`.
|
||||
3. **Tier 2 Rust `financial/` multi-asset upgrades & legacy retirement:** Implement atomic timestamp-slice marks (`F06`), simultaneous `Target` sell-netting, feature side-channel, `USD`/`CAD` Margin + corporate-action/delisting accounting (with all 6 M3 EC-1 fixtures), human Vault Holdout Gate workflow, and retirement of legacy `f64` `BacktestEngine`.
|
||||
175
test/unit/m2-completion-audit-doc.test.ts
Normal file
175
test/unit/m2-completion-audit-doc.test.ts
Normal file
|
|
@ -0,0 +1,175 @@
|
|||
import { existsSync, readFileSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { describe, expect, test } from 'bun:test';
|
||||
|
||||
// Guards the T-204 M2 completion audit (design/m2-completion-audit.md) against
|
||||
// citation rot: every repo path it cites must resolve, every symbol it reports as
|
||||
// landed must still live in the file it names, and the report must keep host-only
|
||||
// verification marked pending. Gaps the audit reports as missing are deliberately
|
||||
// NOT asserted, so landing an M2 fix never breaks this test.
|
||||
|
||||
const repoRoot = fileURLToPath(new URL('../../', import.meta.url));
|
||||
const audit = readFileSync(join(repoRoot, 'design/m2-completion-audit.md'), 'utf8');
|
||||
const designIndex = readFileSync(join(repoRoot, 'design/README.md'), 'utf8');
|
||||
|
||||
// Cited as the gap itself (absent today), as already-retired code, as a sandbox env
|
||||
// note, or as the stale pre-rename docs/ location.
|
||||
const CITED_AS_ABSENT = new Set([
|
||||
'scripts/research-copilot-mcp.ts',
|
||||
'apps/stock/analytics',
|
||||
'python/.venv',
|
||||
'docs',
|
||||
'docs/',
|
||||
'docs/*.md',
|
||||
]);
|
||||
|
||||
function expandBraces(path: string): string[] {
|
||||
const match = /^(.*)\{([^}]+)\}(.*)$/.exec(path);
|
||||
if (!match) {return [path];}
|
||||
const [, prefix, options, suffix] = match;
|
||||
return options!.split(',').flatMap((option) => expandBraces(`${prefix}${option}${suffix}`));
|
||||
}
|
||||
|
||||
function citedRepoPaths(markdown: string): string[] {
|
||||
const spans = [...markdown.matchAll(/`([^`\s]+)`/g)].map((m) => m[1]!);
|
||||
const pathLike = spans.filter(
|
||||
(span) =>
|
||||
/^(apps|libs|tools|python|scripts|design|test|database|docs)\//.test(span) ||
|
||||
/^[A-Za-z0-9_.-]+\.(md|json|yml)$/.test(span)
|
||||
);
|
||||
return [
|
||||
...new Set(
|
||||
pathLike
|
||||
// Strip `:line`, `:a-b`, and `:a-b,c` suffixes and trailing globs.
|
||||
.map((span) => span.replace(/:[\d,-]+$/, '').replace(/\/\*$/, ''))
|
||||
.flatMap(expandBraces)
|
||||
),
|
||||
].sort();
|
||||
}
|
||||
|
||||
describe('design/m2-completion-audit.md citations', () => {
|
||||
test('cites only repo paths that exist, except those it reports as absent', () => {
|
||||
const cited = citedRepoPaths(audit);
|
||||
expect(cited.length).toBeGreaterThan(40);
|
||||
|
||||
const missing = cited.filter((p) => !CITED_AS_ABSENT.has(p) && !existsSync(join(repoRoot, p)));
|
||||
expect(missing).toEqual([]);
|
||||
});
|
||||
|
||||
test('docs/ stays absent so the documentation path-drift note holds', () => {
|
||||
expect(existsSync(join(repoRoot, 'docs'))).toBe(false);
|
||||
expect(existsSync(join(repoRoot, 'design/MILESTONES.md'))).toBe(true);
|
||||
});
|
||||
|
||||
// Symbols the audit reports as LANDED, keyed by the file it attributes them to.
|
||||
const landedSymbols: Array<[file: string, symbol: string | RegExp]> = [
|
||||
['libs/research/src/mcp/copilot-server.ts', 'createResearchCopilotMcpServer'],
|
||||
['libs/research/src/mcp/host/stdio-host.ts', 'runResearchCopilotStdioHost'],
|
||||
['libs/data/postgres/src/research-copilot-executor.ts', 'openResearchCopilotExecutor'],
|
||||
['libs/data/duckdb/src/research-copilot-store.ts', 'openResearchCopilotStore'],
|
||||
['libs/data/duckdb/src/research-copilot-store.ts', 'vaultOperatorAuthorized: false'],
|
||||
['libs/research/src/mcp/tools/query-data.ts', 'createQueryDataTool'],
|
||||
['libs/research/src/notebook-snapshot.ts', 'exportNotebookSnapshot'],
|
||||
['libs/research/src/notebook-snapshot-node.ts', 'exportNotebookSnapshot'],
|
||||
['libs/research/src/market-data-store-duckdb.ts', 'fundamentalsAsOf'],
|
||||
['libs/research/src/market-data-store-routed.ts', 'createRoutedMarketDataStore'],
|
||||
['libs/research/src/market-data-store-questdb.ts', 'createQuestDbIntradayBarsReader'],
|
||||
['libs/research/src/feature-library.ts', 'registerSignal'],
|
||||
['libs/research/src/feature-library.ts', 'runFeatureBatch'],
|
||||
['libs/research/src/feature-library.ts', 'export const RET_1D_V1'],
|
||||
['libs/research/src/feature-library.ts', 'export const FEATURE_INPUT_DATASETS'],
|
||||
['libs/data/questdb/src/schema.ts', 'M2_INTRADAY_SCHEMAS'],
|
||||
['libs/data/questdb/src/schema.ts', 'getM2IntradayDDL'],
|
||||
// The schema is declarative; DDL keywords are rendered from these fields.
|
||||
['libs/data/questdb/src/schema.ts', "capacity: 65536, cache: false"],
|
||||
['libs/data/questdb/src/schema.ts', "partitionBy: 'MONTH'"],
|
||||
['libs/data/questdb/src/schema.ts', 'dedupUpsertKeys'],
|
||||
['tools/curate-etl/src/cli.rs', 'SendIlp('],
|
||||
['tools/curate-etl/src/cli.rs', 'CurateFundamentals('],
|
||||
['tools/curate-etl/src/cli.rs', 'CuratePosts('],
|
||||
['tools/curate-etl/src/cli.rs', 'CurateMacro('],
|
||||
['tools/curate-etl/src/cli.rs', 'CurateBars1m('],
|
||||
['tools/curate-etl/src/cli.rs', 'CurateFx1m('],
|
||||
['tools/curate-etl/src/main.rs', 'run_send_ilp('],
|
||||
['tools/curate-etl/src/mongo_stream.rs', 'pub enum SourceCollection'],
|
||||
['tools/curate-etl/src/run_curate_posts.rs', 'EventsDatasetExists'],
|
||||
['tools/curate-etl/src/run_curate_qm_bars_1m.rs', /pub fn run_curate_qm_bars_1m\b/],
|
||||
['tools/curate-etl/src/ilp_send_tests.rs', 'fn tcp_sends_separate_shards_and_half_closes'],
|
||||
[
|
||||
'tools/curate-etl/src/fundamentals_tests.rs',
|
||||
'fn restatement_of_q1_after_q2_updates_q1_and_ttm_without_overwriting_q2',
|
||||
],
|
||||
[
|
||||
'tools/curate-etl/src/run_curate_bars_1m_tests.rs',
|
||||
'fn split_boundary_nvda_and_nexm_match_raw_bars_1d_closes',
|
||||
],
|
||||
['libs/data/duckdb/test/duckdb-market-data-store.test.ts', 'restatement non-overwrite'],
|
||||
['docker-compose.quant.yml', 'hard: 1048576'],
|
||||
['docker-compose.quant.yml', 'QDB_RAM_USAGE_LIMIT_BYTES=21474836480'],
|
||||
['database/postgres/init/37-research-findings.sql', 'provider_caveats'],
|
||||
['database/postgres/init/36-trial-ledger.sql', 'vault_evaluations'],
|
||||
];
|
||||
|
||||
test.each(landedSymbols)('%s contains %p as the audit reports', (file, symbol) => {
|
||||
const source = readFileSync(join(repoRoot, file), 'utf8');
|
||||
if (typeof symbol === 'string') {expect(source).toContain(symbol);}
|
||||
else {expect(source).toMatch(symbol);}
|
||||
});
|
||||
|
||||
test('every MCP tool the audit counts is registered in the copilot server', () => {
|
||||
const server = readFileSync(join(repoRoot, 'libs/research/src/mcp/copilot-server.ts'), 'utf8');
|
||||
const tools = ['search_symbols', 'query_data', 'analyze_signal', 'event_study', 'file_finding', 'read_knowledge'];
|
||||
for (const tool of tools) {expect(server).toContain(`'${tool}'`);}
|
||||
expect(audit).toContain('6 MCP tools');
|
||||
});
|
||||
|
||||
test('the synthetic split fixture still documents the observed-data comparison as open', () => {
|
||||
// The audit's EC-3 "synthetic only" status rests on this scope note.
|
||||
const fixture = readFileSync(join(repoRoot, 'tools/curate-etl/src/run_curate_bars_1m_tests.rs'), 'utf8');
|
||||
expect(fixture).toMatch(/Does NOT prove .* against retained `bars_1d` data/);
|
||||
expect(audit).toMatch(/OPEN \(Synthetic Only\)/);
|
||||
});
|
||||
});
|
||||
|
||||
describe('design/m2-completion-audit.md structure and honesty', () => {
|
||||
test('holds M3 and covers every section the task requires', () => {
|
||||
expect(audit).toMatch(/HOLD M3/);
|
||||
expect(audit).toMatch(/^## 1\. Verification Gate Results/m);
|
||||
expect(audit).toMatch(/^## 2\. M2 Deliverables & Exit Criteria Matrix/m);
|
||||
expect(audit).toMatch(/^## 3\. Candidate Causes/m);
|
||||
expect(audit).toMatch(/^## 4\. Concrete Blockers Needing Director Decisions/m);
|
||||
expect(audit).toMatch(/^## 5\. M3 Readiness Mapping/m);
|
||||
});
|
||||
|
||||
test('covers all four M2 deliverables and all three M2 exit criteria', () => {
|
||||
for (const area of ['M2.1', 'M2.2', 'M2.3', 'M2.4']) {expect(audit).toContain(`**${area}**`);}
|
||||
for (const ec of ['EC-1', 'EC-2', 'EC-3']) {expect(audit).toContain(`**${ec}:**`);}
|
||||
for (const ec of ['M3 EC-1', 'M3 EC-2', 'M3 EC-3']) {expect(audit).toContain(`**${ec}:**`);}
|
||||
});
|
||||
|
||||
test('keeps host-only verification pending and parking causes unattributed', () => {
|
||||
expect(audit).toMatch(/\|\s*\*\*PENDING\*\*\s*\|/);
|
||||
expect(audit).toContain('none of the four items below can be attributed to a specific parked task');
|
||||
expect(audit).not.toMatch(/EC-3[^|]*\|\s*\*\*SATISFIED/);
|
||||
});
|
||||
|
||||
test('asks the director three decisions, each with a recommendation', () => {
|
||||
const decisions = audit.split(/^## 4\./m)[1]!.split(/^## 5\./m)[0]!;
|
||||
expect(decisions.match(/^\d\. \*\*/gm)?.length).toBe(3);
|
||||
expect(decisions.match(/\*Recommended:\*/g)?.length).toBe(3);
|
||||
});
|
||||
|
||||
test('carries the teData regime-filter-only limit into macro follow-ups', () => {
|
||||
expect(audit).toContain('design/DATA-CONTRACTS.md:26');
|
||||
expect(readFileSync(join(repoRoot, 'design/DATA-CONTRACTS.md'), 'utf8').split('\n')[25]).toContain(
|
||||
'final-revised values only'
|
||||
);
|
||||
});
|
||||
|
||||
test('is indexed exactly once in design/README.md', () => {
|
||||
const rows = designIndex.split('\n').filter((line) => line.includes('(m2-completion-audit.md)'));
|
||||
expect(rows).toHaveLength(1);
|
||||
expect(rows[0]).toMatch(/^\| \*\*\[m2-completion-audit\.md\]\(m2-completion-audit\.md\)\*\* \|.*\|.*\|$/);
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue