Skip to content

refactor(control-plane): share projection snapshot fallback - #7788

Merged
huangruiteng merged 1 commit into
mainfrom
codex/projection-snapshot-transport-20261101
Nov 2, 2026
Merged

huangruiteng merged 1 commit into
mainfrom
codex/projection-snapshot-transport-20261101

Conversation

@loopx-agent

@loopx-agent loopx-agent commented Nov 1, 2026 •

Copy link
Copy Markdown
Collaborator

Turn envelope 和 controller 分别维护相同的传输回退规则:先发送普通请求,只在 request_too_large 拒绝后切换现有的有界私有 snapshot。将这条规则收回既有 effect_runtime.py,同时迁移两个生产调用方,后续修改只需维护一个位置。

这是 controller/executor RFC 的共享 transport 精简。Python 适配完整事实,TypeScript 继续决定 envelope、route 和 receipt;保留普通小包路径、2 MiB/64 MiB 限制、method/private-file/digest 校验与不确定响应不重放规则。五个既有测试文件只调整观察/故障注入位置,断言和合成输入保持原样。相邻重构已应用于这条重复 IO 规则;C4.3 两类结算适配器的不同义务继续各归其主。

验证:在 0e78a19c277f4ca3d44313787162bc0444065172 与精确 head 4fa61cc7b0e584665b859e2a801af076f37471c8 运行同一组既有用例,各 324 passed / 7 skipped。覆盖真实 TS transport 的小包、大包、escaped Unicode、签名拒绝、64 MiB 发送前拒绝、故障注入的非尺寸拒绝/不确定响应,以及合成 File/SQLite authority 的实际 turn managed-step 成功与拒绝、journal 不变和零 spend。本机 Python 3.14.8 / Node 24.21.0。该源码矩阵中的7个显式 native Codex loopback 用例当时未启用;后续分别补测 CodeMode 单例和下述剩余六个原生用例。原 324 passed / 7 skipped 仍是原运行记录,不改记为一次完整原生矩阵通过。

可重放检查(分别在 base 和本 PR 的精确 head 执行):

uv sync --extra test
uv run --extra test python -m pytest -q \
  tests/test_loop_turn_loop_controller.py tests/test_turn_controller_projection.py \
  tests/control_plane/test_saved_context_project.py \
  tests/control_plane/test_progressive_native_context.py \
  tests/control_plane/test_context_delivery_cli.py tests/test_turn_envelope.py \
  tests/control_plane/test_effect_runtime_integration.py::test_oversized_request_is_rejected_before_runtime_dispatch \
  tests/control_plane/test_effect_runtime_integration.py::test_large_local_response_digest_failure_is_ambiguous \
  tests/control_plane/test_effect_runtime_integration.py::test_controller_snapshot_retains_private_file_and_method_guards

回归敏感性:仅将新 helper 临时改为 return effect_runtime_result(method, params),执行下列相同生产入口用例,得到 2 failed;恢复后通过。它分别暴露 producer 丢失完整大包通道、controller 丢失原签名拒绝的情况。

uv run --extra test python -m pytest -q \
  'tests/test_loop_turn_loop_controller.py::test_controller_preserves_complete_goal_over_the_real_transport[large-producer]' \
  tests/test_loop_turn_loop_controller.py::test_large_controller_decision_keeps_signature_rejection

base/head 的五个合成 fixture 函数 AST 指纹相同;其中 _full_decision(源输入)与 _envelope(controller 输入)的 SHA-256 为 b6dc5d6897851f7acd05ca7b10131189fca54a7a6a8db14d090eb2cae10ef3a7、421429a4614cc82e8dcd4472db6cbe1747d31964da359eb3e7b53005a8cb98d0。331 个 case 的 (classname, name, outcome) 排序后,按 json.dumps(..., ensure_ascii=False).encode() 计算的观测 SHA-256 为 ed3e2e238887c8e18c3683b37da4143946f779ec36c92fd07aa739ca4c9f7853,base/head 相同。通过 Ruff、diff 检查、diff-scoped semantic advisory(0 supported carriers)、RFC bilingual diff 检查和 8 文件公开边界扫描。

首次实际 native 消费者补测(CodeMode 单例,历史独立运行)

补充实际 native 消费者验证:Codex 0.166.0-alpha.5.1 的 app-server Code Mode 在同一 base/head 均通过既有 app_code_mode 用例。真实请求包含 custom exec 工具声明,原生嵌套命令完成冷态 full、完整原始页读取、温态 delta 和原 Turn/receipt/文件完整性读回;新增 guard/spend 均为零。仅 inference 为静态 loopback,所有 Goal/SQLite/native home 均为隔离合成夹具。

LOOPX_NATIVE_CHECKPOINT_BIN="$(command -v codex)" uv run --extra test python -m pytest -q \
  'tests/control_plane/test_saved_context_project.py::test_native_saved_preflight_uses_lifecycle_without_guard_replay[app_code_mode]'

在保持原 CLI reader 执行与全部断言不变时,仅让 Code Mode 丢掉 reader 面向模型输出的首字节,该原生用例 1 failed;还原精确源码后 1 passed。这是实际输入 oracle 的敏感性证明;未报告的下游丢失仍保留原 Host 假设边界。

此 fixture 的 base/head 各出现6次本地 inference 请求,解析后的 input 按紧凑 UTF-8 JSON 序列化再累加,分别为 699023 / 703572 bytes;恢复校验为700311 bytes。三次测试整体墙时分别为3.950 / 4.069 / 4.293秒。动态元数据未归一,数值不作因果或性能收益判断;它们也不是 wire bytes、真实模型 token/费用或完整长程成本。首次补测当时未执行其余5个 saved-preflight 变体及1个 native discovery;本轮补测见下,原历史运行范围与失败记录保留。

后续补测:其余五个 saved-preflight 变体与 discovery

在同一不可变 base 0e78a19c277f4ca3d44313787162bc0444065172 与精确 head 4fa61cc7b0e584665b859e2a801af076f37471c8 分别执行,均为 6 passed、0 skipped;Codex 0.166.0-alpha.5.1 前后版本一致。未重复首次已通过的 CodeMode 单例。两个原生用例及六个相关 helper 的 AST 在 base/head 一致;saved-preflight 用例 AST SHA-256:641ddb65a2d2e406bd06fe63367e63da80ac9e38f424c0518686c4bd74797d29。

原生入口 实际通过的边界
app_server 冷 full、温 delta,模型输入中完整实际页与原文件、digest 和完整恢复一致
app_machine 经既有 machine 配置的原生路径,保持相同完整页和来源校验
benchmark 真实 run_once 两轮、同 session、独立原 Turn/selection,完整输入与原源一致
app_progressive、benchmark_progressive 真实 index/选择性 reader;所选 Goal/receipt 字段进入实际模型输入,未将选择性读取晋升为完整 baseline
discovery 两次真实 hook 探测均禁用 probe 的插件功能;原配置和 worker 选择保留,无模型请求或插件目录克隆

App 三变体的展示/读取不新增 guard 或 spend。两条 benchmark 变体各有两轮原 guard+selection,每轮原回执数为2;每个用例仅有一次显式的轮间合成结算扣额。它们并非“零准入/零扣额”,读取本身不重放这些效果。所有 Goal、SQLite、native home 和 checkpoint 均为隔离合成 fixture,inference 为静态 loopback;没有运行真实 benchmark case、外部模型或 live 账号切换。

可重放这次新增范围(分别在 base/head 运行):

LOOPX_NATIVE_CHECKPOINT_BIN="$(command -v codex)" uv run --extra test python -m pytest -q \
  tests/control_plane/test_saved_context_project.py::test_native_saved_preflight_uses_lifecycle_without_guard_replay \
  tests/control_plane/test_saved_context_project.py::test_native_discovery_keeps_plugins_out_of_probe_without_changing_solver \
  -k 'not app_code_mode'

输入 oracle 的新增敏感性检查仅在测试传输边界动手:原 CLI 照常执行,向原生 app_server 交付 reader stdout 时剪去首字节;既有用例 1 failed。撤掉故障后同例 1 passed,tracked 产品和测试源码始终未改。这验证实际输入断言会发现该类丢失,不声明所有未报告的下游丢失都能被生产系统识别。

这轮 base/head 各有 44 次 loopback 请求,解析后的 input 紧凑 UTF-8 JSON 累加分别为 3710932 / 3706222 bytes;完整命令墙时为 46.60 / 53.83 秒。这是共享主机上的顺序单样本,动态元数据未归一,head 此次更慢;不作因果、性能或净收益结论。它们不是 wire bytes、真实 token 或费用;静态 provider 的 usage 是合成值。全部准备、探测和负例成本也不包含在这两个正例命令墙时中。

这些用例补齐原来未运行的调用方回归。progressive 的模型输入只验证选定字段;完整源可恢复不等于模型已读完全部要求。新增资格不涵盖真实模型决策/成果采用、安装态 App、整个 C1/C2 或完整长程成本,也没有新增 >2 MiB native 负载资格;原大包与边界验证仍限前述源码矩阵。

本次提供行为保持的维护性改进;长期效果/效率收益、安装与完整 Host 资格仍需其原有验收。正常提案交评审与维护者决定合并。

Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator Author

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: max

Approval conclusion (author-owned PR; GitHub blocks formal self-approval)

无阻塞发现;保留一项独立归因的基线维护性扫描失败。

动机 / Motivation

受影响的是维护原生上下文 producer/controller 的开发者,以及通过它们继续工作的 Agent。维护者调整大上下文的传输回退时,原来需要同步 producer 与 controller 两份相同规则;本次合并为 transport 中一个函数,普通请求和尺寸拒绝后的完整快照传输保持一致。已独立验证普通、大请求、Unicode、停止分支和签名拒绝的完整结果一致,回退规则只有一个维护点。本次只完成有真实调用者的 transport 去重,不迁移全部消费者、不安装 Host、不授予执行权,也不证明 C1/C2 或长程收益。

改动思路 / Approach

尺寸回退属于现有 transport 的失败恢复策略,放回 effect_runtime 比保留两个调用方副本更直接;TypeScript 决策和各调用方的参数适配仍留在原 owner。当前 PR 仅合并 producer/controller 的尺寸回退,并把五个测试文件的观察接缝指向 transport。已从实际入口核对正向与拒绝路径;原有配置、决策与持久化权责继续由既有 owner 承担。一个具体恢复策略只留一个实现,不把通用 RPC 全部改成自动重试。

具体改动 / Changes

审查 head 4fa61cc7b0e584665b859e2a801af076f37471c8,branch merge base 0e78a19c277f4ca3d44313787162bc0444065172。### 关键代码讲解

  1. effect_runtime_projection_result 先走原 inline 调用,只捕获 EffectRuntimeRejected 且诊断精确等于 request_too_large 的分支,再交原有 bounded snapshot transport。没有广义重试、截断或吞掉语义错误。
  2. _turn_envelope_result 仍保留 source number 的精确拼写适配和 Mapping 校验,只移除本地重复 catch;最终完整 envelope 不变。
  3. _controller_result 同样保留 facts、历史 route 适配与 TypeScript 决策边界。错误签名依旧拒绝,writes_state/spends_quota/launches_host 不因 transport helper 改变。

实际生产为 +17/-19,五个测试文件仅调整观察接缝(+10/-11);没有新增状态、版本或 CLI。规格 docs/architecture/rfcs/controller-executor-unified-contract-v0.md 固定于 0e78a19c277f4ca3d44313787162bc0444065172:Lossless context delivery 与 Shared production paths 在此有限切片已实现;Outcome and cost benefit 属于父级资格,不在本次维护请求范围,未把一次去重当成全路线完成。

对主干的风险 / Risks

PASS:base/head 各331项、零跳过,其中7项使用真实 native Codex0.166.0-alpha.5.1 和静态 loopback provider,无外部模型调用。独立七组完整输入/输出/异常逐字节一致,未归一化;移除两处 caller 的回退绑定会分别触发 request_too_large,恢复后通过。64MiB 预发送拒绝、私有文件/方法/digest 防护和 ambiguous response 不重放另有真实 integration 覆盖。

PASS:Ruff、DCO、diff/public hygiene、6项直接 premerge gate 与12项选中检查。FAIL(独立归因、非阻塞):另1项 full-tree maintainability 扫描在 base/head 都报未改动的 run_host_process 91 statements 超过90;49 decision points 仍低于60。已比对完整 JSON 失败身份、细节、阈值及未改的 scanner/函数源码,不只采用 premerge 的按路径自动解释。直接 gate 的 module-ceiling 检查通过不等于这条扫描通过。原始失败保留,未改阈值;维护性 owner 后续处理该独立债务。归档目录缺少 Git 元数据的探针不能构成相同扫描负载,其零结果已排除,不据此宣称基线通过。

当前主干仍未包含这次 helper 合并。更大的 settlement adapter 收敛与安装版 Host 不属于此小切片,未执行;没有改动 authority store,不以无关 PostgreSQL 测试补计数。未查询或等待远端 CI。

我的整体评价 / Verdict

APPROVE:有实际调用者的 transport 去重已完成,机制与维护收益相称;较大相邻重构无需并入。long_horizon 判为 preserved,依据是完整来源、停止/签名/一次性语义和有限 native 读取验证,不是长期效果或成本实验。user_experience 判为 preserved。检查两个真实 projection 入口和 native Codex 的静态 loopback 输入路径,未改变页面、提示、配置步骤或人工确认轮次。安装版 App/Host 视觉与真实模型采用未验证;本次无渲染内容改动。基线维护性失败仍是失败,CI、审批就绪与合并权限分别判断。

English verdict: APPROVE 4fa61cc; shared projection fallback preserves verified complete transport behavior. An independently matched baseline maintainability failure remains advisory; CI was not consulted.

@huangruiteng
huangruiteng merged commit cb27182 into main Nov 2, 2026
34 of 45 checks passed
@huangruiteng
huangruiteng deleted the codex/projection-snapshot-transport-20261101 branch November 2, 2026 03:30
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