feat(storage): move desktop SQLite ownership into a storage utility process
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.
This commit is contained in:
@@ -1,13 +1,19 @@
|
||||
import { mkdtemp, rm, writeFile } from 'node:fs/promises'
|
||||
import { mkdir, mkdtemp, rm, writeFile } from 'node:fs/promises'
|
||||
import { tmpdir } from 'node:os'
|
||||
import { join } from 'node:path'
|
||||
import { rgPath } from '@vscode/ripgrep'
|
||||
import { expect, it } from 'vitest'
|
||||
import { FileOutputBacking, outputFixtureRoot } from '../../../tests/support/paged-output-backing'
|
||||
import { ModelToolProvider, type ModelToolResult } from './model-tool-provider'
|
||||
|
||||
it('pages native rg output through the production provider and releases it', async () => {
|
||||
await mkdir(outputFixtureRoot, { recursive: true })
|
||||
const root = await mkdtemp(join(tmpdir(), 'goodbuddy-rg-provider-'))
|
||||
const provider = new ModelToolProvider(root, [], undefined, undefined, false, { ripgrepExecutablePath: rgPath })
|
||||
const backingStore = new FileOutputBacking()
|
||||
const provider = new ModelToolProvider(root, [], undefined, undefined, false, {
|
||||
ripgrepExecutablePath: rgPath,
|
||||
outputStore: { backingStore }
|
||||
})
|
||||
const context = { conversationId: 'rg-pages', runtimeTarget: 'model' as const, }
|
||||
const signal = new AbortController().signal
|
||||
const parse = (result: ModelToolResult) => {
|
||||
@@ -45,6 +51,7 @@ it('pages native rg output through the production provider and releases it', asy
|
||||
await expect(provider.callTool('output_read', { handle: reference.handle }, signal, context)).rejects.toThrow('不存在')
|
||||
} finally {
|
||||
await provider.dispose()
|
||||
await backingStore.dispose()
|
||||
await rm(root, { recursive: true, force: true })
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user