stablyai/orca · error · Error

Recorded benchmark helper identity is invalid

Error message

Recorded benchmark helper identity is invalid

What it means

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.

Source

Thrown at config/scripts/macos-computer-helper-owner-loss-processes.mjs:113

  if (errors.length > 1) {
    throw new AggregateError(errors, 'Benchmark exact-command cleanup failed')
  }
  return true
}

function sleepSync(milliseconds) {
  Atomics.wait(sleepBuffer, 0, 0, milliseconds)
}

function validateDetachedIdentity(identity, expectedCommandFragment) {
  if (
    !Number.isInteger(identity?.pid) ||
    identity.pid <= 0 ||
    identity.pgid !== identity.pid ||
    typeof identity.command !== 'string' ||
    !identity.command.includes(expectedCommandFragment)
  ) {
    throw new Error('Recorded benchmark helper identity is invalid')
  }
}

function sameIdentity(left, right) {
  return left?.pid === right?.pid && left?.pgid === right?.pgid && left?.command === right?.command
}

function processIdentities(includeEnvironment = false) {
  const args = includeEnvironment
    ? ['eww', '-axo', 'pid=,pgid=,command=']
    : ['-axo', 'pid=,pgid=,command=']
  const output = execFileSync('ps', args, {
    encoding: 'utf8',
    maxBuffer: 20 * 1024 * 1024
  })
  return output
    .split('\n')
    .map((line) => line.trim().match(/^(\d+)\s+(\d+)\s+(.+)$/))

View on GitHub (pinned to 1136503c6a)

Solutions

  1. Verify the helper is spawned with detached:true so it becomes its own process-group leader (pgid === pid)
  2. Check the recorded identity JSON file: cat the helper.json record and verify pid, pgid, command fields
  3. Ensure the expectedCommandFragment (helperPath constant) matches the actual helper binary path in the command string
  4. Use writeProcessRecord's atomic rename to prevent corrupt records from partial writes

Example fix

// before: helper not detached, pgid !== pid
spawn(helperPath, args, { stdio: 'ignore' })
// identity = { pid: 123, pgid: 100, command: '...' } → fails validation

// after: detach so pgid === pid
const child = spawn(helperPath, args, { detached: true, stdio: 'ignore' })
child.unref()
// identity = { pid: 123, pgid: 123, command: '...' } → passes
Defensive patterns

Strategy: type-guard

Validate before calling

// Validate identity shape before passing to signalProcessIdentity
function isValidDetachedIdentity(identity, expectedFragment) {
  return Number.isInteger(identity?.pid) &&
    identity.pid > 0 &&
    identity.pgid === identity.pid &&
    typeof identity.command === 'string' &&
    identity.command.includes(expectedFragment)
}

Type guard

function isValidDetachedIdentity(identity, expectedFragment) {
  return Number.isInteger(identity?.pid) &&
    identity.pid > 0 &&
    identity.pgid === identity.pid &&
    typeof identity.command === 'string' &&
    identity.command.includes(expectedFragment)
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of stablyai/orca@1136503c6a (2026-08-12). Data as JSON: /api/errors/98a035a8649a5abe. Report an issue: GitHub.