Skip to content

test(windows): decode CLI JSON as UTF-8 - #6294

Merged
huangruiteng merged 1 commit into
loopx-project:mainfrom
LIHUA919:codex/windows-utf8-cli-capture
Oct 12, 2026
Merged

huangruiteng merged 1 commit into
loopx-project:mainfrom
LIHUA919:codex/windows-utf8-cli-capture

Conversation

@LIHUA919

Copy link
Copy Markdown
Contributor

The Windows PowerShell check fails the ordinary File and SQLite lifecycle cases when it reads a Todo note containing Chinese text and an emoji (PR #5280 job); the same assertion failed on an unrelated PR #6273 job. LoopX's CLI explicitly writes UTF-8 JSON, while this test module's subprocess.run(text=True) helpers decode captured output with the Windows locale. The resulting mojibake makes a preserved note appear corrupted to the test. Decode all three Python CLI JSON captures as UTF-8, matching the product output contract without changing stored data or runtime behavior.

Validation: a UTF-8 child decoded as CP1252 reproduced the observed mojibake, while UTF-8 decoding returned the exact Unicode text. The full test_sqlite_authority_cli.py module passed 9/9 from this source checkout on Python 3.12; Ruff, git diff --check, and the changed-file public boundary scan passed (one unrelated active-state warning). The Windows CI result on this exact head remains pending for confirmation.

Signed-off-by: Lihua <1017343802@qq.com>

@loopx-agent loopx-agent 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.

Reviewer: model_agent · gpt-6.1-sol · OpenAI · runtime_reported · reasoning_effort=xhigh

Reviewed exact head: b42cc1b

动机

在 Windows 或其他非 UTF-8 locale 下验证 Todo 生命周期的贡献者。
CLI 已输出 UTF-8 JSON,而测试父进程默认按本机编码解码,中文和 emoji 变成乱码,File/SQLite 的真实生命周期断言因此误报。三处捕获显式按 UTF-8 解码后,原断言和数据保持完整。
同一 CP1252 父进程反事实中,base 的 File/SQLite 两例失败、七例通过;当前 head 九例通过,普通环境也是九例通过。
仅修复测试捕获,不改变 CLI 编码、Todo 持久化、authority、断言或测试样本;未宣称原生 Windows 验证。

改动思路

对齐既有生产者编码契约即可修复,不改产品输出、不删 Unicode 样本,也不放松生命周期断言。规范依据 loopx/entrypoint.py 的 pin_utf8_stdio,不可变版本 d03863f;这是原有 stdio 契约,不是此次新增规定。

具体改动

tests/control_plane/test_sqlite_authority_cli.py:47 的 cli、:172 和 :301 的 command 三个 helper,都在 subprocess.run 保留 capture_output/text/timeout 的同时明确 encoding=utf-8。前者继续验证 SQLite-only CLI,无 Markdown fallback;后两者继续用独立复制包和真实 CLI 验证普通工作、归档与 File/SQLite 退出读回。运行入口、stdout JSON、stderr 诊断和返回码断言未变化。

对主干的风险

普通 exact-head 九例通过。相同九例仅将父进程 subprocess._text_encoding 改为 CP1252:base 七过、File/SQLite 的两条中文/emoji note 精确断言失败;head 九过。实际子进程、JSON 和持久化 owner 未替换。既有 stdio/runtime subprocess 回归、Ruff 与 diff hygiene 已检查;不查询 CI。CP1252 模拟验证解码边界,不能冒充原生 Windows 资格。
这是对已有 durable coverage 的就地修复,未新增同形测试或测试脚手架;同作者近期 PR 涉及不同真实问题,未发现同形拆分。界面、CLI/Lark 产品行为、authority 和调度均未改。

我的整体评价

APPROVE,没有阻塞发现。这三处明确 codec 消除了已复现的假失败,并保持完整 Unicode 数据和原生命周期验收;无需为三个既有 helper 引入抽象或扩大重构。没有新增 capability、默认行为或持久化协议,原生 Windows 验证范围如上。

English verdict: APPROVE - b42cc1b. Three existing CLI test captures now match the unchanged UTF-8 stdio contract. The same CP1252-parent suite fails two Unicode lifecycle assertions at base and passes all nine at head; the ordinary suite also passes nine. No assertions or Unicode fixtures were weakened. Native Windows was not claimed and CI was not consulted.

@huangruiteng
huangruiteng merged commit 18cff5d into loopx-project:main Oct 12, 2026
19 of 26 checks passed
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.

3 participants