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
Let Change agent switch a Claude harness that was never used (#1474)
0xken15fd0e8794ddea
diff --git a/cli/src/engines/sessionStore.golden.spec.ts b/cli/src/engines/sessionStore.golden.spec.tsindex 8a4e55d34..e5c85a540 100644--- a/cli/src/engines/sessionStore.golden.spec.ts+++ b/cli/src/engines/sessionStore.golden.spec.ts@@ -652,11 +652,12 @@ describe('core finds sessions where it did before Claude Code and Codex declared}// Safety correction: an existing unusable process record is not proof of absence. Keep// the former artifact intact, assert its exact old answer, and name every changed case.+ // A valid record naming a conversation with no transcript yet is a process before its+ // first prompt: its former answer, no session, is right again (and no folder scan follows).const held = new Map<string, string>(['default homes', 'moved homes'].flatMap(home => [...['no id', 'no start', 'unreadable'].map(name => [`process record · ${home} · ${name}`, 'the process record is incomplete or invalid',] as const),- [`process record · ${home} · no transcript`, 'the process names a conversation whose transcript is unavailable'] as const,[`process record · ${home} · another folder`, 'the current process record names a different working directory'] as const,]))const descriptorCorrections = new Map<string, { before: unknown; reason: string }>([diff --git a/cli/src/lib/sessionRepair.bounds.spec.ts b/cli/src/lib/sessionRepair.bounds.spec.tsindex 19e270786..017870044 100644--- a/cli/src/lib/sessionRepair.bounds.spec.ts+++ b/cli/src/lib/sessionRepair.bounds.spec.ts@@ -304,7 +304,10 @@ describe('bounded native metadata', () => {return actual.open(name, flags, mode)})}- await expect(repair.findLiveSession('claude', CWD, START, { pid: 77 })).rejects.toThrow('Conversation identity is held')+ const found = repair.findLiveSession('claude', CWD, START, { pid: 77 })+ // A valid record whose conversation is not written yet names no session: still never the sibling's.+ if (mode === 'missing transcript') await expect(found).resolves.toBeNull()+ else await expect(found).rejects.toThrow('Conversation identity is held')})it.each(['unreadable', 'conflicting'])('does not accept the first home before checking a %s moved-home record', async mode => {diff --git a/cli/src/lib/sessionRepair.spec.ts b/cli/src/lib/sessionRepair.spec.tsindex abfe7bb7a..e1bed7e93 100644--- a/cli/src/lib/sessionRepair.spec.ts+++ b/cli/src/lib/sessionRepair.spec.ts@@ -878,11 +878,30 @@ it.each(['bad pid', 'bad start', 'missing file', 'bad json', 'different pid', 'dmkdirSync(join(home, 'sessions'))if (mode !== 'missing file') writeFileSync(join(home, 'sessions', '77.json'), mode === 'bad json' ? '{' : JSON.stringify(record))const result = processSessionOf('claude', mode === 'bad pid' ? -1 : 77, CWD, mode === 'bad start' ? NaN : STARTED_AT)- if (['bad json', 'different cwd', 'missing start', 'missing cwd', 'missing id', 'invalid id', 'missing history'].includes(mode)) {+ if (['bad json', 'different cwd', 'missing start', 'missing cwd', 'missing id', 'invalid id'].includes(mode)) {await expect(result).rejects.toThrow('Conversation identity is held')} else await expect(result).resolves.toBeNull()})+// Claude Code names its session in the record at once but writes the transcript only with the first prompt: a+// harness opened and never used held its binding, and Change agent waited on it forever (2026-10-21). Its own+// record is the whole answer: no conversation yet. A sibling's newer file in the same folder never stands in.+it('reads a Claude process whose conversation is not written yet as having none, never as a sibling\'s', async () => {+ const home = tempRoot(); const root = join(home, 'projects')+ const id = '11111111-2222-4333-8444-555555555556'+ writeTranscript(root, 'project', '11111111-2222-4333-8444-555555555557', CWD, STARTED_AT + 5_000)+ mkdirSync(join(home, 'sessions'))+ writeFileSync(join(home, 'sessions', '77.json'), JSON.stringify({ pid: 77, cwd: CWD, sessionId: id, procStart: new Date(STARTED_AT).toUTCString() }))+ const { findLiveSession, processSessionEvidence, processSessionOf } = await load(root)+ const proof = await processSessionEvidence('claude', 77, CWD, STARTED_AT)+ expect(proof).toMatchObject({ session: null, unwritten: id })+ expect(() => proof.verify()).not.toThrow()+ await expect(processSessionOf('claude', 77, CWD, STARTED_AT)).resolves.toBeNull()+ await expect(findLiveSession('claude', CWD, STARTED_AT, { pid: 77, bornOnly: true })).resolves.toBeNull()+ // Without the process's own record the folder scan still finds the newer file: that is the guess refused above.+ await expect(findLiveSession('claude', CWD, STARTED_AT, { bornOnly: true })).resolves.toMatchObject({ sessionId: '11111111-2222-4333-8444-555555555557' })+})+/*** Hermes keeps one store per HOME, and `hermes -p <name>` has its own. A repair that only asked* `<HERMES_HOME>/state.db` could never rebind a profile agent after a restart — its row is in adiff --git a/cli/src/lib/sessionRepair.ts b/cli/src/lib/sessionRepair.tsindex 2427d729f..4c1228479 100644--- a/cli/src/lib/sessionRepair.ts+++ b/cli/src/lib/sessionRepair.ts@@ -339,9 +339,11 @@ async function storeSession(opts?: { bornOnly?: boolean; excludedSessionId?: string; pid?: number; codexHome?: string; expectedProcess?: ProcessIdentity; nativeBudget?: NativeEvidenceBudget },): Promise<RepairedSession | null> {const scan = scanMeta(engine, store.scan, cwd)- if ('record' in store.live) {- const exact = opts?.pid ? await processSessionOf(engine, opts.pid, cwd, startedAtMs) : null- if (exact) return exact+ if ('record' in store.live && opts?.pid) {+ const exact = await processSessionEvidence(engine, opts.pid, cwd, startedAtMs)+ exact.verify()+ // A process that names a conversation it has not written yet has none: a folder scan would guess a sibling's.+ if (exact.session || exact.unwritten) return exact.session}const sessions = repairRoots(engine, opts?.codexHome)const found = opts?.pid && 'open' in store.live@@ -616,17 +618,18 @@ export async function processSessionOf(engine: AgentEngine, pid: number, cwd: streturn proof.session}-/** Stop retains this proof across its final process probe and any fallback lookup. */+/** Stop retains this proof across its final process probe and any fallback lookup. `unwritten` is the conversation+ * the process names before its first prompt writes it: there is no session yet, and nothing to look for elsewhere. */export async function processSessionEvidence(engine: AgentEngine, pid: number, cwd: string, startedAtMs: number,budget = new NativeEvidenceBudget(),-): Promise<{ session: RepairedSession | null; verify(): void }> {+): Promise<{ session: RepairedSession | null; unwritten?: string; verify(): void }> {const live = sessionStoreOf(engine)?.liveif (!live || !('record' in live) || !Number.isSafeInteger(pid) || pid <= 0 || !Number.isFinite(startedAtMs)) {return { session: null, verify() {} }}const paths = new NativePaths(budget)const rule = live.record- let result: RepairedSession | null = null+ let result: { sessionId: string; transcriptPath: string | null } | null = nulllet selected: string | undefinedconst roots = repairRoots(engine)const records: { file: string; text: string | null }[] = []@@ -663,12 +666,14 @@ export async function processSessionEvidence(engine: AgentEngine, pid: number, c// No asynchronous work follows the selected record. This includes negative and stale claims.for (const { file, text } of recheck) verifyProcessRecord(file, text, budget)}- return { session: result, verify }+ return result?.transcriptPath+ ? { session: { sessionId: result.sessionId, transcriptPath: result.transcriptPath }, verify }+ : { session: null, ...(result ? { unwritten: result.sessionId } : {}), verify }}type ProcessRecordRule = Extract<SessionStoreContract['live'], { record: unknown }>['record']-async function processRecord(engine: AgentEngine, rule: ProcessRecordRule, text: string, pid: number, cwd: string, startedAtMs: number): Promise<RepairedSession | null> {+async function processRecord(engine: AgentEngine, rule: ProcessRecordRule, text: string, pid: number, cwd: string, startedAtMs: number): Promise<{ sessionId: string; transcriptPath: string | null } | null> {try {const record = JSON.parse(text)if (!record || typeof record !== 'object' || Array.isArray(record)@@ -685,9 +690,11 @@ async function processRecord(engine: AgentEngine, rule: ProcessRecordRule, text:// Both represent the exact second, not the metadata file's modification time or a recycled PID.if (record[rule.pid] !== pid || ![Date.parse(start), Date.parse(`${start} UTC`)].includes(startedAtMs)) return nullif (!await sameDir(folder, cwd)) throw new IdentityReadUnavailable('the current process record names a different working directory')- const transcriptPath = await findResumedTranscript(engine, sessionId)- if (!transcriptPath) throw new IdentityReadUnavailable('the process names a conversation whose transcript is unavailable')- return { sessionId, transcriptPath }+ // Claude Code writes the transcript with the first prompt, so a harness opened and never used has none. Held, its+ // Change agent waited forever (2026-10-21). A lookup that cannot finish still throws; only a missing file is null.+ // The lookup's own id test answers null too, and a malformed id is no proof the conversation is empty.+ if (!/^[0-9a-f-]{16,128}$/i.test(sessionId)) throw new IdentityReadUnavailable('the process record is incomplete or invalid')+ return { sessionId, transcriptPath: await findResumedTranscript(engine, sessionId) }} catch (error) {if (error instanceof IdentityReadUnavailable) throw errorif (error instanceof SyntaxError) throw new IdentityReadUnavailable('the process record is incomplete or invalid')