The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
Keep OpenCode launch control eager (#1110)
Deeee33093971d2
diff --git a/cli/e2e/eagerOpenCode.e2e.ts b/cli/e2e/eagerOpenCode.e2e.tsnew file mode 100644index 000000000..b8b2a392b--- /dev/null+++ b/cli/e2e/eagerOpenCode.e2e.ts@@ -0,0 +1,103 @@+/** Real launch dispatch keeps working without OpenCode's optional interpretation chunk. */+import { execFileSync } from 'node:child_process'+import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'+import { tmpdir } from 'node:os'+import { dirname, join } from 'node:path'+import { afterAll, afterEach, beforeAll, expect, it, onTestFailed } from 'vitest'+import { readLeanBundle } from '../src/harnessd/leanBundle.js'+import { LocalClient } from './harness/client.js'+import { CLI_ROOT, IsolatedDaemon, until } from './harness/daemon.js'+import { withLean } from './harness/release.js'++let scratch = '', bundle = ''+let daemon: IsolatedDaemon | undefined, client: LocalClient | undefined+beforeAll(() => {+ scratch = mkdtempSync(join(tmpdir(), 'eager-opencode-'))+ bundle = join(scratch, 'build', 'cli.js')+ execFileSync(process.execPath, ['build-bundle.mjs'], { cwd: CLI_ROOT,+ env: { ...process.env, BUNDLE_OUT_DIR: dirname(bundle) }, stdio: 'pipe' })+}, 120_000)+afterEach(async () => { client?.close(); await daemon?.close(); client = undefined; daemon = undefined })+afterAll(() => { if (scratch) rmSync(scratch, { recursive: true, force: true }) })++it.each([['missing', 1], ['stalled', 1], ['missing', 2], ['stalled', 2]] as const)(+ 'OpenCode with %s optional code, v%s: create, fork, restart, retarget and Stop/resume', async (mode, major) => {+ const lean = readLeanBundle(readFileSync(bundle))!+ const files = Object.fromEntries([...lean.files].map(([name, value]) => [name, value.toString('utf8')]))+ const chunks = Object.keys(files).filter(name => name.startsWith('core-inProcess-') && files[name]!.includes('OpencodeReader'))+ expect(chunks).toHaveLength(1)+ if (mode === 'missing') delete files[chunks[0]!]+ else files[chunks[0]!] = "console.error('[fixture] OpenCode reader stalled'); await new Promise(() => {});\n"+ const script = join(scratch, `${mode}-${major}`, 'cli.js'); mkdirSync(dirname(script), { recursive: true })+ writeFileSync(script, withLean(readFileSync(bundle, 'utf8'), files), { mode: 0o755 })+ const d = daemon = await IsolatedDaemon.create({ scriptPath: script, env: { HARNESS_CONNECTIONS_PORT: '0' } })+ onTestFailed(() => console.log(d.log()))+ const binary = join(d.root, 'bin', 'opencode'), launches = join(d.root, 'launches.jsonl')+ d.env.OPENCODE_PATH = binary+ d.env.OPENCODE_DATA_DIR = join(d.root, 'opencode', 'data')+ d.env.OPENCODE_PLUGIN_DIR = join(d.root, 'opencode', 'plugin')+ writeFileSync(binary, `#!${process.execPath}+const fs = require('node:fs');+const args = process.argv.slice(2);+if (args.includes('--version')) { console.log('opencode v${major}.0.18'); process.exit(0) }+if (args.includes('--help')) { console.log('--auto --session --prompt --agent'); process.exit(0) }+if (args[0] === 'models') { console.log('fixture/model'); process.exit(0) }+const id = args.includes('--session') ? args[args.indexOf('--session') + 1] : 'ses_' + process.pid;+process.title = ('opencode --session ' + id).padEnd(160);+fs.appendFileSync(${JSON.stringify(launches)}, JSON.stringify({id,args,pid:process.pid}) + '\\n');+console.log('fixture-opencode-ready'); console.log('┃');+setInterval(() => {}, 1000);+`, { mode: 0o755 })+ await d.start()+ const c = client = await LocalClient.connect(d)+ const rows = async () => (await c.request('agents_list', { includeStopped: true })).agents as Array<Record<string, any>>+ const active = (id: string) => until('OpenCode binds without its reader', async () => {+ const row = (await rows()).find(row => row.id === id)+ return row?.status === 'active' && row.sessionId ? row : null+ }, 30_000, 100)+ const records = () => readFileSync(launches, 'utf8').split('\n').filter(Boolean).map(line => JSON.parse(line)) as Array<{id: string; args: string[]; pid: number}>+ const cwd = join(d.projectsDir, 'native'); mkdirSync(cwd)+ if (major === 2) {+ const named = await c.request('agent_create', { engine: 'opencode', cwd, agent: 'reviewer' }, 30_000)+ expect(named.error).toBe('AGENT_UNSUPPORTED')+ }+ const created = await c.request('agent_create', { engine: 'opencode', cwd, ...(major === 1 ? { agent: 'reviewer' } : {}) }, 30_000)+ expect(created.error, JSON.stringify(created)).toBeUndefined()+ const source = await active(created.agent.id)+ expect(records()[0]!.args.includes('--agent')).toBe(major === 1)+ const forked = await c.request('agent_fork', { agentId: source.id, name: 'copy', prompt: 'fixture follow-up' }, 30_000)+ expect(forked.error, JSON.stringify(forked)).toBeUndefined()+ const child = await active(forked.agent?.id ?? forked.agentId ?? forked.session?.agentId)+ expect(child.sessionId).not.toBe(source.sessionId)+ const childLaunch = records().find(one => one.id === child.sessionId)!+ expect(childLaunch.args.includes('--agent')).toBe(major === 1)+ expect(childLaunch.args).toContain('--prompt')+ // A live upgrade must change relaunch flags even though no reader ever loaded. The saved+ // named agent is a v1 fact; the new v2 executable must not receive its rejected --agent flag.+ if (major === 1) writeFileSync(binary, readFileSync(binary, 'utf8').replace('opencode v1.0.18', 'opencode v2.0.18') + '\n// upgraded fixture\n', { mode: 0o755 })+ for (const request of ['agent_restart', 'agent_retarget']) {+ const before = records().filter(one => one.id === source.sessionId).length+ const result = await c.request(request, { agentId: source.id, ...(request === 'agent_retarget' ? { clearGrid: true } : {}) }, 45_000)+ expect(result.error, JSON.stringify(result)).toBeUndefined()+ await until('the replacement received the same conversation', () => records().filter(one => one.id === source.sessionId).length > before || null, 20_000, 100)+ const resumed = records().filter(one => one.id === source.sessionId).at(-1)!+ expect(resumed.args).toContain('--session')+ expect(resumed.args.includes('--agent')).toBe(false)+ expect((await active(source.id)).sessionId).toBe(source.sessionId)+ }+ const closed = await c.request('agent_close', { agentId: source.id, sessionId: source.sessionId, createdAt: source.createdAt, mode: 'now' }, 45_000)+ // This native-process fixture has an ID but no conversation rows. Close must hold before+ // its checkpoint; Stop can still preserve that ID and resume the same native process contract.+ expect(closed, JSON.stringify(closed)).toMatchObject({ error: 'HISTORY_NOT_SAVED' })+ expect((await active(source.id)).sessionId).toBe(source.sessionId)+ expect((await c.request('agent_delete', { agentId: source.id }, 45_000)).error).toBeUndefined()+ await until('Stop preserves the conversation', async () => {+ const row = (await rows()).find(row => row.id === source.id)+ return row?.status === 'stopped' && row.sessionId === source.sessionId ? row : null+ }, 20_000, 100)+ expect((await c.request('agent_resume', { agentId: source.id }, 45_000)).error).toBeUndefined()+ expect((await active(source.id)).sessionId).toBe(source.sessionId)+ expect((await active(child.id)).sessionId).toBe(child.sessionId)+ expect((await fetch(`http://127.0.0.1:${d.port}/api/health`)).ok).toBe(true)+ expect(d.coresStarted()).toBe(1)+ }, 180_000)diff --git a/cli/e2e/opencodeLaunchCost.e2e.ts b/cli/e2e/opencodeLaunchCost.e2e.tsnew file mode 100644index 000000000..53b4bf1d8--- /dev/null+++ b/cli/e2e/opencodeLaunchCost.e2e.ts@@ -0,0 +1,45 @@+/** Opt-in baseline/candidate bundle measurement; OPENCODE_COST_ROOT contains both cli.js files.+ * Private daemons and fake native processes only. Run without other heavy validation. */+import { execFileSync } from 'node:child_process'+import { mkdirSync, writeFileSync } from 'node:fs'+import { join } from 'node:path'+import { expect, it } from 'vitest'+import { IsolatedDaemon } from './harness/daemon.js'+import { LocalClient } from './harness/client.js'++it.runIf(Boolean(process.env.OPENCODE_COST_ROOT))('samples the same cold daemon and OpenCode launches with each frozen bundle', async () => {+ const samples: unknown[] = []+ const root = process.env.OPENCODE_COST_ROOT!+ const sample = (pid: number) => {+ const [cpu, rss] = execFileSync('ps', ['-o', 'time=,rss=', '-p', String(pid)], { encoding: 'utf8' }).trim().split(/\s+/)+ return { cpuMs: cpu.split(':').reverse().reduce((sum, value, i) => sum + Number(value) * 60 ** i, 0) * 1000, rssMiB: Number(rss) / 1024 }+ }+ for (const which of ['baseline', 'candidate', 'candidate', 'baseline']) {+ const d = await IsolatedDaemon.create({ scriptPath: join(root, which, 'cli.js'), env: { HARNESS_CONNECTIONS_PORT: '0' } })+ let client: LocalClient | undefined+ try {+ const bin = join(d.root, 'bin', 'opencode'); d.env.OPENCODE_PATH = bin+ d.env.OPENCODE_PLUGIN_DIR = join(d.root, 'opencode', 'plugin')+ writeFileSync(bin, `#!${process.execPath}+if (process.argv.includes('--version')) { console.log('opencode v2.0.18'); process.exit(0) }+if (process.argv.includes('--help')) { console.log('--auto'); process.exit(0) }+process.title = ('opencode --session ses_' + process.pid).padEnd(160);+console.log('┃'); setInterval(() => {}, 1000);+`, { mode: 0o755 })+ const began = performance.now(); await d.start(); const readyMs = performance.now() - began+ const atReady = sample(d.corePid()!)+ client = await LocalClient.connect(d)+ const launches: unknown[] = []+ for (let i = 0; i < 2; i++) {+ const cwd = join(d.projectsDir, String(i)); mkdirSync(cwd)+ const before = sample(d.corePid()!), start = performance.now()+ const result = await client.request('agent_create', { engine: 'opencode', cwd }, 30000)+ expect(result.error).toBeUndefined()+ const after = sample(d.corePid()!)+ launches.push({ phase: i ? 'warm' : 'cold', requestMs: performance.now() - start, coreCpuMs: after.cpuMs - before.cpuMs, rssMiB: after.rssMiB })+ }+ samples.push({ bundle: which, readyMs, atReady, launches })+ } finally { client?.close(); await d.close() }+ }+ writeFileSync(join(root, 'cost.json'), JSON.stringify({ node: process.version, platform: process.platform, tmux: execFileSync('tmux', ['-V'], { encoding: 'utf8' }).trim(), samples }, null, 2) + '\n')+}, 240000)diff --git a/cli/scripts/handoff-2026-10-08/mutate-opencode-launch.py b/cli/scripts/handoff-2026-10-08/mutate-opencode-launch.pynew file mode 100644index 000000000..e7c969e4c--- /dev/null+++ b/cli/scripts/handoff-2026-10-08/mutate-opencode-launch.py@@ -0,0 +1,60 @@+"""Break OpenCode native declarations and real launch wiring; only assertion failures count."""+import os+from pathlib import Path+import subprocess+import sys++cli = Path(sys.argv[1]).resolve()+golden = 'src/engines/opencodeLaunch.golden.spec.ts'+architecture = 'src/architecture.spec.ts'+eager = 'src/core/agents/retarget.spec.ts'+mutations = [+ ('wrong native generation', 'src/engines/opencode/contract.ts', 'const OPENCODE_V2_MAJOR = 2', 'const OPENCODE_V2_MAJOR = 3', golden),+ ('version protocol', 'src/engines/opencode/contract.ts', "args: ['--version']", "args: ['--help']", golden),+ ('version parsing', 'src/engines/opencode/contract.ts', r'/(\d+)\.\d+\.\d+/', r'/major=(\d+)/', golden),+ ('native SQL session field', 'src/engines/opencode/contract.ts', "'$.model.providerID'", "'$.model.provider'", golden),+ ('native transaction absent', 'src/engines/opencode/contract.ts', "'BEGIN IMMEDIATE;'", "'-- no transaction'", golden),+ ('native API provider field', 'src/engines/opencode/contract.ts', "provider: 'providerID'", "provider: 'provider'", golden),+ ('variant lost', 'src/engines/opencode/contract.ts', "variantSeparator: '#'", "variantSeparator: '@'", golden),+ ('create version disconnected', 'src/core/agents/create.ts', 'opencode.opencodeMajorVersion()', 'null', golden),+ ('fork version disconnected', 'src/core/agents/fork.ts', 'opencode.opencodeMajorVersion()', 'null', golden),+ ('retarget native model skipped', 'src/core/agents/retarget.ts', 'if (rewritesOpencodeSession && opencode)', 'if (false)', golden),+ ('relaunch depends on optional code', 'src/core/agents/launch.ts', "import { prepareResume, repairedItemsName }", "import { loadEngine } from '../../engines/inProcess.js'\nimport { prepareResume, repairedItemsName }", architecture),+ ('composition reads optional code', 'src/core/main.ts', "opencodeMajor: engine === 'opencode' ? opencodeMajorVersion() : null", "opencodeMajor: engine === 'opencode' ? engineNow('opencode', 'an OpenCode launch was built')?.opencodeMajorVersion() ?? null : null", architecture),+ ('retarget waits on optional reader', 'src/core/agents/retarget.ts', "const opencode = session.engine === 'opencode' ? opencodeLaunch : null", "const opencode = session.engine === 'opencode' ? await (await import('../../engines/inProcess.js')).loadEngine('opencode') : null", eager),+]+env = {**os.environ, 'TZ': 'UTC', 'TMPDIR': '/tmp'}+for name in ['TMUX', 'TMUX_PANE', 'RECORD_OPENCODE_LAUNCH_GOLDEN']:+ env.pop(name, None)+++def run(specs):+ pattern = ['--testNamePattern=while its optional reader is'] if specs == [eager] else []+ return subprocess.run(['node', 'node_modules/vitest/vitest.mjs', 'run', *specs, *pattern, '--maxWorkers=1'],+ cwd=cli, env=env, capture_output=True, text=True, timeout=180)+++baseline = run([golden, architecture, eager])+if baseline.returncode:+ print(baseline.stdout + baseline.stderr)+ raise SystemExit('baseline failed; no mutants ran')+print('unchanged baseline passed', flush=True)+for label, relative, before, after, spec in mutations:+ path = cli / relative+ original = path.read_text()+ assert original.count(before) == 1, (label, original.count(before))+ try:+ mutated = original.replace(before, after)+ if label == 'composition reads optional code':+ old_import = 'import { inProcessScreen, preloadEngine }'+ assert mutated.count(old_import) == 1+ mutated = mutated.replace(old_import, 'import { engineNow, inProcessScreen, preloadEngine }')+ path.write_text(mutated)+ result = run([spec])+ output = result.stdout + result.stderr+ if result.returncode == 0 or 'AssertionError' not in output:+ print(output)+ raise SystemExit(f'{label}: not caught by an assertion')+ print(f'{label}: caught by assertion', flush=True)+ finally:+ path.write_text(original)diff --git a/cli/src/architecture.spec.ts b/cli/src/architecture.spec.tsindex 6f3a83c93..38287af74 100644--- a/cli/src/architecture.spec.ts+++ b/cli/src/architecture.spec.ts@@ -452,6 +452,21 @@ describe('the daemon\'s shape', () => {}})+ it('native launch control is eager and reaches only engine declarations', () => {+ for (const entry of ['core/agents/create.ts', 'core/agents/fork.ts', 'core/agents/retarget.ts',+ 'core/agents/launch.ts', 'core/agents/launches.ts', 'core/agents/externalPreflight.ts',+ 'lib/launchOverrides.ts', 'engines/launchControl.ts', 'engines/kit/nativeVersion.ts', 'engines/kit/nativeSessionModel.ts']) {+ const imports = importsFor(entry, readFileSync(join(SRC, entry), 'utf8'))+ expect(imports.filter(one => one.dynamic || /inProcess\.js$/.test(one.from)), entry).toEqual([])+ }+ expect([...closureOf('engines/launchControl.ts').keys()].filter(theirs)).toEqual([])+ for (const entry of ['engines/kit/nativeVersion.ts', 'engines/kit/nativeSessionModel.ts']) {+ expect([...closureOf(entry).keys()].filter(file => /^engines\/(?!kit\/)/.test(file)), entry).toEqual([])+ }+ const main = readFileSync(join(SRC, 'core/main.ts'), 'utf8')+ expect(main).not.toMatch(/\bengineNow\s*\(\s*['"]opencode['"]/)+ })+it('the gateway reaches the core only through core/api.ts: never a core module, the registry, cli.ts or the socket', () => {// It speaks to the core through GatewayPort and GatewayEvents alone, so that it can run in a process of// its own (step 10, R2) without taking any of the core with it.diff --git a/cli/src/backendSocket.spec.ts b/cli/src/backendSocket.spec.tsindex 338cf6aa7..639440649 100644--- a/cli/src/backendSocket.spec.ts+++ b/cli/src/backendSocket.spec.ts@@ -38,7 +38,7 @@ import * as scmProjects from './scm/scmProjects.js'import * as machineResources from './lib/machineResources.js'import * as projectFolder from './lib/projectFolder.js'import * as projectPreview from './lib/projectPreview.js'-import * as opencodeVersion from './engines/opencode/version.js'+import * as opencodeVersion from './engines/launchControl.js'import { randomUUID } from 'node:crypto'import { fakeGridAnswers, installFakeGrid, type FakeGrid } from './lib/__fixtures__/fakeGrid.js'import { clearGridMcpUrlCache } from './lib/gridMcpUrl.js'diff --git a/cli/src/core/agents/create.spec.ts b/cli/src/core/agents/create.spec.tsindex ef9dafeaa..5e866d608 100644--- a/cli/src/core/agents/create.spec.ts+++ b/cli/src/core/agents/create.spec.ts@@ -30,7 +30,7 @@ vi.mock('../../engines/inProcess.js', async (real) => {const actual = await real<typeof import('../../engines/inProcess.js')>()return { ...actual, loadEngine: vi.fn(actual.loadEngine) }})-vi.mock('../../engines/opencode/version.js', () => ({ opencodeMajorVersion: vi.fn(() => 2) }))+vi.mock('../../engines/launchControl.js', () => ({ opencodeMajorVersion: vi.fn(() => 2) }))// The engines' folder trust (engines/launchPrep.ts), one spy per engine: never the person's own config.const trust = vi.hoisted(() => ({claudeTrusts: vi.fn((_path: string) => false), codexTrusts: vi.fn((_path: string, _profile?: string | null) => false),@@ -356,25 +356,17 @@ describe('creating an agent', () => {warn.mockRestore()})- it('refuses an OpenCode create whose code could not be loaded, before anything is written or any pane opens', async () => {- const warn = vi.spyOn(console, 'warn').mockImplementation(() => {})- vi.mocked(loadEngine).mockResolvedValueOnce(null)+ it('creates OpenCode from eager facts when optional code cannot load', async () => {+ vi.mocked(loadEngine).mockImplementation(() => new Promise(() => {}))const t = setup()- expect(await t.create(request({ engine: 'opencode', agent: 'reviewer', grid: { networkName: 'g' } }))).toEqual({ ok: false, error: 'ENGINE_UNAVAILABLE', detail: 'OpenCode\'s code could not be loaded' })- expect(warn).toHaveBeenCalledWith('[agent] create opencode refused · OpenCode\'s code could not be loaded')- expect(t.deps.gridLaunchMachine).not.toHaveBeenCalled()- expect(t.deps.installOpencodePlugin).not.toHaveBeenCalled()- expect(createAndRegisterPane).not.toHaveBeenCalled()- // Any other engine's launch loads nothing, and its machine facts are asked for that engine.- vi.mocked(loadEngine).mockClear()+ await t.create(request({ engine: 'opencode', agent: 'reviewer' }))+ expect(namedAgentArgs).toHaveBeenLastCalledWith('opencode', 'reviewer', 2)+ expect(createAndRegisterPane).toHaveBeenCalledOnce()+ expect(t.deps.installOpencodePlugin).toHaveBeenCalledWith(4242)+ expect(loadEngine).not.toHaveBeenCalled()buildGridLaunch.mockResolvedValueOnce({ ok: false, error: 'GRID_UNSUPPORTED', detail: 'no' })await t.create(request({ engine: 'claude', agent: 'reviewer', grid: { networkName: 'g' } }))- expect(loadEngine).not.toHaveBeenCalled()expect(t.deps.gridLaunchMachine).toHaveBeenCalledWith('claude')- // With OpenCode's code, its own probe names the version its named agent opens for.- await t.create(request({ engine: 'opencode', agent: 'reviewer' }))- expect(namedAgentArgs).toHaveBeenLastCalledWith('opencode', 'reviewer', 2)- warn.mockRestore()})it('opens as a named agent, with a first prompt, and does not install an engine with a path override', async () => {diff --git a/cli/src/core/agents/create.ts b/cli/src/core/agents/create.tsindex 6cdfe85fb..19f485bec 100644--- a/cli/src/core/agents/create.ts+++ b/cli/src/core/agents/create.ts@@ -17,7 +17,7 @@ import { harnessEnvToClear, type DshAccount } from '../../dsh/launch.js'import { dshPinnedPermissionMode } from '../../dsh/manifest.js'import { incompatibleHarnessEngine } from '../../dsh/compatibility.js'import type { DshThrough } from './dshThrough.js'-import { loadEngine } from '../../engines/inProcess.js'+import * as opencodeLaunch from '../../engines/launchControl.js'import { isTerminalEngine, type AgentEngine } from '../../engines/types.js'import { engineLabel } from '../../lib/agentNames.js'import { createAndRegisterPane } from '../../lib/createAgentPane.js'@@ -116,15 +116,8 @@ export function createAgentCreator({console.warn(`[agent] create refused · ${engine} · ${refusal.detail}`)return { ok: false, ...refusal }}- // Which OpenCode is installed decides its argv: v2's TUI exits on v1's flags. Its probe is OpenCode's own code,- // loaded for an OpenCode launch alone (engines/inProcess.ts), here before anything is written: without it the- // launch is refused, never given a guessed argv.- const opencode = engine === 'opencode' ? await loadEngine('opencode') : null- if (engine === 'opencode' && !opencode) {- const detail = 'OpenCode\'s code could not be loaded'- console.warn(`[agent] create opencode refused · ${detail}`)- return { ok: false, error: 'ENGINE_UNAVAILABLE', detail }- }+ // Native version and model control are eager; optional readers never decide whether a launch can proceed.+ const opencode = engine === 'opencode' ? opencodeLaunch : null// Harness-created sessions are easy to distinguish from a user's organic tmux sessions while// retaining the engine and a collision-resistant creation suffix for diagnostics. Computed// before the grid block because a file-configured engine keys its config directory on it.diff --git a/cli/src/core/agents/externalPreflight.spec.ts b/cli/src/core/agents/externalPreflight.spec.tsindex bda030565..ad67f7445 100644--- a/cli/src/core/agents/externalPreflight.spec.ts+++ b/cli/src/core/agents/externalPreflight.spec.ts@@ -26,7 +26,8 @@ it('refuses a missing or changing folder or unsupported permissions before engin})it('requires OpenCode launch support and hooks before any external owner can be stopped', async () => {vi.mocked(loadEngine).mockResolvedValueOnce(null)- expect(await setup().prepare(row('opencode'), session)).not.toBeNull()+ expect(await setup().prepare(row('opencode'), session)).toBeNull()+ expect(loadEngine).not.toHaveBeenCalled()expect(await setup({ installOpencodePlugin: async () => false }).prepare(row('opencode'), session)).not.toBeNull()const enabled = setup()expect(await enabled.prepare(row('opencode'), session)).toBeNull()diff --git a/cli/src/core/agents/externalPreflight.ts b/cli/src/core/agents/externalPreflight.tsindex 159519fd0..29c4ca916 100644--- a/cli/src/core/agents/externalPreflight.ts+++ b/cli/src/core/agents/externalPreflight.ts@@ -1,5 +1,4 @@/** Verify a resumable launch before asking an external terminal to quit. */-import { loadEngine } from '../../engines/inProcess.js'import { engineHooks } from '../../engines/hooks.js'import { buildEngineCommandArgv, refusePermissionFlagIfUnsupported } from '../../lib/engineLaunch.js'import { workspaceMissing } from '../../lib/workspaceCheck.js'@@ -17,8 +16,7 @@ export function createExternalPreflight(deps: {if (deps.blocksFolder(session.cwd)) return { detail: 'Waiting for the workspace operation to finish.' }const refused = await refusePermissionFlagIfUnsupported(row.engine, row)if (refused) return refused- if (row.engine === 'opencode' && (!await loadEngine('opencode')- || !deps.hooksDisabled && !await deps.installOpencodePlugin(deps.hookPort))) {+ if (row.engine === 'opencode' && !deps.hooksDisabled && !await deps.installOpencodePlugin(deps.hookPort)) {return { detail: 'Waiting for OpenCode’s launch support to become available.' }}if (row.codexHome && !deps.hooksDisabled) engineHooks.codex.installIn(deps.hookPort, row.codexHome)diff --git a/cli/src/core/agents/fork.spec.ts b/cli/src/core/agents/fork.spec.tsindex ecf37f989..7e3503a07 100644--- a/cli/src/core/agents/fork.spec.ts+++ b/cli/src/core/agents/fork.spec.ts@@ -18,7 +18,7 @@ vi.mock('../../engines/inProcess.js', async (real) => {const actual = await real<typeof import('../../engines/inProcess.js')>()return { ...actual, loadEngine: vi.fn(actual.loadEngine) }})-vi.mock('../../engines/opencode/version.js', () => ({ opencodeMajorVersion: vi.fn(() => 2) }))+vi.mock('../../engines/launchControl.js', () => ({ opencodeMajorVersion: vi.fn(() => 2) }))vi.mock('../../lib/createAgentPane.js', () => ({ createAndRegisterPane: vi.fn() }))vi.mock('../../lib/engineBin.js', async (real) => ({ ...await real<object>(), enginePathOverride: vi.fn(() => null) }))vi.mock('../../lib/engineInstall.js', async (real) => ({ ...await real<object>(), engineInstallRecipe: vi.fn(() => ({ install: 'recipe' })) }))@@ -175,26 +175,15 @@ describe('forking an agent', () => {expect(createAndRegisterPane).not.toHaveBeenCalled()})- it('refuses to fork OpenCode when its code could not be loaded, having written nothing, and loads nothing for another engine', async () => {+ it('forks OpenCode with eager version facts while optional code is unavailable', async () => {const { loadEngine } = await import('../../engines/inProcess.js')- vi.mocked(loadEngine).mockResolvedValueOnce(null)- vi.mocked(installedDsh).mockReturnValue({ manifest: { name: 'Blender' } } as never)- const refused = setup(source({ engine: 'opencode', agent: 'reviewer', dsh: 'blender' } as Partial<RegisteredSession>))- expect(await refused.fork({ agentId: 'a1', name: null, prompt: null }))- .toEqual({ ok: false, error: 'ENGINE_UNAVAILABLE', detail: 'OpenCode\'s code could not be loaded' })- // No instruction files prepared, no harness runtime folder, no relaunch overrides, no pane.- expect(prepareInstructionWrites).not.toHaveBeenCalled()- expect(launchDsh).not.toHaveBeenCalled()- expect(refused.deps.relaunchOverrides).not.toHaveBeenCalled()- expect(createAndRegisterPane).not.toHaveBeenCalled()- vi.mocked(installedDsh).mockReset().mockReturnValue(undefined)- vi.mocked(loadEngine).mockClear()- await setup(source({ agent: 'reviewer' } as Partial<RegisteredSession>)).fork({ agentId: 'a1', name: null, prompt: null })- expect(loadEngine).not.toHaveBeenCalled()+ vi.mocked(loadEngine).mockResolvedValue(null)+ await setup(source({ agent: 'reviewer' })).fork({ agentId: 'a1', name: null, prompt: null })expect(supportsNamedAgent).toHaveBeenLastCalledWith('claude', null)- // With OpenCode's code, its own probe names the version the fork's named agent is checked against.- await setup(source({ engine: 'opencode', agent: 'reviewer' } as Partial<RegisteredSession>)).fork({ agentId: 'a1', name: null, prompt: null })+ await setup(source({ engine: 'opencode', agent: 'reviewer' })).fork({ agentId: 'a1', name: null, prompt: null })expect(supportsNamedAgent).toHaveBeenLastCalledWith('opencode', 2)+ expect(createAndRegisterPane).toHaveBeenCalledTimes(2)+ expect(loadEngine).not.toHaveBeenCalled()})it('carries the harness and the named agent over, when the engine still takes it', async () => {diff --git a/cli/src/core/agents/fork.ts b/cli/src/core/agents/fork.tsindex dcbe9d009..268d12cf9 100644--- a/cli/src/core/agents/fork.ts+++ b/cli/src/core/agents/fork.ts@@ -13,7 +13,7 @@ import type { BackendSocket } from '../../backendSocket.js'import { installedDsh } from '../../dsh/installed.js'import { harnessEnvToClear } from '../../dsh/launch.js'import type { DshThrough } from './dshThrough.js'-import { loadEngine } from '../../engines/inProcess.js'+import * as opencodeLaunch from '../../engines/launchControl.js'import type { TurnRecaps } from '../turns/recaps.js'import { createAndRegisterPane } from '../../lib/createAgentPane.js'import { enginePathOverride } from '../../lib/engineBin.js'@@ -75,10 +75,7 @@ export function createAgentForker({}const plan = planFork({ engine, sessionId: source.sessionId, name: sourceName, cwd: source.cwd }, memory, prompt)if (!plan.ok) return { ok: false, error: plan.error, detail: plan.detail }- // Which OpenCode is installed decides a fork's named agent (below). Its probe is OpenCode's own code, loaded for- // OpenCode alone (engines/inProcess.ts), here before anything is written: without it, no fork.- const opencode = engine === 'opencode' ? await loadEngine('opencode') : null- if (engine === 'opencode' && !opencode) return { ok: false, error: 'ENGINE_UNAVAILABLE', detail: 'OpenCode\'s code could not be loaded' }+ const opencode = engine === 'opencode' ? opencodeLaunch : nullconst label = buildHarnessSessionLabel(engine)await prepareInstructionWrites(source.cwd)diff --git a/cli/src/core/agents/launch.spec.ts b/cli/src/core/agents/launch.spec.tsindex b00f0dfc1..66d423819 100644--- a/cli/src/core/agents/launch.spec.ts+++ b/cli/src/core/agents/launch.spec.ts@@ -37,21 +37,14 @@ function setup() {describe('relaunch helpers', () => {afterEach(() => { vi.restoreAllMocks(); vi.clearAllMocks() })- it('refuses an OpenCode relaunch whose code could not be loaded, having written nothing, and loads nothing for another engine', async () => {+ it('relaunches with eager control when optional OpenCode code cannot load', async () => {const { deps, helpers } = setup()- vi.mocked(loadEngine).mockResolvedValueOnce(null)- expect(await helpers.relaunchOverrides(session({ engine: 'opencode' }))).toEqual({ ok: false, error: 'ENGINE_UNAVAILABLE', detail: 'OpenCode\'s code could not be loaded' })- // No instruction files prepared, no API notes, no overrides built.- expect(prepareInstructionWrites).not.toHaveBeenCalled()- expect(deps.prepareApiTools).not.toHaveBeenCalled()- expect(buildLaunchOverrides).not.toHaveBeenCalled()- vi.mocked(loadEngine).mockClear()+ vi.mocked(loadEngine).mockImplementation(() => new Promise(() => {}))+ expect(await helpers.relaunchOverrides(session({ engine: 'opencode' }))).toEqual({ ok: true })expect(await helpers.relaunchOverrides(session())).toEqual({ ok: true })- expect(loadEngine).not.toHaveBeenCalled()expect(prepareInstructionWrites).toHaveBeenCalledWith('/work')- // With OpenCode's code, an OpenCode relaunch is built.- expect(await helpers.relaunchOverrides(session({ engine: 'opencode' }))).toEqual({ ok: true })- expect(loadEngine).toHaveBeenCalledWith('opencode')+ expect(deps.prepareApiTools).toHaveBeenCalledWith('/work', 'opencode')+ expect(loadEngine).not.toHaveBeenCalled()})it('rebuilds a launch from the row: its DSH, folder and named agent, whatever the source adds', async () => {diff --git a/cli/src/core/agents/launch.ts b/cli/src/core/agents/launch.tsindex 24fccc254..dd294f9eb 100644--- a/cli/src/core/agents/launch.ts+++ b/cli/src/core/agents/launch.ts@@ -6,7 +6,6 @@** Moved verbatim out of `runForeground` (the core boundary, step 10: docs/design/2026-10-03-harnessd.md).*/-import { loadEngine } from '../../engines/inProcess.js'import { prepareResume, repairedItemsName } from '../../engines/launchPrep.js'import { dropPermissionFlagIfUnsupported } from '../../lib/engineLaunch.js'import { gridUnavailable, type GridLaunchAnswer, type GridLaunchRequest } from '../../lib/gridLaunchWire.js'@@ -47,11 +46,6 @@ export function createLaunchHelpers({ prepareApiTools, launchOverridesDeps, setG// pasted since takes effect, and a removed API is refused rather than kept on its old key: the models// service reads them as it builds the launch (`buildLaunchOverrides`, `refresh`).const relaunchOverrides = async (session: RegisteredSession, source: LaunchSource = session): Promise<LaunchOverridesResult> => {- // OpenCode's version decides its relaunch's argv, read by OpenCode's own code (lib/launchOverrides.ts): loaded- // here, before anything is written, and the relaunch refused without it.- if (session.engine === 'opencode' && !await loadEngine('opencode')) {- return { ok: false, error: 'ENGINE_UNAVAILABLE', detail: 'OpenCode\'s code could not be loaded' }- }await prepareInstructionWrites(session.cwd)prepareApiTools(session.cwd, session.engine)const result = await buildLaunchOverrides(launchOverridesDeps, session.engine, { dsh: session.dsh ?? null, dshRuntime: session.dshRuntime ?? null, cwd: session.cwd, agent: session.agent ?? null, scmLaunch: session.scmLaunch ?? null, ...source, gridLaunch: source.gridLaunch ?? null }, session.agentId)diff --git a/cli/src/core/agents/launches.spec.ts b/cli/src/core/agents/launches.spec.tsindex ae7bb3cc0..78a551f71 100644--- a/cli/src/core/agents/launches.spec.ts+++ b/cli/src/core/agents/launches.spec.ts@@ -5,7 +5,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'import { installedDsh } from '../../dsh/installed.js'import { dshSupportedEngines } from '../../dsh/manifest.js'import { loadEngine } from '../../engines/inProcess.js'-import { opencodeMajorVersion } from '../../engines/opencode/version.js'+import { opencodeMajorVersion } from '../../engines/launchControl.js'import { AgentCreationReceiptError, AgentCreationReceipts, type AgentCreationOutcome } from '../../lib/agentCreationReceipt.js'import type { AgentFrame } from '../../lib/agentFrame.js'import { MAX_FIRST_PROMPT_CHARS, permissionModeApproves, permissionModeFlags, supportsFirstPrompt, supportsNamedAgent } from '../../lib/engineLaunch.js'@@ -36,7 +36,7 @@ vi.mock('../../engines/inProcess.js', async (real) => {const actual = await real<typeof import('../../engines/inProcess.js')>()return { ...actual, loadEngine: vi.fn(actual.loadEngine) }})-vi.mock('../../engines/opencode/version.js', async (real) => ({ ...await real<object>(), opencodeMajorVersion: vi.fn(() => 1) }))+vi.mock('../../engines/launchControl.js', async (real) => ({ ...await real<object>(), opencodeMajorVersion: vi.fn(() => 1) }))vi.mock('../../lib/newAgentModel.js', async (real) => ({...await real<object>(), parseNewAgentModel: vi.fn(() => ({ state: 'absent' })),}))@@ -173,12 +173,11 @@ describe('agent_create, refused before any pane exists', () => {expect(create).not.toHaveBeenCalled()})- it('an OpenCode named agent when OpenCode\'s code could not be loaded, and loads nothing for another engine\'s', async () => {+ it('validates a named OpenCode launch without optional code', async () => {const { ask, create } = setup()- vi.mocked(loadEngine).mockResolvedValueOnce(null)- expect(await ask({ engine: 'opencode', cwd: '/w', agent: 'reviewer' })).toStrictEqual({ error: 'ENGINE_UNAVAILABLE', detail: 'OpenCode\'s code could not be loaded' })- expect(create).not.toHaveBeenCalled()- vi.mocked(loadEngine).mockClear()+ vi.mocked(loadEngine).mockResolvedValue(null)+ await ask({ engine: 'opencode', cwd: '/w', agent: 'reviewer' })+ expect(create).toHaveBeenCalledOnce()await ask({ engine: 'claude', cwd: '/w', agent: 'reviewer' })expect(loadEngine).not.toHaveBeenCalled()})diff --git a/cli/src/core/agents/launches.ts b/cli/src/core/agents/launches.tsindex a4569cc59..9eb1a7c7a 100644--- a/cli/src/core/agents/launches.ts+++ b/cli/src/core/agents/launches.ts@@ -15,7 +15,7 @@ import type { BackendSocket } from '../../backendSocket.js'import { installedDsh } from '../../dsh/installed.js'import { DSH_ID_RE, dshSupportedEngines } from '../../dsh/manifest.js'import { folderTrust } from '../../engines/launchPrep.js'-import { loadEngine } from '../../engines/inProcess.js'+import * as opencodeLaunch from '../../engines/launchControl.js'import { ENGINES, isTerminalEngine, type AgentEngine } from '../../engines/types.js'import { AgentCreationReceiptError, creationFingerprint, validCreationId, type AgentCreationReceipts, type AgentCreationStatus } from '../../lib/agentCreationReceipt.js'import type { AgentFrame } from '../../lib/agentFrame.js'@@ -184,12 +184,8 @@ export function createLaunchRequests({ receipts, createAgent, forkAgent, resumeAif (typeof payload.agent !== 'string' || !AGENT_NAME_RE.test(payload.agent)) {reply({ error: 'INVALID_AGENT', detail: 'agent must be 1-64 letters, digits, `-` or `_`' }); return}- // OpenCode v2 counts as no way: its TUI exits 1 on `--agent` (engineLaunch.ts). Which one is installed is- // read by OpenCode's own probe, loaded for OpenCode alone (engines/inProcess.ts); without it, no launch.- const opencode = engine === 'opencode' ? await loadEngine('opencode') : null- if (engine === 'opencode' && !opencode) {- reply({ error: 'ENGINE_UNAVAILABLE', detail: 'OpenCode\'s code could not be loaded' }); return- }+ // v2's TUI cannot open a named agent. Its native version control is eager.+ const opencode = engine === 'opencode' ? opencodeLaunch : nullif (!supportsNamedAgent(engine, opencode ? opencode.opencodeMajorVersion() : null)) {reply({ error: 'AGENT_UNSUPPORTED', detail: new NamedAgentUnsupportedError(engine).message }); return}diff --git a/cli/src/core/agents/retarget.spec.ts b/cli/src/core/agents/retarget.spec.tsindex 0a2a27c80..99218a02c 100644--- a/cli/src/core/agents/retarget.spec.ts+++ b/cli/src/core/agents/retarget.spec.ts@@ -1,6 +1,6 @@import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'-import { applyOpencodeSessionModel, parseOpencodeModelId } from '../../engines/opencode/sessionModel.js'-import { isOpencodeV2 } from '../../engines/opencode/version.js'+import { applyOpencodeSessionModel, parseOpencodeModelId } from '../../engines/launchControl.js'+import { isOpencodeV2 } from '../../engines/launchControl.js'import { binaryOnPath } from '../../lib/binaryOnPath.js'import { validateLaunchOverrides } from '../../lib/launchOverrides.js'import type { RegisteredSession } from '../../lib/registry.js'@@ -11,17 +11,17 @@ import { clearPaneRemainOnExit } from '../../lib/tmux.js'import { workspaceMissing } from '../../lib/workspaceCheck.js'import { createAgentRetargeter, type RetargetDeps } from './retarget.js'-vi.mock('../../engines/opencode/sessionModel.js', async (real) => ({+vi.mock('../../engines/launchControl.js', async (real) => ({...await real<object>(),+ isOpencodeV2: vi.fn(() => false), opencodeMajorVersion: vi.fn(() => 1),applyOpencodeSessionModel: vi.fn(async () => ({ ok: true })),parseOpencodeModelId: vi.fn((id: string) => ({ providerID: id.split('/')[0], modelID: id.split('/')[1] })),}))-// OpenCode's version probe is its own code, loaded for an OpenCode launch alone; a test may say it could not be.+// Optional readers cannot gate a native launch decision.vi.mock('../../engines/inProcess.js', async (real) => {const actual = await real<typeof import('../../engines/inProcess.js')>()return { ...actual, loadEngine: vi.fn(actual.loadEngine) }})-vi.mock('../../engines/opencode/version.js', () => ({ isOpencodeV2: vi.fn(() => false), opencodeMajorVersion: vi.fn(() => 1) }))vi.mock('../../lib/binaryOnPath.js', () => ({ binaryOnPath: vi.fn(() => true) }))vi.mock('../../lib/gatewayRuntime.js', async (real) => ({ ...await real<object>(), probeGatewayRuntime: vi.fn(async () => ({ kind: 'none' })) }))vi.mock('../../lib/gridLaunchWire.js', async (real) => ({ ...await real<object>(), describeGridLaunch: vi.fn(() => 'claude on Home'), gridEnvVarNames: vi.fn(() => ['ANTHROPIC_BASE_URL']) }))@@ -240,13 +240,21 @@ describe('retargeting an agent', () => {vi.mocked(binaryOnPath).mockReturnValue(true)})- it('refuses to move OpenCode when its code could not be loaded, before the pane is touched', async () => {+ it.each(['missing', 'stalled'])('moves OpenCode while its optional reader is %s', async mode => {const { loadEngine } = await import('../../engines/inProcess.js')- vi.mocked(loadEngine).mockResolvedValueOnce(null)- const run = setup(agent({ engine: 'opencode' } as Partial<RegisteredSession>))- expect(await run.retarget({ agentId: 'a1', grid })).toEqual({ ok: false, error: 'ENGINE_UNAVAILABLE', detail: 'OpenCode\'s code could not be loaded' })- expect(restartAgent).not.toHaveBeenCalled()- expect(applyOpencodeSessionModel).not.toHaveBeenCalled()+ vi.mocked(loadEngine).mockImplementation(() => mode === 'stalled' ? new Promise(() => {}) : Promise.resolve(null))+ const run = setup(agent({ engine: 'opencode' } as Partial<RegisteredSession>), {+ relaunchOverrides: vi.fn(async () => ({ ok: true, overrides: { sessionModel: 'grid/big', gridLaunchRecord: null } })) as never,+ })+ let timer: ReturnType<typeof setTimeout> | undefined+ try {+ const result = await Promise.race([run.retarget({ agentId: 'a1', grid }),+ new Promise(resolve => { timer = setTimeout(() => resolve('blocked on optional code'), 1000) })])+ expect(result).toEqual({ ok: true })+ expect(restartAgent).toHaveBeenCalledOnce()+ expect(applyOpencodeSessionModel).toHaveBeenCalledOnce()+ expect(loadEngine).not.toHaveBeenCalled()+ } finally { clearTimeout(timer) }})it('reads the live bypass flag only when the row recorded none, and announces nothing for a row gone meanwhile', async () => {diff --git a/cli/src/core/agents/retarget.ts b/cli/src/core/agents/retarget.tsindex 1546aa9c8..99615f0ce 100644--- a/cli/src/core/agents/retarget.ts+++ b/cli/src/core/agents/retarget.ts@@ -12,7 +12,7 @@* Moved verbatim out of `runForeground` (the core boundary, step 11: docs/design/2026-10-03-harnessd.md).*/import type { BackendSocket } from '../../backendSocket.js'-import { loadEngine } from '../../engines/inProcess.js'+import * as opencodeLaunch from '../../engines/launchControl.js'import { binaryOnPath } from '../../lib/binaryOnPath.js'import { probeGatewayRuntime } from '../../lib/gatewayRuntime.js'import { describeGridLaunch, gridEnvVarNames } from '../../lib/gridLaunchWire.js'@@ -126,10 +126,7 @@ export function createAgentRetargeter({// sqlite3 (`applyOpencodeSessionModel`).const rewritesOpencodeSession = session.engine === 'opencode' && !!session.sessionId&& (!!grid || !!remembered?.includes('/'))- // OpenCode's version and its session's model are OpenCode's own code, loaded for OpenCode alone- // (engines/inProcess.ts), as the launch overrides above loaded it: without it, the move is refused.- const opencode = session.engine === 'opencode' ? await loadEngine('opencode') : null- if (session.engine === 'opencode' && !opencode) return { ok: false, error: 'ENGINE_UNAVAILABLE', detail: 'OpenCode\'s code could not be loaded' }+ const opencode = session.engine === 'opencode' ? opencodeLaunch : nullconst opencodeMajor = opencode ? opencode.opencodeMajorVersion() : nullif (rewritesOpencodeSession && opencode && !opencode.isOpencodeV2(opencodeMajor) && !binaryOnPath('sqlite3')) {return {diff --git a/cli/src/core/main.ts b/cli/src/core/main.tsindex cdf2bd287..cbfe67703 100644--- a/cli/src/core/main.ts+++ b/cli/src/core/main.ts@@ -5,7 +5,8 @@ import { createModelControls } from './engines/modelControls.js'import { masterRunsEngineModelControl } from '../harnessd/services.js'import { createScreens } from './engines/screens.js'import { createScreenTransport } from './engines/screenTransport.js'-import { engineNow, inProcessScreen, preloadEngine } from '../engines/inProcess.js'+import { inProcessScreen, preloadEngine } from '../engines/inProcess.js'+import { opencodeMajorVersion } from '../engines/launchControl.js'import { masterRunsEngineScreen } from '../harnessd/services.js'import { createSubmissions } from './engines/submissions.js'import { createNativeControls } from './engines/nativeControls.js'@@ -1946,7 +1947,7 @@ async function runForeground(session: AuthSession | null): Promise<void> {*/const gridLaunchMachine = (engine: AgentEngine): GridLaunchMachine => ({hermesSystemManaged: existsSync(HERMES_SYSTEM_MANAGED_DIR),- opencodeMajor: engine === 'opencode' ? engineNow('opencode', 'an OpenCode launch was built')?.opencodeMajorVersion() ?? null : null,+ opencodeMajor: engine === 'opencode' ? opencodeMajorVersion() : null,})/**diff --git a/cli/src/engines/__fixtures__/opencode-launch.golden.json b/cli/src/engines/__fixtures__/opencode-launch.golden.jsonnew file mode 100644index 000000000..4050bb31c--- /dev/null+++ b/cli/src/engines/__fixtures__/opencode-launch.golden.json@@ -0,0 +1,1592 @@+{+ "v1 create named=false": {+ "result": {+ "ok": false,+ "error": "RECORDED",+ "detail": "No pane is opened by this golden."+ },+ "panes": [+ {+ "argv": [+ "/bin/sh",+ "-ic",+ ". '<root>/adapter_data_dir/launch/<script>.sh'",+ "harness-engine",+ "<root>/work",+ "<root>/bin/v1",+ "--prompt",+ "fixture prompt"+ ],+ "env": {+ "OPENCODE_CONFIG_CONTENT": "{\"permission\":\"ask\",\"model\":\"opencode/muse-spark-1.3-contributor-free\",\"small_model\":\"opencode/muse-spark-1.3-contributor-free\",\"provider\":{\"opencode\":{\"models\":{\"muse-spark-1.3-contributor-free\":{\"options\":{\"reasoningEffort\":\"xhigh\"}}}}},\"agent\":{\"build\":{\"model\":\"opencode/muse-spark-1.3-contributor-free\",\"variant\":\"xhigh\"},\"plan\":{\"model\":\"opencode/muse-spark-1.3-contributor-free\",\"variant\":\"xhigh\"}}}"+ },+ "engine": "opencode",+ "agent": null,+ "permissionMode": null,+ "grid": null,+ "gridLaunchRecord": null,+ "script": "rm -f -- '<root>/adapter_data_dir/launch/<script>.sh'\nharness_nofile=$(ulimit -S -n 2>/dev/null) || harness_nofile=unlimited; if [ \"$harness_nofile\" != unlimited ] && [ \"$harness_nofile\" -lt 65536 ] 2>/dev/null; then ulimit -S -n 65536 2>/dev/null || ulimit -S -n \"$(ulimit -H -n)\" 2>/dev/null || true; fi; unset harness_nofile\nharness_stopped() {\n [ \"$harness_status\" -gt 128 ] 2>/dev/null || return 1\n harness_signal=$(kill -l \"$harness_status\" 2>/dev/null) || return 1\n case $harness_signal in\n STOP|TSTP|TTIN|TTOU|SIGSTOP|SIGTSTP|SIGTTIN|SIGTTOU) jobs %% >/dev/null 2>&1 ;;\n *) return 1 ;;\n esac\n}\nharness_fg() {\n harness_now=$(date +%s 2>/dev/null) || harness_now=0\n if [ $((harness_now - harness_resumed)) -le 1 ]; then harness_quick=$((harness_quick + 1)); else harness_quick=0; fi\n harness_resumes=$((harness_resumes + 1))\n case $harness_signal in *TTIN|*TTOU) harness_stuck=$harness_quick ;; *) harness_stuck=0 ;; esac\n if [ \"$harness_stuck\" -ge 5 ] || { [ -z \"${ZSH_VERSION:-}\" ] && [ \"$harness_resumes\" -ge 1000 ]; }; then\n kill -9 %% 2>/dev/null\n harness_status=137\n return 0\n fi\n if [ \"$harness_quick\" -ge 3 ]; then harness_waited=$(sleep 1) || :; fi\n harness_resumed=$(date +%s 2>/dev/null) || harness_resumed=0\n harness_status=0\n fg >/dev/null || harness_status=$?\n}\nharness_resume() {\n if [ -n \"${ZSH_VERSION:-}\" ]; then\n while harness_stopped; do harness_fg; done\n return 0\n fi\n harness_stopped || return 0\n harness_fg\n harness_resume\n}\nharness_resumed=0\nharness_quick=0\nharness_resumes=0\nharness_after() {\n if [ \"$harness_status\" -eq 127 ]; then exit 127; fi\n [ -n \"${TMUX_PANE:-}\" ] && { '/fixture/bin/tmux' set-option -p -t \"$TMUX_PANE\" @harness_engine_exit \"$harness_status\" >/dev/null 2>&1 || '/fixture/bin/tmux' set-option -w -t \"$TMUX_PANE\" @harness_engine_exit \"$harness_status\" >/dev/null 2>&1; } || true\n if ! [ -t 0 ]; then exit \"$harness_status\"; fi\n if harness_tty=$(stty -g 2>/dev/null) && stty -icanon -echo min 0 time 3 2>/dev/null; then\n while harness_waiting=$(dd bs=65536 count=1 2>/dev/null | wc -c) && [ \"$((harness_waiting))\" -gt 0 ]; do :; done\n stty \"$harness_tty\" 2>/dev/null || true\n fi\n printf '\\n%s\\n' 'harness: v1 exited ('\"$harness_status\"'). This pane is a shell now — run v1 again, or stop the pane.'\n exec '/bin/sh'\n}\nunset HARNESS_DSH HARNESS_DSH_DIR HARNESS_WORKSPACE HARNESS_CONTEXT_FILE HARNESS_SKILLS_DIR HARNESS_PRIVATE_GRID\nGRID_NO_UPDATE_CHECK=1\nexport GRID_NO_UPDATE_CHECK\nif ! cd -- \"$1\"; then printf '%s\\n' 'harness: the selected working directory is unavailable.' >&2; exit 1; fi\nif ! [ -r . ]; then printf '%s\\n' \"harness: cannot read $PWD — the agent was not started.\" 'harness: check the folder'\"'\"'s permissions for this user.' >&2; exit 1; fi\nshift\nif [ -n \"${ZSH_VERSION:-}\" ]; then setopt monitor 2>/dev/null || :; else set -m 2>/dev/null || :; fi\ntrap : INT QUIT\nharness_engine_bin=$1\nshift\nharness_status=0\n\"$harness_engine_bin\" \"$@\" || harness_status=$?\nharness_resume\nharness_after"+ }+ ],+ "native": []+ },+ "v1 fork named=false": {+ "result": {+ "ok": false,+ "error": "RECORDED",+ "detail": "No pane is opened by this golden."+ },+ "panes": [+ {+ "argv": [+ "/bin/sh",+ "-ic",+ ". '<root>/adapter_data_dir/launch/<script>.sh'",+ "harness-engine",+ "<root>/work",+ "<root>/bin/v1",+ "-m",+ "fixture/model#high",+ "--prompt",+ "You are a fork of the agent \"work · ses_\" in <root>/work. It kept working; you are its copy, picking up from what it knew. Here is its recent history, oldest first.\n\nAsked: fixture ask\n\nIts last full answer:\nfixture answer\n\nContinue from there. Your task now: try another approach"+ ],+ "engine": "opencode",+ "agent": null,+ "forkedFrom": {+ "agentId": "fixture-agent",+ "name": "work · ses_",+ "sessionId": "ses_fixture"+ },+ "permissionMode": null,+ "grid": null,+ "gridLaunchRecord": null,+ "script": "rm -f -- '<root>/adapter_data_dir/launch/<script>.sh'\nharness_nofile=$(ulimit -S -n 2>/dev/null) || harness_nofile=unlimited; if [ \"$harness_nofile\" != unlimited ] && [ \"$harness_nofile\" -lt 65536 ] 2>/dev/null; then ulimit -S -n 65536 2>/dev/null || ulimit -S -n \"$(ulimit -H -n)\" 2>/dev/null || true; fi; unset harness_nofile\nharness_stopped() {\n [ \"$harness_status\" -gt 128 ] 2>/dev/null || return 1\n harness_signal=$(kill -l \"$harness_status\" 2>/dev/null) || return 1\n case $harness_signal in\n STOP|TSTP|TTIN|TTOU|SIGSTOP|SIGTSTP|SIGTTIN|SIGTTOU) jobs %% >/dev/null 2>&1 ;;\n *) return 1 ;;\n esac\n}\nharness_fg() {\n harness_now=$(date +%s 2>/dev/null) || harness_now=0\n if [ $((harness_now - harness_resumed)) -le 1 ]; then harness_quick=$((harness_quick + 1)); else harness_quick=0; fi\n harness_resumes=$((harness_resumes + 1))\n case $harness_signal in *TTIN|*TTOU) harness_stuck=$harness_quick ;; *) harness_stuck=0 ;; esac\n if [ \"$harness_stuck\" -ge 5 ] || { [ -z \"${ZSH_VERSION:-}\" ] && [ \"$harness_resumes\" -ge 1000 ]; }; then\n kill -9 %% 2>/dev/null\n harness_status=137\n return 0\n fi\n if [ \"$harness_quick\" -ge 3 ]; then harness_waited=$(sleep 1) || :; fi\n harness_resumed=$(date +%s 2>/dev/null) || harness_resumed=0\n harness_status=0\n fg >/dev/null || harness_status=$?\n}\nharness_resume() {\n if [ -n \"${ZSH_VERSION:-}\" ]; then\n while harness_stopped; do harness_fg; done\n return 0\n fi\n harness_stopped || return 0\n harness_fg\n harness_resume\n}\nharness_resumed=0\nharness_quick=0\nharness_resumes=0\nharness_after() {\n if [ \"$harness_status\" -eq 127 ]; then exit 127; fi\n [ -n \"${TMUX_PANE:-}\" ] && { '/fixture/bin/tmux' set-option -p -t \"$TMUX_PANE\" @harness_engine_exit \"$harness_status\" >/dev/null 2>&1 || '/fixture/bin/tmux' set-option -w -t \"$TMUX_PANE\" @harness_engine_exit \"$harness_status\" >/dev/null 2>&1; } || true\n if ! [ -t 0 ]; then exit \"$harness_status\"; fi\n if harness_tty=$(stty -g 2>/dev/null) && stty -icanon -echo min 0 time 3 2>/dev/null; then\n while harness_waiting=$(dd bs=65536 count=1 2>/dev/null | wc -c) && [ \"$((harness_waiting))\" -gt 0 ]; do :; done\n stty \"$harness_tty\" 2>/dev/null || true\n fi\n printf '\\n%s\\n' 'harness: v1 exited ('\"$harness_status\"'). This pane is a shell now — run v1 again, or stop the pane.'\n exec '/bin/sh'\n}\nunset HARNESS_DSH HARNESS_DSH_DIR HARNESS_WORKSPACE HARNESS_CONTEXT_FILE HARNESS_SKILLS_DIR HARNESS_PRIVATE_GRID\nGRID_NO_UPDATE_CHECK=1\nexport GRID_NO_UPDATE_CHECK\nif ! cd -- \"$1\"; then printf '%s\\n' 'harness: the selected working directory is unavailable.' >&2; exit 1; fi\nif ! [ -r . ]; then printf '%s\\n' \"harness: cannot read $PWD — the agent was not started.\" 'harness: check the folder'\"'\"'s permissions for this user.' >&2; exit 1; fi\nshift\nif [ -n \"${ZSH_VERSION:-}\" ]; then setopt monitor 2>/dev/null || :; else set -m 2>/dev/null || :; fi\ntrap : INT QUIT\nharness_engine_bin=$1\nshift\nharness_status=0\n\"$harness_engine_bin\" \"$@\" || harness_status=$?\nharness_resume\nharness_after"+ }+ ],+ "native": [+ {+ "binary": "opencode",+ "args": [+ "--version"+ ],+ "cwd": "<repo>"+ }+ ]+ },+ "v1 relaunch named=false": {+ "result": {+ "ok": true,+ "overrides": {+ "env": {},+ "extraArgs": [+ "-m",+ "fixture/model#high"+ ],+ "clearEnv": [+ "HARNESS_DSH",+ "HARNESS_DSH_DIR",+ "HARNESS_WORKSPACE",+ "HARNESS_CONTEXT_FILE",+ "HARNESS_SKILLS_DIR",+ "HARNESS_PRIVATE_GRID"+ ],+ "sessionModel": "fixture/model#high"+ }+ },+ "native": []+ },+ "v1 create named=true": {+ "result": {+ "ok": false,+ "error": "RECORDED",+ "detail": "No pane is opened by this golden."+ },+ "panes": [+ {+ "argv": [+ "/bin/sh",+ "-ic",+ ". '<root>/adapter_data_dir/launch/<script>.sh'",+ "harness-engine",+ "<root>/work",+ "<root>/bin/v1",+ "--agent",+ "reviewer",+ "--prompt",+ "fixture prompt"+ ],+ "env": {+ "OPENCODE_CONFIG_CONTENT": "{\"permission\":\"ask\",\"model\":\"opencode/muse-spark-1.3-contributor-free\",\"small_model\":\"opencode/muse-spark-1.3-contributor-free\",\"provider\":{\"opencode\":{\"models\":{\"muse-spark-1.3-contributor-free\":{\"options\":{\"reasoningEffort\":\"xhigh\"}}}}},\"agent\":{\"build\":{\"model\":\"opencode/muse-spark-1.3-contributor-free\",\"variant\":\"xhigh\"},\"plan\":{\"model\":\"opencode/muse-spark-1.3-contributor-free\",\"variant\":\"xhigh\"}}}"+ },+ "engine": "opencode",+ "agent": "reviewer",+ "permissionMode": null,+ "grid": null,+ "gridLaunchRecord": null,+ "script": "rm -f -- '<root>/adapter_data_dir/launch/<script>.sh'\nharness_nofile=$(ulimit -S -n 2>/dev/null) || harness_nofile=unlimited; if [ \"$harness_nofile\" != unlimited ] && [ \"$harness_nofile\" -lt 65536 ] 2>/dev/null; then ulimit -S -n 65536 2>/dev/null || ulimit -S -n \"$(ulimit -H -n)\" 2>/dev/null || true; fi; unset harness_nofile\nharness_stopped() {\n [ \"$harness_status\" -gt 128 ] 2>/dev/null || return 1\n harness_signal=$(kill -l \"$harness_status\" 2>/dev/null) || return 1\n case $harness_signal in\n STOP|TSTP|TTIN|TTOU|SIGSTOP|SIGTSTP|SIGTTIN|SIGTTOU) jobs %% >/dev/null 2>&1 ;;\n *) return 1 ;;\n esac\n}\nharness_fg() {\n harness_now=$(date +%s 2>/dev/null) || harness_now=0\n if [ $((harness_now - harness_resumed)) -le 1 ]; then harness_quick=$((harness_quick + 1)); else harness_quick=0; fi\n harness_resumes=$((harness_resumes + 1))\n case $harness_signal in *TTIN|*TTOU) harness_stuck=$harness_quick ;; *) harness_stuck=0 ;; esac\n if [ \"$harness_stuck\" -ge 5 ] || { [ -z \"${ZSH_VERSION:-}\" ] && [ \"$harness_resumes\" -ge 1000 ]; }; then\n kill -9 %% 2>/dev/null\n harness_status=137\n return 0\n fi\n if [ \"$harness_quick\" -ge 3 ]; then harness_waited=$(sleep 1) || :; fi\n harness_resumed=$(date +%s 2>/dev/null) || harness_resumed=0\n harness_status=0\n fg >/dev/null || harness_status=$?\n}\nharness_resume() {\n if [ -n \"${ZSH_VERSION:-}\" ]; then\n while harness_stopped; do harness_fg; done\n return 0\n fi\n harness_stopped || return 0\n harness_fg\n harness_resume\n}\nharness_resumed=0\nharness_quick=0\nharness_resumes=0\nharness_after() {\n if [ \"$harness_status\" -eq 127 ]; then exit 127; fi\n [ -n \"${TMUX_PANE:-}\" ] && { '/fixture/bin/tmux' set-option -p -t \"$TMUX_PANE\" @harness_engine_exit \"$harness_status\" >/dev/null 2>&1 || '/fixture/bin/tmux' set-option -w -t \"$TMUX_PANE\" @harness_engine_exit \"$harness_status\" >/dev/null 2>&1; } || true\n if ! [ -t 0 ]; then exit \"$harness_status\"; fi\n if harness_tty=$(stty -g 2>/dev/null) && stty -icanon -echo min 0 time 3 2>/dev/null; then\n while harness_waiting=$(dd bs=65536 count=1 2>/dev/null | wc -c) && [ \"$((harness_waiting))\" -gt 0 ]; do :; done\n stty \"$harness_tty\" 2>/dev/null || true\n fi\n printf '\\n%s\\n' 'harness: v1 exited ('\"$harness_status\"'). This pane is a shell now — run v1 again, or stop the pane.'\n exec '/bin/sh'\n}\nunset HARNESS_DSH HARNESS_DSH_DIR HARNESS_WORKSPACE HARNESS_CONTEXT_FILE HARNESS_SKILLS_DIR HARNESS_PRIVATE_GRID\nGRID_NO_UPDATE_CHECK=1\nexport GRID_NO_UPDATE_CHECK\nif ! cd -- \"$1\"; then printf '%s\\n' 'harness: the selected working directory is unavailable.' >&2; exit 1; fi\nif ! [ -r . ]; then printf '%s\\n' \"harness: cannot read $PWD — the agent was not started.\" 'harness: check the folder'\"'\"'s permissions for this user.' >&2; exit 1; fi\nshift\nif [ -n \"${ZSH_VERSION:-}\" ]; then setopt monitor 2>/dev/null || :; else set -m 2>/dev/null || :; fi\ntrap : INT QUIT\nharness_engine_bin=$1\nshift\nharness_status=0\n\"$harness_engine_bin\" \"$@\" || harness_status=$?\nharness_resume\nharness_after"+ }+ ],+ "native": []+ },+ "v1 fork named=true": {+ "result": {+ "ok": false,+ "error": "RECORDED",+ "detail": "No pane is opened by this golden."+ },+ "panes": [+ {+ "argv": [+ "/bin/sh",+ "-ic",+ ". '<root>/adapter_data_dir/launch/<script>.sh'",+ "harness-engine",+ "<root>/work",+ "<root>/bin/v1",+ "-m",+ "fixture/model#high",+ "--agent",+ "reviewer",+ "--prompt",+ "You are a fork of the agent \"work · ses_\" in <root>/work. It kept working; you are its copy, picking up from what it knew. Here is its recent history, oldest first.\n\nAsked: fixture ask\n\nIts last full answer:\nfixture answer\n\nContinue from there. Your task now: try another approach"+ ],+ "engine": "opencode",+ "agent": "reviewer",+ "forkedFrom": {+ "agentId": "fixture-agent",+ "name": "work · ses_",+ "sessionId": "ses_fixture"+ },+ "permissionMode": null,+ "grid": null,+ "gridLaunchRecord": null,+ "script": "rm -f -- '<root>/adapter_data_dir/launch/<script>.sh'\nharness_nofile=$(ulimit -S -n 2>/dev/null) || harness_nofile=unlimited; if [ \"$harness_nofile\" != unlimited ] && [ \"$harness_nofile\" -lt 65536 ] 2>/dev/null; then ulimit -S -n 65536 2>/dev/null || ulimit -S -n \"$(ulimit -H -n)\" 2>/dev/null || true; fi; unset harness_nofile\nharness_stopped() {\n [ \"$harness_status\" -gt 128 ] 2>/dev/null || return 1\n harness_signal=$(kill -l \"$harness_status\" 2>/dev/null) || return 1\n case $harness_signal in\n STOP|TSTP|TTIN|TTOU|SIGSTOP|SIGTSTP|SIGTTIN|SIGTTOU) jobs %% >/dev/null 2>&1 ;;\n *) return 1 ;;\n esac\n}\nharness_fg() {\n harness_now=$(date +%s 2>/dev/null) || harness_now=0\n if [ $((harness_now - harness_resumed)) -le 1 ]; then harness_quick=$((harness_quick + 1)); else harness_quick=0; fi\n harness_resumes=$((harness_resumes + 1))\n case $harness_signal in *TTIN|*TTOU) harness_stuck=$harness_quick ;; *) harness_stuck=0 ;; esac\n if [ \"$harness_stuck\" -ge 5 ] || { [ -z \"${ZSH_VERSION:-}\" ] && [ \"$harness_resumes\" -ge 1000 ]; }; then\n kill -9 %% 2>/dev/null\n harness_status=137\n return 0\n fi\n if [ \"$harness_quick\" -ge 3 ]; then harness_waited=$(sleep 1) || :; fi\n harness_resumed=$(date +%s 2>/dev/null) || harness_resumed=0\n harness_status=0\n fg >/dev/null || harness_status=$?\n}\nharness_resume() {\n if [ -n \"${ZSH_VERSION:-}\" ]; then\n while harness_stopped; do harness_fg; done\n return 0\n fi\n harness_stopped || return 0\n harness_fg\n harness_resume\n}\nharness_resumed=0\nharness_quick=0\nharness_resumes=0\nharness_after() {\n if [ \"$harness_status\" -eq 127 ]; then exit 127; fi\n [ -n \"${TMUX_PANE:-}\" ] && { '/fixture/bin/tmux' set-option -p -t \"$TMUX_PANE\" @harness_engine_exit \"$harness_status\" >/dev/null 2>&1 || '/fixture/bin/tmux' set-option -w -t \"$TMUX_PANE\" @harness_engine_exit \"$harness_status\" >/dev/null 2>&1; } || true\n if ! [ -t 0 ]; then exit \"$harness_status\"; fi\n if harness_tty=$(stty -g 2>/dev/null) && stty -icanon -echo min 0 time 3 2>/dev/null; then\n while harness_waiting=$(dd bs=65536 count=1 2>/dev/null | wc -c) && [ \"$((harness_waiting))\" -gt 0 ]; do :; done\n stty \"$harness_tty\" 2>/dev/null || true\n fi\n printf '\\n%s\\n' 'harness: v1 exited ('\"$harness_status\"'). This pane is a shell now — run v1 again, or stop the pane.'\n exec '/bin/sh'\n}\nunset HARNESS_DSH HARNESS_DSH_DIR HARNESS_WORKSPACE HARNESS_CONTEXT_FILE HARNESS_SKILLS_DIR HARNESS_PRIVATE_GRID\nGRID_NO_UPDATE_CHECK=1\nexport GRID_NO_UPDATE_CHECK\nif ! cd -- \"$1\"; then printf '%s\\n' 'harness: the selected working directory is unavailable.' >&2; exit 1; fi\nif ! [ -r . ]; then printf '%s\\n' \"harness: cannot read $PWD — the agent was not started.\" 'harness: check the folder'\"'\"'s permissions for this user.' >&2; exit 1; fi\nshift\nif [ -n \"${ZSH_VERSION:-}\" ]; then setopt monitor 2>/dev/null || :; else set -m 2>/dev/null || :; fi\ntrap : INT QUIT\nharness_engine_bin=$1\nshift\nharness_status=0\n\"$harness_engine_bin\" \"$@\" || harness_status=$?\nharness_resume\nharness_after"+ }+ ],+ "native": []+ },+ "v1 relaunch named=true": {+ "result": {+ "ok": true,+ "overrides": {+ "env": {},+ "extraArgs": [+ "-m",+ "fixture/model#high",+ "--agent",+ "reviewer"+ ],+ "clearEnv": [+ "HARNESS_DSH",+ "HARNESS_DSH_DIR",+ "HARNESS_WORKSPACE",+ "HARNESS_CONTEXT_FILE",+ "HARNESS_SKILLS_DIR",+ "HARNESS_PRIVATE_GRID"+ ],+ "sessionModel": "fixture/model#high"+ }+ },+ "native": []+ },+ "v1 retarget own login": {+ "result": {+ "ok": true+ },+ "events": [+ [+ "cancel"+ ],+ [+ "holdRoute"+ ],+ [+ "clearEnv",+ [+ "GRID_API_KEY",+ "OPENCODE_CONFIG"+ ]+ ],+ [+ "holdOpen"+ ],+ [+ "terminate"+ ],+ [+ "respawn",+ [+ "/bin/sh",+ "-ic",+ ". '<root>/adapter_data_dir/launch/<script>.sh'",+ "harness-engine",+ "<root>/work",+ "<root>/bin/v1",+ "--session",+ "ses_fixture",+ "-m",+ "fixture/model#high",+ "--agent",+ "reviewer"+ ],+ {+ "env": {},+ "extraArgs": [+ "-m",+ "fixture/model#high",+ "--agent",+ "reviewer"+ ],+ "clearEnv": [+ "HARNESS_DSH",+ "HARNESS_DSH_DIR",+ "HARNESS_WORKSPACE",+ "HARNESS_CONTEXT_FILE",+ "HARNESS_SKILLS_DIR",+ "HARNESS_PRIVATE_GRID"+ ],+ "sessionModel": "fixture/model#high"+ },+ "rm -f -- '<root>/adapter_data_dir/launch/<script>.sh'\nharness_nofile=$(ulimit -S -n 2>/dev/null) || harness_nofile=unlimited; if [ \"$harness_nofile\" != unlimited ] && [ \"$harness_nofile\" -lt 65536 ] 2>/dev/null; then ulimit -S -n 65536 2>/dev/null || ulimit -S -n \"$(ulimit -H -n)\" 2>/dev/null || true; fi; unset harness_nofile\nharness_stopped() {\n [ \"$harness_status\" -gt 128 ] 2>/dev/null || return 1\n harness_signal=$(kill -l \"$harness_status\" 2>/dev/null) || return 1\n case $harness_signal in\n STOP|TSTP|TTIN|TTOU|SIGSTOP|SIGTSTP|SIGTTIN|SIGTTOU) jobs %% >/dev/null 2>&1 ;;\n *) return 1 ;;\n esac\n}\nharness_fg() {\n harness_now=$(date +%s 2>/dev/null) || harness_now=0\n if [ $((harness_now - harness_resumed)) -le 1 ]; then harness_quick=$((harness_quick + 1)); else harness_quick=0; fi\n harness_resumes=$((harness_resumes + 1))\n case $harness_signal in *TTIN|*TTOU) harness_stuck=$harness_quick ;; *) harness_stuck=0 ;; esac\n if [ \"$harness_stuck\" -ge 5 ] || { [ -z \"${ZSH_VERSION:-}\" ] && [ \"$harness_resumes\" -ge 1000 ]; }; then\n kill -9 %% 2>/dev/null\n harness_status=137\n return 0\n fi\n if [ \"$harness_quick\" -ge 3 ]; then harness_waited=$(sleep 1) || :; fi\n harness_resumed=$(date +%s 2>/dev/null) || harness_resumed=0\n harness_status=0\n fg >/dev/null || harness_status=$?\n}\nharness_resume() {\n if [ -n \"${ZSH_VERSION:-}\" ]; then\n while harness_stopped; do harness_fg; done\n return 0\n fi\n harness_stopped || return 0\n harness_fg\n harness_resume\n}\nharness_resumed=0\nharness_quick=0\nharness_resumes=0\nharness_after() {\n if [ \"$harness_status\" -eq 127 ]; then exit 127; fi\n [ -n \"${TMUX_PANE:-}\" ] && { '/fixture/bin/tmux' set-option -p -t \"$TMUX_PANE\" @harness_engine_exit \"$harness_status\" >/dev/null 2>&1 || '/fixture/bin/tmux' set-option -w -t \"$TMUX_PANE\" @harness_engine_exit \"$harness_status\" >/dev/null 2>&1; } || true\n if ! [ -t 0 ]; then exit \"$harness_status\"; fi\n if harness_tty=$(stty -g 2>/dev/null) && stty -icanon -echo min 0 time 3 2>/dev/null; then\n while harness_waiting=$(dd bs=65536 count=1 2>/dev/null | wc -c) && [ \"$((harness_waiting))\" -gt 0 ]; do :; done\n stty \"$harness_tty\" 2>/dev/null || true\n fi\n printf '\\n%s\\n' 'harness: v1 exited ('\"$harness_status\"'). This pane is a shell now — run v1 again, or stop the pane.'\n exec '/bin/sh'\n}\nGRID_NO_UPDATE_CHECK=1\nexport GRID_NO_UPDATE_CHECK\nif ! cd -- \"$1\"; then printf '%s\\n' 'harness: the selected working directory is unavailable.' >&2; exit 1; fi\nif ! [ -r . ]; then printf '%s\\n' \"harness: cannot read $PWD — the agent was not started.\" 'harness: check the folder'\"'\"'s permissions for this user.' >&2; exit 1; fi\nshift\nif [ -n \"${ZSH_VERSION:-}\" ]; then setopt monitor 2>/dev/null || :; else set -m 2>/dev/null || :; fi\ntrap : INT QUIT\nharness_engine_bin=$1\nshift\nharness_status=0\n\"$harness_engine_bin\" \"$@\" || harness_status=$?\nharness_resume\nharness_after"+ ],+ [+ "process",+ "fixture-agent",+ {+ "pid": 4343,+ "executable": "opencode",+ "startMarker": "replacement"+ },+ "none"+ ],+ [+ "grid",+ "fixture-agent",+ null+ ],+ [+ "active",+ "fixture-agent",+ true+ ],+ [+ "announce"+ ],+ [+ "assignment"+ ],+ [+ "release"+ ],+ [+ "releaseRoute"+ ]+ ],+ "native": [+ {+ "control": [+ "cancel"+ ]+ },+ {+ "control": [+ "holdRoute"+ ]+ },+ {+ "binary": "sqlite3",+ "args": [+ "-batch",+ "-bail",+ "<root>/fixture.db",+ "PRAGMA busy_timeout = 5000;\nBEGIN IMMEDIATE;\nUPDATE message SET data = json_set(data, '$.model.providerID', 'fixture', '$.model.modelID', 'model#high') WHERE id = (SELECT id FROM message WHERE session_id = 'ses_fixture' AND json_extract(data, '$.role') = 'user' ORDER BY time_created DESC LIMIT 1);\nSELECT changes();\nUPDATE session SET model = json_object('id', 'model#high', 'providerID', 'fixture', 'variant', 'default') WHERE id = 'ses_fixture' AND EXISTS (SELECT 1 FROM message WHERE session_id = 'ses_fixture' AND json_extract(data, '$.role') = 'user');\nSELECT changes();\nCOMMIT;"+ ]+ },+ {+ "control": [+ "clearEnv",+ [+ "GRID_API_KEY",+ "OPENCODE_CONFIG"+ ]+ ]+ },+ {+ "control": [+ "holdOpen"+ ]+ },+ {+ "control": [+ "terminate"+ ]+ },+ {+ "control": [+ "respawn",+ [+ "/bin/sh",+ "-ic",+ ". '<root>/adapter_data_dir/launch/<script>.sh'",+ "harness-engine",+ "<root>/work",+ "<root>/bin/v1",+ "--session",+ "ses_fixture",+ "-m",+ "fixture/model#high",+ "--agent",+ "reviewer"+ ],+ {+ "env": {},+ "extraArgs": [+ "-m",+ "fixture/model#high",+ "--agent",+ "reviewer"+ ],+ "clearEnv": [+ "HARNESS_DSH",+ "HARNESS_DSH_DIR",+ "HARNESS_WORKSPACE",+ "HARNESS_CONTEXT_FILE",+ "HARNESS_SKILLS_DIR",+ "HARNESS_PRIVATE_GRID"+ ],+ "sessionModel": "fixture/model#high"+ },+ "rm -f -- '<root>/adapter_data_dir/launch/<script>.sh'\nharness_nofile=$(ulimit -S -n 2>/dev/null) || harness_nofile=unlimited; if [ \"$harness_nofile\" != unlimited ] && [ \"$harness_nofile\" -lt 65536 ] 2>/dev/null; then ulimit -S -n 65536 2>/dev/null || ulimit -S -n \"$(ulimit -H -n)\" 2>/dev/null || true; fi; unset harness_nofile\nharness_stopped() {\n [ \"$harness_status\" -gt 128 ] 2>/dev/null || return 1\n harness_signal=$(kill -l \"$harness_status\" 2>/dev/null) || return 1\n case $harness_signal in\n STOP|TSTP|TTIN|TTOU|SIGSTOP|SIGTSTP|SIGTTIN|SIGTTOU) jobs %% >/dev/null 2>&1 ;;\n *) return 1 ;;\n esac\n}\nharness_fg() {\n harness_now=$(date +%s 2>/dev/null) || harness_now=0\n if [ $((harness_now - harness_resumed)) -le 1 ]; then harness_quick=$((harness_quick + 1)); else harness_quick=0; fi\n harness_resumes=$((harness_resumes + 1))\n case $harness_signal in *TTIN|*TTOU) harness_stuck=$harness_quick ;; *) harness_stuck=0 ;; esac\n if [ \"$harness_stuck\" -ge 5 ] || { [ -z \"${ZSH_VERSION:-}\" ] && [ \"$harness_resumes\" -ge 1000 ]; }; then\n kill -9 %% 2>/dev/null\n harness_status=137\n return 0\n fi\n if [ \"$harness_quick\" -ge 3 ]; then harness_waited=$(sleep 1) || :; fi\n harness_resumed=$(date +%s 2>/dev/null) || harness_resumed=0\n harness_status=0\n fg >/dev/null || harness_status=$?\n}\nharness_resume() {\n if [ -n \"${ZSH_VERSION:-}\" ]; then\n while harness_stopped; do harness_fg; done\n return 0\n fi\n harness_stopped || return 0\n harness_fg\n harness_resume\n}\nharness_resumed=0\nharness_quick=0\nharness_resumes=0\nharness_after() {\n if [ \"$harness_status\" -eq 127 ]; then exit 127; fi\n [ -n \"${TMUX_PANE:-}\" ] && { '/fixture/bin/tmux' set-option -p -t \"$TMUX_PANE\" @harness_engine_exit \"$harness_status\" >/dev/null 2>&1 || '/fixture/bin/tmux' set-option -w -t \"$TMUX_PANE\" @harness_engine_exit \"$harness_status\" >/dev/null 2>&1; } || true\n if ! [ -t 0 ]; then exit \"$harness_status\"; fi\n if harness_tty=$(stty -g 2>/dev/null) && stty -icanon -echo min 0 time 3 2>/dev/null; then\n while harness_waiting=$(dd bs=65536 count=1 2>/dev/null | wc -c) && [ \"$((harness_waiting))\" -gt 0 ]; do :; done\n stty \"$harness_tty\" 2>/dev/null || true\n fi\n printf '\\n%s\\n' 'harness: v1 exited ('\"$harness_status\"'). This pane is a shell now — run v1 again, or stop the pane.'\n exec '/bin/sh'\n}\nGRID_NO_UPDATE_CHECK=1\nexport GRID_NO_UPDATE_CHECK\nif ! cd -- \"$1\"; then printf '%s\\n' 'harness: the selected working directory is unavailable.' >&2; exit 1; fi\nif ! [ -r . ]; then printf '%s\\n' \"harness: cannot read $PWD — the agent was not started.\" 'harness: check the folder'\"'\"'s permissions for this user.' >&2; exit 1; fi\nshift\nif [ -n \"${ZSH_VERSION:-}\" ]; then setopt monitor 2>/dev/null || :; else set -m 2>/dev/null || :; fi\ntrap : INT QUIT\nharness_engine_bin=$1\nshift\nharness_status=0\n\"$harness_engine_bin\" \"$@\" || harness_status=$?\nharness_resume\nharness_after"+ ]+ },+ {+ "control": [+ "process",+ "fixture-agent",+ {+ "pid": 4343,+ "executable": "opencode",+ "startMarker": "replacement"+ },+ "none"+ ]+ },+ {+ "control": [+ "grid",+ "fixture-agent",+ null+ ]+ },+ {+ "control": [+ "active",+ "fixture-agent",+ true+ ]+ },+ {+ "control": [+ "announce"+ ]+ },+ {+ "control": [+ "assignment"+ ]+ },+ {+ "control": [+ "release"+ ]+ },+ {+ "control": [+ "releaseRoute"+ ]+ }+ ]+ },+ "v2 create named=false": {+ "result": {+ "ok": false,+ "error": "RECORDED",+ "detail": "No pane is opened by this golden."+ },+ "panes": [+ {+ "argv": [+ "/bin/sh",+ "-ic",+ ". '<root>/adapter_data_dir/launch/<script>.sh'",+ "harness-engine",+ "<root>/work",+ "<root>/bin/v2",+ "--prompt",+ "fixture prompt"+ ],+ "env": {+ "OPENCODE_CONFIG_CONTENT": "{\"permission\":\"ask\",\"model\":\"opencode/muse-spark-1.3-contributor-free\",\"small_model\":\"opencode/muse-spark-1.3-contributor-free\",\"provider\":{\"opencode\":{\"models\":{\"muse-spark-1.3-contributor-free\":{\"options\":{\"reasoningEffort\":\"xhigh\"}}}}},\"agent\":{\"build\":{\"model\":\"opencode/muse-spark-1.3-contributor-free\",\"variant\":\"xhigh\"},\"plan\":{\"model\":\"opencode/muse-spark-1.3-contributor-free\",\"variant\":\"xhigh\"}}}"+ },+ "engine": "opencode",+ "agent": null,+ "permissionMode": null,+ "grid": null,+ "gridLaunchRecord": null,+ "script": "rm -f -- '<root>/adapter_data_dir/launch/<script>.sh'\nharness_nofile=$(ulimit -S -n 2>/dev/null) || harness_nofile=unlimited; if [ \"$harness_nofile\" != unlimited ] && [ \"$harness_nofile\" -lt 65536 ] 2>/dev/null; then ulimit -S -n 65536 2>/dev/null || ulimit -S -n \"$(ulimit -H -n)\" 2>/dev/null || true; fi; unset harness_nofile\nharness_stopped() {\n [ \"$harness_status\" -gt 128 ] 2>/dev/null || return 1\n harness_signal=$(kill -l \"$harness_status\" 2>/dev/null) || return 1\n case $harness_signal in\n STOP|TSTP|TTIN|TTOU|SIGSTOP|SIGTSTP|SIGTTIN|SIGTTOU) jobs %% >/dev/null 2>&1 ;;\n *) return 1 ;;\n esac\n}\nharness_fg() {\n harness_now=$(date +%s 2>/dev/null) || harness_now=0\n if [ $((harness_now - harness_resumed)) -le 1 ]; then harness_quick=$((harness_quick + 1)); else harness_quick=0; fi\n harness_resumes=$((harness_resumes + 1))\n case $harness_signal in *TTIN|*TTOU) harness_stuck=$harness_quick ;; *) harness_stuck=0 ;; esac\n if [ \"$harness_stuck\" -ge 5 ] || { [ -z \"${ZSH_VERSION:-}\" ] && [ \"$harness_resumes\" -ge 1000 ]; }; then\n kill -9 %% 2>/dev/null\n harness_status=137\n return 0\n fi\n if [ \"$harness_quick\" -ge 3 ]; then harness_waited=$(sleep 1) || :; fi\n harness_resumed=$(date +%s 2>/dev/null) || harness_resumed=0\n harness_status=0\n fg >/dev/null || harness_status=$?\n}\nharness_resume() {\n if [ -n \"${ZSH_VERSION:-}\" ]; then\n while harness_stopped; do harness_fg; done\n return 0\n fi\n harness_stopped || return 0\n harness_fg\n harness_resume\n}\nharness_resumed=0\nharness_quick=0\nharness_resumes=0\nharness_after() {\n if [ \"$harness_status\" -eq 127 ]; then exit 127; fi\n [ -n \"${TMUX_PANE:-}\" ] && { '/fixture/bin/tmux' set-option -p -t \"$TMUX_PANE\" @harness_engine_exit \"$harness_status\" >/dev/null 2>&1 || '/fixture/bin/tmux' set-option -w -t \"$TMUX_PANE\" @harness_engine_exit \"$harness_status\" >/dev/null 2>&1; } || true\n if ! [ -t 0 ]; then exit \"$harness_status\"; fi\n if harness_tty=$(stty -g 2>/dev/null) && stty -icanon -echo min 0 time 3 2>/dev/null; then\n while harness_waiting=$(dd bs=65536 count=1 2>/dev/null | wc -c) && [ \"$((harness_waiting))\" -gt 0 ]; do :; done\n stty \"$harness_tty\" 2>/dev/null || true\n fi\n printf '\\n%s\\n' 'harness: v2 exited ('\"$harness_status\"'). This pane is a shell now — run v2 again, or stop the pane.'\n exec '/bin/sh'\n}\nunset HARNESS_DSH HARNESS_DSH_DIR HARNESS_WORKSPACE HARNESS_CONTEXT_FILE HARNESS_SKILLS_DIR HARNESS_PRIVATE_GRID\nGRID_NO_UPDATE_CHECK=1\nexport GRID_NO_UPDATE_CHECK\nif ! cd -- \"$1\"; then printf '%s\\n' 'harness: the selected working directory is unavailable.' >&2; exit 1; fi\nif ! [ -r . ]; then printf '%s\\n' \"harness: cannot read $PWD — the agent was not started.\" 'harness: check the folder'\"'\"'s permissions for this user.' >&2; exit 1; fi\nshift\nif [ -n \"${ZSH_VERSION:-}\" ]; then setopt monitor 2>/dev/null || :; else set -m 2>/dev/null || :; fi\ntrap : INT QUIT\nharness_engine_bin=$1\nshift\nharness_status=0\n\"$harness_engine_bin\" \"$@\" || harness_status=$?\nharness_resume\nharness_after"+ }+ ],+ "native": []+ },+ "v2 fork named=false": {+ "result": {+ "ok": false,+ "error": "RECORDED",+ "detail": "No pane is opened by this golden."+ },+ "panes": [+ {+ "argv": [+ "/bin/sh",+ "-ic",+ ". '<root>/adapter_data_dir/launch/<script>.sh'",+ "harness-engine",+ "<root>/work",+ "<root>/bin/v2",+ "--prompt",+ "You are a fork of the agent \"work · ses_\" in <root>/work. It kept working; you are its copy, picking up from what it knew. Here is its recent history, oldest first.\n\nAsked: fixture ask\n\nIts last full answer:\nfixture answer\n\nContinue from there. Your task now: try another approach"+ ],+ "engine": "opencode",+ "agent": null,+ "forkedFrom": {+ "agentId": "fixture-agent",+ "name": "work · ses_",+ "sessionId": "ses_fixture"+ },+ "permissionMode": null,+ "grid": null,+ "gridLaunchRecord": null,+ "script": "rm -f -- '<root>/adapter_data_dir/launch/<script>.sh'\nharness_nofile=$(ulimit -S -n 2>/dev/null) || harness_nofile=unlimited; if [ \"$harness_nofile\" != unlimited ] && [ \"$harness_nofile\" -lt 65536 ] 2>/dev/null; then ulimit -S -n 65536 2>/dev/null || ulimit -S -n \"$(ulimit -H -n)\" 2>/dev/null || true; fi; unset harness_nofile\nharness_stopped() {\n [ \"$harness_status\" -gt 128 ] 2>/dev/null || return 1\n harness_signal=$(kill -l \"$harness_status\" 2>/dev/null) || return 1\n case $harness_signal in\n STOP|TSTP|TTIN|TTOU|SIGSTOP|SIGTSTP|SIGTTIN|SIGTTOU) jobs %% >/dev/null 2>&1 ;;\n *) return 1 ;;\n esac\n}\nharness_fg() {\n harness_now=$(date +%s 2>/dev/null) || harness_now=0\n if [ $((harness_now - harness_resumed)) -le 1 ]; then harness_quick=$((harness_quick + 1)); else harness_quick=0; fi\n harness_resumes=$((harness_resumes + 1))\n case $harness_signal in *TTIN|*TTOU) harness_stuck=$harness_quick ;; *) harness_stuck=0 ;; esac\n if [ \"$harness_stuck\" -ge 5 ] || { [ -z \"${ZSH_VERSION:-}\" ] && [ \"$harness_resumes\" -ge 1000 ]; }; then\n kill -9 %% 2>/dev/null\n harness_status=137\n return 0\n fi\n if [ \"$harness_quick\" -ge 3 ]; then harness_waited=$(sleep 1) || :; fi\n harness_resumed=$(date +%s 2>/dev/null) || harness_resumed=0\n harness_status=0\n fg >/dev/null || harness_status=$?\n}\nharness_resume() {\n if [ -n \"${ZSH_VERSION:-}\" ]; then\n while harness_stopped; do harness_fg; done\n return 0\n fi\n harness_stopped || return 0\n harness_fg\n harness_resume\n}\nharness_resumed=0\nharness_quick=0\nharness_resumes=0\nharness_after() {\n if [ \"$harness_status\" -eq 127 ]; then exit 127; fi\n [ -n \"${TMUX_PANE:-}\" ] && { '/fixture/bin/tmux' set-option -p -t \"$TMUX_PANE\" @harness_engine_exit \"$harness_status\" >/dev/null 2>&1 || '/fixture/bin/tmux' set-option -w -t \"$TMUX_PANE\" @harness_engine_exit \"$harness_status\" >/dev/null 2>&1; } || true\n if ! [ -t 0 ]; then exit \"$harness_status\"; fi\n if harness_tty=$(stty -g 2>/dev/null) && stty -icanon -echo min 0 time 3 2>/dev/null; then\n while harness_waiting=$(dd bs=65536 count=1 2>/dev/null | wc -c) && [ \"$((harness_waiting))\" -gt 0 ]; do :; done\n stty \"$harness_tty\" 2>/dev/null || true\n fi\n printf '\\n%s\\n' 'harness: v2 exited ('\"$harness_status\"'). This pane is a shell now — run v2 again, or stop the pane.'\n exec '/bin/sh'\n}\nunset HARNESS_DSH HARNESS_DSH_DIR HARNESS_WORKSPACE HARNESS_CONTEXT_FILE HARNESS_SKILLS_DIR HARNESS_PRIVATE_GRID\nGRID_NO_UPDATE_CHECK=1\nexport GRID_NO_UPDATE_CHECK\nif ! cd -- \"$1\"; then printf '%s\\n' 'harness: the selected working directory is unavailable.' >&2; exit 1; fi\nif ! [ -r . ]; then printf '%s\\n' \"harness: cannot read $PWD — the agent was not started.\" 'harness: check the folder'\"'\"'s permissions for this user.' >&2; exit 1; fi\nshift\nif [ -n \"${ZSH_VERSION:-}\" ]; then setopt monitor 2>/dev/null || :; else set -m 2>/dev/null || :; fi\ntrap : INT QUIT\nharness_engine_bin=$1\nshift\nharness_status=0\n\"$harness_engine_bin\" \"$@\" || harness_status=$?\nharness_resume\nharness_after"+ }+ ],+ "native": [+ {+ "binary": "opencode",+ "args": [+ "--version"+ ],+ "cwd": "<repo>"+ }+ ]+ },+ "v2 relaunch named=false": {+ "result": {+ "ok": true,+ "overrides": {+ "env": {},+ "extraArgs": [],+ "clearEnv": [+ "HARNESS_DSH",+ "HARNESS_DSH_DIR",+ "HARNESS_WORKSPACE",+ "HARNESS_CONTEXT_FILE",+ "HARNESS_SKILLS_DIR",+ "HARNESS_PRIVATE_GRID"+ ],+ "sessionModel": "fixture/model#high"+ }+ },+ "native": []+ },+ "v2 create named=true": {+ "result": {+ "threw": {+ "name": "NamedAgentUnsupportedError",+ "message": "opencode has no documented way to open as a named agent, so the agent was not created."+ }+ },+ "panes": [],+ "native": []+ },+ "v2 fork named=true": {+ "result": {+ "ok": false,+ "error": "RECORDED",+ "detail": "No pane is opened by this golden."+ },+ "panes": [+ {+ "argv": [+ "/bin/sh",+ "-ic",+ ". '<root>/adapter_data_dir/launch/<script>.sh'",+ "harness-engine",+ "<root>/work",+ "<root>/bin/v2",+ "--prompt",+ "You are a fork of the agent \"work · ses_\" in <root>/work. It kept working; you are its copy, picking up from what it knew. Here is its recent history, oldest first.\n\nAsked: fixture ask\n\nIts last full answer:\nfixture answer\n\nContinue from there. Your task now: try another approach"+ ],+ "engine": "opencode",+ "agent": "reviewer",+ "forkedFrom": {+ "agentId": "fixture-agent",+ "name": "work · ses_",+ "sessionId": "ses_fixture"+ },+ "permissionMode": null,+ "grid": null,+ "gridLaunchRecord": null,+ "script": "rm -f -- '<root>/adapter_data_dir/launch/<script>.sh'\nharness_nofile=$(ulimit -S -n 2>/dev/null) || harness_nofile=unlimited; if [ \"$harness_nofile\" != unlimited ] && [ \"$harness_nofile\" -lt 65536 ] 2>/dev/null; then ulimit -S -n 65536 2>/dev/null || ulimit -S -n \"$(ulimit -H -n)\" 2>/dev/null || true; fi; unset harness_nofile\nharness_stopped() {\n [ \"$harness_status\" -gt 128 ] 2>/dev/null || return 1\n harness_signal=$(kill -l \"$harness_status\" 2>/dev/null) || return 1\n case $harness_signal in\n STOP|TSTP|TTIN|TTOU|SIGSTOP|SIGTSTP|SIGTTIN|SIGTTOU) jobs %% >/dev/null 2>&1 ;;\n *) return 1 ;;\n esac\n}\nharness_fg() {\n harness_now=$(date +%s 2>/dev/null) || harness_now=0\n if [ $((harness_now - harness_resumed)) -le 1 ]; then harness_quick=$((harness_quick + 1)); else harness_quick=0; fi\n harness_resumes=$((harness_resumes + 1))\n case $harness_signal in *TTIN|*TTOU) harness_stuck=$harness_quick ;; *) harness_stuck=0 ;; esac\n if [ \"$harness_stuck\" -ge 5 ] || { [ -z \"${ZSH_VERSION:-}\" ] && [ \"$harness_resumes\" -ge 1000 ]; }; then\n kill -9 %% 2>/dev/null\n harness_status=137\n return 0\n fi\n if [ \"$harness_quick\" -ge 3 ]; then harness_waited=$(sleep 1) || :; fi\n harness_resumed=$(date +%s 2>/dev/null) || harness_resumed=0\n harness_status=0\n fg >/dev/null || harness_status=$?\n}\nharness_resume() {\n if [ -n \"${ZSH_VERSION:-}\" ]; then\n while harness_stopped; do harness_fg; done\n return 0\n fi\n harness_stopped || return 0\n harness_fg\n harness_resume\n}\nharness_resumed=0\nharness_quick=0\nharness_resumes=0\nharness_after() {\n if [ \"$harness_status\" -eq 127 ]; then exit 127; fi\n [ -n \"${TMUX_PANE:-}\" ] && { '/fixture/bin/tmux' set-option -p -t \"$TMUX_PANE\" @harness_engine_exit \"$harness_status\" >/dev/null 2>&1 || '/fixture/bin/tmux' set-option -w -t \"$TMUX_PANE\" @harness_engine_exit \"$harness_status\" >/dev/null 2>&1; } || true\n if ! [ -t 0 ]; then exit \"$harness_status\"; fi\n if harness_tty=$(stty -g 2>/dev/null) && stty -icanon -echo min 0 time 3 2>/dev/null; then\n while harness_waiting=$(dd bs=65536 count=1 2>/dev/null | wc -c) && [ \"$((harness_waiting))\" -gt 0 ]; do :; done\n stty \"$harness_tty\" 2>/dev/null || true\n fi\n printf '\\n%s\\n' 'harness: v2 exited ('\"$harness_status\"'). This pane is a shell now — run v2 again, or stop the pane.'\n exec '/bin/sh'\n}\nunset HARNESS_DSH HARNESS_DSH_DIR HARNESS_WORKSPACE HARNESS_CONTEXT_FILE HARNESS_SKILLS_DIR HARNESS_PRIVATE_GRID\nGRID_NO_UPDATE_CHECK=1\nexport GRID_NO_UPDATE_CHECK\nif ! cd -- \"$1\"; then printf '%s\\n' 'harness: the selected working directory is unavailable.' >&2; exit 1; fi\nif ! [ -r . ]; then printf '%s\\n' \"harness: cannot read $PWD — the agent was not started.\" 'harness: check the folder'\"'\"'s permissions for this user.' >&2; exit 1; fi\nshift\nif [ -n \"${ZSH_VERSION:-}\" ]; then setopt monitor 2>/dev/null || :; else set -m 2>/dev/null || :; fi\ntrap : INT QUIT\nharness_engine_bin=$1\nshift\nharness_status=0\n\"$harness_engine_bin\" \"$@\" || harness_status=$?\nharness_resume\nharness_after"+ }+ ],+ "native": []+ },+ "v2 relaunch named=true": {+ "result": {+ "ok": true,+ "overrides": {+ "env": {},+ "extraArgs": [],+ "clearEnv": [+ "HARNESS_DSH",+ "HARNESS_DSH_DIR",+ "HARNESS_WORKSPACE",+ "HARNESS_CONTEXT_FILE",+ "HARNESS_SKILLS_DIR",+ "HARNESS_PRIVATE_GRID"+ ],+ "sessionModel": "fixture/model#high"+ }+ },+ "native": []+ },+ "v2 retarget own login": {+ "result": {+ "ok": true+ },+ "events": [+ [+ "cancel"+ ],+ [+ "holdRoute"+ ],+ [+ "clearEnv",+ [+ "GRID_API_KEY",+ "OPENCODE_CONFIG"+ ]+ ],+ [+ "holdOpen"+ ],+ [+ "terminate"+ ],+ [+ "respawn",+ [+ "/bin/sh",+ "-ic",+ ". '<root>/adapter_data_dir/launch/<script>.sh'",+ "harness-engine",+ "<root>/work",+ "<root>/bin/v2",+ "--session",+ "ses_fixture"+ ],+ {+ "env": {},+ "extraArgs": [],+ "clearEnv": [+ "HARNESS_DSH",+ "HARNESS_DSH_DIR",+ "HARNESS_WORKSPACE",+ "HARNESS_CONTEXT_FILE",+ "HARNESS_SKILLS_DIR",+ "HARNESS_PRIVATE_GRID"+ ],+ "sessionModel": "fixture/model#high"+ },+ "rm -f -- '<root>/adapter_data_dir/launch/<script>.sh'\nharness_nofile=$(ulimit -S -n 2>/dev/null) || harness_nofile=unlimited; if [ \"$harness_nofile\" != unlimited ] && [ \"$harness_nofile\" -lt 65536 ] 2>/dev/null; then ulimit -S -n 65536 2>/dev/null || ulimit -S -n \"$(ulimit -H -n)\" 2>/dev/null || true; fi; unset harness_nofile\nharness_stopped() {\n [ \"$harness_status\" -gt 128 ] 2>/dev/null || return 1\n harness_signal=$(kill -l \"$harness_status\" 2>/dev/null) || return 1\n case $harness_signal in\n STOP|TSTP|TTIN|TTOU|SIGSTOP|SIGTSTP|SIGTTIN|SIGTTOU) jobs %% >/dev/null 2>&1 ;;\n *) return 1 ;;\n esac\n}\nharness_fg() {\n harness_now=$(date +%s 2>/dev/null) || harness_now=0\n if [ $((harness_now - harness_resumed)) -le 1 ]; then harness_quick=$((harness_quick + 1)); else harness_quick=0; fi\n harness_resumes=$((harness_resumes + 1))\n case $harness_signal in *TTIN|*TTOU) harness_stuck=$harness_quick ;; *) harness_stuck=0 ;; esac\n if [ \"$harness_stuck\" -ge 5 ] || { [ -z \"${ZSH_VERSION:-}\" ] && [ \"$harness_resumes\" -ge 1000 ]; }; then\n kill -9 %% 2>/dev/null\n harness_status=137\n return 0\n fi\n if [ \"$harness_quick\" -ge 3 ]; then harness_waited=$(sleep 1) || :; fi\n harness_resumed=$(date +%s 2>/dev/null) || harness_resumed=0\n harness_status=0\n fg >/dev/null || harness_status=$?\n}\nharness_resume() {\n if [ -n \"${ZSH_VERSION:-}\" ]; then\n while harness_stopped; do harness_fg; done\n return 0\n fi\n harness_stopped || return 0\n harness_fg\n harness_resume\n}\nharness_resumed=0\nharness_quick=0\nharness_resumes=0\nharness_after() {\n if [ \"$harness_status\" -eq 127 ]; then exit 127; fi\n [ -n \"${TMUX_PANE:-}\" ] && { '/fixture/bin/tmux' set-option -p -t \"$TMUX_PANE\" @harness_engine_exit \"$harness_status\" >/dev/null 2>&1 || '/fixture/bin/tmux' set-option -w -t \"$TMUX_PANE\" @harness_engine_exit \"$harness_status\" >/dev/null 2>&1; } || true\n if ! [ -t 0 ]; then exit \"$harness_status\"; fi\n if harness_tty=$(stty -g 2>/dev/null) && stty -icanon -echo min 0 time 3 2>/dev/null; then\n while harness_waiting=$(dd bs=65536 count=1 2>/dev/null | wc -c) && [ \"$((harness_waiting))\" -gt 0 ]; do :; done\n stty \"$harness_tty\" 2>/dev/null || true\n fi\n printf '\\n%s\\n' 'harness: v2 exited ('\"$harness_status\"'). This pane is a shell now — run v2 again, or stop the pane.'\n exec '/bin/sh'\n}\nGRID_NO_UPDATE_CHECK=1\nexport GRID_NO_UPDATE_CHECK\nif ! cd -- \"$1\"; then printf '%s\\n' 'harness: the selected working directory is unavailable.' >&2; exit 1; fi\nif ! [ -r . ]; then printf '%s\\n' \"harness: cannot read $PWD — the agent was not started.\" 'harness: check the folder'\"'\"'s permissions for this user.' >&2; exit 1; fi\nshift\nif [ -n \"${ZSH_VERSION:-}\" ]; then setopt monitor 2>/dev/null || :; else set -m 2>/dev/null || :; fi\ntrap : INT QUIT\nharness_engine_bin=$1\nshift\nharness_status=0\n\"$harness_engine_bin\" \"$@\" || harness_status=$?\nharness_resume\nharness_after"+ ],+ [+ "process",+ "fixture-agent",+ {+ "pid": 4343,+ "executable": "opencode",+ "startMarker": "replacement"+ },+ "none"+ ],+ [+ "grid",+ "fixture-agent",+ null+ ],+ [+ "active",+ "fixture-agent",+ true+ ],+ [+ "announce"+ ],+ [+ "assignment"+ ],+ [+ "release"+ ],+ [+ "releaseRoute"+ ]+ ],+ "native": [+ {+ "control": [+ "cancel"+ ]+ },+ {+ "control": [+ "holdRoute"+ ]+ },+ {+ "binary": "opencode",+ "args": [+ "api",+ "model.list"+ ],+ "cwd": "<root>/work"+ },+ {+ "binary": "opencode",+ "args": [+ "api",+ "session.switchModel",+ "--param",+ "sessionID=ses_fixture",+ "-d",+ "{\"model\":{\"id\":\"model\",\"providerID\":\"fixture\",\"variant\":\"high\"}}"+ ],+ "cwd": "<root>/work"+ },+ {+ "binary": "opencode",+ "args": [+ "api",+ "session.get",+ "--param",+ "sessionID=ses_fixture"+ ],+ "cwd": "<root>/work"+ },+ {+ "control": [+ "clearEnv",+ [+ "GRID_API_KEY",+ "OPENCODE_CONFIG"+ ]+ ]+ },+ {+ "control": [+ "holdOpen"+ ]+ },+ {+ "control": [+ "terminate"+ ]+ },+ {+ "control": [+ "respawn",+ [+ "/bin/sh",+ "-ic",+ ". '<root>/adapter_data_dir/launch/<script>.sh'",+ "harness-engine",+ "<root>/work",+ "<root>/bin/v2",+ "--session",+ "ses_fixture"+ ],+ {+ "env": {},+ "extraArgs": [],+ "clearEnv": [+ "HARNESS_DSH",+ "HARNESS_DSH_DIR",+ "HARNESS_WORKSPACE",+ "HARNESS_CONTEXT_FILE",+ "HARNESS_SKILLS_DIR",+ "HARNESS_PRIVATE_GRID"+ ],+ "sessionModel": "fixture/model#high"+ },+ "rm -f -- '<root>/adapter_data_dir/launch/<script>.sh'\nharness_nofile=$(ulimit -S -n 2>/dev/null) || harness_nofile=unlimited; if [ \"$harness_nofile\" != unlimited ] && [ \"$harness_nofile\" -lt 65536 ] 2>/dev/null; then ulimit -S -n 65536 2>/dev/null || ulimit -S -n \"$(ulimit -H -n)\" 2>/dev/null || true; fi; unset harness_nofile\nharness_stopped() {\n [ \"$harness_status\" -gt 128 ] 2>/dev/null || return 1\n harness_signal=$(kill -l \"$harness_status\" 2>/dev/null) || return 1\n case $harness_signal in\n STOP|TSTP|TTIN|TTOU|SIGSTOP|SIGTSTP|SIGTTIN|SIGTTOU) jobs %% >/dev/null 2>&1 ;;\n *) return 1 ;;\n esac\n}\nharness_fg() {\n harness_now=$(date +%s 2>/dev/null) || harness_now=0\n if [ $((harness_now - harness_resumed)) -le 1 ]; then harness_quick=$((harness_quick + 1)); else harness_quick=0; fi\n harness_resumes=$((harness_resumes + 1))\n case $harness_signal in *TTIN|*TTOU) harness_stuck=$harness_quick ;; *) harness_stuck=0 ;; esac\n if [ \"$harness_stuck\" -ge 5 ] || { [ -z \"${ZSH_VERSION:-}\" ] && [ \"$harness_resumes\" -ge 1000 ]; }; then\n kill -9 %% 2>/dev/null\n harness_status=137\n return 0\n fi\n if [ \"$harness_quick\" -ge 3 ]; then harness_waited=$(sleep 1) || :; fi\n harness_resumed=$(date +%s 2>/dev/null) || harness_resumed=0\n harness_status=0\n fg >/dev/null || harness_status=$?\n}\nharness_resume() {\n if [ -n \"${ZSH_VERSION:-}\" ]; then\n while harness_stopped; do harness_fg; done\n return 0\n fi\n harness_stopped || return 0\n harness_fg\n harness_resume\n}\nharness_resumed=0\nharness_quick=0\nharness_resumes=0\nharness_after() {\n if [ \"$harness_status\" -eq 127 ]; then exit 127; fi\n [ -n \"${TMUX_PANE:-}\" ] && { '/fixture/bin/tmux' set-option -p -t \"$TMUX_PANE\" @harness_engine_exit \"$harness_status\" >/dev/null 2>&1 || '/fixture/bin/tmux' set-option -w -t \"$TMUX_PANE\" @harness_engine_exit \"$harness_status\" >/dev/null 2>&1; } || true\n if ! [ -t 0 ]; then exit \"$harness_status\"; fi\n if harness_tty=$(stty -g 2>/dev/null) && stty -icanon -echo min 0 time 3 2>/dev/null; then\n while harness_waiting=$(dd bs=65536 count=1 2>/dev/null | wc -c) && [ \"$((harness_waiting))\" -gt 0 ]; do :; done\n stty \"$harness_tty\" 2>/dev/null || true\n fi\n printf '\\n%s\\n' 'harness: v2 exited ('\"$harness_status\"'). This pane is a shell now — run v2 again, or stop the pane.'\n exec '/bin/sh'\n}\nGRID_NO_UPDATE_CHECK=1\nexport GRID_NO_UPDATE_CHECK\nif ! cd -- \"$1\"; then printf '%s\\n' 'harness: the selected working directory is unavailable.' >&2; exit 1; fi\nif ! [ -r . ]; then printf '%s\\n' \"harness: cannot read $PWD — the agent was not started.\" 'harness: check the folder'\"'\"'s permissions for this user.' >&2; exit 1; fi\nshift\nif [ -n \"${ZSH_VERSION:-}\" ]; then setopt monitor 2>/dev/null || :; else set -m 2>/dev/null || :; fi\ntrap : INT QUIT\nharness_engine_bin=$1\nshift\nharness_status=0\n\"$harness_engine_bin\" \"$@\" || harness_status=$?\nharness_resume\nharness_after"+ ]+ },+ {+ "control": [+ "process",+ "fixture-agent",+ {+ "pid": 4343,+ "executable": "opencode",+ "startMarker": "replacement"+ },+ "none"+ ]+ },+ {+ "control": [+ "grid",+ "fixture-agent",+ null+ ]+ },+ {+ "control": [+ "active",+ "fixture-agent",+ true+ ]+ },+ {+ "control": [+ "announce"+ ]+ },+ {+ "control": [+ "assignment"+ ]+ },+ {+ "control": [+ "release"+ ]+ },+ {+ "control": [+ "releaseRoute"+ ]+ }+ ]+ },+ "unknown create named=false": {+ "result": {+ "ok": false,+ "error": "RECORDED",+ "detail": "No pane is opened by this golden."+ },+ "panes": [+ {+ "argv": [+ "/bin/sh",+ "-ic",+ ". '<root>/adapter_data_dir/launch/<script>.sh'",+ "harness-engine",+ "<root>/work",+ "<root>/bin/unknown",+ "--prompt",+ "fixture prompt"+ ],+ "env": {+ "OPENCODE_CONFIG_CONTENT": "{\"permission\":\"ask\",\"model\":\"opencode/muse-spark-1.3-contributor-free\",\"small_model\":\"opencode/muse-spark-1.3-contributor-free\",\"provider\":{\"opencode\":{\"models\":{\"muse-spark-1.3-contributor-free\":{\"options\":{\"reasoningEffort\":\"xhigh\"}}}}},\"agent\":{\"build\":{\"model\":\"opencode/muse-spark-1.3-contributor-free\",\"variant\":\"xhigh\"},\"plan\":{\"model\":\"opencode/muse-spark-1.3-contributor-free\",\"variant\":\"xhigh\"}}}"+ },+ "engine": "opencode",+ "agent": null,+ "permissionMode": null,+ "grid": null,+ "gridLaunchRecord": null,+ "script": "rm -f -- '<root>/adapter_data_dir/launch/<script>.sh'\nharness_nofile=$(ulimit -S -n 2>/dev/null) || harness_nofile=unlimited; if [ \"$harness_nofile\" != unlimited ] && [ \"$harness_nofile\" -lt 65536 ] 2>/dev/null; then ulimit -S -n 65536 2>/dev/null || ulimit -S -n \"$(ulimit -H -n)\" 2>/dev/null || true; fi; unset harness_nofile\nharness_stopped() {\n [ \"$harness_status\" -gt 128 ] 2>/dev/null || return 1\n harness_signal=$(kill -l \"$harness_status\" 2>/dev/null) || return 1\n case $harness_signal in\n STOP|TSTP|TTIN|TTOU|SIGSTOP|SIGTSTP|SIGTTIN|SIGTTOU) jobs %% >/dev/null 2>&1 ;;\n *) return 1 ;;\n esac\n}\nharness_fg() {\n harness_now=$(date +%s 2>/dev/null) || harness_now=0\n if [ $((harness_now - harness_resumed)) -le 1 ]; then harness_quick=$((harness_quick + 1)); else harness_quick=0; fi\n harness_resumes=$((harness_resumes + 1))\n case $harness_signal in *TTIN|*TTOU) harness_stuck=$harness_quick ;; *) harness_stuck=0 ;; esac\n if [ \"$harness_stuck\" -ge 5 ] || { [ -z \"${ZSH_VERSION:-}\" ] && [ \"$harness_resumes\" -ge 1000 ]; }; then\n kill -9 %% 2>/dev/null\n harness_status=137\n return 0\n fi\n if [ \"$harness_quick\" -ge 3 ]; then harness_waited=$(sleep 1) || :; fi\n harness_resumed=$(date +%s 2>/dev/null) || harness_resumed=0\n harness_status=0\n fg >/dev/null || harness_status=$?\n}\nharness_resume() {\n if [ -n \"${ZSH_VERSION:-}\" ]; then\n while harness_stopped; do harness_fg; done\n return 0\n fi\n harness_stopped || return 0\n harness_fg\n harness_resume\n}\nharness_resumed=0\nharness_quick=0\nharness_resumes=0\nharness_after() {\n if [ \"$harness_status\" -eq 127 ]; then exit 127; fi\n [ -n \"${TMUX_PANE:-}\" ] && { '/fixture/bin/tmux' set-option -p -t \"$TMUX_PANE\" @harness_engine_exit \"$harness_status\" >/dev/null 2>&1 || '/fixture/bin/tmux' set-option -w -t \"$TMUX_PANE\" @harness_engine_exit \"$harness_status\" >/dev/null 2>&1; } || true\n if ! [ -t 0 ]; then exit \"$harness_status\"; fi\n if harness_tty=$(stty -g 2>/dev/null) && stty -icanon -echo min 0 time 3 2>/dev/null; then\n while harness_waiting=$(dd bs=65536 count=1 2>/dev/null | wc -c) && [ \"$((harness_waiting))\" -gt 0 ]; do :; done\n stty \"$harness_tty\" 2>/dev/null || true\n fi\n printf '\\n%s\\n' 'harness: unknown exited ('\"$harness_status\"'). This pane is a shell now — run unknown again, or stop the pane.'\n exec '/bin/sh'\n}\nunset HARNESS_DSH HARNESS_DSH_DIR HARNESS_WORKSPACE HARNESS_CONTEXT_FILE HARNESS_SKILLS_DIR HARNESS_PRIVATE_GRID\nGRID_NO_UPDATE_CHECK=1\nexport GRID_NO_UPDATE_CHECK\nif ! cd -- \"$1\"; then printf '%s\\n' 'harness: the selected working directory is unavailable.' >&2; exit 1; fi\nif ! [ -r . ]; then printf '%s\\n' \"harness: cannot read $PWD — the agent was not started.\" 'harness: check the folder'\"'\"'s permissions for this user.' >&2; exit 1; fi\nshift\nif [ -n \"${ZSH_VERSION:-}\" ]; then setopt monitor 2>/dev/null || :; else set -m 2>/dev/null || :; fi\ntrap : INT QUIT\nharness_engine_bin=$1\nshift\nharness_status=0\n\"$harness_engine_bin\" \"$@\" || harness_status=$?\nharness_resume\nharness_after"+ }+ ],+ "native": []+ },+ "unknown fork named=false": {+ "result": {+ "ok": false,+ "error": "RECORDED",+ "detail": "No pane is opened by this golden."+ },+ "panes": [+ {+ "argv": [+ "/bin/sh",+ "-ic",+ ". '<root>/adapter_data_dir/launch/<script>.sh'",+ "harness-engine",+ "<root>/work",+ "<root>/bin/unknown",+ "-m",+ "fixture/model#high",+ "--prompt",+ "You are a fork of the agent \"work · ses_\" in <root>/work. It kept working; you are its copy, picking up from what it knew. Here is its recent history, oldest first.\n\nAsked: fixture ask\n\nIts last full answer:\nfixture answer\n\nContinue from there. Your task now: try another approach"+ ],+ "engine": "opencode",+ "agent": null,+ "forkedFrom": {+ "agentId": "fixture-agent",+ "name": "work · ses_",+ "sessionId": "ses_fixture"+ },+ "permissionMode": null,+ "grid": null,+ "gridLaunchRecord": null,+ "script": "rm -f -- '<root>/adapter_data_dir/launch/<script>.sh'\nharness_nofile=$(ulimit -S -n 2>/dev/null) || harness_nofile=unlimited; if [ \"$harness_nofile\" != unlimited ] && [ \"$harness_nofile\" -lt 65536 ] 2>/dev/null; then ulimit -S -n 65536 2>/dev/null || ulimit -S -n \"$(ulimit -H -n)\" 2>/dev/null || true; fi; unset harness_nofile\nharness_stopped() {\n [ \"$harness_status\" -gt 128 ] 2>/dev/null || return 1\n harness_signal=$(kill -l \"$harness_status\" 2>/dev/null) || return 1\n case $harness_signal in\n STOP|TSTP|TTIN|TTOU|SIGSTOP|SIGTSTP|SIGTTIN|SIGTTOU) jobs %% >/dev/null 2>&1 ;;\n *) return 1 ;;\n esac\n}\nharness_fg() {\n harness_now=$(date +%s 2>/dev/null) || harness_now=0\n if [ $((harness_now - harness_resumed)) -le 1 ]; then harness_quick=$((harness_quick + 1)); else harness_quick=0; fi\n harness_resumes=$((harness_resumes + 1))\n case $harness_signal in *TTIN|*TTOU) harness_stuck=$harness_quick ;; *) harness_stuck=0 ;; esac\n if [ \"$harness_stuck\" -ge 5 ] || { [ -z \"${ZSH_VERSION:-}\" ] && [ \"$harness_resumes\" -ge 1000 ]; }; then\n kill -9 %% 2>/dev/null\n harness_status=137\n return 0\n fi\n if [ \"$harness_quick\" -ge 3 ]; then harness_waited=$(sleep 1) || :; fi\n harness_resumed=$(date +%s 2>/dev/null) || harness_resumed=0\n harness_status=0\n fg >/dev/null || harness_status=$?\n}\nharness_resume() {\n if [ -n \"${ZSH_VERSION:-}\" ]; then\n while harness_stopped; do harness_fg; done\n return 0\n fi\n harness_stopped || return 0\n harness_fg\n harness_resume\n}\nharness_resumed=0\nharness_quick=0\nharness_resumes=0\nharness_after() {\n if [ \"$harness_status\" -eq 127 ]; then exit 127; fi\n [ -n \"${TMUX_PANE:-}\" ] && { '/fixture/bin/tmux' set-option -p -t \"$TMUX_PANE\" @harness_engine_exit \"$harness_status\" >/dev/null 2>&1 || '/fixture/bin/tmux' set-option -w -t \"$TMUX_PANE\" @harness_engine_exit \"$harness_status\" >/dev/null 2>&1; } || true\n if ! [ -t 0 ]; then exit \"$harness_status\"; fi\n if harness_tty=$(stty -g 2>/dev/null) && stty -icanon -echo min 0 time 3 2>/dev/null; then\n while harness_waiting=$(dd bs=65536 count=1 2>/dev/null | wc -c) && [ \"$((harness_waiting))\" -gt 0 ]; do :; done\n stty \"$harness_tty\" 2>/dev/null || true\n fi\n printf '\\n%s\\n' 'harness: unknown exited ('\"$harness_status\"'). This pane is a shell now — run unknown again, or stop the pane.'\n exec '/bin/sh'\n}\nunset HARNESS_DSH HARNESS_DSH_DIR HARNESS_WORKSPACE HARNESS_CONTEXT_FILE HARNESS_SKILLS_DIR HARNESS_PRIVATE_GRID\nGRID_NO_UPDATE_CHECK=1\nexport GRID_NO_UPDATE_CHECK\nif ! cd -- \"$1\"; then printf '%s\\n' 'harness: the selected working directory is unavailable.' >&2; exit 1; fi\nif ! [ -r . ]; then printf '%s\\n' \"harness: cannot read $PWD — the agent was not started.\" 'harness: check the folder'\"'\"'s permissions for this user.' >&2; exit 1; fi\nshift\nif [ -n \"${ZSH_VERSION:-}\" ]; then setopt monitor 2>/dev/null || :; else set -m 2>/dev/null || :; fi\ntrap : INT QUIT\nharness_engine_bin=$1\nshift\nharness_status=0\n\"$harness_engine_bin\" \"$@\" || harness_status=$?\nharness_resume\nharness_after"+ }+ ],+ "native": [+ {+ "binary": "opencode",+ "args": [+ "--version"+ ],+ "cwd": "<repo>"+ }+ ]+ },+ "unknown relaunch named=false": {+ "result": {+ "ok": true,+ "overrides": {+ "env": {},+ "extraArgs": [+ "-m",+ "fixture/model#high"+ ],+ "clearEnv": [+ "HARNESS_DSH",+ "HARNESS_DSH_DIR",+ "HARNESS_WORKSPACE",+ "HARNESS_CONTEXT_FILE",+ "HARNESS_SKILLS_DIR",+ "HARNESS_PRIVATE_GRID"+ ],+ "sessionModel": "fixture/model#high"+ }+ },+ "native": []+ },+ "unknown create named=true": {+ "result": {+ "ok": false,+ "error": "RECORDED",+ "detail": "No pane is opened by this golden."+ },+ "panes": [+ {+ "argv": [+ "/bin/sh",+ "-ic",+ ". '<root>/adapter_data_dir/launch/<script>.sh'",+ "harness-engine",+ "<root>/work",+ "<root>/bin/unknown",+ "--agent",+ "reviewer",+ "--prompt",+ "fixture prompt"+ ],+ "env": {+ "OPENCODE_CONFIG_CONTENT": "{\"permission\":\"ask\",\"model\":\"opencode/muse-spark-1.3-contributor-free\",\"small_model\":\"opencode/muse-spark-1.3-contributor-free\",\"provider\":{\"opencode\":{\"models\":{\"muse-spark-1.3-contributor-free\":{\"options\":{\"reasoningEffort\":\"xhigh\"}}}}},\"agent\":{\"build\":{\"model\":\"opencode/muse-spark-1.3-contributor-free\",\"variant\":\"xhigh\"},\"plan\":{\"model\":\"opencode/muse-spark-1.3-contributor-free\",\"variant\":\"xhigh\"}}}"+ },+ "engine": "opencode",+ "agent": "reviewer",+ "permissionMode": null,+ "grid": null,+ "gridLaunchRecord": null,+ "script": "rm -f -- '<root>/adapter_data_dir/launch/<script>.sh'\nharness_nofile=$(ulimit -S -n 2>/dev/null) || harness_nofile=unlimited; if [ \"$harness_nofile\" != unlimited ] && [ \"$harness_nofile\" -lt 65536 ] 2>/dev/null; then ulimit -S -n 65536 2>/dev/null || ulimit -S -n \"$(ulimit -H -n)\" 2>/dev/null || true; fi; unset harness_nofile\nharness_stopped() {\n [ \"$harness_status\" -gt 128 ] 2>/dev/null || return 1\n harness_signal=$(kill -l \"$harness_status\" 2>/dev/null) || return 1\n case $harness_signal in\n STOP|TSTP|TTIN|TTOU|SIGSTOP|SIGTSTP|SIGTTIN|SIGTTOU) jobs %% >/dev/null 2>&1 ;;\n *) return 1 ;;\n esac\n}\nharness_fg() {\n harness_now=$(date +%s 2>/dev/null) || harness_now=0\n if [ $((harness_now - harness_resumed)) -le 1 ]; then harness_quick=$((harness_quick + 1)); else harness_quick=0; fi\n harness_resumes=$((harness_resumes + 1))\n case $harness_signal in *TTIN|*TTOU) harness_stuck=$harness_quick ;; *) harness_stuck=0 ;; esac\n if [ \"$harness_stuck\" -ge 5 ] || { [ -z \"${ZSH_VERSION:-}\" ] && [ \"$harness_resumes\" -ge 1000 ]; }; then\n kill -9 %% 2>/dev/null\n harness_status=137\n return 0\n fi\n if [ \"$harness_quick\" -ge 3 ]; then harness_waited=$(sleep 1) || :; fi\n harness_resumed=$(date +%s 2>/dev/null) || harness_resumed=0\n harness_status=0\n fg >/dev/null || harness_status=$?\n}\nharness_resume() {\n if [ -n \"${ZSH_VERSION:-}\" ]; then\n while harness_stopped; do harness_fg; done\n return 0\n fi\n harness_stopped || return 0\n harness_fg\n harness_resume\n}\nharness_resumed=0\nharness_quick=0\nharness_resumes=0\nharness_after() {\n if [ \"$harness_status\" -eq 127 ]; then exit 127; fi\n [ -n \"${TMUX_PANE:-}\" ] && { '/fixture/bin/tmux' set-option -p -t \"$TMUX_PANE\" @harness_engine_exit \"$harness_status\" >/dev/null 2>&1 || '/fixture/bin/tmux' set-option -w -t \"$TMUX_PANE\" @harness_engine_exit \"$harness_status\" >/dev/null 2>&1; } || true\n if ! [ -t 0 ]; then exit \"$harness_status\"; fi\n if harness_tty=$(stty -g 2>/dev/null) && stty -icanon -echo min 0 time 3 2>/dev/null; then\n while harness_waiting=$(dd bs=65536 count=1 2>/dev/null | wc -c) && [ \"$((harness_waiting))\" -gt 0 ]; do :; done\n stty \"$harness_tty\" 2>/dev/null || true\n fi\n printf '\\n%s\\n' 'harness: unknown exited ('\"$harness_status\"'). This pane is a shell now — run unknown again, or stop the pane.'\n exec '/bin/sh'\n}\nunset HARNESS_DSH HARNESS_DSH_DIR HARNESS_WORKSPACE HARNESS_CONTEXT_FILE HARNESS_SKILLS_DIR HARNESS_PRIVATE_GRID\nGRID_NO_UPDATE_CHECK=1\nexport GRID_NO_UPDATE_CHECK\nif ! cd -- \"$1\"; then printf '%s\\n' 'harness: the selected working directory is unavailable.' >&2; exit 1; fi\nif ! [ -r . ]; then printf '%s\\n' \"harness: cannot read $PWD — the agent was not started.\" 'harness: check the folder'\"'\"'s permissions for this user.' >&2; exit 1; fi\nshift\nif [ -n \"${ZSH_VERSION:-}\" ]; then setopt monitor 2>/dev/null || :; else set -m 2>/dev/null || :; fi\ntrap : INT QUIT\nharness_engine_bin=$1\nshift\nharness_status=0\n\"$harness_engine_bin\" \"$@\" || harness_status=$?\nharness_resume\nharness_after"+ }+ ],+ "native": []+ },+ "unknown fork named=true": {+ "result": {+ "ok": false,+ "error": "RECORDED",+ "detail": "No pane is opened by this golden."+ },+ "panes": [+ {+ "argv": [+ "/bin/sh",+ "-ic",+ ". '<root>/adapter_data_dir/launch/<script>.sh'",+ "harness-engine",+ "<root>/work",+ "<root>/bin/unknown",+ "-m",+ "fixture/model#high",+ "--agent",+ "reviewer",+ "--prompt",+ "You are a fork of the agent \"work · ses_\" in <root>/work. It kept working; you are its copy, picking up from what it knew. Here is its recent history, oldest first.\n\nAsked: fixture ask\n\nIts last full answer:\nfixture answer\n\nContinue from there. Your task now: try another approach"+ ],+ "engine": "opencode",+ "agent": "reviewer",+ "forkedFrom": {+ "agentId": "fixture-agent",+ "name": "work · ses_",+ "sessionId": "ses_fixture"+ },+ "permissionMode": null,+ "grid": null,+ "gridLaunchRecord": null,+ "script": "rm -f -- '<root>/adapter_data_dir/launch/<script>.sh'\nharness_nofile=$(ulimit -S -n 2>/dev/null) || harness_nofile=unlimited; if [ \"$harness_nofile\" != unlimited ] && [ \"$harness_nofile\" -lt 65536 ] 2>/dev/null; then ulimit -S -n 65536 2>/dev/null || ulimit -S -n \"$(ulimit -H -n)\" 2>/dev/null || true; fi; unset harness_nofile\nharness_stopped() {\n [ \"$harness_status\" -gt 128 ] 2>/dev/null || return 1\n harness_signal=$(kill -l \"$harness_status\" 2>/dev/null) || return 1\n case $harness_signal in\n STOP|TSTP|TTIN|TTOU|SIGSTOP|SIGTSTP|SIGTTIN|SIGTTOU) jobs %% >/dev/null 2>&1 ;;\n *) return 1 ;;\n esac\n}\nharness_fg() {\n harness_now=$(date +%s 2>/dev/null) || harness_now=0\n if [ $((harness_now - harness_resumed)) -le 1 ]; then harness_quick=$((harness_quick + 1)); else harness_quick=0; fi\n harness_resumes=$((harness_resumes + 1))\n case $harness_signal in *TTIN|*TTOU) harness_stuck=$harness_quick ;; *) harness_stuck=0 ;; esac\n if [ \"$harness_stuck\" -ge 5 ] || { [ -z \"${ZSH_VERSION:-}\" ] && [ \"$harness_resumes\" -ge 1000 ]; }; then\n kill -9 %% 2>/dev/null\n harness_status=137\n return 0\n fi\n if [ \"$harness_quick\" -ge 3 ]; then harness_waited=$(sleep 1) || :; fi\n harness_resumed=$(date +%s 2>/dev/null) || harness_resumed=0\n harness_status=0\n fg >/dev/null || harness_status=$?\n}\nharness_resume() {\n if [ -n \"${ZSH_VERSION:-}\" ]; then\n while harness_stopped; do harness_fg; done\n return 0\n fi\n harness_stopped || return 0\n harness_fg\n harness_resume\n}\nharness_resumed=0\nharness_quick=0\nharness_resumes=0\nharness_after() {\n if [ \"$harness_status\" -eq 127 ]; then exit 127; fi\n [ -n \"${TMUX_PANE:-}\" ] && { '/fixture/bin/tmux' set-option -p -t \"$TMUX_PANE\" @harness_engine_exit \"$harness_status\" >/dev/null 2>&1 || '/fixture/bin/tmux' set-option -w -t \"$TMUX_PANE\" @harness_engine_exit \"$harness_status\" >/dev/null 2>&1; } || true\n if ! [ -t 0 ]; then exit \"$harness_status\"; fi\n if harness_tty=$(stty -g 2>/dev/null) && stty -icanon -echo min 0 time 3 2>/dev/null; then\n while harness_waiting=$(dd bs=65536 count=1 2>/dev/null | wc -c) && [ \"$((harness_waiting))\" -gt 0 ]; do :; done\n stty \"$harness_tty\" 2>/dev/null || true\n fi\n printf '\\n%s\\n' 'harness: unknown exited ('\"$harness_status\"'). This pane is a shell now — run unknown again, or stop the pane.'\n exec '/bin/sh'\n}\nunset HARNESS_DSH HARNESS_DSH_DIR HARNESS_WORKSPACE HARNESS_CONTEXT_FILE HARNESS_SKILLS_DIR HARNESS_PRIVATE_GRID\nGRID_NO_UPDATE_CHECK=1\nexport GRID_NO_UPDATE_CHECK\nif ! cd -- \"$1\"; then printf '%s\\n' 'harness: the selected working directory is unavailable.' >&2; exit 1; fi\nif ! [ -r . ]; then printf '%s\\n' \"harness: cannot read $PWD — the agent was not started.\" 'harness: check the folder'\"'\"'s permissions for this user.' >&2; exit 1; fi\nshift\nif [ -n \"${ZSH_VERSION:-}\" ]; then setopt monitor 2>/dev/null || :; else set -m 2>/dev/null || :; fi\ntrap : INT QUIT\nharness_engine_bin=$1\nshift\nharness_status=0\n\"$harness_engine_bin\" \"$@\" || harness_status=$?\nharness_resume\nharness_after"+ }+ ],+ "native": []+ },+ "unknown relaunch named=true": {+ "result": {+ "ok": true,+ "overrides": {+ "env": {},+ "extraArgs": [+ "-m",+ "fixture/model#high",+ "--agent",+ "reviewer"+ ],+ "clearEnv": [+ "HARNESS_DSH",+ "HARNESS_DSH_DIR",+ "HARNESS_WORKSPACE",+ "HARNESS_CONTEXT_FILE",+ "HARNESS_SKILLS_DIR",+ "HARNESS_PRIVATE_GRID"+ ],+ "sessionModel": "fixture/model#high"+ }+ },+ "native": []+ },+ "unknown retarget own login": {+ "result": {+ "ok": true+ },+ "events": [+ [+ "cancel"+ ],+ [+ "holdRoute"+ ],+ [+ "clearEnv",+ [+ "GRID_API_KEY",+ "OPENCODE_CONFIG"+ ]+ ],+ [+ "holdOpen"+ ],+ [+ "terminate"+ ],+ [+ "respawn",+ [+ "/bin/sh",+ "-ic",+ ". '<root>/adapter_data_dir/launch/<script>.sh'",+ "harness-engine",+ "<root>/work",+ "<root>/bin/unknown",+ "--session",+ "ses_fixture",+ "-m",+ "fixture/model#high",+ "--agent",+ "reviewer"+ ],+ {+ "env": {},+ "extraArgs": [+ "-m",+ "fixture/model#high",+ "--agent",+ "reviewer"+ ],+ "clearEnv": [+ "HARNESS_DSH",+ "HARNESS_DSH_DIR",+ "HARNESS_WORKSPACE",+ "HARNESS_CONTEXT_FILE",+ "HARNESS_SKILLS_DIR",+ "HARNESS_PRIVATE_GRID"+ ],+ "sessionModel": "fixture/model#high"+ },+ "rm -f -- '<root>/adapter_data_dir/launch/<script>.sh'\nharness_nofile=$(ulimit -S -n 2>/dev/null) || harness_nofile=unlimited; if [ \"$harness_nofile\" != unlimited ] && [ \"$harness_nofile\" -lt 65536 ] 2>/dev/null; then ulimit -S -n 65536 2>/dev/null || ulimit -S -n \"$(ulimit -H -n)\" 2>/dev/null || true; fi; unset harness_nofile\nharness_stopped() {\n [ \"$harness_status\" -gt 128 ] 2>/dev/null || return 1\n harness_signal=$(kill -l \"$harness_status\" 2>/dev/null) || return 1\n case $harness_signal in\n STOP|TSTP|TTIN|TTOU|SIGSTOP|SIGTSTP|SIGTTIN|SIGTTOU) jobs %% >/dev/null 2>&1 ;;\n *) return 1 ;;\n esac\n}\nharness_fg() {\n harness_now=$(date +%s 2>/dev/null) || harness_now=0\n if [ $((harness_now - harness_resumed)) -le 1 ]; then harness_quick=$((harness_quick + 1)); else harness_quick=0; fi\n harness_resumes=$((harness_resumes + 1))\n case $harness_signal in *TTIN|*TTOU) harness_stuck=$harness_quick ;; *) harness_stuck=0 ;; esac\n if [ \"$harness_stuck\" -ge 5 ] || { [ -z \"${ZSH_VERSION:-}\" ] && [ \"$harness_resumes\" -ge 1000 ]; }; then\n kill -9 %% 2>/dev/null\n harness_status=137\n return 0\n fi\n if [ \"$harness_quick\" -ge 3 ]; then harness_waited=$(sleep 1) || :; fi\n harness_resumed=$(date +%s 2>/dev/null) || harness_resumed=0\n harness_status=0\n fg >/dev/null || harness_status=$?\n}\nharness_resume() {\n if [ -n \"${ZSH_VERSION:-}\" ]; then\n while harness_stopped; do harness_fg; done\n return 0\n fi\n harness_stopped || return 0\n harness_fg\n harness_resume\n}\nharness_resumed=0\nharness_quick=0\nharness_resumes=0\nharness_after() {\n if [ \"$harness_status\" -eq 127 ]; then exit 127; fi\n [ -n \"${TMUX_PANE:-}\" ] && { '/fixture/bin/tmux' set-option -p -t \"$TMUX_PANE\" @harness_engine_exit \"$harness_status\" >/dev/null 2>&1 || '/fixture/bin/tmux' set-option -w -t \"$TMUX_PANE\" @harness_engine_exit \"$harness_status\" >/dev/null 2>&1; } || true\n if ! [ -t 0 ]; then exit \"$harness_status\"; fi\n if harness_tty=$(stty -g 2>/dev/null) && stty -icanon -echo min 0 time 3 2>/dev/null; then\n while harness_waiting=$(dd bs=65536 count=1 2>/dev/null | wc -c) && [ \"$((harness_waiting))\" -gt 0 ]; do :; done\n stty \"$harness_tty\" 2>/dev/null || true\n fi\n printf '\\n%s\\n' 'harness: unknown exited ('\"$harness_status\"'). This pane is a shell now — run unknown again, or stop the pane.'\n exec '/bin/sh'\n}\nGRID_NO_UPDATE_CHECK=1\nexport GRID_NO_UPDATE_CHECK\nif ! cd -- \"$1\"; then printf '%s\\n' 'harness: the selected working directory is unavailable.' >&2; exit 1; fi\nif ! [ -r . ]; then printf '%s\\n' \"harness: cannot read $PWD — the agent was not started.\" 'harness: check the folder'\"'\"'s permissions for this user.' >&2; exit 1; fi\nshift\nif [ -n \"${ZSH_VERSION:-}\" ]; then setopt monitor 2>/dev/null || :; else set -m 2>/dev/null || :; fi\ntrap : INT QUIT\nharness_engine_bin=$1\nshift\nharness_status=0\n\"$harness_engine_bin\" \"$@\" || harness_status=$?\nharness_resume\nharness_after"+ ],+ [+ "process",+ "fixture-agent",+ {+ "pid": 4343,+ "executable": "opencode",+ "startMarker": "replacement"+ },+ "none"+ ],+ [+ "grid",+ "fixture-agent",+ null+ ],+ [+ "active",+ "fixture-agent",+ true+ ],+ [+ "announce"+ ],+ [+ "assignment"+ ],+ [+ "release"+ ],+ [+ "releaseRoute"+ ]+ ],+ "native": [+ {+ "control": [+ "cancel"+ ]+ },+ {+ "control": [+ "holdRoute"+ ]+ },+ {+ "binary": "sqlite3",+ "args": [+ "-batch",+ "-bail",+ "<root>/fixture.db",+ "PRAGMA busy_timeout = 5000;\nBEGIN IMMEDIATE;\nUPDATE message SET data = json_set(data, '$.model.providerID', 'fixture', '$.model.modelID', 'model#high') WHERE id = (SELECT id FROM message WHERE session_id = 'ses_fixture' AND json_extract(data, '$.role') = 'user' ORDER BY time_created DESC LIMIT 1);\nSELECT changes();\nUPDATE session SET model = json_object('id', 'model#high', 'providerID', 'fixture', 'variant', 'default') WHERE id = 'ses_fixture' AND EXISTS (SELECT 1 FROM message WHERE session_id = 'ses_fixture' AND json_extract(data, '$.role') = 'user');\nSELECT changes();\nCOMMIT;"+ ]+ },+ {+ "control": [+ "clearEnv",+ [+ "GRID_API_KEY",+ "OPENCODE_CONFIG"+ ]+ ]+ },+ {+ "control": [+ "holdOpen"+ ]+ },+ {+ "control": [+ "terminate"+ ]+ },+ {+ "control": [+ "respawn",+ [+ "/bin/sh",+ "-ic",+ ". '<root>/adapter_data_dir/launch/<script>.sh'",+ "harness-engine",+ "<root>/work",+ "<root>/bin/unknown",+ "--session",+ "ses_fixture",+ "-m",+ "fixture/model#high",+ "--agent",+ "reviewer"+ ],+ {+ "env": {},+ "extraArgs": [+ "-m",+ "fixture/model#high",+ "--agent",+ "reviewer"+ ],+ "clearEnv": [+ "HARNESS_DSH",+ "HARNESS_DSH_DIR",+ "HARNESS_WORKSPACE",+ "HARNESS_CONTEXT_FILE",+ "HARNESS_SKILLS_DIR",+ "HARNESS_PRIVATE_GRID"+ ],+ "sessionModel": "fixture/model#high"+ },+ "rm -f -- '<root>/adapter_data_dir/launch/<script>.sh'\nharness_nofile=$(ulimit -S -n 2>/dev/null) || harness_nofile=unlimited; if [ \"$harness_nofile\" != unlimited ] && [ \"$harness_nofile\" -lt 65536 ] 2>/dev/null; then ulimit -S -n 65536 2>/dev/null || ulimit -S -n \"$(ulimit -H -n)\" 2>/dev/null || true; fi; unset harness_nofile\nharness_stopped() {\n [ \"$harness_status\" -gt 128 ] 2>/dev/null || return 1\n harness_signal=$(kill -l \"$harness_status\" 2>/dev/null) || return 1\n case $harness_signal in\n STOP|TSTP|TTIN|TTOU|SIGSTOP|SIGTSTP|SIGTTIN|SIGTTOU) jobs %% >/dev/null 2>&1 ;;\n *) return 1 ;;\n esac\n}\nharness_fg() {\n harness_now=$(date +%s 2>/dev/null) || harness_now=0\n if [ $((harness_now - harness_resumed)) -le 1 ]; then harness_quick=$((harness_quick + 1)); else harness_quick=0; fi\n harness_resumes=$((harness_resumes + 1))\n case $harness_signal in *TTIN|*TTOU) harness_stuck=$harness_quick ;; *) harness_stuck=0 ;; esac\n if [ \"$harness_stuck\" -ge 5 ] || { [ -z \"${ZSH_VERSION:-}\" ] && [ \"$harness_resumes\" -ge 1000 ]; }; then\n kill -9 %% 2>/dev/null\n harness_status=137\n return 0\n fi\n if [ \"$harness_quick\" -ge 3 ]; then harness_waited=$(sleep 1) || :; fi\n harness_resumed=$(date +%s 2>/dev/null) || harness_resumed=0\n harness_status=0\n fg >/dev/null || harness_status=$?\n}\nharness_resume() {\n if [ -n \"${ZSH_VERSION:-}\" ]; then\n while harness_stopped; do harness_fg; done\n return 0\n fi\n harness_stopped || return 0\n harness_fg\n harness_resume\n}\nharness_resumed=0\nharness_quick=0\nharness_resumes=0\nharness_after() {\n if [ \"$harness_status\" -eq 127 ]; then exit 127; fi\n [ -n \"${TMUX_PANE:-}\" ] && { '/fixture/bin/tmux' set-option -p -t \"$TMUX_PANE\" @harness_engine_exit \"$harness_status\" >/dev/null 2>&1 || '/fixture/bin/tmux' set-option -w -t \"$TMUX_PANE\" @harness_engine_exit \"$harness_status\" >/dev/null 2>&1; } || true\n if ! [ -t 0 ]; then exit \"$harness_status\"; fi\n if harness_tty=$(stty -g 2>/dev/null) && stty -icanon -echo min 0 time 3 2>/dev/null; then\n while harness_waiting=$(dd bs=65536 count=1 2>/dev/null | wc -c) && [ \"$((harness_waiting))\" -gt 0 ]; do :; done\n stty \"$harness_tty\" 2>/dev/null || true\n fi\n printf '\\n%s\\n' 'harness: unknown exited ('\"$harness_status\"'). This pane is a shell now — run unknown again, or stop the pane.'\n exec '/bin/sh'\n}\nGRID_NO_UPDATE_CHECK=1\nexport GRID_NO_UPDATE_CHECK\nif ! cd -- \"$1\"; then printf '%s\\n' 'harness: the selected working directory is unavailable.' >&2; exit 1; fi\nif ! [ -r . ]; then printf '%s\\n' \"harness: cannot read $PWD — the agent was not started.\" 'harness: check the folder'\"'\"'s permissions for this user.' >&2; exit 1; fi\nshift\nif [ -n \"${ZSH_VERSION:-}\" ]; then setopt monitor 2>/dev/null || :; else set -m 2>/dev/null || :; fi\ntrap : INT QUIT\nharness_engine_bin=$1\nshift\nharness_status=0\n\"$harness_engine_bin\" \"$@\" || harness_status=$?\nharness_resume\nharness_after"+ ]+ },+ {+ "control": [+ "process",+ "fixture-agent",+ {+ "pid": 4343,+ "executable": "opencode",+ "startMarker": "replacement"+ },+ "none"+ ]+ },+ {+ "control": [+ "grid",+ "fixture-agent",+ null+ ]+ },+ {+ "control": [+ "active",+ "fixture-agent",+ true+ ]+ },+ {+ "control": [+ "announce"+ ]+ },+ {+ "control": [+ "assignment"+ ]+ },+ {+ "control": [+ "release"+ ]+ },+ {+ "control": [+ "releaseRoute"+ ]+ }+ ]+ },+ "missing create named=false": {+ "result": {+ "ok": false,+ "error": "RECORDED",+ "detail": "No pane is opened by this golden."+ },+ "panes": [+ {+ "argv": [+ "/bin/sh",+ "-ic",+ ". '<root>/adapter_data_dir/launch/<script>.sh'",+ "harness-engine",+ "<root>/work",+ "<root>/bin/missing",+ "--prompt",+ "fixture prompt"+ ],+ "env": {+ "OPENCODE_CONFIG_CONTENT": "{\"permission\":\"ask\",\"model\":\"opencode/muse-spark-1.3-contributor-free\",\"small_model\":\"opencode/muse-spark-1.3-contributor-free\",\"provider\":{\"opencode\":{\"models\":{\"muse-spark-1.3-contributor-free\":{\"options\":{\"reasoningEffort\":\"xhigh\"}}}}},\"agent\":{\"build\":{\"model\":\"opencode/muse-spark-1.3-contributor-free\",\"variant\":\"xhigh\"},\"plan\":{\"model\":\"opencode/muse-spark-1.3-contributor-free\",\"variant\":\"xhigh\"}}}"+ },+ "engine": "opencode",+ "agent": null,+ "permissionMode": null,+ "grid": null,+ "gridLaunchRecord": null,+ "script": "rm -f -- '<root>/adapter_data_dir/launch/<script>.sh'\nharness_nofile=$(ulimit -S -n 2>/dev/null) || harness_nofile=unlimited; if [ \"$harness_nofile\" != unlimited ] && [ \"$harness_nofile\" -lt 65536 ] 2>/dev/null; then ulimit -S -n 65536 2>/dev/null || ulimit -S -n \"$(ulimit -H -n)\" 2>/dev/null || true; fi; unset harness_nofile\nharness_stopped() {\n [ \"$harness_status\" -gt 128 ] 2>/dev/null || return 1\n harness_signal=$(kill -l \"$harness_status\" 2>/dev/null) || return 1\n case $harness_signal in\n STOP|TSTP|TTIN|TTOU|SIGSTOP|SIGTSTP|SIGTTIN|SIGTTOU) jobs %% >/dev/null 2>&1 ;;\n *) return 1 ;;\n esac\n}\nharness_fg() {\n harness_now=$(date +%s 2>/dev/null) || harness_now=0\n if [ $((harness_now - harness_resumed)) -le 1 ]; then harness_quick=$((harness_quick + 1)); else harness_quick=0; fi\n harness_resumes=$((harness_resumes + 1))\n case $harness_signal in *TTIN|*TTOU) harness_stuck=$harness_quick ;; *) harness_stuck=0 ;; esac\n if [ \"$harness_stuck\" -ge 5 ] || { [ -z \"${ZSH_VERSION:-}\" ] && [ \"$harness_resumes\" -ge 1000 ]; }; then\n kill -9 %% 2>/dev/null\n harness_status=137\n return 0\n fi\n if [ \"$harness_quick\" -ge 3 ]; then harness_waited=$(sleep 1) || :; fi\n harness_resumed=$(date +%s 2>/dev/null) || harness_resumed=0\n harness_status=0\n fg >/dev/null || harness_status=$?\n}\nharness_resume() {\n if [ -n \"${ZSH_VERSION:-}\" ]; then\n while harness_stopped; do harness_fg; done\n return 0\n fi\n harness_stopped || return 0\n harness_fg\n harness_resume\n}\nharness_resumed=0\nharness_quick=0\nharness_resumes=0\nharness_after() {\n if [ \"$harness_status\" -eq 127 ]; then exit 127; fi\n [ -n \"${TMUX_PANE:-}\" ] && { '/fixture/bin/tmux' set-option -p -t \"$TMUX_PANE\" @harness_engine_exit \"$harness_status\" >/dev/null 2>&1 || '/fixture/bin/tmux' set-option -w -t \"$TMUX_PANE\" @harness_engine_exit \"$harness_status\" >/dev/null 2>&1; } || true\n if ! [ -t 0 ]; then exit \"$harness_status\"; fi\n if harness_tty=$(stty -g 2>/dev/null) && stty -icanon -echo min 0 time 3 2>/dev/null; then\n while harness_waiting=$(dd bs=65536 count=1 2>/dev/null | wc -c) && [ \"$((harness_waiting))\" -gt 0 ]; do :; done\n stty \"$harness_tty\" 2>/dev/null || true\n fi\n printf '\\n%s\\n' 'harness: missing exited ('\"$harness_status\"'). This pane is a shell now — run missing again, or stop the pane.'\n exec '/bin/sh'\n}\nunset HARNESS_DSH HARNESS_DSH_DIR HARNESS_WORKSPACE HARNESS_CONTEXT_FILE HARNESS_SKILLS_DIR HARNESS_PRIVATE_GRID\nGRID_NO_UPDATE_CHECK=1\nexport GRID_NO_UPDATE_CHECK\nif ! cd -- \"$1\"; then printf '%s\\n' 'harness: the selected working directory is unavailable.' >&2; exit 1; fi\nif ! [ -r . ]; then printf '%s\\n' \"harness: cannot read $PWD — the agent was not started.\" 'harness: check the folder'\"'\"'s permissions for this user.' >&2; exit 1; fi\nshift\nif [ -n \"${ZSH_VERSION:-}\" ]; then setopt monitor 2>/dev/null || :; else set -m 2>/dev/null || :; fi\ntrap : INT QUIT\nharness_engine_bin=$1\nshift\nharness_status=0\n\"$harness_engine_bin\" \"$@\" || harness_status=$?\nharness_resume\nharness_after"+ }+ ],+ "native": []+ },+ "missing fork named=false": {+ "result": {+ "ok": false,+ "error": "RECORDED",+ "detail": "No pane is opened by this golden."+ },+ "panes": [+ {+ "argv": [+ "/bin/sh",+ "-ic",+ ". '<root>/adapter_data_dir/launch/<script>.sh'",+ "harness-engine",+ "<root>/work",+ "<root>/bin/missing",+ "-m",+ "fixture/model#high",+ "--prompt",+ "You are a fork of the agent \"work · ses_\" in <root>/work. It kept working; you are its copy, picking up from what it knew. Here is its recent history, oldest first.\n\nAsked: fixture ask\n\nIts last full answer:\nfixture answer\n\nContinue from there. Your task now: try another approach"+ ],+ "engine": "opencode",+ "agent": null,+ "forkedFrom": {+ "agentId": "fixture-agent",+ "name": "work · ses_",+ "sessionId": "ses_fixture"+ },+ "permissionMode": null,+ "grid": null,+ "gridLaunchRecord": null,+ "script": "rm -f -- '<root>/adapter_data_dir/launch/<script>.sh'\nharness_nofile=$(ulimit -S -n 2>/dev/null) || harness_nofile=unlimited; if [ \"$harness_nofile\" != unlimited ] && [ \"$harness_nofile\" -lt 65536 ] 2>/dev/null; then ulimit -S -n 65536 2>/dev/null || ulimit -S -n \"$(ulimit -H -n)\" 2>/dev/null || true; fi; unset harness_nofile\nharness_stopped() {\n [ \"$harness_status\" -gt 128 ] 2>/dev/null || return 1\n harness_signal=$(kill -l \"$harness_status\" 2>/dev/null) || return 1\n case $harness_signal in\n STOP|TSTP|TTIN|TTOU|SIGSTOP|SIGTSTP|SIGTTIN|SIGTTOU) jobs %% >/dev/null 2>&1 ;;\n *) return 1 ;;\n esac\n}\nharness_fg() {\n harness_now=$(date +%s 2>/dev/null) || harness_now=0\n if [ $((harness_now - harness_resumed)) -le 1 ]; then harness_quick=$((harness_quick + 1)); else harness_quick=0; fi\n harness_resumes=$((harness_resumes + 1))\n case $harness_signal in *TTIN|*TTOU) harness_stuck=$harness_quick ;; *) harness_stuck=0 ;; esac\n if [ \"$harness_stuck\" -ge 5 ] || { [ -z \"${ZSH_VERSION:-}\" ] && [ \"$harness_resumes\" -ge 1000 ]; }; then\n kill -9 %% 2>/dev/null\n harness_status=137\n return 0\n fi\n if [ \"$harness_quick\" -ge 3 ]; then harness_waited=$(sleep 1) || :; fi\n harness_resumed=$(date +%s 2>/dev/null) || harness_resumed=0\n harness_status=0\n fg >/dev/null || harness_status=$?\n}\nharness_resume() {\n if [ -n \"${ZSH_VERSION:-}\" ]; then\n while harness_stopped; do harness_fg; done\n return 0\n fi\n harness_stopped || return 0\n harness_fg\n harness_resume\n}\nharness_resumed=0\nharness_quick=0\nharness_resumes=0\nharness_after() {\n if [ \"$harness_status\" -eq 127 ]; then exit 127; fi\n [ -n \"${TMUX_PANE:-}\" ] && { '/fixture/bin/tmux' set-option -p -t \"$TMUX_PANE\" @harness_engine_exit \"$harness_status\" >/dev/null 2>&1 || '/fixture/bin/tmux' set-option -w -t \"$TMUX_PANE\" @harness_engine_exit \"$harness_status\" >/dev/null 2>&1; } || true\n if ! [ -t 0 ]; then exit \"$harness_status\"; fi\n if harness_tty=$(stty -g 2>/dev/null) && stty -icanon -echo min 0 time 3 2>/dev/null; then\n while harness_waiting=$(dd bs=65536 count=1 2>/dev/null | wc -c) && [ \"$((harness_waiting))\" -gt 0 ]; do :; done\n stty \"$harness_tty\" 2>/dev/null || true\n fi\n printf '\\n%s\\n' 'harness: missing exited ('\"$harness_status\"'). This pane is a shell now — run missing again, or stop the pane.'\n exec '/bin/sh'\n}\nunset HARNESS_DSH HARNESS_DSH_DIR HARNESS_WORKSPACE HARNESS_CONTEXT_FILE HARNESS_SKILLS_DIR HARNESS_PRIVATE_GRID\nGRID_NO_UPDATE_CHECK=1\nexport GRID_NO_UPDATE_CHECK\nif ! cd -- \"$1\"; then printf '%s\\n' 'harness: the selected working directory is unavailable.' >&2; exit 1; fi\nif ! [ -r . ]; then printf '%s\\n' \"harness: cannot read $PWD — the agent was not started.\" 'harness: check the folder'\"'\"'s permissions for this user.' >&2; exit 1; fi\nshift\nif [ -n \"${ZSH_VERSION:-}\" ]; then setopt monitor 2>/dev/null || :; else set -m 2>/dev/null || :; fi\ntrap : INT QUIT\nharness_engine_bin=$1\nshift\nharness_status=0\n\"$harness_engine_bin\" \"$@\" || harness_status=$?\nharness_resume\nharness_after"+ }+ ],+ "native": []+ },+ "missing relaunch named=false": {+ "result": {+ "ok": true,+ "overrides": {+ "env": {},+ "extraArgs": [+ "-m",+ "fixture/model#high"+ ],+ "clearEnv": [+ "HARNESS_DSH",+ "HARNESS_DSH_DIR",+ "HARNESS_WORKSPACE",+ "HARNESS_CONTEXT_FILE",+ "HARNESS_SKILLS_DIR",+ "HARNESS_PRIVATE_GRID"+ ],+ "sessionModel": "fixture/model#high"+ }+ },+ "native": []+ },+ "missing create named=true": {+ "result": {+ "ok": false,+ "error": "RECORDED",+ "detail": "No pane is opened by this golden."+ },+ "panes": [+ {+ "argv": [+ "/bin/sh",+ "-ic",+ ". '<root>/adapter_data_dir/launch/<script>.sh'",+ "harness-engine",+ "<root>/work",+ "<root>/bin/missing",+ "--agent",+ "reviewer",+ "--prompt",+ "fixture prompt"+ ],+ "env": {+ "OPENCODE_CONFIG_CONTENT": "{\"permission\":\"ask\",\"model\":\"opencode/muse-spark-1.3-contributor-free\",\"small_model\":\"opencode/muse-spark-1.3-contributor-free\",\"provider\":{\"opencode\":{\"models\":{\"muse-spark-1.3-contributor-free\":{\"options\":{\"reasoningEffort\":\"xhigh\"}}}}},\"agent\":{\"build\":{\"model\":\"opencode/muse-spark-1.3-contributor-free\",\"variant\":\"xhigh\"},\"plan\":{\"model\":\"opencode/muse-spark-1.3-contributor-free\",\"variant\":\"xhigh\"}}}"+ },+ "engine": "opencode",+ "agent": "reviewer",+ "permissionMode": null,+ "grid": null,+ "gridLaunchRecord": null,+ "script": "rm -f -- '<root>/adapter_data_dir/launch/<script>.sh'\nharness_nofile=$(ulimit -S -n 2>/dev/null) || harness_nofile=unlimited; if [ \"$harness_nofile\" != unlimited ] && [ \"$harness_nofile\" -lt 65536 ] 2>/dev/null; then ulimit -S -n 65536 2>/dev/null || ulimit -S -n \"$(ulimit -H -n)\" 2>/dev/null || true; fi; unset harness_nofile\nharness_stopped() {\n [ \"$harness_status\" -gt 128 ] 2>/dev/null || return 1\n harness_signal=$(kill -l \"$harness_status\" 2>/dev/null) || return 1\n case $harness_signal in\n STOP|TSTP|TTIN|TTOU|SIGSTOP|SIGTSTP|SIGTTIN|SIGTTOU) jobs %% >/dev/null 2>&1 ;;\n *) return 1 ;;\n esac\n}\nharness_fg() {\n harness_now=$(date +%s 2>/dev/null) || harness_now=0\n if [ $((harness_now - harness_resumed)) -le 1 ]; then harness_quick=$((harness_quick + 1)); else harness_quick=0; fi\n harness_resumes=$((harness_resumes + 1))\n case $harness_signal in *TTIN|*TTOU) harness_stuck=$harness_quick ;; *) harness_stuck=0 ;; esac\n if [ \"$harness_stuck\" -ge 5 ] || { [ -z \"${ZSH_VERSION:-}\" ] && [ \"$harness_resumes\" -ge 1000 ]; }; then\n kill -9 %% 2>/dev/null\n harness_status=137\n return 0\n fi\n if [ \"$harness_quick\" -ge 3 ]; then harness_waited=$(sleep 1) || :; fi\n harness_resumed=$(date +%s 2>/dev/null) || harness_resumed=0\n harness_status=0\n fg >/dev/null || harness_status=$?\n}\nharness_resume() {\n if [ -n \"${ZSH_VERSION:-}\" ]; then\n while harness_stopped; do harness_fg; done\n return 0\n fi\n harness_stopped || return 0\n harness_fg\n harness_resume\n}\nharness_resumed=0\nharness_quick=0\nharness_resumes=0\nharness_after() {\n if [ \"$harness_status\" -eq 127 ]; then exit 127; fi\n [ -n \"${TMUX_PANE:-}\" ] && { '/fixture/bin/tmux' set-option -p -t \"$TMUX_PANE\" @harness_engine_exit \"$harness_status\" >/dev/null 2>&1 || '/fixture/bin/tmux' set-option -w -t \"$TMUX_PANE\" @harness_engine_exit \"$harness_status\" >/dev/null 2>&1; } || true\n if ! [ -t 0 ]; then exit \"$harness_status\"; fi\n if harness_tty=$(stty -g 2>/dev/null) && stty -icanon -echo min 0 time 3 2>/dev/null; then\n while harness_waiting=$(dd bs=65536 count=1 2>/dev/null | wc -c) && [ \"$((harness_waiting))\" -gt 0 ]; do :; done\n stty \"$harness_tty\" 2>/dev/null || true\n fi\n printf '\\n%s\\n' 'harness: missing exited ('\"$harness_status\"'). This pane is a shell now — run missing again, or stop the pane.'\n exec '/bin/sh'\n}\nunset HARNESS_DSH HARNESS_DSH_DIR HARNESS_WORKSPACE HARNESS_CONTEXT_FILE HARNESS_SKILLS_DIR HARNESS_PRIVATE_GRID\nGRID_NO_UPDATE_CHECK=1\nexport GRID_NO_UPDATE_CHECK\nif ! cd -- \"$1\"; then printf '%s\\n' 'harness: the selected working directory is unavailable.' >&2; exit 1; fi\nif ! [ -r . ]; then printf '%s\\n' \"harness: cannot read $PWD — the agent was not started.\" 'harness: check the folder'\"'\"'s permissions for this user.' >&2; exit 1; fi\nshift\nif [ -n \"${ZSH_VERSION:-}\" ]; then setopt monitor 2>/dev/null || :; else set -m 2>/dev/null || :; fi\ntrap : INT QUIT\nharness_engine_bin=$1\nshift\nharness_status=0\n\"$harness_engine_bin\" \"$@\" || harness_status=$?\nharness_resume\nharness_after"+ }+ ],+ "native": []+ },+ "missing fork named=true": {+ "result": {+ "ok": false,+ "error": "RECORDED",+ "detail": "No pane is opened by this golden."+ },+ "panes": [+ {+ "argv": [+ "/bin/sh",+ "-ic",+ ". '<root>/adapter_data_dir/launch/<script>.sh'",+ "harness-engine",+ "<root>/work",+ "<root>/bin/missing",+ "-m",+ "fixture/model#high",+ "--agent",+ "reviewer",+ "--prompt",+ "You are a fork of the agent \"work · ses_\" in <root>/work. It kept working; you are its copy, picking up from what it knew. Here is its recent history, oldest first.\n\nAsked: fixture ask\n\nIts last full answer:\nfixture answer\n\nContinue from there. Your task now: try another approach"+ ],+ "engine": "opencode",+ "agent": "reviewer",+ "forkedFrom": {+ "agentId": "fixture-agent",+ "name": "work · ses_",+ "sessionId": "ses_fixture"+ },+ "permissionMode": null,+ "grid": null,+ "gridLaunchRecord": null,+ "script": "rm -f -- '<root>/adapter_data_dir/launch/<script>.sh'\nharness_nofile=$(ulimit -S -n 2>/dev/null) || harness_nofile=unlimited; if [ \"$harness_nofile\" != unlimited ] && [ \"$harness_nofile\" -lt 65536 ] 2>/dev/null; then ulimit -S -n 65536 2>/dev/null || ulimit -S -n \"$(ulimit -H -n)\" 2>/dev/null || true; fi; unset harness_nofile\nharness_stopped() {\n [ \"$harness_status\" -gt 128 ] 2>/dev/null || return 1\n harness_signal=$(kill -l \"$harness_status\" 2>/dev/null) || return 1\n case $harness_signal in\n STOP|TSTP|TTIN|TTOU|SIGSTOP|SIGTSTP|SIGTTIN|SIGTTOU) jobs %% >/dev/null 2>&1 ;;\n *) return 1 ;;\n esac\n}\nharness_fg() {\n harness_now=$(date +%s 2>/dev/null) || harness_now=0\n if [ $((harness_now - harness_resumed)) -le 1 ]; then harness_quick=$((harness_quick + 1)); else harness_quick=0; fi\n harness_resumes=$((harness_resumes + 1))\n case $harness_signal in *TTIN|*TTOU) harness_stuck=$harness_quick ;; *) harness_stuck=0 ;; esac\n if [ \"$harness_stuck\" -ge 5 ] || { [ -z \"${ZSH_VERSION:-}\" ] && [ \"$harness_resumes\" -ge 1000 ]; }; then\n kill -9 %% 2>/dev/null\n harness_status=137\n return 0\n fi\n if [ \"$harness_quick\" -ge 3 ]; then harness_waited=$(sleep 1) || :; fi\n harness_resumed=$(date +%s 2>/dev/null) || harness_resumed=0\n harness_status=0\n fg >/dev/null || harness_status=$?\n}\nharness_resume() {\n if [ -n \"${ZSH_VERSION:-}\" ]; then\n while harness_stopped; do harness_fg; done\n return 0\n fi\n harness_stopped || return 0\n harness_fg\n harness_resume\n}\nharness_resumed=0\nharness_quick=0\nharness_resumes=0\nharness_after() {\n if [ \"$harness_status\" -eq 127 ]; then exit 127; fi\n [ -n \"${TMUX_PANE:-}\" ] && { '/fixture/bin/tmux' set-option -p -t \"$TMUX_PANE\" @harness_engine_exit \"$harness_status\" >/dev/null 2>&1 || '/fixture/bin/tmux' set-option -w -t \"$TMUX_PANE\" @harness_engine_exit \"$harness_status\" >/dev/null 2>&1; } || true\n if ! [ -t 0 ]; then exit \"$harness_status\"; fi\n if harness_tty=$(stty -g 2>/dev/null) && stty -icanon -echo min 0 time 3 2>/dev/null; then\n while harness_waiting=$(dd bs=65536 count=1 2>/dev/null | wc -c) && [ \"$((harness_waiting))\" -gt 0 ]; do :; done\n stty \"$harness_tty\" 2>/dev/null || true\n fi\n printf '\\n%s\\n' 'harness: missing exited ('\"$harness_status\"'). This pane is a shell now — run missing again, or stop the pane.'\n exec '/bin/sh'\n}\nunset HARNESS_DSH HARNESS_DSH_DIR HARNESS_WORKSPACE HARNESS_CONTEXT_FILE HARNESS_SKILLS_DIR HARNESS_PRIVATE_GRID\nGRID_NO_UPDATE_CHECK=1\nexport GRID_NO_UPDATE_CHECK\nif ! cd -- \"$1\"; then printf '%s\\n' 'harness: the selected working directory is unavailable.' >&2; exit 1; fi\nif ! [ -r . ]; then printf '%s\\n' \"harness: cannot read $PWD — the agent was not started.\" 'harness: check the folder'\"'\"'s permissions for this user.' >&2; exit 1; fi\nshift\nif [ -n \"${ZSH_VERSION:-}\" ]; then setopt monitor 2>/dev/null || :; else set -m 2>/dev/null || :; fi\ntrap : INT QUIT\nharness_engine_bin=$1\nshift\nharness_status=0\n\"$harness_engine_bin\" \"$@\" || harness_status=$?\nharness_resume\nharness_after"+ }+ ],+ "native": []+ },+ "missing relaunch named=true": {+ "result": {+ "ok": true,+ "overrides": {+ "env": {},+ "extraArgs": [+ "-m",+ "fixture/model#high",+ "--agent",+ "reviewer"+ ],+ "clearEnv": [+ "HARNESS_DSH",+ "HARNESS_DSH_DIR",+ "HARNESS_WORKSPACE",+ "HARNESS_CONTEXT_FILE",+ "HARNESS_SKILLS_DIR",+ "HARNESS_PRIVATE_GRID"+ ],+ "sessionModel": "fixture/model#high"+ }+ },+ "native": []+ },+ "missing retarget own login": {+ "result": {+ "ok": true+ },+ "events": [+ [+ "cancel"+ ],+ [+ "holdRoute"+ ],+ [+ "clearEnv",+ [+ "GRID_API_KEY",+ "OPENCODE_CONFIG"+ ]+ ],+ [+ "holdOpen"+ ],+ [+ "terminate"+ ],+ [+ "respawn",+ [+ "/bin/sh",+ "-ic",+ ". '<root>/adapter_data_dir/launch/<script>.sh'",+ "harness-engine",+ "<root>/work",+ "<root>/bin/missing",+ "--session",+ "ses_fixture",+ "-m",+ "fixture/model#high",+ "--agent",+ "reviewer"+ ],+ {+ "env": {},+ "extraArgs": [+ "-m",+ "fixture/model#high",+ "--agent",+ "reviewer"+ ],+ "clearEnv": [+ "HARNESS_DSH",+ "HARNESS_DSH_DIR",+ "HARNESS_WORKSPACE",+ "HARNESS_CONTEXT_FILE",+ "HARNESS_SKILLS_DIR",+ "HARNESS_PRIVATE_GRID"+ ],+ "sessionModel": "fixture/model#high"+ },+ "rm -f -- '<root>/adapter_data_dir/launch/<script>.sh'\nharness_nofile=$(ulimit -S -n 2>/dev/null) || harness_nofile=unlimited; if [ \"$harness_nofile\" != unlimited ] && [ \"$harness_nofile\" -lt 65536 ] 2>/dev/null; then ulimit -S -n 65536 2>/dev/null || ulimit -S -n \"$(ulimit -H -n)\" 2>/dev/null || true; fi; unset harness_nofile\nharness_stopped() {\n [ \"$harness_status\" -gt 128 ] 2>/dev/null || return 1\n harness_signal=$(kill -l \"$harness_status\" 2>/dev/null) || return 1\n case $harness_signal in\n STOP|TSTP|TTIN|TTOU|SIGSTOP|SIGTSTP|SIGTTIN|SIGTTOU) jobs %% >/dev/null 2>&1 ;;\n *) return 1 ;;\n esac\n}\nharness_fg() {\n harness_now=$(date +%s 2>/dev/null) || harness_now=0\n if [ $((harness_now - harness_resumed)) -le 1 ]; then harness_quick=$((harness_quick + 1)); else harness_quick=0; fi\n harness_resumes=$((harness_resumes + 1))\n case $harness_signal in *TTIN|*TTOU) harness_stuck=$harness_quick ;; *) harness_stuck=0 ;; esac\n if [ \"$harness_stuck\" -ge 5 ] || { [ -z \"${ZSH_VERSION:-}\" ] && [ \"$harness_resumes\" -ge 1000 ]; }; then\n kill -9 %% 2>/dev/null\n harness_status=137\n return 0\n fi\n if [ \"$harness_quick\" -ge 3 ]; then harness_waited=$(sleep 1) || :; fi\n harness_resumed=$(date +%s 2>/dev/null) || harness_resumed=0\n harness_status=0\n fg >/dev/null || harness_status=$?\n}\nharness_resume() {\n if [ -n \"${ZSH_VERSION:-}\" ]; then\n while harness_stopped; do harness_fg; done\n return 0\n fi\n harness_stopped || return 0\n harness_fg\n harness_resume\n}\nharness_resumed=0\nharness_quick=0\nharness_resumes=0\nharness_after() {\n if [ \"$harness_status\" -eq 127 ]; then exit 127; fi\n [ -n \"${TMUX_PANE:-}\" ] && { '/fixture/bin/tmux' set-option -p -t \"$TMUX_PANE\" @harness_engine_exit \"$harness_status\" >/dev/null 2>&1 || '/fixture/bin/tmux' set-option -w -t \"$TMUX_PANE\" @harness_engine_exit \"$harness_status\" >/dev/null 2>&1; } || true\n if ! [ -t 0 ]; then exit \"$harness_status\"; fi\n if harness_tty=$(stty -g 2>/dev/null) && stty -icanon -echo min 0 time 3 2>/dev/null; then\n while harness_waiting=$(dd bs=65536 count=1 2>/dev/null | wc -c) && [ \"$((harness_waiting))\" -gt 0 ]; do :; done\n stty \"$harness_tty\" 2>/dev/null || true\n fi\n printf '\\n%s\\n' 'harness: missing exited ('\"$harness_status\"'). This pane is a shell now — run missing again, or stop the pane.'\n exec '/bin/sh'\n}\nGRID_NO_UPDATE_CHECK=1\nexport GRID_NO_UPDATE_CHECK\nif ! cd -- \"$1\"; then printf '%s\\n' 'harness: the selected working directory is unavailable.' >&2; exit 1; fi\nif ! [ -r . ]; then printf '%s\\n' \"harness: cannot read $PWD — the agent was not started.\" 'harness: check the folder'\"'\"'s permissions for this user.' >&2; exit 1; fi\nshift\nif [ -n \"${ZSH_VERSION:-}\" ]; then setopt monitor 2>/dev/null || :; else set -m 2>/dev/null || :; fi\ntrap : INT QUIT\nharness_engine_bin=$1\nshift\nharness_status=0\n\"$harness_engine_bin\" \"$@\" || harness_status=$?\nharness_resume\nharness_after"+ ],+ [+ "process",+ "fixture-agent",+ {+ "pid": 4343,+ "executable": "opencode",+ "startMarker": "replacement"+ },+ "none"+ ],+ [+ "grid",+ "fixture-agent",+ null+ ],+ [+ "active",+ "fixture-agent",+ true+ ],+ [+ "announce"+ ],+ [+ "assignment"+ ],+ [+ "release"+ ],+ [+ "releaseRoute"+ ]+ ],+ "native": [+ {+ "control": [+ "cancel"+ ]+ },+ {+ "control": [+ "holdRoute"+ ]+ },+ {+ "binary": "sqlite3",+ "args": [+ "-batch",+ "-bail",+ "<root>/fixture.db",+ "PRAGMA busy_timeout = 5000;\nBEGIN IMMEDIATE;\nUPDATE message SET data = json_set(data, '$.model.providerID', 'fixture', '$.model.modelID', 'model#high') WHERE id = (SELECT id FROM message WHERE session_id = 'ses_fixture' AND json_extract(data, '$.role') = 'user' ORDER BY time_created DESC LIMIT 1);\nSELECT changes();\nUPDATE session SET model = json_object('id', 'model#high', 'providerID', 'fixture', 'variant', 'default') WHERE id = 'ses_fixture' AND EXISTS (SELECT 1 FROM message WHERE session_id = 'ses_fixture' AND json_extract(data, '$.role') = 'user');\nSELECT changes();\nCOMMIT;"+ ]+ },+ {+ "control": [+ "clearEnv",+ [+ "GRID_API_KEY",+ "OPENCODE_CONFIG"+ ]+ ]+ },+ {+ "control": [+ "holdOpen"+ ]+ },+ {+ "control": [+ "terminate"+ ]+ },+ {+ "control": [+ "respawn",+ [+ "/bin/sh",+ "-ic",+ ". '<root>/adapter_data_dir/launch/<script>.sh'",+ "harness-engine",+ "<root>/work",+ "<root>/bin/missing",+ "--session",+ "ses_fixture",+ "-m",+ "fixture/model#high",+ "--agent",+ "reviewer"+ ],+ {+ "env": {},+ "extraArgs": [+ "-m",+ "fixture/model#high",+ "--agent",+ "reviewer"+ ],+ "clearEnv": [+ "HARNESS_DSH",+ "HARNESS_DSH_DIR",+ "HARNESS_WORKSPACE",+ "HARNESS_CONTEXT_FILE",+ "HARNESS_SKILLS_DIR",+ "HARNESS_PRIVATE_GRID"+ ],+ "sessionModel": "fixture/model#high"+ },+ "rm -f -- '<root>/adapter_data_dir/launch/<script>.sh'\nharness_nofile=$(ulimit -S -n 2>/dev/null) || harness_nofile=unlimited; if [ \"$harness_nofile\" != unlimited ] && [ \"$harness_nofile\" -lt 65536 ] 2>/dev/null; then ulimit -S -n 65536 2>/dev/null || ulimit -S -n \"$(ulimit -H -n)\" 2>/dev/null || true; fi; unset harness_nofile\nharness_stopped() {\n [ \"$harness_status\" -gt 128 ] 2>/dev/null || return 1\n harness_signal=$(kill -l \"$harness_status\" 2>/dev/null) || return 1\n case $harness_signal in\n STOP|TSTP|TTIN|TTOU|SIGSTOP|SIGTSTP|SIGTTIN|SIGTTOU) jobs %% >/dev/null 2>&1 ;;\n *) return 1 ;;\n esac\n}\nharness_fg() {\n harness_now=$(date +%s 2>/dev/null) || harness_now=0\n if [ $((harness_now - harness_resumed)) -le 1 ]; then harness_quick=$((harness_quick + 1)); else harness_quick=0; fi\n harness_resumes=$((harness_resumes + 1))\n case $harness_signal in *TTIN|*TTOU) harness_stuck=$harness_quick ;; *) harness_stuck=0 ;; esac\n if [ \"$harness_stuck\" -ge 5 ] || { [ -z \"${ZSH_VERSION:-}\" ] && [ \"$harness_resumes\" -ge 1000 ]; }; then\n kill -9 %% 2>/dev/null\n harness_status=137\n return 0\n fi\n if [ \"$harness_quick\" -ge 3 ]; then harness_waited=$(sleep 1) || :; fi\n harness_resumed=$(date +%s 2>/dev/null) || harness_resumed=0\n harness_status=0\n fg >/dev/null || harness_status=$?\n}\nharness_resume() {\n if [ -n \"${ZSH_VERSION:-}\" ]; then\n while harness_stopped; do harness_fg; done\n return 0\n fi\n harness_stopped || return 0\n harness_fg\n harness_resume\n}\nharness_resumed=0\nharness_quick=0\nharness_resumes=0\nharness_after() {\n if [ \"$harness_status\" -eq 127 ]; then exit 127; fi\n [ -n \"${TMUX_PANE:-}\" ] && { '/fixture/bin/tmux' set-option -p -t \"$TMUX_PANE\" @harness_engine_exit \"$harness_status\" >/dev/null 2>&1 || '/fixture/bin/tmux' set-option -w -t \"$TMUX_PANE\" @harness_engine_exit \"$harness_status\" >/dev/null 2>&1; } || true\n if ! [ -t 0 ]; then exit \"$harness_status\"; fi\n if harness_tty=$(stty -g 2>/dev/null) && stty -icanon -echo min 0 time 3 2>/dev/null; then\n while harness_waiting=$(dd bs=65536 count=1 2>/dev/null | wc -c) && [ \"$((harness_waiting))\" -gt 0 ]; do :; done\n stty \"$harness_tty\" 2>/dev/null || true\n fi\n printf '\\n%s\\n' 'harness: missing exited ('\"$harness_status\"'). This pane is a shell now — run missing again, or stop the pane.'\n exec '/bin/sh'\n}\nGRID_NO_UPDATE_CHECK=1\nexport GRID_NO_UPDATE_CHECK\nif ! cd -- \"$1\"; then printf '%s\\n' 'harness: the selected working directory is unavailable.' >&2; exit 1; fi\nif ! [ -r . ]; then printf '%s\\n' \"harness: cannot read $PWD — the agent was not started.\" 'harness: check the folder'\"'\"'s permissions for this user.' >&2; exit 1; fi\nshift\nif [ -n \"${ZSH_VERSION:-}\" ]; then setopt monitor 2>/dev/null || :; else set -m 2>/dev/null || :; fi\ntrap : INT QUIT\nharness_engine_bin=$1\nshift\nharness_status=0\n\"$harness_engine_bin\" \"$@\" || harness_status=$?\nharness_resume\nharness_after"+ ]+ },+ {+ "control": [+ "process",+ "fixture-agent",+ {+ "pid": 4343,+ "executable": "opencode",+ "startMarker": "replacement"+ },+ "none"+ ]+ },+ {+ "control": [+ "grid",+ "fixture-agent",+ null+ ]+ },+ {+ "control": [+ "active",+ "fixture-agent",+ true+ ]+ },+ {+ "control": [+ "announce"+ ]+ },+ {+ "control": [+ "assignment"+ ]+ },+ {+ "control": [+ "release"+ ]+ },+ {+ "control": [+ "releaseRoute"+ ]+ }+ ]+ }+}diff --git a/cli/src/engines/dshLaunchShapes.golden.spec.ts b/cli/src/engines/dshLaunchShapes.golden.spec.tsindex 73f9e96d9..29db8fe12 100644--- a/cli/src/engines/dshLaunchShapes.golden.spec.ts+++ b/cli/src/engines/dshLaunchShapes.golden.spec.ts@@ -38,7 +38,7 @@ vi.mock('../lib/createAgentPane.js', () => ({}),}))vi.mock('../lib/tmuxVersion.js', async (real) => ({ ...await real<object>(), tmuxSupportsSessionEnv: vi.fn(async () => pane.tmux) }))-vi.mock('../engines/opencode/version.js', async (real) => ({ ...await real<object>(), opencodeMajorVersion: vi.fn(() => 2) }))+vi.mock('../engines/launchControl.js', async (real) => ({ ...await real<object>(), opencodeMajorVersion: vi.fn(() => 2) }))vi.mock('../lib/engineBin.js', async (real) => ({ ...await real<object>(), enginePathOverride: vi.fn(() => null) }))// A create's and a fork's label is new each time, and their session's runtime is keyed on it: one per engine here.vi.mock('../lib/harnessSessionLabel.js', async (real) => ({ ...await real<object>(), buildHarnessSessionLabel: vi.fn((engine: string) => `harness-${engine}-golden`) }))diff --git a/cli/src/engines/kit/nativeSessionModel.ts b/cli/src/engines/kit/nativeSessionModel.tsnew file mode 100644index 000000000..134e3d763--- /dev/null+++ b/cli/src/engines/kit/nativeSessionModel.ts@@ -0,0 +1,242 @@+/** Native launch writes from an engine's declared SQLite transaction or CLI API protocol.+ * Optional history readers never own these operations. Compatibility extraction first;+ * cancellation and uncertain-write corrections are tracked in the OpenCode control research note. */+import { execFile } from 'node:child_process'+import { promisify } from 'node:util'++export interface NativeSessionModel { providerID: string; modelID: string }+export type NativeModelResult = { ok: true } | { ok: false; code: string; detail: string }+export type NativeApiRun = (args: string[], options: { cwd?: string }) => Promise<{ stdout: string }>+export interface NativeModelRule {+ label: string; serviceMajor: number; id: RegExp; modelFlags: readonly string[]; modelEquals: string; variantSeparator: string+ errors: { sqliteMissing: string; sessionMissing: string; writeFailed: string; binaryMissing: string; switchFailed: string; unknownModel: string }+ sqlite: { args: readonly string[]; timeoutMs: number; statements: readonly string[] }+ api: { timeoutMs: number; retryDelayMs: number; list: readonly string[]; switch: readonly string[]; get: readonly string[];+ paramFlag: string; sessionParam: string; bodyFlag: string; missingSession: RegExp;+ fields: { data: string; model: string; id: string; alternativeId: string; provider: string; variant: string } }+}+const execFileAsync = promisify(execFile)++export function createSessionModelControl(rule: NativeModelRule, binary: () => string) {+ const ID_RE = rule.id+ /** A SQL string literal — the only way a value reaches the statement. */+ function lit(value: string): string {+ return `'${value.replace(/'/g, "''")}'`+ }++ /**+ * The `provider/model` an opencode argv names, split the way opencode splits it: the provider is+ * everything before the FIRST slash, the model is the rest (`vibe/minimax/minimax-m3` → `vibe` ++ * `minimax/minimax-m3`). Reads the LAST `-m`/`--model`, which is the one opencode honours.+ * Null when the argv names no model — then there is nothing to write and the engine decides.+ */+ function modelFromArgv(args: readonly string[]): NativeSessionModel | null {+ let id: string | null = null+ for (let i = 0; i < args.length; i++) {+ const arg = args[i]+ if (rule.modelFlags.includes(arg) && i + 1 < args.length) { id = args[i + 1]; i++ }+ else if (arg.startsWith(rule.modelEquals)) id = arg.slice(rule.modelEquals.length)+ }+ return id ? parseModelId(id) : null+ }++ /** A `provider/model` id split the way opencode splits it, or null when it names no provider. */+ function parseModelId(id: string): NativeSessionModel | null {+ const slash = id.indexOf('/')+ if (slash <= 0 || slash === id.length - 1) return null+ return { providerID: id.slice(0, slash), modelID: id.slice(slash + 1) }+ }++ /**+ * Rewrite `sessionId`'s model in `dbPath` so that resuming it opens on `model`.+ *+ * One transaction: both rows or neither. Refuses without writing when `sqlite3` is absent, when the+ * id is not an opencode session id, or when the session has no user message yet (the declared transaction guards it).+ */+ async function setSessionModel(+ dbPath: string,+ sessionId: string,+ model: NativeSessionModel,+ ): Promise<NativeModelResult> {+ if (!ID_RE.test(sessionId)) {+ return { ok: false, code: rule.errors.sessionMissing, detail: `not an ${rule.label} session id: ${sessionId}` }+ }+ if (!model.providerID || !model.modelID) {+ return { ok: false, code: rule.errors.writeFailed, detail: 'refusing to write an empty provider or model id' }+ }+ const values: Record<string, string> = { session: lit(sessionId), provider: lit(model.providerID), model: lit(model.modelID) }+ const sql = rule.sqlite.statements.join('\n').replace(/\{\{(session|provider|model)\}\}/g, (_token, key: string) => values[key]!)++ let stdout: string+ try {+ // `-bail` stops at the first failing statement; the shell then exits with the transaction still+ // open, and SQLite rolls it back on close — so a failing second UPDATE leaves the first unapplied.+ // Bounded: a CLI that never answers used to hold this `agent_create` open for good. The write+ // itself waits at most `busy_timeout` (5s, above) for opencode's lock, so 15s is generous.+ ({ stdout } = await execFileAsync('sqlite3', [...rule.sqlite.args, dbPath, sql], { timeout: rule.sqlite.timeoutMs, killSignal: 'SIGKILL' }))+ } catch (err) {+ const error = err as NodeJS.ErrnoException & { stderr?: string }+ if (error?.code === 'ENOENT') {+ return { ok: false, code: rule.errors.sqliteMissing, detail: 'sqlite3 CLI not found on PATH' }+ }+ const stderr = String(error?.stderr ?? '').trim()+ return { ok: false, code: rule.errors.writeFailed, detail: stderr || String(error?.message ?? err) }+ }+ const lines = stdout.trim().split('\n').map((line) => line.trim()).filter(Boolean)+ // Lines: the pragma's echo, then the two change counts.+ const messages = Number(lines[lines.length - 2])+ const sessions = Number(lines[lines.length - 1])+ if (!Number.isFinite(messages) || !Number.isFinite(sessions)) {+ return { ok: false, code: rule.errors.writeFailed, detail: `unexpected sqlite3 output: ${stdout.trim().slice(0, 200)}` }+ }+ if (messages === 0) {+ return {+ ok: false,+ code: rule.errors.sessionMissing,+ detail: `session ${sessionId} has no user message yet — nothing to rewrite; -m applies on launch`,+ }+ }+ console.log(+ `[${rule.label}] session model set to ${model.providerID}/${model.modelID} · ` ++ `${messages} message row, ${sessions} session row`,+ )+ return { ok: true }+ }++ const runNative: NativeApiRun = async (args, options) => {+ // Bounded like the sqlite3 write: the service answers in well under a second (77ms measured).+ const { stdout } = await execFileAsync(binary(), args, {+ ...(options.cwd ? { cwd: options.cwd } : {}), timeout: rule.api.timeoutMs, killSignal: 'SIGKILL',+ })+ return { stdout }+ }++ /** What a failed `opencode api` call said: the body is on stdout, the HTTP status on stderr. */+ function apiFailure(err: unknown): { missing: boolean; text: string } {+ const error = err as NodeJS.ErrnoException & { stdout?: string; stderr?: string }+ if (error?.code === 'ENOENT') return { missing: true, text: String(error.message ?? err) }+ const text = [error?.stdout, error?.stderr].map((part) => String(part ?? '').trim()).filter(Boolean).join(' · ')+ return { missing: false, text: text || String(error?.message ?? err) }+ }++ /**+ * Put `sessionId` on `model` through the engine's declared native API.+ *+ * Talks to the background service (`opencode api` with no `--standalone`), which owns the store.+ * Proved on 2.0.18 that a session last opened by a `--standalone` pane is switched just the same,+ * and that the next pane reads it from the store whichever server it runs on. Never touches the DB.+ *+ * Measured on 2.0.18 that the service stores any id (`opencode/does-not-exist` reads back as set),+ * so with `checkCatalog` the model is looked for in `model.list` first — for a model of opencode's+ * own; a grid's provider is declared in its pane's own config, which the service never reads. A+ * switch that did not land is tried once more, after `retryDelayMs`; one that cannot (no such+ * session, no opencode, an unknown model) is not.+ */+ async function switchSessionModel(+ sessionId: string,+ model: NativeSessionModel,+ options: { cwd?: string; run?: NativeApiRun; checkCatalog?: boolean; retryDelayMs?: number } = {},+ ): Promise<NativeModelResult> {+ if (!ID_RE.test(sessionId)) {+ return { ok: false, code: rule.errors.sessionMissing, detail: `not an ${rule.label} session id: ${sessionId}` }+ }+ const run = options.run ?? runNative+ if (options.checkCatalog) {+ const known = await listsModel(run, model, options.cwd)+ if (known === false) {+ return { ok: false, code: rule.errors.unknownModel, detail: `${rule.label} has no ${model.providerID}/${model.modelID} — \`${rule.label} models\` lists the ones it has` }+ }+ }+ let result = await switchOnce(run, sessionId, model, options.cwd)+ if (!result.ok && result.code === rule.errors.switchFailed) {+ console.warn(`[${rule.label}] switch to ${model.providerID}/${model.modelID} did not land (${result.detail}) · trying once more`)+ await new Promise((resolve) => setTimeout(resolve, options.retryDelayMs ?? rule.api.retryDelayMs))+ result = await switchOnce(run, sessionId, model, options.cwd)+ }+ return result+ }++ /**+ * A v2 model id and the effort it names: `model#high` is opencode's own way (`opencode run -m+ * provider/model#variant`). v1 never splits it — its `-m` and its rewrite take the id as written.+ */+ function splitVariant(modelID: string): { id: string; variant?: string } {+ const at = modelID.lastIndexOf(rule.variantSeparator)+ return at > 0 && at < modelID.length - rule.variantSeparator.length ? { id: modelID.slice(0, at), variant: modelID.slice(at + rule.variantSeparator.length) } : { id: modelID }+ }++ /** Whether the service's `model.list` has [model]; null when the list could not be read. */+ async function listsModel(run: NativeApiRun, model: NativeSessionModel, cwd?: string): Promise<boolean | null> {+ try {+ const { stdout } = await run([...rule.api.list], { cwd })+ const parsed = JSON.parse(stdout) as Record<string, unknown> | unknown[]+ const fields = rule.api.fields+ const rows = (Array.isArray(parsed) ? parsed : parsed[fields.data]) as Array<Record<string, unknown>> | undefined+ if (!Array.isArray(rows)) return null+ const { id } = splitVariant(model.modelID)+ return rows.some((m) => m[fields.provider] === model.providerID && (m[fields.id] === id || m[fields.alternativeId] === id))+ } catch {+ return null+ }+ }++ /** One switch through the service, read back. */+ async function switchOnce(run: NativeApiRun, sessionId: string, model: NativeSessionModel, cwd?: string): Promise<NativeModelResult> {+ const options = { cwd }+ const param = `${rule.api.sessionParam}=${sessionId}`+ const { id, variant } = splitVariant(model.modelID)+ const fields = rule.api.fields+ const body = JSON.stringify({ [fields.model]: { [fields.id]: id, [fields.provider]: model.providerID, ...(variant ? { [fields.variant]: variant } : {}) } })+ try {+ await run([...rule.api.switch, rule.api.paramFlag, param, rule.api.bodyFlag, body], { cwd: options.cwd })+ } catch (err) {+ const failure = apiFailure(err)+ if (failure.missing) return { ok: false, code: rule.errors.binaryMissing, detail: `${rule.label} not found: ${failure.text}` }+ const code = rule.api.missingSession.test(failure.text) ? rule.errors.sessionMissing : rule.errors.switchFailed+ return { ok: false, code, detail: failure.text }+ }+ // Read back: the service answers 204 for any model, known or not, so only the session itself can+ // say the switch landed.+ let stdout: string+ try {+ ({ stdout } = await run([...rule.api.get, rule.api.paramFlag, param], { cwd: options.cwd }))+ } catch (err) {+ return { ok: false, code: rule.errors.switchFailed, detail: `could not read the session back · ${apiFailure(err).text}` }+ }+ let now: Record<string, unknown> | undefined+ try {+ now = (JSON.parse(stdout) as Record<string, Record<string, Record<string, unknown>>>)[fields.data]?.[fields.model]+ } catch {+ now = undefined+ }+ // (A variant asked for must read back too; none asked for, the service's own is fine.)+ if (now?.[fields.id] !== id || now?.[fields.provider] !== model.providerID || (variant && now?.[fields.variant] !== variant)) {+ const seen = now ? `${String(now[fields.provider])}/${String(now[fields.id])}${now[fields.variant] ? `#${String(now[fields.variant])}` : ''}` : stdout.trim().slice(0, 200)+ return { ok: false, code: rule.errors.switchFailed, detail: `session ${sessionId} is still on ${seen}` }+ }+ console.log(`[${rule.label}] session model switched to ${model.providerID}/${model.modelID} through the service`)+ return { ok: true }+ }++ /**+ * Put a resumed session on `model` the way the installed OpenCode needs, BEFORE its pane is+ * relaunched. A failure here is the caller's refusal: the live process has not been touched yet.+ *+ * * v1 (or a version not read): the SQL rewrite above. A session with no user message yet is fine+ * there — the relaunch's `-m` applies to it — so that one answer is success.+ * * v2: the API. Every failure is a failure, `SESSION_NOT_FOUND` included: the relaunch carries no+ * `-m`, so a switch that did not land is a pane on the old model with the move reported done.+ */+ async function applySessionModel(+ input: { major: number | null | undefined; dbPath: string; sessionId: string; model: NativeSessionModel; cwd?: string; checkCatalog?: boolean },+ deps: { run?: NativeApiRun; retryDelayMs?: number } = {},+ ): Promise<NativeModelResult> {+ if ((input.major ?? 0) >= rule.serviceMajor) {+ return switchSessionModel(input.sessionId, input.model, { cwd: input.cwd, run: deps.run, checkCatalog: input.checkCatalog, retryDelayMs: deps.retryDelayMs })+ }+ const written = await setSessionModel(input.dbPath, input.sessionId, input.model)+ return !written.ok && written.code === rule.errors.sessionMissing ? { ok: true } : written+ }++ return { modelFromArgv, parseModelId, setSessionModel, switchSessionModel, applySessionModel }+}diff --git a/cli/src/engines/kit/nativeVersion.ts b/cli/src/engines/kit/nativeVersion.tsnew file mode 100644index 000000000..251c3c0f7--- /dev/null+++ b/cli/src/engines/kit/nativeVersion.ts@@ -0,0 +1,35 @@+/** Native executable facts used by launch control, without loading an interpreter. */+import { execFileSync } from 'node:child_process'+import { statSync } from 'node:fs'+import { resolveBinaryOnPath } from '../../lib/binaryOnPath.js'++export interface VersionRule { output: RegExp; args: readonly string[]; timeoutMs: number }+export interface VersionProbe { identity(): string | null; read(): string }++export function parseMajor(rule: VersionRule, output: string): number | null {+ const match = rule.output.exec(output)+ return match ? Number(match[1]) : null+}++export function nativeVersionProbe(rule: VersionRule, binary: () => string): VersionProbe {+ return {+ identity: () => {+ const bin = binary(), path = bin.includes('/') ? bin : resolveBinaryOnPath(bin)+ if (!path) return null+ try { const info = statSync(path); return `${path}:${info.size}:${info.mtimeMs}` } catch { return null }+ },+ read: () => execFileSync(binary(), [...rule.args], {+ encoding: 'utf8', timeout: rule.timeoutMs, killSignal: 'SIGKILL', stdio: ['ignore', 'pipe', 'ignore'],+ }),+ }+}++/** Compatibility behavior: one answer per installed file; absent files have no cache key. */+export function majorVersion(rule: VersionRule, probe: VersionProbe, memo: Map<string, number | null>): number | null {+ const identity = probe.identity()+ if (identity !== null && memo.has(identity)) return memo.get(identity) ?? null+ let major: number | null+ try { major = parseMajor(rule, probe.read()) } catch { major = null }+ if (identity !== null) memo.set(identity, major)+ return major+}diff --git a/cli/src/engines/launchControl.eager.spec.ts b/cli/src/engines/launchControl.eager.spec.tsnew file mode 100644index 000000000..f27483e18--- /dev/null+++ b/cli/src/engines/launchControl.eager.spec.ts@@ -0,0 +1,13 @@+import { expect, it, vi } from 'vitest'+import { opencodeBin } from '../lib/engineBin.js'++vi.mock('../lib/engineBin.js', () => ({ opencodeBin: vi.fn(() => { throw new Error('a native command was resolved during import') }) }))+vi.mock('./inProcess.js', () => ({ loadEngine: vi.fn(() => { throw new Error('optional code was loaded during import') }) }))++it('imports native control without probing an executable, reading a store or loading interpretation', async () => {+ const control = await import('./launchControl.js')+ expect(control.parseOpencodeMajor('opencode v2.0.18')).toBe(2)+ expect(control.parseOpencodeModelId('fixture/model')).toEqual({ providerID: 'fixture', modelID: 'model' })+ expect(opencodeBin).not.toHaveBeenCalled()+ expect((await import('./inProcess.js')).loadEngine).not.toHaveBeenCalled()+})diff --git a/cli/src/engines/launchControl.ts b/cli/src/engines/launchControl.tsnew file mode 100644index 000000000..17e44d09a--- /dev/null+++ b/cli/src/engines/launchControl.ts@@ -0,0 +1,25 @@+/** Eager native launch control. Importing it neither probes a binary nor reads or writes a store. */+import { opencodeBin } from '../lib/engineBin.js'+import { OPENCODE_SESSION_MODEL, OPENCODE_VERSION } from './opencode/contract.js'+import { majorVersion, nativeVersionProbe, parseMajor, type VersionProbe } from './kit/nativeVersion.js'+import { createSessionModelControl, type NativeApiRun, type NativeModelResult, type NativeSessionModel } from './kit/nativeSessionModel.js'+export { isOpencodeV2 } from './opencode/contract.js'++export type OpencodeVersionProbe = VersionProbe+const versionProbe = nativeVersionProbe(OPENCODE_VERSION, opencodeBin)+const versionMemo = new Map<string, number | null>()+export const parseOpencodeMajor = (output: string): number | null => parseMajor(OPENCODE_VERSION, output)+export const opencodeMajorVersion = (probe: VersionProbe = versionProbe, memo = versionMemo): number | null => majorVersion(OPENCODE_VERSION, probe, memo)++export type OpencodeSessionModel = NativeSessionModel+export type SetOpencodeSessionModelResult = NativeModelResult+export type OpencodeApiRun = NativeApiRun+const model = createSessionModelControl(OPENCODE_SESSION_MODEL, opencodeBin)+export const opencodeModelFromArgv = model.modelFromArgv+export const parseOpencodeModelId = model.parseModelId+export const setOpencodeSessionModel = model.setSessionModel+export const switchOpencodeSessionModel = model.switchSessionModel+export function applyOpencodeSessionModel(+ input: { opencodeMajor: number | null | undefined; dbPath: string; sessionId: string; model: NativeSessionModel; cwd?: string; checkCatalog?: boolean },+ deps: { run?: NativeApiRun; retryDelayMs?: number } = {},+): Promise<NativeModelResult> { return model.applySessionModel({ ...input, major: input.opencodeMajor }, deps) }diff --git a/cli/src/engines/launchShapes.golden.spec.ts b/cli/src/engines/launchShapes.golden.spec.tsindex 6f69c7e56..b30277765 100644--- a/cli/src/engines/launchShapes.golden.spec.ts+++ b/cli/src/engines/launchShapes.golden.spec.ts@@ -39,7 +39,7 @@ vi.mock('../lib/createAgentPane.js', () => ({}),}))vi.mock('../lib/tmuxVersion.js', async (real) => ({ ...await real<object>(), tmuxSupportsSessionEnv: vi.fn(async () => pane.tmux) }))-vi.mock('../engines/opencode/version.js', async (real) => ({ ...await real<object>(), opencodeMajorVersion: vi.fn(() => 2) }))+vi.mock('../engines/launchControl.js', async (real) => ({ ...await real<object>(), opencodeMajorVersion: vi.fn(() => 2) }))vi.mock('../lib/engineBin.js', async (real) => ({ ...await real<object>(), enginePathOverride: vi.fn(() => null) }))const GOLDEN = fileURLToPath(new URL('./__fixtures__/launch-shapes.golden.json', import.meta.url))diff --git a/cli/src/engines/opencode/contract.ts b/cli/src/engines/opencode/contract.tsindex 4dc613107..cab33b3ff 100644--- a/cli/src/engines/opencode/contract.ts+++ b/cli/src/engines/opencode/contract.ts@@ -10,3 +10,28 @@ const OPENCODE_V2_MAJOR = 2export function isOpencodeV2(major: number | null | undefined): boolean {return (major ?? 0) >= OPENCODE_V2_MAJOR}++export const OPENCODE_VERSION = { output: /(\d+)\.\d+\.\d+/, args: ['--version'], timeoutMs: 5_000 } as const++/** Native model changes: v1's picker transaction and v2's service protocol, measured before extraction. */+export const OPENCODE_SESSION_MODEL = {+ label: 'opencode', serviceMajor: OPENCODE_V2_MAJOR, id: /^[A-Za-z0-9_]+$/,+ modelFlags: ['-m', '--model'], modelEquals: '--model=', variantSeparator: '#',+ errors: { sqliteMissing: 'OPENCODE_SQLITE_MISSING', sessionMissing: 'OPENCODE_SESSION_NOT_FOUND',+ writeFailed: 'OPENCODE_DB_WRITE_FAILED', binaryMissing: 'OPENCODE_MISSING',+ switchFailed: 'OPENCODE_MODEL_SWITCH_FAILED', unknownModel: 'OPENCODE_MODEL_UNKNOWN' },+ sqlite: { args: ['-batch', '-bail'], timeoutMs: 15_000, statements: [+ 'PRAGMA busy_timeout = 5000;',+ 'BEGIN IMMEDIATE;',+ "UPDATE message SET data = json_set(data, '$.model.providerID', {{provider}}, '$.model.modelID', {{model}}) WHERE id = (SELECT id FROM message WHERE session_id = {{session}} AND json_extract(data, '$.role') = 'user' ORDER BY time_created DESC LIMIT 1);",+ 'SELECT changes();',+ "UPDATE session SET model = json_object('id', {{model}}, 'providerID', {{provider}}, 'variant', 'default') WHERE id = {{session}} AND EXISTS (SELECT 1 FROM message WHERE session_id = {{session}} AND json_extract(data, '$.role') = 'user');",+ 'SELECT changes();',+ 'COMMIT;',+ ] },+ api: { timeoutMs: 15_000, retryDelayMs: 1_000, list: ['api', 'model.list'], switch: ['api', 'session.switchModel'],+ get: ['api', 'session.get'], paramFlag: '--param', sessionParam: 'sessionID', bodyFlag: '-d',+ missingSession: /SessionNotFoundError|HTTP 404/,+ fields: { data: 'data', model: 'model', id: 'id', alternativeId: 'modelID', provider: 'providerID', variant: 'variant' },+ },+} as constdiff --git a/cli/src/engines/opencode/inProcess.ts b/cli/src/engines/opencode/inProcess.tsindex a1858a42f..40ad57a4f 100644--- a/cli/src/engines/opencode/inProcess.ts+++ b/cli/src/engines/opencode/inProcess.ts@@ -1,8 +1,8 @@/*** OpenCode's code the core runs in its own process, loaded only once one of OpenCode's sessions needs it* (engines/inProcess.ts; docs/design/2026-10-08-other-engines-out-of-core.md). It re-exports, and holds no code of- * its own: what the core calls is the engine's own, unchanged: its transcripts' readers, its runtime profile's, the- * probe of the installed version its launches are built for, and the writer of a session's model.+ * its own: what the core calls is the engine's own, unchanged: its transcripts' readers, its runtime profile's and+ * session search. Native launch exports below are compatibility aliases of eager launch control.*/export { OpencodeReader, readOpencodeMessages } from './reader.js'export { lastOpencodeTurnText, opencodeMessagesToEvents, windowOpencodeMessages } from './normalizer.js'diff --git a/cli/src/engines/opencode/sessionModel.ts b/cli/src/engines/opencode/sessionModel.tsindex e0f39542c..cbe231e6b 100644--- a/cli/src/engines/opencode/sessionModel.ts+++ b/cli/src/engines/opencode/sessionModel.ts@@ -44,272 +44,5 @@* complaint, so success is read back with `session.get` rather than assumed.*/-import { execFile } from 'child_process'-import { promisify } from 'util'-import { opencodeBin } from '../../lib/engineBin.js'-import { isOpencodeV2 } from './version.js'--const execFileAsync = promisify(execFile)--/** Same shape `reader.ts` accepts — an opencode session id is `ses_` + base62. */-const ID_RE = /^[A-Za-z0-9_]+$/--export interface OpencodeSessionModel {- /** opencode's provider key, e.g. `opencode` or a grid's `gridProviderId(networkName)`. */- providerID: string- /** The model id under that provider, e.g. `big-pickle` or `Qwen3.6-35B-A3B`. */- modelID: string-}--export type SetOpencodeSessionModelResult =- | { ok: true }- | {- ok: false- code:- | 'OPENCODE_SQLITE_MISSING'- | 'OPENCODE_SESSION_NOT_FOUND'- | 'OPENCODE_DB_WRITE_FAILED'- | 'OPENCODE_MISSING'- | 'OPENCODE_MODEL_SWITCH_FAILED'- | 'OPENCODE_MODEL_UNKNOWN'- detail: string- }--/** A SQL string literal — the only way a value reaches the statement. */-function lit(value: string): string {- return `'${value.replace(/'/g, "''")}'`-}--/**- * The `provider/model` an opencode argv names, split the way opencode splits it: the provider is- * everything before the FIRST slash, the model is the rest (`vibe/minimax/minimax-m3` → `vibe` +- * `minimax/minimax-m3`). Reads the LAST `-m`/`--model`, which is the one opencode honours.- * Null when the argv names no model — then there is nothing to write and the engine decides.- */-export function opencodeModelFromArgv(args: readonly string[]): OpencodeSessionModel | null {- let id: string | null = null- for (let i = 0; i < args.length; i++) {- const arg = args[i]- if ((arg === '-m' || arg === '--model') && i + 1 < args.length) { id = args[i + 1]; i++ }- else if (arg.startsWith('--model=')) id = arg.slice('--model='.length)- }- return id ? parseOpencodeModelId(id) : null-}--/** A `provider/model` id split the way opencode splits it, or null when it names no provider. */-export function parseOpencodeModelId(id: string): OpencodeSessionModel | null {- const slash = id.indexOf('/')- if (slash <= 0 || slash === id.length - 1) return null- return { providerID: id.slice(0, slash), modelID: id.slice(slash + 1) }-}--/**- * Rewrite `sessionId`'s model in `dbPath` so that resuming it opens on `model`.- *- * One transaction: both rows or neither. Refuses without writing when `sqlite3` is absent, when the- * id is not an opencode session id, or when the session has no user message yet (see the header).- */-export async function setOpencodeSessionModel(- dbPath: string,- sessionId: string,- model: OpencodeSessionModel,-): Promise<SetOpencodeSessionModelResult> {- if (!ID_RE.test(sessionId)) {- return { ok: false, code: 'OPENCODE_SESSION_NOT_FOUND', detail: `not an opencode session id: ${sessionId}` }- }- if (!model.providerID || !model.modelID) {- return { ok: false, code: 'OPENCODE_DB_WRITE_FAILED', detail: 'refusing to write an empty provider or model id' }- }- const sid = lit(sessionId)- const provider = lit(model.providerID)- const modelId = lit(model.modelID)- // The user-message guard is repeated on the session UPDATE so a session with no user message is- // touched by neither statement: the transaction then commits with nothing changed, which is how- // "no user message yet" is told apart from a failed write. `changes()` after each UPDATE is the- // only stdout this reads.- const hasUser =- `EXISTS (SELECT 1 FROM message WHERE session_id = ${sid} AND json_extract(data, '$.role') = 'user')`- const sql = [- 'PRAGMA busy_timeout = 5000;',- 'BEGIN IMMEDIATE;',- `UPDATE message SET data = json_set(data, '$.model.providerID', ${provider}, '$.model.modelID', ${modelId}) ` +- `WHERE id = (SELECT id FROM message WHERE session_id = ${sid} AND json_extract(data, '$.role') = 'user' ` +- 'ORDER BY time_created DESC LIMIT 1);',- 'SELECT changes();',- `UPDATE session SET model = json_object('id', ${modelId}, 'providerID', ${provider}, 'variant', 'default') ` +- `WHERE id = ${sid} AND ${hasUser};`,- 'SELECT changes();',- 'COMMIT;',- ].join('\n')-- let stdout: string- try {- // `-bail` stops at the first failing statement; the shell then exits with the transaction still- // open, and SQLite rolls it back on close — so a failing second UPDATE leaves the first unapplied.- // Bounded: a CLI that never answers used to hold this `agent_create` open for good. The write- // itself waits at most `busy_timeout` (5s, above) for opencode's lock, so 15s is generous.- ({ stdout } = await execFileAsync('sqlite3', ['-batch', '-bail', dbPath, sql], { timeout: 15_000, killSignal: 'SIGKILL' }))- } catch (err) {- const error = err as NodeJS.ErrnoException & { stderr?: string }- if (error?.code === 'ENOENT') {- return { ok: false, code: 'OPENCODE_SQLITE_MISSING', detail: 'sqlite3 CLI not found on PATH' }- }- const stderr = String(error?.stderr ?? '').trim()- return { ok: false, code: 'OPENCODE_DB_WRITE_FAILED', detail: stderr || String(error?.message ?? err) }- }- const lines = stdout.trim().split('\n').map((line) => line.trim()).filter(Boolean)- // Lines: the pragma's echo, then the two change counts.- const messages = Number(lines[lines.length - 2])- const sessions = Number(lines[lines.length - 1])- if (!Number.isFinite(messages) || !Number.isFinite(sessions)) {- return { ok: false, code: 'OPENCODE_DB_WRITE_FAILED', detail: `unexpected sqlite3 output: ${stdout.trim().slice(0, 200)}` }- }- if (messages === 0) {- return {- ok: false,- code: 'OPENCODE_SESSION_NOT_FOUND',- detail: `session ${sessionId} has no user message yet — nothing to rewrite; -m applies on launch`,- }- }- console.log(- `[opencode] session model set to ${model.providerID}/${model.modelID} · ` +- `${messages} message row, ${sessions} session row`,- )- return { ok: true }-}--/** Runs `opencode <args>`; resolves with stdout, rejects the way `execFile` does. A seam for specs. */-export type OpencodeApiRun = (args: string[], options: { cwd?: string }) => Promise<{ stdout: string }>--const runOpencode: OpencodeApiRun = async (args, options) => {- // Bounded like the sqlite3 write: the service answers in well under a second (77ms measured).- const { stdout } = await execFileAsync(opencodeBin(), args, {- ...(options.cwd ? { cwd: options.cwd } : {}), timeout: 15_000, killSignal: 'SIGKILL',- })- return { stdout }-}--/** What a failed `opencode api` call said: the body is on stdout, the HTTP status on stderr. */-function apiFailure(err: unknown): { missing: boolean; text: string } {- const error = err as NodeJS.ErrnoException & { stdout?: string; stderr?: string }- if (error?.code === 'ENOENT') return { missing: true, text: String(error.message ?? err) }- const text = [error?.stdout, error?.stderr].map((part) => String(part ?? '').trim()).filter(Boolean).join(' · ')- return { missing: false, text: text || String(error?.message ?? err) }-}--/**- * Put `sessionId` on `model` through OpenCode v2's own API — see "v2" in the header.- *- * Talks to the background service (`opencode api` with no `--standalone`), which owns the store.- * Proved on 2.0.18 that a session last opened by a `--standalone` pane is switched just the same,- * and that the next pane reads it from the store whichever server it runs on. Never touches the DB.- *- * Measured on 2.0.18 that the service stores any id (`opencode/does-not-exist` reads back as set),- * so with `checkCatalog` the model is looked for in `model.list` first — for a model of opencode's- * own; a grid's provider is declared in its pane's own config, which the service never reads. A- * switch that did not land is tried once more, after `retryDelayMs`; one that cannot (no such- * session, no opencode, an unknown model) is not.- */-export async function switchOpencodeSessionModel(- sessionId: string,- model: OpencodeSessionModel,- options: { cwd?: string; run?: OpencodeApiRun; checkCatalog?: boolean; retryDelayMs?: number } = {},-): Promise<SetOpencodeSessionModelResult> {- if (!ID_RE.test(sessionId)) {- return { ok: false, code: 'OPENCODE_SESSION_NOT_FOUND', detail: `not an opencode session id: ${sessionId}` }- }- const run = options.run ?? runOpencode- if (options.checkCatalog) {- const known = await listsModel(run, model, options.cwd)- if (known === false) {- return { ok: false, code: 'OPENCODE_MODEL_UNKNOWN', detail: `opencode has no ${model.providerID}/${model.modelID} — \`opencode models\` lists the ones it has` }- }- }- let result = await switchOnce(run, sessionId, model, options.cwd)- if (!result.ok && result.code === 'OPENCODE_MODEL_SWITCH_FAILED') {- console.warn(`[opencode] switch to ${model.providerID}/${model.modelID} did not land (${result.detail}) · trying once more`)- await new Promise((resolve) => setTimeout(resolve, options.retryDelayMs ?? 1_000))- result = await switchOnce(run, sessionId, model, options.cwd)- }- return result-}--/**- * A v2 model id and the effort it names: `model#high` is opencode's own way (`opencode run -m- * provider/model#variant`). v1 never splits it — its `-m` and its rewrite take the id as written.- */-function splitVariant(modelID: string): { id: string; variant?: string } {- const at = modelID.lastIndexOf('#')- return at > 0 && at < modelID.length - 1 ? { id: modelID.slice(0, at), variant: modelID.slice(at + 1) } : { id: modelID }-}--/** Whether the service's `model.list` has [model]; null when the list could not be read. */-async function listsModel(run: OpencodeApiRun, model: OpencodeSessionModel, cwd?: string): Promise<boolean | null> {- try {- const { stdout } = await run(['api', 'model.list'], { cwd })- const parsed = JSON.parse(stdout) as { data?: unknown } | unknown[]- const rows = (Array.isArray(parsed) ? parsed : (parsed as { data?: unknown }).data) as Array<{ id?: unknown; modelID?: unknown; providerID?: unknown }> | undefined- if (!Array.isArray(rows)) return null- const { id } = splitVariant(model.modelID)- return rows.some((m) => m.providerID === model.providerID && (m.id === id || m.modelID === id))- } catch {- return null- }-}--/** One switch through the service, read back. */-async function switchOnce(run: OpencodeApiRun, sessionId: string, model: OpencodeSessionModel, cwd?: string): Promise<SetOpencodeSessionModelResult> {- const options = { cwd }- const param = `sessionID=${sessionId}`- const { id, variant } = splitVariant(model.modelID)- const body = JSON.stringify({ model: { id, providerID: model.providerID, ...(variant ? { variant } : {}) } })- try {- await run(['api', 'session.switchModel', '--param', param, '-d', body], { cwd: options.cwd })- } catch (err) {- const failure = apiFailure(err)- if (failure.missing) return { ok: false, code: 'OPENCODE_MISSING', detail: `opencode not found: ${failure.text}` }- const code = /SessionNotFoundError|HTTP 404/.test(failure.text) ? 'OPENCODE_SESSION_NOT_FOUND' : 'OPENCODE_MODEL_SWITCH_FAILED'- return { ok: false, code, detail: failure.text }- }- // Read back: the service answers 204 for any model, known or not, so only the session itself can- // say the switch landed.- let stdout: string- try {- ({ stdout } = await run(['api', 'session.get', '--param', param], { cwd: options.cwd }))- } catch (err) {- return { ok: false, code: 'OPENCODE_MODEL_SWITCH_FAILED', detail: `could not read the session back · ${apiFailure(err).text}` }- }- let now: { id?: unknown; providerID?: unknown; variant?: unknown } | undefined- try {- now = (JSON.parse(stdout) as { data?: { model?: { id?: unknown; providerID?: unknown; variant?: unknown } } }).data?.model- } catch {- now = undefined- }- // (A variant asked for must read back too; none asked for, the service's own is fine.)- if (now?.id !== id || now?.providerID !== model.providerID || (variant && now?.variant !== variant)) {- const seen = now ? `${String(now.providerID)}/${String(now.id)}${now.variant ? `#${String(now.variant)}` : ''}` : stdout.trim().slice(0, 200)- return { ok: false, code: 'OPENCODE_MODEL_SWITCH_FAILED', detail: `session ${sessionId} is still on ${seen}` }- }- console.log(`[opencode] session model switched to ${model.providerID}/${model.modelID} through the service`)- return { ok: true }-}--/**- * Put a resumed session on `model` the way the installed OpenCode needs, BEFORE its pane is- * relaunched. A failure here is the caller's refusal: the live process has not been touched yet.- *- * * v1 (or a version not read): the SQL rewrite above. A session with no user message yet is fine- * there — the relaunch's `-m` applies to it — so that one answer is success.- * * v2: the API. Every failure is a failure, `SESSION_NOT_FOUND` included: the relaunch carries no- * `-m`, so a switch that did not land is a pane on the old model with the move reported done.- */-export async function applyOpencodeSessionModel(- input: { opencodeMajor: number | null | undefined; dbPath: string; sessionId: string; model: OpencodeSessionModel; cwd?: string; checkCatalog?: boolean },- deps: { run?: OpencodeApiRun; retryDelayMs?: number } = {},-): Promise<SetOpencodeSessionModelResult> {- if (isOpencodeV2(input.opencodeMajor)) {- return switchOpencodeSessionModel(input.sessionId, input.model, { cwd: input.cwd, run: deps.run, checkCatalog: input.checkCatalog, retryDelayMs: deps.retryDelayMs })- }- const written = await setOpencodeSessionModel(input.dbPath, input.sessionId, input.model)- return !written.ok && written.code === 'OPENCODE_SESSION_NOT_FOUND' ? { ok: true } : written-}+export { opencodeModelFromArgv, parseOpencodeModelId, setOpencodeSessionModel, switchOpencodeSessionModel, applyOpencodeSessionModel } from '../launchControl.js'+export type { OpencodeSessionModel, SetOpencodeSessionModelResult, OpencodeApiRun } from '../launchControl.js'diff --git a/cli/src/engines/opencode/version.ts b/cli/src/engines/opencode/version.tsindex 87af57f01..4be5208db 100644--- a/cli/src/engines/opencode/version.ts+++ b/cli/src/engines/opencode/version.ts@@ -14,62 +14,5 @@* v1 fallback; the hook installer waits for a confirmed v1 before writing the incompatible v1 plugin.*/-import { execFileSync } from 'node:child_process'-import { statSync } from 'node:fs'-import { opencodeBin } from '../../lib/engineBin.js'-import { resolveBinaryOnPath } from '../../lib/binaryOnPath.js'--/** The major in what `opencode --version` prints: `opencode v2.0.18` on v2, a bare `1.18.31` on v1. */-export function parseOpencodeMajor(output: string): number | null {- const match = /(\d+)\.\d+\.\d+/.exec(output)- return match ? Number(match[1]) : null-}--export { isOpencodeV2 } from './contract.js'--/** How the version is read. A seam so the cache can be specified without a binary. */-export interface OpencodeVersionProbe {- /** Something that changes when the installed file does, or null when it cannot be found. */- identity: () => string | null- /** What `--version` prints. Throws when the binary will not answer. */- read: () => string-}--const realProbe: OpencodeVersionProbe = {- identity: () => {- const bin = opencodeBin()- const path = bin.includes('/') ? bin : resolveBinaryOnPath(bin)- if (!path) return null- try {- const stat = statSync(path)- return `${path}:${stat.size}:${stat.mtimeMs}`- } catch {- return null- }- },- // Bounded: this runs on the daemon's thread, once per installed file. 2.0.18 answers in ~50ms.- read: () => execFileSync(opencodeBin(), ['--version'], {- encoding: 'utf8', timeout: 5_000, killSignal: 'SIGKILL', stdio: ['ignore', 'pipe', 'ignore'],- }),-}--const cache = new Map<string, number | null>()--/** The installed OpenCode's major version, or null when it cannot be read. Never throws. */-export function opencodeMajorVersion(- probe: OpencodeVersionProbe = realProbe,- memo: Map<string, number | null> = cache,-): number | null {- const identity = probe.identity()- // No file to key on: nothing is installed where this daemon can see it, so nothing is cached — the- // pane may install it, and the next launch should find out what it got.- if (identity !== null && memo.has(identity)) return memo.get(identity) ?? null- let major: number | null- try {- major = parseOpencodeMajor(probe.read())- } catch {- major = null- }- if (identity !== null) memo.set(identity, major)- return major-}+export { isOpencodeV2, opencodeMajorVersion, parseOpencodeMajor } from '../launchControl.js'+export type { OpencodeVersionProbe } from '../launchControl.js'diff --git a/cli/src/engines/opencodeLaunch.golden.spec.ts b/cli/src/engines/opencodeLaunch.golden.spec.tsnew file mode 100644index 000000000..4d3976540--- /dev/null+++ b/cli/src/engines/opencodeLaunch.golden.spec.ts@@ -0,0 +1,170 @@+/** Former-code launch answers and native commands, before OpenCode control becomes eager. */+import { appendFileSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSync, existsSync } from 'node:fs'+import { tmpdir } from 'node:os'+import { dirname, join } from 'node:path'+import { fileURLToPath } from 'node:url'+import { afterAll, beforeAll, expect, it, vi } from 'vitest'+import type { RegisteredSession } from '../lib/registry.js'+import type { AgentEngine } from './types.js'++const captured = vi.hoisted(() => ({ panes: [] as Record<string, any>[] }))+vi.mock('../lib/createAgentPane.js', () => ({ createAndRegisterPane: async (input: Record<string, any>) => {+ captured.panes.push(input)+ return { ok: false, error: 'RECORDED', detail: 'No pane is opened by this golden.' }+} }))+vi.mock('../lib/tmuxVersion.js', async real => ({ ...await real<object>(), tmuxSupportsSessionEnv: async () => true }))+vi.mock('../lib/tmux.js', async real => ({ ...await real<object>(), clearPaneRemainOnExit: async () => {}, processArgs: async () => '' }))+vi.mock('../lib/gatewayRuntime.js', async real => ({ ...await real<object>(), probeGatewayRuntime: async () => ({ kind: 'none' }) }))+vi.mock('../lib/binaryOnPath.js', async real => {+ const actual = await real<typeof import('../lib/binaryOnPath.js')>()+ return { ...actual, resolveBinaryOnPath: (name: string) => name === 'tmux' ? '/fixture/bin/tmux' : actual.resolveBinaryOnPath(name) }+})++const GOLDEN = fileURLToPath(new URL('./__fixtures__/opencode-launch.golden.json', import.meta.url))+const RECORD = process.env.RECORD_OPENCODE_LAUNCH_GOLDEN === '1'+let root = '', work = '', calls = ''+const platform = Object.getOwnPropertyDescriptor(process, 'platform')!+const actual: Record<string, unknown> = {}++function normalize(value: unknown, label?: string): unknown {+ let text = JSON.stringify(value ?? null).split(root).join('<root>')+ .split(process.cwd()).join('<repo>')+ .split(process.execPath).join('<node>').split(dirname(process.execPath)).join('<node-dir>')+ .replace(/\/launch\/[0-9a-f-]{36}\.sh/g, '/launch/<script>.sh')+ if (label) text = text.split(label).join('<pane-label>')+ return JSON.parse(text)+}+function paneAnswer(): unknown {+ return captured.panes.map(pane => {+ const script = (pane.argv as string[]).map(arg => /^\. '(.+\/launch\/[0-9a-f-]{36}\.sh)'$/.exec(arg)?.[1]).find(Boolean)+ return normalize({ argv: pane.argv, env: pane.env, engine: pane.engine, agent: pane.agent, forkedFrom: pane.forkedFrom,+ permissionMode: pane.permissionMode, grid: pane.grid, gridLaunchRecord: pane.gridLaunchRecord,+ script: script ? readFileSync(script, 'utf8') : null }, pane.sessionLabel)+ })+}+function nativeCalls(): unknown[] {+ return existsSync(calls) ? readFileSync(calls, 'utf8').trim().split('\n').filter(Boolean).map(line => JSON.parse(line)) : []+}+function resetCase(): void { captured.panes.length = 0; writeFileSync(calls, '') }+async function attempt(run: () => Promise<unknown>): Promise<unknown> {+ try { return await run() } catch (error) { return { threw: error instanceof Error ? { name: error.name, message: error.message } : String(error) } }+}++beforeAll(() => {+ root = realpathSync(mkdtempSync(join(tmpdir(), 'opencode-launch-golden-')))+ work = join(root, 'work'); calls = join(root, 'calls.jsonl')+ Object.defineProperty(process, 'platform', { ...platform, value: 'linux' })+ vi.useFakeTimers({ toFake: ['Date'] }); vi.setSystemTime(new Date('2026-10-09T00:00:00Z'))+ for (const name of ['HOME', 'ADAPTER_DATA_DIR', 'ADAPTER_RUNTIME_DIR', 'CODEX_HOME', 'CLAUDE_CONFIG_DIR', 'OPENCODE_DATA_DIR', 'OPENCODE_CONFIG_DIR']) {+ const path = join(root, name.toLowerCase()); mkdirSync(path, { recursive: true }); vi.stubEnv(name, path)+ }+ vi.stubEnv('TZ', 'UTC'); vi.stubEnv('SHELL', '/bin/sh'); vi.stubEnv('ZDOTDIR', join(root, 'zdotdir'))+ vi.stubEnv('CLAUDE_PATH', '/fixture/bin/claude'); vi.stubEnv('CODEX_PATH', '/fixture/bin/codex')+ vi.stubEnv('HARNESS_OS', ''); vi.stubEnv('HARNESS_GRID_BIN', '')+ mkdirSync(work); mkdirSync(join(root, 'bin')); mkdirSync(join(root, 'zdotdir'))+ vi.stubEnv('PATH', join(root, 'bin'))+ vi.stubEnv('OPENCODE_PATH', join(root, 'bin', 'v1'))+ // These binaries only report facts or record requests. They never launch an engine or open a real store.+ for (const [name, version] of [['v1', '1.18.31'], ['v2', 'opencode v2.0.18'], ['unknown', 'not-a-version']]) {+ writeFileSync(join(root, 'bin', name), `#!${process.execPath}+const fs = require('node:fs');+const args = process.argv.slice(2);+fs.appendFileSync(${JSON.stringify(calls)}, JSON.stringify({binary:'opencode',args,cwd:process.cwd()})+'\\n');+if(args[0]==='--version') console.log(${JSON.stringify(version)});+else if(args[1]==='model.list') console.log(JSON.stringify({data:[{providerID:'fixture',id:'model'}]}));+else if(args[1]==='session.switchModel') { fs.writeFileSync(${JSON.stringify(join(root, 'model.json'))}, args[args.indexOf('-d')+1]); console.log('{}'); }+else if(args[1]==='session.get') console.log(JSON.stringify({data:JSON.parse(fs.readFileSync(${JSON.stringify(join(root, 'model.json'))},'utf8'))}));+else { console.error('Unexpected fixture command'); process.exitCode=1; }+`, { mode: 0o755 })+ }+ writeFileSync(join(root, 'bin', 'sqlite3'), `#!${process.execPath}+require('node:fs').appendFileSync(${JSON.stringify(calls)}, JSON.stringify({binary:'sqlite3',args:process.argv.slice(2)})+'\\n');+console.log('5000\\n1\\n1');+`, { mode: 0o755 })+ vi.resetModules()+})+afterAll(() => {+ vi.useRealTimers(); vi.unstubAllEnvs(); Object.defineProperty(process, 'platform', platform)+ if (root) rmSync(root, { recursive: true, force: true })+})++it('records create, fork, relaunch and actual retarget dispatch before the extraction', async () => {+ const { launchShapes } = await import('../testing/launchShapes.js')+ const { opencodeMajorVersion } = await import('./opencode/version.js')+ const { createAgentRetargeter } = await import('../core/agents/retarget.js')+ const { buildEngineLaunchArgv } = await import('../lib/engineLaunch.js')+ const { env } = await import('../config/env.js')+ const world = { dataDir: join(root, 'adapter_data_dir'), machine: () => ({ hermesSystemManaged: false, opencodeMajor: opencodeMajorVersion() }),+ tmuxSupportsSessionEnv: async () => true, readCodexConfig: () => null, setGridLaunch: () => {} }+ const shapes = launchShapes(world)+ const row = (engine: AgentEngine, named = false): RegisteredSession => ({ agentId: 'fixture-agent', sessionId: 'ses_fixture', engine, cwd: work,+ registeredAt: Date.now(), active: true, runtimes: [{ backend: 'tmux', paneId: '%4' }], agent: named ? 'reviewer' : null,+ processIdentity: { pid: 4242, executable: engine, startMarker: 'fixture' }, grid: null, gridLaunch: null, codexHome: null,+ dsh: null, dshRuntime: null, scmLaunch: null, permissionMode: null, bypassPermission: false, subscriptionModel: 'fixture/model#high',+ }) as unknown as RegisteredSession+ const createRest = { tmuxBackend: {}, registry: {}, hooksDisabled: true, hookPort: 4242,+ installOpencodePlugin: async () => true, terminalHintMachineName: () => 'fixture-machine', blocksFolder: () => false,+ gridSetup: () => null, privateGridName: async () => null, watchNewPane: async () => {}, announceSession: () => {}, attachDsh: () => {},+ }+ for (const version of ['v1', 'v2', 'unknown', 'missing']) {+ vi.stubEnv('OPENCODE_PATH', join(root, 'bin', version))+ env.OPENCODE_PATH = join(root, 'bin', version)+ for (const named of [false, true]) {+ resetCase()+ const result = await attempt(() => shapes.create(createRest as never)({ engine: 'opencode', cwd: work, bypassPermission: false,+ permissionMode: null, grid: null, codexHome: null, dsh: null, prompt: 'fixture prompt', name: null,+ agent: named ? 'reviewer' : null, resumeSessionId: null, takeOver: null } as never))+ actual[`${version} create named=${named}`] = normalize({ result, panes: paneAnswer(), native: nativeCalls() })++ const source = row('opencode', named)+ resetCase()+ const fork = await shapes.fork({ tmuxBackend: {}, registry: { byAgent: () => source },+ mirror: { isBusy: () => false, recentAsks: () => ['fixture ask'], recent: () => [], lastFullText: () => 'fixture answer' },+ pendingForkInherit: new Map(), watchNewPane: async () => {}, announceSession: () => {}, attachDsh: () => {},+ } as never)({ agentId: source.agentId, name: null, prompt: 'try another approach' })+ actual[`${version} fork named=${named}`] = normalize({ result: fork, panes: paneAnswer(), native: nativeCalls() })++ resetCase()+ actual[`${version} relaunch named=${named}`] = normalize({ result: await shapes.relaunch(source), native: nativeCalls() })+ }++ resetCase()+ const source = row('opencode', true), events: unknown[] = []+ const event = (entry: unknown[]) => { events.push(entry); appendFileSync(calls, JSON.stringify({ control: entry }) + '\n') }+ const retarget = createAgentRetargeter({+ purgeBusy: () => false, tmuxBackend: { clearEnv: async (_pane: unknown, names: string[]) => { event(['clearEnv', names]); return { state: 'succeeded' } } },+ registry: { resolve: () => source, byAgent: () => source, updateProcessIdentity: (...args: unknown[]) => event(['process', ...args]),+ setGridLaunch: (...args: unknown[]) => event(['grid', ...args]), setSubscriptionModel: (...args: unknown[]) => event(['subscription', ...args]),+ setActive: (...args: unknown[]) => event(['active', ...args]) },+ runtimeProfiles: { selectedModel: () => null },+ launchOverridesDeps: { machine: world.machine, tmuxSupportsSessionEnv: world.tmuxSupportsSessionEnv },+ captureTerminal: async () => 'fixture idle', readScreen: async () => ({ pane: { idle: true } }),+ acquireTerminalControl: () => () => event(['release']), relaunchOverrides: shapes.relaunch,+ downgradedPermission: async () => ({ bypassPermission: false, permissionMode: null }),+ agentReconciler: { holdRoute: () => event(['holdRoute']), releaseRoute: () => event(['releaseRoute']) },+ restartJobs: { busy: () => false, cancel: () => event(['cancel']) },+ paneSwapDeps: (s: RegisteredSession, _pane: unknown, overrides: { extraArgs: string[]; env: unknown; clearEnv: string[] }) => ({+ holdOpen: async () => { event(['holdOpen']); return { ok: true } },+ terminate: async () => { event(['terminate']); return 'gone' },+ buildArgv: (options: { bypassPermission: boolean; resumeSessionId?: string }) => buildEngineLaunchArgv(s.engine, { ...options, cwd: s.cwd!, extraArgs: overrides.extraArgs }),+ respawn: async (argv: string[]) => {+ const script = argv.map(arg => /^\. '(.+\/launch\/[0-9a-f-]{36}\.sh)'$/.exec(arg)?.[1]).find(Boolean)+ event(['respawn', argv, overrides, script ? readFileSync(script, 'utf8') : null]); return { ok: true }+ },+ waitForProcess: async () => ({ pid: 4343, executable: 'opencode', startMarker: 'replacement' }), log: () => {},+ }),+ liveBypassPermission: async () => false, announceSession: () => event(['announce']), refreshGridAssignment: () => event(['assignment']),+ opencodeDb: join(root, 'fixture.db'),+ } as never)+ actual[`${version} retarget own login`] = normalize({ result: await retarget({ agentId: source.agentId, grid: null }), events, native: nativeCalls() })+ }+ if (RECORD) writeFileSync(GOLDEN, JSON.stringify(actual, null, 2) + '\n')+ else expect(actual).toEqual(JSON.parse(readFileSync(GOLDEN, 'utf8')))+}, 120_000)++it('contains no host paths or executable location', () => {+ const text = readFileSync(GOLDEN, 'utf8')+ expect(text).not.toContain(root)+ expect(text).not.toContain(process.execPath)+ expect(text).not.toMatch(/\/Users\/|\/home\/runner|opencode-launch-golden-/)+})diff --git a/cli/src/lib/discoveryScripts.spec.ts b/cli/src/lib/discoveryScripts.spec.tsindex b91dc5059..37bd9403d 100644--- a/cli/src/lib/discoveryScripts.spec.ts+++ b/cli/src/lib/discoveryScripts.spec.ts@@ -7,7 +7,7 @@ import { pathToFileURL } from 'url'/** Pi and OpenCode register through generated source, so pin its process-owned wire contract directly. */const dirs: string[] = []const version = vi.hoisted(() => ({ major: 1 as number | null }))-vi.mock('../engines/opencode/version.js', () => ({ opencodeMajorVersion: () => version.major }))+vi.mock('../engines/launchControl.js', () => ({ opencodeMajorVersion: () => version.major }))beforeEach(() => {version.major = 1vi.useFakeTimers({ toFake: ['setInterval', 'clearInterval', 'setTimeout', 'clearTimeout'] })diff --git a/cli/src/lib/hooks.ts b/cli/src/lib/hooks.tsindex 7760e68dd..59a7d20dd 100644--- a/cli/src/lib/hooks.ts+++ b/cli/src/lib/hooks.ts@@ -6,7 +6,7 @@ import { cursorConfigDir, cursorDataDir } from '../engines/cursor/home.js'import { env } from '../config/env.js'import { VERSION } from '../version.js'import { hermesConfigHomes } from '../engines/hermes/home.js'-import { opencodeMajorVersion } from '../engines/opencode/version.js'+import { opencodeMajorVersion } from '../engines/launchControl.js'import { command, isOurs, writeJsonAtomic, type HookBlock, type Settings } from '../engines/kit/notifyHooks.js'const GROK_HOOKS_PATH = join(env.GROK_HOME, 'hooks', 'harness.json')diff --git a/cli/src/lib/launchOverrides.spec.ts b/cli/src/lib/launchOverrides.spec.tsindex 9b3506abc..d4617cbe2 100644--- a/cli/src/lib/launchOverrides.spec.ts+++ b/cli/src/lib/launchOverrides.spec.ts@@ -109,17 +109,15 @@ describe('buildLaunchOverrides — a relaunch comes back where the agent was', (expect(calls).toEqual([])})- it('refuses an OpenCode launch whose code could not be loaded, and asks the machine for the engine it launches', async () => {- vi.mocked(loadEngine).mockResolvedValueOnce(null)- expect(await buildLaunchOverrides(deps().d, 'opencode', {}, 'agent-1')).toEqual({ ok: false, error: 'ENGINE_UNAVAILABLE', detail: 'OpenCode\'s code could not be loaded' })- vi.mocked(loadEngine).mockClear()+ it('builds OpenCode overrides without optional code and uses the requested engine facts', async () => {+ vi.mocked(loadEngine).mockImplementation(() => new Promise(() => {}))+ expect(await buildLaunchOverrides(deps().d, 'opencode', {}, 'agent-1')).toMatchObject({ ok: true })const machine = vi.fn((_engine: string) => ({ hermesSystemManaged: false }))await buildLaunchOverrides(deps({ machine }).d, 'claude', { gridLaunch: GRID, subscriptionModel: 'opus' }, 'agent-1')- expect(loadEngine).not.toHaveBeenCalled()expect(machine.mock.calls.every(([engine]) => engine === 'claude')).toBe(true)await buildLaunchOverrides(deps({ machine }).d, 'opencode', { agent: 'reviewer' }, 'agent-1')- expect(loadEngine).toHaveBeenCalledWith('opencode')expect(machine).toHaveBeenLastCalledWith('opencode')+ expect(loadEngine).not.toHaveBeenCalled()})it('never lets the key into argv', async () => {diff --git a/cli/src/lib/launchOverrides.ts b/cli/src/lib/launchOverrides.tsindex 00d678f47..1050eb9c0 100644--- a/cli/src/lib/launchOverrides.ts+++ b/cli/src/lib/launchOverrides.ts@@ -13,7 +13,6 @@*/import { join } from 'node:path'-import { loadEngine } from '../engines/inProcess.js'import type { AgentEngine } from '../engines/types.js'import { subscriptionModelLaunch } from './subscriptionModel.js'import { ownLoginProviderArgs } from '../engines/launches.js'@@ -142,21 +141,12 @@ export async function validateLaunchOverrides(engine: AgentEngine,source: LaunchSource,): Promise<{ ok: true } | { ok: false; error: string; detail: string; unavailable?: string }> {- const unloaded = await opencodeUnloaded(engine)- if (unloaded) return unloadedif (!source.gridLaunch) return { ok: true }const built = await deps.gridLaunch({ engine, override: source.gridLaunch, machine: deps.machine(engine) })if (!built.ok) return { ok: false, error: built.error, detail: built.detail, ...(built.unavailable ? { unavailable: built.unavailable } : {}) }return tmuxRefusal(deps, engine, source.gridLaunch)}-/** Which OpenCode is installed decides its argv (`machine`), read by OpenCode's own probe: loaded for an OpenCode- * launch alone (engines/inProcess.ts), and the launch refused without it rather than given a guess. */-async function opencodeUnloaded(engine: AgentEngine): Promise<{ ok: false; error: string; detail: string } | null> {- if (engine !== 'opencode' || await loadEngine('opencode')) return null- return { ok: false, error: 'ENGINE_UNAVAILABLE', detail: 'OpenCode\'s code could not be loaded' }-}-/** Only a launch that SETS variables needs the tmux that can set them. */async function tmuxRefusal(deps: Pick<LaunchOverridesDeps, 'tmuxSupportsSessionEnv'>, engine: AgentEngine, override: GridLaunchOverride,@@ -225,9 +215,6 @@ async function buildBaseLaunchOverrides(source: LaunchSource,configKey: string,): Promise<LaunchOverridesResult> {- // Checked first, as every relaunch was before its grid launch moved to models (validateLaunchOverrides).- const unloaded = await opencodeUnloaded(engine)- if (unloaded) return unloaded// Coming back to the engine's own login undoes TWO things the grid launch set, and they are// undone separately because the engine remembers them differently.//diff --git a/docs/research/2026-10-09-opencode-control.md b/docs/research/2026-10-09-opencode-control.mdnew file mode 100644index 000000000..f28d2f72c--- /dev/null+++ b/docs/research/2026-10-09-opencode-control.md@@ -0,0 +1,44 @@+# OpenCode launch control and the remaining safety boundaries++The daemon separation audit found launch decisions still behind `loadEngine('opencode')`: create, fork, relaunch, retarget, external preflight, request validation and `lib/launchOverrides.ts`. The composition root also asks the loaded engine for its version. Native launch control must be eager; history and interpretation remain optional.++The next extraction records the former code first. `opencodeLaunch.golden.spec.ts` exercises the actual create, fork, relaunch and retarget paths with v1, v2, unknown and missing binaries, named agents and remembered models. It records pane argv and scripts, environments, native SQLite/API commands, and their order relative to process replacement and publication. Linux, UTC and time are pinned; homes and binaries are disposable fixtures, Node and tmux paths are placeholders, and no real pane or process is changed. The existing launch-shapes and launch-argv goldens cover grid/saved-API construction and the other engines. Hook installation and failure isolation need their own acceptance before the control work is complete.++Independent read-only review identified the following existing problems. Extracting their functions does not fix them, and a passing compatibility golden is not evidence that these failures are safe.++## Native preparation++- The version probe synchronously blocks core for up to five seconds and caches unknown results by executable identity. A transient failure can last until the binary changes. A launch also asks the version independently for flags, named agents and plugins. Use an asynchronous eager probe and one executable/version snapshot per launch; imports themselves must never probe or write.+- Plugin installation logs and swallows write/removal failures while preflight reports success. An incompatible v1 plugin can survive a v2 preparation. Verify the result, preserve unrelated plugin files, and hold the launch with the reason when preparation is unavailable.+- Create and external admission prepare OpenCode hooks, but fork, restart, retarget and owned restore do not. All dispatch paths need the same preparation and version snapshot, including upgrades after daemon startup.+- Startup awaits the shared optional hooks module with no deadline. Readiness must not depend on that module. Required native hook installation belongs in eager declarations/mechanics; optional interpretation can recover separately.++## Mutation ownership++- Retarget retains a mutable row over awaited preparation and native model writes. A pane control pin is not proof that the process and conversation still match. Copy the target identity and fence every mutation, retry, signal and publication against current ownership and cancellation.+- An unreadable v2 model catalogue currently allows a write. A failed readback can repeat `session.switchModel` after the first write may already have succeeded. Preserve an unconfirmed result and reconcile with reads; do not blindly replay an ambiguous mutation.+- Verify the v1 two-row transaction and rollback behavior, including missing rows and no-user-message sessions. A native model change followed by failed respawn must not be described as if nothing changed.++## Durable holds and staged preparation++Boot restore retains the service-unavailable marker, but create, fork, restart and retarget can discard it. Creation receipts can persist an unavailable service as a failed request. Instruction writes and a live config directory can also precede a later models/Store refusal. This requires a separate shared launch follow-up: retain the intent and reason, stage writes until dependencies are ready, and resume only under current authority. A live process left running and an inert held launch need distinct outcomes.++The final audit must include missing/stalled OpenCode and hooks chunks in the real bundle, readiness and unrelated Stop while preparation is pending, unreadable/unwritable plugin paths, catalogue outage, lost replies, mismatched readback, and Stop/rebind at each awaited boundary. Deliberate mutations must break both caller wiring and the declared facts and fail assertions.++## Eager extraction acceptance++Former-code commit `9393bd13951f391bc8f31c9abc56a18e40ee3efe` records 28 launch observations before any production move. Its JSON fixture remains byte-for-byte unchanged. Native version and model control now live in eager `engines/launchControl.ts`, generic `engines/kit` mechanics, and OpenCode's declared version/SQL/API facts. Compatibility re-exports retain existing imports. Create, fork, relaunch, retarget, external admission, request validation and the composition root no longer load or consult the optional OpenCode module for those operations. The import test verifies that importing native control does not resolve a binary or load interpretation.++Validation on Node 22.23.2, macOS, UTC, private homes/daemon/tmux:++- TypeScript and architecture pass. Core/services: 1,896 tests, every per-file coverage metric 100%; harnessd: 265 passed and one intentional skip, every per-file metric 100%.+- 396 affected tests pass, including the unchanged OpenCode, launch-shapes and DSH launch-shapes goldens and existing native version/SQLite/API specs. Fault assertions cover an unavailable or stalled reader; the architecture check prevents reintroducing a lazy launch import.+- Four real-bundle cases remove or stall the OpenCode chunk on v1 and v2. Create, fork, restart, retarget, Stop/resume and continued sibling operation pass. The v1 cases replace the executable with v2 while the daemon is running: relaunch drops the saved v1 named-agent flag even though interpretation never loads. The unwritten native-store fixture holds Close with its checkpoint reason and keeps the agent active; this is not evidence of v2 checkpoint support.+- Thirteen mutations fail assertions: version threshold/probe/parser, SQL field/transaction, API provider field/variant, actual create/fork version wiring, actual retarget model dispatch, lazy relaunch/retarget dependencies, and the composition root consulting optional code. A wrong mutation source marker was corrected before the remaining cases were exercised; setup failures were not counted.+- Initial e2e fixture failures were corrected: the fake help now declares its supported permission flag, own-login retarget uses the wire's `clearGrid`, and a fake conversation with no stored rows is expected to hold Close. No production guard was weakened to make them pass.++[Runtime measurements](2026-10-09-opencode-launch-cost.json) compare frozen main and candidate bundles in baseline/candidate/candidate/baseline order with two OpenCode launches in each cold daemon. Core ready latency was 1,109–1,140 ms on main and 1,213–1,215 ms after extraction; core CPU at ready 300 versus 320 ms; RSS 76.8–77.0 versus 77.8–78.8 MiB. Cold request latency was 541–952 versus 522–540 ms and warm requests 93–94 versus 89–92 ms. Two samples and the 10 ms `ps` CPU resolution support only a reference comparison, not a speed claim or a new threshold. Reproduce with `OPENCODE_COST_ROOT` naming a folder containing `baseline/cli.js` and `candidate/cli.js`, and run `e2e/opencodeLaunchCost.e2e.ts` alone under the same Node/tmux, UTC and private tmux environment.++The native-preparation, mutation-ownership and durable-hold work above remains separate and required. Also audit Close's OpenCode checkpoint: it currently selects the v1 `session`/`message`/`part` tables, while v2 stores new conversations separately. An unavailable or unsupported checkpoint must keep holding the live agent with its reason.++All 44 broader core, fork, machine and race end-to-end cases also pass. Independent read-only review found no blocking regression in the extraction; its requested architecture assertion now detects the former two-argument `engineNow` call and is exercised by a composition mutation. Main advanced only in OS and website files during validation; those changes were integrated without changing CLI inputs.diff --git a/docs/research/2026-10-09-opencode-launch-cost.json b/docs/research/2026-10-09-opencode-launch-cost.jsonnew file mode 100644index 000000000..1ac0be0b9--- /dev/null+++ b/docs/research/2026-10-09-opencode-launch-cost.json@@ -0,0 +1,102 @@+{+ "node": "v22.23.2",+ "platform": "darwin",+ "tmux": "tmux 3.5a",+ "samples": [+ {+ "bundle": "baseline",+ "readyMs": 1140.490702,+ "atReady": {+ "cpuMs": 300,+ "rssMiB": 76.83203125+ },+ "launches": [+ {+ "phase": "cold",+ "requestMs": 951.6568220000001,+ "coreCpuMs": 30,+ "rssMiB": 78.53125+ },+ {+ "phase": "warm",+ "requestMs": 92.50876100000005,+ "coreCpuMs": 20,+ "rssMiB": 78.72265625+ }+ ]+ },+ {+ "bundle": "candidate",+ "readyMs": 1214.9187920000004,+ "atReady": {+ "cpuMs": 320,+ "rssMiB": 77.84765625+ },+ "launches": [+ {+ "phase": "cold",+ "requestMs": 540.1093879999999,+ "coreCpuMs": 40,+ "rssMiB": 79.46484375+ },+ {+ "phase": "warm",+ "requestMs": 92.12919299999976,+ "coreCpuMs": 10,+ "rssMiB": 79.6640625+ }+ ]+ },+ {+ "bundle": "candidate",+ "readyMs": 1212.7409969999999,+ "atReady": {+ "cpuMs": 320,+ "rssMiB": 78.828125+ },+ "launches": [+ {+ "phase": "cold",+ "requestMs": 521.7426919999998,+ "coreCpuMs": 30,+ "rssMiB": 80.4609375+ },+ {+ "phase": "warm",+ "requestMs": 88.81767500000024,+ "coreCpuMs": 10,+ "rssMiB": 80.71875+ }+ ]+ },+ {+ "bundle": "baseline",+ "readyMs": 1109.4595839999993,+ "atReady": {+ "cpuMs": 300,+ "rssMiB": 76.9765625+ },+ "launches": [+ {+ "phase": "cold",+ "requestMs": 541.2657639999998,+ "coreCpuMs": 40,+ "rssMiB": 78.640625+ },+ {+ "phase": "warm",+ "requestMs": 94.00080700000035,+ "coreCpuMs": 10,+ "rssMiB": 78.84375+ }+ ]+ }+ ],+ "baseline": "2477d7e1d8f70e3fdee4d2b24d4b043080016587",+ "candidate": "OpenCode eager extraction after former-code golden 9393bd13951f391bc8f31c9abc56a18e40ee3efe",+ "bundleSha256": {+ "baseline": "e83840776b83900cd5851eca771e285507456ed3524e97ccd0a0bf8db0129c0c",+ "candidate": "75d1c875df5a17dede8f99eef620cafb83eb2f6bfc1033596c5b5ebd84f1d63c"+ },+ "scope": "Four cold private daemons, baseline/candidate/candidate/baseline; two launches per daemon. Core PID only; ps CPU has 10ms resolution. Two samples per variant are reference measurements, not a performance gate."+}