fix(verify): force LC_ALL=C at the git chokepoint so rollback stops matching English (#236)#237
Conversation
…atching English (#236) safe_rollback tolerated a benign `git checkout <snapshot> -- <preserve-dir>` no-op (a preserve dir holding only untracked files) by substring-matching git's English "pathspec ... did not match" message. `_run_git` ran git with the inherited environment, so under a localized git (e.g. LANG=it_IT.UTF-8) the message is translated, the substring never matches, and the benign no-op raises GitError — turning a resolvable re-drive into the rollback-pause path. Force LC_ALL=C at the sole git spawn point (_run_git) so every message the orchestrator inspects stays stable English, making the whole class of locale-fragile parsing impossible rather than patching the one instance. The locale is merged last so it wins over both the inherited environment and the explicit env the two _git_env callers pass (their throwaway GIT_INDEX_FILE / synthetic commit identity vars are preserved by the spread). Regression coverage spies on the actual subprocess env rather than the parent LANG, so the guarantee holds even on a CI box with no non-English locale catalogs installed (where a plain LANG=it_IT test would emit English anyway and pass without the fix). Refs #233.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
WalkthroughGit subprocesses now force ChangesLocale-stable Git handling
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related issues
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Closes #236.
safe_rollback(src/bmad_loop/verify.py) restores eachpreservedir from a pre-reset stash snapshot and tolerates the benign case — a preserve dir holding only untracked files — by substring-matching git's English message:_run_gitspawned git with the inherited environment and no locale override, so under a localized git (e.g.LANG=it_IT.UTF-8) the benign message is translated, the substring never matches, and the benign no-op raisesGitError— a resolved re-drive that should auto-recover instead lands in the rollback-pause path. Reported by @Polloinfilzato in #233 as a locale-dependent test failure; the root cause is production code and the blast radius is the rollback path.Fix
Force
LC_ALL=Cat the single git spawn point,_run_git, so every git message the orchestrator inspects stays stable English — making the whole class of locale-fragile message parsing impossible rather than patching the one instance.LC_ALL=Cis merged last so it wins over both the inherited environment and any explicitenv. The two_git_envcallers (throwawayGIT_INDEX_FILEsnapshot staging; syntheticcommit-treeidentity) keep their vars because the caller's env is spread first.LC_ALL=Calone is sufficient — verified thatLANGUAGE=it LC_ALL=C git …still prints English (gettext disables translation entirely in the C locale, so it wins overLANGUAGE).verify.py:587today is the only site insrc/that branches on English git text; the merge machinery already decides via return codes /MERGE_HEAD/git diff --quiet.Tests
Two portable regression tests spy on
subprocess.run'senvrather than the parentLANG, so the guarantee is pinned even on a CI box with no non-English locale catalogs installed (a plainLANG=it_ITtest would emit English anyway and pass without the fix — false green):test_run_git_forces_c_locale— assertsLC_ALL=Creaches every git child.test_run_git_locale_merge_preserves_explicit_env— asserts the merge preserves a caller-supplied env key alongside the forcedLC_ALL.The existing
"did not match"tolerance tests stay green and now hold under any operator locale.Verification
trunk checkclean on changed files.Refs #233.
Summary by CodeRabbit
Bug Fixes
Tests
Documentation