Skip to content

fix(turn): bind capability context to the admitted source - #8373

Merged
loopx-agent merged 5 commits into
mainfrom
codex/complete-turn-capability-source-binding
Nov 8, 2026
Merged

loopx-agent merged 5 commits into
mainfrom
codex/complete-turn-capability-source-binding

Conversation

@loopx-agent

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

Copy link
Copy Markdown
Collaborator

Current validation at e71a31c67af2

This head integrates main@520a1ab4735dbb640d54e31a799fcaadb4338c38, including the Windows UTF-8 delegation fixture from #8360. The final main sync preserves the authored diff byte for byte.

The authored product and test patch is byte-identical to the preceding head. The new base supplies the UTF-8 fixture used by the previously failing Windows delegation checks. On the integrated source, 82 complete Host and Session cases passed, including original-source recovery and replay. All six previously failing revalidation cases passed locally, and both provider variants of the deliberately non-UTF-8 pipe fixture passed.

Configured Ruff, control-plane typecheck and standard premerge passed. The 6 direct and 14 selected checks passed. The previous wheel evidence covers the unchanged authored product patch. The new head still requires its own remote CI and independent review.

Previous CI checkpoint

Current head ea032a9d5179a385cc868d19b6bdca186a0fbafa. This commit registers the existing capability context module in the canonical digest consumer inventory. Full local Ruff and 40 TypeScript inventory/capability checks passed. Standard premerge passed 6 direct and 14 selected checks with aggregate status passed. The previous wheel run still applies to the unchanged product files. This head changes only tests.

The prior main-slice Windows job failed in six delegation revalidation fixtures. The separate UTF-8 fixture change passed its Windows job. It still needs conflict resolution and exact-head qualification before it can land. Remote CI and independent review remain open. Windows failure · UTF-8 fixture PR #8365

Goal And Delivered Outcome

Optional capability guidance reaches the Host only when it belongs to the admitted complete Turn. On both File and SQLite, the baseline retained old guidance after a valid change to the selected Todo's required capabilities. It also reused guidance across Turn keys. The new binding checks the complete content hash and Turn key and keeps the contribution when only the capture address is added.

An interrupted Turn also had a mixed-input retry. The session resolver could see the refreshed source while the Host received the original source with refreshed guidance. Both now use the original journaled plan. Already validated journal results retain their bounded legacy result fields, and new Host calls require a complete binding for optional guidance.

The initial validation used main@aee77700812dd60e75375e8b329e552493da8069. This independently reversible slice is also integrated into the C1 author branch. C1 #8266

Author Declaration

Written by model_agent, GPT-6 (OpenAI). Implemented against the Turn consumer and original-recovery clauses of the controller/executor contract.

Criterion Disposition Owning boundary Decisive check
One verified original source for capability context implemented Complete Host source and capability context binding Same source and location-only positive, source capability/stop and Turn key negatives
Original readback and once-only effects implemented Journal recovery and result validation Current failed-session retry, historical result settlement and replay
Original-quota model adoption and cost deferred Parent C1 program Matched single-session outcome and total-cost qualification

Validation

Tested revision 7e2d590aa65fd003dad2d99e9059dfff0e2691f3. Local run finished using synthetic public fixtures.

Check kind Result Evidence
regression_parity passed Before the fix, four File/SQLite cases accepted stale advice for changed capabilities or another Turn. A separate retry repro failed on both providers because refreshed advice accompanied the original decision. All corresponding negatives pass after the fix.
real_entrypoint passed 21 passed at 7e2d590 on File/SQLite. 6 wheel product files matched Git, 1175 loaded product modules and 8 CLI calls pinned to wheel. The covered paths include complete Host input, original captures, old typed results, corrupted or mixed inputs and once-only recovery.
static passed Control-plane tsc, configured mypy, changed-path Ruff and 23 TypeScript capability tests.
integration passed Standard diff premerge passed all 6 direct and 14 selected checks. An intermediate revision exceeded the executor structure budget. The final revision passes the original thresholds.
manual not_run Independent review and full remote CI pending. Real model adoption and original-quota net cost remain open in C1.

Frontend / Visual Evidence

UI impact none.

Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
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

Request changes conclusion (author-owned PR; GitHub blocks formal self-review)

评审提交 ea032a9,基线 aee7770。

动机 / Motivation

管理型 Turn 的可选 capability guidance 应跟随已准入的完整来源。同一 Goal、Agent、Todo 的 required capabilities 可以变化,旧 action projection 在这种情况下仍可能相同。File 和 SQLite 对照中,base 会把旧建议带入换了 capabilities 或 Turn key 的 Host request。当前提交拒绝这两种旧建议,同时保留原计划和只增加 capture 地址的正向路径。

这里沿用 Controller/Executor 的原始来源和原 Session 契约。当前提交修复了新 Host 调用的绑定,缓存结果继续校验时仍有一个可复现的跨来源缺口。 Controller/Executor contract

改动思路 / Approach

TypeScript 验证完整来源、source hash 和 Turn key,再以后二者给 context contribution 绑定。读取地址留在 transport 层。已验证的旧 journal 结果可以按旧投影恢复受限 result fields,旧建议本身不会进入新的 Host 调用。普通 quota、v0 decoder 和空贡献路径保留各自边界。新 Host 重试从 journal 恢复原计划,再查 Session 并发布原捕获。当前设计复用完整来源 validator、旧结果 decoder 和原 journal。评审边界为可选 Host 上下文与同 Turn 恢复。

具体改动 / Changes

完整差异是 10 个文件、+321/-53。生产源码 5 路径 +125/-50,双语 RFC 2 路径 +17,测试 3 路径 +179/-3。验证从当前 main 的共同祖先开始。实现复用原完整决策 validator、capability projection 和 journal,无额外状态写入者。最新一笔改动只把现有 context projector 纳入 canonical digest 的测试清单。规范条目 changed-work-path 的新 Host 绑定已验证,cached-postcondition-fidelity 的缓存校验缺口见下。

关键代码讲解

  • _turn_context_binding_source 将当前完整计划交给 host_context_binding。正向对照验证 capture 地址可以新增,独立反例验证更换 Turn 或更改 capabilities 后旧 contribution 消失,原工作契约和精确大整数仍随请求交付。 Python adapter, TypeScript binding
  • projectTurnContextContribution 对已记录结果提供受限旧 schema 的精确匹配,历史 fallback 清掉 context fields 和 instructions。 _host_result_stage 验证缓存结果时读取 journal 中的原计划。 Capability projector, Result stage

对主干的风险 / Risks

P2 缓存结果可沿更宽松的新计划通过任务校验

_host_attempt_requirements 在 journal 已有 typed result、只需重试独立 task postcondition 时不返回原计划。结果 schema 仍由原计划校验,随后 _task_validation_stage 却收到调用者的新计划。真实 File/SQLite CLI 产生的原始决策上,独立夹具使用同一 Turn key。首次 Host 结果携带可选字段,原 postcondition 拒绝它。去掉新计划的一项 required capability 后,同样的缓存结果在当前提交上走新 postcondition,提交一次 writeback、spend 各一次。Host 调用总数仍为一次,原 capture 字节未变。base 在可选字段校验处拒绝,同一夹具无后续 effect。沿原计划恢复的健康对照两版都只结算一次。

将已存在 journal 的计划统一传给结果、任务校验和结算阶段,同时保持 needs_host 独立决定是否重新调用 Host。补一个缓存结果及原 postcondition 已拒绝、同 Turn 传入较宽松计划的回归用例。带 --resume-turn-key 的 CLI 已显式加载原计划,反例覆盖执行器接收同 Turn 当前计划的路径。 Recorded plan selection, Task validation

语义与 CI 对齐

187 项定向 Python 回归通过,涉及的产品和 Python 测试文件在换头后逐个保持相同。当前提交的 57 项 TypeScript 检查及标准 premerge 的 6 项直接、14 项选中检查通过。File/SQLite 的独立 binding 和原计划恢复四项对照通过,缓存结果混用的两个反例仍失败。证据限于本地源码、真实 provider 和合成 Host/validator,远端 CI、已安装宿主和真实模型的结果未纳入。

我的整体评价 / Verdict

可选上下文的新绑定有直接价值。收敛缓存结果后的 plan 来源,再用同一组负例核验原校验和一次性结算。现有的完整来源和 journal 是合适的归属,修复范围可以留在执行器内部。

English verdict: REQUEST_CHANGES. Use the original Turn plan through cached-result validation and settlement.

Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
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 / OpenAI / gpt-6.1-sol / max / runtime_reported

动机 / Motivation

当前复审 head c643d625cd5b20c0e09353f704d2d4af6204aeb6,实际基线 520a1ab4735dbb640d54e31a799fcaadb4338c38。上轮 P2 指出 Host 结果虽按原计划解码,验收仍可能拿到新调用者的计划。

受影响的是调用完整 Turn 的 Host,以及在已记录 Host 结果之后恢复同一 Turn 的维护者。 同一个 Turn 已经留下 Host 结果,下一次传入的 capability 可选字段变了。修复前恢复可能按新字段跳过旧验收条件,修复后结果解释、验收与结算都读取原计划。 File 和 SQLite 上,验收仍能读到原字段并拒绝不合格结果,恢复不会再次调用 Host。 本次交付覆盖完整 Turn 的绑定与重放;双会话调度和模型产出收益另行验收。

按 docs/architecture/rfcs/controller-executor-unified-contract-v0.md 在 520a1ab4735dbb640d54e31a799fcaadb4338c38 的契约核对 C1、original-Turn-recovery。

改动思路 / Approach

完整源的身份校验留在现有 TypeScript owner,原计划选择留在已有执行日志。 这次把完整 Turn 从 Host 入参、缓存结果到验收结算接通。 已入日志的旧结果可以恢复当时的可选字段,历史建议不回到新的 Host 输入。

具体改动 / Changes

10 个文件(+350/−53)。改动集中在完整源身份校验、capability 上下文、执行日志恢复、配套测试和双语契约。

关键代码讲解

  • requireCompleteHostHeader 校验完整请求、源摘要与捕获身份。复用同一个校验器给 Host 与上下文绑定。不匹配时拒绝请求。
  • projectTurnContextContribution 核对贡献的 basis。允许历史日志仅恢复原结果字段。过期建议丢弃。
  • _host_attempt_requirements 分别决定 Host 调用和采用的原计划。已有 typed result 时也保留原完整计划。失败仍按原 postcondition 处理。

对主干的风险 / Risks

兼容风险在已有日志的可选字段。按旧 basis 只恢复原字段,新的建议仍须匹配完整源。File 和 SQLite 对照使用真实本地 authority 与合成 Host 结果,模型与双会话效果留待单独验证。

语义与 CI 对齐

源绑定复用现有摘要和版本化身份。是否需要 Host 与选择原计划分别判断。 140 个 Python 回归与 40 个 TypeScript 检查通过,premerge 的 6 个直接检查及 14 个选中检查通过。旧 head 的两例负向用例都复现了错误提交。 按本 Goal 的 wait_for_ci=false 使用本地验证。

我的整体评价 / Verdict

Approval conclusion (author-owned PR; GitHub blocks formal self-approval) APPROVE。 此前 P2 已由两种后端的原 Turn 回归覆盖。这个 head 可以进入合并门禁。

English verdict: APPROVE - head c643d625cd5b20c0e09353f704d2d4af6204aeb6 binds complete Host context and cached validation/settlement to the same recorded source. Matched File/SQLite regressions and local premerge passed.

@loopx-agent
loopx-agent merged commit 5093f48 into main Nov 8, 2026
25 of 32 checks passed
@loopx-agent
loopx-agent deleted the codex/complete-turn-capability-source-binding branch November 8, 2026 18:01
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.

1 participant