20 KiB
Milestone M2 Completion Audit & M3 Readiness Report (T-204)
Verdict: HOLD M3 — M2 is ~70% complete on master, with 7 concrete wiring/contract gaps remaining before M2 closure.
All sandbox-runnable TypeScript, ESLint, contract, and Rust native gates pass (0 errors, 0 warnings, 1,548 Rust tests and 1,848 targeted Bun tests green). 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 on master), 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 ILP v2 + latency gates remain unverified.
Scope & Provenance Notes
- Audit-only: Zero production code, build config, or CI changes (project CI is off).
- Documentation path drift: Milestone and contract docs moved from
docs/todesign/, whileAGENTS.md(lines 43–48),CLAUDE.md(lines 3, 7–11), andREADME.md(lines 7, 9, 11–13, 142, 264, 435) still referencedocs/*.md.- Sandbox boundary: Worktree
.gitmetadata lives outside the agent sandbox, so every deliverable below was verified directly from source files, exports, CLI parsers, and test execution rather thangithistory. Host-only gates (bun run check,audit:secrets, worktree-git tests inscripts/test/, andPIPELINE_TEST_DATABASE_URLPostgreSQL suites) are verified by Studio's unsandboxed runner.- 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. Sandbox-Safe Verification Gate Results
Executed inside the task worktree sandbox (network disabled; zero contact with QA MongoDB 27017/stock or QA PostgreSQL 5432/trading_bot):
| Gate / Suite | Command | Exit | 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, split_boundary_nvda_and_nexm_match_raw_bars_1d_closes) |
| 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 |
| Host-Only Gates | CARGO_BUILD_JOBS=2 bun run check / bun --env-file=... test |
N/A | HOST-ONLY — covered by Studio unsandboxed verification (.git metadata & 127.0.0.1:5432 PostgreSQL outside sandbox) |
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-onlytrial_ledger,findings, andprovider_caveats(database/postgres/init/37-research-findings.sql:81-99). - Holdout Vault fence:
createQueryDataTool(libs/research/src/mcp/tools/query-data.ts) andopenResearchCopilotStore(libs/data/duckdb/src/research-copilot-store.ts:40) hardcodevaultOperatorAuthorized: false, rejectscope/vault_evaluation_onlykeys, clamp bounds strictly belowvaultCutoffTs, and drop post-cutoff rows (libs/research/test/mcp-query-data.test.ts). - PIT & 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) proveknown_at <= asOfand Q1-after-Q2 restatement non-overwrite;tools/curate-etl/src/bars_1m_tests.rs:107,220andrun_curate_bars_1m_tests.rsproveNEXM.V(1:20) andNVDA.US(10:1) split price/volume un-adjustment within0.5%. - 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 on master (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. (2) createDuckDbMarketDataStore().macroAsOf (libs/research/src/market-data-store-duckdb.ts:2294-2296) throws MarketDataStoreNotImplementedError, blocking read-back of macro/part.parquet. (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); NEXM.V (1:20) and NVDA.US (10:1) split tests (bars_1m_tests.rs:107,220, run_curate_bars_1m_tests.rs). |
(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 QuestDB 10.2.0 binary-double (0x10) TCP ILP v2 acceptance (tools/curate-etl/src/ilp_send.rs:15-21) and < 250 ms warm / < 1 s cold query latency are 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' 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. |
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. |
PARTIAL | Split-boundary 0.5% fixture PASSES (tools/curate-etl/src/bars_1m_tests.rs:107,220, run_curate_bars_1m_tests.rs:split_boundary_nvda_and_nexm_match_raw_bars_1d_closes). Live quant QuestDB 10.2.0 binary-double (0x10) TCP ILP v2 load and < 250 ms warm / < 1 s cold benchmark remain UNVERIFIED. |
3. Root-Cause Breakdown: Why M2 Auto Mode Parked 3 Consecutive Tasks
Four compounding operational issues explain why the prior M2 Auto Mode run stalled:
studio/auto-*branch-reset drift leftT-196unported onmaster: AlthoughT-190(send-ilp) andT-194/T-202(curate-macro) landed onmaster, the desktop MCP CLI wiring (T-196:scripts/research-copilot-mcp.tsand"mcp:research-copilot"inpackage.json) is absent onmaster. Downstream tasks assuming a runnable desktop MCP server hit an immediate missing-entrypoint blocker.docs/*→design/*path drift across agent instructions:AGENTS.md(L43–48),CLAUDE.md(L3, L7–11),README.md(L7, L9, L11–13, L142, L264, L435), and task prompts still point todocs/*.md, causing agents to waste turns or fail path checks against the renameddesign/directory.- Sandbox boundary friction (
.git& PostgreSQL): Runningbun run check,audit:secrets, worktree-git tests (scripts/test/), orPIPELINE_TEST_DATABASE_URL(127.0.0.1:5432) suites inside the agent sandbox fails by design; tasks that treat those expected sandbox errors as code regressions or try to run livequantQuestDB checks from inside the sandbox park prematurely. - Unqueued director-gated Option B
--from-mongoextension for M2: The2026-11-30addendum indesign/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, butSourceCollection(tools/curate-etl/src/mongo_stream.rs:53-62) still allowlists only the 8 M1 collections, leaving M2 curation stuck in file-mode.bsonstaging.
4. Concrete Blockers Needing Director Decisions
- Option B
--from-mongofor M2 collections vs..bsonstaging: Should we extendtools/curate-etlSourceCollectionwith--from-mongostreaming for the 6 M2 collections (qmFinancials,qmFinancials-old,ceoPosts,teData,eodIntraday1M,qmIntraday), or close M2 in file-mode.bsonstaging?- Recommended: Extend
--from-mongoto the 6 M2 collections (reusing the M1ReadOnlyMongoClient+ChunkedMongoRawDocumentSourcepattern) so3.40BeodIntraday1Mdocs never require~500–832 GiBof intermediate.bsonscratch files.
- Recommended: Extend
- Canonical
ceoPostseventkind&<out>/eventsco-publishing: Shouldtools/curate-etl/src/parquet_posts.rsswitchEVENT_KIND_POSTfrom"post"to"ceo_post"and co-publish alongsidecurate-eventsunder<out>/events/year=YYYY/(e.g. distinct filenamepart-posts.parquetor merged event partition), or keep posts in a separate curated root?- Recommended: Change
EVENT_KIND_POSTto"ceo_post"(matching TSEVENT_KINDS,event-panel.ts, and PythonEventKind) and write a non-colliding file (events/year=YYYY/part-posts.parquet) so a single curated root serves filings, earnings, andceoPoststogether.
- Recommended: Change
- Live
quantQuestDB10.2.0ILP v2 & latency benchmark gate for M2 closure: Should M2 closure require an operator-runquantQuestDB10.2.0load verifying binary-double (0x10) TCP ILP v2 acceptance and the< 250 mswarm /< 1 scold Exit Criterion 3 benchmark, or accept fixture-level closure and defer the livequantload/benchmark to an ops follow-up (matching the M1d52aa20precedent)?- Recommended: Require a small-slice (
NEXM.V+NVDA.US, 1 year) operator verification onquantto confirm QuestDB10.2.0TCP ILP v2 binary-double acceptance and< 250 ms/< 1 slatency before closing M2, while deferring full3.40B-row backfill to an ops runbook.
- Recommended: Require a small-slice (
5. M3 Readiness Verdict & Recommended Task Order
Verdict: Do not start M3 yet. M3's Exit Criterion 3 requires a real M2 signal promoted via register_signal to flow through Tier 1 Screen → Tier 2 Rust Engine → CPCV/DSR/PBO/Recency → Human 6m Vault Gate, and M3's starting baselines are untouched on master:
apps/stock/engine/Cargo.tomlhas noparquetorarrowcrates yet (M3 Task 1 prerequisite: retire JSON-over-Postgres/IPC/N-API bar path).libs/calculations/src/index.tsexportsdeflatedSharpeRatio,effectiveIndependentTrials,analyzeSignalPanel,eventStudy, andevaluateRecencyGate, but has no CSCVPBO(S = 16) or Purged Walk-Forward/CPCV yet.
5.1 Ordered Task List to Finish M2 (8 Tasks)
- Restore
T-196desktop MCP entrypoint & wire routed intraday store: Addscripts/research-copilot-mcp.ts+"mcp:research-copilot"inpackage.json, and updateopenResearchCopilotStore(libs/data/duckdb/src/research-copilot-store.ts) to composecreateRoutedMarketDataStore+createQuestDbIntradayBarsReaderwhen QuestDB config is present. - Fix
ceoPostskind = 'ceo_post'&<out>/eventsco-publishing: ChangeEVENT_KIND_POSTintools/curate-etl/src/parquet_posts.rsto"ceo_post"and allowrun_curate_poststo co-publish into<out>/events/year=YYYY/without colliding withcurate-events. - Implement
MarketDataStore.macroAsOf,crossSection, andfx('1m'): Implement DuckDB read-back formacro/part.parquet(macroAsOf) and versionedfeatures/<name>/v<version>/(crossSection) inlibs/research/src/market-data-store-duckdb.ts, and routefx({ timeframe: '1m' })to QuestDBfx_1minlibs/research/src/market-data-store-routed.ts. - Wire
curate-qm-bars-1mCLI & expand Feature Library inputs: Exposecurate-qm-bars-1mintools/curate-etl/src/{cli,main}.rs, add'macro'and'corporate_actions'toFEATURE_INPUT_DATASETSinlibs/research/src/feature-library.ts, and extend MCPanalyze_signalto support materializedfeatures(andmacro/ceoPostsas needed). - Add Python
stockbotM2 parity ®ister_signal(D04/D11): Exposefundamentals_as_of,macro_as_of,cross_section,fx(..., timeframe='1m'), andregister_signal(...)inpython/stockbot/with offlinepytestcoverage. - Extend
curate-etl --from-mongoto the 6 M2 collections (subject to Director Decision 1): AddqmFinancials,qmFinancials-old(with--qm-financials-oldmerge),ceoPosts,teData,eodIntraday1M, andqmIntradaytoSourceCollectionintools/curate-etl/src/mongo_stream.rs. - 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 staledocs/links inAGENTS.md,CLAUDE.md, andREADME.mdtodesign/. - Operator
quantQuestDB10.2.0ILP v2 & latency verification (Exit Criterion 3): ApplygetM2IntradayDDL(), runsend-ilpon aNEXM.V+NVDA.US1-year slice againstquantQuestDB10.2.0(verifying0x10binary-double acceptance via PGWire), and record warm (< 250 ms) and cold (< 1 s) 1-year1mread timings.
5.2 Initial M3 Prerequisite Sequence (Once M2 Closes)
- Retire JSON-over-Postgres/IPC/N-API bar path (M3 Task 1): Add
parquet/arrow-rstoapps/stock/engine/Cargo.toml, store(hash, manifest, parquet_paths)inbacktest_datasets, and lift single-series TS gates innative-worker.ts. - Tier 1 Columnar Screener & CSCV PBO (
S = 16): Implement CSCVPBOand Purged Walk-Forward/CPCV inlibs/calculations, plus vectorized Polars/DuckDB portfolio sweeps loggingM_{T \times N}matrices totrial_ledger. - Tier 2 Rust
financial/multi-asset upgrades: Atomic timestamp-slice marks (F06), simultaneousTargetsell-netting, feature side-channel (featuresmap intoReplay/StrategyContext), andUSD/CADMargin + corporate-action/delisting accounting.