mirror of
https://github.com/stablyai/orca.git
synced 2026-11-15 18:37:24 +00:00
test: remove startup sweep plan-only suite and mailbox plan observer
This commit is contained in:
@@ -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']) {
|
||||
|
||||
@@ -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')
|
||||
])
|
||||
)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user