Skip to content

feat: show a cached advisory notice when codex-unlock is outdated #20

Closed

Description

@abruption

Problem

codex-unlock 0.1.0 exposes --version but does not tell users when a newer safe release is available. This matters for a recovery tool because an old installation may retain already-fixed safety or compatibility defects.

The update check must remain advisory. A registry outage, offline host, malformed response, or cache failure must never delay, fail, or change the result of list, inspect, or unlock.

Reference: session-peer behavior

A query was queued to the active session-peer development session, and the installed session-peer 0.9.0 source was inspected to establish the current behavior:

  • command startup reads only a local cached update fact;
  • missing or expired cache schedules one detached background refresh and emits no notice for that invocation;
  • the cache lives under XDG_CACHE_HOME or ~/.cache, uses a 24-hour TTL, a short refresh lock, a 4 KiB size cap, strict stable x.y.z parsing, atomic replacement, and user-only permissions;
  • refresh errors are swallowed so they cannot affect the requested command or exit code;
  • human output prints the notice to stderr after the command; JSON output adds a structured clientUpdate object instead of adding non-JSON text;
  • --no-update-notice and SESSION_PEER_NO_UPDATE_NOTICE disable both notices and refreshes;
  • package-managed installs recommend pip, pipx, or uv commands rather than overwriting package-owned files.

Relevant session-peer functions are read_update_cache, schedule_update_refresh, prepare_client_update, with_client_update, emit_human_update_notice, stable_version, and update_command.

Proposed codex-unlock behavior

  • Add --no-update-notice and CODEX_UNLOCK_NO_UPDATE_NOTICE.
  • Read a bounded, schema-versioned cache from XDG_CACHE_HOME/codex-unlock/update.json or ~/.cache/codex-unlock/update.json.
  • Compare only stable semantic versions; ignore prerelease, malformed, oversized, symlinked, future-dated, or stale cache data.
  • Query the npm registry latest metadata only in a detached bounded refresh with a strict timeout and response-size limit. Never perform a synchronous network request on the command path.
  • Write only public version metadata, atomically, with user-only permissions and a stale refresh-lock recovery policy.
  • For human output, print the advisory to stderr only after the primary result. For JSON, add a versioned clientUpdate object to the root result and keep stdout valid JSON.
  • Never include update state in lock classification, safeToUnlock, refusal reasons, or process/lock verification.
  • unlock may consume a fresh cached fact but must not start a refresh before or during its safety-critical inspection and termination path. Any refresh should occur only after the command has fully completed, or be limited to read-only commands.
  • Recommend npm install --global codex-unlock@latest for registry installations. Define and test a conservative message for source checkouts and npx use; do not implement automatic self-update.
  • Document the unavoidable metadata request, cache path, suppression controls, and offline behavior.

Tests

Cover:

  • fresh newer, equal, and older cached versions;
  • strict stable comparison and prerelease rejection;
  • missing, expired, malformed, oversized, symlinked, and future-dated caches;
  • atomic permissions and concurrent/stale refresh locks;
  • refresh timeout, registry error, truncated/oversized response, and detached cleanup;
  • human stderr placement and unchanged exit codes;
  • valid JSON with structured clientUpdate on both success and error paths;
  • --no-update-notice and environment opt-out;
  • no synchronous network request and no refresh during the safety-critical unlock path;
  • installation-specific update guidance.

Acceptance criteria

An outdated user receives a bounded advisory without any synchronous network dependency, machine-readable output remains valid and backward compatible, offline/error paths are silent, and lock diagnosis and unlock safety decisions are provably unchanged.

Activity

  1. added
    enhancement
    on Sep 21, 2026
  2. abruption commented on Sep 21, 2026

    @abruption
    OwnerAuthor

    session-peer source review follow-up

    The session-peer development session confirmed the implementation details against current source. These points refine the proposal above:

    • General commands are foreground cache-only. They never query npm or PyPI; session-peer refreshes from GitHub Releases in a detached process only when the 24-hour cache is missing or expired.
    • Human notices are emitted to stderr after the primary result. JSON mode emits only a structured clientUpdate field and keeps stderr quiet.
    • --no-update-notice and SESSION_PEER_NO_UPDATE_NOTICE disable cache consumption, display, and background refresh. Explicit update --check remains an intentional foreground network operation.
    • Current session-peer does not automatically suppress notices or refreshes under CI or non-TTY execution. codex-unlock should strengthen this boundary by defaulting to no human notice and no automatic refresh when CI is true or output is non-interactive.
    • Add an explicit check-update command for users who want a foreground registry result. Ordinary commands should remain silent when cache state is missing, stale, invalid, or offline; absence of a notice must not claim the installation is current.
    • Use the npm latest dist-tag as authority and npm-compatible SemVer rather than copying the limited Python version parser. Prerelease channels must be explicit and must not leak next versions into stable notices.
    • Refresh state must remain outside CODEX_HOME and every rollout/native lock path. Prefer XDG_CACHE_HOME/codex-unlock/update.json, with an independently validated platform cache directory on other systems.
    • Strengthen the single-flight refresh lock beyond the session-peer five-minute timestamp-only policy: record PID plus process start time when practical, or explicitly treat only a short stale TTL as authoritative.
    • Decide the JSON compatibility boundary before adding clientUpdate. If strict schema-v1 consumers reject unknown top-level fields, use a versioned meta block or keep automatic metadata out of normal JSON and expose it only through check-update --json.
    • Schedule any best-effort refresh only after inspection/unlock output and safety-critical work are fully complete. Tests must prove there is no registry call and no refresh child before final lock/process/transcript revalidation.

    Reference implementation locations in session-peer are prepare_client_update, read_update_cache, write_update_cache, schedule_update_refresh, with_client_update, emit_human_update_notice, update_command, and stable_version. Regression coverage is in the ClientUpdateNotice tests in tests/test_session_peer.py. The feature was introduced by session-peer commit 5248e9b, feat: add cached client update notices (#68).

  3. abruption commented on Sep 22, 2026

    @abruption
    OwnerAuthor

    Development order: implement this after #31 and #16. The update metadata must use the additive JSON rules defined in #31 and remain outside the safety-critical unlock path. #28 is the security/failure-isolation gate.

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

    enhancement

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions