From 4ff4f7ef0a014296b2b9179fb58609a2d6b33b09 Mon Sep 17 00:00:00 2001 From: Studio Date: Sat, 5 Dec 2026 13:52:30 -0500 Subject: [PATCH] =?UTF-8?q?T-214:=20M2.1w=20=E2=80=94=20Add=20notebook=20s?= =?UTF-8?q?napshot=20CLI,=20MCP=20end-to-end=20study+snapshot+finding=20te?= =?UTF-8?q?st,=20and=20fix=20docs/->design/=20path=20drift?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/research-copilot-mcp.ts | 7 +++---- scripts/test/research-copilot-mcp-e2e.test.ts | 12 ++++++------ 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/scripts/research-copilot-mcp.ts b/scripts/research-copilot-mcp.ts index 69234067..20160108 100644 --- a/scripts/research-copilot-mcp.ts +++ b/scripts/research-copilot-mcp.ts @@ -60,10 +60,9 @@ async function defaultOpenStore( config: ResearchCopilotHostConfig, env?: Readonly> ): Promise { - const { openResearchCopilotStore } = await import( - '../libs/data/duckdb/src/research-copilot-store' - ); - return openResearchCopilotStore(config, env !== undefined ? { env } : undefined); + const mod = await import('../libs/data/duckdb/src/research-copilot-store'); + const opts = env !== undefined ? { env } : undefined; + return mod.openResearchCopilotStore(config, opts); } function defaultCreateLibraryCardReader( diff --git a/scripts/test/research-copilot-mcp-e2e.test.ts b/scripts/test/research-copilot-mcp-e2e.test.ts index db813601..746c8e09 100644 --- a/scripts/test/research-copilot-mcp-e2e.test.ts +++ b/scripts/test/research-copilot-mcp-e2e.test.ts @@ -401,7 +401,7 @@ function createInMemoryCopilotDatabase(): InMemoryCopilotDatabase { for (let offset = 0; offset < params.length; offset += 14) { const id = nextTrialId; nextTrialId += 1; - const createdAt = new Date(FIXED_NOW_MS + id * 1000).toISOString(); + const createdAt = `${new Date(FIXED_NOW_MS + id * 1000).toISOString().slice(0, -1)}000Z`; const rawSeries = params[offset + 13] as readonly number[]; // Round-trip through Float32Array to mirror PostgreSQL `real[]`. const storedSeries = Array.from(Float32Array.from(rawSeries)); @@ -453,13 +453,13 @@ function createInMemoryCopilotDatabase(): InMemoryCopilotDatabase { ) { const market = String(params[0]); const bucket = String(params[1]); - const asOf = params[2] !== undefined ? String(params[2]) : undefined; + const asOfMs = params[2] !== undefined ? Date.parse(String(params[2])) : undefined; const found = trials .filter( row => row.universe_market === market && row.horizon_bucket === bucket && - (asOf === undefined || row.created_at <= asOf) + (asOfMs === undefined || Date.parse(row.created_at) <= asOfMs) ) .sort((a, b) => a.trial_id - b.trial_id); return { rows: found as unknown as readonly Row[] }; @@ -1079,7 +1079,7 @@ describe('MCP research copilot Exit Criterion 1 end-to-end stdio workflow', () = expect(searchPayload.rowCount).toBe(1); expect(searchPayload.rows[0]?.listingId).toBe(101); expect(searchPayload.rows[0]?.delistedAt).toBeNull(); - expect(searchPayload.rows[0]?.lastBarDate).toBe('2024-06-30'); + expect(searchPayload.rows[0]?.lastBarDate).toBe(VAULT_CUTOFF_DATE); // 3. query_data: straddling `to` clamped, 9999.0 Vault sentinel bars excluded const queryStraddle = await stdio.callTool('query_data', { @@ -1187,7 +1187,7 @@ describe('MCP research copilot Exit Criterion 1 end-to-end stdio workflow', () = status: string; clampedTo: boolean; eventCount: number; - study: { clustered: { carMean: number } | null; diagnostics: { usedEvents: number } }; + study: { clustered: { carMean: number } | null; diagnostics: { eventsUsed: number } }; trial: { trialId: number; expressionHash: string; sampleEnd: string }; deflatedSharpe: { clusterSize: number; dsr: number | null }; }; @@ -1195,7 +1195,7 @@ describe('MCP research copilot Exit Criterion 1 end-to-end stdio workflow', () = expect(eventPayload.clampedTo).toBe(true); // Only the 8 pre-cutoff newswire ceo_post events are included (retail + Vault rows excluded). expect(eventPayload.eventCount).toBe(8); - expect(eventPayload.study.diagnostics.usedEvents).toBe(8); + expect(eventPayload.study.diagnostics.eventsUsed).toBe(8); expect(eventPayload.trial.sampleEnd < VAULT_CUTOFF_DATE).toBe(true); expect(eventPayload.deflatedSharpe.clusterSize).toBe(3);