Skip to content

Preserve Unicode Git and GitHub names under legacy locales - #1907

Merged
mergify[bot] merged 7 commits into
mainfrom
lean178/1504-1505-legacy-locale-v2
Nov 26, 2026
Merged

mergify[bot] merged 7 commits into
mainfrom
lean178/1504-1505-legacy-locale-v2

Conversation

@eowca

@eowca eowca commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Keep Unicode branch names for GitHub lookups and pass native ref bytes to Git for reflog, guarded pushes, and cleanup. Decode GitHub CLI responses as UTF-8. This supersedes #1529.

Closes #1504
Closes #1505

Validation

Recorded for 56fc575a86e5

  • uv run --group dev ruff check src tests: exit 0
  • uv run --group dev tach check: exit 0
  • uv run --python 3.14 python scripts/check_architecture_docs.py: exit 0
  • scripts/size_budget.sh: exit 0
  • uv run --group dev pytest -q: exit 0
  • The automated ASCII-locale regression exercises status, a force-with-lease push to a fixture remote using the reflog, and cleanup. It opens a PR with a Unicode readiness reason and checks the escaped diagnostic. Removing the reflog fix reproduces the original ASCII encoding failure. The same scenario also passed with ISO-8859-2 in a local rehearsal.
  • Fake GitHub REST and GraphQL responses verify literal Unicode with legacy subprocess defaults.
  • Size budget on 6b72f82 reports 8,125 source lines (−1) and 13,557 test lines (+38), both within caps.

Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

Review

  • primary, claude, 487048f, request_changes

The GitHub fixture retains the original REST argv, successful login, and missing-login assertions. The existing no-PR status test remains in place.

eowca and others added 5 commits November 26, 2026 13:23
Architecture-Review: unchanged; filesystem paths and refs round-trip native Git bytes and GitHub keeps its UTF-8 transport.
Co-Authored-By: Codex <noreply@openai.com>
Co-Authored-By: Codex <noreply@openai.com>
Architecture-Review: unchanged; the merge retains the existing Git and GitHub transport boundaries.
Co-Authored-By: Codex <noreply@openai.com>

@loopzero-feder-positronics loopzero-feder-positronics Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

loopzero primary review by claude on 487048fe429f23ec53fc505b59509119b9be1d40, 94.2s: request_changes (0 critical, 1 important, 2 suggestion)

Settings per native call (launch configuration and CLI claims, not backend attestation):

  • Call 1: requested model claude-opus-5-5 (effort medium); CLI-reported model claude-opus-5-5 (effort unknown); configured model claude-opus-5-5 (effort medium)

Native Claude output is retained in the restricted local review receipt.

Comment thread src/loopzero/cli.py Resolved
Comment thread src/loopzero/cli.py
existing = _sync_task_narrative(wt, pr.body or "") if pr is not None else None
body = _pr_body(wt, head, config, existing)
force_lease = False
git_branch = os.fsdecode(branch.encode("utf-8", "surrogateescape"))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Unicode↔Git-native name conversion is repeated by hand in five places

The same idiom is written out at five sites:

  • os.fsdecode(x.encode("utf-8", "surrogateescape")) at cli.py:712, cli.py:1853 and github.py:1479.
  • The reverse, os.fsencode(x).decode("utf-8", "surrogateescape"), at worktree.py:308 and worktree.py:355.

branch() now returns either form depending on the native flag, so every new Git call that takes a task-branch name must remember to convert it. If one forgets, it crashes with UnicodeEncodeError under a legacy locale.

The same gap already exists for the configured base branch. The TOML-sourced base_branch reaches Git argv unconverted at config.py:75, 106 and 109, worktree.py:231 and cli.py:1277. These are outside this task's acceptance, but they belong to the same class.

Suggested fix: add a pair of helpers in worktree, for example git_name(unicode) -> native and unicode_name(native) -> unicode, and use them at all of these sites. That keeps the conversion in one place.

Comment thread src/loopzero/github.py
if current != expected_head:
return current is None
ref = f"refs/heads/{branch}"
ref = os.fsdecode(f"refs/heads/{branch}".encode("utf-8", "surrogateescape"))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: No test runs delete_remote_branch under a legacy locale

The legacy-locale test calls cli._delete_tracking_ref and worktree.cleanup directly. It never goes through cmd_merge → _cleanup_remote_refs → github.delete_remote_branch, so the native-ref change at github.py:1479 has no test. If that conversion regresses, git push :refs/heads/lz/Łódź fails with UnicodeEncodeError at argv encoding. _cleanup_remote_refs only catches GhError and ProcTimeout, so the error escapes and aborts merge after the PR has already merged.

Add a narrow check for this path. One option: monkeypatch github._remote_branch_head and assert the argv bytes inside the legacy-locale subprocess.

eowca and others added 2 commits November 26, 2026 15:01
Architecture-Review: unchanged; display encoding preserves the existing status and resolution interfaces.
Co-Authored-By: Codex <noreply@openai.com>

@loopzero-feder-positronics loopzero-feder-positronics Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

loopzero delta review by claude on 56fc575a86e59ec83951ab2a21eab904c99fbac7, 16.5s: approve (0 critical, 0 important, 1 suggestion)

Settings per native call (launch configuration and CLI claims, not backend attestation):

  • Call 1: requested model claude-opus-5-5 (effort medium); CLI-reported model claude-opus-5-5 (effort unknown); configured model claude-opus-5-5 (effort medium)

Native Claude output is retained in the restricted local review receipt.

Comment thread tests/test_cli.py
from pathlib import Path
from loopzero import cli, worktree

cli._readiness = lambda *_, **__: cli.github.Readiness(False, ("check \\u0141 is pending",))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Legacy-locale test stubs out _readiness, so the real readiness path never runs with a Unicode branch

The subprocess replaces cli._readiness with a lambda that returns a fixed reason. That proves _print_display escapes the reason text. It does not check that the real readiness evaluation (check runs, review markers and branch-history lookups for lz/Łódź) works under LC_ALL=C. If that evaluation decoded or encoded the branch wrongly, this test would still pass. A smaller fix: keep the real _readiness and add fake GitHub responses so it returns a pending or blocking reason that includes the Unicode branch or a finding title. If that costs too much fixture setup, add a comment saying the stub only covers display escaping.

@eowca
eowca marked this pull request as ready for review November 26, 2026 14:10
@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

@Mergifyio queue

@mergify

mergify Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

✅ Merged into main as 5c63c56 at 14:16 UTC

5 min in the queue, 4 min of it CI.

So far

  • ✅ Entered the queue Thu 26 Nov, 14:11 · rule main · triggered by @eowca with the @mergifyio queue command
  • ✅ Passed · draft #1927
  • ✅ Merged 14:16 · 5c63c56 · squash
3 merge conditions met
  • github-review-approved · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required
  • any of · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required:
    • check-success = checks
    • check-neutral = checks
    • check-skipped = checks
  • any of · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required:
    • check-success = Loop-zero Eligibility
    • check-neutral = Loop-zero Eligibility
    • check-skipped = Loop-zero Eligibility

Times in UTC · dashboard · how the merge queue works

@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

No description provided.

@mergify
mergify Bot merged commit 5c63c56 into main Nov 26, 2026
19 checks passed
@mergify mergify Bot removed the queued label Nov 26, 2026
@eowca
eowca deleted the lean178/1504-1505-legacy-locale-v2 branch November 26, 2026 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Decode GitHub CLI JSON as UTF-8 under legacy locales Preserve Unicode Git branch names and checkout paths under legacy locales

1 participant