Skip to content

fix(perf): pin utf-8 on the py-spy subprocess call - #20146

Merged
javenciu merged 1 commit into
mainfrom
fix/subprocess-encoding-cli-perf
Oct 14, 2026
Merged

javenciu merged 1 commit into
mainfrom
fix/subprocess-encoding-cli-perf

Conversation

@javenciu

@javenciu javenciu commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A text-mode subprocess call in 1 file decodes its child's output as UTF-8 on every platform instead of the locale's code page.

The subprocess-encoding gate counts, per file, the sites the repo still tolerates. This PR retires: 1 src/kiro_crew/cli_perf.py.

Why it matters

Without an explicit encoding, subprocess.run(..., text=True) decodes with the locale code page, which on Windows is not UTF-8: non-ASCII output becomes mojibake or raises UnicodeDecodeError (#5249). The repo lists every such call per file in .github/subprocess-encoding-baseline.txt and the gate lets each count only shrink.

Not a goal

  • Calls in files not listed here (each is its own one-mechanism PR).
  • Changing what any child process does or how its output is used.
  • Any refactor or reformatting of untouched lines.

What changed (motivation → approach → change)

Each call below now pins UTF-8 (encoding="utf-8", or the shared **UTF8_TEXT mapping from kiro_crew.subprocess_utf8 where the file's neighbours use it), and the file's baseline line is removed.

  • src/kiro_crew/cli_perf.py: argv, capture_output=True, text=True, timeout=args.seconds + 60
  • .github/subprocess-encoding-baseline.txt: removed 1 src/kiro_crew/cli_perf.py.

Backwards compatibility

Compatible: the call's return type and the output's meaning are unchanged; only the decode encoding is pinned.
Removes nothing: a baseline entry is a tolerance the gate stops needing, not a capability.

Tests

  • Deleting the baseline line with the file untouched: RATCHET_SCOPE_WHOLE_TREE=1 python3 scripts/check_subprocess_encoding.py exits non-zero ("new offender(s)"), proving the gate still counts the old call.
  • With the edit: python3 scripts/check_subprocess_encoding.py --test && python3 scripts/check_subprocess_encoding.py exit 0, and the touched file' own tests pass with an unchanged count.
  • flake8 clean on the touched file; the repo's baselined black gate passes.

Manual verification

N/A — unit coverage sufficient: the gate and the file's own tests exercise the changed lines directly.

Pattern harvest

Rule candidate: none new; the rule is already enforced by scripts/check_subprocess_encoding.py (a baselined CI gate that flags every text-mode subprocess call without an explicit encoding), and this PR retires baseline entries under it.

Screenshots / video

Why no screenshot: nothing renders; this change pins a subprocess decode encoding and a CI baseline only.

No issue exists; burn-down of the subprocess-encoding gate baseline (precedents #19928, #20014, #19527).

`kirocrew perf sample` runs py-spy in text mode with no encoding, so
the child's stdout and stderr are decoded with the host code page:
mojibake on Windows, and a UnicodeDecodeError under a code page that
cannot decode the bytes, which the function's `except OSError` clauses
do not catch.

Splat the shared UTF8_TEXT mapping instead. It carries text=True, so
the explicit text=True goes. Drop the file's line from the
subprocess-encoding baseline so the ratchet shrinks (#5249).
@javenciu
javenciu requested review from a team and KiroCrewCaptain as code owners October 14, 2026 05:48
@javenciu
javenciu requested a review from mbriones98 October 14, 2026 05:48
@github-actions github-actions Bot added the readiness: action required A blocking check or review needs attention label Oct 14, 2026
@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of b7cf0710e66fd28dc5f57d2978bce9c5bd4888a0 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] b7cf071

False positive or not applicable? A repository writer can comment:
/ai-review override gpt b7cf0710e66fd28dc5f57d2978bce9c5bd4888a0: <one-sentence reason>

@javenciu

Copy link
Copy Markdown
Contributor Author

Closing and reopening so CI runs on hosted runners: same-repo runs from this account queue on the fleet label without a runner (details on #19683).

@javenciu javenciu closed this Oct 14, 2026
@javenciu javenciu reopened this Oct 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision b7cf0710e66fd28dc5f57d2978bce9c5bd4888a0 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Advisory — does not block merge.

@github-actions

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of b7cf0710e66fd28dc5f57d2978bce9c5bd4888a0 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

First-Principles-Verdict: PASS

Nothing to check.

What this change ships

Inventory (2 items) — 2 justified

Intent: profiling with kirocrew perf no longer garbles or crashes on non-ASCII py-spy output under a non-UTF-8 Windows locale; FIX.

  1. py-spy output is decoded as UTF-8, with replacement on bad bytes, on every platform. It uses the existing UTF8_TEXT from src/kiro_crew/subprocess_utf8.py:62 — justified
  2. The baseline drops the cli_perf.py entry, so the gate now refuses a new unpinned call there — justified

[FIRST-PRINCIPLES-REVIEWED] b7cf071

Description read

[DESCRIPTION-READ] cdf5b6cea1ab4ac93c8d827ee14002a9b98ed8c52c05630c4c566135975b7f31

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of b7cf0710e66fd28dc5f57d2978bce9c5bd4888a0 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Nothing to check.

[DESIGN-REVIEWED] b7cf071

Description read

[DESCRIPTION-READ] 349408c13c6510d8c225cd2e70aebbe7d1f6f5d0123a77a7c2b11851a7de1f74

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed b7cf0710e66fd28dc5f57d2978bce9c5bd4888a0 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] b7cf071

Verdict parsed from the review's SHA-scoped output markers for commit b7cf0710e66fd28dc5f57d2978bce9c5bd4888a0.

False positive or not applicable? A repository writer can comment:
/ai-review override fable b7cf0710e66fd28dc5f57d2978bce9c5bd4888a0: <one-sentence reason>

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention labels Oct 14, 2026
@javenciu
javenciu enabled auto-merge (squash) October 14, 2026 10:17

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Tier 1 auto-approve: fix (2 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, security checklist all-NO, no reviewer-lane findings, readiness signal fresh for this head SHA, declared category matches the diff. Category: passes the shared UTF8_TEXT kwargs to the py-spy subprocess call instead of text=True and drops the file from the subprocess-encoding baseline.

This was referenced Nov 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

readiness: passed Eligible automated validation passed for the current revision

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants