Repository navigation
fix(#695): safe_eval drops every bridge variable containing I under Turkish collation - #697
Merged
Merged
Conversation
…A-Z] Red on purpose. The fix is not in this commit. safe_eval is the only bridge between the Python pipeline and the shell, and it matches KEY=VALUE with ^([A-Z_][A-Z0-9_]*)=. [A-Z] is a POSIX bracket RANGE, matched by the locale's collation rather than by byte value, and Turkish collation does not place I inside A..Z. Under tr_TR every bridge variable whose name carries an I -- EXTRACT_FILE, POSITION, SKIP_LINES -- is silently skipped, while the counts (no I) still arrive and pass the "0 exchanges" gate. The run reaches build-prompt with an empty path and dies on FileNotFoundError. One reporter's hook-errors.log holds 5,071 of them: no save has ever completed on that host, whose only unusual property is its language. The locale is chosen by observed behaviour, never by name: a candidate is accepted only after this machine's own bash is watched failing the [A-Z] match on I under it. macOS's libc does not reproduce this at all (checked: tr_TR.UTF-8 there still matches), and GitHub's Linux runners ship only C.UTF-8 and en_US.UTF-8, so the probe falls back to compiling tr_TR/az_AZ with localedef into a scratch LOCPATH -- without that the legs would skip on the one platform where the bug lives and assert nothing anywhere. Paired controls, per CLAUDE.md: HUMAN_COUNT (no I) must arrive on the same input, or a lost EXTRACT_FILE would only mean the harness never ran; LC_ALL must read back as the caller's own afterwards; and two default-locale legs pin that the fix is not bought by widening what safe_eval accepts (a lowercase name stays rejected, a bare command stays unexecuted). Part of #695 Co-Authored-By: Max <noreply>
…n it fails
Green half of the previous commit's red.
`local LC_ALL=C` in safe_eval, scoped to the function and restored on
return. [A-Z] is a POSIX bracket range matched by the locale's collation,
not by byte value; Turkish collation does not place I inside A..Z, so
EXTRACT_FILE, POSITION and SKIP_LINES were silently dropped on every
Turkish-locale host while the counts (no I) arrived intact. This is the
same trap config() and _remember_cfg_flatten_cache_valid_value already
guard against, the same way, in this same file.
Second, save-session.sh now fails CLOSED when the extract step produces
no EXTRACT_FILE. This is not a second fix for the locale bug -- it is the
statement that the bridge is load-bearing. Whatever the reason a variable
stops crossing it, the run must stop there and say which variable, rather
than walking past the "0 exchanges" gate on counts that did arrive and
surfacing three layers down as FileNotFoundError on open(''). The
cooldown marker is already written by then, so continuing does not mean
trying again later; it burns the span. One reporter collected 5,071 of
those traces, none of which named the bridge or the locale.
Observed vs reasoned, per CLAUDE.md:
- OBSERVED: all four ubuntu-latest legs of the previous commit failed on
exactly the target assertion, tr_TR.UTF-8 resolving on the runner --
and only that assertion: the paired positive control (HUMAN_COUNT, no
I) stayed green there, which is the issue's own table reproduced in CI.
- OBSERVED: macOS does not reproduce it at all. The collation legs skip
on darwin, so the local suite (2419 passed, 50 skipped) is evidence
about the fail-closed guard and the non-regression legs, and no
evidence at all about the locale fix.
- REASONED: the guard holds for az_AZ and any other collation that
reorders the Latin range; only tr_TR was exercised.
Part of #695
Co-Authored-By: Max <noreply>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What breaks
safe_eval(scripts/log.sh) is the only bridge between the Python pipeline andthe shell. It matches
KEY=VALUEwith^([A-Z_][A-Z0-9_]*)=.[A-Z]is a POSIXbracket range, matched by the locale's collation order rather than by byte
value, and Turkish collation (tr_TR; az_AZ the same) does not place
IinsideA..Z.So on a Turkish-locale host every bridge variable whose name carries an
Iissilently skipped --
EXTRACT_FILE,POSITION,SKIP_LINES-- while the counts(
EXCHANGE_COUNT,HUMAN_COUNT, noI) still arrive. The counts pass the"0 exchanges" gate, and the run reaches
build-promptwith an empty path:The reporter's
hook-errors.logholds 5,071 of these. No save has ever completedon that host, whose only unusual property is its language. Reported in #695 and
confirmed against the code here.
The commits
Test first, red on purpose. The first commit adds the regression test and no
fix at all, so the red run on this PR is the evidence that the test would not
pass with the code doing nothing. The fix follows in the next commit.
Observed vs reasoned
Stated plainly, per CLAUDE.md:
[[ "I" =~ ^[A-Z]+$ ]]still matches undertr_TR.UTF-8on darwin -- checkedon this machine. This is glibc collation behaviour, so the Linux legs of this
PR's matrix are the only place it is actually observed.
the test watches this machine's own bash fail the
[A-Z]match onIunderit, so a runner that cannot reproduce the bug can never report a pass about it.
C.UTF-8anden_US.UTF-8, so the probefalls back to compiling
tr_TR/az_AZwithlocaledefinto a scratchLOCPATH(no root needed). Without that step the legs would skip on the exactplatform where the bug lives, and the module would assert nothing anywhere.
Whether
localedefand thetr_TRsource files are present onubuntu-latestis reasoned until this PR's run says so; if it turns outthey are not, the legs skip loudly rather than passing vacuously.
Paired controls
Per CLAUDE.md, every "must not happen" is paired with a "must happen":
HUMAN_COUNT(noI) must arrive on the same input -- a lostEXTRACT_FILEwould otherwise only mean the harness never ran
safe_evalat all.LC_ALLmust read back as the caller's own after the function returns.safe_evalaccepts: a lowercase name stays rejected, a bare command staysunexecuted.
Part of #695
[AI-generated]