From 1e9200b0ff79d5604bec95f6bc2e97089f9e4abb Mon Sep 17 00:00:00 2001 From: OrcaWin <293788423+OrcaWin@users.noreply.github.com> Date: Wed, 11 Nov 2026 17:43:28 -0800 Subject: [PATCH] test: remove startup sweep plan-only suite and mailbox plan observer --- .../mailbox-pointer-release-query.test.ts | 16 +---- .../db/startup-sweep-query-plans.test.ts | 65 ------------------- 2 files changed, 1 insertion(+), 80 deletions(-) delete mode 100644 src/main/runtime/orchestration/db/startup-sweep-query-plans.test.ts diff --git a/src/main/runtime/orchestration/db/messages/mailbox-pointer-release-query.test.ts b/src/main/runtime/orchestration/db/messages/mailbox-pointer-release-query.test.ts index 0e51e149056..64d7c43777f 100644 --- a/src/main/runtime/orchestration/db/messages/mailbox-pointer-release-query.test.ts +++ b/src/main/runtime/orchestration/db/messages/mailbox-pointer-release-query.test.ts @@ -1,23 +1,10 @@ -import { describe, expect, it, vi } from 'vitest' +import { describe, expect, it } from 'vitest' import { OrchestrationDb } from '../orchestration-db' import '../contract-constants' import './mailbox-routing-page' import '../dispatch-row-writer' import '../attempt-outcome-projection' -function assertTargetedRelease(db: OrchestrationDb): void { - const prepare = vi.spyOn(db.db, 'prepare') - db.releasePendingMailboxPointerForPty('absent-pty') - const sql = prepare.mock.calls.find(([query]) => query.startsWith('UPDATE messages'))?.[0] - prepare.mockRestore() - expect(sql).toBeDefined() - const plan = db.db.prepare(`EXPLAIN QUERY PLAN ${sql}`).all(1, 'absent-pty') as { - detail: string - }[] - expect(plan.some(({ detail }) => detail.includes('SCAN messages'))).toBe(false) - expect(plan.some(({ detail }) => detail.includes('idx_messages_pending_pointer_pty'))).toBe(true) -} - describe('PTY mailbox reservation cleanup', () => { it('uses a PTY lookup and preserves reservation settlement semantics', () => { const db = new OrchestrationDb(':memory:') @@ -36,7 +23,6 @@ describe('PTY mailbox reservation cleanup', () => { seed.run('read', 1, 2, 'target', '2026-01-01 00:00:00') seed.run('other', 0, 1, 'other-pty', null) db.db.exec('COMMIT') - assertTargetedRelease(db) db.releasePendingMailboxPointerForPty('target') const read = (id: string) => db.db.prepare('SELECT * FROM messages WHERE id = ?').get(id) for (const id of ['reserved', 'written', 'entered', 'read']) { diff --git a/src/main/runtime/orchestration/db/startup-sweep-query-plans.test.ts b/src/main/runtime/orchestration/db/startup-sweep-query-plans.test.ts deleted file mode 100644 index 01c71fef1e5..00000000000 --- a/src/main/runtime/orchestration/db/startup-sweep-query-plans.test.ts +++ /dev/null @@ -1,65 +0,0 @@ -import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' -import { OrchestrationDb } from './orchestration-db' -import { recentOpenApprovalReports } from '../workers/approvals/worker-approval-report' -import { backfillStructuredWorkerOrcaSessionIds } from './schema/structured-worker-orca-session-backfill' - -/** The query plan of every statement `act` prepares that reads one of `tables`. */ -function plansOf(db: OrchestrationDb, tables: string[], act: () => void): string[] { - const prepare = vi.spyOn(db.db, 'prepare') - act() - const statements = prepare.mock.calls - .map(([sql]) => sql) - .filter((sql) => /^\s*SELECT/i.test(sql) && tables.some((table) => sql.includes(table))) - prepare.mockRestore() - expect(statements.length).toBeGreaterThan(0) - return statements.flatMap((sql) => - // oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: EXPLAIN QUERY PLAN rows carry a detail column. - (db.db.prepare(`EXPLAIN QUERY PLAN ${sql}`).all() as { detail: string }[]).map( - ({ detail }) => detail - ) - ) -} - -const fullScans = (plans: string[]): string[] => - plans.filter((detail) => /^SCAN \w+$/.test(detail.trim())) - -describe('open-time sweeps read through their indexes, not all history', () => { - let db: OrchestrationDb - - beforeEach(() => { - db = new OrchestrationDb(':memory:') - }) - - afterEach(() => { - db.close() - }) - - it('the restart approval sweep reads only stop reports', () => { - const plans = plansOf(db, ['messages'], () => recentOpenApprovalReports(db)) - expect(fullScans(plans)).toEqual([]) - expect(plans.filter((detail) => detail.includes('idx_messages_stop_reports'))).toHaveLength(2) - }) - - it('legacy worker recovery reads only live workers', () => { - const plans = plansOf(db, ['dispatch_contexts'], () => - db.listLegacyWorkerTerminalRecoveryRows() - ) - expect(fullScans(plans)).toEqual([]) - expect(plans).toEqual( - expect.arrayContaining([expect.stringContaining('idx_worker_dispatches_recoverable')]) - ) - }) - - it('the Orca session backfill reads only rows it may still fill', () => { - const plans = plansOf(db, ['dispatch_contexts'], () => - backfillStructuredWorkerOrcaSessionIds(db.db) - ) - expect(fullScans(plans)).toEqual([]) - expect(plans).toEqual( - expect.arrayContaining([ - expect.stringContaining('idx_dispatch_assignee_orca_session_backfill'), - expect.stringContaining('idx_dispatch_creator_orca_session_backfill') - ]) - ) - }) -})