Repository navigation
Description
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
abruption commentedon Sep 21, 2026
session-peer source review follow-up
The session-peer development session confirmed the implementation details against current source. These points refine the proposal above:
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).
abruption commentedon Sep 22, 2026
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.