18 KiB
Milestone M2 Gap Audit Report (T-203)
Verdict: OPEN — M2 is not ready for closure. Core M2 libraries (curate-macro, send-ilp, MCP server/adapters with Vault-fenced query_data, fundamentalsAsOf, QuestDB 10.2.0 primitives, and TS Feature Library) are present in the checked-out worktree and are programmer-reported green in the provisioned sandbox, but six concrete code/wiring gaps remain (including the missing desktop MCP entry point, unwired equity 1m QuestDB consumer routing, and a ceo_post vs post event-kind mismatch). Traceable gate verification (with confirmed checkout SHA and retained logs) and all host-only master / quant / desktop closure gates remain PENDING.
Scope & Provenance Notes:
- Milestone and contract documents live under
design/(design/MILESTONES.md,design/DATA-CONTRACTS.md,design/PLATFORM-PLAN.md), notdocs/.- Revision status: Worktree
.gitmetadata lives outside the sandbox boundary, so the exact basemasterSHA andstudio/auto-*branches could not be inspected inside the sandbox. All local checks below ran against the checked-out worktree on branchfeat/m2-gap-audit(/home/boki/.studio/worktrees/stock-bot/slot-1); authoritativemasterverification remains PENDING until the host confirms themasterSHA.- Per settled director decision, T-127 (M1 equity eligibility / Vault file isolation) stays deferred in the backlog and does not block M2.
- Project CI is off; no CI workflows were planned, added, or modified.
1. Verification History & Worktree Gate Results
1.1 Earlier Planning-Phase Setup Failures (Recorded in Approved Plan)
During the initial read-only planning pass (unprovisioned environment before worktree dependencies and writable Cargo target were available), all four requested local gates and supplemental tests failed during setup:
| Gate / Suite | Command | Exit Code | Planning-Phase Outcome |
|---|---|---|---|
| Typecheck | bun run typecheck |
2 |
FAIL — TS2688 missing bun-types |
| Contracts | bun run test:contracts |
2 |
FAIL — TS2688 missing bun-types |
| Lint | bun run lint:check |
127 |
FAIL — eslint: command not found |
| Native Rust | CARGO_BUILD_JOBS=2 bun run test:native |
101 |
FAIL — Read-only file system (os error 30) creating Cargo target path |
Supplemental M2 bun test |
copilot server, stdio, snapshot exporter, DuckDB store, ILP writer | 1 |
FAIL — missing zod and @stock-bot/logger during import setup |
1.2 Programmer-Reported Worktree Sandbox Runs (Verification Pending)
Executed interactively in the provisioned worktree /home/boki/.studio/worktrees/stock-bot/slot-1 (branch feat/m2-gap-audit, Linux sandbox, network disabled).
- Tested checkout revision: Unavailable in sandbox (worktree
.gitmetadata lives outside the sandbox boundary). - Retained command log / run reference: None (ephemeral sandbox terminal output only).
- Verification status: PENDING. Because neither a confirmed checkout SHA nor retained command logs/run IDs are available for these four gates and supplemental suites, the rows below are programmer-reported only and do not constitute verified passes on
masteror the audited revision.
| Gate / Suite | Command | Exit Code | Status (Programmer-Reported) |
|---|---|---|---|
| Typecheck | bun run typecheck |
0 |
PROGRAMMER-REPORTED (pending) — 0 errors reported |
| Contracts | bun run test:contracts |
0 |
PROGRAMMER-REPORTED (pending) — 0 errors reported |
| Lint | bun run lint:check |
0 |
PROGRAMMER-REPORTED (pending) — 0 errors, 0 warnings reported |
| Native Rust | CARGO_BUILD_JOBS=2 bun run test:native |
0 |
PROGRAMMER-REPORTED (pending) — 1,548 passed, 0 failed, 4 ignored across 57 suites |
MCP query_data Vault Fence |
bun test libs/research/test/mcp-query-data.test.ts |
0 |
PROGRAMMER-REPORTED (pending) — 13 pass, 0 fail |
| Real-DuckDB M2 Fixtures | bun test libs/data/duckdb/test/ |
0 |
PROGRAMMER-REPORTED (pending) — 25 pass, 0 fail across 4 files; includes Exit 2 restatement fixture & openResearchCopilotStore |
| Research + QuestDB + Copilot Executor | bun test libs/research/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 |
PROGRAMMER-REPORTED (pending) — 999 pass, 0 fail across 59 files |
| Exit 3 Split-Boundary Fixture | CARGO_BUILD_JOBS=2 cargo test -p curate-etl --offline split_boundary_nvda_and_nexm_match_raw_bars_1d_closes |
0 |
PROGRAMMER-REPORTED (pending) — 1 passed, 0 failed |
| Utils | bun run test:utils |
0 |
PROGRAMMER-REPORTED (pending) — 32 pass, 0 fail across 3 files |
| Calculations | bun run test:calculations |
0 |
PROGRAMMER-REPORTED (pending) — 144 pass, 0 fail across 12 files |
- Prior Studio unsandboxed runs (review branch
feat/m2-gap-audit): Studiobuild(#1589,#1591) andtest(#1590,#1592) passed on the review branch. These runs cover separate Studiobuildandtestcommands on the review branch—not the four individual requested gates (typecheck,test:contracts,lint:check,test:native)—and do not confirm the auditedmasterrevision. - Verification status: PENDING host confirmation of the exact
masterSHA, retained logs forCARGO_BUILD_JOBS=2 bun run check, and the separatetest/postgres/run (see Section 4.1).
2. Verified on master (Source Inspection; Traceable Runtime Verification & Host master SHA Pending)
- PRESENT · MCP Copilot Libraries, Vault-Fenced
query_data& Snapshot Exporter.libs/research/src/mcp/copilot-server.tsexposes all six M2 tools (search_symbols,query_data,analyze_signal,event_study,file_finding,read_knowledge).createQueryDataTool(libs/research/src/mcp/tools/query-data.ts) enforces strict Vault fencing: its Zod schema omitsscopeandvault_evaluation_only(.strict()rejects them with zero store calls), callsfenceVaultQueryBoundsbefore anystore.universeorstore.barscall (clampingto/asOfstrictly belowvaultCutoffTsand rejecting ranges starting at/aftervaultCutoffTswithVaultHoldoutFenceError), always passesscope: 'vault_fenced', and applies defense-in-depth row filtering dropping any row whererow.ts >= vaultCutoffTs || row.knownAt >= vaultCutoffTs(lines 203–210).- Boundary cases in
libs/research/test/mcp-query-data.test.ts— rejectingscope/vault_evaluation_only/unknown keys (L303), rejecting ranges starting at/aftervaultCutoffTswithVaultHoldoutFenceError(L342), clamping straddlingto/asOfbelow cutoff (L359), dropping leaky post-cutoffts/knownAtrows (L386), clamping universe date viamin(to, asOf)(L508), and DuckDB microsecond-bound +adj_factorssnapshot checks (L576) — are programmer-reported passing in the worktree (13pass,0fail; traceable verification & hostmasterSHA pending). libs/research/src/mcp/adapters/postgres-copilot.ts(createPostgresResearchCopilotServer) wires the read-only Studio library reader, PostgreSQL findings/caveats, trial lookup, and exchange calendars.openResearchCopilotStore(libs/data/duckdb/src/research-copilot-store.ts, T-184) andopenResearchCopilotExecutor(libs/data/postgres/src/research-copilot-executor.ts, T-189/T-200) are exported and programmer-reported passing in worktree unit tests (verification pending).exportNotebookSnapshot(libs/research/src/notebook-snapshot.ts) and its Node/Bun adapters (libs/research/src/notebook-snapshot-node.ts) implement themarimo check→ static HTML export sequence.
- PRESENT ·
tools/curate-etlCLI Subcommands.tools/curate-etl/src/cli.rsandtools/curate-etl/src/main.rswirecurate-bars-1d,curate-adj-factors,curate-corporate-actions,curate-fx-1d,curate-shorts,curate-events,curate-bars-1m,curate-fx-1m,curate-posts,curate-fundamentals,curate-macro, andsend-ilp.curate-macro(T-194/T-202) connectsrun_curate_macrotocurate_and_write_macro;send-ilp(T-190) connectsrun_send_ilpto shard discovery and one TCP connection per shard. Both are programmer-reported passing in offline native tests in the worktree (verification pending).
- PRESENT · Exit 2 (PIT Restatement) & Exit 3 (Split-Boundary) Fixtures.
tools/curate-etl/src/fundamentals.rsbuilds deduplicated 2D PIT snapshots and 4-quarter TTM with venue lag provenance.libs/data/duckdb/test/duckdb-market-data-store.test.tscontains the real-DuckDBfundamentalsAsOfrestatement fixture proving a restated Q1 (known_at > Q2) never overwrites Q2 (programmer-reported passing in worktree; verification pending).tools/curate-etl/src/run_curate_bars_1m_tests.rscontainssplit_boundary_nvda_and_nexm_match_raw_bars_1d_closeswith the0.5%threshold and negative controls (programmer-reported passing in worktree; verification pending).
- PRESENT · QuestDB
10.2.0Primitives & TS Feature Library.docker-compose.yml,docker-compose.dev.yml, anddocker-compose.prod.ymlpinquestdb/questdb:10.2.0.libs/data/questdb/src/{schema,client,query-builder,ilp-v2-writer}.tsprovide monthly WAL DDL (M2_INTRADAY_SCHEMAS,getM2IntradayDDL), parameterized PGWire (QuestDBClient.query),LATEST ON, and the ILP v2 binary batch writer.libs/research/src/feature-library.tsimplementsregisterSignal,runFeatureBatch, and Zstd Parquet writing for versioned DuckDB SQL features.
3. Remaining M2 Code Gaps
-
FAIL · Desktop MCP Entry Point & Exit 1 Wiring
- T-196 target
scripts/research-copilot-mcp.tsand rootpackage.jsonscriptmcp:research-copilotare absent. runResearchCopilotStdioHost(libs/research/src/mcp/host/stdio-host.ts) still requires caller-injected store/executor factories rather than a runnable default entrypoint.apps/stock/web-api/src/has no MCP/SSE route.- Impact: Desktop Claude Code cannot yet launch the copilot end-to-end to satisfy M2 Exit Criterion 1.
- T-196 target
-
FAIL ·
ceoPostsEvent-Kind & Output-Root Interoperabilitytools/curate-etl/src/parquet_posts.rsemitsEVENT_KIND_POST = "post", whereaslibs/research/src/market-data-store.ts(EventKind),libs/research/src/market-data-store-duckdb.ts(EVENT_KINDS),libs/research/src/mcp/tools/event-study.ts, andpython/stockbot/data.py(EventKind) all expect"ceo_post".tools/curate-etl/src/run_curate_posts.rswrites<out_dir>/events/year=YYYY/part.parquetand fails closed (RunCuratePostsError::EventsDatasetExists) if<out_dir>/eventsalready hasyear=*partitions fromcurate-events, while the copilot store takes a single curated root.- Impact: Published
ceoPostscannot be queried alongside filings and earnings through the DuckDB store or MCPevent_studyas shipped.
-
PARTIAL · Fundamentals & Macro Contract Gaps
build_fundamentals_rows(tools/curate-etl/src/fundamentals.rs) links filings using listing/fiscal-class plus report-date or filing-window heuristics because sampled filings lack statement period, whereasdesign/DATA-CONTRACTS.mdspecifies a direct period-end join.run_curate_fundamentals(tools/curate-etl/src/run_curate_fundamentals.rs) takes one caller-prepared financials BSON dump and requireslisting_venues.tsv, whichexportCurateInputs(apps/stock/data-pipeline/src/security-master/export-curate-inputs.ts) does not emit. No physicalfundamentals_bitemporalwriter oreodFinancialsOLDbackfill path exists.createDuckDbMarketDataStore().macroAsOf(libs/research/src/market-data-store-duckdb.ts:2294) still rejects withMarketDataStoreNotImplementedError, so curatedteDataParquet (macro/part.parquet) has no DuckDB reader.
-
PARTIAL · Intraday Operating Path
run_curate_qm_bars_1m(tools/curate-etl/src/run_curate_qm_bars_1m.rs) is implemented as a library function but has no binary subcommand dispatch intools/curate-etl/src/{cli,main}.rs.curate-bars-1mandcurate-fx-1moperate in file-mode BSON only (no--from-mongostreaming).tools/curate-etl/src/bars_1m.rsapplies fixed Eastern session tags (venue/date overrides exist in close validation, not curation), and loaders stamp caller-supplied--known-at-microswhose historical availability semantics must be defined before as-of studies.
-
FAIL / PARTIAL · QuestDB Startup Wiring & Intraday Read Path (Equity
1m+ FX1m)- Unwired equity
1mconsumer path: No application entry point constructscreateRoutedMarketDataStore(libs/research/src/market-data-store-routed.ts) withcreateQuestDbIntradayBarsReader(libs/research/src/market-data-store-questdb.ts). The documented copilot factoryopenResearchCopilotStore(libs/data/duckdb/src/research-copilot-store.ts) opens DuckDB alone (openDuckDbMarketDataStore), which rejectstimeframe: '1m'queries withMarketDataStoreNotImplementedErrorbefore reaching QuestDB. - Unwired FX
1mroute: Even whencreateRoutedMarketDataStoreis constructed,fx()delegates to the daily store rather than QuestDBfx_1m. - Startup DDL & legacy writer:
getM2IntradayDDL(libs/data/questdb/src/schema.ts:139) is opt-in with no checked-in startup caller applying it, andQuestDBClient(libs/data/questdb/src/client.ts:232) still instantiates legacyQuestDBInfluxWriter(libs/data/questdb/src/influx-writer.ts). - Schema wording drift:
M2_INTRADAY_SCHEMAS.fx_1mmatchesdesign/DATA-CONTRACTS.md(DEDUP UPSERT KEYS(ts, pair)), whiledesign/MILESTONES.md:96wording can be read as(ts, listing_id)for bothbars_1mandfx_1m.
- Unwired equity
-
PARTIAL · Feature Library & Documentation Drift
python/stockbot/__init__.pyandpython/stockbot/signals.pydo not exposeregister_signal(...)(only TSlibs/research/src/feature-library.tshasregisterSignal).createDuckDbMarketDataStore().crossSection(libs/research/src/market-data-store-duckdb.ts:2283) still rejects withMarketDataStoreNotImplementedError.tools/curate-etl/README.mdstill describes landedcurate-fundamentalsandcurate-macroCLI wiring as deferred/follow-up in older stage sections (e.g., lines 1697, 1744, 1752, 1836, 1859).AGENTS.mdandstudio.config.jsonstill referencedocs/paths instead ofdesign/.design/MILESTONES.md:97labels the Feature LibraryD04reopened, whereasdesign/PLATFORM-PLAN.mdassigns theregister_signalpromotion bridge toD11.
4. Manual Host-Only Closure Gates
These checks cannot run inside the sandbox and must be executed on the host / quant before closing M2:
-
Host Git Revision, Unmerged Branches, Full Check Gate & PostgreSQL Safety Suite
- Record the exact audited
masterSHA and inspectstudio/auto-*branches for any unmerged M2 commits (in particular T-196 desktop MCP wiring). - Run
CARGO_BUILD_JOBS=2 bun run checkoutside the sandbox on the confirmedmasterrevision (coversaudit:secrets,build,typecheck,test:contracts,test:tooling,test:utils,test:calculations,test:integration,test:native, andlint:check) and retain the command output/log alongside themasterSHA. - Because
scripts/check.ts(bun run check) does not invoketest:postgresor discovertest/postgres/, run the fixture-backed PostgreSQL safety suite separately usingbun --env-file=/home/boki/.studio/test-env/stock-bot.env test test/postgres/(against isolatedstock_bot_safety*) and record its result and log alongsidebun run check. - Never mutate QA MongoDB (
localhost:27017/stock) or QA PostgreSQL (localhost:5432/trading_bot).
- Record the exact audited
-
Desktop Claude Code End-to-End Verification (Exit 1)
- After runnable MCP entry-point wiring lands, connect desktop Claude Code against the read-only Studio library (
~/repos/studio/catalog/quant/library/library.yml) and isolated PostgreSQL. - Exercise all six MCP tools: run a PIT fundamentals + alt-data signal study and an event study, verify actual
marimo check-clean static HTML export, and retrieve the filed finding with its trial and artifact references.
- After runnable MCP entry-point wiring lands, connect desktop Claude Code against the read-only Studio library (
-
Live
quantQuestDB10.2.0Preflight, Load & Latency Verification (Exit 3)- Host & schema precheck: Verify on
quant: QuestDB10.2.0image,vm.max_map_count >= 1048576, containerulimits.nofile = 1048576, memory limits, and pre-createdPARTITION BY MONTHWAL tables with documented dedup keys ((ts, listing_id)forbars_1m,(ts, pair)forfx_1m). - Small live preflight per shard type (before bulk load): Because
tools/curate-etl/src/cli.rs:175documents that ILP v2 binary double encoding over TCP on QuestDB10.2.0is still unverified live, send one small sample shard for each shard type (bars_1m,bars_1m_qm,fx_1m) viasend-ilpfirst. Confirm committed row counts, decoded OHLCV/FX numeric values and timestamps, and healthy WAL state (wal_tables()) through PGWire before starting the bulk load. - Full bulk load & reconciliation: Run
send-ilpforbars_1m,bars_1m_qm, andfx_1m; reconcile source counts vs. QuestDB PGWire row counts and WAL state (TCPsend-ilpsuccess confirms socket delivery only, not committed rows), and verify overlapping EOD/QM bar dedup and repeat-load idempotency. - Split-boundary verification: Compare
NEXM.V(1:20) andNVDA.US(10:1) split-boundarybars_1msession closes against independently sourced rawbars_1dcloses (<= 0.5%). - Read latency benchmark & explicit scope: Benchmark a pinned 1-year single-listing
1mread (adjustment: 'raw') at< 250 mswarm /< 1 scold using the real PGWire-backed reader path:QuestDBClient.query(sql, params)(libs/data/questdb/src/client.ts) injected asQuestDbQueryExecutorintocreateQuestDbIntradayBarsReader(libs/research/src/market-data-store-questdb.ts), optionally composed viacreateRoutedMarketDataStore({ daily, intraday }). Record listing ID, date range, row count, elapsed times, and cache conditions. Scope note: Until equity1mrouting is wired intoopenResearchCopilotStoreand the desktop MCP entrypoint (Section 3, item 5), this benchmark measures the standalone PGWire-backed reader path, not a running copilot application; re-verify through the running application once consumer wiring lands.
- Host & schema precheck: Verify on