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
Make engine-home adoption durable and retryable (#1132)
Deec7d460b1d801
diff --git a/cli/e2e/enginehomes.e2e.ts b/cli/e2e/enginehomes.e2e.tsindex 6c3f11c23..457bd27b6 100644--- a/cli/e2e/enginehomes.e2e.ts+++ b/cli/e2e/enginehomes.e2e.ts@@ -6,13 +6,15 @@* engine takes them whatever the daemon's own environment says: the desktop app starts the daemon* without the profile. An agent must still bind, take turns and come back after a restart.*/+import { createHash } from 'node:crypto'+import { tmpdir } from 'node:os'import { execFileSync } from 'node:child_process'-import { existsSync, mkdirSync, readFileSync, readdirSync, renameSync, writeFileSync } from 'node:fs'+import { existsSync, mkdtempSync, rmSync, mkdirSync, readFileSync, readdirSync, renameSync, writeFileSync } from 'node:fs'import { join } from 'node:path'import { pathToFileURL } from 'node:url'import { afterEach, describe, expect, it, onTestFailed } from 'vitest'import { LocalClient, type Frame } from './harness/client.js'-import { CLI_ROOT, IsolatedDaemon, until } from './harness/daemon.js'+import { assertHooksContained, CLI_ROOT, IsolatedDaemon, until } from './harness/daemon.js'import { sharedCodex } from './harness/sharedCodex.js'type Engine = 'claude' | 'codex'@@ -50,10 +52,63 @@ const codexCommands = (sessionId: string): string[] =>execFileSync('ps', ['-A', '-o', 'command='], { encoding: 'utf8' }).split('\n').filter((line) => /^codex\s/.test(line.trim()) && line.includes(sessionId))+it.each(['legacy', 'journal', 'unconfirmed'] as const)('refuses an uncontained %s home before starting any daemon', source => {+ const root = mkdtempSync(join(tmpdir(), 'home-containment-'))+ try {+ const env = { HOME: root, CODEX_HOME: join(root, 'codex'), ZDOTDIR: root, ADAPTER_DATA_DIR: root, HOOK_INSTALL_ENGINES: 'codex' }+ const file = join(root, 'engine-homes.json'), homes = { claude: [], codex: ['/fixture-unowned-home'] }+ if (source === 'legacy') writeFileSync(file, JSON.stringify(homes), { mode: 0o600 })+ else {+ mkdirSync(file + '.adoptions', { mode: 0o700 }); mkdirSync(file + '.confirmations', { mode: 0o700 })+ const record = JSON.stringify({ version: 1, previous: null, legacyRequired: false, homes }) + '\n'+ writeFileSync(join(file + '.adoptions', '000.json'), record, { mode: 0o600 })+ if (source === 'journal') writeFileSync(file + '.adopted', createHash('sha256').update(record).digest('hex') + '\n', { mode: 0o600 })+ }+ expect(() => assertHooksContained(root, env)).toThrow(source === 'unconfirmed' ? 'unconfirmed adoption' : 'installs hooks only inside')+ } finally { rmSync(root, { recursive: true, force: true }) }+})+describe('the person\'s engines keeping their data elsewhere', () => {let daemon: IsolatedDaemon | undefinedafterEach(async () => { await daemon?.close(); daemon = undefined })+ it('keeps readiness and a terminal available while a moved-home write is held, then retries and restores it', async () => {+ const d = await IsolatedDaemon.create(); daemon = d+ onTestFailed(() => console.log(`---- daemon log\n${d.log().split('\n').slice(-150).join('\n')}`))+ const home = join(d.root, 'codex-durable'), fault = join(d.root, 'adoption-unavailable')+ mkdirSync(home, { mode: 0o700 })+ writeFileSync(fault, 'hold', { mode: 0o600 })+ d.env.HARNESS_HOME_ADOPTION_FAULT_FILE = fault+ d.env.NODE_OPTIONS = `--import=${pathToFileURL(join(CLI_ROOT, 'e2e/harness/homeAdoptionFault.mjs')).href}`+ writeFileSync(join(d.env.ZDOTDIR!, '.zshrc'), `export CODEX_HOME=${JSON.stringify(home)}\n`)+ await d.start()+ let client = await LocalClient.connect(d)+ await until('the explicit durable adoption hold', () => d.log().includes('[hooks] home adoption held'))+ expect(existsSync(join(home, 'hooks.json'))).toBe(false)+ const terminal = await client.request('agent_create', { engine: 'terminal', cwd: d.projectsDir }, 60_000)+ expect(terminal.error, JSON.stringify(terminal)).toBeUndefined()+ expect((await row(client, terminal.agent.id))?.status).toBe('active')+ renameSync(fault, fault + '.recovered')+ await until('the pending home to receive hooks after durability recovers', () => existsSync(join(home, 'hooks.json')), 30_000)+ await until('the adoption recovery acknowledgement', () => d.log().includes('[hooks] home adoption recovered'), 30_000)+ const created = await client.request('agent_create', { engine: 'codex', cwd: d.projectsDir, bypassPermission: true }, 90_000)+ expect(created.error, JSON.stringify(created)).toBeUndefined()+ const bound = await until('the recovered home to bind', async () => {+ const value = await row(client, created.agent.id); return value?.sessionId ? value : null+ }, 45_000)+ await turn(client, bound.id, 'durable adoption recovered')+ client.close(); await d.stop()+ // The new boot must discover the saved home even after the login shell stops naming it.+ writeFileSync(join(d.env.ZDOTDIR!, '.zshrc'), '')+ await d.start(); client = await LocalClient.connect(d)+ const restored = await until('the durable home after restart without its shell variable', async () => {+ const value = await row(client, bound.id); return value?.sessionId === bound.sessionId ? value : null+ }, 45_000)+ expect(restored.transcriptPath).toBe(bound.transcriptPath)+ await turn(client, bound.id, 'the saved home survived restart')+ client.close()+ }, 240_000)+it.each(['claude', 'codex'] as const)('%s model picker follows the login shell home', async engine => {const d = await IsolatedDaemon.create(); daemon = dd.env.NODE_OPTIONS = `--import=${pathToFileURL(join(CLI_ROOT, 'e2e/harness/hiddenProcessEnv.mjs')).href}`diff --git a/cli/e2e/harness/daemon.ts b/cli/e2e/harness/daemon.tsindex 65bde350b..71270a82b 100644--- a/cli/e2e/harness/daemon.ts+++ b/cli/e2e/harness/daemon.ts@@ -20,6 +20,7 @@ import { promisify } from 'node:util'import { isolatedTmux, type IsolatedTmux } from '../../src/testing/isolatedTmux.js'import { artifactLog, artifactsEnabled } from './artifacts.js'import { daemonEnvironment } from '../../src/testing/daemonEnvironment.js'+import { readAdoptedHomes } from '../../src/engines/kit/homeAdoption.js'const exec = promisify(execFile)const here = dirname(fileURLToPath(import.meta.url))@@ -158,12 +159,20 @@ export function assertHooksContained(root: string, env: NodeJS.ProcessEnv): void}}}- try {- const remembered = JSON.parse(readFileSync(join(env.ADAPTER_DATA_DIR!, 'engine-homes.json'), 'utf8')) as Record<string, unknown>- for (const [engine, homes] of Object.entries(remembered)) {- for (const home of Array.isArray(homes) ? homes : []) check(`the ${engine} home remembered in engine-homes.json`, String(home))- }- } catch { /* none remembered yet */ }+ // Incomplete published records can be recovered during boot; an unreadable catalog cannot+ // justify starting a daemon whose recovered destinations have not passed containment.+ const file = join(env.ADAPTER_DATA_DIR!, 'engine-homes.json')+ let remembered: ReturnType<typeof readAdoptedHomes>['homes']+ try { remembered = readAdoptedHomes(file).homes }+ catch (error) {+ // A malformed legacy catalog cannot be imported or repaired by adoption. Published journal+ // intent can recover at boot, so its destinations must pass the guard before starting.+ if (existsSync(file + '.adoptions') || existsSync(file + '.adopted') || existsSync(file + '.confirmations')) throw error+ return+ }+ for (const [engine, homes] of Object.entries(remembered)) {+ for (const home of homes) check(`the ${engine} home remembered in engine-homes.json`, home)+ }}/**diff --git a/cli/e2e/harness/homeAdoptionFault.mjs b/cli/e2e/harness/homeAdoptionFault.mjsnew file mode 100644index 000000000..3b060ed23--- /dev/null+++ b/cli/e2e/harness/homeAdoptionFault.mjs@@ -0,0 +1,13 @@+// Private fixture: make only publication of an engine-home adoption unavailable until its flag is moved.+import fs from 'node:fs'+import { syncBuiltinESMExports } from 'node:module'++const link = fs.linkSync+fs.linkSync = function (from, to) {+ const flag = process.env.HARNESS_HOME_ADOPTION_FAULT_FILE+ if (flag && fs.existsSync(flag) && /engine-homes\.json\.adoptions\/\d{3}\.json$/.test(String(to))) {+ throw Object.assign(new Error('fixture home adoption storage unavailable'), { code: 'EIO' })+ }+ return link.call(this, from, to)+}+syncBuiltinESMExports()diff --git a/cli/scripts/handoff-2026-10-08/home-adoption-cost.ts b/cli/scripts/handoff-2026-10-08/home-adoption-cost.tsnew file mode 100644index 000000000..f4c0fd88e--- /dev/null+++ b/cli/scripts/handoff-2026-10-08/home-adoption-cost.ts@@ -0,0 +1,55 @@+/** Matched catalog work: fresh native proof, or a registry-sized batch of legacy bound-home lookups. */+import { createHash } from 'node:crypto'+import { mkdirSync, mkdtempSync, realpathSync, rmSync, writeFileSync } from 'node:fs'+import { tmpdir } from 'node:os'+import { join, resolve } from 'node:path'+import { performance } from 'node:perf_hooks'+import { pathToFileURL } from 'node:url'++const workload = process.argv[2] ?? 'native-one'+if (!['native-one', 'native-full', 'registry-one', 'registry-full'].includes(workload)) throw Error('Unknown workload')+const cli = process.env.ADOPTION_COST_CLI ?? resolve(import.meta.dirname, '../..')+const root = realpathSync(mkdtempSync(join(tmpdir(), 'home-adoption-cost-')))+for (const name of ['HOME', 'ADAPTER_DATA_DIR', 'ADAPTER_RUNTIME_DIR', 'CODEX_HOME', 'CLAUDE_CONFIG_DIR']) process.env[name] = join(root, name)+process.env.CLAUDE_PROJECTS_DIR = join(process.env.CLAUDE_CONFIG_DIR!, 'projects')+const data = process.env.ADAPTER_DATA_DIR!, file = join(data, 'engine-homes.json')+mkdirSync(data, { mode: 0o700 })+try {+ const count = workload.endsWith('full') ? 63 : 1+ const known = Array.from({ length: count }, (_, i) => join(root, `moved-${i}`))+ // Both implementations see the same homes. The former reader ignores the new immutable records.+ writeFileSync(file, JSON.stringify({ claude: [], codex: known }), { mode: 0o600 })+ mkdirSync(file + '.adoptions', { mode: 0o700 }); mkdirSync(file + '.confirmations', { mode: 0o700 })+ let previous: string | null = null+ for (const [index, home] of known.entries()) {+ const number = String(index).padStart(3, '0')+ const text = JSON.stringify({ version: 1, previous, legacyRequired: true, homes: { claude: [], codex: [home] } }) + '\n'+ const hash = createHash('sha256').update(text).digest('hex')+ writeFileSync(join(file + '.adoptions', number + '.json'), text, { mode: 0o600 })+ writeFileSync(index ? join(file + '.confirmations', number + '.committed') : file + '.adopted', hash + '\n', { mode: 0o600 })+ previous = hash+ }+ const homes = await import(pathToFileURL(join(cli, 'src/lib/engineHomes.ts')).href)+ const iterations = workload.startsWith('registry') ? 200 : 25+ const latenciesMs: number[] = [], outcomes: Record<string, number> = {}+ const cpu = process.cpuUsage(), started = performance.now()+ const snapshot = workload.startsWith('registry') ? homes.engineHomeSnapshot?.() : undefined+ for (let i = 0; i < iterations; i++) {+ const before = performance.now()+ let outcome: string+ try {+ if (workload.startsWith('native')) outcome = homes.nativeSessionRoots('codex').length === count + 1 ? 'complete' : 'wrong'+ else {+ const home = known[i % count]+ outcome = homes.sessionCodexHome({ transcriptPath: join(home, 'sessions', `row-${i}.jsonl`) }, snapshot) === home ? 'complete' : 'wrong'+ }+ } catch (error) { if ((error as { code?: string }).code !== 'IDENTITY_UNAVAILABLE') throw error; outcome = 'held' }+ latenciesMs.push(Number((performance.now() - before).toFixed(4)))+ outcomes[outcome] = (outcomes[outcome] ?? 0) + 1+ }+ snapshot?.verify()+ const elapsedMs = performance.now() - started, used = process.cpuUsage(cpu)+ console.log(JSON.stringify({ workload, records: count, iterations, outcomes, latenciesMs, elapsedMs,+ cpuMs: (used.user + used.system) / 1000, peakRssMiB: process.resourceUsage().maxRSS / 1024,+ node: process.version, platform: process.platform, arch: process.arch }))+} finally { rmSync(root, { recursive: true, force: true }) }diff --git a/cli/scripts/handoff-2026-10-08/mutate-home-adoptions.py b/cli/scripts/handoff-2026-10-08/mutate-home-adoptions.pynew file mode 100644index 000000000..07e32bbbe--- /dev/null+++ b/cli/scripts/handoff-2026-10-08/mutate-home-adoptions.py@@ -0,0 +1,68 @@+"""Owned disposable worktree only: adoption and hook retries must fail assertions when disconnected."""+import os+from pathlib import Path+import subprocess+import sys++cli = Path(sys.argv[1]).resolve()+writer = 'src/engines/kit/homeAdoption.ts'+homes = 'src/lib/engineHomes.ts'+coordinator = 'src/core/engines/homeAdoptions.ts'+spec = 'src/engines/kit/homeAdoption.spec.ts'+home_spec = 'src/lib/engineHomes.spec.ts'+coord_spec = 'src/core/engines/homeAdoptions.spec.ts'+mutations = [+ ('durable writer disconnected', homes, 'const committed = writer.adopt(', 'const committed = ((..._args: unknown[]) => ({ claude: [], codex: [] }))(', 'src/lib/engineHomeAdoption.golden.spec.ts'),+ ('new record never confirmed', writer, 'seal({ path, value, digest: digest(text), sealed: false }, found.entries.length, found, staging, check)', 'void 0', spec),+ ('stage flush omitted', writer, 'writeFileSync(fd, text); fsyncSync(fd); check()', 'writeFileSync(fd, text); check()', spec),+ ('directory flush omitted', writer, ' fsyncSync(fd); check()', ' check()', spec),+ ('final baseline import omitted', writer, 'if (ENGINES.some(engine => observed[engine].some(home => !recorded[engine].includes(home)))\n || (legacyObserved && !final.entries.at(-1)?.value.legacyRequired)) return null', 'if (false) return null', spec),+ ('requested unsaved home forgotten', homes, '...(pendingCatalogFile === file ? [pendingHomes[name]] : [])', '...[]', home_spec),+ ('empty boot skips published recovery', writer, ' merge(additions)', ' if (!additions.claude.length && !additions.codex.length) return readAdoptedHomes(file).homes\n merge(additions)', spec),+ ('last frontier omitted', writer, ' frontier()\n check()', ' check()', spec),+ ('numbered membership omitted', writer, 'if (present !== result.includes(name))', 'if (false)', spec),+ ('directory stamp omitted', writer, 'if (stamp(after) !== stamp(info))', 'if (false)', spec),+ ('required legacy file ignored', writer, "if (required && legacy.text === null)", 'if (false)', spec),+ ('held observations forgotten across calls', writer, ' const check = deadline()\n try {', ' observed = empty(); legacyObserved = false; exhausted = false\n const check = deadline()\n try {', spec),+ ('recovery uses a fresh adopter', homes, 'return adopter().adopt({ claude: [], codex: [] })', 'return createHomeAdopter(savedFile()).adopt({ claude: [], codex: [] })', home_spec),+ ('held observations cannot constrain roots', homes, '...(observed ? [observed.homes[name]] : [])', '...[]', home_spec),+ ('peer recovery hooks forgotten', coordinator, 'restoring = true // Confirmation may also have recovered another writer\'s home.', 'restoring = false', coord_spec),+ ('closed callback accepted', coordinator, 'closed = true', 'closed = false', coord_spec),+ ('batch final proof omitted', 'src/lib/registry.ts', 'try { snapshot.verify() }', 'try { void 0 }', 'src/lib/registry.homes.spec.ts'),+ ('batch preservation omitted', 'src/lib/registry.ts', 'for (const [id, raw] of dependent) preserve(staged.get(id)!, raw, error)', 'void 0', 'src/lib/registry.homes.spec.ts'),+ ('boot recovery disconnected', 'src/core/engines/hooks.ts', 'read: recoverEngineHomes,', 'read: () => ({ claude: [], codex: [] }),', 'src/core/engines/hooks.spec.ts'),+ ('released binding retains hold', 'src/lib/registry.ts', ' delete entry.identityHold', ' void 0', 'src/lib/registry.homes.spec.ts'),+ ('stopped snapshot persists hold', 'src/lib/stoppedAgents.ts', ' delete snapshot.identityHold', ' void 0', 'src/lib/stoppedAgents.spec.ts'),+]+env = {**os.environ, 'TZ': 'UTC', 'TMPDIR': '/tmp'}+for key in list(env):+ if key in ['TMUX', 'TMUX_PANE'] or key.startswith('RECORD_'):+ env.pop(key)+if not Path(env.get('TMUX_TMPDIR', '/missing-private-tmux')).is_dir():+ raise SystemExit('An existing private TMUX_TMPDIR is required')+++def run(specs):+ return subprocess.run(['node', 'node_modules/vitest/vitest.mjs', 'run', *specs, '--maxWorkers=1'],+ cwd=cli, env=env, capture_output=True, text=True, timeout=180)+++baseline = run(sorted({target for _, _, _, _, target in mutations}))+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, target in mutations:+ path = cli / relative+ original = path.read_text()+ assert original.count(before) == 1, (label, original.count(before))+ try:+ path.write_text(original.replace(before, after))+ result = run([target])+ 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/core/engines/homeAdoptions.spec.ts b/cli/src/core/engines/homeAdoptions.spec.tsnew file mode 100644index 000000000..cdcf4b075--- /dev/null+++ b/cli/src/core/engines/homeAdoptions.spec.ts@@ -0,0 +1,99 @@+import { afterEach, expect, it, vi } from 'vitest'+import { createHomeAdoptions, type HomeAdoptionDeps } from './homeAdoptions.js'++const controllers: Array<ReturnType<typeof createHomeAdoptions>> = []+function setup(overrides: Partial<HomeAdoptionDeps> = {}) {+ vi.useFakeTimers()+ const deps = {+ read: vi.fn(() => ({ claude: [], codex: [] })),+ confirm: vi.fn(() => ({ claude: null, codex: null })),+ install: vi.fn(), held: vi.fn(), ...overrides,+ }+ const controller = createHomeAdoptions(deps)+ controllers.push(controller)+ return { ...controller, deps }+}+afterEach(() => { controllers.splice(0).forEach(value => value.close()); vi.useRealTimers() })++it('installs fresh saved homes and every confirmed request once, including another writer’s idempotent win', () => {+ const c = setup({ read: vi.fn(() => ({ claude: ['/previous'], codex: [] })),+ confirm: vi.fn(() => ({ claude: '/previous', codex: '/already-committed' })) })+ c.submit({ CODEX_HOME: '/already-committed' })+ c.submit({ CODEX_HOME: '/already-committed' })+ expect(c.deps.read).toHaveBeenCalledTimes(2)+ expect(vi.mocked(c.deps.install).mock.calls).toEqual([['claude', '/previous'], ['codex', '/already-committed']])+ expect(c.deps.held).not.toHaveBeenCalled()+ expect(vi.getTimerCount()).toBe(0)+})++it('returns while storage is unavailable, reports its reason once, and retries until both confirmations recover', async () => {+ let readable = false, writable = false+ const c = setup({ read: vi.fn(() => {+ if (!readable) throw new Error('catalog unavailable')+ return { claude: ['/saved'], codex: [] }+ }), confirm: vi.fn(() => {+ if (!writable) throw new Error('durability unavailable')+ return { claude: null, codex: '/requested' }+ }) })+ c.submit({ CODEX_HOME: '/requested' })+ expect(c.deps.install).not.toHaveBeenCalled()+ expect(vi.mocked(c.deps.held).mock.calls).toEqual([['durability unavailable']])+ c.submit({ CODEX_HOME: '/requested' })+ expect(vi.getTimerCount()).toBe(1)+ await vi.advanceTimersByTimeAsync(1_000)+ expect(c.deps.held).toHaveBeenCalledTimes(1)+ readable = true+ await vi.advanceTimersByTimeAsync(1_000)+ expect(c.deps.install).toHaveBeenCalledWith('claude', '/saved')+ expect(c.deps.held).toHaveBeenLastCalledWith('durability unavailable')+ writable = true+ await vi.advanceTimersByTimeAsync(1_000)+ expect(c.deps.install).toHaveBeenLastCalledWith('codex', '/requested')+ expect(c.deps.held).toHaveBeenLastCalledWith(null)+ expect(vi.getTimerCount()).toBe(0)+})++it('retains only declared home variables and snapshots them before retry', async () => {+ const confirm = vi.fn<HomeAdoptionDeps['confirm']>().mockImplementationOnce(() => { throw 'held' })+ .mockReturnValue({ claude: '/c', codex: '/d' })+ const c = setup({ confirm })+ const environment = { CLAUDE_CONFIG_DIR: '/c', CODEX_HOME: '/d', SECRET: 'must not be retained' }+ c.submit(environment)+ environment.CODEX_HOME = '/changed'+ await vi.advanceTimersByTimeAsync(1_000)+ expect(confirm.mock.calls).toEqual([[{ CLAUDE_CONFIG_DIR: '/c', CODEX_HOME: '/d' }], [{ CLAUDE_CONFIG_DIR: '/c', CODEX_HOME: '/d' }]])+ expect(vi.mocked(c.deps.held).mock.calls).toEqual([['held'], [null]])+})++it('retains hook installation independently of adoption, without blocking another home', async () => {+ const install = vi.fn<HomeAdoptionDeps['install']>().mockImplementationOnce(() => { throw new Error('settings unavailable') })+ const c = setup({ confirm: vi.fn(() => ({ claude: '/c', codex: '/d' })), install })+ c.submit({})+ expect(install.mock.calls).toEqual([['claude', '/c'], ['codex', '/d']])+ expect(c.deps.held).toHaveBeenCalledWith('settings unavailable')+ await vi.advanceTimersByTimeAsync(1_000)+ expect(c.deps.confirm).toHaveBeenCalledTimes(1)+ expect(install.mock.calls).toEqual([['claude', '/c'], ['codex', '/d'], ['claude', '/c']])+ expect(c.deps.held).toHaveBeenLastCalledWith(null)+})++it('installs a peer home recovered while confirming a later request', () => {+ const read = vi.fn<HomeAdoptionDeps['read']>()+ .mockReturnValueOnce({ claude: [], codex: ['/saved'] })+ .mockReturnValue({ claude: [], codex: ['/saved', '/peer', '/requested'] })+ const c = setup({ read, confirm: vi.fn(() => ({ claude: null, codex: '/requested' })) })+ c.retry()+ c.submit({ CODEX_HOME: '/requested' })+ expect(vi.mocked(c.deps.install).mock.calls).toEqual([['codex', '/saved'], ['codex', '/requested'], ['codex', '/peer']])+})++it('fences queued retries and late login-shell callbacks when the owning daemon closes', async () => {+ const c = setup({ confirm: vi.fn(() => { throw new Error('held') }) })+ c.submit({ CODEX_HOME: '/old' })+ c.close()+ c.submit({ CODEX_HOME: '/late' }); c.retry()+ await vi.advanceTimersByTimeAsync(10_000)+ expect(c.deps.confirm).toHaveBeenCalledTimes(1)+ expect(c.deps.install).not.toHaveBeenCalled()+ expect(vi.getTimerCount()).toBe(0)+})diff --git a/cli/src/core/engines/homeAdoptions.ts b/cli/src/core/engines/homeAdoptions.tsnew file mode 100644index 000000000..c74d375c5--- /dev/null+++ b/cli/src/core/engines/homeAdoptions.ts@@ -0,0 +1,68 @@+import type { HomeCatalog } from '../../engines/kit/homeCatalog.js'+import type { SessionStoreEngine } from '../../engines/sessionStoreContracts.js'++export interface HomeAdoptionDeps {+ read(): HomeCatalog+ confirm(environment: NodeJS.ProcessEnv): Record<SessionStoreEngine, string | null>+ install(engine: SessionStoreEngine, home: string): void+ held(reason: string | null): void+}++/** Core-owned retries. A confirmed durable home and its hook installation are separate acknowledgements. */+export function createHomeAdoptions(deps: HomeAdoptionDeps) {+ let closed = false, restoring = true, reported: string | null = null+ let timer: ReturnType<typeof setTimeout> | undefined+ const requests = new Map<string, NodeJS.ProcessEnv>()+ const installs = new Map<string, [SessionStoreEngine, string]>()+ const installed = new Set<string>()+ const queue = (engine: SessionStoreEngine, home: string): void => {+ const key = JSON.stringify([engine, home])+ if (!installed.has(key)) installs.set(key, [engine, home])+ }+ const reason = (error: unknown): string => error instanceof Error ? error.message : String(error)+ const retry = (): void => {+ if (closed) return+ let held: string | null = null+ for (const [key, environment] of requests) {+ try {+ const confirmed = deps.confirm(environment)+ for (const engine of ['claude', 'codex'] as const) if (confirmed[engine]) queue(engine, confirmed[engine])+ requests.delete(key)+ restoring = true // Confirmation may also have recovered another writer's home.+ } catch (error) { held ??= reason(error) }+ }+ if (restoring) {+ try {+ const homes = deps.read()+ for (const engine of ['claude', 'codex'] as const) for (const home of homes[engine]) queue(engine, home)+ restoring = false+ } catch (error) { held ??= reason(error) }+ }+ for (const [key, [engine, home]] of installs) {+ try { deps.install(engine, home); installed.add(key); installs.delete(key) }+ catch (error) { held ??= reason(error) }+ }+ if (held !== reported) { reported = held; deps.held(held) }+ if ((restoring || requests.size || installs.size) && !timer) {+ timer = setTimeout(() => { timer = undefined; retry() }, 1_000)+ timer.unref()+ }+ }+ return {+ retry,+ submit(environment: NodeJS.ProcessEnv): void {+ if (closed) return+ // Only two declared home variables survive this callback; never retain login-shell credentials.+ const selected: NodeJS.ProcessEnv = {}+ for (const key of ['CLAUDE_CONFIG_DIR', 'CODEX_HOME']) if (environment[key] !== undefined) selected[key] = environment[key]+ const key = JSON.stringify(selected)+ requests.set(key, selected)+ retry()+ },+ close(): void {+ closed = true+ if (timer) clearTimeout(timer)+ timer = undefined; requests.clear(); installs.clear(); installed.clear()+ },+ }+}diff --git a/cli/src/core/engines/hooks.spec.ts b/cli/src/core/engines/hooks.spec.tsindex 3c1370b47..e7510d7e9 100644--- a/cli/src/core/engines/hooks.spec.ts+++ b/cli/src/core/engines/hooks.spec.ts@@ -3,7 +3,7 @@ import * as hooks from '../../engines/nativeHooks.js'import { engineHooks } from '../../engines/hooks.js'import type { RegisteredSession } from '../../lib/registry.js'import { processRows } from '../../lib/terminalAgentDiscovery.js'-import { adoptHomes, movedHomes } from '../../lib/engineHomes.js'+import { confirmHomes, recoverEngineHomes } from '../../lib/engineHomes.js'import { createEngineHooks, installEngineHooks, installOpencodePluginBeforeSpawn, PROCESS_RECORD_WAIT_MS, type EngineHookDeps } from './hooks.js'import { loadEngine } from '../../engines/inProcess.js'import { createPaneOperations } from '../agents/paneOperations.js'@@ -16,8 +16,8 @@ vi.mock('../../engines/hooks.js', async (real) => {} }})vi.mock('../../lib/engineHomes.js', () => ({- adoptHomes: vi.fn(() => ({ claude: null, codex: null })),- movedHomes: vi.fn(() => []),+ confirmHomes: vi.fn(() => ({ claude: null, codex: null })),+ recoverEngineHomes: vi.fn(() => ({ claude: [], codex: [] })),}))// Native installation must finish even when optional interpretation cannot be loaded.const loading = vi.hoisted(() => ({ stalled: false }))@@ -371,7 +371,7 @@ describe('installing every engine\'s hooks', () => {})it('only the engines asked for (HOOK_INSTALL_ENGINES), the homes they moved included', async () => {- vi.mocked(movedHomes).mockReturnValueOnce(['/w/claude']).mockReturnValueOnce(['/w/codex'])+ vi.mocked(recoverEngineHomes).mockReturnValueOnce({ claude: ['/w/claude'], codex: ['/w/codex'] })await installEngineHooks(4242, { only: new Set(['codex']), environment: {} })expect(engineHooks.codex.install).toHaveBeenCalledWith(4242)expect(engineHooks.codex.installIn).toHaveBeenCalledWith(4242, '/w/codex')@@ -394,35 +394,65 @@ describe('installing every engine\'s hooks', () => {// lib/engineHomes.ts: with CLAUDE_CONFIG_DIR or CODEX_HOME in the person's profile, no agent ever bound.it('puts the hooks in every home adopted on an earlier boot, at every start', async () => {- vi.mocked(movedHomes).mockReturnValueOnce(['/w/claude']).mockReturnValueOnce(['/w/codex'])+ vi.mocked(recoverEngineHomes).mockReturnValueOnce({ claude: ['/w/claude'], codex: ['/w/codex'] })await installEngineHooks(4242, { environment: {} })expect(engineHooks.claude.installIn).toHaveBeenCalledWith(4242, '/w/claude')expect(engineHooks.codex.installIn).toHaveBeenCalledWith(4242, '/w/codex')- expect(vi.mocked(movedHomes).mock.calls).toEqual([['claude'], ['codex']])+ expect(recoverEngineHomes).toHaveBeenCalledTimes(1)})it('adopts the homes its own environment moves, then the login shell\'s once that is read, and installs there', async () => {const log = vi.spyOn(console, 'log').mockImplementation(() => {})const own = { CLAUDE_CONFIG_DIR: '/m/claude' }const shell = { CODEX_HOME: '/s/codex' }- vi.mocked(adoptHomes)+ vi.mocked(confirmHomes).mockReturnValueOnce({ claude: '/m/claude', codex: null }).mockReturnValueOnce({ claude: null, codex: '/s/codex' })void installEngineHooks(4242, { environment: own, loginShell: Promise.resolve(shell) })- expect(adoptHomes).toHaveBeenCalledWith(own)+ expect(confirmHomes).toHaveBeenCalledWith(own)expect(engineHooks.claude.installIn).toHaveBeenCalledWith(4242, '/m/claude')- expect(log).toHaveBeenCalledWith('[hooks] engines keep their data elsewhere here: Claude Code in /m/claude')+ expect(log).toHaveBeenCalledWith('[hooks] Claude Code hooks installed in its adopted home')await Promise.resolve()- expect(adoptHomes).toHaveBeenLastCalledWith(shell)+ expect(confirmHomes).toHaveBeenLastCalledWith(shell)expect(engineHooks.codex.installIn).toHaveBeenCalledWith(4242, '/s/codex')- expect(log).toHaveBeenCalledWith('[hooks] engines keep their data elsewhere here: Codex in /s/codex')+ expect(log).toHaveBeenCalledWith('[hooks] Codex hooks installed in its adopted home')})it('reads the daemon\'s own environment when none is given, and logs nothing when nothing moved', async () => {const log = vi.spyOn(console, 'log').mockImplementation(() => {})- await installEngineHooks(4242)- expect(adoptHomes).toHaveBeenCalledWith(process.env)- expect(log).not.toHaveBeenCalled()+ vi.stubEnv('CODEX_HOME', '/fixture/codex')+ vi.stubEnv('CLAUDE_CONFIG_DIR', '/fixture/claude')+ try {+ await installEngineHooks(4242)+ expect(confirmHomes).toHaveBeenCalledWith({ CODEX_HOME: '/fixture/codex', CLAUDE_CONFIG_DIR: '/fixture/claude' })+ expect(log).not.toHaveBeenCalled()+ } finally { vi.unstubAllEnvs() }+ })++ it('contains a rejected login-shell read and fences a late successful read after close', async () => {+ const rejected = await installEngineHooks(4242, { environment: {}, loginShell: Promise.reject('fixture unavailable') })+ expect(console.warn).toHaveBeenCalledWith('[hooks] login-shell homes unavailable · fixture unavailable')+ rejected.close()+ await installEngineHooks(4242, { environment: {}, loginShell: Promise.reject(new Error('fixture failed')) })+ expect(console.warn).toHaveBeenLastCalledWith('[hooks] login-shell homes unavailable · fixture failed')+ let resolve!: (environment: NodeJS.ProcessEnv) => void+ const installed = await installEngineHooks(4242, { environment: {}, loginShell: new Promise(done => { resolve = done }) })+ const calls = vi.mocked(confirmHomes).mock.calls.length+ installed.close(); resolve({ CODEX_HOME: '/late' }); await Promise.resolve()+ expect(confirmHomes).toHaveBeenCalledTimes(calls)+ })++ it('reports held home adoption without withholding other installers, then recovers', async () => {+ vi.useFakeTimers()+ vi.mocked(confirmHomes).mockImplementationOnce(() => { throw new Error('fixture durability unavailable') })+ const installed = await installEngineHooks(4242, { environment: {} })+ try {+ expect(console.warn).toHaveBeenCalledWith('[hooks] home adoption held · fixture durability unavailable')+ for (const install of installs) expect(install).toHaveBeenCalledWith(4242)+ const log = vi.spyOn(console, 'log').mockImplementation(() => {})+ await vi.advanceTimersByTimeAsync(1_000)+ expect(log).toHaveBeenCalledWith('[hooks] home adoption recovered')+ } finally { installed.close(); vi.useRealTimers() }})it('one at a time: a vendor whose install throws is skipped and named, and the rest still install', async () => {diff --git a/cli/src/core/engines/hooks.ts b/cli/src/core/engines/hooks.tsindex 6da47e538..022718121 100644--- a/cli/src/core/engines/hooks.ts+++ b/cli/src/core/engines/hooks.ts@@ -5,9 +5,10 @@* Moved verbatim out of `runForeground` (the core boundary, step 12: docs/design/2026-10-03-harnessd.md).*/import { engineHooks } from '../../engines/hooks.js'-import { sessionStoreContracts, type SessionStoreEngine } from '../../engines/sessionStoreContracts.js'+import { sessionStoreContracts } from '../../engines/sessionStoreContracts.js'import { chooseHookAgent, type HookServerHandlers } from '../../hookServer.js'-import { adoptHomes, movedHomes } from '../../lib/engineHomes.js'+import { confirmHomes, recoverEngineHomes } from '../../lib/engineHomes.js'+import { createHomeAdoptions } from './homeAdoptions.js'import * as nativeHooks from '../../engines/nativeHooks.js'import { sid } from '../../lib/log.js'import type { registry, RegisteredSession } from '../../lib/registry.js'@@ -235,7 +236,7 @@ const OTHER_INSTALLERS: Array<[string, (port: number) => void]> = [* An unavailable interpreter cannot delay this step. A vendor whose settings throw is named and skipped;* durable launch holds for preparation failures are a separate behavior change. Never rejects.*/-export async function installEngineHooks(port: number, options: InstallEngineHooksOptions = {}): Promise<void> {+export async function installEngineHooks(port: number, options: InstallEngineHooksOptions = {}): Promise<{ close(): void }> {const hookStep = (vendor: string, install: () => void): void => {if (options.only && !options.only.has(vendor)) returntry { install() } catch (error) {@@ -246,19 +247,22 @@ export async function installEngineHooks(port: number, options: InstallEngineHoo// too: every one adopted before, those the daemon's own environment names, and those of the login shell// every engine is launched through once it has been read. That read is never waited on (cli.ts), so an// engine started in the first seconds of a daemon's very first start with a moved home may miss its first hook.- const installIn = (homes: Array<[SessionStoreEngine, string]>): void => {- for (const [engine, home] of homes) hookStep(engine, () => engineHooks[engine].installIn(port, home))- }- const adopt = (environment: NodeJS.ProcessEnv): void => {- const moved = (Object.entries(adoptHomes(environment)) as Array<[SessionStoreEngine, string | null]>)- .filter((found): found is [SessionStoreEngine, string] => !!found[1])- if (!moved.length) return- console.log(`[hooks] engines keep their data elsewhere here: ${moved.map(([engine, home]) => `${sessionStoreContracts[engine].product} in ${home}`).join(', ')}`)- installIn(moved)- }- installIn((Object.keys(sessionStoreContracts) as SessionStoreEngine[]).flatMap((engine) => movedHomes(engine).map((home): [SessionStoreEngine, string] => [engine, home])))- adopt(options.environment ?? process.env)- void options.loginShell?.then(adopt)+ const adoptions = createHomeAdoptions({+ read: recoverEngineHomes,+ confirm: confirmHomes,+ install: (engine, home) => {+ if (options.only && !options.only.has(engine)) return+ engineHooks[engine].installIn(port, home)+ console.log(`[hooks] ${sessionStoreContracts[engine].product} hooks installed in its adopted home`)+ },+ held: reason => {+ if (reason) console.warn(`[hooks] home adoption held · ${reason}`)+ else console.log('[hooks] home adoption recovered')+ },+ })+ adoptions.submit(options.environment ?? process.env)+ void options.loginShell?.then(adoptions.submit, error => console.warn(`[hooks] login-shell homes unavailable · ${error instanceof Error ? error.message : error}`))for (const [engine, hooks] of Object.entries(engineHooks)) hookStep(engine, () => hooks.install(port))for (const [vendor, install] of OTHER_INSTALLERS) hookStep(vendor, () => install(port))+ return { close: adoptions.close }}diff --git a/cli/src/core/main.ts b/cli/src/core/main.tsindex 24657730a..81e18f8dc 100644--- a/cli/src/core/main.ts+++ b/cli/src/core/main.ts@@ -1910,7 +1910,8 @@ async function runForeground(session: AuthSession | null): Promise<void> {})localWsServerRef = localWsServer// Every engine's hooks, pointed at the port the local server actually bound (core/engines/hooks.ts).- if (!env.DISABLE_HOOK_INSTALL) await installEngineHooks(hookPort, { only: env.HOOK_INSTALL_ENGINES, loginShell: loginShellEnvPromise })+ const installedHooks = env.DISABLE_HOOK_INSTALL ? undefined+ : await installEngineHooks(hookPort, { only: env.HOOK_INSTALL_ENGINES, loginShell: loginShellEnvPromise })// Each transcript line, through its engine's normalizer, into the funnel (core/transcripts/ingest.ts).const ingest = createIngest({@@ -2448,7 +2449,7 @@ async function runForeground(session: AuthSession | null): Promise<void> {// stops being `bootHandoff` HERE, and not a line earlier: everything the teardown releases exists by now.// A straight-line assignment, never a wait: if the body never reaches this line the handler stays// `bootHandoff`, and the fix still lands.- const updateTeardown = (): TeardownStep[] => { externalResumes?.stop(); return [+ const updateTeardown = (): TeardownStep[] => { installedHooks?.close(); externalResumes?.stop(); return [['the registry', () => registry.flush({ exiting: true })], ['the updater', () => daemonBoot.updaterBeside?.()],['the reconciler', () => agentReconciler.stop()],['the timers', () => { clearInterval(logTrimTimer); clearInterval(runtimeReconcileTimer); clearInterval(paneTitleSyncTimer) }],@@ -2485,6 +2486,7 @@ async function runForeground(session: AuthSession | null): Promise<void> {* which restarts any other exit (harnessd/protocol.ts). */const forGood = (reason: string): boolean => reason === 'revoked' || reason === 'busy'const shutdown = async (signal: string): Promise<void> => {+ installedHooks?.close()externalResumes?.stop()console.log(`\n[cli] ${signal} — shutting down`)// A slow teardown may exhaust the master's grace. Persist already acknowledged bindings first.diff --git a/cli/src/engines/codex/subagent.spec.ts b/cli/src/engines/codex/subagent.spec.tsindex 093bfd59a..0ce528d11 100644--- a/cli/src/engines/codex/subagent.spec.ts+++ b/cli/src/engines/codex/subagent.spec.ts@@ -1,3 +1,4 @@+import { clearEngineHomeFixture } from '../../testing/engineHomeFixture.js'import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'fs'import { tmpdir } from 'os'@@ -66,7 +67,7 @@ describe('Codex child rollout reader', () => {expect(codexSubagentResolverFor(join(root, 'elsewhere'))(childId)).toBeNull()} finally {vi.unstubAllEnvs()- rmSync(join(process.env.ADAPTER_DATA_DIR!, 'engine-homes.json'), { force: true })+ clearEngineHomeFixture(process.env.ADAPTER_DATA_DIR!)homes.resetEngineHomes()}})@@ -101,3 +102,6 @@ describe('Codex child rollout reader', () => {})})})++// Filesystem durability deadlines are exercised separately from these deterministic fixture reads.+vi.mock('node:perf_hooks', async original => ({ ...await original<object>(), performance: { now: () => 0 } }))diff --git a/cli/src/engines/exactResume.golden.spec.ts b/cli/src/engines/exactResume.golden.spec.tsindex 1bc1cb07b..d0241889a 100644--- a/cli/src/engines/exactResume.golden.spec.ts+++ b/cli/src/engines/exactResume.golden.spec.ts@@ -96,3 +96,6 @@ it('records Pi custom ids, lossy folders and unwritten conversations', async ()await check('pi:missing-directory', repair.findResumedTranscript('pi', 'not-written', { cwd: path('absent') }))})it('records every observation', () => { if (!RECORD) expect(Object.keys(captured).sort()).toEqual(Object.keys(expected).sort()) })++// Filesystem durability deadlines are exercised separately from these deterministic fixture reads.+vi.mock('node:perf_hooks', async original => ({ ...await original<object>(), performance: { now: () => 0 } }))diff --git a/cli/src/engines/kit/homeAdoption.process.spec.ts b/cli/src/engines/kit/homeAdoption.process.spec.tsnew file mode 100644index 000000000..9a90209d5--- /dev/null+++ b/cli/src/engines/kit/homeAdoption.process.spec.ts@@ -0,0 +1,95 @@+import { execFile } from 'node:child_process'+import { mkdtempSync, mkdirSync, realpathSync, rmSync, writeFileSync } from 'node:fs'+import { tmpdir } from 'node:os'+import { join, resolve } from 'node:path'+import { promisify } from 'node:util'+import { buildSync } from 'esbuild'+import { afterAll, afterEach, beforeAll, beforeEach, expect, it } from 'vitest'+import { createHomeAdopter, readAdoptedHomes } from './homeAdoption.js'++const execute = promisify(execFile)+let bundleRoot = '', root = '', file = '', script = ''+let adopter: ReturnType<typeof createHomeAdopter>+beforeAll(() => {+ bundleRoot = realpathSync(mkdtempSync(join(tmpdir(), 'adoption-process-bundle-')))+ script = join(bundleRoot, 'writer.mjs')+ buildSync({ stdin: { resolveDir: process.cwd(), sourcefile: 'writer.ts', contents: `+ import fs from 'node:fs'+ import { syncBuiltinESMExports } from 'node:module'+ import { createHomeAdopter } from ${JSON.stringify(resolve('src/engines/kit/homeAdoption.ts'))}+ const [file, homes, gate, phase] = process.argv.slice(2)+ const adopter = createHomeAdopter(file)+ const fds = new Map(), original = { open: fs.openSync, close: fs.closeSync, link: fs.linkSync, flush: fs.fsyncSync }+ let published = false, confirmed = false+ fs.openSync = (...args) => { const fd = original.open(...args); fds.set(fd, String(args[0])); return fd }+ fs.closeSync = fd => { original.close(fd); fds.delete(fd) }+ fs.linkSync = (from, to) => {+ const record = String(to).endsWith('/001.json'), seal = String(to).endsWith('/001.committed')+ if (record && phase === 'before-record') process.exit(75)+ original.link(from, to)+ if (record) { published = true; if (phase === 'record') process.exit(75) }+ if (seal) { confirmed = true; if (phase === 'confirmation') process.exit(75) }+ }+ fs.fsyncSync = fd => {+ original.flush(fd)+ if (published && fds.get(fd) === file + '.adoptions' && phase === 'record-flush') process.exit(75)+ if (confirmed && fds.get(fd) === file + '.confirmations' && phase === 'confirmation-flush') process.exit(75)+ }+ syncBuiltinESMExports()+ const end = Date.now() + 8000+ while (!fs.existsSync(gate)) {+ if (Date.now() > end) throw Error('fixture gate timed out')+ await new Promise(resolve => setTimeout(resolve, 5))+ }+ for (;;) {+ try { const result = adopter.adopt(JSON.parse(homes)); process.stdout.write(JSON.stringify(result)); break }+ catch (error) {+ if (error?.code !== 'IDENTITY_UNAVAILABLE' || Date.now() > end) throw error+ await new Promise(resolve => setTimeout(resolve, 20))+ }+ }+ ` }, outfile: script, bundle: true, platform: 'node', format: 'esm', logLevel: 'silent' })+})+beforeEach(() => {+ root = realpathSync(mkdtempSync(join(tmpdir(), 'adoption-process-')))+ mkdirSync(join(root, 'data'), { mode: 0o700 })+ file = join(root, 'data', 'engine-homes.json')+ adopter = createHomeAdopter(file)+})+afterEach(() => rmSync(root, { recursive: true, force: true }))+afterAll(() => rmSync(bundleRoot, { recursive: true, force: true }))+const add = (...codex: string[]) => ({ claude: [], codex })+async function settle(homes: ReturnType<typeof add>): Promise<void> {+ const end = Date.now() + 5000+ for (;;) {+ try { adopter.adopt(homes); return }+ catch (error) {+ if ((error as { code?: string }).code !== 'IDENTITY_UNAVAILABLE' || Date.now() > end) throw error+ await new Promise(resolve => setTimeout(resolve, 20))+ }+ }+}+function writer(homes: ReturnType<typeof add>, phase = '') {+ return execute(process.execPath, [script, file, JSON.stringify(homes), join(root, 'start'), phase], {+ timeout: 10_000, killSignal: 'SIGKILL', maxBuffer: 64 * 1024,+ env: { HOME: root, ADAPTER_DATA_DIR: join(root, 'data'), CODEX_HOME: join(root, 'codex'),+ CLAUDE_CONFIG_DIR: join(root, 'claude'), TZ: 'UTC', TMPDIR: '/tmp' },+ })+}++it.each([false, true])('serializes separate processes racing distinct or identical first homes (same=%s)', async same => {+ const first = writer(add('/first')), second = writer(add(same ? '/first' : '/second'))+ writeFileSync(join(root, 'start'), 'go')+ await Promise.all([first, second])+ expect(readAdoptedHomes(file).homes.codex.sort()).toEqual(same ? ['/first'] : ['/first', '/second'])+}, 15_000)++it.each(['before-record', 'record', 'record-flush', 'confirmation', 'confirmation-flush'])+ ('recovers a writer that exits without cleanup at %s', async phase => {+ await settle(add('/saved'))+ writeFileSync(join(root, 'start'), 'go')+ await expect(writer(add('/interrupted'), phase)).rejects.toMatchObject({ code: 75 })+ // A published intent can be completed by a fresh boot without any shell variable naming it.+ await settle(phase === 'before-record' ? add('/interrupted') : add())+ expect(readAdoptedHomes(file).homes).toEqual(add('/saved', '/interrupted'))+ }, 15_000)diff --git a/cli/src/engines/kit/homeAdoption.spec.ts b/cli/src/engines/kit/homeAdoption.spec.tsnew file mode 100644index 000000000..aa687df46--- /dev/null+++ b/cli/src/engines/kit/homeAdoption.spec.ts@@ -0,0 +1,312 @@+import * as fs from 'node:fs'+import { tmpdir } from 'node:os'+import { join } from 'node:path'+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'+import { createHomeAdopter, readAdoptedHomes } from './homeAdoption.js'++const clock = vi.hoisted(() => ({ now: 0, remaining: Infinity }))+vi.mock('node:perf_hooks', async original => ({ ...await original<object>(), performance: { now: () => --clock.remaining < 0 ? 251 : clock.now } }))++vi.mock('node:fs', async original => {+ const actual = await original<typeof fs>()+ return { ...actual, openSync: vi.fn(actual.openSync), closeSync: vi.fn(actual.closeSync),+ fsyncSync: vi.fn(actual.fsyncSync), linkSync: vi.fn(actual.linkSync),+ readSync: vi.fn(actual.readSync), writeFileSync: vi.fn(actual.writeFileSync), opendirSync: vi.fn(actual.opendirSync), lstatSync: vi.fn(actual.lstatSync) }+})+let actual: typeof fs, root = '', file = ''+let adopter: ReturnType<typeof createHomeAdopter>+const empty = () => ({ claude: [], codex: [] as string[] })+const add = (...codex: string[]) => ({ claude: [], codex })+const record = (index: number) => join(file + '.adoptions', `${String(index).padStart(3, '0')}.json`)+const seal = (index: number) => index ? join(file + '.confirmations', `${String(index).padStart(3, '0')}.committed`) : file + '.adopted'+const unavailable = () => Object.assign(new Error('fixture storage unavailable'), { code: 'EIO' })+const files = new Map<number, string>()+beforeEach(async () => {+ clock.now = 0; clock.remaining = Infinity+ actual = await vi.importActual<typeof fs>('node:fs')+ for (const name of ['openSync', 'closeSync', 'fsyncSync', 'linkSync', 'readSync', 'writeFileSync', 'opendirSync', 'lstatSync'] as const) {+ vi.mocked(fs[name]).mockReset().mockImplementation(actual[name] as never)+ }+ files.clear()+ vi.mocked(fs.openSync).mockImplementation((...args) => {+ const fd = actual.openSync(...args); files.set(fd, String(args[0])); return fd+ })+ vi.mocked(fs.closeSync).mockImplementation(fd => { actual.closeSync(fd); files.delete(fd) })+ root = actual.realpathSync(actual.mkdtempSync(join(tmpdir(), 'durable-home-adoption-')))+ file = join(root, 'data', 'engine-homes.json')+ adopter = createHomeAdopter(file)+})+afterEach(() => { vi.restoreAllMocks(); actual.rmSync(root, { recursive: true, force: true }) })++describe('durable monotone home adoption', () => {+ it('leaves a new installation alone for an empty request', () => {+ expect(adopter.adopt(empty())).toEqual(empty())+ expect(actual.existsSync(file + '.adoptions')).toBe(false)+ })++ it('preserves the imported file and reads committed homes independently of module memory', () => {+ actual.mkdirSync(join(root, 'data'), { mode: 0o700 })+ const original = '{"codex":["/previous"]}\n'+ actual.writeFileSync(file, original, { mode: 0o600 })+ expect(() => adopter.adopt(add('/new'))).not.toThrow()+ expect(adopter.adopt(add('/new'))).toEqual(add('/previous', '/new'))+ expect(actual.readFileSync(file, 'utf8')).toBe(original)+ expect(readAdoptedHomes(file).homes).toEqual(add('/previous', '/new'))+ const first = actual.readFileSync(record(0), 'utf8')+ expect(adopter.adopt(add('/new'))).toEqual(add('/previous', '/new'))+ expect(actual.readFileSync(record(0), 'utf8')).toBe(first)+ expect(actual.existsSync(record(1))).toBe(false)+ actual.writeFileSync(file, '{"claude":["/external"]}', { mode: 0o600 })+ expect(adopter.adopt(add('/later'))).toEqual({ claude: ['/external'], codex: ['/previous', '/new', '/later'] })+ expect(readAdoptedHomes(file).homes).toEqual({ claude: ['/external'], codex: ['/previous', '/new', '/later'] })+ })++ it.each(['same', 'different', 'last-slot'] as const)('rebases an exclusive-publication loser without losing a winner: %s', mode => {+ const prior = mode === 'last-slot' ? Array.from({ length: 62 }, (_, n) => `/saved-${n}`) : ['/saved']+ adopter.adopt(add(...prior))+ let raced = false+ vi.mocked(fs.linkSync).mockImplementation((from, to) => {+ if (String(to) === record(1) && !raced) {+ raced = true+ createHomeAdopter(file).adopt(add(mode === 'same' ? '/requested' : '/peer'))+ }+ return actual.linkSync(from, to)+ })+ if (mode === 'last-slot') expect(() => adopter.adopt(add('/requested'))).toThrow('known session-home limit')+ else expect(adopter.adopt(add('/requested')).codex).toEqual([...prior, ...(mode === 'same' ? [] : ['/peer']), '/requested'])+ const found = readAdoptedHomes(file).homes.codex+ expect(found).toEqual([...prior, ...(mode === 'same' ? ['/requested'] : ['/peer']), ...(mode === 'different' ? ['/requested'] : [])])+ expect(actual.existsSync(record(mode === 'different' ? 3 : 2))).toBe(false)+ expect(raced).toBe(true)+ })++ it.each(['write', 'stage-flush', 'record-link', 'journal-flush', 'confirmation-link', 'confirmation-flush'] as const)+ ('does not acknowledge a failed %s, and an idempotent retry confirms it', phase => {+ adopter.adopt(add('/saved'))+ let published = false, confirmed = false, failed = false+ const fail = () => { failed = true; throw unavailable() }+ vi.mocked(fs.writeFileSync).mockImplementation((...args) => {+ if (!failed && phase === 'write') fail()+ return actual.writeFileSync(...args)+ })+ vi.mocked(fs.linkSync).mockImplementation((from, to) => {+ if (String(to) === record(1)) {+ if (!failed && phase === 'record-link') fail()+ published = true+ }+ if (String(to) === seal(1)) {+ if (!failed && phase === 'confirmation-link') fail()+ confirmed = true+ }+ return actual.linkSync(from, to)+ })+ vi.mocked(fs.fsyncSync).mockImplementation(fd => {+ const path = files.get(fd)+ if (!failed && ((phase === 'stage-flush' && path?.includes('/.staging/'))+ || (phase === 'journal-flush' && published && path === file + '.adoptions')+ || (phase === 'confirmation-flush' && confirmed && path === file + '.confirmations'))) fail()+ actual.fsyncSync(fd)+ })+ expect(() => adopter.adopt(add('/requested'))).toThrow(/durable adoption/)+ expect(failed).toBe(true)+ if (published && !confirmed) expect(() => readAdoptedHomes(file)).toThrow('unconfirmed adoption')+ expect(adopter.adopt(add('/requested'))).toEqual(add('/saved', '/requested'))+ expect(readAdoptedHomes(file).homes).toEqual(add('/saved', '/requested'))+ expect(files.size).toBe(0)+ })++ it.each([false, true])('finishes a complete abandoned record after restart, including without another home request (empty=%s)', emptyRequest => {+ adopter.adopt(add('/saved'))+ vi.mocked(fs.linkSync).mockImplementation((from, to) => {+ if (String(to) === seal(1)) throw unavailable()+ return actual.linkSync(from, to)+ })+ expect(() => adopter.adopt(add('/interrupted'))).toThrow()+ expect(() => readAdoptedHomes(file)).toThrow('unconfirmed adoption')+ vi.mocked(fs.linkSync).mockImplementation(actual.linkSync)+ let recovered+ expect(() => { recovered = adopter.adopt(emptyRequest ? empty() : add('/later')) }).not.toThrow()+ expect(recovered).toEqual(add('/saved', '/interrupted', ...(emptyRequest ? [] : ['/later'])))+ })++ it.each(['journal', 'confirmations', 'tail', 'legacy'] as const)('holds missing committed %s evidence and recovers when restored', target => {+ actual.mkdirSync(join(root, 'data'), { mode: 0o700 })+ actual.writeFileSync(file, '{"codex":["/previous"]}', { mode: 0o600 })+ adopter.adopt(add('/first')); adopter.adopt(add('/second'))+ const lost = target === 'journal' ? file + '.adoptions' : target === 'confirmations' ? file + '.confirmations' : target === 'tail' ? record(1) : file+ actual.renameSync(lost, lost + '.owned-backup')+ expect(() => readAdoptedHomes(file)).toThrow(/journal|catalog/)+ expect(() => adopter.adopt(add('/third'))).toThrow(/journal|catalog/)+ actual.renameSync(lost + '.owned-backup', lost)+ expect(readAdoptedHomes(file).homes).toEqual(add('/previous', '/first', '/second'))+ })++ it.each(['record', 'confirmation', 'unknown', 'symlink-staging', 'writable-record', 'oversized'] as const)+ ('preserves foreign or incomplete %s evidence without repair by replacement', target => {+ adopter.adopt(add('/saved'))+ if (target === 'record') actual.writeFileSync(record(0), '{ partial')+ if (target === 'confirmation') actual.writeFileSync(seal(0), 'foreign\n')+ if (target === 'unknown') actual.writeFileSync(join(file + '.adoptions', 'unknown'), 'foreign')+ if (target === 'symlink-staging') {+ actual.renameSync(join(file + '.adoptions', '.staging'), join(root, 'owned-staging'))+ actual.symlinkSync(join(root, 'owned-staging'), join(file + '.adoptions', '.staging'))+ }+ if (target === 'writable-record') actual.chmodSync(record(0), 0o666)+ if (target === 'oversized') actual.writeFileSync(record(0), 'x'.repeat(70_000))+ const before = actual.readFileSync(record(0), 'utf8')+ expect(() => readAdoptedHomes(file)).toThrow()+ expect(() => adopter.adopt(add('/new'))).toThrow()+ expect(actual.readFileSync(record(0), 'utf8')).toBe(before)+ })++ it('rechecks the whole record pool after reading its final entry', () => {+ adopter.adopt(add('/saved')); adopter.adopt(add('/later'))+ let changed = false+ vi.mocked(fs.readSync).mockImplementation((...args) => {+ const count = actual.readSync(...args as Parameters<typeof actual.readSync>)+ if (!changed && files.get(args[0]) === record(1)) {+ changed = true+ actual.writeFileSync(record(0), actual.readFileSync(record(0), 'utf8').replace('/saved', '/other'))+ }+ return count+ })+ expect(() => readAdoptedHomes(file)).toThrow('changed during its catalog read')+ })++ it('checks for a concurrent addition after the final proof pass', () => {+ adopter.adopt(add('/saved'))+ let reads = 0, appended = false+ vi.mocked(fs.readSync).mockImplementation((...args) => {+ const count = actual.readSync(...args as Parameters<typeof actual.readSync>)+ if (files.get(args[0]) === record(0) && ++reads === 2) {+ appended = true+ createHomeAdopter(file).adopt(add('/competitor'))+ }+ return count+ })+ expect(() => readAdoptedHomes(file)).toThrow('changed during its catalog read')+ expect(appended).toBe(true)+ expect(readAdoptedHomes(file).homes).toEqual(add('/saved', '/competitor'))+ })++ it('checks absent journal evidence again after a concurrent first adoption', () => {+ actual.mkdirSync(join(root, 'data'), { mode: 0o700 })+ actual.writeFileSync(file, '{"codex":[]}', { mode: 0o600 })+ let reads = 0, appended = false+ const open = vi.mocked(fs.openSync).getMockImplementation()!+ vi.mocked(fs.openSync).mockImplementation((...args) => {+ if (String(args[0]) === file && ++reads === 2) {+ appended = true+ createHomeAdopter(file).adopt(add('/competitor'))+ }+ return open(...args)+ })+ expect(() => readAdoptedHomes(file)).toThrow('changed during its catalog read')+ expect(appended).toBe(true)+ })++ it.each(['first', 'append', 'idempotent'] as const)('imports a baseline appearing during %s publication before acknowledgement', phase => {+ if (phase !== 'first') adopter.adopt(add('/saved'))+ let changed = false+ const external = () => { changed = true; actual.writeFileSync(file, '{"codex":["/external"]}', { mode: 0o600 }) }+ vi.mocked(fs.linkSync).mockImplementation((from, to) => {+ if (!changed && phase !== 'idempotent' && String(to) === record(phase === 'first' ? 0 : 1)) external()+ return actual.linkSync(from, to)+ })+ vi.mocked(fs.fsyncSync).mockImplementation(fd => {+ if (!changed && phase === 'idempotent' && files.get(fd) === file + '.confirmations') external()+ actual.fsyncSync(fd)+ })+ const result = adopter.adopt(add(phase === 'idempotent' ? '/saved' : '/requested'))+ expect(result.codex).toContain('/external')+ expect(changed).toBe(true)+ actual.unlinkSync(file)+ expect(() => readAdoptedHomes(file)).toThrow('missing its adopted legacy catalog')+ actual.writeFileSync(file, '{}', { mode: 0o600 })+ expect(readAdoptedHomes(file).homes.codex).toContain('/external')+ })++ it.each(['replacement', 'removal'] as const)('retains a completely observed baseline across a deadline hold and %s', change => {+ let probes = 0+ vi.mocked(fs.linkSync).mockImplementation((from, to) => {+ if (String(to) === record(0)) actual.writeFileSync(file, '{"codex":["/competitor"]}', { mode: 0o600 })+ return actual.linkSync(from, to)+ })+ vi.mocked(fs.lstatSync).mockImplementation(((path, options) => {+ // Let the final complete read return B, then exhaust the next rebase before B is imported.+ if (String(path) === record(127) && ++probes === 2) clock.remaining = 1+ return actual.lstatSync(path, options)+ }) as typeof fs.lstatSync)+ expect(() => adopter.adopt(add('/requested'))).toThrow('work deadline')+ expect(adopter.observations()).toEqual({ homes: add('/requested', '/competitor'), legacyRequired: true, exhausted: false })+ expect(actual.existsSync(record(1))).toBe(false)+ clock.remaining = Infinity+ vi.mocked(fs.lstatSync).mockImplementation(actual.lstatSync)+ if (change === 'removal') {+ actual.unlinkSync(file)+ expect(() => adopter.adopt(add('/requested'))).toThrow('missing its observed legacy catalog')+ }+ actual.writeFileSync(file, '{}', { mode: 0o600 })+ expect(adopter.adopt(empty()).codex).toEqual(['/requested', '/competitor'])+ expect(readAdoptedHomes(file).homes.codex).toContain('/competitor')+ actual.unlinkSync(file)+ expect(() => readAdoptedHomes(file)).toThrow('missing its adopted legacy catalog')+ })++ it('keeps observation overflow held through later retries', () => {+ actual.mkdirSync(join(root, 'data'), { mode: 0o700 })+ actual.writeFileSync(file, JSON.stringify(add('/first')), { mode: 0o600 })+ vi.mocked(fs.fsyncSync).mockImplementationOnce(() => { throw unavailable() })+ expect(() => adopter.adopt(empty())).toThrow()+ actual.writeFileSync(file, JSON.stringify(add(...Array.from({ length: 63 }, (_, n) => `/next-${n}`))))+ expect(() => adopter.adopt(empty())).toThrow('known session-home limit')+ actual.writeFileSync(file, JSON.stringify(add('/first')))+ expect(() => adopter.adopt(empty())).toThrow('retained observation limit')+ expect(adopter.observations().exhausted).toBe(true)+ expect(actual.existsSync(record(0))).toBe(false)+ })++ it.each(['journal', 'confirmations', 'both'] as const)('holds an ancestor redirected only during %s enumeration to an old valid prefix', target => {+ adopter.adopt(add('/saved'))+ const old = join(root, 'old-data'), current = join(root, 'data'), aside = join(root, 'aside')+ actual.cpSync(current, old, { recursive: true })+ adopter.adopt(add('/competitor'))+ let redirected = false+ vi.mocked(fs.opendirSync).mockImplementation((path, options) => {+ const wanted = target === 'journal' ? file + '.adoptions' : file + '.confirmations'+ if (target === 'both' ? ![file + '.adoptions', file + '.confirmations'].includes(String(path)) : String(path) !== wanted) return actual.opendirSync(path, options)+ redirected = true+ actual.renameSync(current, aside); actual.symlinkSync(old, current)+ try { return actual.opendirSync(path, options) }+ finally { actual.unlinkSync(current); actual.renameSync(aside, current) }+ })+ expect(() => readAdoptedHomes(file)).toThrow('numbered entry pool')+ expect(redirected).toBe(true)+ })++ it('holds an addition after its next slot was inspected during the final numbered pass', () => {+ adopter.adopt(add('/saved'))+ let probes = 0, appended = false+ vi.mocked(fs.lstatSync).mockImplementation(((path, options) => {+ if (String(path) === record(127) && ++probes === 2) {+ appended = true+ createHomeAdopter(file).adopt(add('/late-competitor'))+ }+ return actual.lstatSync(path, options)+ }) as typeof fs.lstatSync)+ expect(() => readAdoptedHomes(file)).toThrow('changed its directory during enumeration')+ expect(appended).toBe(true)+ })++ it.each([['relative'], ['/bad\0path'], ['/' + 'x'.repeat(4096)], Array.from({ length: 64 }, (_, n) => `/home-${n}`)].map(paths => ({ paths })))+ ('refuses an invalid request without publishing any prefix: $paths', ({ paths }) => {+ expect(() => adopter.adopt(add(...paths))).toThrow('invalid home list')+ expect(actual.existsSync(record(0))).toBe(false)+ })++ it('holds when an I/O call exhausts the shared work deadline', () => {+ vi.mocked(fs.fsyncSync).mockImplementation(fd => { actual.fsyncSync(fd); clock.now += 251 })+ expect(() => adopter.adopt(add('/held'))).toThrow('work deadline')+ expect(actual.existsSync(record(0))).toBe(false)+ })+})diff --git a/cli/src/engines/kit/homeAdoption.ts b/cli/src/engines/kit/homeAdoption.tsnew file mode 100644index 000000000..e16a9b783--- /dev/null+++ b/cli/src/engines/kit/homeAdoption.ts@@ -0,0 +1,322 @@+/** A monotone catalog: exclusive numbered publication serializes writers without a reapable lock. */+import { createHash, randomUUID } from 'node:crypto'+import { closeSync, constants, fstatSync, fsyncSync, linkSync, lstatSync, mkdirSync, openSync,+ opendirSync, readSync, unlinkSync, writeFileSync, type BigIntStats } from 'node:fs'+import { dirname, join } from 'node:path'+import { performance } from 'node:perf_hooks'+import { MAX_CATALOG_HOMES, readHomeCatalog, type HomeCatalog, type HomeCatalogRead } from './homeCatalog.js'+import { IdentityReadUnavailable } from './identityScan.js'++const MAX_RECORDS = MAX_CATALOG_HOMES * 2 + 2+const MAX_BYTES = 64 * 1024+const ENGINES = ['claude', 'codex'] as const+type FileRead = { text: string; version: string }+type RecordValue = { version: 1; previous: string | null; legacyRequired: boolean; homes: HomeCatalog }+type Entry = { path: string; digest: string; value: RecordValue; sealed: boolean }+type State = { homes: HomeCatalog; legacy: HomeCatalogRead; entries: Entry[]; directory: string; initialized: boolean; confirmations: string; marker: string; version: string }+const unavailable = (reason: string) => new IdentityReadUnavailable(`the saved engine-home adoption journal ${reason}`)+const missing = (error: unknown) => (error as NodeJS.ErrnoException).code === 'ENOENT'+const digest = (text: string) => createHash('sha256').update(text).digest('hex')+const stamp = (info: BigIntStats) => [info.dev, info.ino, info.mode, info.uid, info.size, info.mtimeNs, info.ctimeNs].join(':')+const empty = (): HomeCatalog => ({ claude: [], codex: [] })+const deadline = () => {+ const until = performance.now() + 250+ return () => { if (performance.now() > until) throw unavailable('exceeded its work deadline') }+}+function inspect(info: BigIntStats, directory = false): void {+ if (!(directory ? info.isDirectory() : info.isFile())+ || (typeof process.getuid === 'function' && info.uid !== BigInt(process.getuid()))+ || (info.mode & 0o022n)) throw unavailable('has an unsafe owner, type or write permission')+}+function read(file: string, check: () => void, max = MAX_BYTES + 1024): FileRead | null {+ check()+ let before: BigIntStats+ try { before = lstatSync(file, { bigint: true }) }+ catch (error) { if (missing(error)) return null; throw unavailable('could not be inspected') }+ inspect(before)+ if (before.size > max) throw unavailable('exceeds its byte limit')+ let fd: number | undefined+ try {+ fd = openSync(file, constants.O_RDONLY | constants.O_NONBLOCK | constants.O_NOFOLLOW)+ const opened = fstatSync(fd, { bigint: true })+ if (stamp(opened) !== stamp(before)) throw unavailable('changed before its read')+ const bytes = Buffer.alloc(Number(opened.size))+ let offset = 0, calls = 0+ while (offset < bytes.length) {+ check()+ if (++calls > 64) throw unavailable('exceeded its read-operation limit')+ const count = readSync(fd, bytes, { offset, length: bytes.length - offset, position: offset })+ if (!count) throw unavailable('ended during its read')+ offset += count+ }+ if (stamp(fstatSync(fd, { bigint: true })) !== stamp(opened)+ || stamp(lstatSync(file, { bigint: true })) !== stamp(opened)) throw unavailable('changed during its read')+ check()+ return { text: new TextDecoder('utf-8', { fatal: true }).decode(bytes), version: stamp(opened) }+ } catch (error) {+ if (error instanceof IdentityReadUnavailable) throw error+ throw unavailable('could not be read completely')+ } finally {+ if (fd !== undefined) try { closeSync(fd) } catch { throw unavailable('could not close its read descriptor') }+ }+}+function merge(...catalogs: HomeCatalog[]): HomeCatalog {+ const result = empty()+ for (const catalog of catalogs) for (const engine of ENGINES) {+ if (!catalog || !Array.isArray(catalog[engine]) || catalog[engine].length > MAX_CATALOG_HOMES+ || catalog[engine].some(home => typeof home !== 'string' || !home.startsWith('/') || home.length > 4096 || home.includes('\0'))) {+ throw unavailable('contains an invalid home list')+ }+ for (const home of catalog[engine]) if (!result[engine].includes(home)) result[engine].push(home)+ if (result[engine].length > MAX_CATALOG_HOMES) throw unavailable('reached the known session-home limit')+ }+ if (Buffer.byteLength(JSON.stringify(result)) > MAX_BYTES) throw unavailable('exceeds its combined catalog byte limit')+ return result+}+function parse(text: string, previous: string | null): RecordValue {+ let value: RecordValue+ try { value = JSON.parse(text) } catch { throw unavailable('has an incomplete record') }+ if (!value || typeof value !== 'object' || Array.isArray(value) || value.version !== 1+ || value.previous !== previous || typeof value.legacyRequired !== 'boolean'+ || Object.keys(value).sort().join(',') !== 'homes,legacyRequired,previous,version'+ || !value.homes || typeof value.homes !== 'object' || Array.isArray(value.homes)+ || Object.keys(value.homes).sort().join(',') !== 'claude,codex') throw unavailable('has an unknown record schema or broken chain')+ // A repeated property cannot hide an earlier list, including escaped key spellings.+ const keys = new Set<string>()+ for (const match of text.matchAll(/"(?:\\.|[^"\\])*"/g)) {+ let next = match.index! + match[0].length+ while (' \t\r\n'.includes(text[next] ?? '\0')) next+++ if (text[next] !== ':') continue+ const key = JSON.parse(match[0]) as string+ if (keys.has(key)) throw unavailable('contains a repeated record property')+ keys.add(key)+ }+ for (const engine of ENGINES) {+ const homes = value.homes[engine]+ if (!Array.isArray(homes) || homes.length > MAX_CATALOG_HOMES+ || homes.some(home => typeof home !== 'string' || !home.startsWith('/') || home.length > 4096 || home.includes('\0'))+ || new Set(homes).size !== homes.length) throw unavailable('contains an invalid home list')+ }+ return value+}+function names(directory: string, check: () => void, confirmations = false): string[] | null {+ check()+ let info: BigIntStats+ try { info = lstatSync(directory, { bigint: true }) }+ catch (error) { if (missing(error)) return null; throw unavailable('could not inspect its directory') }+ inspect(info, true)+ const dir = opendirSync(directory)+ const result: string[] = []+ try {+ for (;;) {+ check()+ const entry = dir.readSync()+ if (!entry) break+ if (result.length >= MAX_RECORDS * 2 + 1) throw unavailable('exceeded its entry limit')+ if (confirmations ? !/^\d{3}\.committed$/.test(entry.name)+ : entry.name !== '.staging' && !/^\d{3}\.json$/.test(entry.name)) throw unavailable('contains an unknown entry')+ if (entry.name === '.staging') inspect(lstatSync(join(directory, entry.name), { bigint: true }), true)+ result.push(entry.name)+ }+ // Directory iterators have no public descriptor in Node. Validate every possible numbered+ // slot directly, so an iterator redirected to an older copied directory cannot hide a tail.+ const suffix = confirmations ? '.committed' : '.json'+ for (let index = 0; index < MAX_RECORDS; index++) {+ check()+ const name = String(index).padStart(3, '0') + suffix+ let present = true+ try { present = lstatSync(join(directory, name), { bigint: true, throwIfNoEntry: false }) !== undefined }+ catch (error) { if (missing(error)) present = false; else throw unavailable('could not inspect a numbered entry') }+ if (present !== result.includes(name)) throw unavailable('changed its numbered entry pool')+ }+ } finally { dir.closeSync() }+ const after = lstatSync(directory, { bigint: true })+ if (stamp(after) !== stamp(info)) throw unavailable('changed its directory during enumeration')+ return result.sort()+}+function state(file: string, check: () => void, recover = false): State {+ check()+ const legacy = readHomeCatalog(file), directory = file + '.adoptions', marker = file + '.adopted', confirmations = file + '.confirmations'+ const initialNames = names(directory, check), initialConfirmations = names(confirmations, check, true), genesis = read(marker, check, 128)+ const frontier = (): void => {+ if (readHomeCatalog(file).version !== legacy.version+ || names(confirmations, check, true)?.join(',') !== initialConfirmations?.join(',')+ || names(directory, check)?.join(',') !== initialNames?.join(',')) throw unavailable('changed during its catalog read')+ }+ if (!initialNames) {+ if (genesis || initialConfirmations?.length) throw unavailable('is missing its committed directory')+ if (initialConfirmations && !recover) throw unavailable('has an incomplete initialization')+ if (read(marker, check, 128) !== null) throw unavailable('changed during its catalog read')+ frontier()+ return { homes: legacy.homes, legacy, entries: [], directory, initialized: false, confirmations, marker, version: legacy.version ?? 'new' }+ }+ if (genesis && !initialConfirmations) throw unavailable('is missing its confirmation directory')+ const files = initialNames.filter(name => name.endsWith('.json'))+ if (files.length > MAX_RECORDS || (!recover && !files.length)) throw unavailable('has an incomplete record pool')+ const entries: Entry[] = [], signatures: string[] = [], proofs = new Map<string, string | undefined>()+ proofs.set(marker, genesis?.version)+ let homes = empty(), previous: string | null = null, required = false+ for (let index = 0; index < files.length; index++) {+ check()+ if (files[index] !== `${String(index).padStart(3, '0')}.json`) throw unavailable('has a gap in its record pool')+ const path = join(directory, files[index]), source = read(path, check)+ if (!source) throw unavailable('lost a record during its read')+ const value = parse(source.text, previous), hash = digest(source.text)+ if (required && !value.legacyRequired) throw unavailable('forgot its legacy catalog')+ const merged = merge(homes, value.homes)+ if (index && JSON.stringify(merged) === JSON.stringify(homes) && required === value.legacyRequired) throw unavailable('contains a redundant record')+ homes = merged; required = value.legacyRequired+ const confirmationPath = index === 0 ? marker : join(confirmations, String(index).padStart(3, '0') + '.committed')+ const confirmation = index === 0 ? genesis : read(confirmationPath, check, 128)+ if (confirmation && confirmation.text !== hash + '\n') throw unavailable('has a mismatched durable confirmation')+ if (!confirmation && !recover) throw unavailable('has an unconfirmed adoption')+ entries.push({ path, digest: hash, value, sealed: !!confirmation })+ proofs.set(path, source.version); proofs.set(confirmationPath, confirmation?.version)+ signatures.push(source.version, confirmation?.version ?? '')+ previous = hash+ }+ if (genesis && !entries.length) throw unavailable('lost its initial record')+ const expectedConfirmations = entries.flatMap((entry, index) => index && entry.sealed ? [String(index).padStart(3, '0') + '.committed'] : [])+ if ((initialConfirmations ?? []).join(',') !== expectedConfirmations.sort().join(',')) throw unavailable('has an orphaned durable confirmation')+ if (required && legacy.text === null) throw unavailable('is missing its adopted legacy catalog')+ for (const [path, version] of proofs) {+ if (read(path, check)?.version !== version) throw unavailable('changed during its catalog read')+ }+ // Immutable records cannot change in a cooperating writer; a new record can appear during this pass.+ // Re-observe pool membership last, including the absent-directory case above.+ frontier()+ check()+ return { homes: merge(homes, legacy.homes), legacy, entries, directory, initialized: true, confirmations, marker,+ version: digest(JSON.stringify([legacy.version, genesis?.version, signatures])) }+}++/** Fresh baseline plus every durably committed addition. A partial journal is never an empty catalog. */+export function readAdoptedHomes(file: string): HomeCatalogRead {+ try {+ const found = state(file, deadline())+ return { homes: found.homes, text: JSON.stringify(found.homes), version: found.version }+ } catch (error) {+ if (error instanceof IdentityReadUnavailable) throw error+ throw unavailable('could not be read completely')+ }+}+function syncDirectory(directory: string, check: () => void, ancestor = false): void {+ check()+ const fd = openSync(directory, constants.O_RDONLY | constants.O_DIRECTORY | (ancestor ? 0 : constants.O_NOFOLLOW))+ try {+ const info = fstatSync(fd, { bigint: true })+ if (ancestor) { if (!info.isDirectory()) throw unavailable('has an unavailable ancestor directory') }+ else inspect(info, true)+ fsyncSync(fd); check()+ }+ finally { closeSync(fd) }+}+function directory(path: string, check: () => void, depth = 0): void {+ check()+ if (depth > 32) throw unavailable('exceeded its parent-directory limit')+ try { inspect(lstatSync(path, { bigint: true }), true) }+ catch (error) {+ if (!missing(error)) throw error+ directory(dirname(path), check, depth + 1)+ try { mkdirSync(path, { mode: 0o700 }) }+ catch (error) { if ((error as NodeJS.ErrnoException).code !== 'EEXIST') throw error }+ }+ inspect(lstatSync(path, { bigint: true }), true)+ // Flush each newly created name before creating anything beneath it. A retry also completes a failed parent flush.+ syncDirectory(dirname(path), check, true)+}+function publish(path: string, text: string, staging: string, check: () => void): boolean {+ check()+ const temporary = join(staging, randomUUID())+ const fd = openSync(temporary, constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | constants.O_NOFOLLOW, 0o600)+ try {+ try { writeFileSync(fd, text); fsyncSync(fd); check() }+ finally { closeSync(fd) }+ try { linkSync(temporary, path) }+ catch (error) { if ((error as NodeJS.ErrnoException).code === 'EEXIST') return false; throw error }+ return true+ } finally { unlinkSync(temporary) }+}+function seal(entry: Entry, index: number, found: State, staging: string, check: () => void): void {+ // Another writer may finish a crashed writer's complete immutable record. No lock or partial slot is reaped.+ const source = read(entry.path, check)+ if (!source || digest(source.text) !== entry.digest) throw unavailable('changed before durability confirmation')+ const fd = openSync(entry.path, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK)+ try {+ if (stamp(fstatSync(fd, { bigint: true })) !== source.version) throw unavailable('changed before its durable flush')+ fsyncSync(fd)+ } finally { closeSync(fd) }+ syncDirectory(found.directory, check)+ // Confirmations live outside the journal: losing its newest record cannot look like an older complete pool.+ const marker = index ? join(found.confirmations, String(index).padStart(3, '0') + '.committed') : found.marker+ publish(marker, entry.digest + '\n', staging, check)+ if (read(marker, check, 128)?.text !== entry.digest + '\n') throw unavailable('changed its durable confirmation')+ syncDirectory(dirname(marker), check)+}++/** Positive observations survive a held reply. They constrain retries, never authorize session roots. */+export function createHomeAdopter(file: string) {+ let observed = empty(), legacyObserved = false, exhausted = false+ function adopt(additions: HomeCatalog): HomeCatalog {+ const check = deadline()+ try {+ if (exhausted) throw unavailable('exhausted its retained observation limit')+ merge(additions)+ const remember = (found: State): void => {+ legacyObserved ||= found.legacy.text !== null+ try { observed = merge(observed, found.homes) }+ catch (error) { exhausted = true; throw error }+ }+ const confirmed = (): HomeCatalog | null => {+ const final = state(file, check)+ remember(final)+ const recorded = merge(...final.entries.map(entry => entry.value.homes))+ if (ENGINES.some(engine => observed[engine].some(home => !recorded[engine].includes(home)))+ || (legacyObserved && !final.entries.at(-1)?.value.legacyRequired)) return null+ return final.homes+ }+ for (let attempt = 0; attempt < 4; attempt++) {+ const found = state(file, check, true)+ remember(found)+ if (legacyObserved && found.legacy.text === null) throw unavailable('is missing its observed legacy catalog')+ if (!found.entries.length && !additions.claude.length && !additions.codex.length && !legacyObserved) {+ if (found.initialized) throw unavailable('has no complete initialization intent to recover')+ return found.homes+ }+ directory(dirname(file), check); directory(found.directory, check); directory(found.confirmations, check)+ const staging = join(found.directory, '.staging'); directory(staging, check)+ syncDirectory(dirname(file), check)+ for (const [index, entry] of found.entries.entries()) if (!entry.sealed) seal(entry, index, found, staging, check)+ // A previous reply may have failed after publication but before the directory flush.+ // Confirmation on disk is not permission for this writer to skip its durability obligation.+ syncDirectory(found.directory, check); syncDirectory(found.confirmations, check); syncDirectory(dirname(file), check)+ const wanted = merge(found.homes, observed, additions)+ const prior = found.entries.at(-1), required = !!prior?.value.legacyRequired || legacyObserved+ const recorded = merge(...found.entries.map(entry => entry.value.homes))+ const extra = Object.fromEntries(ENGINES.map(engine => [engine, wanted[engine].filter(home => !recorded[engine].includes(home))])) as HomeCatalog+ if (prior && !extra.claude.length && !extra.codex.length && required === prior.value.legacyRequired) {+ const done = confirmed()+ if (done) return done+ continue+ }+ if (found.entries.length >= MAX_RECORDS) throw unavailable('reached its record limit')+ const value: RecordValue = { version: 1, previous: prior?.digest ?? null, legacyRequired: required, homes: extra }+ const text = JSON.stringify(value) + '\n', path = join(found.directory, String(found.entries.length).padStart(3, '0') + '.json')+ if (!publish(path, text, staging, check)) continue+ seal({ path, value, digest: digest(text), sealed: false }, found.entries.length, found, staging, check)+ const done = confirmed()+ if (done) return done+ }+ throw unavailable('is busy with another adoption')+ } catch (error) {+ if (error instanceof IdentityReadUnavailable) throw error+ throw unavailable('could not confirm durable adoption')+ }+ }+ return {+ adopt,+ observations(): { homes: HomeCatalog; legacyRequired: boolean; exhausted: boolean } {+ return { homes: { claude: [...observed.claude], codex: [...observed.codex] }, legacyRequired: legacyObserved, exhausted }+ },+ }+}diff --git a/cli/src/engines/kit/homeCatalog.spec.ts b/cli/src/engines/kit/homeCatalog.spec.tsindex e48815e96..9a2f25783 100644--- a/cli/src/engines/kit/homeCatalog.spec.ts+++ b/cli/src/engines/kit/homeCatalog.spec.ts@@ -10,7 +10,7 @@ vi.mock('node:perf_hooks', async original => ({ ...await original<object>(), pervi.mock('node:fs', async original => {const actual = await original<typeof import('node:fs')>()return { ...actual, lstatSync: vi.fn(actual.lstatSync), openSync: vi.fn(actual.openSync),- readSync: vi.fn(actual.readSync), fstatSync: vi.fn(actual.fstatSync), closeSync: vi.fn(actual.closeSync), renameSync: vi.fn(actual.renameSync) }+ readSync: vi.fn(actual.readSync), fstatSync: vi.fn(actual.fstatSync), closeSync: vi.fn(actual.closeSync), linkSync: vi.fn(actual.linkSync) }})vi.mock('node:fs/promises', async original => {const actual = await original<typeof import('node:fs/promises')>()@@ -36,7 +36,7 @@ function transcript(home: string): string {beforeEach(async () => {actual = await vi.importActual<typeof fs>('node:fs')vi.mocked(asyncFs.opendir).mockReset().mockImplementation((await vi.importActual<typeof asyncFs>('node:fs/promises')).opendir)- for (const name of ['lstatSync', 'openSync', 'readSync', 'fstatSync', 'closeSync', 'renameSync'] as const) {+ for (const name of ['lstatSync', 'openSync', 'readSync', 'fstatSync', 'closeSync', 'linkSync'] as const) {vi.mocked(fs[name]).mockReset().mockImplementation(actual[name] as never)}clock.now = 0@@ -80,7 +80,7 @@ describe('fresh complete native home evidence', () => {expect(homes.movedHomes('codex')).toEqual([])await expect(repair.findResumedTranscript('codex', ID)).resolves.toBe(own)write(text); actual.utimesSync(catalog(), before.atime, new Date('2026-10-09T00:00:00Z'))- expect(homes.movedHomes('codex')).toEqual([]) // This compatibility behavior is intentionally not the new authority.+ expect(homes.movedHomes('codex')).toEqual([path('moved')]) // The durable catalog reader now refreshes legacy callers too.await expect(repair.findResumedTranscript('codex', ID)).rejects.toThrow('more than one transcript')})@@ -157,14 +157,15 @@ describe('fresh complete native home evidence', () => {} finally { Array.prototype[Symbol.iterator] = iterator }})- it('does not exclude a known competitor after legacy adoption failed to persist', async () => {+ it('does not exclude a pending competitor after durable adoption failed to persist', async () => {transcript(path('codex')); transcript(path('unsaved'))write({ codex: [] })- vi.mocked(fs.renameSync).mockImplementation(() => { throw new Error('fixture disk unavailable') })- expect(homes.adoptHomes({ CODEX_HOME: path('unsaved') })).toMatchObject({ codex: path('unsaved') })+ vi.mocked(fs.linkSync).mockImplementation(() => { throw new Error('fixture disk unavailable') })+ expect(() => homes.adoptHomes({ CODEX_HOME: path('unsaved') })).toThrow('durable adoption')expect(JSON.parse(actual.readFileSync(catalog(), 'utf8'))).toEqual({ codex: [] })- await expect(repair.findResumedTranscript('codex', ID)).rejects.toThrow('previously observed or unsaved home')- write({ codex: [path('unsaved')] })+ await expect(repair.findResumedTranscript('codex', ID)).rejects.toThrow(/incomplete record pool|previously observed or unsaved home/)+ vi.mocked(fs.linkSync).mockImplementation(actual.linkSync)+ homes.confirmHomes({ CODEX_HOME: path('unsaved') })await expect(repair.findResumedTranscript('codex', ID)).rejects.toThrow('more than one transcript')})diff --git a/cli/src/engines/kit/resumeRepair.spec.ts b/cli/src/engines/kit/resumeRepair.spec.tsindex 25579231a..0e7a45dc3 100644--- a/cli/src/engines/kit/resumeRepair.spec.ts+++ b/cli/src/engines/kit/resumeRepair.spec.ts@@ -1,3 +1,4 @@+import { clearEngineHomeFixture } from '../../testing/engineHomeFixture.js'import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'import { constants as bufferConstants } from 'node:buffer'import { createHash } from 'node:crypto'@@ -206,7 +207,7 @@ describe('preparing a stopped Codex session for resume', () => {expect(() => fresh.prepareResume({ ...source(), codexHome: null, transcriptPath: stray })).toThrow('outside the session profile')} finally {vi.unstubAllEnvs()- rmSync(join(process.env.ADAPTER_DATA_DIR!, 'engine-homes.json'), { force: true })+ clearEngineHomeFixture(process.env.ADAPTER_DATA_DIR!)homes.resetEngineHomes()}})@@ -235,3 +236,6 @@ describe('preparing a stopped Codex session for resume', () => {expect(prepareCodexResume({ ...source(), transcriptPath: null })).toEqual({ repairedItems: 0 })})})++// Filesystem durability deadlines are exercised separately from these deterministic fixture reads.+vi.mock('node:perf_hooks', async original => ({ ...await original<object>(), performance: { now: () => 0 } }))diff --git a/cli/src/engines/sessionStore.golden.spec.ts b/cli/src/engines/sessionStore.golden.spec.tsindex 898e29bed..02f5449a4 100644--- a/cli/src/engines/sessionStore.golden.spec.ts+++ b/cli/src/engines/sessionStore.golden.spec.ts@@ -1,3 +1,4 @@+import { clearEngineHomeFixture } from '../testing/engineHomeFixture.js'import { nativeConversationFixture } from '../testing/nativeConversationEvidence.js'/*** Where Claude Code and Codex keep their sessions, and what core reads there, answer for answer: recorded@@ -29,6 +30,8 @@ import { afterAll, beforeAll, describe, expect, it, vi } from 'vitest'import type { RegisteredSession } from '../lib/registry.js'const fixtureClock = vi.hoisted(() => ({ root: '', now: Date.parse('2026-10-09T00:00:00Z') }))+vi.mock('node:perf_hooks', async original => ({ ...await original<object>(), performance: { now: () => 0 } }))+vi.mock('../lib/bootId.js', async original => ({ ...await original<object>(), currentBootId: () => 'fixture-boot', bootChanged: () => false }))vi.mock('../lib/processLiveness.js', async original => ({ ...await original<object>(),processLockIdentity: () => ({ startMarker: 'fixture-start', generationMarker: 'fixture-generation' }), lockOwnerAlive: () => true,@@ -162,13 +165,13 @@ afterAll(() => {/** The person's moved homes: adopted, so remembered in the data folder, as the core does at start. */function adoptMoved(): unknown {m.homes.resetEngineHomes()- rmSync(join(root, 'data', 'engine-homes.json'), { force: true })+ clearEngineHomeFixture(join(root, 'data'))return m.homes.adoptEngineHomes({ CLAUDE_CONFIG_DIR: join(root, 'moved-claude'), CODEX_HOME: join(root, 'moved-codex') },{ claudeHome: join(root, 'claude'), codexHome: join(root, 'codex') })}function forgetMoved(): void {m.homes.resetEngineHomes()- rmSync(join(root, 'data', 'engine-homes.json'), { force: true })+ clearEngineHomeFixture(join(root, 'data'))}// --------------------------------------------------------------------------------------------- homes@@ -191,7 +194,7 @@ async function homeCases(): Promise<Record<string, unknown>> {],sessionClaudeHome: [h.sessionClaudeHome({ transcriptPath: paths.claudeMoved }), h.sessionClaudeHome({ transcriptPath: paths.claudeA }),h.sessionClaudeHome({ transcriptPath: paths.outside }), h.sessionClaudeHome({})],- saved: existsSync(join(root, 'data', 'engine-homes.json')) ? readFileSync(join(root, 'data', 'engine-homes.json'), 'utf8') : null,+ saved: (() => { h.resetEngineHomes(); const catalog = h.movedEngineHomes(); return Object.values(catalog).some(homes => homes.length) ? JSON.stringify(catalog) + '\n' : null })(),})forgetMoved()cases['none moved'] = norm(probe())diff --git a/cli/src/engines/transcriptReads.golden.spec.ts b/cli/src/engines/transcriptReads.golden.spec.tsindex 075342610..881e41e28 100644--- a/cli/src/engines/transcriptReads.golden.spec.ts+++ b/cli/src/engines/transcriptReads.golden.spec.ts@@ -1,3 +1,4 @@+import { clearEngineHomeFixture } from '../testing/engineHomeFixture.js'/*** What core and the readers make of Claude Code's and Codex's conversations on disk, answer for answer: recorded* from the code as it stood before their adoption, activity and paging rules became declared data the kit applies,@@ -93,13 +94,13 @@ afterAll(() => {function adoptMoved(): void {m.homes.resetEngineHomes()- rmSync(join(root, 'data', 'engine-homes.json'), { force: true })+ clearEngineHomeFixture(join(root, 'data'))m.homes.adoptEngineHomes({ CLAUDE_CONFIG_DIR: join(root, 'moved-claude'), CODEX_HOME: join(root, 'moved-codex') },{ claudeHome: join(root, 'claude'), codexHome: join(root, 'codex') })}function forgetMoved(): void {m.homes.resetEngineHomes()- rmSync(join(root, 'data', 'engine-homes.json'), { force: true })+ clearEngineHomeFixture(join(root, 'data'))}// --------------------------------------------------------------------------------------------- adoption@@ -598,3 +599,6 @@ describe('core reads Claude Code\'s and Codex\'s conversations as it did beforeexpect(text).not.toMatch(/\/Users\/|\/home\/runner/)})})++// Filesystem durability deadlines are exercised separately from these deterministic fixture reads.+vi.mock('node:perf_hooks', async original => ({ ...await original<object>(), performance: { now: () => 0 } }))diff --git a/cli/src/lib/__fixtures__/engine-home-adoption.golden.json b/cli/src/lib/__fixtures__/engine-home-adoption.golden.jsonnew file mode 100644index 000000000..a8120fc47--- /dev/null+++ b/cli/src/lib/__fixtures__/engine-home-adoption.golden.json@@ -0,0 +1,103 @@+{+ "new:roots": [+ [+ "<root>/CLAUDE_CONFIG_DIR/projects"+ ],+ [+ "<root>/CODEX_HOME/sessions"+ ]+ ],+ "new:empty-environment": {+ "claude": null,+ "codex": null+ },+ "adopt:first": {+ "claude": "<root>/claude-first",+ "codex": "<root>/codex-first"+ },+ "adopt:catalog": {+ "claude": [+ "<root>/claude-first"+ ],+ "codex": [+ "<root>/codex-first"+ ]+ },+ "adopt:repeat": {+ "claude": null,+ "codex": null+ },+ "adopt:roots": [+ [+ "<root>/CLAUDE_CONFIG_DIR/projects",+ "<root>/claude-first/projects"+ ],+ [+ "<root>/CODEX_HOME/sessions",+ "<root>/codex-first/sessions"+ ]+ ],+ "adopt:second": {+ "claude": null,+ "codex": "<root>/codex-second"+ },+ "restart:known": {+ "claude": [+ "<root>/claude-first"+ ],+ "codex": [+ "<root>/codex-first",+ "<root>/codex-second"+ ]+ },+ "restart:repeat": {+ "claude": null,+ "codex": null+ },+ "merge:external": {+ "claude": [+ "<root>/claude-first",+ "<root>/external-claude"+ ],+ "codex": [+ "<root>/codex-first",+ "<root>/codex-second"+ ]+ },+ "merge:adopt": {+ "claude": "<root>/claude-second",+ "codex": null+ },+ "merge:catalog": {+ "claude": [+ "<root>/claude-first",+ "<root>/external-claude",+ "<root>/claude-second"+ ],+ "codex": [+ "<root>/codex-first",+ "<root>/codex-second"+ ]+ },+ "own:explicit-default": {+ "claude": null,+ "codex": null+ },+ "invalid:relative": {+ "claude": null,+ "codex": null+ },+ "restart:complete": [+ [+ "<root>/CLAUDE_CONFIG_DIR/projects",+ "<root>/claude-first/projects",+ "<root>/external-claude/projects",+ "<root>/claude-second/projects"+ ],+ [+ "<root>/CODEX_HOME/sessions",+ "<root>/codex-first/sessions",+ "<root>/codex-second/sessions"+ ]+ ]+}diff --git a/cli/src/lib/agentFrame.spec.ts b/cli/src/lib/agentFrame.spec.tsindex 9d3f7684c..813f48d2d 100644--- a/cli/src/lib/agentFrame.spec.ts+++ b/cli/src/lib/agentFrame.spec.ts@@ -21,6 +21,11 @@ function session(grid: RegisteredSession['grid'], codexHome: RegisteredSession['const assignment = { baseUrl: 'https://grid.autonomous.ai/grid-abc/relay', model: 'DeepSeek-V4-Flash-0731' }describe('agentFrame', () => {+ it('exposes an unavailable identity reason while retaining the current session', async () => {+ const row = { ...session(null), identityHold: 'Waiting for the saved session homes.' }+ expect(await agentFrame(row, { selectedModel: null, terminalAvailable: true }))+ .toMatchObject({ sessionId: 's1', status: 'active', identityHold: row.identityHold })+ })it('carries only the owning machine’s cached token snapshot, including a measured zero', async () => {const context = { selectedModel: null, terminalAvailable: true }const usage = { totalTokens: 0, updatedAt: '2026-09-22T16:00:00Z' }diff --git a/cli/src/lib/agentFrame.ts b/cli/src/lib/agentFrame.tsindex 9a3e37b86..8a712c2d6 100644--- a/cli/src/lib/agentFrame.ts+++ b/cli/src/lib/agentFrame.ts@@ -66,6 +66,7 @@ export type AgentFrame = {closePlan: { state: 'waiting' | 'failed'; detail?: string } | nullcloseSupported: booleanlaunch: NonNullable<RegisteredSession['launch']>+ identityHold?: stringcreatedAt: stringupdatedAt: string/**@@ -216,6 +217,7 @@ export async function agentFrame(closePlan: s.closePlan ? { state: s.closePlan.state, ...(s.closePlan.detail ? { detail: s.closePlan.detail } : {}) } : null,closeSupported: true,launch: s.launch ?? { state: 'ready' },+ ...(s.identityHold ? { identityHold: s.identityHold } : {}),createdAt: new Date(s.registeredAt).toISOString(),updatedAt: new Date(updatedAt).toISOString(),// Null, never omitted, for the reason the module doc gives: a push without the key would erasediff --git a/cli/src/lib/engineHomeAdoption.golden.spec.ts b/cli/src/lib/engineHomeAdoption.golden.spec.tsnew file mode 100644index 000000000..5376a8e57--- /dev/null+++ b/cli/src/lib/engineHomeAdoption.golden.spec.ts@@ -0,0 +1,78 @@+/** Saved-home adoption answers from main, before making its writer durable and retryable. */+import { mkdirSync, mkdtempSync, readFileSync, realpathSync, renameSync, rmSync, writeFileSync } from 'node:fs'+import { tmpdir } from 'node:os'+import { join } from 'node:path'+import { fileURLToPath } from 'node:url'+import { afterAll, beforeAll, expect, it, vi } from 'vitest'++vi.mock('./loginShellEnv.js', () => ({ loginShellEnvironment: () => ({}) }))+vi.mock('node:perf_hooks', async original => ({ ...await original<object>(), performance: { now: () => 0 } }))+vi.mock('node:child_process', () => {+ const forbidden = () => { throw Error('Host binaries are forbidden in the adoption golden') }+ return { exec: forbidden, execSync: forbidden, execFile: forbidden, execFileSync: forbidden,+ spawn: forbidden, spawnSync: forbidden, fork: forbidden }+})+const GOLDEN = fileURLToPath(new URL('./__fixtures__/engine-home-adoption.golden.json', import.meta.url))+const RECORD = process.env.RECORD_ENGINE_HOME_ADOPTION_GOLDEN === '1'+const platform = Object.getOwnPropertyDescriptor(process, 'platform')!+let root = '', homes: typeof import('./engineHomes.js'), expected: Record<string, unknown>+const captured: Record<string, unknown> = {}+const path = (...parts: string[]) => join(root, ...parts)+const catalog = () => path('ADAPTER_DATA_DIR', 'engine-homes.json')+// Replay through a fresh reader: the physical persistence format is not a public catalog answer.+const durableCatalog = () => { homes.resetEngineHomes(); return homes.movedEngineHomes() }+function check(key: string, value: unknown): void {+ captured[key] = JSON.parse(JSON.stringify(value ?? null).split(root).join('<root>'))+ if (!RECORD) expect({ key, value: captured[key] }).toEqual({ key, value: expected[key] })+}+beforeAll(async () => {+ root = realpathSync(mkdtempSync(join(tmpdir(), 'engine-home-adoption-golden-')))+ for (const name of ['HOME', 'ADAPTER_DATA_DIR', 'ADAPTER_RUNTIME_DIR', 'CODEX_HOME', 'CLAUDE_CONFIG_DIR',+ 'XDG_CONFIG_HOME', 'XDG_DATA_HOME']) {+ mkdirSync(path(name), { recursive: true, mode: 0o700 })+ vi.stubEnv(name, path(name))+ }+ vi.stubEnv('CLAUDE_PROJECTS_DIR', path('CLAUDE_CONFIG_DIR', 'projects'))+ vi.stubEnv('TZ', 'UTC')+ Object.defineProperty(process, 'platform', { ...platform, value: 'linux' })+ vi.useFakeTimers({ toFake: ['Date'], now: Date.parse('2026-10-10T00:00:00Z') })+ vi.resetModules()+ homes = await import('./engineHomes.js')+ expected = RECORD ? {} : JSON.parse(readFileSync(GOLDEN, 'utf8'))+})+afterAll(() => {+ if (RECORD) writeFileSync(GOLDEN, JSON.stringify(captured, null, 2) + '\n')+ homes?.resetEngineHomes(); vi.useRealTimers(); vi.unstubAllEnvs()+ Object.defineProperty(process, 'platform', platform)+ rmSync(root, { recursive: true, force: true })+})++it('preserves adoption results, idempotence, merges and restart discovery', () => {+ check('new:roots', [homes.nativeSessionRoots('claude'), homes.nativeSessionRoots('codex')])+ check('new:empty-environment', homes.adoptHomes({}))+ const claude = path('claude-first'), codex = path('codex-first')+ check('adopt:first', homes.adoptHomes({ CLAUDE_CONFIG_DIR: ` ${claude}/ `, CODEX_HOME: codex }))+ check('adopt:catalog', durableCatalog())+ check('adopt:repeat', homes.adoptHomes({ CLAUDE_CONFIG_DIR: claude, CODEX_HOME: `${codex}/` }))+ check('adopt:roots', [homes.nativeSessionRoots('claude'), homes.nativeSessionRoots('codex')])+ const second = path('codex-second')+ check('adopt:second', homes.adoptHomes({ CODEX_HOME: second }))+ homes.resetEngineHomes()+ check('restart:known', homes.movedEngineHomes())+ check('restart:repeat', homes.adoptHomes({ CODEX_HOME: second }))+ const external = path('external-claude')+ const saved = durableCatalog()+ saved.claude.push(external)+ writeFileSync(`${catalog()}.external`, JSON.stringify(saved), { mode: 0o600 })+ renameSync(`${catalog()}.external`, catalog())+ check('merge:external', homes.movedEngineHomes())+ check('merge:adopt', homes.adoptHomes({ CLAUDE_CONFIG_DIR: path('claude-second') }))+ check('merge:catalog', durableCatalog())+ check('own:explicit-default', homes.adoptHomes({ CODEX_HOME: path('explicit-default') }, { codex: path('explicit-default') }))+ check('invalid:relative', homes.adoptHomes({ CODEX_HOME: 'relative', CLAUDE_CONFIG_DIR: '~/relative' }))+ homes.resetEngineHomes()+ check('restart:complete', [homes.nativeSessionRoots('claude'), homes.nativeSessionRoots('codex')])+})+it('replays every recorded observation', () => {+ if (!RECORD) expect(Object.keys(captured).sort()).toEqual(Object.keys(expected).sort())+})diff --git a/cli/src/lib/engineHomes.golden.spec.ts b/cli/src/lib/engineHomes.golden.spec.tsindex c21a84855..6c41ed394 100644--- a/cli/src/lib/engineHomes.golden.spec.ts+++ b/cli/src/lib/engineHomes.golden.spec.ts@@ -7,6 +7,7 @@ import { fileURLToPath } from 'node:url'import { afterAll, beforeAll, expect, it, vi } from 'vitest'const shell = vi.hoisted(() => ({ environment: {} as NodeJS.ProcessEnv }))+vi.mock('node:perf_hooks', async original => ({ ...await original<object>(), performance: { now: () => 0 } }))vi.mock('./loginShellEnv.js', () => ({ loginShellEnvironment: () => shell.environment }))vi.mock('node:child_process', () => {const forbidden = () => { throw new Error('Host binaries are forbidden in this golden') }@@ -60,7 +61,8 @@ it('records declared roots, durable adoption, profiles and bound-home selection'}const claude = path('moved-claude'), codex = path('moved-codex'), profile = path('profile')check('adopt:both', homes.adoptHomes({ CLAUDE_CONFIG_DIR: ` ${claude}/ `, CODEX_HOME: `${codex}/` }))- check('adopt:saved', JSON.parse(readFileSync(saved(), 'utf8')))+ homes.resetEngineHomes()+ check('adopt:saved', homes.movedEngineHomes())check('adopt:duplicate', homes.adoptHomes({ CLAUDE_CONFIG_DIR: claude, CODEX_HOME: codex }))check('adopt:roots', [homes.nativeSessionRoots('claude'), homes.nativeSessionRoots('codex')])check('adopt:home-roots', [homes.homeRoots('CODEX_HOME'), homes.homeRoots('CLAUDE_PROJECTS_DIR')])diff --git a/cli/src/lib/engineHomes.spec.ts b/cli/src/lib/engineHomes.spec.tsindex de3ac8bc5..7e72cf69c 100644--- a/cli/src/lib/engineHomes.spec.ts+++ b/cli/src/lib/engineHomes.spec.ts@@ -1,3 +1,4 @@+import * as fs from 'node:fs'import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'import { homedir, tmpdir } from 'node:os'import { dirname, join } from 'node:path'@@ -6,25 +7,39 @@ import { env } from '../config/env.js'import {adoptEngineHomes, adoptHomes, claudeProjectsRoots, codexHomeRoots, launchClaudeConfigDir, launchCodexHome, movedEngineHomes, movedHomes,ownHomeOf, profileEnvironment, resetEngineHomes, sessionClaudeHome, sessionCodexHome, sessionFolderOf, sessionRoots,+ confirmHomes, durableEngineHomes, nativeSessionRoots, recoverEngineHomes, engineHomeSnapshot,} from './engineHomes.js'// The login shell's environment, as the daemon captured it at start-up: none, unless a test says so.const shell = vi.hoisted(() => ({ env: {} as NodeJS.ProcessEnv }))vi.mock('./loginShellEnv.js', () => ({ loginShellEnvironment: () => shell.env }))+const clock = vi.hoisted(() => ({ remaining: Infinity }))+vi.mock('node:perf_hooks', async original => ({ ...await original<object>(), performance: { now: () => --clock.remaining < 0 ? 251 : 0 } }))+vi.mock('node:fs', async original => {+ const actual = await original<typeof fs>()+ return { ...actual, linkSync: vi.fn(actual.linkSync), lstatSync: vi.fn(actual.lstatSync) }+})const saved = () => join(env.ADAPTER_DATA_DIR, 'engine-homes.json')const defaults = { claudeHome: '/home/someone/.claude', codexHome: '/home/someone/.codex' }describe('the homes the person moved', () => {let root: string- beforeEach(() => {+ let originalData: string+ beforeEach(async () => {+ clock.remaining = Infinity+ const actual = await vi.importActual<typeof fs>('node:fs')+ vi.mocked(fs.linkSync).mockReset().mockImplementation(actual.linkSync)+ vi.mocked(fs.lstatSync).mockReset().mockImplementation(actual.lstatSync)root = mkdtempSync(join(tmpdir(), 'engine-homes-'))- rmSync(saved(), { force: true })+ originalData = env.ADAPTER_DATA_DIR+ env.ADAPTER_DATA_DIR = join(root, 'data')+ mkdirSync(env.ADAPTER_DATA_DIR, { mode: 0o700 })resetEngineHomes()})afterEach(() => {rmSync(root, { recursive: true, force: true })- rmSync(saved(), { force: true })+ env.ADAPTER_DATA_DIR = originalDataresetEngineHomes()})@@ -53,7 +68,7 @@ describe('the homes the person moved', () => {const claude = join(root, 'claude-work'), codex = join(root, 'codex-work')adoptEngineHomes({ CLAUDE_CONFIG_DIR: claude }, defaults)adoptEngineHomes({ CODEX_HOME: codex }, defaults)- expect(JSON.parse(readFileSync(saved(), 'utf8'))).toEqual({ claude: [claude], codex: [codex] })+ expect(durableEngineHomes()).toEqual({ claude: [claude], codex: [codex] })resetEngineHomes()expect(claudeProjectsRoots('/own')).toEqual(['/own', join(claude, 'projects')])resetEngineHomes()@@ -77,21 +92,74 @@ describe('the homes the person moved', () => {expect(codexHomeRoots('/default')).toEqual(['/default', join(root, 'previous'), join(root, 'new-login')])})- it('still adopts when the data folder cannot be written; the next boot adopts again', () => {+ it('holds an unwritable adoption without exposing it as a usable root, then confirms the same request after recovery', () => {const blocked = join(root, 'blocked')writeFileSync(blocked, 'a file where the folder should be')const before = env.ADAPTER_DATA_DIRenv.ADAPTER_DATA_DIR = join(blocked, 'data')try {const claude = join(root, 'claude-work')+ expect(() => adoptEngineHomes({ CLAUDE_CONFIG_DIR: claude }, defaults)).toThrow(/held/)+ expect(claudeProjectsRoots('/own')).toEqual(['/own'])+ expect(() => nativeSessionRoots('codex')).toThrow(/held/)+ rmSync(blocked)+ mkdirSync(env.ADAPTER_DATA_DIR, { recursive: true, mode: 0o700 })+ expect(() => nativeSessionRoots('codex')).toThrow('previously observed or unsaved home')expect(adoptEngineHomes({ CLAUDE_CONFIG_DIR: claude }, defaults)).toEqual({ claude, codex: null })expect(claudeProjectsRoots('/own')).toEqual(['/own', join(claude, 'projects')])+ expect(confirmHomes({ CLAUDE_CONFIG_DIR: claude })).toEqual({ claude, codex: null })} finally {env.ADAPTER_DATA_DIR = before}mkdirSync(root, { recursive: true })})+ it('shares held observations with native roots and empty-environment recovery', async () => {+ const actual = await vi.importActual<typeof fs>('node:fs')+ const file = saved(), requested = join(root, 'requested'), competitor = join(root, 'competitor')+ let probes = 0+ vi.mocked(fs.linkSync).mockImplementation((from, to) => {+ if (String(to).endsWith('/000.json')) actual.writeFileSync(file, JSON.stringify({ codex: [competitor] }), { mode: 0o600 })+ return actual.linkSync(from, to)+ })+ vi.mocked(fs.lstatSync).mockImplementation(((path, options) => {+ if (String(path) === file + '.adoptions/127.json' && ++probes === 2) clock.remaining = 1+ return actual.lstatSync(path, options)+ }) as typeof fs.lstatSync)+ expect(() => confirmHomes({ CODEX_HOME: requested })).toThrow('work deadline')+ clock.remaining = Infinity+ vi.mocked(fs.lstatSync).mockImplementation(actual.lstatSync)+ actual.writeFileSync(file, '{}', { mode: 0o600 })+ expect(movedHomes('codex')).not.toContain(competitor)+ expect(() => nativeSessionRoots('codex')).toThrow('previously observed or unsaved home')+ expect(recoverEngineHomes().codex).toEqual([requested, competitor])+ expect(nativeSessionRoots('codex')).toContain(join(competitor, 'sessions'))+ })++ it('does not transfer catalog observations or pending requests into another data directory', () => {+ adoptHomes({ CODEX_HOME: join(root, 'first-catalog-home') })+ env.ADAPTER_DATA_DIR = join(root, 'second-catalog')+ mkdirSync(env.ADAPTER_DATA_DIR, { mode: 0o700 })+ expect(movedHomes('codex')).toEqual([])+ expect(nativeSessionRoots('codex')).toEqual([join(env.CODEX_HOME, 'sessions')])+ expect(confirmHomes({ CODEX_HOME: join(root, 'second-catalog-home') }).codex).toBe(join(root, 'second-catalog-home'))+ expect(recoverEngineHomes().codex).toEqual([join(root, 'second-catalog-home')])+ })++ it('requires a fresh final proof for an explicit immutable batch snapshot', () => {+ const before = join(root, 'before'), after = join(root, 'after')+ adoptHomes({ CODEX_HOME: before })+ const snapshot = engineHomeSnapshot()+ expect(() => snapshot.homes.codex.push(after)).toThrow(TypeError)+ expect(sessionRoots('codex', undefined, snapshot)).toContain(join(before, 'sessions'))+ expect(sessionCodexHome({ transcriptPath: join(before, 'sessions', 'thread.jsonl') }, snapshot)).toBe(before)+ writeFileSync(saved(), JSON.stringify({ codex: [after] }), { mode: 0o600 })+ expect(() => snapshot.verify()).toThrow('changed during the operation')+ const fresh = engineHomeSnapshot()+ expect(fresh.homes.codex).toEqual([before, after])+ expect(() => fresh.verify()).not.toThrow()+ })+it('a bound conversation stays in its known home even when the current shell changes or a service has no shell cache', () => {const home = join(root, 'previous-login'), current = join(root, 'current-login')adoptEngineHomes({ CODEX_HOME: home }, defaults)diff --git a/cli/src/lib/engineHomes.ts b/cli/src/lib/engineHomes.tsindex 9ad9fa1fa..6793c2198 100644--- a/cli/src/lib/engineHomes.ts+++ b/cli/src/lib/engineHomes.ts@@ -13,12 +13,13 @@* it is the engine's own (`registry.validTranscriptPath`). The defaults stay: a session started without* the variable, from another terminal or before the profile set it, still lands in them.*- * ⚠️ Remembered in the data folder (`engine-homes.json`), and read before the first transcript check.+ * Remembered in the data folder (the legacy `engine-homes.json` plus confirmed immutable adoption+ * records), and read before the first transcript check.* The login shell is read after start-up begins, never waited on, and the registry checks every saved* agent's transcript as it loads: a home known only from this boot's shell was unknown at that check,* and every agent bound in it lost its binding at each restart (measured, the same test).*/-import { mkdirSync, readFileSync, renameSync, statSync, writeFileSync } from 'node:fs'+import { readFileSync, statSync } from 'node:fs'import { homedir } from 'node:os'import { dirname, isAbsolute, join, relative, resolve, sep } from 'node:path'import { env } from '../config/env.js'@@ -28,21 +29,48 @@ import { sessionStoreContracts, sessionStoreOf, type SessionStoreEngine } from 'import type { AgentEngine } from '../engines/types.js'import { loginShellEnvironment } from './loginShellEnv.js'import { MAX_CATALOG_HOMES, readHomeCatalog, type HomeCatalog } from '../engines/kit/homeCatalog.js'+import { createHomeAdopter, readAdoptedHomes } from '../engines/kit/homeAdoption.js'import { IdentityReadUnavailable } from '../engines/kit/identityScan.js'/** The homes each engine's person moved (its session store's `sessions.moved.variable`), by engine, as saved. */const movedByEngine = Object.fromEntries(Object.keys(sessionStoreContracts).map((engine) => [engine, [] as string[]])) as Record<SessionStoreEngine, string[]>let loadedStamp = ''+let loadedFile = ''// Positive facts only: they can require a hold, never supply roots absent from a fresh read.let nativeCatalogFile = ''let nativeKnownHomes: HomeCatalog = { claude: [], codex: [] }let nativeCatalogOverflow = false+let pendingCatalogFile = ''+let pendingHomes: HomeCatalog = { claude: [], codex: [] }+let pendingAdopter: ReturnType<typeof createHomeAdopter> | undefinedconst savedFile = (): string => join(env.ADAPTER_DATA_DIR, 'engine-homes.json')+function adopter(file = savedFile()): ReturnType<typeof createHomeAdopter> {+ if (pendingCatalogFile !== file || !pendingAdopter) {+ pendingCatalogFile = file; pendingHomes = { claude: [], codex: [] }; pendingAdopter = createHomeAdopter(file)+ }+ return pendingAdopter+}+function observeCatalog(file: string): void {+ if (loadedFile !== file) {+ loadedFile = file; loadedStamp = ''+ for (const homes of Object.values(movedByEngine)) homes.length = 0+ }+ if (nativeCatalogFile === file) return+ nativeCatalogFile = file; nativeKnownHomes = { claude: [], codex: [] }; nativeCatalogOverflow = false+}/** Found by QA on a quiet machine: search starts before the core adopts its shell's homes. Read again when that process* replaces the small saved file, retaining in-memory homes if a write or read is unavailable. */function load(): void {+ observeCatalog(savedFile())+ try {+ const saved = readAdoptedHomes(savedFile()).homes+ for (const engine of Object.keys(movedByEngine) as SessionStoreEngine[]) {+ for (const home of saved[engine]) if (!movedByEngine[engine].includes(home)) movedByEngine[engine].push(home)+ }+ return+ } catch { /* Legacy lifecycle readers retain their positive facts; native control uses the strict reader below. */ }try {const file = savedFile(), stat = statSync(file)const stamp = `${file}:${stat.ino}:${stat.mtimeMs}:${stat.size}`@@ -58,16 +86,6 @@ function load(): void {} catch { /* none adopted yet, or unreadable: the login shell's are adopted again once it is read */ }}-function save(): void {- const file = savedFile()- try {- mkdirSync(dirname(file), { recursive: true })- const draft = `${file}.${process.pid}.tmp`- writeFileSync(draft, JSON.stringify(movedByEngine) + '\n', { mode: 0o600 })- renameSync(draft, file)- } catch { /* best effort: adopted again at the next start, once the login shell is read */ }-}-/** The homes an environment moved that the daemon did not already use: null where it moved none new. */export interface MovedHomes {claude: string | null@@ -91,20 +109,48 @@ export function ownHomeOf(engine: SessionStoreEngine): string {* (`own`, by engine: `ownHomeOf` unless given), and say which are new, by engine.*/export function adoptHomes(environment: NodeJS.ProcessEnv, own: Partial<Record<SessionStoreEngine, string>> = {}): Record<SessionStoreEngine, string | null> {+ return adopt(environment, own, false)+}++/** Every requested home confirmed durable, including an idempotent retry whose earlier reply was lost. */+export function confirmHomes(environment: NodeJS.ProcessEnv): Record<SessionStoreEngine, string | null> {+ return adopt(environment, {}, true)+}++function adopt(environment: NodeJS.ProcessEnv, own: Partial<Record<SessionStoreEngine, string>>, confirmed: boolean): Record<SessionStoreEngine, string | null> {load()- const adopt = (value: string | undefined, home: string, known: string[]): string | null => {+ const file = savedFile()+ observeCatalog(file)+ const writer = adopter(file)+ const requested = (value: string | undefined, home: string): string | null => {const dir = value?.trim()// A relative or `~` path is not a folder the engine resolves the same way from every directory.if (!dir || !isAbsolute(dir)) return nullconst moved = resolve(dir)- if (moved === resolve(home) || known.includes(moved)) return null- known.push(moved)- return moved+ return moved === resolve(home) ? null : moved+ }+ const engines = Object.keys(movedByEngine) as SessionStoreEngine[]+ const wanted = Object.fromEntries(engines.map(engine => [engine,+ requested(environment[sessionStoreContracts[engine].sessions.moved.variable], own[engine] ?? ownHomeOf(engine))])) as Record<SessionStoreEngine, string | null>+ const result = Object.fromEntries(engines.map(engine => [engine, confirmed || !movedByEngine[engine].includes(wanted[engine]!)+ || pendingHomes[engine].includes(wanted[engine]!) ? wanted[engine] : null])) as Record<SessionStoreEngine, string | null>+ for (const engine of engines) {+ const home = wanted[engine]+ if (home && !pendingHomes[engine].includes(home)) {+ if (pendingHomes[engine].length >= MAX_CATALOG_HOMES) {+ nativeCatalogOverflow = true+ throw new IdentityReadUnavailable('the pending session-home limit was reached')+ }+ pendingHomes[engine].push(home)+ }}- const moved = Object.fromEntries((Object.keys(movedByEngine) as SessionStoreEngine[]).map((engine) => [engine,- adopt(environment[sessionStoreContracts[engine].sessions.moved.variable], own[engine] ?? ownHomeOf(engine), movedByEngine[engine])])) as Record<SessionStoreEngine, string | null>- if (Object.values(moved).some(Boolean)) save()- return moved+ if (!Object.values(wanted).some(Boolean)) return result+ const committed = writer.adopt(Object.fromEntries(engines.map(engine => [engine, wanted[engine] ? [wanted[engine]] : []])) as HomeCatalog)+ for (const engine of engines) {+ for (const home of committed[engine]) if (!movedByEngine[engine].includes(home)) movedByEngine[engine].push(home)+ pendingHomes[engine] = pendingHomes[engine].filter(home => home !== wanted[engine])+ }+ return result}/** The homes the person moved `engine`'s to, adopted on this boot or an earlier one; none for an engine that@@ -118,13 +164,13 @@ export function movedHomes(engine: AgentEngine | string): string[] {* Every folder `engine`'s sessions may be in: the agent's own profile's alone, for an engine whose sessions follow* one; else the daemon's own folder and each moved home's. Empty for an engine that declares no session store.*/-export function sessionRoots(engine: AgentEngine | string, profile?: string | null): string[] {+export function sessionRoots(engine: AgentEngine | string, profile?: string | null, snapshot?: EngineHomeSnapshot): string[] {const store = sessionStoreOf(engine)if (!store) return []const { own, moved, profile: followsProfile } = store.sessionsconst below = (home: string): string => own.folder ? join(home, own.folder) : homeif (followsProfile && profile) return [below(profile)]- return [below(env[own.setting]), ...movedHomes(engine).map((home) => join(home, moved.folder))]+ return [below(env[own.setting]), ...(snapshot ? snapshot.homes[engine as SessionStoreEngine] : movedHomes(engine)).map((home) => join(home, moved.folder))]}/** Complete native identity pools cannot use the legacy reader's partial or cached catalog.@@ -135,22 +181,30 @@ export function nativeSessionRoots(engine: AgentEngine | string, profile?: strinconst { own, moved, profile: followsProfile } = store.sessionsconst below = (home: string): string => own.folder ? join(home, own.folder) : homeif (followsProfile && profile) return [below(profile)]- const file = savedFile(), read = readHomeCatalog(file)- if (nativeCatalogFile !== file) {- nativeCatalogFile = file; nativeKnownHomes = { claude: [], codex: [] }; nativeCatalogOverflow = false- }+ const { read } = readNativeHomes()+ return [below(env[own.setting]), ...read.homes[engine as SessionStoreEngine].map(home => join(home, moved.folder))]+}++function readNativeHomes() {+ const file = savedFile()+ observeCatalog(file)+ const read = readAdoptedHomes(file)+ const observed = pendingCatalogFile === file ? pendingAdopter?.observations() : undefinedconst names = Object.keys(sessionStoreContracts) as SessionStoreEngine[]const overflow = (): never => {nativeCatalogOverflow = truethrow new IdentityReadUnavailable('the known session-home limit was reached')}- if (nativeCatalogOverflow) overflow()+ if (nativeCatalogOverflow || observed?.exhausted) overflow()+ if (observed?.legacyRequired && readHomeCatalog(file).text === null) {+ throw new IdentityReadUnavailable('the saved engine-home catalog lost its observed legacy file')+ }for (const name of names) {// Adoption predates this boundary and can keep an unsaved home in memory. Bound that// legacy list before copying or visiting it; remembering an overflow also prevents forgetting it.const legacy = movedByEngine[name]if (legacy.length > MAX_CATALOG_HOMES) overflow()- for (const list of [read.homes[name], legacy]) for (const home of list) {+ for (const list of [read.homes[name], legacy, ...(observed ? [observed.homes[name]] : []), ...(pendingCatalogFile === file ? [pendingHomes[name]] : [])]) for (const home of list) {if (nativeKnownHomes[name].includes(home)) continueif (nativeKnownHomes[name].length === MAX_CATALOG_HOMES) overflow()nativeKnownHomes[name].push(home)@@ -163,7 +217,26 @@ export function nativeSessionRoots(engine: AgentEngine | string, profile?: strinthrow new IdentityReadUnavailable('the saved engine-home catalog omits a previously observed or unsaved home')}}- return [below(env[own.setting]), ...read.homes[engine as SessionStoreEngine].map(home => join(home, moved.folder))]+ return { file, read }+}++/** One explicit synchronous bulk operation. Revalidate before publishing any decisions made from it. */+export interface EngineHomeSnapshot {+ readonly homes: HomeCatalog+ verify(): void+}+export function engineHomeSnapshot(): EngineHomeSnapshot {+ const { file, read } = readNativeHomes()+ const homes = { claude: [...read.homes.claude], codex: [...read.homes.codex] }+ Object.freeze(homes.claude); Object.freeze(homes.codex); Object.freeze(homes)+ return {+ homes,+ verify(): void {+ if (savedFile() !== file || readNativeHomes().read.version !== read.version) {+ throw new IdentityReadUnavailable('the saved engine-home catalog changed during the operation')+ }+ },+ }}/** Every moved home known: adopted on this boot or an earlier one. */@@ -171,6 +244,16 @@ export function movedEngineHomes(): { claude: string[]; codex: string[] } {return { claude: movedHomes('claude'), codex: movedHomes('codex') }}+/** Fresh complete adopted homes for boot-time hook installation; unavailable storage must be retried. */+export function durableEngineHomes(): HomeCatalog {+ return readAdoptedHomes(savedFile()).homes+}++/** Recover a published adoption after a crash, even if this boot no longer names its home in the shell. */+export function recoverEngineHomes(): HomeCatalog {+ return adopter().adopt({ claude: [], codex: [] })+}+/** Every folder Claude Code's transcripts may be in: `own`, then each moved home's. */export function claudeProjectsRoots(own: string): string[] {return [own, ...movedHomes('claude').map((home) => join(home, sessionStoreContracts.claude.sessions.moved.folder))]@@ -183,13 +266,13 @@ export function codexHomeRoots(own: string): string[] {/** Every home a daemon setting names: the daemon's own, then each one the person moved and Harness adopted (the* engines whose movable home is that setting's folder). */-export function homeRoots(setting: FolderSetting): string[] {- load()+export function homeRoots(setting: FolderSetting, snapshot?: EngineHomeSnapshot): string[] {+ if (!snapshot) load()const moved = (Object.keys(movedByEngine) as SessionStoreEngine[]).filter((engine) => {const { own, moved: movable } = sessionStoreContracts[engine].sessionsreturn own.setting === setting && movable.ownHome === 'setting'})- return [env[setting], ...moved.flatMap((engine) => movedByEngine[engine])]+ return [env[setting], ...moved.flatMap((engine) => snapshot ? snapshot.homes[engine] : movedByEngine[engine])]}/**@@ -227,8 +310,8 @@ export function launchHome(setting: FolderSetting, profile: string | null | unde/** Found by QA on a quiet machine: activity, close and Monitor looked at another server when the process's* environment was unreadable. A bound transcript identifies its adopted home even in a service* without the core's shell cache. An explicit profile remains authoritative. */-export function sessionCodexHome(session: { codexHome?: string | null; transcriptPath?: string | null }): string {- return sessionHomeOf('codex', { profile: session.codexHome, transcriptPath: session.transcriptPath })+export function sessionCodexHome(session: { codexHome?: string | null; transcriptPath?: string | null }, snapshot?: EngineHomeSnapshot): string {+ return sessionHomeOf('codex', { profile: session.codexHome, transcriptPath: session.transcriptPath }, snapshot)}/**@@ -236,11 +319,11 @@ export function sessionCodexHome(session: { codexHome?: string | null; transcrip* `sessions.moved.ownHome` is `setting`: Codex's): the agent's own profile, else the known home whose sessions* (or archived sessions) hold the file, else the home a launch made now would use.*/-export function sessionHomeOf(engine: SessionStoreEngine, session: { profile?: string | null; transcriptPath?: string | null }): string {+export function sessionHomeOf(engine: SessionStoreEngine, session: { profile?: string | null; transcriptPath?: string | null }, snapshot?: EngineHomeSnapshot): string {if (session.profile) return session.profileconst { own, archived } = sessionStoreContracts[engine].sessionsconst folders = [own.folder, archived].filter((folder): folder is string => !!folder)- const home = session.transcriptPath && homeRoots(own.setting).find(root => {+ const home = session.transcriptPath && homeRoots(own.setting, snapshot).find(root => {const path = relative(root, session.transcriptPath!)return folders.some((folder) => path.startsWith(`${folder}${sep}`))})@@ -248,9 +331,9 @@ export function sessionHomeOf(engine: SessionStoreEngine, session: { profile?: s}/** The sessions folder of that home (`sessionHomeOf`): where a session beside the one in that file is. */-export function sessionFolderOf(engine: SessionStoreEngine, session: { profile?: string | null; transcriptPath?: string | null }): string {+export function sessionFolderOf(engine: SessionStoreEngine, session: { profile?: string | null; transcriptPath?: string | null }, snapshot?: EngineHomeSnapshot): string {const { own } = sessionStoreContracts[engine].sessions- const home = sessionHomeOf(engine, session)+ const home = sessionHomeOf(engine, session, snapshot)return own.folder ? join(home, own.folder) : home}@@ -291,7 +374,11 @@ export function profileEnvironment(engine: AgentEngine | string, home: string):export function resetEngineHomes(): void {for (const homes of Object.values(movedByEngine)) homes.length = 0loadedStamp = ''+ loadedFile = ''nativeCatalogFile = ''nativeKnownHomes = { claude: [], codex: [] }nativeCatalogOverflow = false+ pendingCatalogFile = ''+ pendingAdopter = undefined+ pendingHomes = { claude: [], codex: [] }}diff --git a/cli/src/lib/registry.homes.spec.ts b/cli/src/lib/registry.homes.spec.tsindex d561831d9..185f26afa 100644--- a/cli/src/lib/registry.homes.spec.ts+++ b/cli/src/lib/registry.homes.spec.ts@@ -3,8 +3,22 @@ import { tmpdir } from 'node:os'import { join } from 'node:path'import { afterEach, expect, it, vi } from 'vitest'+const fault = vi.hoisted(() => ({ beforeVerify: undefined as (() => void) | undefined, captures: 0 }))+vi.mock('node:perf_hooks', async original => ({ ...await original<object>(), performance: { now: () => 0 } }))+function observeHomeReads(): void { vi.doMock('./engineHomes.js', async original => {+ const actual = await original<typeof import('./engineHomes.js')>()+ return { ...actual, engineHomeSnapshot: () => {+ fault.captures+++ const snapshot = actual.engineHomeSnapshot()+ return { ...snapshot, verify: () => { fault.beforeVerify?.(); snapshot.verify() } }+ } }+}) }+vi.mock('./bootId.js', async original => ({ ...await original<object>(), currentBootId: () => 'fixture-boot', bootChanged: () => false }))+vi.mock('./processLiveness.js', async original => ({ ...await original<object>(),+ processLockIdentity: () => ({ startMarker: 'fixture-start', generationMarker: 'fixture-generation' }), lockOwnerAlive: () => true,+}))let root: string | undefined-afterEach(() => { vi.unstubAllEnvs(); vi.resetModules(); if (root) rmSync(root, { recursive: true, force: true }) })+afterEach(() => { fault.beforeVerify = undefined; fault.captures = 0; vi.doUnmock('./engineHomes.js'); vi.unstubAllEnvs(); vi.resetModules(); if (root) rmSync(root, { recursive: true, force: true }) })it('repairs a child-overwritten parent from an adopted Codex home before the login shell is read', async () => {// Found by QA on a quiet machine: restart searched only the default home and discarded this parent binding.@@ -33,3 +47,73 @@ it('repairs a child-overwritten parent from an adopted Codex home before the logexpect(registry.get(parentId)?.transcriptPath).toBe(parent)expect(JSON.parse(readFileSync(join(root, 'registry.json'), 'utf8'))[0].transcriptPath).toBe(parent)})+++it.each(['unbind', 'release', 'separate-shell'] as const)('clears a hold with its binding while retaining a sibling hold: %s', async operation => {+ root = mkdtempSync(join(tmpdir(), 'registry-home-release-'))+ vi.stubEnv('ADAPTER_DATA_DIR', root)+ vi.stubEnv('CODEX_HOME', join(root, 'own-codex'))+ const rows = [0, 1].map(index => ({ launcherId: `fixture-${index}`, engine: 'codex', sessionId: `session-${index}`,+ transcriptPath: join(root!, 'moved-codex', 'sessions', `rollout-${index}.jsonl`), tmuxPane: `%${index + 1}`,+ projectDir: 'fixture', cwd: root, processIdentity: null, registeredAt: 1, updatedAt: 1, lastHookAt: 1, lastTranscriptAt: 1 }))+ writeFileSync(join(root, 'engine-homes.json'), '{', { mode: 0o600 })+ writeFileSync(join(root, 'registry.json'), JSON.stringify(rows), { mode: 0o600 })+ vi.resetModules()+ const { registry } = await import('./registry.js')+ const log = vi.spyOn(console, 'log').mockImplementation(() => {})+ try {+ registry.load()+ expect(registry.byAgent('fixture-0')?.identityHold).toBeTruthy()+ const released = operation === 'unbind'+ ? (expect(registry.unbindSession('session-0')).toBe(true), registry.byAgent('fixture-0'))+ : registry.releaseEngine('fixture-0', operation === 'separate-shell')+ expect(released).toMatchObject({ sessionId: '', transcriptPath: null })+ expect(released).not.toHaveProperty('identityHold')+ expect(registry.byAgent(released!.agentId)).not.toHaveProperty('identityHold')+ expect(registry.byAgent('fixture-1')?.identityHold).toBeTruthy()+ if (operation === 'separate-shell') {+ expect(released!.agentId).not.toBe('fixture-0')+ expect(registry.byAgent('fixture-0')).toBeUndefined()+ }+ const saved = JSON.parse(readFileSync(join(root, 'registry.json'), 'utf8'))+ expect(saved.some((row: any) => Object.hasOwn(row, 'identityHold'))).toBe(false)+ } finally { log.mockRestore() }+})++it.each(['healthy', 'unreadable', 'changed-at-commit'] as const)('stages a registry-sized home batch without losing bindings: %s', async condition => {+ root = mkdtempSync(join(tmpdir(), 'registry-home-batch-'))+ vi.stubEnv('ADAPTER_DATA_DIR', root)+ vi.stubEnv('CODEX_HOME', join(root, 'own-codex'))+ const moved = join(root, 'moved-codex'), sessions = join(moved, 'sessions')+ mkdirSync(sessions, { recursive: true })+ const rows = Array.from({ length: 200 }, (_, index) => {+ const id = `aaaaaaaa-1111-4222-8333-${String(index).padStart(12, '0')}`+ const transcriptPath = join(sessions, `rollout-${id}.jsonl`)+ writeFileSync(transcriptPath, JSON.stringify({ type: 'session_meta', payload: { id, source: 'cli' } }) + '\n')+ return { launcherId: `fixture-${index}`, engine: 'codex', sessionId: id, transcriptPath, tmuxPane: `%${index + 1}`,+ projectDir: 'fixture', cwd: root, processIdentity: null, registeredAt: 1, updatedAt: 1, lastHookAt: 1, lastTranscriptAt: 1 }+ })+ const file = join(root, 'engine-homes.json')+ writeFileSync(file, condition === 'unreadable' ? '{' : JSON.stringify({ codex: condition === 'changed-at-commit' ? [] : [moved] }), { mode: 0o600 })+ writeFileSync(join(root, 'registry.json'), JSON.stringify(rows), { mode: 0o600 })+ if (condition === 'changed-at-commit') fault.beforeVerify = () => writeFileSync(file, JSON.stringify({ codex: [moved] }))+ vi.resetModules()+ observeHomeReads()+ const { registry } = await import('./registry.js')+ const log = vi.spyOn(console, 'log').mockImplementation(() => {})+ registry.load()+ log.mockRestore()+ expect(fault.captures).toBe(1)+ expect(registry.list()).toHaveLength(200)+ for (const row of rows) {+ expect(registry.get(row.sessionId)).toMatchObject({ sessionId: row.sessionId, transcriptPath: row.transcriptPath })+ expect(Boolean(registry.get(row.sessionId)?.identityHold)).toBe(condition !== 'healthy')+ }+ const saved = JSON.parse(readFileSync(join(root, 'registry.json'), 'utf8'))+ expect(saved.map((row: any) => row.sessionId).sort()).toEqual(rows.map(row => row.sessionId).sort())+ expect(saved.some((row: any) => row.identityHold)).toBe(false)+ fault.beforeVerify = undefined+ writeFileSync(file, JSON.stringify({ codex: [moved] }))+ registry.load()+ expect(registry.list().every(row => row.sessionId && !row.identityHold)).toBe(true)+})diff --git a/cli/src/lib/registry.spec.ts b/cli/src/lib/registry.spec.tsindex 211f1a586..8e98b3430 100644--- a/cli/src/lib/registry.spec.ts+++ b/cli/src/lib/registry.spec.ts@@ -2429,3 +2429,6 @@ describe('fork origin record — persistence edges', () => {expect(reloaded.byAgent(entry.agentId)?.forkedFrom).toEqual({ agentId: 'p', name: 'P' })})})++// Filesystem durability deadlines are exercised separately from these deterministic fixture reads.+vi.mock('node:perf_hooks', async original => ({ ...await original<object>(), performance: { now: () => 0 } }))diff --git a/cli/src/lib/registry.ts b/cli/src/lib/registry.tsindex f03fe3f46..41bd6d8ed 100644--- a/cli/src/lib/registry.ts+++ b/cli/src/lib/registry.ts@@ -41,7 +41,7 @@ import { machineNames } from './machineNames.js'import { cursorDataDir } from '../engines/cursor/contract.js'import { IdentityReadUnavailable } from '../engines/kit/identityScan.js'import { env } from '../config/env.js'-import { sessionFolderOf, sessionRoots } from './engineHomes.js'+import { engineHomeSnapshot, sessionFolderOf, sessionRoots, type EngineHomeSnapshot } from './engineHomes.js'import { findSessionFileOf, sessionMetaOf } from '../engines/sessionFiles.js'import { isSessionStoreEngine, sessionStoreContracts, sessionStoreOf } from '../engines/sessionStoreContracts.js'import { admitHook } from '../engines/hooks.js'@@ -91,6 +91,8 @@ export interface RegisteredSession {active: boolean/** Harness-created panes can be rendered before their engine process exists. Absent on legacy rows. */launch?: AgentLaunch+ /** Fresh evidence is unavailable; retain the binding and expose its reason without persisting an authority verdict. */+ identityHold?: string/** Enter on stopped work must never become a fresh conversation, including after a daemon restart. */resumeOnly?: true/** External admission survives a crash independently of any conversation Harness already owns. */@@ -551,8 +553,9 @@ function tmuxProjection(runtimes: readonly TerminalRuntimeRef[]): string {}function persistedRow(entry: RegisteredSession): RegisteredSession | Omit<RegisteredSession, 'tmuxPane'> {- if (entry.tmuxPane) return { ...entry, runtimes: entry.runtimes.map((runtime) => ({ ...runtime })) }- const { tmuxPane: _legacy, ...row } = entry+ const { identityHold: _hold, ...saved } = entry+ if (saved.tmuxPane) return { ...saved, runtimes: saved.runtimes.map((runtime) => ({ ...runtime })) }+ const { tmuxPane: _legacy, ...row } = savedreturn { ...row, runtimes: row.runtimes.map((runtime) => ({ ...runtime })) }}@@ -588,7 +591,7 @@ export function strictPersistedRow(raw: unknown): RegisteredSession | null {// Taken out of the spread and put back only when it is a real moment: the spread would otherwise// carry a hand-edited string or a negative number straight into the frame's `toISOString()`.// `forkedFrom` is out too, so an invalid one is dropped rather than spread back in as-is.- const { lastOpenedAt: rawOpenedAt, closePlan: rawClosePlan, forkedFrom: rawForkedFrom, scmLaunch: rawScmLaunch, externalResume: _externalResume, ...rest } = row+ const { identityHold: _identityHold, lastOpenedAt: rawOpenedAt, closePlan: rawClosePlan, forkedFrom: rawForkedFrom, scmLaunch: rawScmLaunch, externalResume: _externalResume, ...rest } = rowconst lastOpenedAt = normalizedOpenedAt(rawOpenedAt)// Out of the spread for the same reason: a half-formed record is dropped, never relaunched with.const scmLaunch = parseScmLaunchRecord(rawScmLaunch)@@ -961,8 +964,8 @@ export function engineKeepsTranscriptFile(engine: AgentEngine): boolean {* home the person moved in their shell profile (lib/engineHomes.ts). An agent's own profile (its CODEX_HOME) is* its only one, for an engine whose sessions follow one.*/-function transcriptRoots(engine: AgentEngine, root: (() => string) | 'store', codexHome?: string): string[] {- return root === 'store' ? sessionRoots(engine, codexHome) : [root()]+function transcriptRoots(engine: AgentEngine, root: (() => string) | 'store', codexHome?: string, snapshot?: EngineHomeSnapshot): string[] {+ return root === 'store' ? sessionRoots(engine, codexHome, snapshot) : [root()]}export function validTranscriptPath(engine: AgentEngine, filePath: string, codexHome?: string, allowMissing = false): boolean {@@ -974,7 +977,7 @@ export function inspectTranscriptPath(engine: AgentEngine, filePath: string): boreturn checkTranscriptPath(engine, filePath, undefined, false, true)}-function checkTranscriptPath(engine: AgentEngine, filePath: string, codexHome: string | undefined, allowMissing: boolean, strict: boolean): boolean {+function checkTranscriptPath(engine: AgentEngine, filePath: string, codexHome: string | undefined, allowMissing: boolean, strict: boolean, snapshot?: EngineHomeSnapshot): boolean {const rootFor = TRANSCRIPT_ROOT[engine]if (!rootFor) return falsetry {@@ -985,7 +988,7 @@ function checkTranscriptPath(engine: AgentEngine, filePath: string, codexHome: scatch (error) { if (strict) throw error; return false }}const st = statSync(missing ? dirname(actual) : actual)- if (!(missing ? st.isDirectory() : st.isFile()) || !transcriptRoots(engine, rootFor, codexHome).some(within)) return false+ if (!(missing ? st.isDirectory() : st.isFile()) || !transcriptRoots(engine, rootFor, codexHome, snapshot).some(within)) return falseif (engine === 'cursor') {const id = basename(actual).replace(/\.jsonl$/, '')if (!id || basename(dirname(actual)) !== id || basename(dirname(dirname(actual))) !== 'agent-transcripts') return false@@ -1091,6 +1094,7 @@ class Registry {if (entry.sessionId && this.sessionIndex.get(entry.sessionId) === entry.agentId) {this.sessionIndex.delete(entry.sessionId)}+ delete entry.identityHoldentry.sessionId = ''entry.boundAt = nullentry.transcriptPath = null@@ -1167,10 +1171,30 @@ class Registry {// pre-reboot pids on disk with no second chance to notice — force the cleared snapshot out.changed = true}+ // One fresh catalog proof serves this synchronous batch. No row is indexed or saved until+ // that proof is checked again; a changed or unavailable catalog preserves its former bindings.+ let snapshot: EngineHomeSnapshot | undefined, unavailableHomes: unknown+ const dependent = new Map<string, Partial<RegisteredSession>>()+ const staged = new Map<string, RegisteredSession>()+ const catalogFor = (engine: AgentEngine, profile?: string): EngineHomeSnapshot | undefined => {+ if (TRANSCRIPT_ROOT[engine] !== 'store' || sessionStoreOf(engine)?.sessions.profile && profile) return undefined+ if (unavailableHomes) throw unavailableHomes+ try { return snapshot ??= engineHomeSnapshot() }+ catch (error) { unavailableHomes = error; throw error }+ }+ const preserve = (row: RegisteredSession, original: Partial<RegisteredSession>, error: unknown): void => {+ row.sessionId = typeof original.sessionId === 'string' ? original.sessionId : ''+ row.boundAt = row.sessionId ? original.boundAt ?? original.registeredAt ?? row.registeredAt : null+ row.transcriptPath = typeof original.transcriptPath === 'string' && original.transcriptPath ? original.transcriptPath : null+ row.source = row.sessionId && typeof original.source === 'string' ? original.source : null+ row.projectDir = typeof original.projectDir === 'string' ? original.projectDir : row.transcriptPath ? basename(dirname(row.transcriptPath)) : row.sessionId || row.agentId+ row.identityHold = error instanceof Error ? error.message : String(error)+ }for (const raw of Array.isArray(arr) ? arr : []) {const engine = normalizedAgentEngine(raw?.engine)const runtimes = normalizedRuntimes(raw?.runtimes, raw?.tmuxPane)const pane = tmuxProjection(runtimes)+ if (!runtimes.length) { changed = true; continue }let transcriptPath =typeof raw?.transcriptPath === 'string' && raw.transcriptPath? raw.transcriptPath@@ -1186,39 +1210,45 @@ class Registry {// binding with the child's file: put the parent's own back, found by its id in the same home (or its// profile), else release the binding. Declared by the engine's session store (`repairsOverwrittenParent`)// and read with the kit, in core.- let repairedParentTranscript = false- if (isSessionStoreEngine(engine) && sessionStoreContracts[engine].repairsOverwrittenParent && transcriptPath) {- const meta = sessionMetaOf(engine, transcriptPath)- if (meta?.isSubagent) {- const repaired = meta.parentThreadId === rawSessionId- ? findSessionFileOf(engine, rawSessionId, sessionFolderOf(engine, { profile: rawCodexHome, transcriptPath }))- : null- if (!repaired || !validTranscriptPath(engine, repaired, rawCodexHome) || sessionMetaOf(engine, repaired)?.isSubagent) {- changed = true- bound = false- transcriptPath = null- } else {- console.log(`[registry] repaired ${sessionStoreContracts[engine].label} parent ${rawSessionId.slice(0, 8)} transcript after child hook overwrite`)- transcriptPath = repaired- repairedParentTranscript = true- changed = true+ let repairedParentTranscript = false, homeError: unknown+ const needsCatalog = !!transcriptPath && TRANSCRIPT_ROOT[engine] === 'store' && !(sessionStoreOf(engine)?.sessions.profile && rawCodexHome)+ try {+ const rowSnapshot = needsCatalog ? catalogFor(engine, rawCodexHome) : undefined+ if (isSessionStoreEngine(engine) && sessionStoreContracts[engine].repairsOverwrittenParent && transcriptPath) {+ const meta = sessionMetaOf(engine, transcriptPath)+ if (meta?.isSubagent) {+ const repaired = meta.parentThreadId === rawSessionId+ ? findSessionFileOf(engine, rawSessionId, sessionFolderOf(engine, { profile: rawCodexHome, transcriptPath }, rowSnapshot))+ : null+ if (!repaired || !checkTranscriptPath(engine, repaired, rawCodexHome, false, false, rowSnapshot) || sessionMetaOf(engine, repaired)?.isSubagent) {+ changed = true+ bound = false+ transcriptPath = null+ } else {+ console.log(`[registry] repaired ${sessionStoreContracts[engine].label} parent ${rawSessionId.slice(0, 8)} transcript after child hook overwrite`)+ transcriptPath = repaired+ repairedParentTranscript = true+ changed = true+ }}}- }- // A process agent remains valid without a session. A missing/invalid transcript releases only the- // binding so the discovery/store repair path can bind it again if appropriate.- if (!bound) transcriptPath = null- if (!runtimes.length) {- changed = true- continue- }- if (- (bound && engine !== 'cursor' && engine !== 'opencode' && engine !== 'kilo' && engine !== 'pi' && engine !== 'hermes' && engine !== 'commandcode' && engine !== 'devin' && !transcriptPath)- || (bound && transcriptPath !== null && !validTranscriptPath(engine, transcriptPath, rawCodexHome))- ) {- bound = false- transcriptPath = null- changed = true+ // A process agent remains valid without a session. A missing/invalid transcript releases only the+ // binding so the discovery/store repair path can bind it again if appropriate.+ if (!bound) transcriptPath = null+ if (+ (bound && engine !== 'cursor' && engine !== 'opencode' && engine !== 'kilo' && engine !== 'pi' && engine !== 'hermes' && engine !== 'commandcode' && engine !== 'devin' && !transcriptPath)+ || (bound && transcriptPath !== null && !checkTranscriptPath(engine, transcriptPath, rawCodexHome, false, false, rowSnapshot))+ ) {+ bound = false+ transcriptPath = null+ changed = true+ }+ } catch (error) {+ if (!(error instanceof IdentityReadUnavailable)) throw error+ homeError = error+ transcriptPath = typeof raw.transcriptPath === 'string' && raw.transcriptPath ? raw.transcriptPath : null+ bound = !!rawSessionId+ repairedParentTranscript = false}// Old launcher-owned records used launcherId as the public id. Preserve it while process discovery// validates/adopts the live runtime, then save the record without the legacy ownership field.@@ -1299,11 +1329,23 @@ class Registry {|| raw.lastTranscriptAt == null|| legacyLauncherId !== '') changed = true- if (this.agents.has(s.agentId)) {+ if (staged.has(s.agentId)) {this.quarantine('contains duplicate agent identities')return}- this.index(s)+ if (needsCatalog) dependent.set(s.agentId, raw)+ if (homeError) preserve(s, raw, homeError)+ staged.set(s.agentId, s)+ }+ if (snapshot) {+ try { snapshot.verify() }+ catch (error) {+ for (const [id, raw] of dependent) preserve(staged.get(id)!, raw, error)+ }+ }+ for (const row of staged.values()) {+ this.index(row)+ if (row.identityHold) console.log(`[registry] ${row.agentId.slice(0, 8)} binding held · ${row.identityHold}`)}if (!validatedRows(this.list().map(persistedRow))) {this.quarantine('violates global identity invariants')@@ -2529,12 +2571,15 @@ class Registry {for (const row of rows) {const entry = previous.get(row.agentId) ?? rowif (entry !== row) {+ const identityHold = entry.engine === row.engine && entry.sessionId === row.sessionId+ && entry.transcriptPath === row.transcriptPath && entry.codexHome === row.codexHome ? entry.identityHold : undefined// External deletions count too: retaining a cancelled closePlan here would make the// next observation write it back and turn a cancelled close into pending work again.for (const key of Object.keys(entry)) {if (!Object.hasOwn(row, key)) delete (entry as unknown as Record<string, unknown>)[key]}Object.assign(entry, row)+ if (identityHold) entry.identityHold = identityHold}this.index(entry)}diff --git a/cli/src/lib/runtimeProfile.homes.spec.ts b/cli/src/lib/runtimeProfile.homes.spec.tsindex b508c3bc5..b7f4de817 100644--- a/cli/src/lib/runtimeProfile.homes.spec.ts+++ b/cli/src/lib/runtimeProfile.homes.spec.ts@@ -81,3 +81,6 @@ it.each(['claude', 'codex'] as const)('a bound %s conversation keeps its originaexpect(models).toContain(engine === 'claude' ? 'sonnet' : 'previous-model')expect(models).not.toContain(engine === 'claude' ? 'haiku' : 'current-model')})++// Filesystem durability deadlines are exercised separately from these deterministic fixture reads.+vi.mock('node:perf_hooks', async original => ({ ...await original<object>(), performance: { now: () => 0 } }))diff --git a/cli/src/lib/sessionRepair.spec.ts b/cli/src/lib/sessionRepair.spec.tsindex 48bf7bc40..3a6458e6d 100644--- a/cli/src/lib/sessionRepair.spec.ts+++ b/cli/src/lib/sessionRepair.spec.ts@@ -1,3 +1,4 @@+import { clearEngineHomeFixture } from '../testing/engineHomeFixture.js'import { nativeConversationFixture } from '../testing/nativeConversationEvidence.js'import { afterEach, describe, expect, it, vi } from 'vitest'import { mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, utimesSync, writeFileSync } from 'fs'@@ -620,7 +621,7 @@ describe('session repair — homes the person moved', () => {}afterEach(async () => {delete process.env.CODEX_HOME- rmSync(join(process.env.ADAPTER_DATA_DIR!, 'engine-homes.json'), { force: true })+ clearEngineHomeFixture(process.env.ADAPTER_DATA_DIR!);(await import('./engineHomes.js')).resetEngineHomes()})@@ -818,7 +819,7 @@ describe('findResumedTranscript', () => {// An agent's own Codex profile is its only home.await expect(findResumedTranscript('codex', codexId, { codexHome: tempRoot() })).resolves.toBeNull()} finally {- rmSync(join(process.env.ADAPTER_DATA_DIR!, 'engine-homes.json'), { force: true })+ clearEngineHomeFixture(process.env.ADAPTER_DATA_DIR!)homes.resetEngineHomes()}})@@ -923,3 +924,6 @@ describe('hermes repair across profile homes', () => {expect(await findLiveSession('hermes', CWD, STARTED_AT, { bornOnly: true })).toBeNull()})})++// Filesystem durability deadlines are exercised separately from these deterministic fixture reads.+vi.mock('node:perf_hooks', async original => ({ ...await original<object>(), performance: { now: () => 0 } }))diff --git a/cli/src/lib/stoppedAgents.spec.ts b/cli/src/lib/stoppedAgents.spec.tsindex fb6bc580b..40938ac99 100644--- a/cli/src/lib/stoppedAgents.spec.ts+++ b/cli/src/lib/stoppedAgents.spec.ts@@ -20,6 +20,15 @@ afterEach(() => {})describe('saved catalog reads', () => {+ it('saves a held conversation without persisting its transient identity verdict', async () => {+ const { saved, store } = await fixture()+ store.save({ ...saved, identityHold: 'The session-home catalog is unavailable.' })+ const raw = JSON.parse(readFileSync(join(directory, 'stopped-agents', `${saved.agentId}.json`), 'utf8'))+ expect(raw.session.sessionId).toBe(saved.sessionId)+ expect(raw.session).not.toHaveProperty('identityHold')+ expect(store.get(saved.agentId)).not.toHaveProperty('identityHold')+ })+it('does not reread unchanged records for status snapshots, but resume still reads the file', async () => {const { saved, store } = await fixture()store.save(saved)diff --git a/cli/src/lib/stoppedAgents.ts b/cli/src/lib/stoppedAgents.tsindex 3820f01f0..0c7e170a0 100644--- a/cli/src/lib/stoppedAgents.ts+++ b/cli/src/lib/stoppedAgents.ts@@ -148,6 +148,8 @@ export class StoppedAgentStore {}// A later Resume is an explicit new visit, never an instruction to close it again.delete snapshot.closePlan+ // A hold describes this daemon's current observation, never durable conversation evidence.+ delete snapshot.identityHold// A snapshot without a tmux pane omits the legacy alias just like registry persistence.if (!snapshot.tmuxPane) delete (snapshot as Partial<RegisteredSession>).tmuxPaneatomicWriteJson(join(this.directory, `${session.agentId}.json`), { version: 1, session: snapshot })diff --git a/cli/src/testing/engineHomeFixture.ts b/cli/src/testing/engineHomeFixture.tsnew file mode 100644index 000000000..9806f76ab--- /dev/null+++ b/cli/src/testing/engineHomeFixture.ts@@ -0,0 +1,13 @@+import { realpathSync, rmSync } from 'node:fs'+import { tmpdir } from 'node:os'+import { isAbsolute, join, relative, sep } from 'node:path'++/** Reset only a caller-owned temporary catalog, including its immutable adoption records. */+export function clearEngineHomeFixture(dataDirectory: string): void {+ const root = realpathSync(tmpdir()), directory = realpathSync(dataDirectory)+ const below = relative(root, directory)+ if (!below || below === '..' || below.startsWith(`..${sep}`) || isAbsolute(below)) throw new Error('A home-catalog fixture must be in a private temporary directory')+ for (const suffix of ['', '.adoptions', '.confirmations', '.adopted']) {+ rmSync(join(directory, 'engine-homes.json' + suffix), { recursive: true, force: true })+ }+}diff --git a/docs/research/2026-10-09-daemon-core-completion.md b/docs/research/2026-10-09-daemon-core-completion.mdindex 02b4ccce8..079e22be5 100644--- a/docs/research/2026-10-09-daemon-core-completion.md+++ b/docs/research/2026-10-09-daemon-core-completion.md@@ -19,9 +19,12 @@ This is the remaining completion scope as of October 9, after the six extraction- [x] Fresh bounded Hermes pools and Stop home preservation (#1120, merged as `a847441e5` at 16:39:44 UTC).- [x] Complete exact Claude/Codex/Pi resume pools and typed Pi Close recovery (#1123, merged as `fb834fb18` at 17:14:15 UTC).+- [x] Fresh complete native home catalog evidence (#1126); durable writers and legacy consumers remain below.+- [x] Complete native descriptor/process/header ownership evidence (#1131, merged as `9eafacf3b` at October 10 00:33:06 UTC).+## Remaining blockers-1. **Complete native identity and retry.** Exact transcript lookup is landed; lock/descriptor enumeration, legacy registry repair and the saved-home catalog remain. The [catalog audit](2026-10-09-native-home-catalog.md) records its fresh-evidence boundary and required remaining caller/writer migration. The native Hermes pool is landed; optional home promotion and shared handle-cache lifetime still need their authority/resource audit. An unreadable or truncated pool cannot prove absence or uniqueness. Every binding entry and transcript poll retains pending work, isolates a failed lookup, and retries without blocking sibling sessions or readiness. Surface the hold reason through the shared session state.+1. **Complete native identity and retry.** Exact transcript lookup and native lock/descriptor enumeration are landed. Durable home adoption and its staged registry batch are [under validation](2026-10-10-durable-home-adoption.md); legacy registry repair and the remaining saved-home consumers still require migration. The [catalog audit](2026-10-09-native-home-catalog.md) records its fresh-evidence boundary and required remaining caller/writer migration. The native Hermes pool is landed; optional home promotion and shared handle-cache lifetime still need their authority/resource audit. An unreadable or truncated pool cannot prove absence or uniqueness. Every binding entry and transcript poll retains pending work, isolates a failed lookup, and retries without blocking sibling sessions or readiness. Surface the hold reason through the shared session state.2. **Complete native launch preparation.** Probe executable/version facts asynchronously with a deadline and one confirmed executable snapshot per launch. Failed hook writes/removals hold launch, preserve foreign configuration and are checked consistently by create, fork, restart, retarget, restore and upgrades. Do not memoize an unavailable version as a permanent answer.3. **Durable manual lifecycle intent and mutation authority.** Preserve create/fork/restart/retarget requests across unavailable services and daemon restart. Publish generated configuration atomically after dependencies are ready. Check immutable session ownership after every relevant await and before native writes, signals and publication. Reconcile unconfirmed OpenCode v2 mutations read-only; unreadable catalogs must not authorize mutation. Cover v1 missing-row/rollback cases and report a confirmed native change followed by failed respawn truthfully.4. **Close, turns and input stay in core.** Audit OpenCode v2 Close checkpointing against its current conversation store; unavailable checkpoint/activity evidence keeps the live session with its reason. Finish per-engine Stop/turn facts, authority across asynchronous drains, Cursor pending-task persistence, agy backstop control, input verification declarations, and Pi header/argv and unwritten-conversation handling.diff --git a/docs/research/2026-10-09-daemon-separation-progress.md b/docs/research/2026-10-09-daemon-separation-progress.mdindex 7b0cbd021..91b593ada 100644--- a/docs/research/2026-10-09-daemon-separation-progress.md+++ b/docs/research/2026-10-09-daemon-separation-progress.md@@ -212,3 +212,10 @@ and the final unavailable-service/readiness audit. Line counts do not establish## Fresh Hermes stores and retained Stop homes[PR #1120](https://github.com/autonomous-ai/openharness/pull/1120) merged as `a847441e5` at 16:39:44 UTC on October 9. Fresh complete native pools hold unreadable, ambiguous, oversized or changing evidence; Stop preserves the proven home. The [report](2026-10-09-hermes-store-pools.md) contains the unchanged golden, 27 assertion-failing mutants, full coverage/native acceptance and matched cost. Final source had independent exact-head/base approval and every automatic head check, including `ci/required`. Implementation/review corrections ended at 15:52, local acceptance and cost by 15:57, and final documentation review at 16:00. CI waiting and integration extended to 16:39 after the recorded legacy-golden safety correction and three documentation-only main advances. The merge helper ran 16:39:30–16:39:44. Publication remains zero. Native identity as a group remains open; exact resume is next, followed by legacy records, saved-home failure handling and shared hold visibility.+++## Native descriptor evidence and durable home adoption++[PR #1131](https://github.com/autonomous-ai/openharness/pull/1131) merged as `9eafacf3b512a0b1ffd23e0d446115896b01f7ed` on October 10 at 00:33:06 UTC. Its [report](2026-10-09-native-descriptor-evidence.md) records the unchanged 29-observation golden, 21 assertion-failing mutations, native/private acceptance, full coverage, 150 matched cost samples, and exact-head/base independent review. Automatic CI run `38008750415` completed all applicable checks including `ci/required`. Merge verification ran 00:32:53–00:33:06. No release occurred.++The owner resumed the paused task on October 9 at 22:25:51 UTC. Work is now on [durable home adoption](2026-10-10-durable-home-adoption.md), including crash recovery, retained observations, core hook retries and a staged registry batch. Validation and review are in progress; this is not a claim that the native-identity group or the complete refactor is finished.diff --git a/docs/research/2026-10-09-native-descriptor-evidence.md b/docs/research/2026-10-09-native-descriptor-evidence.mdindex 46a6c0783..925742f8e 100644--- a/docs/research/2026-10-09-native-descriptor-evidence.md+++ b/docs/research/2026-10-09-native-descriptor-evidence.md@@ -45,7 +45,7 @@ The [raw measurements](2026-10-09-native-descriptor-cost.json) compare former so| Duplicate descriptors | 170 / 172 ms | 509 / 797 ms | 2.88 / 28.07 ms | 94.6 / 105.6 MiB || Competing rollouts | 171 / 172 ms | 509 / 797 ms | 2.90 / 27.77 ms | 94.1 / 107.0 MiB |-CPU is the observer's mean per lookup; peak RSS is the mean fresh observer process peak, including startup. Fresh-process CPU, including startup and child probes, increased from about 1.32 seconds to 3.06–3.12 seconds per five-call process. The p95 convention is `sorted[floor((n-1)*0.95)]`. These scopes are separate and do not estimate whole-daemon readiness. The additional observations cost roughly 340 ms at the median and 9–13 MiB in this workload. The three-second lookup budget remains the control bound; these measurements introduce no automatic performance threshold.+CPU is the observer's mean per lookup; peak RSS is the mean fresh observer process peak, including startup. Fresh-process CPU, including startup and child probes, increased from about 1.32 seconds to 3.06–3.12 seconds per five-call process. The p95 convention is `sorted[floor((n-1)*0.95)]`. These scopes are separate and do not estimate whole-daemon readiness. The additional observations cost roughly 340 ms at the median and 8–13 MiB in this workload. The three-second lookup budget remains the control bound; these measurements introduce no automatic performance threshold.Two incomplete pre-fix measurement attempts are not included as passing evidence. Each encountered a hold in the single-file workload. Recording the reason and a bounded process-table observation identified an unrelated exiting process with Darwin state `?E+`; the strict parser had rejected the entire graph. The parser now retains `?` as uncertain state and continues native verification for a relevant owner or child, rather than treating it as absent. Three regressions cover the unrelated row and uncertain owner/child refusal, and a twentieth mutation removes that support. The [Darwin process-state formatter](https://raw.githubusercontent.com/apple-oss-distributions/adv_cmds/main/ps/print.c) describes its exit and foreground modifiers. The complete final run took 66.7 seconds, from October 10 00:20:09 to 00:21:16 UTC, and passed every expected outcome.diff --git a/docs/research/2026-10-10-durable-home-adoption.md b/docs/research/2026-10-10-durable-home-adoption.mdnew file mode 100644index 000000000..1b6e42b53--- /dev/null+++ b/docs/research/2026-10-10-durable-home-adoption.md@@ -0,0 +1,56 @@+# Durable engine-home adoption++An adopted Claude Code or Codex home must be durable before core treats it as usable or installs its hooks. The former writer merged process-local arrays and overwrote one JSON file, swallowing write failures. Concurrent writers could lose each other's homes; a failed write could still look successful to the hook coordinator.++## Publication and recovery++The existing `engine-homes.json` remains an imported baseline. New additions are immutable, exclusively linked numbered records in `engine-homes.json.adoptions`. Each record identifies its predecessor and contains positive additions and the requirement to retain an observed baseline. Publication flushes the staged record before linking, the record and directory before confirmation, and the confirmation's parent before acknowledging. The initial confirmation is outside the journal (`engine-homes.json.adopted`); subsequent confirmations live in `engine-homes.json.confirmations`. Losing a committed tail or the journal therefore cannot silently resemble an older complete catalog.++A publication loser rebases on the winner, with four attempts and a shared 250 ms work deadline. Complete published intentions can be confirmed after a crash even when the next login environment no longer names their home. Empty abandoned initialization without a complete intention stays held. No published record, baseline, foreign configuration, or abandoned staging file is removed or overwritten. Only a writer's own staging file is unlinked.++Reads are fresh and bounded: 63 moved homes per engine, 128 numbered slots, 64 KiB combined catalog text, regular account-owned files without group/world write permission, descriptor/path version checks, strict UTF-8 and schema, contiguous hash-linked records, complete outside confirmations, and a final membership check. Directory iterators are not trusted to establish absence by themselves: every bounded numbered slot is checked independently, and the directory's full metadata stamp is checked across enumeration. Missing-slot checks avoid constructing an ENOENT exception for each absent name.++The per-catalog adopter retains bounded positive observations and required baseline presence across held calls. These observations can require a hold but cannot supply usable session roots. Overflow stays held. Confirmation, empty-environment recovery, and native omission checks share that state; changing the catalog or resetting the test seam does not transfer it elsewhere.++The core coordinator separately acknowledges adoption and hook installation, retries failures with a reason, refreshes peer homes after confirmation, and closes before daemon teardown. It retains only the two home variables, never the rest of the login environment. Native installers that swallow their own write errors still need the separate launch/hook migration in the completion checklist; this coordinator can retry errors that reach it.++## Bulk registry reads++An initial measurement found a material recurring cost: 200 independent legacy home lookups over 63 journal records took about 3.95 seconds; avoiding ENOENT exceptions reduced that only to 3.14 seconds. Those exploratory results prompted an explicit batch proof, not a cache.++Registry load acquires one immutable catalog snapshot for its synchronous batch. It stages binding decisions, verifies the catalog again, then publishes the rows. Unavailable or changed home evidence preserves the original bindings and attaches an `identityHold` reason to the shared frame. The reason is transient, retained across saves of the same binding, and never persisted as proof. Independent native operations continue to read fresh evidence. The former session-store golden covers healthy registry loading unchanged.++This is the catalog portion of registry loading. Legacy header/repair reads, admission, restore/restart preflight and automatic per-row retry are still part of the remaining caller migration; no claim is made that those paths are finished.++## Matched cost++[Raw measurements](2026-10-10-home-adoption-cost.json) compare main `9eafacf3b` with implementation `0944754af` on Node 22.23.2, macOS x64, under UTC and `/tmp`. Three interleaved fresh-process repetitions cover each source and workload (24 processes), without concurrent local validation, from 01:24:20 to 01:24:28 UTC on October 10. Each native workload makes 25 independent reads; each registry workload makes 200 bound-home lookups, including the candidate's initial snapshot and final verification. One and 63 adopted homes are tested; candidate journal fixtures have the matching number of records. All calls returned complete evidence.++| Workload | Main elapsed / CPU (ms) | Candidate elapsed / CPU (ms) | Main / candidate peak RSS (MiB) |+| --- | ---: | ---: | ---: |+| Native, one home | 3.17 / 6.50 | 61.09 / 94.76 | 80.54 / 90.59 |+| Native, 63 homes | 6.44 / 14.30 | 439.43 / 514.44 | 82.79 / 91.75 |+| Registry batch, one home | 5.38 / 11.48 | 12.78 / 30.05 | 81.84 / 87.18 |+| Registry batch, 63 homes | 18.74 / 44.88 | 64.75 / 97.86 | 87.94 / 90.57 |++Values are medians across the three processes. Elapsed and CPU include the whole operation; imports and fixture construction are excluded, while peak RSS includes the process. Per-row latency samples exclude the batch proofs and must not be used as the whole-batch cost. Independent reads pay for fresh durable evidence (about 17.6 ms per read at 63 records in this workload); the explicit batch avoids paying that cost for every registry row. This is measured cost, not a claimed performance threshold. Subsequent lifecycle corrections only clear a transient reason when releasing or saving a stopped binding; the measured catalog and batch algorithms are unchanged.++## Compatibility and limits++The logical healthy catalog answers remain unchanged, but the physical persistence format changes. Older binaries only understand the imported baseline and do not discover homes written solely to the journal. This work does not claim downgrade compatibility. No CLI release is authorized. The user-owned baseline is preserved byte for byte, including when it is malformed or unavailable.++The checks detect bounded changes and incomplete evidence; they cannot cancel a blocked kernel filesystem operation or create an atomic snapshot of unrelated paths. Simultaneous erasure of every independent on-disk witness cannot be distinguished from a new installation by a fresh process. In-memory unacknowledged observations cannot survive process death unless their intent was published.++## Golden and validation evidence++The home-adoption golden was recorded from former main before production changes, in `843af5c3a`. Fresh-reader adapters and fixed performance clocks were first replayed against former code and committed separately (`92b48b8e7`, `227018162`, `74e030ea7`). Golden artifacts remain unchanged. Their private homes, pinned platforms, fixed clocks and forbidden host binaries make them independent of the host; commands use UTC and `/tmp`.++The validation plan includes typecheck, architecture, core/services and harnessd coverage at 100%, touched registry/home/repair/golden specs, serial resume, and private enginehomes/machine/chaos/tmux acceptance. The full Linux unit suite is provided by automatic ready-PR CI. Mutations run only in an owned disposable worktree, after a green baseline, and must fail an assertion rather than merely fail to import. Matched cost runs separately from local validation.++Independent review produced regressions for empty-environment recovery, late pool additions, imported baselines appearing during publication, ancestor/iterator redirection, peer hook recovery, directory changes after a numbered slot was checked, and observations lost across a held call. The final pass also found a hold reason surviving binding release and leaking into stopped snapshots. Public unbind/release routes now clear it, and stopped persistence strips it; regressions check sibling holds and raw saved bytes. Exact-head/base approval is recorded in [PR #1132](https://github.com/autonomous-ai/openharness/pull/1132) before landing.++Receipt `20261010T012509.817212Z-63290` on `0944754af` passed typecheck, 1,952 core/services tests across 163 files at 100% coverage, 265 harnessd tests at 100% with one existing skip, all 34 private enginehomes/machine/chaos tests, and 57 private tmux tests across six files (15 installed-vendor rows excluded). Seventeen focused files passed; the large-transcript resume file had one timeout under concurrent load. It must pass alone before landing. The unchanged golden baseline passed before all 19 initial wiring mutations failed assertions. Two additional mutations cover the final lifecycle corrections. Final corrected-source coverage, focused/serial results and exact-head automatic CI evidence are recorded in the PR before merge.++Intermediate failures are not counted as passing: one typecheck found a null narrowing error; a registry fixture depended on denied host boot-time inspection; a mock retained a previous test's module environment; and a save initially stripped the transient hold reason. Each received a correction and a targeted regression. The mutation runner also needed a unique directory-flush selector and a shutdown mutation that actually disconnected the close fence; neither runner error was counted as a caught mutant. Draft-only CI deliberately withholds `ci/required` until the PR is ready.++Implementation, validation, independent review/CI waiting, and merge are recorded separately in the PR. Publication remains zero.diff --git a/docs/research/2026-10-10-home-adoption-cost.json b/docs/research/2026-10-10-home-adoption-cost.jsonnew file mode 100644index 000000000..f4bb21e4c--- /dev/null+++ b/docs/research/2026-10-10-home-adoption-cost.json@@ -0,0 +1,3140 @@+{+ "baseline": "9eafacf3b512a0b1ffd23e0d446115896b01f7ed",+ "candidate": "0944754af3557100498ae7e251a9547849cd0506",+ "started": "2026-10-10T01:24:20.855893+00:00",+ "finished": "2026-10-10T01:24:28.161410+00:00",+ "samples": [+ {+ "source": "main",+ "repeat": 1,+ "workload": "native-one",+ "records": 1,+ "iterations": 25,+ "outcomes": {+ "complete": 25+ },+ "latenciesMs": [+ 0.628,+ 0.2117,+ 0.2266,+ 0.1992,+ 0.1293,+ 0.0999,+ 0.158,+ 0.1049,+ 0.0894,+ 0.0851,+ 0.0766,+ 0.0739,+ 0.0755,+ 0.0747,+ 0.0742,+ 0.072,+ 0.0723,+ 0.0728,+ 0.0731,+ 0.0776,+ 0.0723,+ 0.0725,+ 0.0715,+ 0.0729,+ 0.0726+ ],+ "elapsedMs": 3.1028770000000065,+ "cpuMs": 6.286,+ "peakRssMiB": 82.28515625,+ "node": "v22.23.2",+ "platform": "darwin",+ "arch": "x64"+ },+ {+ "source": "candidate",+ "repeat": 1,+ "workload": "native-one",+ "records": 1,+ "iterations": 25,+ "outcomes": {+ "complete": 25+ },+ "latenciesMs": [+ 5.4856,+ 3.5973,+ 3.3725,+ 3.9375,+ 3.1423,+ 2.626,+ 2.293,+ 2.3149,+ 2.3256,+ 2.4984,+ 1.9908,+ 1.9805,+ 2.0351,+ 2.0325,+ 1.9707,+ 2.114,+ 1.9103,+ 1.9038,+ 1.8954,+ 1.9325,+ 1.9057,+ 2.0639,+ 1.9186,+ 1.9355,+ 1.822+ ],+ "elapsedMs": 61.085785000000016,+ "cpuMs": 94.761,+ "peakRssMiB": 88.86328125,+ "node": "v22.23.2",+ "platform": "darwin",+ "arch": "x64"+ },+ {+ "source": "main",+ "repeat": 1,+ "workload": "native-full",+ "records": 63,+ "iterations": 25,+ "outcomes": {+ "complete": 25+ },+ "latenciesMs": [+ 0.869,+ 0.3347,+ 0.2555,+ 0.2125,+ 0.2125,+ 0.2101,+ 0.2975,+ 0.2342,+ 0.2342,+ 0.2378,+ 0.2436,+ 0.2205,+ 0.2174,+ 0.2187,+ 0.2333,+ 0.2119,+ 0.229,+ 0.221,+ 0.2374,+ 0.2275,+ 0.2224,+ 0.2048,+ 0.2021,+ 0.1984,+ 0.2075+ ],+ "elapsedMs": 6.453924000000001,+ "cpuMs": 14.238,+ "peakRssMiB": 82.7890625,+ "node": "v22.23.2",+ "platform": "darwin",+ "arch": "x64"+ },+ {+ "source": "candidate",+ "repeat": 1,+ "workload": "native-full",+ "records": 63,+ "iterations": 25,+ "outcomes": {+ "complete": 25+ },+ "latenciesMs": [+ 26.8859,+ 22.5004,+ 19.907,+ 18.6714,+ 19.5821,+ 18.8722,+ 17.7853,+ 17.3708,+ 17.2478,+ 18.066,+ 17.6114,+ 17.0393,+ 16.0671,+ 16.2033,+ 16.397,+ 15.7674,+ 15.9202,+ 15.7925,+ 15.8923,+ 15.9645,+ 15.9993,+ 16.1757,+ 16.2003,+ 15.8849,+ 15.5299+ ],+ "elapsedMs": 439.42944399999993,+ "cpuMs": 514.438,+ "peakRssMiB": 91.74609375,+ "node": "v22.23.2",+ "platform": "darwin",+ "arch": "x64"+ },+ {+ "source": "main",+ "repeat": 1,+ "workload": "registry-one",+ "records": 1,+ "iterations": 200,+ "outcomes": {+ "complete": 200+ },+ "latenciesMs": [+ 0.3633,+ 0.0427,+ 0.0328,+ 0.0324,+ 0.0337,+ 0.0307,+ 0.0971,+ 0.0507,+ 0.0323,+ 0.0339,+ 0.0256,+ 0.0249,+ 0.0232,+ 0.0228,+ 0.0225,+ 0.022,+ 0.0284,+ 0.0222,+ 0.0236,+ 0.0221,+ 0.022,+ 0.0224,+ 0.0218,+ 0.022,+ 0.0219,+ 0.022,+ 0.0221,+ 0.0218,+ 0.0219,+ 0.022,+ 0.0219,+ 0.0218,+ 0.022,+ 0.0219,+ 0.08,+ 0.0298,+ 0.0242,+ 0.0227,+ 0.0222,+ 0.0233,+ 0.0219,+ 0.0218,+ 0.0215,+ 0.0219,+ 0.0216,+ 0.0216,+ 0.0217,+ 0.0217,+ 0.0215,+ 0.0216,+ 0.0281,+ 0.0273,+ 0.0218,+ 0.0195,+ 0.019,+ 0.0188,+ 0.0187,+ 0.0186,+ 0.0188,+ 0.0186,+ 0.0186,+ 0.0188,+ 0.0184,+ 0.0192,+ 0.0186,+ 0.0186,+ 0.0194,+ 0.0193,+ 0.0189,+ 0.0187,+ 0.0185,+ 0.0186,+ 0.0187,+ 0.019,+ 0.0186,+ 0.0186,+ 0.0188,+ 0.0186,+ 0.0186,+ 0.0186,+ 0.0188,+ 0.0187,+ 0.0184,+ 0.0191,+ 0.0186,+ 0.0188,+ 0.0188,+ 0.0189,+ 0.0186,+ 0.0185,+ 0.0186,+ 0.0186,+ 0.0183,+ 0.0187,+ 0.0194,+ 0.019,+ 0.0186,+ 0.0188,+ 0.0185,+ 0.0184,+ 0.0189,+ 0.0188,+ 0.0188,+ 0.019,+ 0.0185,+ 0.0185,+ 0.0188,+ 0.0186,+ 0.0186,+ 0.0185,+ 0.0186,+ 0.0185,+ 0.0188,+ 0.0187,+ 0.0187,+ 0.0186,+ 0.0187,+ 0.0184,+ 0.0189,+ 0.0187,+ 0.0186,+ 0.0185,+ 0.0229,+ 0.0251,+ 0.0227,+ 0.0227,+ 0.0244,+ 0.023,+ 0.0226,+ 0.0232,+ 0.0242,+ 0.0415,+ 0.0264,+ 0.0237,+ 0.0252,+ 0.023,+ 0.0237,+ 0.0247,+ 0.0238,+ 0.0232,+ 0.0235,+ 0.035,+ 0.0234,+ 0.0247,+ 0.0227,+ 0.0506,+ 0.0234,+ 0.025,+ 0.0225,+ 0.0224,+ 0.0261,+ 0.0234,+ 0.0233,+ 0.0227,+ 0.0243,+ 0.0226,+ 0.0231,+ 0.0229,+ 0.0226,+ 0.0225,+ 0.023,+ 0.0245,+ 0.0225,+ 0.0228,+ 0.0229,+ 0.0246,+ 0.0231,+ 0.0327,+ 0.024,+ 0.0227,+ 0.0226,+ 0.023,+ 0.024,+ 0.0228,+ 0.023,+ 0.0231,+ 0.0242,+ 0.0228,+ 0.0238,+ 0.0244,+ 0.0229,+ 0.024,+ 0.0356,+ 0.0278,+ 0.0233,+ 0.0236,+ 0.0236,+ 0.0249,+ 0.0229,+ 0.023,+ 0.0256,+ 0.0233,+ 0.0227,+ 0.0233,+ 0.0248,+ 0.0228,+ 0.0233,+ 0.023,+ 0.0247,+ 0.0226+ ],+ "elapsedMs": 5.321852000000007,+ "cpuMs": 11.133,+ "peakRssMiB": 81.8359375,+ "node": "v22.23.2",+ "platform": "darwin",+ "arch": "x64"+ },+ {+ "source": "candidate",+ "repeat": 1,+ "workload": "registry-one",+ "records": 1,+ "iterations": 200,+ "outcomes": {+ "complete": 200+ },+ "latenciesMs": [+ 0.1954,+ 0.0221,+ 0.0171,+ 0.0172,+ 0.0198,+ 0.0243,+ 0.0187,+ 0.0278,+ 0.0203,+ 0.0346,+ 0.0166,+ 0.0158,+ 0.015,+ 0.0139,+ 0.0149,+ 0.015,+ 0.0133,+ 0.0152,+ 0.0149,+ 0.0135,+ 0.0147,+ 0.0147,+ 0.0134,+ 0.015,+ 0.0148,+ 0.0134,+ 0.0149,+ 0.015,+ 0.0146,+ 0.016,+ 0.0148,+ 0.0133,+ 0.0151,+ 0.0135,+ 0.0388,+ 0.0173,+ 0.0134,+ 0.0155,+ 0.0171,+ 0.0134,+ 0.0153,+ 0.015,+ 0.0125,+ 0.0141,+ 0.0152,+ 0.015,+ 0.0135,+ 0.0151,+ 0.0419,+ 0.0143,+ 0.0245,+ 0.0214,+ 0.0145,+ 0.0134,+ 0.0134,+ 0.0113,+ 0.0128,+ 0.013,+ 0.0112,+ 0.0126,+ 0.0113,+ 0.011,+ 0.0128,+ 0.0112,+ 0.0129,+ 0.018,+ 0.0113,+ 0.0133,+ 0.0126,+ 0.0111,+ 0.0127,+ 0.013,+ 0.0113,+ 0.013,+ 0.0123,+ 0.0108,+ 0.0125,+ 0.0127,+ 0.0109,+ 0.0131,+ 0.0128,+ 0.0113,+ 0.0149,+ 0.0235,+ 0.0131,+ 0.0109,+ 0.0126,+ 0.0128,+ 0.0112,+ 0.0133,+ 0.0126,+ 0.011,+ 0.0125,+ 0.0128,+ 0.0114,+ 0.0126,+ 0.0128,+ 0.0109,+ 0.0124,+ 0.014,+ 0.0127,+ 0.0128,+ 0.0126,+ 0.011,+ 0.0131,+ 0.0131,+ 0.0111,+ 0.0129,+ 0.0127,+ 0.011,+ 0.0129,+ 0.0127,+ 0.0119,+ 0.0136,+ 0.0131,+ 0.0115,+ 0.0133,+ 0.0117,+ 0.012,+ 0.0123,+ 0.0126,+ 0.0107,+ 0.013,+ 0.0129,+ 0.0113,+ 0.0127,+ 0.013,+ 0.0111,+ 0.0128,+ 0.0128,+ 0.0114,+ 0.0129,+ 0.0126,+ 0.0112,+ 0.0124,+ 0.0127,+ 0.0116,+ 0.0123,+ 0.0123,+ 0.0112,+ 0.0124,+ 0.0124,+ 0.0128,+ 0.011,+ 0.0125,+ 0.0126,+ 0.0108,+ 0.0121,+ 0.0126,+ 0.011,+ 0.0129,+ 0.0129,+ 0.0112,+ 0.0123,+ 0.0131,+ 0.0098,+ 0.0135,+ 0.0126,+ 0.0108,+ 0.0123,+ 0.0122,+ 0.0198,+ 0.0129,+ 0.0127,+ 0.0111,+ 0.0127,+ 0.0126,+ 0.0107,+ 0.0115,+ 0.0126,+ 0.011,+ 0.0109,+ 0.0125,+ 0.0107,+ 0.011,+ 0.0126,+ 0.011,+ 0.011,+ 0.0123,+ 0.011,+ 0.0116,+ 0.0137,+ 0.026,+ 0.0128,+ 0.0133,+ 0.0109,+ 0.0113,+ 0.0125,+ 0.0147,+ 0.0123,+ 0.0129,+ 0.0109,+ 0.0117,+ 0.0194,+ 0.0138,+ 0.0112,+ 0.0129,+ 0.027,+ 0.0114,+ 0.0127+ ],+ "elapsedMs": 12.958547999999979,+ "cpuMs": 30.517,+ "peakRssMiB": 88.640625,+ "node": "v22.23.2",+ "platform": "darwin",+ "arch": "x64"+ },+ {+ "source": "main",+ "repeat": 1,+ "workload": "registry-full",+ "records": 63,+ "iterations": 200,+ "outcomes": {+ "complete": 200+ },+ "latenciesMs": [+ 0.3827,+ 0.0598,+ 0.0505,+ 0.0459,+ 0.0495,+ 0.0497,+ 0.1309,+ 0.0686,+ 0.0625,+ 0.0683,+ 0.0613,+ 0.0609,+ 0.0655,+ 0.0678,+ 0.0708,+ 0.0742,+ 0.0776,+ 0.0808,+ 0.0856,+ 0.088,+ 0.0906,+ 0.0944,+ 0.1163,+ 0.1202,+ 0.1856,+ 0.2144,+ 0.1582,+ 0.155,+ 0.148,+ 0.1499,+ 0.152,+ 0.1589,+ 0.1619,+ 0.1685,+ 0.2548,+ 0.1863,+ 0.1821,+ 0.1845,+ 0.2055,+ 0.1909,+ 0.2103,+ 0.1996,+ 0.2009,+ 0.2481,+ 0.2138,+ 0.2636,+ 0.2324,+ 0.223,+ 0.61,+ 0.1116,+ 0.1013,+ 0.0985,+ 0.0988,+ 0.1151,+ 0.1051,+ 0.1041,+ 0.1082,+ 0.1099,+ 0.1088,+ 0.1087,+ 0.1141,+ 0.1162,+ 0.1237,+ 0.0211,+ 0.0187,+ 0.0209,+ 0.0218,+ 0.0232,+ 0.0266,+ 0.0256,+ 0.0267,+ 0.0284,+ 0.03,+ 0.0487,+ 0.0365,+ 0.0357,+ 0.0755,+ 0.0531,+ 0.054,+ 0.0563,+ 0.0593,+ 0.0616,+ 0.0638,+ 0.0635,+ 0.0744,+ 0.0698,+ 0.0693,+ 0.0711,+ 0.0737,+ 0.0756,+ 0.0794,+ 0.0807,+ 0.0824,+ 0.0842,+ 0.0979,+ 0.0897,+ 0.0902,+ 0.1092,+ 0.0967,+ 0.1013,+ 0.1049,+ 0.1146,+ 0.1056,+ 0.1064,+ 0.1289,+ 0.1171,+ 0.1154,+ 0.1148,+ 0.1292,+ 0.1191,+ 0.4627,+ 0.1136,+ 0.0972,+ 0.0961,+ 0.0952,+ 0.0981,+ 0.0997,+ 0.0997,+ 0.1323,+ 0.102,+ 0.0997,+ 0.1001,+ 0.1016,+ 0.1036,+ 0.1041,+ 0.1061,+ 0.0176,+ 0.0187,+ 0.1179,+ 0.0307,+ 0.0233,+ 0.0244,+ 0.0253,+ 0.027,+ 0.0279,+ 0.0292,+ 0.0323,+ 0.0331,+ 0.0342,+ 0.0359,+ 0.0368,+ 0.0388,+ 0.039,+ 0.044,+ 0.0426,+ 0.0437,+ 0.0452,+ 0.0478,+ 0.0502,+ 0.0517,+ 0.0524,+ 0.0533,+ 0.0537,+ 0.055,+ 0.0566,+ 0.0578,+ 0.0608,+ 0.0607,+ 0.0631,+ 0.0637,+ 0.0649,+ 0.0668,+ 0.0688,+ 0.0692,+ 0.0725,+ 0.0724,+ 0.079,+ 0.0749,+ 0.0775,+ 0.0789,+ 0.0795,+ 0.0813,+ 0.0835,+ 0.0846,+ 0.0856,+ 0.2621,+ 0.1122,+ 0.0948,+ 0.0924,+ 0.0934,+ 0.0954,+ 0.0976,+ 0.0976,+ 0.0976,+ 0.1096,+ 0.1526,+ 0.1109,+ 0.1131,+ 0.1118,+ 0.0217,+ 0.0192,+ 0.0194,+ 0.0222,+ 0.0227,+ 0.0238,+ 0.0247,+ 0.0263,+ 0.028,+ 0.0306,+ 0.032+ ],+ "elapsedMs": 19.067436999999984,+ "cpuMs": 45.431,+ "peakRssMiB": 87.71875,+ "node": "v22.23.2",+ "platform": "darwin",+ "arch": "x64"+ },+ {+ "source": "candidate",+ "repeat": 1,+ "workload": "registry-full",+ "records": 63,+ "iterations": 200,+ "outcomes": {+ "complete": 200+ },+ "latenciesMs": [+ 0.1973,+ 0.0434,+ 0.0365,+ 0.0371,+ 0.0388,+ 0.0432,+ 0.0445,+ 0.0478,+ 0.052,+ 0.0917,+ 0.0598,+ 0.0636,+ 0.0654,+ 0.0708,+ 0.0848,+ 0.0784,+ 0.0831,+ 0.0865,+ 0.0898,+ 0.0924,+ 0.0964,+ 0.1018,+ 0.1023,+ 0.1089,+ 0.1245,+ 0.1198,+ 0.1325,+ 0.1274,+ 0.1283,+ 0.1339,+ 0.1395,+ 0.1413,+ 0.1578,+ 0.1476,+ 0.1509,+ 0.1642,+ 0.1598,+ 0.1649,+ 0.1684,+ 0.1696,+ 0.4909,+ 0.1551,+ 0.1533,+ 0.1547,+ 0.1594,+ 0.1784,+ 0.1659,+ 0.1683,+ 0.1714,+ 0.1751,+ 0.1774,+ 0.1984,+ 0.0944,+ 0.1045,+ 0.0967,+ 0.0967,+ 0.0983,+ 0.0995,+ 0.1012,+ 0.1031,+ 0.1486,+ 0.119,+ 0.1049,+ 0.0109,+ 0.0114,+ 0.0127,+ 0.0141,+ 0.0155,+ 0.0167,+ 0.0191,+ 0.0198,+ 0.0212,+ 0.0226,+ 0.0377,+ 0.0276,+ 0.0284,+ 0.0298,+ 0.0307,+ 0.0321,+ 0.0338,+ 0.0352,+ 0.0369,+ 0.0379,+ 0.0401,+ 0.0414,+ 0.0439,+ 0.045,+ 0.0464,+ 0.0486,+ 0.0499,+ 0.0502,+ 0.0515,+ 0.0527,+ 0.0553,+ 0.0559,+ 0.0601,+ 0.0586,+ 0.0607,+ 0.0624,+ 0.0634,+ 0.0653,+ 0.0666,+ 0.0685,+ 0.0692,+ 0.0815,+ 0.0738,+ 0.2072,+ 0.0848,+ 0.0794,+ 0.0802,+ 0.0816,+ 0.0817,+ 0.084,+ 0.0841,+ 0.0863,+ 0.088,+ 0.0898,+ 0.0925,+ 0.0925,+ 0.0933,+ 0.0959,+ 0.116,+ 0.0944,+ 0.0937,+ 0.0946,+ 0.0971,+ 0.0102,+ 0.0109,+ 0.0135,+ 0.0136,+ 0.0151,+ 0.0163,+ 0.0177,+ 0.0189,+ 0.0202,+ 0.0218,+ 0.0238,+ 0.0248,+ 0.0263,+ 0.0277,+ 0.0293,+ 0.0301,+ 0.0316,+ 0.0332,+ 0.035,+ 0.036,+ 0.0372,+ 0.0391,+ 0.0416,+ 0.0432,+ 0.0449,+ 0.0461,+ 0.0479,+ 0.047,+ 0.049,+ 0.05,+ 0.0511,+ 0.0533,+ 0.054,+ 0.0566,+ 0.0568,+ 0.0579,+ 0.0596,+ 0.0639,+ 0.0629,+ 0.0639,+ 0.0653,+ 0.0672,+ 0.0678,+ 0.0686,+ 0.0716,+ 0.0722,+ 0.0743,+ 0.1911,+ 0.0867,+ 0.0801,+ 0.081,+ 0.0818,+ 0.0834,+ 0.0838,+ 0.0852,+ 0.0873,+ 0.0892,+ 0.0902,+ 0.0915,+ 0.0928,+ 0.0936,+ 0.096,+ 0.0988,+ 0.0106,+ 0.0113,+ 0.0125,+ 0.0137,+ 0.0162,+ 0.0309,+ 0.0185,+ 0.0192,+ 0.0207,+ 0.022,+ 0.0237+ ],+ "elapsedMs": 64.75119799999999,+ "cpuMs": 94.797,+ "peakRssMiB": 90.5703125,+ "node": "v22.23.2",+ "platform": "darwin",+ "arch": "x64"+ },+ {+ "source": "candidate",+ "repeat": 2,+ "workload": "native-one",+ "records": 1,+ "iterations": 25,+ "outcomes": {+ "complete": 25+ },+ "latenciesMs": [+ 5.4609,+ 3.7399,+ 3.5146,+ 3.6966,+ 2.527,+ 2.4931,+ 2.4341,+ 2.4453,+ 2.4617,+ 2.657,+ 2.0389,+ 2.0175,+ 2.0894,+ 2.0357,+ 2.0348,+ 2.2957,+ 2.0489,+ 1.973,+ 1.9834,+ 2.0112,+ 1.9875,+ 2.2076,+ 2.0475,+ 2.0102,+ 1.8971+ ],+ "elapsedMs": 62.19510299999999,+ "cpuMs": 94.893,+ "peakRssMiB": 90.59375,+ "node": "v22.23.2",+ "platform": "darwin",+ "arch": "x64"+ },+ {+ "source": "main",+ "repeat": 2,+ "workload": "native-one",+ "records": 1,+ "iterations": 25,+ "outcomes": {+ "complete": 25+ },+ "latenciesMs": [+ 0.6305,+ 0.2143,+ 0.2265,+ 0.202,+ 0.1351,+ 0.1034,+ 0.1584,+ 0.11,+ 0.0913,+ 0.0866,+ 0.0789,+ 0.0756,+ 0.0754,+ 0.0761,+ 0.0769,+ 0.0748,+ 0.0744,+ 0.0872,+ 0.0808,+ 0.0764,+ 0.0743,+ 0.0747,+ 0.074,+ 0.0736,+ 0.0753+ ],+ "elapsedMs": 3.173173999999989,+ "cpuMs": 6.497,+ "peakRssMiB": 77.8203125,+ "node": "v22.23.2",+ "platform": "darwin",+ "arch": "x64"+ },+ {+ "source": "candidate",+ "repeat": 2,+ "workload": "native-full",+ "records": 63,+ "iterations": 25,+ "outcomes": {+ "complete": 25+ },+ "latenciesMs": [+ 31.197,+ 22.4728,+ 19.8077,+ 19.1096,+ 19.151,+ 18.0701,+ 17.3425,+ 17.3962,+ 17.4057,+ 17.1841,+ 17.3029,+ 17.108,+ 16.6513,+ 16.4603,+ 16.8719,+ 16.4854,+ 16.743,+ 16.1606,+ 16.3995,+ 16.6162,+ 16.1784,+ 15.9735,+ 16.2419,+ 16.0596,+ 15.8414+ ],+ "elapsedMs": 446.340416,+ "cpuMs": 524.379,+ "peakRssMiB": 93.14453125,+ "node": "v22.23.2",+ "platform": "darwin",+ "arch": "x64"+ },+ {+ "source": "main",+ "repeat": 2,+ "workload": "native-full",+ "records": 63,+ "iterations": 25,+ "outcomes": {+ "complete": 25+ },+ "latenciesMs": [+ 0.8528,+ 0.3292,+ 0.2524,+ 0.2114,+ 0.2136,+ 0.2129,+ 0.2972,+ 0.2049,+ 0.2506,+ 0.2381,+ 0.2206,+ 0.2173,+ 0.2253,+ 0.2203,+ 0.2311,+ 0.216,+ 0.2336,+ 0.2423,+ 0.2471,+ 0.2282,+ 0.2171,+ 0.2012,+ 0.204,+ 0.2043,+ 0.2091+ ],+ "elapsedMs": 6.440832999999998,+ "cpuMs": 14.295,+ "peakRssMiB": 84.16015625,+ "node": "v22.23.2",+ "platform": "darwin",+ "arch": "x64"+ },+ {+ "source": "candidate",+ "repeat": 2,+ "workload": "registry-one",+ "records": 1,+ "iterations": 200,+ "outcomes": {+ "complete": 200+ },+ "latenciesMs": [+ 0.1915,+ 0.0241,+ 0.0209,+ 0.0209,+ 0.0232,+ 0.0215,+ 0.0178,+ 0.0233,+ 0.0198,+ 0.023,+ 0.0164,+ 0.0158,+ 0.0131,+ 0.0135,+ 0.0149,+ 0.013,+ 0.0148,+ 0.0148,+ 0.0144,+ 0.0131,+ 0.0149,+ 0.0135,+ 0.0133,+ 0.0149,+ 0.0128,+ 0.0146,+ 0.0151,+ 0.0128,+ 0.0145,+ 0.0149,+ 0.0127,+ 0.0145,+ 0.014,+ 0.0137,+ 0.0334,+ 0.0162,+ 0.0134,+ 0.0147,+ 0.0153,+ 0.013,+ 0.0153,+ 0.0149,+ 0.0159,+ 0.015,+ 0.0143,+ 0.0131,+ 0.0132,+ 0.0144,+ 0.0131,+ 0.028,+ 0.022,+ 0.0187,+ 0.0154,+ 0.0133,+ 0.0109,+ 0.0126,+ 0.012,+ 0.0111,+ 0.013,+ 0.0137,+ 0.0106,+ 0.0126,+ 0.0128,+ 0.011,+ 0.0125,+ 0.0127,+ 0.011,+ 0.0121,+ 0.0124,+ 0.0119,+ 0.0121,+ 0.0344,+ 0.0115,+ 0.0225,+ 0.0128,+ 0.0108,+ 0.0124,+ 0.0127,+ 0.011,+ 0.0128,+ 0.0123,+ 0.0114,+ 0.0128,+ 0.0127,+ 0.0124,+ 0.0111,+ 0.0126,+ 0.0123,+ 0.011,+ 0.0124,+ 0.0124,+ 0.0106,+ 0.0128,+ 0.0125,+ 0.011,+ 0.0127,+ 0.0107,+ 0.0108,+ 0.0126,+ 0.011,+ 0.0116,+ 0.0128,+ 0.0107,+ 0.0132,+ 0.0124,+ 0.0105,+ 0.0128,+ 0.0125,+ 0.0118,+ 0.0111,+ 0.012,+ 0.0125,+ 0.0111,+ 0.0124,+ 0.0109,+ 0.0111,+ 0.0131,+ 0.0113,+ 0.0111,+ 0.0127,+ 0.0113,+ 0.0132,+ 0.0132,+ 0.0109,+ 0.0127,+ 0.0131,+ 0.0113,+ 0.0127,+ 0.0133,+ 0.0109,+ 0.0128,+ 0.0124,+ 0.0109,+ 0.0134,+ 0.013,+ 0.0106,+ 0.0125,+ 0.0124,+ 0.0108,+ 0.013,+ 0.0125,+ 0.0128,+ 0.0125,+ 0.0112,+ 0.0126,+ 0.0118,+ 0.0123,+ 0.0128,+ 0.0127,+ 0.0109,+ 0.0221,+ 0.0126,+ 0.011,+ 0.0123,+ 0.0129,+ 0.011,+ 0.0127,+ 0.012,+ 0.0109,+ 0.0126,+ 0.0126,+ 0.0109,+ 0.0124,+ 0.0124,+ 0.011,+ 0.0123,+ 0.0122,+ 0.011,+ 0.0123,+ 0.012,+ 0.011,+ 0.0127,+ 0.012,+ 0.011,+ 0.0127,+ 0.0123,+ 0.0109,+ 0.0125,+ 0.0127,+ 0.0108,+ 0.0124,+ 0.0137,+ 0.0246,+ 0.0151,+ 0.0183,+ 0.0115,+ 0.013,+ 0.0124,+ 0.0107,+ 0.0128,+ 0.0126,+ 0.0109,+ 0.0111,+ 0.0127,+ 0.011,+ 0.0108,+ 0.0125,+ 0.0111,+ 0.0112,+ 0.0125+ ],+ "elapsedMs": 12.506032999999974,+ "cpuMs": 29.524,+ "peakRssMiB": 87.1796875,+ "node": "v22.23.2",+ "platform": "darwin",+ "arch": "x64"+ },+ {+ "source": "main",+ "repeat": 2,+ "workload": "registry-one",+ "records": 1,+ "iterations": 200,+ "outcomes": {+ "complete": 200+ },+ "latenciesMs": [+ 0.3619,+ 0.0448,+ 0.0324,+ 0.0315,+ 0.0343,+ 0.0339,+ 0.127,+ 0.0673,+ 0.0368,+ 0.0362,+ 0.0285,+ 0.0319,+ 0.0266,+ 0.0236,+ 0.0229,+ 0.0243,+ 0.0227,+ 0.0226,+ 0.0237,+ 0.0227,+ 0.0228,+ 0.0223,+ 0.0231,+ 0.0229,+ 0.0225,+ 0.0224,+ 0.0225,+ 0.0227,+ 0.0224,+ 0.0224,+ 0.0227,+ 0.0219,+ 0.0222,+ 0.0221,+ 0.0797,+ 0.0294,+ 0.0233,+ 0.0224,+ 0.0218,+ 0.0217,+ 0.0217,+ 0.0217,+ 0.0217,+ 0.0229,+ 0.022,+ 0.0216,+ 0.0216,+ 0.0218,+ 0.0217,+ 0.0217,+ 0.0279,+ 0.0273,+ 0.0225,+ 0.0193,+ 0.0191,+ 0.0189,+ 0.019,+ 0.0188,+ 0.0186,+ 0.0187,+ 0.0186,+ 0.0184,+ 0.0189,+ 0.0185,+ 0.0185,+ 0.0186,+ 0.0184,+ 0.0184,+ 0.0187,+ 0.0185,+ 0.0187,+ 0.0197,+ 0.0186,+ 0.0184,+ 0.0184,+ 0.0184,+ 0.0186,+ 0.0187,+ 0.0187,+ 0.0187,+ 0.0187,+ 0.0185,+ 0.0187,+ 0.0188,+ 0.0186,+ 0.0187,+ 0.0185,+ 0.0192,+ 0.0189,+ 0.0185,+ 0.0188,+ 0.0189,+ 0.019,+ 0.0189,+ 0.0189,+ 0.0185,+ 0.0186,+ 0.0186,+ 0.0193,+ 0.0191,+ 0.0187,+ 0.019,+ 0.0187,+ 0.0183,+ 0.0187,+ 0.0186,+ 0.0187,+ 0.0187,+ 0.0187,+ 0.0185,+ 0.0187,+ 0.0184,+ 0.0186,+ 0.0187,+ 0.0186,+ 0.0185,+ 0.0185,+ 0.0188,+ 0.019,+ 0.0185,+ 0.0185,+ 0.0188,+ 0.0187,+ 0.0187,+ 0.0186,+ 0.0186,+ 0.0232,+ 0.0236,+ 0.0239,+ 0.0238,+ 0.0245,+ 0.0422,+ 0.0263,+ 0.025,+ 0.023,+ 0.0229,+ 0.0235,+ 0.0245,+ 0.024,+ 0.0231,+ 0.0235,+ 0.0362,+ 0.0252,+ 0.0255,+ 0.0238,+ 0.0229,+ 0.0248,+ 0.0231,+ 0.0236,+ 0.0234,+ 0.0248,+ 0.0226,+ 0.0232,+ 0.0228,+ 0.0254,+ 0.0233,+ 0.0235,+ 0.0246,+ 0.0231,+ 0.0229,+ 0.0231,+ 0.0246,+ 0.0234,+ 0.0325,+ 0.0252,+ 0.0267,+ 0.0229,+ 0.0233,+ 0.0245,+ 0.0233,+ 0.0235,+ 0.0256,+ 0.0249,+ 0.0233,+ 0.0232,+ 0.0253,+ 0.0252,+ 0.0229,+ 0.0232,+ 0.0247,+ 0.0235,+ 0.0233,+ 0.037,+ 0.0251,+ 0.023,+ 0.0231,+ 0.0244,+ 0.0224,+ 0.0231,+ 0.0227,+ 0.0244,+ 0.0227,+ 0.0226,+ 0.0248,+ 0.0234,+ 0.0234,+ 0.0233,+ 0.0248,+ 0.0228,+ 0.0229+ ],+ "elapsedMs": 5.374583000000001,+ "cpuMs": 11.482,+ "peakRssMiB": 84.515625,+ "node": "v22.23.2",+ "platform": "darwin",+ "arch": "x64"+ },+ {+ "source": "candidate",+ "repeat": 2,+ "workload": "registry-full",+ "records": 63,+ "iterations": 200,+ "outcomes": {+ "complete": 200+ },+ "latenciesMs": [+ 0.2017,+ 0.0429,+ 0.037,+ 0.0336,+ 0.0502,+ 0.0417,+ 0.0425,+ 0.0471,+ 0.0514,+ 0.063,+ 0.0614,+ 0.1415,+ 0.0815,+ 0.0977,+ 0.0773,+ 0.0794,+ 0.0825,+ 0.0917,+ 0.0906,+ 0.0954,+ 0.0999,+ 0.1176,+ 0.106,+ 0.1124,+ 0.1412,+ 0.1234,+ 0.1239,+ 0.1557,+ 0.1297,+ 0.1353,+ 0.1362,+ 0.1499,+ 0.1462,+ 0.1468,+ 0.1522,+ 0.1572,+ 0.1581,+ 0.1625,+ 0.1766,+ 0.5674,+ 0.1562,+ 0.1524,+ 0.1523,+ 0.1551,+ 0.1613,+ 0.1785,+ 0.1667,+ 0.1694,+ 0.172,+ 0.1754,+ 0.1789,+ 0.1441,+ 0.0952,+ 0.1038,+ 0.0963,+ 0.0976,+ 0.0986,+ 0.0994,+ 0.1019,+ 0.1029,+ 0.1545,+ 0.1216,+ 0.107,+ 0.0107,+ 0.0115,+ 0.0127,+ 0.0142,+ 0.0156,+ 0.0168,+ 0.0181,+ 0.0198,+ 0.0213,+ 0.0226,+ 0.0247,+ 0.0263,+ 0.0283,+ 0.0292,+ 0.0309,+ 0.0326,+ 0.0344,+ 0.0366,+ 0.0373,+ 0.0399,+ 0.0516,+ 0.044,+ 0.044,+ 0.0446,+ 0.0463,+ 0.048,+ 0.0494,+ 0.0516,+ 0.0539,+ 0.0545,+ 0.0582,+ 0.0569,+ 0.0577,+ 0.0632,+ 0.0623,+ 0.0626,+ 0.0842,+ 0.0677,+ 0.0684,+ 0.0687,+ 0.0702,+ 0.2389,+ 0.0836,+ 0.0778,+ 0.0783,+ 0.0793,+ 0.0802,+ 0.0824,+ 0.0834,+ 0.0848,+ 0.0877,+ 0.0893,+ 0.0892,+ 0.0909,+ 0.0926,+ 0.0937,+ 0.0961,+ 0.1132,+ 0.0938,+ 0.0921,+ 0.0939,+ 0.0965,+ 0.0966,+ 0.0103,+ 0.0111,+ 0.0134,+ 0.0137,+ 0.0155,+ 0.0166,+ 0.0176,+ 0.0192,+ 0.0204,+ 0.0218,+ 0.0242,+ 0.0247,+ 0.0263,+ 0.0284,+ 0.0304,+ 0.0321,+ 0.033,+ 0.0339,+ 0.0361,+ 0.0376,+ 0.0382,+ 0.0396,+ 0.0402,+ 0.042,+ 0.0432,+ 0.0445,+ 0.0461,+ 0.047,+ 0.0493,+ 0.0504,+ 0.0513,+ 0.0538,+ 0.055,+ 0.0561,+ 0.0587,+ 0.0748,+ 0.0778,+ 0.0689,+ 0.0645,+ 0.0643,+ 0.0657,+ 0.0664,+ 0.0686,+ 0.0696,+ 0.071,+ 0.1954,+ 0.0789,+ 0.0774,+ 0.0912,+ 0.0863,+ 0.0802,+ 0.0809,+ 0.0827,+ 0.0927,+ 0.0866,+ 0.087,+ 0.0899,+ 0.0902,+ 0.0964,+ 0.0949,+ 0.0936,+ 0.0956,+ 0.0965,+ 0.0106,+ 0.0109,+ 0.0125,+ 0.0135,+ 0.0164,+ 0.0318,+ 0.0183,+ 0.0192,+ 0.022,+ 0.022,+ 0.0242+ ],+ "elapsedMs": 64.54144300000002,+ "cpuMs": 97.859,+ "peakRssMiB": 91.46875,+ "node": "v22.23.2",+ "platform": "darwin",+ "arch": "x64"+ },+ {+ "source": "main",+ "repeat": 2,+ "workload": "registry-full",+ "records": 63,+ "iterations": 200,+ "outcomes": {+ "complete": 200+ },+ "latenciesMs": [+ 0.3734,+ 0.0596,+ 0.048,+ 0.0449,+ 0.0471,+ 0.0504,+ 0.133,+ 0.0688,+ 0.0588,+ 0.0674,+ 0.0623,+ 0.0636,+ 0.0654,+ 0.0664,+ 0.0692,+ 0.0728,+ 0.0759,+ 0.0792,+ 0.0827,+ 0.0855,+ 0.089,+ 0.0923,+ 0.1172,+ 0.1308,+ 0.1545,+ 0.1427,+ 0.1494,+ 0.1481,+ 0.1482,+ 0.1497,+ 0.1629,+ 0.1861,+ 0.1939,+ 0.17,+ 0.2339,+ 0.1816,+ 0.1789,+ 0.1801,+ 0.1948,+ 0.1998,+ 0.2045,+ 0.1951,+ 0.2001,+ 0.2289,+ 0.2223,+ 0.2402,+ 0.2122,+ 0.2143,+ 0.6215,+ 0.1135,+ 0.1002,+ 0.098,+ 0.0982,+ 0.1145,+ 0.1043,+ 0.1036,+ 0.1045,+ 0.1051,+ 0.1073,+ 0.109,+ 0.111,+ 0.1236,+ 0.1147,+ 0.0198,+ 0.019,+ 0.02,+ 0.022,+ 0.0233,+ 0.0247,+ 0.0259,+ 0.0276,+ 0.0289,+ 0.0312,+ 0.032,+ 0.0335,+ 0.0462,+ 0.0514,+ 0.0551,+ 0.0732,+ 0.0616,+ 0.0586,+ 0.0794,+ 0.0636,+ 0.0659,+ 0.0681,+ 0.0681,+ 0.0806,+ 0.0736,+ 0.0734,+ 0.0757,+ 0.0767,+ 0.0806,+ 0.0817,+ 0.0868,+ 0.0873,+ 0.1001,+ 0.0928,+ 0.0954,+ 0.0993,+ 0.1144,+ 0.109,+ 0.1039,+ 0.1051,+ 0.1141,+ 0.1205,+ 0.1119,+ 0.111,+ 0.1172,+ 0.1162,+ 0.127,+ 0.3724,+ 0.1026,+ 0.0932,+ 0.0941,+ 0.0946,+ 0.0971,+ 0.0977,+ 0.1232,+ 0.1013,+ 0.0966,+ 0.0971,+ 0.0989,+ 0.1011,+ 0.1022,+ 0.1033,+ 0.1048,+ 0.2235,+ 0.0199,+ 0.0198,+ 0.0206,+ 0.0218,+ 0.0235,+ 0.0247,+ 0.0263,+ 0.0275,+ 0.0285,+ 0.0315,+ 0.0321,+ 0.0334,+ 0.0348,+ 0.0362,+ 0.0376,+ 0.0387,+ 0.0405,+ 0.0418,+ 0.0432,+ 0.0447,+ 0.046,+ 0.0473,+ 0.0494,+ 0.0512,+ 0.0518,+ 0.0536,+ 0.0546,+ 0.057,+ 0.0582,+ 0.0596,+ 0.0605,+ 0.0624,+ 0.0628,+ 0.0639,+ 0.0654,+ 0.0679,+ 0.0685,+ 0.0707,+ 0.0726,+ 0.0767,+ 0.0747,+ 0.0752,+ 0.0781,+ 0.0809,+ 0.0807,+ 0.0813,+ 0.0836,+ 0.0843,+ 0.2721,+ 0.1094,+ 0.0948,+ 0.0917,+ 0.0932,+ 0.0944,+ 0.0945,+ 0.0965,+ 0.0967,+ 0.1002,+ 0.1192,+ 0.1038,+ 0.1068,+ 0.1045,+ 0.0181,+ 0.0185,+ 0.0197,+ 0.0211,+ 0.0227,+ 0.0235,+ 0.025,+ 0.0264,+ 0.0276,+ 0.0289,+ 0.031+ ],+ "elapsedMs": 18.740125000000006,+ "cpuMs": 44.878,+ "peakRssMiB": 87.9375,+ "node": "v22.23.2",+ "platform": "darwin",+ "arch": "x64"+ },+ {+ "source": "main",+ "repeat": 3,+ "workload": "native-one",+ "records": 1,+ "iterations": 25,+ "outcomes": {+ "complete": 25+ },+ "latenciesMs": [+ 0.6262,+ 0.2175,+ 0.2348,+ 0.2091,+ 0.1364,+ 0.1064,+ 0.1667,+ 0.1123,+ 0.0967,+ 0.0929,+ 0.083,+ 0.0812,+ 0.0808,+ 0.0797,+ 0.0808,+ 0.0787,+ 0.0784,+ 0.0792,+ 0.0783,+ 0.0831,+ 0.082,+ 0.0843,+ 0.0776,+ 0.0783,+ 0.0779+ ],+ "elapsedMs": 3.270224999999982,+ "cpuMs": 6.61,+ "peakRssMiB": 80.53515625,+ "node": "v22.23.2",+ "platform": "darwin",+ "arch": "x64"+ },+ {+ "source": "candidate",+ "repeat": 3,+ "workload": "native-one",+ "records": 1,+ "iterations": 25,+ "outcomes": {+ "complete": 25+ },+ "latenciesMs": [+ 5.6686,+ 3.6354,+ 3.251,+ 3.3355,+ 2.447,+ 2.4257,+ 2.2887,+ 2.28,+ 2.3176,+ 2.5383,+ 2.0091,+ 1.9711,+ 2.0379,+ 1.9703,+ 1.977,+ 2.1458,+ 1.9506,+ 1.9467,+ 1.9566,+ 1.9678,+ 1.9535,+ 2.1431,+ 1.9753,+ 1.9851,+ 1.8918+ ],+ "elapsedMs": 60.153999999999996,+ "cpuMs": 92.489,+ "peakRssMiB": 92.61328125,+ "node": "v22.23.2",+ "platform": "darwin",+ "arch": "x64"+ },+ {+ "source": "main",+ "repeat": 3,+ "workload": "native-full",+ "records": 63,+ "iterations": 25,+ "outcomes": {+ "complete": 25+ },+ "latenciesMs": [+ 0.8452,+ 0.3125,+ 0.247,+ 0.2007,+ 0.1992,+ 0.2029,+ 0.2918,+ 0.2282,+ 0.2266,+ 0.221,+ 0.2123,+ 0.2202,+ 0.2057,+ 0.2164,+ 0.2094,+ 0.2104,+ 0.2334,+ 0.2148,+ 0.2241,+ 0.2244,+ 0.2125,+ 0.2078,+ 0.2014,+ 0.2072,+ 0.1948+ ],+ "elapsedMs": 6.228794999999991,+ "cpuMs": 14.581,+ "peakRssMiB": 81.32421875,+ "node": "v22.23.2",+ "platform": "darwin",+ "arch": "x64"+ },+ {+ "source": "candidate",+ "repeat": 3,+ "workload": "native-full",+ "records": 63,+ "iterations": 25,+ "outcomes": {+ "complete": 25+ },+ "latenciesMs": [+ 26.3193,+ 21.5328,+ 19.0513,+ 17.8798,+ 17.8271,+ 18.1699,+ 17.4767,+ 17.386,+ 17.1674,+ 16.9109,+ 17.0043,+ 16.9442,+ 17.3066,+ 16.5805,+ 15.9742,+ 15.6085,+ 15.1448,+ 15.3024,+ 15.3365,+ 16.1454,+ 15.8174,+ 15.6659,+ 16.0237,+ 16.1636,+ 15.9773+ ],+ "elapsedMs": 430.8084369999999,+ "cpuMs": 506.99,+ "peakRssMiB": 90.97265625,+ "node": "v22.23.2",+ "platform": "darwin",+ "arch": "x64"+ },+ {+ "source": "main",+ "repeat": 3,+ "workload": "registry-one",+ "records": 1,+ "iterations": 200,+ "outcomes": {+ "complete": 200+ },+ "latenciesMs": [+ 0.3456,+ 0.0436,+ 0.0332,+ 0.0323,+ 0.0341,+ 0.0313,+ 0.0962,+ 0.053,+ 0.0357,+ 0.0354,+ 0.0262,+ 0.0233,+ 0.0229,+ 0.0227,+ 0.0224,+ 0.0228,+ 0.0238,+ 0.0232,+ 0.0225,+ 0.0226,+ 0.0223,+ 0.0224,+ 0.0224,+ 0.022,+ 0.0223,+ 0.0221,+ 0.0221,+ 0.0221,+ 0.0222,+ 0.022,+ 0.0223,+ 0.022,+ 0.0222,+ 0.0221,+ 0.0799,+ 0.0295,+ 0.0238,+ 0.0224,+ 0.0217,+ 0.0217,+ 0.0215,+ 0.0217,+ 0.0215,+ 0.0216,+ 0.0228,+ 0.0215,+ 0.0212,+ 0.0214,+ 0.0213,+ 0.0216,+ 0.0283,+ 0.0269,+ 0.0224,+ 0.0188,+ 0.0185,+ 0.0183,+ 0.0185,+ 0.0184,+ 0.0184,+ 0.0674,+ 0.028,+ 0.0222,+ 0.0197,+ 0.0188,+ 0.0192,+ 0.019,+ 0.0188,+ 0.0194,+ 0.0191,+ 0.0188,+ 0.0185,+ 0.0203,+ 0.0191,+ 0.0188,+ 0.0186,+ 0.0185,+ 0.0187,+ 0.0186,+ 0.0188,+ 0.0187,+ 0.0184,+ 0.0185,+ 0.0184,+ 0.0185,+ 0.0187,+ 0.0185,+ 0.0185,+ 0.0185,+ 0.0187,+ 0.0186,+ 0.0184,+ 0.0187,+ 0.0187,+ 0.0187,+ 0.0185,+ 0.0184,+ 0.0185,+ 0.0184,+ 0.0187,+ 0.0194,+ 0.0191,+ 0.0185,+ 0.0185,+ 0.0184,+ 0.0186,+ 0.0185,+ 0.0186,+ 0.0184,+ 0.0185,+ 0.0184,+ 0.0187,+ 0.0187,+ 0.0187,+ 0.0185,+ 0.0183,+ 0.0185,+ 0.0185,+ 0.0184,+ 0.0187,+ 0.0185,+ 0.0184,+ 0.0187,+ 0.0184,+ 0.0186,+ 0.0187,+ 0.0185,+ 0.0186,+ 0.0254,+ 0.0237,+ 0.0231,+ 0.0232,+ 0.0642,+ 0.0274,+ 0.0242,+ 0.0252,+ 0.0242,+ 0.0249,+ 0.0234,+ 0.0249,+ 0.037,+ 0.0262,+ 0.0242,+ 0.0238,+ 0.0234,+ 0.0246,+ 0.0232,+ 0.0236,+ 0.025,+ 0.023,+ 0.0231,+ 0.0232,+ 0.0247,+ 0.0233,+ 0.0227,+ 0.0246,+ 0.0236,+ 0.0233,+ 0.0253,+ 0.0247,+ 0.0231,+ 0.0227,+ 0.0232,+ 0.0253,+ 0.0248,+ 0.0229,+ 0.0243,+ 0.0228,+ 0.0229,+ 0.0232,+ 0.0242,+ 0.0234,+ 0.0234,+ 0.0227,+ 0.025,+ 0.023,+ 0.0232,+ 0.0238,+ 0.0235,+ 0.0232,+ 0.023,+ 0.0243,+ 0.0241,+ 0.0346,+ 0.0271,+ 0.0231,+ 0.0236,+ 0.0236,+ 0.0349,+ 0.0237,+ 0.0233,+ 0.0228,+ 0.023,+ 0.0234,+ 0.0245,+ 0.0246,+ 0.0247,+ 0.0235,+ 0.0237,+ 0.0247,+ 0.023+ ],+ "elapsedMs": 5.3781350000000145,+ "cpuMs": 11.926,+ "peakRssMiB": 80.1953125,+ "node": "v22.23.2",+ "platform": "darwin",+ "arch": "x64"+ },+ {+ "source": "candidate",+ "repeat": 3,+ "workload": "registry-one",+ "records": 1,+ "iterations": 200,+ "outcomes": {+ "complete": 200+ },+ "latenciesMs": [+ 0.1846,+ 0.0245,+ 0.0198,+ 0.0221,+ 0.0218,+ 0.0219,+ 0.0189,+ 0.0247,+ 0.0202,+ 0.025,+ 0.0162,+ 0.0163,+ 0.0158,+ 0.0138,+ 0.0154,+ 0.0157,+ 0.0134,+ 0.0153,+ 0.016,+ 0.0133,+ 0.0151,+ 0.0154,+ 0.0134,+ 0.0151,+ 0.0155,+ 0.0138,+ 0.0153,+ 0.0155,+ 0.0136,+ 0.0153,+ 0.0153,+ 0.0135,+ 0.0149,+ 0.0155,+ 0.0318,+ 0.0177,+ 0.015,+ 0.0142,+ 0.0156,+ 0.0151,+ 0.0135,+ 0.0151,+ 0.0153,+ 0.0133,+ 0.0152,+ 0.0148,+ 0.0135,+ 0.015,+ 0.0157,+ 0.0289,+ 0.0246,+ 0.0212,+ 0.0148,+ 0.014,+ 0.0126,+ 0.0116,+ 0.0132,+ 0.013,+ 0.0214,+ 0.0132,+ 0.0125,+ 0.0113,+ 0.0129,+ 0.0125,+ 0.011,+ 0.0129,+ 0.0129,+ 0.0112,+ 0.0131,+ 0.0126,+ 0.0113,+ 0.013,+ 0.0126,+ 0.0205,+ 0.0127,+ 0.0133,+ 0.0111,+ 0.0127,+ 0.0127,+ 0.011,+ 0.0126,+ 0.0128,+ 0.011,+ 0.0114,+ 0.0125,+ 0.0111,+ 0.0113,+ 0.013,+ 0.012,+ 0.0113,+ 0.013,+ 0.0112,+ 0.0129,+ 0.0134,+ 0.0114,+ 0.0126,+ 0.0128,+ 0.0113,+ 0.0126,+ 0.0127,+ 0.0115,+ 0.0128,+ 0.0125,+ 0.0112,+ 0.0124,+ 0.0132,+ 0.0111,+ 0.0123,+ 0.0124,+ 0.0113,+ 0.0132,+ 0.0131,+ 0.0101,+ 0.0138,+ 0.0127,+ 0.011,+ 0.0127,+ 0.0133,+ 0.0115,+ 0.0135,+ 0.0138,+ 0.0117,+ 0.0131,+ 0.0128,+ 0.0114,+ 0.0127,+ 0.0129,+ 0.0112,+ 0.0139,+ 0.0131,+ 0.011,+ 0.0128,+ 0.013,+ 0.0113,+ 0.0131,+ 0.013,+ 0.0218,+ 0.0135,+ 0.0126,+ 0.0112,+ 0.0128,+ 0.0113,+ 0.0128,+ 0.0112,+ 0.0112,+ 0.0127,+ 0.0112,+ 0.0114,+ 0.0124,+ 0.0112,+ 0.0117,+ 0.0127,+ 0.0131,+ 0.0113,+ 0.0127,+ 0.0126,+ 0.0115,+ 0.0135,+ 0.0128,+ 0.0111,+ 0.0129,+ 0.0127,+ 0.0113,+ 0.0129,+ 0.0133,+ 0.0125,+ 0.0131,+ 0.0129,+ 0.0114,+ 0.0124,+ 0.0128,+ 0.0113,+ 0.0127,+ 0.0131,+ 0.0113,+ 0.0128,+ 0.0129,+ 0.0113,+ 0.0127,+ 0.0125,+ 0.011,+ 0.0137,+ 0.0264,+ 0.0123,+ 0.0129,+ 0.0134,+ 0.0114,+ 0.0146,+ 0.0231,+ 0.0124,+ 0.0128,+ 0.0129,+ 0.0109,+ 0.0129,+ 0.0127,+ 0.0111,+ 0.013,+ 0.0127,+ 0.0112,+ 0.0128+ ],+ "elapsedMs": 12.77729500000001,+ "cpuMs": 30.046,+ "peakRssMiB": 83.5546875,+ "node": "v22.23.2",+ "platform": "darwin",+ "arch": "x64"+ },+ {+ "source": "main",+ "repeat": 3,+ "workload": "registry-full",+ "records": 63,+ "iterations": 200,+ "outcomes": {+ "complete": 200+ },+ "latenciesMs": [+ 0.3876,+ 0.0584,+ 0.0459,+ 0.0428,+ 0.0453,+ 0.0478,+ 0.1301,+ 0.0662,+ 0.0566,+ 0.0656,+ 0.0609,+ 0.0607,+ 0.0632,+ 0.0658,+ 0.0689,+ 0.0722,+ 0.0751,+ 0.079,+ 0.0834,+ 0.0859,+ 0.0887,+ 0.0921,+ 0.1222,+ 0.1378,+ 0.1426,+ 0.1417,+ 0.1498,+ 0.1412,+ 0.1474,+ 0.1492,+ 0.1509,+ 0.1532,+ 0.1687,+ 0.1634,+ 0.2228,+ 0.1824,+ 0.1827,+ 0.1847,+ 0.195,+ 0.201,+ 0.1953,+ 0.197,+ 0.203,+ 0.2466,+ 0.1447,+ 0.127,+ 0.1521,+ 0.1324,+ 0.4419,+ 0.1181,+ 0.105,+ 0.1062,+ 0.1042,+ 0.1208,+ 0.1094,+ 0.1087,+ 0.11,+ 0.112,+ 0.1128,+ 0.1129,+ 0.1159,+ 0.1359,+ 0.1225,+ 0.0195,+ 0.019,+ 0.0203,+ 0.022,+ 0.0235,+ 0.0256,+ 0.0265,+ 0.0281,+ 0.0296,+ 0.031,+ 0.0433,+ 0.0508,+ 0.0547,+ 0.0567,+ 0.056,+ 0.0606,+ 0.078,+ 0.0592,+ 0.0595,+ 0.0619,+ 0.0641,+ 0.0655,+ 0.0668,+ 0.0781,+ 0.0713,+ 0.0728,+ 0.0733,+ 0.0782,+ 0.08,+ 0.0917,+ 0.0852,+ 0.0852,+ 0.0967,+ 0.0903,+ 0.0917,+ 0.0922,+ 0.0995,+ 0.0985,+ 0.0998,+ 0.102,+ 0.1121,+ 0.1216,+ 0.1117,+ 0.111,+ 0.1213,+ 0.1163,+ 0.3825,+ 0.1055,+ 0.0934,+ 0.0912,+ 0.0911,+ 0.0935,+ 0.0937,+ 0.0944,+ 0.0958,+ 0.0974,+ 0.1211,+ 0.0996,+ 0.0961,+ 0.0982,+ 0.0986,+ 0.1,+ 0.1012,+ 0.018,+ 0.0184,+ 0.0199,+ 0.0208,+ 0.0222,+ 0.0236,+ 0.0254,+ 0.0265,+ 0.0275,+ 0.0286,+ 0.0303,+ 0.032,+ 0.0337,+ 0.0347,+ 0.0358,+ 0.0388,+ 0.0391,+ 0.0404,+ 0.0419,+ 0.0426,+ 0.0444,+ 0.0462,+ 0.0472,+ 0.0482,+ 0.0492,+ 0.051,+ 0.0531,+ 0.0541,+ 0.0549,+ 0.0558,+ 0.0579,+ 0.0593,+ 0.0605,+ 0.1532,+ 0.0688,+ 0.0651,+ 0.0664,+ 0.0676,+ 0.0726,+ 0.0708,+ 0.0711,+ 0.0738,+ 0.075,+ 0.0752,+ 0.0768,+ 0.0781,+ 0.079,+ 0.0805,+ 0.2169,+ 0.1034,+ 0.0896,+ 0.0878,+ 0.0872,+ 0.0895,+ 0.09,+ 0.0912,+ 0.0934,+ 0.0943,+ 0.097,+ 0.1136,+ 0.0995,+ 0.1002,+ 0.1005,+ 0.0179,+ 0.0181,+ 0.0187,+ 0.0201,+ 0.0214,+ 0.0228,+ 0.0241,+ 0.0253,+ 0.0267,+ 0.0279,+ 0.0298+ ],+ "elapsedMs": 17.90193400000001,+ "cpuMs": 42.548,+ "peakRssMiB": 88.8046875,+ "node": "v22.23.2",+ "platform": "darwin",+ "arch": "x64"+ },+ {+ "source": "candidate",+ "repeat": 3,+ "workload": "registry-full",+ "records": 63,+ "iterations": 200,+ "outcomes": {+ "complete": 200+ },+ "latenciesMs": [+ 0.2029,+ 0.0437,+ 0.0372,+ 0.037,+ 0.0405,+ 0.0432,+ 0.0439,+ 0.0474,+ 0.0527,+ 0.0731,+ 0.0615,+ 0.0627,+ 0.0714,+ 0.0874,+ 0.0745,+ 0.0799,+ 0.0821,+ 0.0865,+ 0.0896,+ 0.0947,+ 0.0971,+ 0.1,+ 0.1049,+ 0.1169,+ 0.1325,+ 0.1191,+ 0.1207,+ 0.1262,+ 0.1332,+ 0.133,+ 0.1376,+ 0.1403,+ 0.1546,+ 0.1505,+ 0.1586,+ 0.1571,+ 0.1583,+ 0.1667,+ 0.169,+ 0.4966,+ 0.156,+ 0.1516,+ 0.1524,+ 0.1557,+ 0.1604,+ 0.1761,+ 0.1216,+ 0.0932,+ 0.0925,+ 0.094,+ 0.0961,+ 0.0968,+ 0.0988,+ 0.1139,+ 0.1032,+ 0.1041,+ 0.1061,+ 0.1074,+ 0.1094,+ 0.1103,+ 0.1684,+ 0.113,+ 0.1116,+ 0.0113,+ 0.0125,+ 0.0131,+ 0.0149,+ 0.0162,+ 0.0179,+ 0.0194,+ 0.021,+ 0.0226,+ 0.0243,+ 0.0263,+ 0.0275,+ 0.0293,+ 0.0317,+ 0.0328,+ 0.0346,+ 0.036,+ 0.0376,+ 0.0392,+ 0.0406,+ 0.0567,+ 0.0416,+ 0.0415,+ 0.0429,+ 0.044,+ 0.0468,+ 0.0478,+ 0.0492,+ 0.0505,+ 0.0516,+ 0.0552,+ 0.0552,+ 0.056,+ 0.0583,+ 0.0602,+ 0.0609,+ 0.0614,+ 0.0643,+ 0.0664,+ 0.0665,+ 0.0674,+ 0.2098,+ 0.077,+ 0.0733,+ 0.0736,+ 0.0772,+ 0.0775,+ 0.0831,+ 0.0823,+ 0.0814,+ 0.0827,+ 0.0849,+ 0.0856,+ 0.0875,+ 0.0889,+ 0.0905,+ 0.0915,+ 0.095,+ 0.0955,+ 0.0951,+ 0.1171,+ 0.0946,+ 0.0941,+ 0.0107,+ 0.0108,+ 0.0129,+ 0.0133,+ 0.0147,+ 0.0167,+ 0.0175,+ 0.0189,+ 0.0204,+ 0.0214,+ 0.0229,+ 0.0246,+ 0.0254,+ 0.0275,+ 0.0283,+ 0.0308,+ 0.0315,+ 0.0328,+ 0.034,+ 0.0359,+ 0.0367,+ 0.0388,+ 0.0395,+ 0.0431,+ 0.0434,+ 0.0447,+ 0.0446,+ 0.0462,+ 0.0476,+ 0.0483,+ 0.0508,+ 0.0523,+ 0.0526,+ 0.0539,+ 0.0554,+ 0.0607,+ 0.0586,+ 0.0596,+ 0.0606,+ 0.0627,+ 0.0635,+ 0.0644,+ 0.0666,+ 0.0678,+ 0.0692,+ 0.199,+ 0.0783,+ 0.073,+ 0.0747,+ 0.0755,+ 0.0766,+ 0.0785,+ 0.0806,+ 0.0809,+ 0.0825,+ 0.0829,+ 0.0847,+ 0.087,+ 0.0875,+ 0.0907,+ 0.0916,+ 0.0912,+ 0.0941,+ 0.0101,+ 0.0107,+ 0.0122,+ 0.0132,+ 0.0162,+ 0.033,+ 0.0179,+ 0.0191,+ 0.0209,+ 0.0214,+ 0.023+ ],+ "elapsedMs": 68.576503,+ "cpuMs": 101.245,+ "peakRssMiB": 89.88671875,+ "node": "v22.23.2",+ "platform": "darwin",+ "arch": "x64"+ }+ ]+}