Skip to content

perf(turn): persist the initial reservation in one checkpoint - #7944

Merged
huangruiteng merged 1 commit into
mainfrom
codex/turn-start-checkpoint-20261102T230539Z
Nov 3, 2026
Merged

huangruiteng merged 1 commit into
mainfrom
codex/turn-start-checkpoint-20261102T230539Z

Conversation

@huangruiteng

Copy link
Copy Markdown
Collaborator

A fresh managed Turn currently persists the full initial journal, then immediately persists it again to attach its already accepted cadence reservation. Build that complete initial snapshot before its single write, while retaining the separate durable Host-attempt checkpoint and subsequent confirmation.

The existing journal and cadence owners keep their authority. Unconfigured starts, saved-result replay, reserved-attempt recovery and unknown Host outcomes retain their existing paths. This is an independent, main-based slice of #7430; its integrated candidate is 410080edcb665fa45320aadf416d3f1c0f64694c.

Validation at 622637ea8303905e9fc5024975b7f373be13ac1d against main 107e9e32e8f3df29f63b94524250f4044cc01a80:

  • Four complete modules: 268 passed. The integrated C1 candidate passes 369 across the same modules.
  • Twelve real CLI cases cover File/SQLite, interruption before/after the initial checkpoint, durable attempt and confirmation, original interval/identity, changed-source refusal, replay and no duplicate Host or settlement. The original main and C1 functions pass this same recovery matrix. Removing the durable-attempt checkpoint makes both File/SQLite sensitivity cases fail.
  • Eight matched pairs use identical source/plan inputs and unmodified owners. Fresh reservations remove exactly one turn_journal.write; the four unconfigured controls have identical RPC counts and bytes. Namespace-normalized Host inputs and final journals match; terminal replay starts no Host and does not rewrite the journal.

Observed warm JSON-RPC wire bytes, including request/response framing and newlines:

Source fixture Capture RPCs Before After Saved
File inline 6 → 5 70,719 53,948 16,771
SQLite inline 6 → 5 70,819 54,023 16,796
File file 7 → 6 121,392 103,945 17,447
SQLite file 7 → 6 121,573 104,100 17,473

The controlled comparison freezes the original run_loopx_turn_once function and observes the same real owner calls; its synthetic Host stops after input observation. These figures qualify the startup RPC component. Packet-body reduction, model fees and accepted long-horizon outcomes remain separate measurements.

Ruff, DCO, whitespace, semantic advisory and public-boundary scan pass. Quick premerge passes six direct and three selected checks, with the unchanged machine_section_projection maintainability failure retained as an inherited advisory and reproduced on the clean baseline. The changed executor remains at 90 statements and 58 decision points under the existing 90/60 limits. The cadence test reuses #7430's same-capture reader correction while preserving its 1440-minute floor and rejection assertions.

The bounded refactor is the cohesive initial-checkpoint write gate in the existing executor. Journal schema, cadence policy, attempt durability and confirmation ordering stay with their existing owners. The full C1 acceptance, original input budgets, independent review and maintainer merge decision remain open.

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

@huangruiteng huangruiteng 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 | model=gpt-6.1-sol | provider=OpenAI | runtime_reported | reasoning_effort=max

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

未发现当前完整提案的阻塞缺陷。

动机 / Motivation

运行受管理 Turn 的 CLI Agent 与维护者。 原路径先保存缺少 cadence reservation 的初始日志,再立即重写;新路径一次保存完整初始快照。 真实 File/SQLite CLI 对照确认已配置启动少一次 journal 写入,未配置路径和终态重放的写入次数不变。 不改变额度准入、Host 启动确认、持久化格式或默认配置,也不认证模型费用与长期任务收益。 完整端到端延迟、真实模型采用和长期效果仍需在冻结实验中衡量。

改动思路 / Approach

复用现有 executor、cadence 和 TypeScript journal owner;只合并尚未派发 Host 的初始快照,独立 attempt checkpoint 保留。 当前 PR 仅收敛初始日志写入,不新增状态、策略或 CLI。 这是对现有写入顺序的有界简化:先接受原 cadence reservation,生成完整初始快照;随后仍单独保存 attempt,再确认启动并调用 Host。额度、日志和恢复决策继续由原 owner 负责,不增加缓存或另写一套恢复规则。

具体改动 / Changes

完整审查 622637ea8303905e9fc5024975b7f373be13ac1d 相对 107e9e32e8f3df29f63b94524250f4044cc01a80 的三文件、+178/-11;其中产品 executor 18 行变动,其余是恢复测试和同一捕获的 scheduler 读取适配。spec_ref=docs/reference/protocols/loopx-turn-v0.md,spec_revision=107e9e32e8f3df29f63b94524250f4044cc01a80。逐项映射:journal-attempt-before-confirmation implemented;unknown-host-outcome-stops-reinvocation implemented;saved-terminal-result-replay implemented。

关键代码讲解

  • run_loopx_turn_once 保留原日志锁、恢复评估与准入。仅在新建日志或已获 reservation 时进入初始写入门,把现有 admission 放入快照后一次持久化。恢复、失败重试和 saved-result settlement 继续走原分支。
  • _host_result_stage 的 attempt 增量与持久化仍在 confirmation 和 Host 之前。不能把此写入一起折掉;否则失去返回的 Host 可能被再次执行。测试保留原 deadline、身份、捕获内容及 unknown-outcome 拒绝,不把未知效果写成没有发生。

对主干的风险 / Risks

独立运行两个完整改动模块 164 PASS;把同一新恢复契约放到不可变基线运行,六个断点、两个真实 File/SQLite 后端 12 PASS。沿公开 CLI 的四组对照中,已配置场景的写入 4→3,未配置场景 3→3;终态重放均新增零写入、总共仅一次 Host。这里的 Host 是读取输入后返回失败的真实子进程,不能据此认证模型费用、完整 wire bytes 或任务效果。

另在私有内存中只移除独立 attempt checkpoint,两种后端均按预期失败,确认测试会抓住最危险的过度合并。首次 quick premerge 因审查环境缺少 npm TypeScript 依赖失败;安装依赖后 6 direct /3 selected PASS、0 blocking failures,原始失败保留。语义扫描在干净基线也通过,已有 maintainability advisory 保留;未查询或等待 CI。

语义与 CI 对齐

复用既有 vocabulary、日志 schema 与默认策略,未增加状态 owner、权限或自动重试。已配置启动的初始快照时序是公开披露的有意变化;未配置路径、unknown-outcome refusal 与 replay 均有真实 CLI 反例和读回。合并资格与维护者授权仍是独立边界。

我的整体评价 / Verdict

APPROVE。 这是 justified_increment:交付可验证的启动写入减少,long_horizon 和 user_experience 的现有恢复语义保持。复用现有 executor、cadence 和 TypeScript journal owner;只合并尚未派发 Host 的初始快照,独立 attempt checkpoint 保留。 当前 PR 仅收敛初始日志写入,不新增状态、策略或 CLI。 检查 executor 与现有 CLI 路径,没有渲染页面或首屏数据变化。 安装后的宿主与模型任务收益未验证;此改动不需要 UI 截图。 不把局部写入数量提升成端到端性能收益;后续集成仍须验证实际原生执行和持续任务结果。

English verdict: APPROVE — exact head 622637ea8303905e9fc5024975b7f373be13ac1d removes one redundant initial reservation checkpoint while retaining durable Host-attempt ordering, unknown-outcome refusal and terminal replay. Actual model and end-to-end cost benefits remain unverified.

@huangruiteng
huangruiteng merged commit bcf8f90 into main Nov 3, 2026
31 of 42 checks passed
@huangruiteng
huangruiteng deleted the codex/turn-start-checkpoint-20261102T230539Z branch November 3, 2026 04:49
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