Skip to content

fix(goals): pin UTF-8 when reading amendment source gates - #6397

Merged
huangruiteng merged 1 commit into
mainfrom
codex/goal-amendment-utf8
Oct 14, 2026
Merged

huangruiteng merged 1 commit into
mainfrom
codex/goal-amendment-utf8

Conversation

@huangruiteng

Copy link
Copy Markdown
Collaborator

Governed Goal amendments read UTF-8 source Turn gates using the host's default codec. On a non-UTF-8 host, Unicode gate metadata raises a decoding error before the native lifecycle decision. Pin that read to UTF-8 while retaining strict rejection of invalid bytes, malformed JSON and closing Goal lifetimes.

The existing File/SQLite native CLI tests now simulate an ASCII-default gate reader and verify an open ASCII gate, a closing gate with Unicode metadata, malformed JSON and invalid UTF-8. Rejected requests preserve the original canonical revision and intent. This stays in the existing Python transport adapter; no new state owner or extraction is needed for the codec-only change.

Validation:

  • Reproduced the existing text I/O guard failure on the base.
  • Both File/SQLite Unicode gate cases fail on the base with an ASCII decoding error.
  • 33 tests passed: the text I/O guard and complete native amendment authority suite.
  • Ruff on both changed files and git diff --check passed.

Local checks simulate a non-UTF-8 default; this has not been tested on a Windows host. Full CI remains pending. The defect is inherited from the base and also appears in PR #6391's CI; this is an independent fix.

Signed-off-by: huangruiteng <huangrt01@163.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.

Exact head: a7b212115b4a8d90c119f27b0a040cf23fa8dc48. APPROVE — 未发现阻塞项。

动机

受影响的是在非 UTF-8 默认环境下配置或提交 governed Goal amendment 的维护者和 Agent。例如 closing gate 带有“复核”操作名,原实现按主机默认 ASCII 解码,提前报 codec 错误;修复后按 gate 的 UTF-8 存储格式读取,返回原生 goal_retirement_in_progress 并拒绝写入。当前 File/SQLite 反例已验证:Unicode closing gate 到达原生拒绝,开放 gate 可正常配置,坏 JSON 和无效 UTF-8 仍失败,拒绝后原 intent 与 provider revision 不变。本次只修 gate 读取编码,不改变 amendment 权限、状态机、默认启用方式、canonical 存储或参数;真实 Windows 主机未验。

改动思路

保留 Python source/transport 适配层和已有 TypeScript 决策 owner;一行显式 encoding 足够,不为 codec 引入新 helper 或分类规则。本次边界为 gate 的严格 UTF-8 解码和原生入口反例验证,生命周期及原操作恢复的所有权保持。 source Turn gate 的其它读取 owner 本来就显式使用 UTF-8;此处遗漏造成主机相关错误。保持 quota→registry 的锁序、source Goal 路由、native authority/CAS 与原操作恢复,不用 replacement decode,也不扩大到全局编码设置。现有治理入口无需增加前端配置或发现步骤。

具体改动

规范依据 docs/architecture/rfcs/shared-goal-alignment-and-governed-amendment-v0.md,改动前版本 3dd3c550afecfa0c525a34e8744a3cf06774ac94,§9.3 的既有约束:source-owned-lifetime、canonical-refusal-and-readback、transport-not-decision-owner 均 implemented。这些标签对应原文要求,不新增 roadmap 门槛。

关键代码讲解

  • execute_goal_amendment L56 在原 guards 下读取 gate,唯一运行时变化是 L92 的 encoding="utf-8"。然后仍把当前 source facts 交给 goal.amendment.execute,不自己判 closing 或授予执行权。
  • sourceGoalMutationReadiness L311 保留 profile、active lifetime、精确 GoalRef 和 closing-gate 拒绝;amendment authority 原有调用未改。编码修复使 Unicode metadata 正确到达这条原生规则。
  • 新四种 codec 反例分别使用 File/SQLite:开放 ASCII gate、closing Unicode gate、坏 JSON、无效 UTF-8。拒绝后检查原 provider revision 和 intent,防止“报错了但已经写入”;finally 恢复 fixture gate 后再 inspect。

两文件 +56/-1:一行 transport 修复和 55 行耐久入口验证。没有新状态、协议、wrapper 或迁移。

对主干的风险

最强反例是为了“成功解码”而吞掉坏字节或绕过 closing fence;当前保持 strict UTF-8 与原 native refusal。相同当前测试在不可变 base 上得到 2 failed /6 passed:File/SQLite 的 Unicode closing 均提前出现 ASCII codec error,未到达 goal_retirement_in_progress。当前完整 authority 模块 31 passed、0 skip,37.46s,再加文本 IO 守卫 2 passed。既有 configure/propose/commit/replay、错误身份、retirement、缺 authority 等路径仍覆盖。

语义与 CI 对齐

复用既有 gate 词汇及 TS owner,不新增分类规则、domain 义务或 guidance。Ruff、diff、开发期 advisory 后全树 semantic 通过;原生 canary 5 direct /13 selected,0 failure /0 hold,公私边界干净。未查询、轮询或等待 GitHub CI。测试模拟非 UTF-8 默认,不等于实际 Windows 主机或安装前端认证;这个可区分的 codec 修复不要求无关 provider/GUI 重构。

我的整体评价

APPROVE,绑定 a7b212115b4a8d90c119f27b0a040cf23fa8dc48。普通 Unicode gate 现在能给出准确生命周期原因;持续工作、claim、CAS、回读和原操作恢复的所有权保留,旧错误没有被改成成功。相关简化 pass 判定保持一行修复最合适:跨模块复用私有 _read_gate 会连带改变错误/形状处理,当前没有这个必要。权限、默认启用与用户入口不变;合并需要各自原有授权和 readiness。

English verdict: APPROVE — a7b212115b4a8d90c119f27b0a040cf23fa8dc48. Explicit strict UTF-8 restores the existing native closing-gate rejection under an ASCII-default simulation. The same current oracle fails twice on the frozen base and passes on the head; all 31 File/SQLite authority tests, two IO guards and exact-scope canary checks pass. Native Windows and installed frontend adoption remain untested. Remote CI was not consulted; merge authority is separate.

@huangruiteng
huangruiteng merged commit 39bb523 into main Oct 14, 2026
30 of 36 checks passed
@huangruiteng
huangruiteng deleted the codex/goal-amendment-utf8 branch October 14, 2026 06:26
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.

2 participants