From 49c1fedfd8927de3956b4d4e0f6e160197adb376 Mon Sep 17 00:00:00 2001 From: Garry Tan Date: Sun, 16 Aug 2026 15:23:42 -0700 Subject: [PATCH] fix(codex-probe): cache signature uses GNU-first stat with numeric validation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On GNU stat, -f means FILESYSTEM mode — the BSD-first form emitted a multi-line filesystem block on Linux, so the cache signature never matched its own cache line and the model-probe cache missed on every read (each preflight re-paid the probe). Same class and same fix as #2195: GNU -c %Y first, BSD -f %m fallback, non-numeric residue coerced to 0. Verified: the probe test file passes 7/7 under real GNU stat in a Linux container (it failed 2/7 on Linux CI before). Co-Authored-By: Claude Fable 5 --- bin/gstack-codex-probe | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/bin/gstack-codex-probe b/bin/gstack-codex-probe index 15d466e94..2d151ef60 100755 --- a/bin/gstack-codex-probe +++ b/bin/gstack-codex-probe @@ -64,9 +64,16 @@ _gstack_codex_model_probe() { local _cache="$_gstack_home/.codex-model-probe" # Cache signature: config.toml + auth.json mtimes. Editing the model pin # or re-logging-in invalidates the cached MODEL_OK immediately. + # GNU-first stat order + numeric validation (the #2195 pattern): on GNU + # stat, `-f` means FILESYSTEM mode, so the BSD-first form emitted a + # multi-line filesystem block on Linux — the signature then never matched + # its own cache line and the cache missed on every read. BSD stat rejects + # `-c` cleanly, so GNU-first degrades correctly on macOS. local _cfg_m _auth_m _sig - _cfg_m=$(stat -f %m "$_codex_home/config.toml" 2>/dev/null || stat -c %Y "$_codex_home/config.toml" 2>/dev/null || echo 0) - _auth_m=$(stat -f %m "$_codex_home/auth.json" 2>/dev/null || stat -c %Y "$_codex_home/auth.json" 2>/dev/null || echo 0) + _cfg_m=$(stat -c %Y "$_codex_home/config.toml" 2>/dev/null || stat -f %m "$_codex_home/config.toml" 2>/dev/null || echo 0) + _auth_m=$(stat -c %Y "$_codex_home/auth.json" 2>/dev/null || stat -f %m "$_codex_home/auth.json" 2>/dev/null || echo 0) + case "$_cfg_m" in ''|*[!0-9]*) _cfg_m=0 ;; esac + case "$_auth_m" in ''|*[!0-9]*) _auth_m=0 ;; esac _sig="${_cfg_m}-${_auth_m}" local _now _now=$(date +%s 2>/dev/null || echo 0)