mirror of
https://github.com/garrytan/gstack.git
synced 2026-09-09 22:48:57 +02:00
fix(codex-probe): cache signature uses GNU-first stat with numeric validation
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 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
fe20340fba
commit
49c1fedfd8
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user