{"record":{"id":"98a035a8649a5abe","repo":"stablyai/orca","slug":"recorded-benchmark-helper-identity-is-invalid","errorCode":null,"errorMessage":"Recorded benchmark helper identity is invalid","messagePattern":"Recorded benchmark helper identity is invalid","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"config/scripts/macos-computer-helper-owner-loss-processes.mjs","lineNumber":113,"sourceCode":"  if (errors.length > 1) {\n    throw new AggregateError(errors, 'Benchmark exact-command cleanup failed')\n  }\n  return true\n}\n\nfunction sleepSync(milliseconds) {\n  Atomics.wait(sleepBuffer, 0, 0, milliseconds)\n}\n\nfunction validateDetachedIdentity(identity, expectedCommandFragment) {\n  if (\n    !Number.isInteger(identity?.pid) ||\n    identity.pid <= 0 ||\n    identity.pgid !== identity.pid ||\n    typeof identity.command !== 'string' ||\n    !identity.command.includes(expectedCommandFragment)\n  ) {\n    throw new Error('Recorded benchmark helper identity is invalid')\n  }\n}\n\nfunction sameIdentity(left, right) {\n  return left?.pid === right?.pid && left?.pgid === right?.pgid && left?.command === right?.command\n}\n\nfunction processIdentities(includeEnvironment = false) {\n  const args = includeEnvironment\n    ? ['eww', '-axo', 'pid=,pgid=,command=']\n    : ['-axo', 'pid=,pgid=,command=']\n  const output = execFileSync('ps', args, {\n    encoding: 'utf8',\n    maxBuffer: 20 * 1024 * 1024\n  })\n  return output\n    .split('\\n')\n    .map((line) => line.trim().match(/^(\\d+)\\s+(\\d+)\\s+(.+)$/))","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/config/scripts/macos-computer-helper-owner-loss-processes.mjs#L95-L131","documentation":"validateDetachedIdentity checks that the identity object has a positive integer pid, pgid equals pid (the process is its own process-group leader, confirming it was detached via setsid), command is a string containing the expected fragment (helperPath). If any check fails, the identity is considered corrupt or from a different process.","triggerScenarios":"The identity record has pgid !== pid (helper was not detached / not a session leader); command does not include the expected helperPath fragment (wrong binary or stale record); pid is not a positive integer (corrupt JSON); command is not a string.","commonSituations":"Helper was spawned without detached:true so pgid differs from pid; the helper binary path changed but the record was written with an old path; JSON record on disk is corrupt from a partial write; the record is from a different helper version.","solutions":["Verify the helper is spawned with detached:true so it becomes its own process-group leader (pgid === pid)","Check the recorded identity JSON file: cat the helper.json record and verify pid, pgid, command fields","Ensure the expectedCommandFragment (helperPath constant) matches the actual helper binary path in the command string","Use writeProcessRecord's atomic rename to prevent corrupt records from partial writes"],"exampleFix":"// before: helper not detached, pgid !== pid\nspawn(helperPath, args, { stdio: 'ignore' })\n// identity = { pid: 123, pgid: 100, command: '...' } → fails validation\n\n// after: detach so pgid === pid\nconst child = spawn(helperPath, args, { detached: true, stdio: 'ignore' })\nchild.unref()\n// identity = { pid: 123, pgid: 123, command: '...' } → passes","handlingStrategy":"type-guard","validationCode":"// Validate identity shape before passing to signalProcessIdentity\nfunction isValidDetachedIdentity(identity, expectedFragment) {\n  return Number.isInteger(identity?.pid) &&\n    identity.pid > 0 &&\n    identity.pgid === identity.pid &&\n    typeof identity.command === 'string' &&\n    identity.command.includes(expectedFragment)\n}","typeGuard":"function isValidDetachedIdentity(identity, expectedFragment) {\n  return Number.isInteger(identity?.pid) &&\n    identity.pid > 0 &&\n    identity.pgid === identity.pid &&\n    typeof identity.command === 'string' &&\n    identity.command.includes(expectedFragment)\n}","tryCatchPattern":null,"preventionTips":["Ensure the helper is spawned with detached:true so pgid === pid","Verify the helperPath constant matches the actual binary path in the command string","Use the atomic writeProcessRecord (rename-based) to prevent corrupt JSON from partial writes"],"tags":["validation","process-identity"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}