Skip to content

fix(turn): preserve Todo context across repair and replan results - #6940

Merged
huangruiteng merged 1 commit into
mainfrom
codex/turn-replan-writeback-20261020
Oct 20, 2026
Merged

huangruiteng merged 1 commit into
mainfrom
codex/turn-replan-writeback-20261020

Conversation

@loopx-agent

Copy link
Copy Markdown
Collaborator

Goal And Delivered Outcome

A repair/replan Host result could overwrite the selected Todo's notes and evidence before refresh-state rejected its missing semantic delta. The rejection left the original task context erased, despite no accepted result or quota spend.

Remove that implicit Todo write and its unused adapter. Full diagnostics stay in the journal's typed host_result for accepted results, refusal and cached recovery. Keep the selected-Todo guard and existing explicit update/completion authority.

  • Basis: reproduced data-integrity defect in turn run-once; intended base: main at 1388ddb8d3409971a72dff5f9891832f7769c1d2.
  • Observable result: existing Task context survives refusal/retry and accepted replan; the next Turn can consume the validated plan and complete its independently checked step.

Author Declaration

  • Written by: model_agent — OpenAI Codex, GPT-6 family.
  • Specification: existing native Host journal/recovery contract in docs/reference/protocols/turn-envelope-v0.md at the base above; the reproduced preservation invariant described here is the repair requirement.
Criterion Disposition Owning path Evidence
Refused repair/replan preserves existing Todo context implemented loopx/cli_commands/turn_run_once.py Four File/SQLite result-kind regressions fail before the fix and pass after it.
Diagnostics survive cached recovery implemented Existing journal host_result Summary/follow-up retained; recovery invokes no second Host and spends no quota.
Valid replan supports subsequent work and exact replay implemented Existing refresh/settlement owner Two backend cases validate a plan, execute it in the next Turn, check the result independently and spend once per Turn.
Explicit lifecycle retains its authority/root fences implemented turn_todo_writeback.py and Todo owner Existing completion fence and explicit-update split-root regression pass.
  • Self-check: reviewed all six changed files, retained the selected-Todo check, removed the redundant writer and preserved the unique authority-fence coverage. No additional abstraction or review repair pass.

Scope And Continuation

Author implementation is complete within this scope. Required remote CI and maintainer review remain; this proposal has not been merged or installed. The patch changes CLI persistence, with no new configuration, capability or authority owner.

Validation

  • Tested revision: ced7181df5dcfc27b0f455b354e497e31f16dcbd.
  • Run state: finished locally; remote CI pending.
  • Input classes: synthetic, public_fixture.
Check kind Result Evidence / limitation
real_entrypoint / real_backend passed Native CLI against isolated File authority v0 / SQLite 3.53.4 stores (Node 24.21.0): refusal, cached recovery, accepted replan, subsequent work and exact replay. Explicit protocol-only DSH runner and independent command validator; no live model.
regression_parity passed All four refusal-preservation cases fail on the base's implicit writer and pass on the fix. Ordinary progress/repair/replan and explicit completion paths retain their existing settlement behavior.
unit / integration passed 129 focused Turn/fence tests; 197 executor/DSH tests (six overlap); 33 optional-memory isolation tests; four final entry/fence checks.
real_entrypoint passed Six cases pass outside the checkout with a fresh non-editable wheel. All 1680 packaged Python/TypeScript payloads match source and installation. Initial harness collection omitted a public fixture helper; retained that failure and added the helper without changing production payloads.
static passed Full declared Ruff roots plus changed CLI files, configured mypy (17 files), CLI output budget, whitespace/RFC checks and six-path public scan.
integration passed Native premerge: six direct checks and 19 selected checks, zero failures/warnings/manual holds. Exact-scope CQR cqr_de419a602e505aa24aa2 is valid/pass; safe-fix passes used: zero.
integration not_run Required GitHub CI and independent PR review remain pending at submission. Full platform/Node/pytest CI qualification is not claimed from the local targeted runs.

Coverage follows the shared result callback, both affected kinds, real persistence, immutable diagnostics and effect recovery. No performance, installed App or live-model benefit claim. Shared-authority provider code, routing and compatibility projections are unchanged; this is not an authority promotion or migration qualification.

Frontend / Visual Evidence

  • UI impact: none. Existing Task context is preserved; no rendered UI source or interaction changes.
  • Before/after, viewport/preview, source data, attention/craft review: N/A for this CLI persistence repair.

Type of Change

  • Bug fix
  • Documentation update
  • Test update

LoopX Area

  • Control plane (goals, todos, quota, scheduler, registry, runtime)
  • Host or runtime integration

Technical Direction

Core control-plane hardening: bounded result-writeback data integrity repair. No new RFC milestone or broader convergence claim.

Shared-authority RFC fixture impact

N/A: no provider, promotion, runtime-routing or compatibility-projection change. Real File/SQLite consumer checks are disclosed above.

Boundary Checklist

  • Diff, body and evidence contain no private state, credentials, raw traces, internal links or local paths.
  • No duplicated maintainer benchmark work.
  • Scoped to the reproduced defect.
  • No paired RFC changed; staged and committed bilingual checks pass.
  • UI impact is none.
  • Commit includes DCO sign-off.

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)

结论:APPROVE。未发现阻断问题;这是作者自行复核后的 COMMENTED 结论,不是独立第三方批准,也不代表允许合并或已安装。

动机

使用原生 Turn 命令执行任务的用户和 Agent 会遇到这个问题。当 Host 返回缺少必要重规划证据的修复结果时,旧路径先覆盖原任务备注与证据,再报告拒绝;新路径拒绝时保留原任务上下文。已在真实 File/SQLite 入口验证拒绝、缓存恢复、合法重规划和下一轮实际消费计划,且每个成功 Turn 仅扣一次额度。本提案不新增执行器、配置或权限,不认证真实模型效果、安装态采用或整体收敛性能。

改动思路

诊断已有 journal 的真实生产写入方,删除重复 Todo 写入即可修复丢失;无需增加事务层或第二套权限。只修复原生 Turn 结果写回的上下文完整性,保留现有重规划、结算和显式 Todo 生命周期 owner。旧实现把 Host 的摘要当作隐式编辑任务的意图,随后才检查是否接受结果。仅把旧写入挪到验证之后,仍会覆盖已有备注,并增加一次需要恢复的状态变更;直接复用既有日志更简单。完整诊断在独立校验和结算前已经持久化,后续重试读取同一日志。既有选择任务守卫、当前权限校验和显式完成操作继续保留。正常路径无需用户增加设置、复制信息或确认轮次。

触发 旧路径 此 head 的结果
缺必要重规划证据 先覆盖任务,再拒绝 保留任务、拒绝、零扣额
合法重规划 隐式覆盖任务备注 日志保留诊断,任务上下文完整
原日志重放 既有回执恢复 保留该机制,不重复 Host 或扣额

具体改动

规范依据是变更前的 docs/reference/protocols/turn-envelope-v0.md,spec_revision 1388ddb8d3409971a72dff5f9891832f7769c1d2,主要读取 Native Turn Host capture 和既有结算段落。本次新增的六行是行为披露,不能反过来作为实现正确性的独立依据。判别性输入还来自旧版本真实覆盖任务备注的回归。

  • journal-owner:implemented。日志拥有原生 Turn 身份;既有结果生产者在结算前持久化完整结果,删除冗余 Todo 写入。
  • cached-recovery:implemented。缓存结果恢复保留原回执,无需重新启动 Host;拒绝重试计数仍为 1,已提交重放所有 effects 均为 false。
  • current-authority:implemented。保留当前准入、选中 Todo、workspace/runtime root 与显式生命周期 owner;独立来源或已缓存观察没有获得新权限。

关键代码讲解

  1. execute_turn_run_once.writeback 仍先校验 durable-writeback 的 effect 引用,并对 repair/replan 要求选中 Todo,再调用原 refresh_state_run。改变是移除在它之前的 note/evidence 替换;推荐动作、原身份、工作区和后续回执路径保持。
  2. _host_result_stage 是既有完整诊断的生产者:标准化结果写入 host_result 并保存日志。已有 typed-result 阶段时复用原结果,所以删除 Todo 写入不会丢失摘要或 follow-up,也不需要再造诊断存储。
  3. write_turn_validated_completion 仍转交 complete_goal_todo,完整传递 runtime override、身份和工作区。删除的是唯一调用的隐式修复适配器。对应 split-root 测试移到实际的显式 update owner,保留其拒绝和原状态保护断言。

新增回归文件用真实 File/SQLite authority、原生 run-once、子进程协议 Host 和独立工件验证器,分别验证四个拒绝场景及两个合法计划后续执行场景。既有 driver 测试仍检查自适应选中 Todo 与工作区传递,只把旧的隐式写入断言换为完整日志和任务保留断言。协议文档明确连成功 repair/replan 也不隐式替换备注,避免静默默认改变。

对主干的风险

最强反例是删写入后诊断丢失、成功修复无法继续,或恢复再次调用 Host/扣额。此次从原生入口分别读回完整任务、原始状态字节、日志和计数,覆盖这些风险。本轮在精确 head 新跑 17 项全部通过;保留 base 的四个 note/evidence 失败,没有把历史失败改写成通过。先前相同源码的 197 项 executor/DSH、33 项可选记忆隔离、非 editable wheel 六例和全部 1680 个代码载荷一致性仍适用,复用前逐一核对六个变更文件哈希。额外在隔离进程中加载两处不可变 base 生产模块并运行原测试,三个正常结果分支通过;已核对其他生产文件与 base 相同。首次比较脚本缺父包属性注册,在 Host 调用前失败;修正导入装配后通过,保留原失败。premerge 的六项直接检查、19 项选中检查以及有效 CQR、静态/预算/公开边界检查保留原证据。

这次没有 default-off 功能声明:上下文完整性修复适用于所有既有原生 Host;可选记忆开关、提示和 schema 均不变。摘要是诊断,语义校验和显式 Todo 操作仍是机器约束。当前 main 已推进且六个改动路径没有重叠,但这里没有声称完成新 main 的合并资格;后续合并仍需对应 owner 的当前门禁。依本次评审配置的 wait_for_ci=false,本轮未查询、轮询或等待远端 CI。

语义与 CI 对齐

复用既有词汇和 journal/settlement owner,没有新增协议枚举、开关或权限。对 accepted repair/replan 的备注保留属于明确披露的 intentional_change_validated;拒绝原因、当前校验和显式生命周期语义保留。没有把预算测试或签名相等当成语义证明,也没有把协议 Host 当真实模型。原 wheel 夹具首次缺公共 helper 的收集失败和后续修正分别保留;没有修改生产载荷来消除该失败。

我的整体评价

long_horizon 为 improved:任务上下文在失败、恢复和后续工作间保全,且验证了两次实际工件步骤与恰好一次效果;这不等于证明长程模型收益。user_experience 为 improved:原任务读回可靠,零新增必要交互轮次,详细诊断仍从既有日志获取。改动规模与真实数据完整性问题相称,删除已有重复写入就是此处最有价值的局部简化;无需引入新事务或迁移框架。诊断已有 journal 的真实生产写入方,删除重复 Todo 写入即可修复丢失;无需增加事务层或第二套权限。只修复原生 Turn 结果写回的上下文完整性,保留现有重规划、结算和显式 Todo 生命周期 owner。此审查只判断 ced7181df5dcfc27b0f455b354e497e31f16dcbd 的有界修复;独立评审、实际安装采用、模型与全成本验收以及最终合并授权均不由这条自审结论替代。

English verdict: APPROVE — head ced7181df5dcfc27b0f455b354e497e31f16dcbd. Native File/SQLite refusals preserve Todo context and full journal diagnostics; accepted replan, subsequent validated work and exact replay pass. Fresh 17-case review validation and immutable-source local/wheel evidence support this scoped fix. Author-owned COMMENTED self-review; CI not consulted, no merge or installed-adoption claim.

@huangruiteng
huangruiteng merged commit 5820d46 into main Oct 20, 2026
30 of 41 checks passed
@huangruiteng
huangruiteng deleted the codex/turn-replan-writeback-20261020 branch October 20, 2026 12:02
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