Skip to content

Complete finding resolution with legacy stdout encodings - #1520

Closed
eowca wants to merge 3 commits into
mainfrom
lean178/1503-resolve-legacy-output
Closed

eowca wants to merge 3 commits into
mainfrom
lean178/1503-resolve-legacy-output

Conversation

@eowca

@eowca eowca commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Complete finding resolution with legacy stdout encodings

Context and goal

  • Goal: Resolve a finding and refresh eligibility even when the terminal cannot encode its title.
  • Problem: The successful GitHub mutations precede a print that can raise an encoding error, skipping the eligibility refresh.
  • Context: Preserve Unicode on capable streams. Escape a character only when the stream cannot encode it.

Closes #1503

Acceptance

  • With strict ASCII stdout, list findings with Unicode titles or paths and complete the same reply, resolve, and eligibility operations in the same order.
  • Preserve the original Unicode on UTF-8 stdout and leave GitHub content intact.
  • Extend existing cases with zero net test lines.

Base

Base: a68ef3b

Notes

Use the CLI's existing stdout configuration to select a display error handler for resolve. This keeps the mutation and dispatch flow as it was. No architecture update is needed because output encoding does not change GitHub or readiness authority.

Validation

(no loopzero check run recorded)


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

Review

  • primary, claude, 5c460a3, approve

Architecture-Review: unchanged; stdout escaping preserves the existing resolution and eligibility sequence.
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 5c460a3704b6d2ad7a9431f267c054b9e2f074b9, 40.3s: approve (0 critical, 0 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 tests/test_cli.py
@pytest.mark.parametrize("outcome", ["refreshed", "remaining", "dispatch failed"])
def test_resolve_lists_then_replies_and_resolves_one_finding(finding_pr, gh: FakeGh, capsys, outcome) -> None:
sys.stdout.reconfigure(encoding="ascii" if outcome == "refreshed" else "utf-8", errors="strict")
finding_pr["comments"]["nodes"][0]["body"] = finding_pr["comments"]["nodes"][0]["body"].replace("Off by one", "Łódź")

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: The Unicode path case from the acceptance criteria has no test

The acceptance criteria cover findings with Unicode titles or paths. The test only changes the comment body ("Off by one" -> "Łódź"), so the listing line's f.path (cli.py:1668) never contains non-ASCII text. The fix works on the whole stream, so paths are handled too, but nothing would catch a future change that formats paths differently (for example .encode()/ascii()). Smallest fix with no net test lines: put the same substitution into the fixture's path (e.g. src/a.py -> src/ą.py) and fold it into the existing title expectation string.

Comment thread src/loopzero/cli.py
args = parser.parse_args(argv)
# Preserve output order and escape characters a legacy stream cannot write during resolve.
if isinstance(sys.stdout, io.TextIOWrapper):
sys.stdout.reconfigure(line_buffering=True, errors="backslashreplace" if args.command == "resolve" else None)

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: The error handler stays set on a shared stdout in later in-process main() calls

For non-resolve commands, errors=None keeps the stream's current handler. A real CLI process calls main() once, so this is harmless there. In tests (and any embedding that calls main() repeatedly on the same sys.stdout), a resolve call leaves backslashreplace in place for every later command. Encoding failures from other commands could then go unnoticed in the same test. This is not a shipped bug. If you want strict isolation, reset to the stream's original handler instead of passing None (for example, capture sys.stdout.errors once). The line is also 117 characters, over the configured 100-character line length; E501 isn't selected, so this is cosmetic.

@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #1565 (the one replacement after both review rounds were used). Closing per the replacement ruling (#595).

@eowca eowca closed this Nov 26, 2026
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.

Complete finding resolution when stdout cannot encode the title

1 participant