Skip to content

"Which helper is current" is implemented twice, and neither copy checks process identity #667

Description

@possibilities

Follow-up from CodeRabbit review of #665; the code belongs to #664 rather than to that PR.

Two sites pick a live running helper by newest updatedAt, falling back to the freshest record, using isProcessAlive(pid) alone as the liveness test:

  • lib/codex-manager/commands/rotation.ts:576-587 (liveAppRuntimeHelpers / selectAppRuntimeHelperStatus)
  • lib/runtime/runtime-current-account.ts:168-188 (its own byRecency sort and live filter)

A single codex-multi-auth rotation status run executes both copies, so any drift between them produces a status line and an account marker that disagree.

The shared gap is identity: a stale legacy runtime-rotation-app-helper.json whose PID was recycled passes isProcessAlive, counts as live, and can be selected as the current helper — the exact trust that #664 removed from the helper's own idle reaper, still present in the readers. lib/runtime/app-bind.ts:1233-1236 already parses startedAt, so the identity check is available.

Suggested: one shared selector used by both call sites, with startedAt parsed in readAppRuntimeHelperStatusFile so liveness can be identity-checked. Regression case: two live per-PID status files plus one stale legacy file with a recycled PID, asserting both readers agree.

Credit: CodeRabbit, on #665.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions