mirror of
https://github.com/stablyai/orca.git
synced 2026-11-13 17:37:40 +00:00
* refactor(tooling): organize test runtime and maintenance owners * test(tooling): preserve relocated runtime fixture dependency edges * refactor(tooling): preserve xterm routing owner checks * ci(tooling): include routing owner in sparse checkout * test(tooling): preserve copied workflow dependency closures * fix(tooling): normalize hashed JSON assets in release parity * fix(tooling): distinguish asset aliases from literal references * fix(tooling): frame normalized asset reference payloads * fix(tooling): normalize decoded JSON asset references * refactor(tooling): organize build, CI and release owners * fix(tooling): align moved generator and workflow path contracts * fix(tooling): update generated plugin bundle owner banners * test(tooling): create relocated mobile verifier fixture directories * test(tooling): copy headless detector dependency closure * test(tooling): align native batch policy fixtures with owner path * fix(tooling): link moved reliability command to historical evidence * fix(tooling): preserve nested sandbox owners and canonical guide source * fix(tooling): target release version owners in checkout fixture
81 lines
3.3 KiB
JavaScript
81 lines
3.3 KiB
JavaScript
import { mkdtempSync, rmSync, writeFileSync } from 'node:fs'
|
|
import { tmpdir } from 'node:os'
|
|
import { join, resolve } from 'node:path'
|
|
import { runProcessSync } from '@orca/process-host'
|
|
import { describeProcessFailure } from '../../tool-invocation/process-failure-message.mjs'
|
|
import { ORCAD_FOREIGN_SQLITE_READER_ENTRY } from '../../../../src/shared/orcad-artifacts.ts'
|
|
|
|
// Run reads in child under the runtime orcad ships, which may differ from build Node; trust exit status, not output.
|
|
const PROBE = `
|
|
const { Worker } = require('node:worker_threads')
|
|
const { DatabaseSync } = process.getBuiltinModule('node:sqlite')
|
|
const [entry, dbPath, missingPath] = process.argv.slice(2)
|
|
const db = new DatabaseSync(dbPath)
|
|
db.exec('CREATE TABLE session (id TEXT PRIMARY KEY, directory TEXT NOT NULL, time_created INTEGER NOT NULL, parent_id TEXT)')
|
|
db.prepare('INSERT INTO session VALUES (?, ?, ?, ?)').run('ses_smoke', '/smoke', 100, null)
|
|
db.close()
|
|
const steps = [
|
|
{
|
|
request: { id: 1, kind: 'openCodeBinderSessions', dbPath, cursor: { ms: 0, id: '' } },
|
|
expected: [{ id: 'ses_smoke', directory: '/smoke', createdAtMs: 100, parentId: null }]
|
|
},
|
|
{ request: { id: 2, kind: 'cursorProfile', dbPath: missingPath }, expected: { status: 'missing' } },
|
|
// The OpenCode history scanner's kinds share this entry.
|
|
{ request: { id: 3, kind: 'list', dbPaths: [], limit: null }, expected: { candidates: [], issues: [] } }
|
|
]
|
|
const worker = new Worker(entry, { execArgv: [] })
|
|
const fail = (code, message) => {
|
|
console.error(message)
|
|
process.exit(code)
|
|
}
|
|
setTimeout(() => fail(3, 'foreign SQLite reader worker did not answer'), 20000).unref()
|
|
worker.on('error', (error) => fail(4, String(error && error.stack || error)))
|
|
worker.on('exit', (code) => fail(5, 'foreign SQLite reader worker exited with ' + code))
|
|
let step = 0
|
|
worker.on('message', (response) => {
|
|
const { request, expected } = steps[step]
|
|
if (!response || response.id !== request.id || response.ok !== true ||
|
|
JSON.stringify(response.value) !== JSON.stringify(expected)) {
|
|
fail(6, request.kind + ' answered ' + JSON.stringify(response))
|
|
}
|
|
step += 1
|
|
if (step === steps.length) {
|
|
process.exit(0)
|
|
}
|
|
worker.postMessage(steps[step].request)
|
|
})
|
|
worker.postMessage(steps[0].request)
|
|
`
|
|
|
|
/**
|
|
* Load the built foreign SQLite reader entry and run real reads through it.
|
|
* @param outDir - orcad output directory holding the entry.
|
|
* @param options.runtimePath - Node to run under; the build's own Node when omitted.
|
|
*/
|
|
export function smokeForeignSqliteReaderWorker(outDir, { runtimePath, timeoutMs = 30_000 } = {}) {
|
|
const directory = mkdtempSync(join(tmpdir(), 'orca-foreign-sqlite-smoke-'))
|
|
try {
|
|
const probe = join(directory, 'probe.cjs')
|
|
writeFileSync(probe, PROBE)
|
|
const result = runProcessSync({
|
|
program: runtimePath ?? process.execPath,
|
|
args: [
|
|
probe,
|
|
resolve(outDir, ORCAD_FOREIGN_SQLITE_READER_ENTRY),
|
|
join(directory, 'opencode.db'),
|
|
join(directory, 'missing.vscdb')
|
|
],
|
|
env: { ...process.env, ORCA_BACKGROUND_LAUNCH: '1' },
|
|
timeoutMs,
|
|
maxOutputBytes: 64 * 1024
|
|
})
|
|
if (result.code !== 0 || result.timedOut) {
|
|
throw new Error(
|
|
`Foreign SQLite reader worker smoke failed: ${describeProcessFailure(result)}`
|
|
)
|
|
}
|
|
} finally {
|
|
rmSync(directory, { recursive: true, force: true })
|
|
}
|
|
}
|