Repository navigation
fix: pin UTF-8 at context and settlement IO boundaries - #7497
Conversation
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
loopx-agent
left a comment
There was a problem hiding this comment.
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
Reviewer: model_agent; gpt-6.1-sol; OpenAI; runtime_reported; reasoning_effort=max
APPROVE,精确head fd9b2f9a9351e8df7cfa02813e0934ae7d0149c7。两处已复现的UTF-8契约缺口已补齐,未发现本diff引入的阻塞问题。
动机 / Motivation
使用native context和原Turn补结算的CLI用户与维护者。 context锁文件与补结算CLI子进程使用文本模式却未指定编码,依赖宿主locale,违反既有全运行时UTF-8边界并可能误解码文本。 两处既有IO显式指定UTF-8,锁、argv、结算身份、收据、超时和异常路径保持。 不修改权限、上下文保留策略、模型、结算准入、重试、schema或UI。
改动思路 / Approach
在实际IO调用处补齐encoding参数,复用原文件锁、子进程和既有错误处理,不新增codec包装层。 编码属于IO调用自身的输入输出边界,不需要额外策略、配置或全局locale修改。原fd安全检查、文件锁的finally释放,以及补结算原始命令的身份、source、slots和receipt验证均保持原位。本PR仅为两个已有文本IO边界补齐显式UTF-8编码。
具体改动 / Changes
按 ca0396a3d80af5a313b776a99bdd375045b3addd 的 docs/development/testing-and-quality.md 与既有全仓UTF-8回归契约核对 TEXT-IO-UTF8、SUBPROCESS-UTF8。codex_context._locked只在原os.fdopen增加encoding;补结算的subprocess.run只为原text=True增加同一codec,argv、捕获、60秒timeout和check=False未变,JSON仍进入同一回执核验。两项全仓UTF-8契约扫描和受影响context/settlement cohort为206通过;最初24项未显式选择Codex二进制而跳过,随后隔离loopback补跑为18通过6跳过。全部premerge、规定Ruff与mypy、二文件边界通过。 补跑的6个skip是native失败compaction恢复或additionalContext不能保留完整原文的真实缺口,不是通过;它们没有被本codec修复改变或计入合格结果。
对主干的风险 / Risks
主要风险是无意改变锁和子进程生命周期,diff只有两个keyword,受影响真实路径与失败/恢复用例仍通过。其他平台未现场执行;现有明确UTF-8契约和扫描提供独立codec oracle,不能据此声称所有平台或Host上下文保留合格。最初误把未选择binary的skip看成平台限制,公开PR说明已按XML读回更正为206通过、24初始skip,补跑18通过6保留skip。CI依Goal配置未查询。
我的整体评价 / Verdict
在实际IO调用处补齐encoding参数,复用原文件锁、子进程和既有错误处理,不新增codec包装层。 本PR仅为两个已有文本IO边界补齐显式UTF-8编码。 修复与原IO owner一致,范围可独立回滚且没有状态迁移。只有两个编码参数变化,不影响渲染界面。未执行其他宿主平台;原生compaction/additionalContext另有六个资格缺口,均保留为skip;全量发布与真实模型资格仍由统一候选完成。 本结论仅覆盖codec修复,不把原生Host的保留缺口或正式发布资格改写为通过。
English verdict: APPROVE fd9b2f9a9351e8df7cfa02813e0934ae7d0149c7. Both existing text IO calls explicitly use UTF-8.206affected core cases and required local gates passed;native supplemental loopback recorded18passes and6honestly retained source-retention skips. No authority or lifecycle changes.
The context lock file and the owed-settlement CLI subprocess used text mode without an explicit codec. On non-UTF-8 locales this could decode existing context or subprocess output differently from the rest of the runtime.
Both existing IO boundaries now explicitly use UTF-8. Locking, process arguments, settlement identity, receipts and failure handling are unchanged. No protocol, authority or configuration changes.
Validation: the two repository-wide UTF-8 contract tests and affected real context/settlement suites passed (206 passed;24 native Codex loopback cases initially skipped until an explicit binary was selected). Required premerge, configured static checks and public-boundary results are recorded in the exact-head review. The24 native loopback cases were then executed separately with the explicit local Codex binary:18passed and6skipped because failed-compaction recovery or native additionalContext retention does not preserve the complete original source in those cases. Skips remain evidence gaps;they are not passes. Other platform execution and final release qualification remain separate.