Main no longer opens desktop business SQLite. A single utility-process
storage owner holds the Assistant, Knowledge, attachment, document-result,
remote-binding and native model-ledger databases and runs whole domain
transactions; Main and Runtime callers use explicit async domain operations.
- Remove the Main readWithFallback path and the supervision worker's
separate business write connection; manifests are scanned read-only and
committed by the sole writer.
- Remote events are ACKed only after commit; process loss reports
unconfirmed writes instead of replaying them.
- Use native utilityProcess messaging with one in-flight bound (32) and
ordered waiting instead of capacity rejection and retries.
- Start the storage process before the window so startup overlaps.
- Keep short tool output in memory and store full output once in owned
storage; paging, branching, restart and deletion reuse that copy.
- Put required runtime launch files under goodbuddy-prefixed owned temp
directories and reclaim confirmed stale ones; stop writing duplicate
parsed.md.
- Add lint guards for SQLite ownership and architecture, concurrency
acceptance fixtures, and maintenance/architecture documentation.
Validation: typecheck and lint pass. Alternating baseline (edf019aa) vs
candidate runs show no regression on single-session, C01, C02, C04 and a
5-minute C06; Main p99 drops from ~21 ms to ~16.7 ms under concurrency.
Fresh portable copy (1.75M events) upgrade content unchanged; real-model
output paging passes with 4 external requests. Full npm test runs had
1-9 different timing-sensitive failures per run that pass when rerun.
Not covered: C03 review publication, C07 source body, app-level C05.
37 lines
2.2 KiB
TypeScript
37 lines
2.2 KiB
TypeScript
// @vitest-environment node
|
|
import { spawn } from 'node:child_process'
|
|
import { mkdir, mkdtemp, rm } from 'node:fs/promises'
|
|
import { join, resolve } from 'node:path'
|
|
import { randomUUID } from 'node:crypto'
|
|
import { expect, it } from 'vitest'
|
|
import { AssistantDatabase } from './assistant/assistant-database'
|
|
|
|
it('runs the three owner-local perf harnesses with explicit reader/checkpoint shutdown', async () => {
|
|
const parent = resolve('temp/goodbuddy-storage-foundation')
|
|
await mkdir(parent, { recursive: true })
|
|
const directory = await mkdtemp(join(parent, 'perf-smoke-'))
|
|
try {
|
|
const database = new AssistantDatabase(join(directory, 'assistant.sqlite'))
|
|
try {
|
|
database.initialize(directory)
|
|
database.saveLocalConversations([{ header: { id: randomUUID(), title: 'Synthetic perf', updatedAt: 1 },
|
|
messages: [{ id: randomUUID(), role: 'user', state: 'complete', content: 'Synthetic', createdAt: 1 }] }])
|
|
} finally { database.close() }
|
|
const env = { ...process.env, NODE_DISABLE_COMPILE_CACHE: '1', TEMP: directory, TMP: directory, TMPDIR: directory,
|
|
GB_MPERF_NODE: '1', GB_MPERF_CONVERSATIONS: '4', GB_MPERF_MESSAGES: '20', GB_MPERF_ACTIVITY: '100', GB_MPERF_CALLS: '2',
|
|
GB_KPERF_NODE: '1', GB_KPERF_SIZES: '100', GB_KPERF_DIMENSIONS: '4', GB_KPERF_QUERIES: '2',
|
|
GB_WPERF_NODE: '1', GB_WPERF_DATA: directory, GB_WPERF_EVENTS: '4', GB_WPERF_RATE: '0', GB_WPERF_KEEP: '0' }
|
|
for (const script of ['run-main-perf.cjs', 'run-knowledge-perf.cjs', 'run-write-perf.cjs']) {
|
|
const child = spawn(process.execPath, [resolve('build', script)], { env, stdio: ['ignore', 'pipe', 'pipe'] })
|
|
let output = ''
|
|
child.stdout.on('data', value => { output += value })
|
|
child.stderr.on('data', value => { output += value })
|
|
const timeout = setTimeout(() => child.kill(), 40_000)
|
|
try {
|
|
const code = await new Promise<number | null>((resolve, reject) => { child.once('exit', resolve); child.once('error', reject) })
|
|
expect(code, `${script}: ${output}`).toBe(0)
|
|
} finally { clearTimeout(timeout) }
|
|
}
|
|
} finally { await rm(directory, { recursive: true, force: true, maxRetries: 10, retryDelay: 100 }) }
|
|
}, 120_000)
|