Skip to content

fix: a missing or dangling Codex home is reported as an absent lock with exit 0 #67

Closed

Description

@abruption

What happened

An ENOENT anywhere on the lock path is classified as absent, including when the Codex home itself does not exist or thread-writer-locks is a dangling symlink. unlock then reports success:

$ codex-unlock unlock <thread> --codex-home /nonexistent/typo --json
outcome "not_locked", lockReleased true, transcript "missing", exit 0

The same happens when thread-writer-locks points to an unmounted volume, and list --codex-home /nonexistent/typo exits 0 with an empty list.

Typical triggers are a typo in --codex-home, a shell whose CODEX_HOME differs from the one Codex uses, or a home on an unmounted external volume. The real lock may be held in another home while the tool prints "Lock released: yes" and exits 0, which automation may treat as permission to start a new writer.

What you expected

A missing Codex home (or a missing/dangling thread-writer-locks directory) is not "confirmed absent". It should be reported as unknown or as a usage/configuration error, and unlock should not return lockReleased: true with exit 0.

Environment

  • codex-unlock 0.4.0 at 6227e6c
  • macOS 27.0 arm64, Node.js 22.14.0

Source evidence

  • Any ENOENT becomes absent:

    codex-unlock/src/lock.ts

    Lines 31 to 39 in 6227e6c

    if ((error as NodeJS.ErrnoException).code === "ENOENT") {
    return {
    status: "absent",
    exists: false,
    regularFile: null,
    symlink: null,
    ownedByCurrentUser: null,
    snapshot: null,
    };
  • absent classification:
    if (lockObservation === "absent") {
    return lockStable === false ? "unknown" : "absent";
  • not_locked with lockReleased: true:

    codex-unlock/src/unlock.ts

    Lines 197 to 211 in 6227e6c

    if (
    inspection.classification === "absent" ||
    inspection.classification === "stale_residue"
    ) {
    return unlockResult(inspection, {
    outcome: "not_locked",
    changed: false,
    pid: null,
    signalSent: null,
    processExited: null,
    processObservation: null,
    lockReleased: true,
    transcriptUnchanged: null,
    reasons: [inspection.classification],
    });
  • Exit 0 for not_locked:
    if (result.outcome === "unlocked" || result.outcome === "not_locked") return 0;
  • list treats a missing lock directory as empty:
    if ((error as NodeJS.ErrnoException).code === "ENOENT") {
    names = [];
  • JSON contract defines absent as "the lock path was confirmed absent":
    - `absent`: the lock path was confirmed absent;

Acceptance criteria

  • The Codex home and its thread-writer-locks directory are verified to exist (and to be directories) before a lock is reported absent.
  • A missing home yields a documented non-success result for inspect/unlock and a clear error or warning for list.
  • Tests cover a nonexistent home and a dangling thread-writer-locks symlink.

Scope and limitations

  • No signal is sent; the issue is a false success report. A home that exists but has never created thread-writer-locks may need a separate, explicitly documented treatment.

Checked

Activity

  1. added this to the v0.4.1 milestone on Sep 28, 2026
  2. added
    bug
    on Sep 28, 2026
  3. added a commit that references this issue on Sep 29, 2026
    a15d32e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions