T-215: M2.5 — Execute host/quant M2 preflight, observed split-boundary & latency checks, and desktop Claude Code EC-1 sign-off
This commit is contained in:
parent
923893c328
commit
51165adfeb
2 changed files with 1396 additions and 66 deletions
|
|
@ -12,15 +12,34 @@ import type { ManagedMarketDataStore, ResearchCopilotHostConfig } from '@stock-b
|
||||||
import {
|
import {
|
||||||
MAX_COLD_READ_MS,
|
MAX_COLD_READ_MS,
|
||||||
MAX_WARM_READ_MS,
|
MAX_WARM_READ_MS,
|
||||||
|
MIN_ONE_YEAR_WINDOW_MS,
|
||||||
|
type M2LoadReceipt,
|
||||||
type VerifyM2QuantCliDeps,
|
type VerifyM2QuantCliDeps,
|
||||||
|
type VerifyM2QuantDdlOnlyReport,
|
||||||
type VerifyM2QuantReport,
|
type VerifyM2QuantReport,
|
||||||
runVerifyM2QuantCli,
|
runVerifyM2QuantCli,
|
||||||
} from '../verify-m2-quant';
|
} from '../verify-m2-quant';
|
||||||
|
|
||||||
const NVDA_LISTING_ID = 101;
|
const NVDA_LISTING_ID = 101;
|
||||||
const NEXM_LISTING_ID = 202;
|
const NEXM_LISTING_ID = 202;
|
||||||
|
const OVERLAP_LISTING_ID = 303;
|
||||||
const VAULT_CUTOFF_ISO = '2025-02-13T00:00:00Z';
|
const VAULT_CUTOFF_ISO = '2025-02-13T00:00:00Z';
|
||||||
const VAULT_CUTOFF_MS = Date.parse(VAULT_CUTOFF_ISO);
|
const VAULT_CUTOFF_MS = Date.parse(VAULT_CUTOFF_ISO);
|
||||||
|
const KNOWN_AT_US = (BigInt(Date.parse('2025-02-01T00:00:00Z')) * 1000n).toString();
|
||||||
|
|
||||||
|
const DEFAULT_RECEIPT_REL_PATH = 'receipts/m2-load-receipt.json';
|
||||||
|
const DEFAULT_RECEIPT_ABS_PATH = `/tmp/verify-m2-quant-test/${DEFAULT_RECEIPT_REL_PATH}`;
|
||||||
|
const DEFAULT_RESEND_BASELINE_REL_PATH = 'receipts/m2-initial-report.json';
|
||||||
|
const DEFAULT_RESEND_BASELINE_ABS_PATH = `/tmp/verify-m2-quant-test/${DEFAULT_RESEND_BASELINE_REL_PATH}`;
|
||||||
|
|
||||||
|
const EOD_PROBE_TS_ISO = '2024-06-10T19:59:00.000000Z';
|
||||||
|
const EOD_PROBE_TS_US = isoToMicros('2024-06-10T19:59:00Z');
|
||||||
|
const QM_PROBE_TS_ISO = '2025-06-20T19:59:00.000000Z';
|
||||||
|
const QM_PROBE_TS_US = isoToMicros('2025-06-20T19:59:00Z');
|
||||||
|
const FX_PROBE_TS_ISO = '2024-06-10T19:59:00.000000Z';
|
||||||
|
const FX_PROBE_TS_US = isoToMicros('2024-06-10T19:59:00Z');
|
||||||
|
const OVERLAP_PROBE_TS_ISO = '2024-07-02T15:00:00.000000Z';
|
||||||
|
const OVERLAP_PROBE_TS_US = isoToMicros('2024-07-02T15:00:00Z');
|
||||||
|
|
||||||
function createBufferStream(): {
|
function createBufferStream(): {
|
||||||
readonly write: (chunk: string) => boolean;
|
readonly write: (chunk: string) => boolean;
|
||||||
|
|
@ -38,6 +57,10 @@ function createBufferStream(): {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isoToMicros(iso: string): string {
|
||||||
|
return (BigInt(Date.parse(iso)) * 1000n).toString();
|
||||||
|
}
|
||||||
|
|
||||||
function baseArgs(overrides: Record<string, string | null> = {}): string[] {
|
function baseArgs(overrides: Record<string, string | null> = {}): string[] {
|
||||||
const defaults: Record<string, string | null> = {
|
const defaults: Record<string, string | null> = {
|
||||||
'--questdb-host': '10.0.0.51',
|
'--questdb-host': '10.0.0.51',
|
||||||
|
|
@ -50,6 +73,7 @@ function baseArgs(overrides: Record<string, string | null> = {}): string[] {
|
||||||
'--bench-from': '2024-01-02T00:00:00Z',
|
'--bench-from': '2024-01-02T00:00:00Z',
|
||||||
'--bench-to': '2025-01-02T00:00:00Z',
|
'--bench-to': '2025-01-02T00:00:00Z',
|
||||||
'--bench-as-of': '2025-02-01T00:00:00Z',
|
'--bench-as-of': '2025-02-01T00:00:00Z',
|
||||||
|
'--load-receipt': DEFAULT_RECEIPT_REL_PATH,
|
||||||
'--warm-runs': '3',
|
'--warm-runs': '3',
|
||||||
'--wal-settle-timeout-ms': '5000',
|
'--wal-settle-timeout-ms': '5000',
|
||||||
};
|
};
|
||||||
|
|
@ -64,20 +88,136 @@ function baseArgs(overrides: Record<string, string | null> = {}): string[] {
|
||||||
return argv;
|
return argv;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isoToMicros(iso: string): string {
|
function defaultLoadReceipt(): M2LoadReceipt {
|
||||||
return (BigInt(Date.parse(iso)) * 1000n).toString();
|
return {
|
||||||
|
beforeWal: {
|
||||||
|
bars_1m: { writerTxn: '100', sequencerTxn: '100' },
|
||||||
|
fx_1m: { writerTxn: '30', sequencerTxn: '30' },
|
||||||
|
bar_revisions: { writerTxn: '0', sequencerTxn: '0' },
|
||||||
|
},
|
||||||
|
shards: {
|
||||||
|
bars_1m: {
|
||||||
|
probes: [
|
||||||
|
{
|
||||||
|
listingId: NVDA_LISTING_ID,
|
||||||
|
tsUs: EOD_PROBE_TS_US,
|
||||||
|
expectedClose: 121.79,
|
||||||
|
expectedSource: 'eod',
|
||||||
|
expectedKnownAtUs: KNOWN_AT_US,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
bars_1m_qm: {
|
||||||
|
probes: [
|
||||||
|
{
|
||||||
|
listingId: NEXM_LISTING_ID,
|
||||||
|
tsUs: QM_PROBE_TS_US,
|
||||||
|
expectedClose: 8.02,
|
||||||
|
expectedSource: 'qm',
|
||||||
|
expectedKnownAtUs: KNOWN_AT_US,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
fx_1m: {
|
||||||
|
probes: [
|
||||||
|
{
|
||||||
|
pair: 'USDCAD',
|
||||||
|
tsUs: FX_PROBE_TS_US,
|
||||||
|
expectedClose: 1.3765,
|
||||||
|
expectedSource: 'eod',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
dedup: {
|
||||||
|
eodSentRows: 500_500,
|
||||||
|
qmSentRows: 25_000,
|
||||||
|
overlapRows: 500,
|
||||||
|
overlapWinnerSource: 'qm',
|
||||||
|
overlapProbes: [
|
||||||
|
{
|
||||||
|
listingId: OVERLAP_LISTING_ID,
|
||||||
|
tsUs: OVERLAP_PROBE_TS_US,
|
||||||
|
expectedClose: 4.25,
|
||||||
|
expectedSource: 'qm',
|
||||||
|
expectedKnownAtUs: KNOWN_AT_US,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function defaultBars1mProbeMap(): Map<string, readonly Record<string, unknown>[]> {
|
||||||
|
return new Map<string, readonly Record<string, unknown>[]>([
|
||||||
|
[
|
||||||
|
`${NVDA_LISTING_ID}|${EOD_PROBE_TS_ISO}`,
|
||||||
|
[
|
||||||
|
{
|
||||||
|
listing_id: String(NVDA_LISTING_ID),
|
||||||
|
ts_us: EOD_PROBE_TS_US,
|
||||||
|
close: 121.79,
|
||||||
|
source: 'eod',
|
||||||
|
known_at_us: KNOWN_AT_US,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
`${NEXM_LISTING_ID}|${QM_PROBE_TS_ISO}`,
|
||||||
|
[
|
||||||
|
{
|
||||||
|
listing_id: String(NEXM_LISTING_ID),
|
||||||
|
ts_us: QM_PROBE_TS_US,
|
||||||
|
close: 8.02,
|
||||||
|
source: 'qm',
|
||||||
|
known_at_us: KNOWN_AT_US,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
`${OVERLAP_LISTING_ID}|${OVERLAP_PROBE_TS_ISO}`,
|
||||||
|
[
|
||||||
|
{
|
||||||
|
listing_id: String(OVERLAP_LISTING_ID),
|
||||||
|
ts_us: OVERLAP_PROBE_TS_US,
|
||||||
|
close: 4.25,
|
||||||
|
source: 'qm',
|
||||||
|
known_at_us: KNOWN_AT_US,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
function defaultFx1mProbeMap(): Map<string, readonly Record<string, unknown>[]> {
|
||||||
|
return new Map<string, readonly Record<string, unknown>[]>([
|
||||||
|
[
|
||||||
|
`USDCAD|${FX_PROBE_TS_ISO}`,
|
||||||
|
[
|
||||||
|
{
|
||||||
|
pair: 'USDCAD',
|
||||||
|
ts_us: FX_PROBE_TS_US,
|
||||||
|
close: 1.3765,
|
||||||
|
source: 'eod',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
],
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
interface MockFixtureOptions {
|
interface MockFixtureOptions {
|
||||||
readonly walSequence?: readonly (readonly Record<string, unknown>[])[];
|
readonly walSequence?: readonly (readonly Record<string, unknown>[])[];
|
||||||
readonly bars1mSummaryRows?: readonly Record<string, unknown>[];
|
readonly bars1mSummaryRows?: readonly Record<string, unknown>[];
|
||||||
readonly fx1mSummaryRows?: readonly Record<string, unknown>[];
|
readonly fx1mSummaryRows?: readonly Record<string, unknown>[];
|
||||||
|
readonly bars1mProbeRows?: Map<string, readonly Record<string, unknown>[]>;
|
||||||
|
readonly fx1mProbeRows?: Map<string, readonly Record<string, unknown>[]>;
|
||||||
readonly nvda1mRows?: readonly Record<string, unknown>[];
|
readonly nvda1mRows?: readonly Record<string, unknown>[];
|
||||||
readonly nexm1mRows?: readonly Record<string, unknown>[];
|
readonly nexm1mRows?: readonly Record<string, unknown>[];
|
||||||
readonly nvda1dRows?: readonly TableRow[];
|
readonly nvda1dRows?: readonly TableRow[];
|
||||||
readonly nexm1dRows?: readonly TableRow[];
|
readonly nexm1dRows?: readonly TableRow[];
|
||||||
readonly benchBatchesByCall?: readonly (readonly BarRecord[])[];
|
readonly benchBatchesByCall?: readonly (readonly BarRecord[])[];
|
||||||
readonly perfDurationsMs?: readonly number[];
|
readonly perfDurationsMs?: readonly number[];
|
||||||
|
readonly loadReceipt?: M2LoadReceipt;
|
||||||
|
readonly rawFiles?: Record<string, string>;
|
||||||
readonly openPgError?: Error;
|
readonly openPgError?: Error;
|
||||||
readonly queryError?: Error;
|
readonly queryError?: Error;
|
||||||
}
|
}
|
||||||
|
|
@ -148,7 +288,7 @@ function defaultNvda1dRows(): readonly TableRow[] {
|
||||||
function defaultNexm1mRows(): readonly Record<string, unknown>[] {
|
function defaultNexm1mRows(): readonly Record<string, unknown>[] {
|
||||||
return [
|
return [
|
||||||
// Pre-split 2025-06-19 (before 1:20 reverse split)
|
// Pre-split 2025-06-19 (before 1:20 reverse split)
|
||||||
{ ts_us: isoToMicros('2025-06-19T19:59:00Z'), close: 0.40 },
|
{ ts_us: isoToMicros('2025-06-19T19:59:00Z'), close: 0.4 },
|
||||||
// Ex-date 2025-06-20 (after 1:20 reverse split)
|
// Ex-date 2025-06-20 (after 1:20 reverse split)
|
||||||
{ ts_us: isoToMicros('2025-06-20T19:59:00Z'), close: 8.02 },
|
{ ts_us: isoToMicros('2025-06-20T19:59:00Z'), close: 8.02 },
|
||||||
];
|
];
|
||||||
|
|
@ -156,8 +296,8 @@ function defaultNexm1mRows(): readonly Record<string, unknown>[] {
|
||||||
|
|
||||||
function defaultNexm1dRows(): readonly TableRow[] {
|
function defaultNexm1dRows(): readonly TableRow[] {
|
||||||
return [
|
return [
|
||||||
{ session_date: '2025-06-19', close: 0.40 },
|
{ session_date: '2025-06-19', close: 0.4 },
|
||||||
{ session_date: '2025-06-20', close: 8.00 },
|
{ session_date: '2025-06-20', close: 8.0 },
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -205,6 +345,7 @@ function createHarness(
|
||||||
openedPgConfigs: QuestDbPgExecutorConfig[];
|
openedPgConfigs: QuestDbPgExecutorConfig[];
|
||||||
openedStoreConfigs: ResearchCopilotHostConfig[];
|
openedStoreConfigs: ResearchCopilotHostConfig[];
|
||||||
walPollCount: number;
|
walPollCount: number;
|
||||||
|
events: string[];
|
||||||
};
|
};
|
||||||
} {
|
} {
|
||||||
const stdout = createBufferStream();
|
const stdout = createBufferStream();
|
||||||
|
|
@ -218,16 +359,28 @@ function createHarness(
|
||||||
openedPgConfigs: [] as QuestDbPgExecutorConfig[],
|
openedPgConfigs: [] as QuestDbPgExecutorConfig[],
|
||||||
openedStoreConfigs: [] as ResearchCopilotHostConfig[],
|
openedStoreConfigs: [] as ResearchCopilotHostConfig[],
|
||||||
walPollCount: 0,
|
walPollCount: 0,
|
||||||
|
events: [] as string[],
|
||||||
};
|
};
|
||||||
|
|
||||||
const walSeq = options.walSequence ?? [defaultWalRows()];
|
const walSeq = options.walSequence ?? [defaultWalRows()];
|
||||||
const bars1mSummary = options.bars1mSummaryRows ?? defaultBars1mSummaryRows();
|
const bars1mSummary = options.bars1mSummaryRows ?? defaultBars1mSummaryRows();
|
||||||
const fx1mSummary = options.fx1mSummaryRows ?? defaultFx1mSummaryRows();
|
const fx1mSummary = options.fx1mSummaryRows ?? defaultFx1mSummaryRows();
|
||||||
|
const bars1mProbes = options.bars1mProbeRows ?? defaultBars1mProbeMap();
|
||||||
|
const fx1mProbes = options.fx1mProbeRows ?? defaultFx1mProbeMap();
|
||||||
const nvda1m = options.nvda1mRows ?? defaultNvda1mRows();
|
const nvda1m = options.nvda1mRows ?? defaultNvda1mRows();
|
||||||
const nexm1m = options.nexm1mRows ?? defaultNexm1mRows();
|
const nexm1m = options.nexm1mRows ?? defaultNexm1mRows();
|
||||||
const nvda1d = options.nvda1dRows ?? defaultNvda1dRows();
|
const nvda1d = options.nvda1dRows ?? defaultNvda1dRows();
|
||||||
const nexm1d = options.nexm1dRows ?? defaultNexm1dRows();
|
const nexm1d = options.nexm1dRows ?? defaultNexm1dRows();
|
||||||
|
|
||||||
|
const files = new Map<string, string>([
|
||||||
|
[DEFAULT_RECEIPT_ABS_PATH, JSON.stringify(options.loadReceipt ?? defaultLoadReceipt())],
|
||||||
|
]);
|
||||||
|
if (options.rawFiles !== undefined) {
|
||||||
|
for (const [k, v] of Object.entries(options.rawFiles)) {
|
||||||
|
files.set(k, v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let nowClock = 1_000_000;
|
let nowClock = 1_000_000;
|
||||||
let benchCallIdx = 0;
|
let benchCallIdx = 0;
|
||||||
const durations = options.perfDurationsMs ?? [180, 42, 38, 41, 39, 40];
|
const durations = options.perfDurationsMs ?? [180, 42, 38, 41, 39, 40];
|
||||||
|
|
@ -253,18 +406,32 @@ function createHarness(
|
||||||
throw options.queryError;
|
throw options.queryError;
|
||||||
}
|
}
|
||||||
if (sql.includes('FROM wal_tables()')) {
|
if (sql.includes('FROM wal_tables()')) {
|
||||||
|
state.events.push('pg:wal_tables');
|
||||||
const idx = Math.min(state.walPollCount, walSeq.length - 1);
|
const idx = Math.min(state.walPollCount, walSeq.length - 1);
|
||||||
state.walPollCount += 1;
|
state.walPollCount += 1;
|
||||||
return { rows: walSeq[idx] ?? [] };
|
return { rows: walSeq[idx] ?? [] };
|
||||||
}
|
}
|
||||||
if (sql.includes('FROM bars_1m GROUP BY source')) {
|
if (sql.includes('FROM bars_1m GROUP BY source')) {
|
||||||
|
state.events.push('pg:bars_1m_summary');
|
||||||
return { rows: bars1mSummary };
|
return { rows: bars1mSummary };
|
||||||
}
|
}
|
||||||
if (sql.includes('FROM fx_1m GROUP BY pair, source')) {
|
if (sql.includes('FROM fx_1m GROUP BY pair, source')) {
|
||||||
|
state.events.push('pg:fx_1m_summary');
|
||||||
return { rows: fx1mSummary };
|
return { rows: fx1mSummary };
|
||||||
}
|
}
|
||||||
|
if (sql.includes('FROM bars_1m WHERE listing_id = $1 AND ts = $2')) {
|
||||||
|
const key = `${String(params?.[0] ?? '')}|${String(params?.[1] ?? '')}`;
|
||||||
|
state.events.push(`pg:probe_bars_1m:${key}`);
|
||||||
|
return { rows: bars1mProbes.get(key) ?? [] };
|
||||||
|
}
|
||||||
|
if (sql.includes('FROM fx_1m WHERE pair = $1 AND ts = $2')) {
|
||||||
|
const key = `${String(params?.[0] ?? '')}|${String(params?.[1] ?? '')}`;
|
||||||
|
state.events.push(`pg:probe_fx_1m:${key}`);
|
||||||
|
return { rows: fx1mProbes.get(key) ?? [] };
|
||||||
|
}
|
||||||
if (sql.includes("session = 'RTH'")) {
|
if (sql.includes("session = 'RTH'")) {
|
||||||
const listingId = String(params?.[0] ?? '');
|
const listingId = String(params?.[0] ?? '');
|
||||||
|
state.events.push(`pg:split_rth:${listingId}`);
|
||||||
if (listingId === String(NVDA_LISTING_ID)) {
|
if (listingId === String(NVDA_LISTING_ID)) {
|
||||||
return { rows: nvda1m };
|
return { rows: nvda1m };
|
||||||
}
|
}
|
||||||
|
|
@ -284,6 +451,7 @@ function createHarness(
|
||||||
async query(sql: string, params: readonly unknown[]): Promise<readonly TableRow[]> {
|
async query(sql: string, params: readonly unknown[]): Promise<readonly TableRow[]> {
|
||||||
if (sql.includes('read_parquet')) {
|
if (sql.includes('read_parquet')) {
|
||||||
const listingId = Number(params[0]);
|
const listingId = Number(params[0]);
|
||||||
|
state.events.push(`duck:bars_1d:${listingId}`);
|
||||||
if (listingId === NVDA_LISTING_ID) {
|
if (listingId === NVDA_LISTING_ID) {
|
||||||
return nvda1d;
|
return nvda1d;
|
||||||
}
|
}
|
||||||
|
|
@ -301,6 +469,7 @@ function createHarness(
|
||||||
|
|
||||||
const mockStore: MarketDataStore = {
|
const mockStore: MarketDataStore = {
|
||||||
async *bars(): AsyncIterable<BarBatch> {
|
async *bars(): AsyncIterable<BarBatch> {
|
||||||
|
state.events.push(benchCallIdx === 0 ? 'bench:cold' : `bench:warm#${benchCallIdx}`);
|
||||||
const batches = options.benchBatchesByCall;
|
const batches = options.benchBatchesByCall;
|
||||||
const rows =
|
const rows =
|
||||||
batches !== undefined
|
batches !== undefined
|
||||||
|
|
@ -353,6 +522,7 @@ function createHarness(
|
||||||
},
|
},
|
||||||
async applyM2IntradayDDL(): Promise<ApplyM2IntradayDDLResult> {
|
async applyM2IntradayDDL(): Promise<ApplyM2IntradayDDLResult> {
|
||||||
state.ddlCalls += 1;
|
state.ddlCalls += 1;
|
||||||
|
state.events.push('pg:ddl');
|
||||||
return {
|
return {
|
||||||
appliedTables: [...M2_INTRADAY_TABLE_NAMES],
|
appliedTables: [...M2_INTRADAY_TABLE_NAMES],
|
||||||
statements: ['CREATE TABLE IF NOT EXISTS bars_1m ...'],
|
statements: ['CREATE TABLE IF NOT EXISTS bars_1m ...'],
|
||||||
|
|
@ -372,6 +542,13 @@ function createHarness(
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
async readTextFile(path: string): Promise<string> {
|
||||||
|
const content = files.get(path);
|
||||||
|
if (content === undefined) {
|
||||||
|
throw new Error(`ENOENT: no such mock file '${path}'`);
|
||||||
|
}
|
||||||
|
return content;
|
||||||
|
},
|
||||||
async writeReportFile(path: string, content: string): Promise<void> {
|
async writeReportFile(path: string, content: string): Promise<void> {
|
||||||
state.writtenFiles.set(path, content);
|
state.writtenFiles.set(path, content);
|
||||||
},
|
},
|
||||||
|
|
@ -398,10 +575,97 @@ describe('scripts/verify-m2-quant.ts', () => {
|
||||||
const code = await runVerifyM2QuantCli(deps);
|
const code = await runVerifyM2QuantCli(deps);
|
||||||
expect(code).toBe(0);
|
expect(code).toBe(0);
|
||||||
expect(stdout.text()).toContain('Usage: bun run scripts/verify-m2-quant.ts');
|
expect(stdout.text()).toContain('Usage: bun run scripts/verify-m2-quant.ts');
|
||||||
|
expect(stdout.text()).toContain('--ddl-only');
|
||||||
|
expect(stdout.text()).toContain('--load-receipt');
|
||||||
|
expect(stdout.text()).toContain('--resend-baseline');
|
||||||
expect(stderr.text()).toBe('');
|
expect(stderr.text()).toBe('');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('passes end-to-end without --apply-ddl, writes --out, and closes all handles', async () => {
|
test('--ddl-only succeeds against an empty QuestDB instance without querying table contents', async () => {
|
||||||
|
const emptyWal = [
|
||||||
|
{ name: 'bar_revisions', suspended: false, writerTxn: '0', sequencerTxn: '0' },
|
||||||
|
{ name: 'bars_1m', suspended: false, writerTxn: '0', sequencerTxn: '0' },
|
||||||
|
{ name: 'fx_1m', suspended: false, writerTxn: '0', sequencerTxn: '0' },
|
||||||
|
];
|
||||||
|
const { deps, stdout, stderr, state } = createHarness(
|
||||||
|
[
|
||||||
|
'--ddl-only',
|
||||||
|
'--questdb-host',
|
||||||
|
'10.0.0.51',
|
||||||
|
'--questdb-pg-port',
|
||||||
|
'8812',
|
||||||
|
'--out',
|
||||||
|
'out/ddl-only.json',
|
||||||
|
],
|
||||||
|
{
|
||||||
|
walSequence: [emptyWal],
|
||||||
|
bars1mSummaryRows: [],
|
||||||
|
fx1mSummaryRows: [],
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
const code = await runVerifyM2QuantCli(deps);
|
||||||
|
expect(code).toBe(0);
|
||||||
|
expect(stderr.text()).toBe('');
|
||||||
|
expect(state.ddlCalls).toBe(1);
|
||||||
|
expect(state.pgClosed).toBe(true);
|
||||||
|
expect(state.duckClosed).toBe(false);
|
||||||
|
expect(state.storeClosed).toBe(false);
|
||||||
|
expect(state.openedStoreConfigs).toHaveLength(0);
|
||||||
|
expect(state.events).toEqual(['pg:ddl', 'pg:wal_tables']);
|
||||||
|
expect(state.writtenFiles.size).toBe(1);
|
||||||
|
|
||||||
|
const report = JSON.parse(stdout.text()) as VerifyM2QuantDdlOnlyReport;
|
||||||
|
expect(report.ok).toBe(true);
|
||||||
|
expect(report.mode).toBe('ddl_only');
|
||||||
|
expect(report.ddl).toEqual({
|
||||||
|
applied: true,
|
||||||
|
appliedTables: [...M2_INTRADAY_TABLE_NAMES],
|
||||||
|
});
|
||||||
|
expect(report.walTables).toHaveLength(3);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('--ddl-only fails closed if a WAL table is missing or suspended', async () => {
|
||||||
|
const { deps, stdout, stderr } = createHarness(
|
||||||
|
['--ddl-only', '--questdb-host', '10.0.0.51', '--questdb-pg-port', '8812'],
|
||||||
|
{
|
||||||
|
walSequence: [
|
||||||
|
[
|
||||||
|
{ name: 'bar_revisions', suspended: false, writerTxn: '0', sequencerTxn: '0' },
|
||||||
|
{ name: 'bars_1m', suspended: true, writerTxn: '0', sequencerTxn: '0' },
|
||||||
|
{ name: 'fx_1m', suspended: false, writerTxn: '0', sequencerTxn: '0' },
|
||||||
|
],
|
||||||
|
],
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
const code = await runVerifyM2QuantCli(deps);
|
||||||
|
expect(code).toBe(1);
|
||||||
|
expect(stdout.text()).toBe('');
|
||||||
|
assertSingleLineError(stderr.text());
|
||||||
|
expect(stderr.text()).toContain('Suspended QuestDB WAL table');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('measures cold 1y 1m benchmark read BEFORE any verifier query scans bars_1m', async () => {
|
||||||
|
const { deps, stdout, stderr, state } = createHarness(baseArgs());
|
||||||
|
|
||||||
|
const code = await runVerifyM2QuantCli(deps);
|
||||||
|
expect(code).toBe(0);
|
||||||
|
expect(stderr.text()).toBe('');
|
||||||
|
|
||||||
|
const coldIndex = state.events.indexOf('bench:cold');
|
||||||
|
const summaryIndex = state.events.indexOf('pg:bars_1m_summary');
|
||||||
|
const firstProbeIndex = state.events.findIndex(e => e.startsWith('pg:probe_bars_1m:'));
|
||||||
|
const firstSplitIndex = state.events.findIndex(e => e.startsWith('pg:split_rth:'));
|
||||||
|
|
||||||
|
expect(coldIndex).toBe(0);
|
||||||
|
expect(summaryIndex).toBeGreaterThan(coldIndex);
|
||||||
|
expect(firstProbeIndex).toBeGreaterThan(coldIndex);
|
||||||
|
expect(firstSplitIndex).toBeGreaterThan(coldIndex);
|
||||||
|
expect((JSON.parse(stdout.text()) as VerifyM2QuantReport).ok).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('passes end-to-end without --apply-ddl, records effective bounds and load verification, writes --out, and closes all handles', async () => {
|
||||||
const argv = [...baseArgs(), '--out', 'out/m2-quant-verify.json'];
|
const argv = [...baseArgs(), '--out', 'out/m2-quant-verify.json'];
|
||||||
const { deps, stdout, stderr, state } = createHarness(argv);
|
const { deps, stdout, stderr, state } = createHarness(argv);
|
||||||
|
|
||||||
|
|
@ -415,10 +679,17 @@ describe('scripts/verify-m2-quant.ts', () => {
|
||||||
|
|
||||||
const report = JSON.parse(stdout.text()) as VerifyM2QuantReport;
|
const report = JSON.parse(stdout.text()) as VerifyM2QuantReport;
|
||||||
expect(report.ok).toBe(true);
|
expect(report.ok).toBe(true);
|
||||||
|
expect(report.mode).toBe('verify');
|
||||||
expect(report.ddl).toEqual({ applied: false, appliedTables: [] });
|
expect(report.ddl).toEqual({ applied: false, appliedTables: [] });
|
||||||
expect(report.walTables).toHaveLength(3);
|
expect(report.walTables).toHaveLength(3);
|
||||||
expect(report.bars1mSummary).toHaveLength(2);
|
expect(report.bars1mSummary).toHaveLength(2);
|
||||||
expect(report.fx1mSummary).toHaveLength(1);
|
expect(report.fx1mSummary).toHaveLength(1);
|
||||||
|
expect(report.loadVerification.walAdvancement).toHaveLength(2);
|
||||||
|
expect(report.loadVerification.probesVerified).toHaveLength(4);
|
||||||
|
expect(report.loadVerification.dedupAccounting.minExpectedEodRows).toBe(500_000);
|
||||||
|
expect(report.loadVerification.dedupAccounting.minExpectedQmRows).toBe(25_000);
|
||||||
|
expect(report.loadVerification.dedupAccounting.minExpectedTotalBars1mRows).toBe(525_000);
|
||||||
|
expect(report.resendVerification).toBeUndefined();
|
||||||
expect(report.splitChecks).toHaveLength(2);
|
expect(report.splitChecks).toHaveLength(2);
|
||||||
expect(report.splitChecks[0]?.label).toBe('NVDA.US');
|
expect(report.splitChecks[0]?.label).toBe('NVDA.US');
|
||||||
expect(report.splitChecks[0]?.preSplitCount).toBe(1);
|
expect(report.splitChecks[0]?.preSplitCount).toBe(1);
|
||||||
|
|
@ -427,17 +698,24 @@ describe('scripts/verify-m2-quant.ts', () => {
|
||||||
expect(report.splitChecks[1]?.label).toBe('NEXM.V');
|
expect(report.splitChecks[1]?.label).toBe('NEXM.V');
|
||||||
expect(report.splitChecks[1]?.maxRelDiff).toBeCloseTo(0.0025, 6);
|
expect(report.splitChecks[1]?.maxRelDiff).toBeCloseTo(0.0025, 6);
|
||||||
expect(report.benchmark.rowCount).toBe(2);
|
expect(report.benchmark.rowCount).toBe(2);
|
||||||
|
expect(report.benchmark.effectiveFrom).toBe('2024-01-02T00:00:00.000Z');
|
||||||
|
expect(report.benchmark.effectiveTo).toBe('2025-01-02T00:00:00.000Z');
|
||||||
|
expect(report.benchmark.effectiveAsOf).toBe('2025-02-01T00:00:00.000Z');
|
||||||
|
expect(report.benchmark.effectiveSpanMs).toBeGreaterThanOrEqual(MIN_ONE_YEAR_WINDOW_MS);
|
||||||
|
expect(report.benchmark.clampedTo).toBe(false);
|
||||||
|
expect(report.benchmark.clampedAsOf).toBe(false);
|
||||||
expect(report.benchmark.coldMs).toBe(180);
|
expect(report.benchmark.coldMs).toBe(180);
|
||||||
expect(report.benchmark.warmRuns).toEqual([42, 38, 41]);
|
expect(report.benchmark.warmRuns).toEqual([42, 38, 41]);
|
||||||
expect(report.benchmark.maxWarmMs).toBe(42);
|
expect(report.benchmark.maxWarmMs).toBe(42);
|
||||||
expect(report.benchmark.thresholds).toEqual({
|
expect(report.benchmark.thresholds).toEqual({
|
||||||
maxColdMs: MAX_COLD_READ_MS,
|
maxColdMs: MAX_COLD_READ_MS,
|
||||||
maxWarmMs: MAX_WARM_READ_MS,
|
maxWarmMs: MAX_WARM_READ_MS,
|
||||||
|
minWindowMs: MIN_ONE_YEAR_WINDOW_MS,
|
||||||
});
|
});
|
||||||
expect(state.writtenFiles.size).toBe(1);
|
expect(state.writtenFiles.size).toBe(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('invokes applyM2IntradayDDL when --apply-ddl is set', async () => {
|
test('invokes applyM2IntradayDDL when --apply-ddl is set without scanning bars_1m before cold read', async () => {
|
||||||
const argv = [...baseArgs(), '--apply-ddl'];
|
const argv = [...baseArgs(), '--apply-ddl'];
|
||||||
const { deps, stdout, stderr, state } = createHarness(argv);
|
const { deps, stdout, stderr, state } = createHarness(argv);
|
||||||
|
|
||||||
|
|
@ -445,6 +723,8 @@ describe('scripts/verify-m2-quant.ts', () => {
|
||||||
expect(code).toBe(0);
|
expect(code).toBe(0);
|
||||||
expect(stderr.text()).toBe('');
|
expect(stderr.text()).toBe('');
|
||||||
expect(state.ddlCalls).toBe(1);
|
expect(state.ddlCalls).toBe(1);
|
||||||
|
expect(state.events[0]).toBe('pg:ddl');
|
||||||
|
expect(state.events[1]).toBe('bench:cold');
|
||||||
|
|
||||||
const report = JSON.parse(stdout.text()) as VerifyM2QuantReport;
|
const report = JSON.parse(stdout.text()) as VerifyM2QuantReport;
|
||||||
expect(report.ddl).toEqual({
|
expect(report.ddl).toEqual({
|
||||||
|
|
@ -453,6 +733,181 @@ describe('scripts/verify-m2-quant.ts', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('fails closed when WAL did not advance past receipt beforeWal (stale table contents)', async () => {
|
||||||
|
const staleReceipt: M2LoadReceipt = {
|
||||||
|
...defaultLoadReceipt(),
|
||||||
|
beforeWal: {
|
||||||
|
bars_1m: { writerTxn: '120', sequencerTxn: '120' },
|
||||||
|
fx_1m: { writerTxn: '30', sequencerTxn: '30' },
|
||||||
|
},
|
||||||
|
};
|
||||||
|
const { deps, stdout, stderr } = createHarness(baseArgs(), {
|
||||||
|
loadReceipt: staleReceipt,
|
||||||
|
});
|
||||||
|
|
||||||
|
const code = await runVerifyM2QuantCli(deps);
|
||||||
|
expect(code).toBe(1);
|
||||||
|
expect(stdout.text()).toBe('');
|
||||||
|
assertSingleLineError(stderr.text());
|
||||||
|
expect(stderr.text()).toContain("WAL for 'bars_1m' did not advance");
|
||||||
|
});
|
||||||
|
|
||||||
|
test('fails closed when QM shard prefix is rejected even if older EOD and FX rows satisfy split and latency checks', async () => {
|
||||||
|
// Missing 'qm' group in bars_1m summary
|
||||||
|
const missingQmGroup = createHarness(baseArgs(), {
|
||||||
|
bars1mSummaryRows: [defaultBars1mSummaryRows()[0]!],
|
||||||
|
});
|
||||||
|
expect(await runVerifyM2QuantCli(missingQmGroup.deps)).toBe(1);
|
||||||
|
expect(missingQmGroup.stdout.text()).toBe('');
|
||||||
|
expect(missingQmGroup.stderr.text()).toContain("missing required source='qm'");
|
||||||
|
|
||||||
|
// Older 'qm' group exists, but current QM probe key is absent
|
||||||
|
const missingQmProbeMap = defaultBars1mProbeMap();
|
||||||
|
missingQmProbeMap.delete(`${NEXM_LISTING_ID}|${QM_PROBE_TS_ISO}`);
|
||||||
|
const missingQmProbe = createHarness(baseArgs(), {
|
||||||
|
bars1mProbeRows: missingQmProbeMap,
|
||||||
|
});
|
||||||
|
expect(await runVerifyM2QuantCli(missingQmProbe.deps)).toBe(1);
|
||||||
|
expect(missingQmProbe.stdout.text()).toBe('');
|
||||||
|
expect(missingQmProbe.stderr.text()).toContain('bars_1m_qm');
|
||||||
|
expect(missingQmProbe.stderr.text()).toContain('expected exactly 1 row, found 0');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('fails closed on 0x10 close mismatch, dedup duplicate rows, or insufficient post-dedup row counts', async () => {
|
||||||
|
// Corrupted 0x10 binary-double close value on fx_1m probe
|
||||||
|
const badFxProbes = defaultFx1mProbeMap();
|
||||||
|
badFxProbes.set(`USDCAD|${FX_PROBE_TS_ISO}`, [
|
||||||
|
{ pair: 'USDCAD', ts_us: FX_PROBE_TS_US, close: 1.9999, source: 'eod' },
|
||||||
|
]);
|
||||||
|
const badFx = createHarness(baseArgs(), { fx1mProbeRows: badFxProbes });
|
||||||
|
expect(await runVerifyM2QuantCli(badFx.deps)).toBe(1);
|
||||||
|
expect(badFx.stderr.text()).toContain('0x10 close mismatch for fx_1m');
|
||||||
|
|
||||||
|
// Duplicate rows returned for an overlap dedup key
|
||||||
|
const dupOverlapProbes = defaultBars1mProbeMap();
|
||||||
|
dupOverlapProbes.set(`${OVERLAP_LISTING_ID}|${OVERLAP_PROBE_TS_ISO}`, [
|
||||||
|
{
|
||||||
|
listing_id: String(OVERLAP_LISTING_ID),
|
||||||
|
ts_us: OVERLAP_PROBE_TS_US,
|
||||||
|
close: 4.25,
|
||||||
|
source: 'qm',
|
||||||
|
known_at_us: KNOWN_AT_US,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
listing_id: String(OVERLAP_LISTING_ID),
|
||||||
|
ts_us: OVERLAP_PROBE_TS_US,
|
||||||
|
close: 4.25,
|
||||||
|
source: 'eod',
|
||||||
|
known_at_us: KNOWN_AT_US,
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
const dupOverlap = createHarness(baseArgs(), { bars1mProbeRows: dupOverlapProbes });
|
||||||
|
expect(await runVerifyM2QuantCli(dupOverlap.deps)).toBe(1);
|
||||||
|
expect(dupOverlap.stderr.text()).toContain('dedup_overlap');
|
||||||
|
expect(dupOverlap.stderr.text()).toContain('expected exactly 1 row, found 2');
|
||||||
|
|
||||||
|
// Insufficient retained EOD rows after accounting for overlap
|
||||||
|
const underCountedEod = createHarness(baseArgs(), {
|
||||||
|
bars1mSummaryRows: [
|
||||||
|
{ ...defaultBars1mSummaryRows()[0]!, row_count: '499999' },
|
||||||
|
defaultBars1mSummaryRows()[1]!,
|
||||||
|
],
|
||||||
|
});
|
||||||
|
expect(await runVerifyM2QuantCli(underCountedEod.deps)).toBe(1);
|
||||||
|
expect(underCountedEod.stderr.text()).toContain('EOD/QM dedup accounting failed');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('verifies idempotent resend against the same receipt and prior baseline, failing on unchanged WAL or row count drift', async () => {
|
||||||
|
// 1. Run initial verification to produce the baseline report
|
||||||
|
const initial = createHarness(baseArgs());
|
||||||
|
expect(await runVerifyM2QuantCli(initial.deps)).toBe(0);
|
||||||
|
const initialReportJson = initial.stdout.text();
|
||||||
|
|
||||||
|
// 2. Resend with advanced WAL and identical row counts/summaries passes
|
||||||
|
const resendOk = createHarness(
|
||||||
|
baseArgs({ '--resend-baseline': DEFAULT_RESEND_BASELINE_REL_PATH }),
|
||||||
|
{
|
||||||
|
rawFiles: { [DEFAULT_RESEND_BASELINE_ABS_PATH]: initialReportJson },
|
||||||
|
walSequence: [
|
||||||
|
[
|
||||||
|
{ name: 'bar_revisions', suspended: false, writerTxn: '0', sequencerTxn: '0' },
|
||||||
|
{ name: 'bars_1m', suspended: false, writerTxn: '240', sequencerTxn: '240' },
|
||||||
|
{ name: 'fx_1m', suspended: false, writerTxn: '90', sequencerTxn: '90' },
|
||||||
|
],
|
||||||
|
],
|
||||||
|
}
|
||||||
|
);
|
||||||
|
expect(await runVerifyM2QuantCli(resendOk.deps)).toBe(0);
|
||||||
|
expect(resendOk.stderr.text()).toBe('');
|
||||||
|
const resendReport = JSON.parse(resendOk.stdout.text()) as VerifyM2QuantReport;
|
||||||
|
expect(resendReport.resendVerification?.ok).toBe(true);
|
||||||
|
expect(resendReport.resendVerification?.bars1mRowCountsUnchanged).toBe(true);
|
||||||
|
expect(resendReport.resendVerification?.fx1mRowCountsUnchanged).toBe(true);
|
||||||
|
|
||||||
|
// 3. Resend where WAL did not advance past prior baseline fails
|
||||||
|
const resendStaleWal = createHarness(
|
||||||
|
baseArgs({ '--resend-baseline': DEFAULT_RESEND_BASELINE_REL_PATH }),
|
||||||
|
{
|
||||||
|
rawFiles: { [DEFAULT_RESEND_BASELINE_ABS_PATH]: initialReportJson },
|
||||||
|
walSequence: [defaultWalRows()],
|
||||||
|
}
|
||||||
|
);
|
||||||
|
expect(await runVerifyM2QuantCli(resendStaleWal.deps)).toBe(1);
|
||||||
|
expect(resendStaleWal.stderr.text()).toContain('Idempotent resend WAL check');
|
||||||
|
|
||||||
|
// 4. Resend where row count increased (non-idempotent duplicate rows) fails
|
||||||
|
const resendRowDrift = createHarness(
|
||||||
|
baseArgs({ '--resend-baseline': DEFAULT_RESEND_BASELINE_REL_PATH }),
|
||||||
|
{
|
||||||
|
rawFiles: { [DEFAULT_RESEND_BASELINE_ABS_PATH]: initialReportJson },
|
||||||
|
walSequence: [
|
||||||
|
[
|
||||||
|
{ name: 'bar_revisions', suspended: false, writerTxn: '0', sequencerTxn: '0' },
|
||||||
|
{ name: 'bars_1m', suspended: false, writerTxn: '240', sequencerTxn: '240' },
|
||||||
|
{ name: 'fx_1m', suspended: false, writerTxn: '90', sequencerTxn: '90' },
|
||||||
|
],
|
||||||
|
],
|
||||||
|
bars1mSummaryRows: [
|
||||||
|
{ ...defaultBars1mSummaryRows()[0]!, row_count: '500001' },
|
||||||
|
defaultBars1mSummaryRows()[1]!,
|
||||||
|
],
|
||||||
|
}
|
||||||
|
);
|
||||||
|
expect(await runVerifyM2QuantCli(resendRowDrift.deps)).toBe(1);
|
||||||
|
expect(resendRowDrift.stderr.text()).toContain('Idempotent resend failed: bars_1m summary diverged');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('rejects short and Vault-truncated benchmark windows before querying', async () => {
|
||||||
|
// 1-month requested window
|
||||||
|
const shortWindow = createHarness(
|
||||||
|
baseArgs({
|
||||||
|
'--bench-from': '2024-01-02T00:00:00Z',
|
||||||
|
'--bench-to': '2024-02-02T00:00:00Z',
|
||||||
|
})
|
||||||
|
);
|
||||||
|
expect(await runVerifyM2QuantCli(shortWindow.deps)).toBe(1);
|
||||||
|
expect(shortWindow.stdout.text()).toBe('');
|
||||||
|
assertSingleLineError(shortWindow.stderr.text());
|
||||||
|
expect(shortWindow.stderr.text()).toContain('shorter than the required 1-year minimum');
|
||||||
|
expect(shortWindow.state.openedStoreConfigs).toHaveLength(0);
|
||||||
|
expect(shortWindow.state.openedPgConfigs).toHaveLength(0);
|
||||||
|
|
||||||
|
// 1-year requested window truncated below 1 year by Vault cutoff (2025-02-13T00:00:00Z)
|
||||||
|
const vaultTruncated = createHarness(
|
||||||
|
baseArgs({
|
||||||
|
'--bench-from': '2024-06-01T00:00:00Z',
|
||||||
|
'--bench-to': '2025-06-01T00:00:00Z',
|
||||||
|
})
|
||||||
|
);
|
||||||
|
expect(await runVerifyM2QuantCli(vaultTruncated.deps)).toBe(1);
|
||||||
|
expect(vaultTruncated.stdout.text()).toBe('');
|
||||||
|
assertSingleLineError(vaultTruncated.stderr.text());
|
||||||
|
expect(vaultTruncated.stderr.text()).toContain('Vault cutoff');
|
||||||
|
expect(vaultTruncated.stderr.text()).toContain('truncating the effective benchmark window');
|
||||||
|
expect(vaultTruncated.state.openedStoreConfigs).toHaveLength(0);
|
||||||
|
expect(vaultTruncated.state.openedPgConfigs).toHaveLength(0);
|
||||||
|
});
|
||||||
|
|
||||||
test('polls wal_tables() until writerTxn catches up to sequencerTxn', async () => {
|
test('polls wal_tables() until writerTxn catches up to sequencerTxn', async () => {
|
||||||
const { deps, stdout, stderr, state } = createHarness(baseArgs(), {
|
const { deps, stdout, stderr, state } = createHarness(baseArgs(), {
|
||||||
walSequence: [
|
walSequence: [
|
||||||
|
|
@ -476,8 +931,8 @@ describe('scripts/verify-m2-quant.ts', () => {
|
||||||
const { deps, stdout, stderr } = createHarness(baseArgs(), {
|
const { deps, stdout, stderr } = createHarness(baseArgs(), {
|
||||||
walSequence: [
|
walSequence: [
|
||||||
[
|
[
|
||||||
{ name: 'bars_1m', suspended: false, writerTxn: '10', sequencerTxn: '10' },
|
{ name: 'bars_1m', suspended: false, writerTxn: '120', sequencerTxn: '120' },
|
||||||
{ name: 'fx_1m', suspended: false, writerTxn: '10', sequencerTxn: '10' },
|
{ name: 'fx_1m', suspended: false, writerTxn: '45', sequencerTxn: '45' },
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
@ -494,8 +949,8 @@ describe('scripts/verify-m2-quant.ts', () => {
|
||||||
walSequence: [
|
walSequence: [
|
||||||
[
|
[
|
||||||
{ name: 'bar_revisions', suspended: false, writerTxn: '0', sequencerTxn: '0' },
|
{ name: 'bar_revisions', suspended: false, writerTxn: '0', sequencerTxn: '0' },
|
||||||
{ name: 'bars_1m', suspended: true, writerTxn: '10', sequencerTxn: '10' },
|
{ name: 'bars_1m', suspended: true, writerTxn: '120', sequencerTxn: '120' },
|
||||||
{ name: 'fx_1m', suspended: false, writerTxn: '10', sequencerTxn: '10' },
|
{ name: 'fx_1m', suspended: false, writerTxn: '45', sequencerTxn: '45' },
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
@ -514,8 +969,8 @@ describe('scripts/verify-m2-quant.ts', () => {
|
||||||
walSequence: [
|
walSequence: [
|
||||||
[
|
[
|
||||||
{ name: 'bar_revisions', suspended: false, writerTxn: '0', sequencerTxn: '0' },
|
{ name: 'bar_revisions', suspended: false, writerTxn: '0', sequencerTxn: '0' },
|
||||||
{ name: 'bars_1m', suspended: false, writerTxn: '10', sequencerTxn: '20' },
|
{ name: 'bars_1m', suspended: false, writerTxn: '110', sequencerTxn: '120' },
|
||||||
{ name: 'fx_1m', suspended: false, writerTxn: '5', sequencerTxn: '5' },
|
{ name: 'fx_1m', suspended: false, writerTxn: '45', sequencerTxn: '45' },
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
@ -526,7 +981,7 @@ describe('scripts/verify-m2-quant.ts', () => {
|
||||||
expect(stdout.text()).toBe('');
|
expect(stdout.text()).toBe('');
|
||||||
assertSingleLineError(stderr.text());
|
assertSingleLineError(stderr.text());
|
||||||
expect(stderr.text()).toContain('Timed out');
|
expect(stderr.text()).toContain('Timed out');
|
||||||
expect(stderr.text()).toContain('writerTxn=10<sequencerTxn=20');
|
expect(stderr.text()).toContain('writerTxn=110<sequencerTxn=120');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('fails closed when bars_1m or fx_1m has zero rows or non-finite 0x10 closes', async () => {
|
test('fails closed when bars_1m or fx_1m has zero rows or non-finite 0x10 closes', async () => {
|
||||||
|
|
@ -544,7 +999,7 @@ describe('scripts/verify-m2-quant.ts', () => {
|
||||||
bars1mSummaryRows: [
|
bars1mSummaryRows: [
|
||||||
{
|
{
|
||||||
source: 'eod',
|
source: 'eod',
|
||||||
row_count: '100',
|
row_count: '500000',
|
||||||
min_close: Number.NaN,
|
min_close: Number.NaN,
|
||||||
max_close: 120.5,
|
max_close: 120.5,
|
||||||
min_ts_us: isoToMicros('2024-01-02T14:30:00Z'),
|
min_ts_us: isoToMicros('2024-01-02T14:30:00Z'),
|
||||||
|
|
@ -651,7 +1106,7 @@ describe('scripts/verify-m2-quant.ts', () => {
|
||||||
|
|
||||||
test('blocks post-Vault benchmark queries, vault_evaluation_only scope, and leaked bar timestamps', async () => {
|
test('blocks post-Vault benchmark queries, vault_evaluation_only scope, and leaked bar timestamps', async () => {
|
||||||
const postVaultFrom = createHarness(
|
const postVaultFrom = createHarness(
|
||||||
baseArgs({ '--bench-from': VAULT_CUTOFF_ISO, '--bench-to': '2025-06-01T00:00:00Z' })
|
baseArgs({ '--bench-from': VAULT_CUTOFF_ISO, '--bench-to': '2026-06-01T00:00:00Z' })
|
||||||
);
|
);
|
||||||
expect(await runVerifyM2QuantCli(postVaultFrom.deps)).toBe(1);
|
expect(await runVerifyM2QuantCli(postVaultFrom.deps)).toBe(1);
|
||||||
expect(postVaultFrom.stderr.text()).toContain('Vault cutoff');
|
expect(postVaultFrom.stderr.text()).toContain('Vault cutoff');
|
||||||
|
|
@ -737,6 +1192,11 @@ describe('scripts/verify-m2-quant.ts', () => {
|
||||||
assertSingleLineError(missingHost.stderr.text());
|
assertSingleLineError(missingHost.stderr.text());
|
||||||
expect(missingHost.stderr.text()).toContain('Missing required QuestDB connection flags');
|
expect(missingHost.stderr.text()).toContain('Missing required QuestDB connection flags');
|
||||||
|
|
||||||
|
const missingReceipt = createHarness(baseArgs({ '--load-receipt': null }));
|
||||||
|
expect(await runVerifyM2QuantCli(missingReceipt.deps)).toBe(1);
|
||||||
|
assertSingleLineError(missingReceipt.stderr.text());
|
||||||
|
expect(missingReceipt.stderr.text()).toContain('Missing required flag --load-receipt');
|
||||||
|
|
||||||
const conflictingConn = createHarness(
|
const conflictingConn = createHarness(
|
||||||
baseArgs({ '--questdb-url': 'postgres://user:s3cr3tP4ss@10.0.0.51:8812/qdb' })
|
baseArgs({ '--questdb-url': 'postgres://user:s3cr3tP4ss@10.0.0.51:8812/qdb' })
|
||||||
);
|
);
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue