The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): stamp the normalized profile into the spawn ownership record
Brooklyn Nicholson97923275d0b6
diff --git a/apps/desktop/electron/remote-lifecycle-spawn.test.ts b/apps/desktop/electron/remote-lifecycle-spawn.test.tsindex a61f99ec834..56fc38eed24 100644--- a/apps/desktop/electron/remote-lifecycle-spawn.test.ts+++ b/apps/desktop/electron/remote-lifecycle-spawn.test.ts@@ -260,7 +260,11 @@ test.skipIf(process.platform === 'win32').each(variants)(await fixture.run(`python3 -c 'import fcntl,sys;f=open(sys.argv[1],"a");fcntl.flock(f,fcntl.LOCK_EX|fcntl.LOCK_NB)' ${expandRemotePath(`${fixture.marker}.mutex`)}`)- const lock: SpawnLock = { ...fixture.lock, pid: report.pid }+ // The published ownership record carries the profile the spawn argv+ // actually pinned — normalized like the CLI would (#88842) — never the+ // raw roster/bridge label the fixture passed in. Derive the working lock+ // from the published record exactly the way a reconnecting client does.+ const lock: SpawnLock = { ...fixture.lock, pid: report.pid, profile: 'ops__pid__' }if (owned) {assert.deepEqual(JSON.parse(await readFile(fixture.localPath(lockfilePath(ownershipId)), 'utf8')), lock)diff --git a/apps/desktop/electron/remote-lifecycle.ts b/apps/desktop/electron/remote-lifecycle.tsindex 5078f53bcc2..66893f1223e 100644--- a/apps/desktop/electron/remote-lifecycle.ts+++ b/apps/desktop/electron/remote-lifecycle.ts@@ -1157,6 +1157,13 @@ function buildSpawnCommand(hermesPath, profile, opts: any = {}) {// phantom profiles/0/ directory (#88842).const pinned = backendProfileArg(profile)const profileArgs = pinned ? `--profile ${shq(pinned)} ` : ''+ // The lockfile the spawn script publishes must carry the SAME normalized+ // profile as the argv: pidIsOurDashboard and the managed-update drain both+ // prove ownership by comparing the live `--profile` value against+ // lock.profile, and a raw-case record refuses to reap our own backend.+ if (opts.lockMetadata && opts.lockMetadata.profile !== (pinned ?? '')) {+ opts.lockMetadata = { ...opts.lockMetadata, profile: pinned ?? '' }+ }const logPath = expandRemotePath(opts.logPath)const tokenFilePath = opts.tokenFilePathconst tokenArg = tokenFilePath ? ` --ssh-session-token-file ${expandRemotePath(tokenFilePath)}` : ''@@ -1511,7 +1518,7 @@ async function waitForRemoteSpawnCompletion(ssh, ownershipId, timeoutMs) {async function connect(deps) {const {ssh,- profile = '',+ profile: requestedProfile = '',remoteHermesPath = '',ownershipId,forward,@@ -1525,6 +1532,13 @@ async function connect(deps) {signal} = deps+ // The profile must be normalized ONCE, before anything derives from it: the+ // spawn argv (via buildSpawnCommand), the lockfile metadata the spawn script+ // publishes, the ownedSpawn rewrite, and the reuse check all have to agree,+ // or the argv-based ownership proof (pidIsOurDashboard) refuses to reap our+ // own backend after a case-folding change (#88842).+ const profile = backendProfileArg(requestedProfile) ?? ''+const log = msg => rememberLog(`[ssh-lifecycle] ${msg}`)assertBootstrapNotSuperseded(signal)