stock-bot/design/m2-master-audit.md

111 lines
24 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.

# Milestone M2 Master Audit & Closure Plan (T-208)
**Bottom Line:** **HOLD M2 CLOSURE / HOLD M3 — Core M2 infrastructure is ~80% landed on current `master` (including `T-190` `send-ilp`, `T-205` `mcp:research-copilot`, `T-206` `curate-qm-bars-1m`, and `T-207` `curate-macro`), with 6 concrete code/wiring gaps and 1 host/`quant` verification gate remaining before M2 can close.**
All sandbox-runnable TypeScript, ESLint, contract, and Rust native gates passed offline on the audited checkout (`0` errors, `0` warnings; `1,563` Rust tests across `58` suites and `1,050` targeted M2 Bun tests across `65` files). Exit Criterion 2 (2D PIT Q1-after-Q2 restatement non-overwrite) is **Done** in both Rust and real-DuckDB TypeScript fixtures; Exit Criteria 1 and 3 remain **Partial** pending event-kind/glob alignment, `MarketDataStore` read-path completions (`macroAsOf`, `crossSection`, `fx('1m')`), Python `stockbot` M2 parity, `notebook:snapshot` CLI + E2E test, and operator-run host/`quant` QuestDB `10.2.0` verification.
> **Scope, Provenance & Constraints**
> - **Read-only, docs-only audit:** Only `design/m2-master-audit.md` and `design/README.md` are modified. Zero production code, schema, test, build config, or CI changes (project CI is off; zero CI workflows proposed).
> - **Audited checkout & `master` SHA:** Audited directly against source files in worktree `feat/m2-audit` branched from `master`. Because worktree `.git` metadata lives outside the agent sandbox by design, the exact `master` commit SHA is **PENDING** host-side `git rev-parse HEAD` verification.
> - **Supersedes prior T-203/T-204 snapshots:** Unlike `design/m2-completion-audit.md` (T-204), current `master` now includes `T-205` (`scripts/research-copilot-mcp.ts` + `"mcp:research-copilot"`), `T-206` (`curate-qm-bars-1m` CLI), and `T-207` (`curate-macro` CLI). Every status below was re-verified from current source files and test runs.
> - **Documentation path drift:** Canonical specs reside under `design/*.md`, 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` (lines 46–54) still reference `docs/*.md`. Cleanup is queued in `m2-ec1-snapshot-cli-and-doc-paths`.
> - **Strict database safety:** Zero connections to QA MongoDB (`27017/stock`) or QA PostgreSQL (`5432/trading_bot`).
---
## 1. Baseline Verification: M1 (`d52aa20`), `T-127` & Option B Rust Architecture
| Baseline Item | Verified State on `master` | Impact on M2 |
| --- | --- | --- |
| **Accepted M1 (`d52aa20bff3f5c259fb6e2bcfc2d3a78ad5224b1`)** | Landed and intact: security-master & research SQL schemas (`database/postgres/init/34-security-master.sql`, `35-security-master-exchange-seed.sql`, `36-trial-ledger.sql`, `37-research-findings.sql`), Rust Option B `--from-mongo` runners for all 6 M1 commands (`tools/curate-etl/src/run_mongo.rs:1-100`, `mongo_stream.rs`, `mongo_safety.rs`), and Python `stockbot` M1 SDK (`python/stockbot/{__init__,calculations,data,ledger,signals,vault}.py`). | Solid foundation; M2 builds directly on these schemas, adapters, and `ReadOnlyMongoClient`. |
| **`T-127` (Deferred M1 Equity Eligibility & Vault File Isolation)** | Explicitly accepted as deferred in backlog per settled director decision (`d52aa20`). | **Non-blocking for M2.** Does not block EC-1, EC-2, or EC-3. |
| **Settled Rust ETL / `data-pipeline` Decision (Option B)** | Confirmed in `design/data-pipeline/rust-migration-evaluation.md` (including `2026-11-30` Addendum §§A.1–A.4): keep `apps/stock/data-pipeline` in TypeScript (`42` files, `20,349` LOC) for security master Passes 1–6, TSV export, probes, and BullMQ/Hono; keep bulk curation in Rust `tools/curate-etl` (`mongodb = "=3.10.2"` sync `RawDocumentBuf` cursors). | M2's 6 collections (`qmFinancials`, `qmFinancials-old`, `ceoPosts`, `teData`, `eodIntraday1M`, `qmIntraday`) still lack `--from-mongo` wiring in `tools/curate-etl/src/mongo_stream.rs:53-62` (currently 8 M1 collections only). |
| **Post-T-204 Merges (`T-190`, `T-205`, `T-206`, `T-207`)** | All four verified landed: `T-190` `send-ilp` (`tools/curate-etl/src/{ilp_send,cli,main}.rs`), `T-205` desktop MCP stdio entrypoint (`scripts/research-copilot-mcp.ts`, `package.json:56`, `scripts/test/research-copilot-mcp.test.ts`), `T-206` `curate-qm-bars-1m` (`tools/curate-etl/src/{run_curate_qm_bars_1m,cli,main}.rs`), and `T-207` `curate-macro` (`tools/curate-etl/src/{run_curate_macro,cli,main}.rs`). | Removes the T-204 desktop-launch and `curate-qm-bars-1m` CLI blockers. |
---
## 2. Verification Gate Evidence & Research Governance
### 2.1 Sandbox Offline Runs (Executed on `feat/m2-audit`, Zero Network / Zero QA DB Contact)
| Gate / Suite | Command | Exit | 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,563` passed, `0` failed, `4` ignored across `58` suites (`engine` `150` passed + `curate-etl` unit & integration suites including `ilp_send_tests.rs`, `fundamentals_tests.rs`, `parquet_fundamentals_tests.rs`, `run_curate_bars_1m_tests.rs`, `run_curate_qm_bars_1m`, `run_curate_macro`) |
| **Targeted M2 Suites** | `bun test scripts/test/research-copilot-mcp.test.ts scripts/test/security.test.ts libs/research/test/ libs/data/duckdb/test/ libs/data/questdb/test/ libs/data/postgres/test/research-copilot-executor.test.ts libs/data/postgres/test/research-copilot-executor-edge.test.ts` | `0` | **PASS** — `1,050` pass, `0` fail (`80,699` expects, `65` files; includes `7/7` pass in `scripts/test/research-copilot-mcp.test.ts`, real-DuckDB `fundamentalsAsOf` restatement suite, and MCP Vault-fence suite) |
| **Python SDK** | `python3 -m pytest python/tests` | `1` | **SKIPPED (env)** — `/usr/bin/python3: No module named pytest` in sandbox |
### 2.2 Studio Unsandboxed & Host-Only Verification Boundary
| Verification Layer | Command / Scope | Status | Notes |
| --- | --- | :---: | --- |
| **Studio Unsandboxed Runner** | `bun run build` and `bun --env-file=/home/boki/.studio/test-env/stock-bot.env test && CARGO_BUILD_JOBS=2 cargo test --workspace --lib --offline` | **Authoritative post-handoff** | Covers workspace build, `audit:secrets`, worktree-git tooling tests (`scripts/test/`), integration tests, and isolated `stock_bot_safety*` PostgreSQL suites unreachable inside the sandbox. |
| **Host Full Check & `master` SHA** | `git rev-parse HEAD`, `CARGO_BUILD_JOBS=2 bun run check`, `bun --env-file=/home/boki/.studio/test-env/stock-bot.env test test/postgres/` | **PENDING (host)** | Required with retained logs in `design/m2-close-evidence.md` before M2 closure. |
| **`quant` (`10.0.0.51`) & Workstation Live Gates** | Read-only QA Mongo M2 field-shape probe, QuestDB `10.2.0` preflight (`vm.max_map_count`, `nofile`), `0x10` TCP ILP v2 commit, observed `NEXM.V`/`NVDA.US` split check, 1y `1m` PGWire latency, and desktop Claude Code + real `marimo` EC-1 receipt | **PENDING (host/`quant`)** | Tracked in `m2-host-quant-verification-and-closure`. |
### 2.3 Research Governance & Replay / Financial Invariants Verified
- **Economic owner & durable inputs:** Quant data curation owns immutable Zstd Parquet partitions (`bars_1d`, `adj_factors`, `corporate_actions`, `events`, `shorts`, `fx_1d`, `fundamentals_pit`, `macro`, `features/<name>/v<version>`) and published QuestDB ILP v2 shard files; PostgreSQL owns append-only `trial_ledger`, `vault_evaluations`, `findings`, and `provider_caveats` (`database/postgres/init/36-trial-ledger.sql`, `37-research-findings.sql`, protected by `reject_research_evidence_mutation()`).
- **Holdout Vault & `known_at` boundaries:** Verified by `libs/research/test/mcp-query-data.test.ts` (rejects `scope`/`vault_evaluation_only`, clamps bounds strictly `< vaultCutoffTs`, drops leaky post-cutoff rows) and `openResearchCopilotStore` (`libs/data/duckdb/src/research-copilot-store.ts:40`, hardcoding `vaultOperatorAuthorized: false`).
- **Baselines & single-source metrics:** `@stock-bot/calculations` (`144/144` tests passing) remains the sole authority for Sharpe/Sortino/IC/Newey-West/DSR/event-study/recency math; `RET_1D_V1` in `libs/research/src/feature-library.ts:29` documents its zero-return comparison baseline and zero-cost assumption.
- **2D PIT restatement & synthetic split-boundary conservation:**
- Q1 restated after Q2 never overwrites Q2 and updates TTM: verified in Rust (`tools/curate-etl/src/fundamentals_tests.rs:104` `restatement_of_q1_after_q2_updates_q1_and_ttm_without_overwriting_q2`, `parquet_fundamentals_tests.rs:1107` `restatement_of_q1_after_q2_preserves_q2_on_disk_and_updates_ttm`) and real-DuckDB TypeScript (`libs/data/duckdb/test/duckdb-market-data-store.test.ts:251`).
- `NVDA.US` (`10:1`) and `NEXM.V` (`1:20`) split-unadjustment conservation within `0.5%`: verified on **synthetic** fixtures (`tools/curate-etl/src/run_curate_bars_1m_tests.rs:402` `split_boundary_nvda_and_nexm_match_raw_bars_1d_closes`); observed comparison against retained raw `bars_1d` closes remains open on `quant`.
- **Database safety & execution boundary:** Read-only MongoDB/PostgreSQL guards (`assertEnvironmentSafety()`, `MongoDBClient` `mongoReadOnly: true`, Rust `mongo_safety.rs` + sealed `ReadOnlyMongoClient`) remain intact. **Paper and live execution write access is strictly absent from all M2 MCP/research surfaces and remains out of scope until M5.**
---
## 3. Milestone M2 Deliverables & Exit Criteria Matrix
### 3.1 Deliverables (`design/MILESTONES.md` lines 87–98)
| Deliverable | Status | Landed on `master` (Exact Paths, Symbols & Tests) | Missing / Remaining Gaps |
| --- | :---: | --- | --- |
| **M2.1** MCP Server & Notebook Snapshots | **Partial** | - **T-205 landed:** Runnable stdio entrypoint `runResearchCopilotMcp` in `scripts/research-copilot-mcp.ts:77`, `"mcp:research-copilot"` in `package.json:56`, `7/7` tests in `scripts/test/research-copilot-mcp.test.ts`.<br>- All 6 MCP tools (`search_symbols`, `query_data`, `analyze_signal`, `event_study`, `file_finding`, `read_knowledge`) in `libs/research/src/mcp/tools/` + `createResearchCopilotMcpServer` (`libs/research/src/mcp/copilot-server.ts`) + `parseResearchCopilotHostConfig` / `runResearchCopilotStdioHost` (`libs/research/src/mcp/host/stdio-host.ts`).<br>- Real Postgres executor (`openResearchCopilotExecutor` in `libs/data/postgres/src/research-copilot-executor.ts`) + real DuckDB store (`openResearchCopilotStore` in `libs/data/duckdb/src/research-copilot-store.ts:33`) + read-only `library.yml` card reader (`libs/research/src/mcp/adapters/library-cards.ts`) + `database/postgres/init/37-research-findings.sql`.<br>- `exportNotebookSnapshot` & Node subprocess adapter (`libs/research/src/notebook-snapshot.ts`, `libs/research/src/notebook-snapshot-node.ts:67`, `libs/research/test/notebook-snapshot*.test.ts`). | 1. `openResearchCopilotStore` (`libs/data/duckdb/src/research-copilot-store.ts:37`) and `stdio-host.ts:49-79` open DuckDB-only; optional `RESEARCH_MCP_QUESTDB_*` config + `createRoutedMarketDataStore` composition is missing.<br>2. `analyze_signal` (`libs/research/src/mcp/tools/analyze-signal.ts:121-123`) supports only `source: 'shorts' \| 'fundamentals'` (no `source: 'feature'` for versioned Feature Library signals).<br>3. No runnable `scripts/export-notebook-snapshot.ts` / `"notebook:snapshot"` CLI wrapping `@stock-bot/research/notebook-snapshot-node`.<br>4. No automated E2E stdio test covering `search_symbols` → `query_data` → `analyze_signal` → `event_study` (with `ceo_post`) → `exportNotebookSnapshot` → `file_finding` → `read_knowledge`.<br>5. No `apps/stock/web-api` SSE wrapper (recommended deferred to M4; see §4). |
| **M2.2** PIT Fundamentals, `ceoPosts` & Lagged `teData` | **Partial** | - File-mode Rust CLIs wired in `tools/curate-etl/src/cli.rs` & `main.rs`: `curate-fundamentals` (`cli.rs:102,1636`, `run_curate_fundamentals.rs`), `curate-posts` (`cli.rs:101,1317`, `run_curate_posts.rs`), and **T-207** `curate-macro` (`cli.rs:103,1689`, `run_curate_macro.rs`).<br>- Real-DuckDB `fundamentalsAsOf` (`libs/research/src/market-data-store-duckdb.ts:2287`, `libs/data/duckdb/test/duckdb-market-data-store.test.ts:251`).<br>- 2D PIT restatement tests (`fundamentals_tests.rs:104`, `parquet_fundamentals_tests.rs:1107`). | 1. **`ceoPosts` event-kind & partition mismatch:** `EVENT_KIND_POST = "post"` (`tools/curate-etl/src/parquet_posts.rs:22`) mismatches `'ceo_post'` expected by `market-data-store-duckdb.ts` and `python/stockbot/data.py:21`; `run_curate_posts.rs:133` fails with `EventsDatasetExists` when `<out>/events` exists from `curate-events`; both `market-data-store-duckdb.ts:1448` and `python/stockbot/data.py:71` glob only `events/year=*/part.parquet` instead of `events/year=*/*.parquet`.<br>2. `MarketDataStore.macroAsOf` throws `MarketDataStoreNotImplementedError` (`libs/research/src/market-data-store-duckdb.ts:2294-2296`).<br>3. `CurateFundamentalsArgs` (`tools/curate-etl/src/run_curate_fundamentals.rs:113-118`) accepts only a single `--qm-financials` path (no `--qm-financials-old` merge or `--curate-inputs` resolution).<br>4. `export-curate-inputs.ts:20-24` does not emit `listing_venues.tsv` (`us_tsx` / `tsxv_cse`).<br>5. `SourceCollection` (`mongo_stream.rs:53-62`), `RAW_BSON_EXPORT_COLLECTIONS` (`export-raw-bson.ts:11-20`), and `FIELD_SHAPE_PROBE_COLLECTIONS` (`source-field-shapes.ts:8-17`) allowlist only the 8 M1 collections (missing `qmFinancials`, `qmFinancials-old`, `ceoPosts`, `teData`).<br>6. `python/stockbot/data.py` lacks `fundamentals_as_of` and `macro_as_of`. |
| **M2.3** QuestDB `10.2.0` Intraday & `send-ilp` | **Partial** | - **T-190 landed:** `send-ilp` multi-socket TCP sender (`tools/curate-etl/src/ilp_send.rs`, `cli.rs:104,2461`, `main.rs:22`, `ilp_send_tests.rs`).<br>- **T-206 landed:** `curate-qm-bars-1m` CLI (`tools/curate-etl/src/run_curate_qm_bars_1m.rs`, `cli.rs:99,2277`, `main.rs:39`) alongside `curate-bars-1m` (`cli.rs:98,2110`) and `curate-fx-1m` (`cli.rs:100,2381`).<br>- QuestDB `10.2.0` query layer, ILP v2 writer, and opt-in `M2_INTRADAY_SCHEMAS` / `getM2IntradayDDL()` (`libs/data/questdb/src/schema.ts:13-63,139`, `libs/data/questdb/test/`).<br>- Vault-fenced QuestDB `bars('1m')` reader (`libs/research/src/market-data-store-questdb.ts`) + `createRoutedMarketDataStore` (`libs/research/src/market-data-store-routed.ts`).<br>- `docker-compose.quant.yml:30-45` (`nofile: 1048576`, `QDB_RAM_USAGE_LIMIT_BYTES=21474836480`, `mem_limit: 28g`). | 1. `fx({ timeframe: '1m' })` throws `MarketDataStoreNotImplementedError` in TS (`libs/research/src/market-data-store-duckdb.ts:1529-1534`, delegated unchanged by `market-data-store-routed.ts:184-186`) and `NotImplementedError` in Python (`python/stockbot/data.py:258-259`); `market-data-store-questdb.ts` reads `bars_1m` only (no `fx_1m` reader).<br>2. `getM2IntradayDDL()` (`libs/data/questdb/src/schema.ts:139`) is pure/opt-in with no runnable initializer script/helper wired to apply it.<br>3. No `--from-mongo` streaming in `mongo_stream.rs` / `run_mongo.rs` (and no allowlist entries in `export-raw-bson.ts` / `source-field-shapes.ts`) for `eodIntraday1M` (`3.40B`) or `qmIntraday` (`173.3M`).<br>4. Live `quant` preflight (`vm.max_map_count`, `nofile`), `0x10` binary-double TCP ILP acceptance (`ilp_send.rs:15-21`), observed `NEXM.V`/`NVDA.US` split check, and 1y `1m` PGWire latency benchmark are unverified. |
| **M2.4** Versioned Feature Library (`D04` / `D11`) | **Partial** | - Declarative DuckDB SQL feature definitions, immutable `registerSignal`, Vault-fenced yearly Zstd Parquet `runFeatureBatch`, and built-in `RET_1D_V1` in `libs/research/src/feature-library.ts` (`libs/research/test/feature-library.test.ts`). | 1. `MarketDataStore.crossSection` throws `MarketDataStoreNotImplementedError` (`libs/research/src/market-data-store-duckdb.ts:2283-2285`), blocking read-back of `features/<name>/v<version>/year=*/part.parquet`.<br>2. `FEATURE_INPUT_DATASETS` (`libs/research/src/feature-library.ts:61-68`) omits `'macro'` and `'corporate_actions'`.<br>3. Python `stockbot` (`python/stockbot/{__init__,data,signals}.py`) lacks `register_signal(...)`, batch feature materialization, and `cross_section(...)`. |
### 3.2 Exit Criteria (`design/MILESTONES.md` lines 100–103)
| Exit Criterion | Status | Verified Evidence & Remaining Work |
| --- | :---: | --- |
| **EC-1:** Desktop Claude Code via MCP executes a fundamental + alt-data signal study and event study end-to-end, exports a `marimo check`-clean static HTML snapshot, and files a finding. | **Partial** | **Landed:** `scripts/research-copilot-mcp.ts` (`mcp:research-copilot`) + all 6 MCP tools + `exportNotebookSnapshot`.<br>**Missing:** `ceo_post` event compatibility (`m2-ceo-posts-events-compat`), `notebook:snapshot` CLI + automated E2E stdio test (`m2-ec1-snapshot-cli-and-doc-paths`), and desktop Claude Code + real `marimo` session receipt (`m2-host-quant-verification-and-closure`). |
| **EC-2:** Restatement fixture test proves a restated Q1 (`known_at > Q2`) never overwrites Q2 in `fundamentalsAsOf`. | **Done (Offline Rust + Real-DuckDB)** | Proven offline in `tools/curate-etl/src/fundamentals_tests.rs:104`, `tools/curate-etl/src/parquet_fundamentals_tests.rs:1107`, and real-DuckDB `libs/data/duckdb/test/duckdb-market-data-store.test.ts:251`. Python `fundamentals_as_of` parity is tracked in `m2-python-sdk-m2-parity`. |
| **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 for one listing loads in `< 250 ms` warm / `< 1 s` cold. | **Partial (Synthetic Done; Live `quant` Missing)** | **Done (synthetic):** `tools/curate-etl/src/run_curate_bars_1m_tests.rs:402` (`split_boundary_nvda_and_nexm_match_raw_bars_1d_closes`).<br>**Missing (live `quant`):** Host/container `vm.max_map_count`/`nofile` preflight, `getM2IntradayDDL()` execution, QuestDB `10.2.0` `0x10` TCP ILP v2 commit check, observed `NEXM.V` + `NVDA.US` `bars_1m` vs. retained raw `bars_1d` close check (`<= 0.5%`), and pinned 1-year single-listing PGWire latency benchmark (`< 250 ms` warm / `< 1 s` cold). |
---
## 4. Concrete Blockers & Director Trade-Offs
Confirm these six items (3 design trade-offs + 3 operational/environment prerequisites) before coding/closing M2:
1. **Option B `--from-mongo` for the 6 M2 collections vs. `.bson` staging *(Design trade-off)*:** Extend `tools/curate-etl` `SourceCollection` + `run_mongo.rs` with direct read-only MongoDB streaming for `qmFinancials`, `qmFinancials-old`, `ceoPosts`, `teData`, `eodIntraday1M`, and `qmIntraday`, or stay on `.bson` staging files for M2?
- *Recommended:* Extend Option B `--from-mongo` to all 6 M2 collections (`m2-curate-etl-mongo-and-financials-old`) so `3.40B` `eodIntraday1M` rows never require `~500–832 GiB` of NVMe scratch space, while keeping file mode for offline tests.
2. **MCP stdio-only for M2 vs. `web-api` SSE wrapper *(Design trade-off)*:** Close M2 with the landed desktop stdio server (`bun run mcp:research-copilot`), or also add an HTTP/SSE wrapper inside `apps/stock/web-api` now?
- *Recommended:* Keep M2 stdio-only for desktop Claude Code (EC-1) and defer the network-isolated HTTP/SSE MCP endpoint to M4 containerized campaigns.
3. **`fundamentals_pit`-only vs. physical `fundamentals_bitemporal/part.parquet` *(Design trade-off)*:** Keep `curate-fundamentals` writing pre-resolved 2D PIT snapshots (`fundamentals_pit/year=YYYY/part.parquet`), or also materialize a separate raw `fundamentals_bitemporal/part.parquet` table in M2?
- *Recommended:* Keep `fundamentals_pit`-only for M2 (`DATA-CONTRACTS.md` §3A and EC-2 both target `fundamentalsAsOf` over `fundamentals_pit`), and materialize `fundamentals_bitemporal` only if a downstream M3/M4 use case requires unflattened multi-period history.
4. **Live read-only QA MongoDB M2 field-shape probe *(Operational prerequisite)*:** Run `probe-source-field-shapes.ts` read-only (`studio_stock_bot_read@stock`) once `m2-data-pipeline-m2-inputs-and-probes` allowlists the 6 M2 collections, to confirm live `ceoPosts` numeric timestamp unit (`Seconds` vs `Millis`), `qmFinancials`/`qmFinancials-old` metric paths, and `teData` labels before production curation.
5. **`quant` (`10.0.0.51`) QuestDB `10.2.0` operator access *(Operational prerequisite)*:** Required for sysctl (`vm.max_map_count >= 1048576`) & container `nofile = 1048576` preflight, applying `getM2IntradayDDL()`, verifying `0x10` binary-double TCP ILP v2 commits via PGWire `wal_tables()`, running the observed `NEXM.V`/`NVDA.US` split check, and timing the 1-year `1m` PGWire latency gate.
6. **Workstation `marimo` + desktop Claude Code setup *(Operational prerequisite)*:** Required on the operator workstation with `bun run mcp:research-copilot`, Studio `library.yml`, real `marimo`, and isolated PostgreSQL to record the EC-1 sign-off receipt.
---
## 5. Ordered M2 Closure Backlog (7 Tasks)
Aligned 1-to-1 with the approved implementation backlog keys:
| Order | Key | Task | Depends On | Primary Acceptance |
| :---: | --- | --- | --- | --- |
| **1** | `m2-ceo-posts-events-compat` | **M2.2u** — Fix `ceoPosts` event kind (`'ceo_post'`) and co-publish under `<curatedRoot>/events` | *(none)* | `EVENT_KIND_POST = "ceo_post"`; non-clobbering `events/year=YYYY/part-posts.parquet`; TS (`market-data-store-duckdb.ts`) & Python (`data.py`) glob `events/year=*/*.parquet` verified in real-DuckDB combined filing/earnings/`ceo_post` test. |
| **2** | `m2-store-macro-cross-section-fx1m` | **M2.3s** — Implement `MarketDataStore.macroAsOf`, `crossSection`, QuestDB `fx('1m')`, and copilot `1m` routing | *(none)* | Vault-fenced DuckDB `macroAsOf` & `crossSection` tests; QuestDB `fx_1m` reader + `createRoutedMarketDataStore` `fx('1m')` routing + `getM2IntradayDDL()` initializer; optional `RESEARCH_MCP_QUESTDB_*` in `stdio-host.ts`/`openResearchCopilotStore`; `analyze_signal` `source: 'feature'` + `FEATURE_INPUT_DATASETS` (`'macro'`, `'corporate_actions'`). |
| **3** | `m2-data-pipeline-m2-inputs-and-probes` | **M2.2v** — Export `listing_venues.tsv` and extend field-shape probe & BSON fixture exporter for M2 collections | *(none)* | Atomic `listing_venues.tsv` (`us_tsx` / `tsxv_cse`) in `export-curate-inputs.ts`; all 14 M1+M2 collections allowlisted in `source-field-shapes.ts` & `export-raw-bson.ts` with `mongoReadOnly: true`. |
| **4** | `m2-curate-etl-mongo-and-financials-old` | **M2.3t** — Add `--qm-financials-old` merge and Option B `--from-mongo` streaming for M2 collections in `curate-etl` | `m2-ceo-posts-events-compat`, `m2-data-pipeline-m2-inputs-and-probes` | `curate-fundamentals` `--qm-financials-old` + `--curate-inputs`; sealed read-only `--from-mongo` streaming for all 6 M2 collections with byte-identical offline parity tests and zero new crates. |
| **5** | `m2-python-sdk-m2-parity` | **M2.4b** — Add Python `stockbot` `register_signal`, batch feature runner, and M2 `MarketDataStore` methods | `m2-ceo-posts-events-compat`, `m2-store-macro-cross-section-fx1m` | Vault-fenced `fundamentals_as_of`, `macro_as_of`, `cross_section`, optional QuestDB `1m` `bars`/`fx`, and `register_signal(...)` writing contract Zstd Parquet readable identically by TS and Python. |
| **6** | `m2-ec1-snapshot-cli-and-doc-paths` | **M2.1w** — Add notebook snapshot CLI, MCP E2E study+snapshot+finding test, and fix `docs/` → `design/` path drift | `m2-store-macro-cross-section-fx1m` | Fail-closed `scripts/export-notebook-snapshot.ts` (`"notebook:snapshot"`); E2E stdio MCP test (`search_symbols` → `file_finding` + snapshot); `docs/*.md` → `design/*.md` updated in `AGENTS.md`, `CLAUDE.md`, `README.md`, `studio.config.json`, `tools/curate-etl/README.md`. |
| **7** | `m2-host-quant-verification-and-closure` | **M2.5** — Execute host/`quant` M2 preflight, observed split-boundary & latency checks, and desktop Claude Code EC-1 sign-off | `m2-curate-etl-mongo-and-financials-old`, `m2-python-sdk-m2-parity`, `m2-ec1-snapshot-cli-and-doc-paths` | Retained host `CARGO_BUILD_JOBS=2 bun run check` + `test/postgres/` + live read-only M2 probe + `quant` QuestDB `10.2.0` preflight/`0x10` ILP/observed `NEXM.V` & `NVDA.US` split/latency checks + desktop Claude Code EC-1 receipt in `design/m2-close-evidence.md`, marking M2 closed in `design/MILESTONES.md`. |