Skip to content

Admit managed Codex preparation before claiming work - #8669

Merged
cocolord merged 1 commit into
mainfrom
codex/rfc-r1-managed-start-20261113t025250
Nov 13, 2026
Merged

cocolord merged 1 commit into
mainfrom
codex/rfc-r1-managed-start-20261113t025250

Conversation

@cocolord

@cocolord cocolord commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

A minimal builtin Codex caller could receive an eligible next task but still stop before the Host because it did not consume the advertised ordinary managed claim. This change prepares that exact task automatically after validating the existing Host arguments and obtaining start admission, then rereads the same Todo and requires ready before execution.

The existing Turn binding lock now encloses the optional preparation admission callback. Preparation and execution reuse the same settlement identity for unstarted cadence recovery; historical transaction-key reservations remain recoverable without bypassing a started request. The existing spend precheck rejects another claim for a settled Turn, and canonical claim receipts preserve confirmed or unknown state effects through a later Host failure. No new persisted schema, decision owner, provider default, CLI option or permission is added.

内置 Codex 原先无法直接消费下一项任务的普通领取准备。本批先校验参数、通过现有调度准入,再执行精确普通 claim 并重读同一 Todo ready;启动准入位于既有 Turn binding lock 内。ACK 丢失后复用原未启动预约,已结算 Turn 拒绝重新领取,后续 Host 失败也保留真实领取效果。

Validation at b891500:

  • Source regression: 395 passed, 1 native Windows-only skip across the Turn, Codex and preparation suites.
  • Independent final core wheel on Python 3.11: 22 passed, using real isolated File/SQLite authority, synthetic Codex transport and an independent artifact validator. All 1885 packaged runtime sources match the reviewed source bytes.
  • Six paired public CLI cases at immutable main 167b0a1 and this head preserve plan, preview, prepared execution and original-key replay on both backends.
  • Receipt/quota owner regression: 106 passed, 1 platform skip. Standard premerge passed, including bilingual RFC, semantic vocabulary, compile and public boundary checks.
  • Independent malformed-input/wait oracles fail in six cases on the prior claim proposal; the concurrent binding/admission oracle fails in all four CLI/backend combinations on the earlier unlocked revision. The final unchanged head passes those invariants, lost-ACK recovery, settled-lease retry and unavailable-Host effect readback.

This is an executable-start prerequisite for the existing RFC, with a paired bilingual checkpoint and updated Codex quickstart. Actual model adoption, full R1/V1–V5/V10, progressive product control, default closure, paired complete costs and original-goal regression remain open. No model, package release or frozen budget is promoted. Local tests use synthetic Host responses; native Windows execution remains untested locally. Remote CI/readiness is recorded separately in the exact-head review.

本批不等于完整 R1:真实模型采用、原始目标回归、渐进控制与完整成本仍待验收;保留此前失败和冻结预算。

Latest CI readback: the full-scope Ruff job reports an unchanged F811 ordinary fixture redefinition in tests/test_lark_private_conversations.py:2816; the identical command produces the identical sole error at immutable main and this head. All changed Python files pass Ruff. The dependent CI qualifications were skipped/failed and are not claimed as passed. Independent changed-invariant validation above passed; the published exact-head review records the baseline comparison and separate readiness hold.

Preserve the existing typed ordinary claim and exact Turn binding while moving validator transport checks and start admission before preparation writes. Reuse the settlement identity for unstarted cadence recovery, retain historical transaction-key reservations, and qualify source and standalone-core rejection/recovery paths.

Co-authored-by: ChengLong GU <88359731+gcl-coder@users.noreply.github.com>
Signed-off-by: lusendong.6789 <lusendong.6789@bytedance.com>
Signed-off-by: lusendong.6789 <lusendong.6789@bytedance.com>
Co-authored-by: TRAE CLI <traecli@bytedance.com>
@cocolord
cocolord force-pushed the codex/rfc-r1-managed-start-20261113t025250 branch from 82e5cf6 to b891500 Compare November 13, 2026 04:42

@cocolord cocolord left a comment •

Copy link
Copy Markdown
Member 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; OpenAI; self_reported (runtime observation unavailable: session_not_bound)

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

动机 / Motivation

使用内置 Codex CLI 连续推进任务的调用方会遇到这个问题。 旧主干在下一项任务缺少 lease 时只返回不可执行,调用方必须另行领取;新路径在合法输入和调度准入后自动领取同一任务,再验证 ready 才启动。 这里的 lease 是既有的任务所有权凭据,缺少它时原主干会把下一项任务挡在模型调用之前。只重复同一个 run-once 不会形成成果,还会把准备工作交回使用者。

隔离 File/SQLite 与独立安装包验证了自动准备、失败回读和原 Turn 恢复,已准备任务与只读路径保留原行为。 本批不选择新模型或 provider、不发布安装包,也不宣称实际模型采用、完整 R1 或整个原始目标已验收。 一句目标到真实模型成果、initial/revised/compacted/lost-ACK 采用、渐进产品控制、默认闭包和配对完整成本仍需原 RFC 的后续验收。 本次没有用测试数或合入数代替原目标完成判断;它交付的是后续真实采用不可缺少、可独立回滚的启动安全前置。

改动思路 / Approach

保留这批机制:它们分别保护同一启动链的身份、调度和回读不变量,并复用现有 owner;只做领取桥接会留下已重现的并发与恢复缺陷。 当前 PR 的边界是现有 builtin Codex run-once 的可执行启动与原 Turn 恢复,不新增调度策略、持久化 schema 或第二个决策 owner。 TypeScript 继续拥有 readiness、普通领取、cadence 和结算规则,Python 只连接现有 CLI/Host transport 与 effect 回执。参数检查抽为同一个 helper;没有复制出另一套 validator,也没有新锁或新持久化 owner。

触发 原提案/主干问题 最终提交的处理
下一项合法任务缺 lease 主干需要额外手工领取 仅执行 typed 决策公布的精确普通 claim,再重读同一 Todo
validator 无效或正在等待 d434 在拒绝前写 lease/Turn 回执 先校验输入并取得真实 start admission,再准备
两个 Todo 竞争同一 Turn 82e5 可由败方占用胜方 interval 在既有 binding lock 内检查绑定、spend 与 cadence,再写回执
claim ACK 丢失、尚无 journal 换 request key 会把已预约的启动变成等待 准备和执行复用 settlement effect identity,恢复原未启动预约
原 Turn 已结算或后续 Host 不可用 再领取或错误报告没有状态写入 既有 spend precheck 拒绝再领取;保留 confirmed/unknown claim effects

上表根据 b891500 的源码解释控制流,执行证据来自下面的真实 CLI 测试。required 不变量是身份、准入顺序与可信回读;可配置 cadence 策略仍由原 TS owner 决定;ordinary claim 是 provider IO;effects 是回执投影。既有 receipt API 不传 callback 时保持原语义。对历史 transaction-key 只在新的 no-write interval wait 后查询同一个旧预约,已启动的 request 不能借此再启动。

具体改动 / Changes

评审规格是 docs/reference/protocols/loopx-turn-v0.md,不可变 spec_revision:167b0a1f3a3307c284b021ea9a09c7c0b5e5a11f;以变更前的合同为依据,没有把这次 RFC checkpoint 改写成独立验收。需求来源还包括 #8587 的后续 Todo 被挡住问题。各项映射如下:3. Route 已实现,等待和不允许交付时不启动;4. Prepare 已实现,精确身份与普通 claim 后重读 ready;6. Validate 保留独立 validator,Host exit zero 不充当成功;8. Spend and schedule 保留验证写回后单次扣额;recorded_effects 对确认与未知分别回读;In-flight Turn settlement 保留 Todo 可开放但已结算原 Turn 不再工作/扣额的边界。完整 R1 与模型采用不在这些已实现项中。

关键代码讲解

  1. handle_turn_command:只有 builtin codex-cli、run-once 和 --execute 同时成立时安装准备器。它提前复用 Host 参数校验与实际 cadence 准入,记录 ordinary claim mutation receipt,随后重新解析同一任务的决策并要求 ready。native callback、plan 和其它 Host 不接入这个自动准备分支。
  2. builtin_execution_preparation_claim:校验既有 schema、host_execution_allowed、精确 Goal/Agent/Todo/Turn 与广告的 argv,不能修剪身份后猜另一项任务。它调用现有 binding owner 后才运行普通 claim。stdout 是严格 UTF-8 协议数据,stderr 只是容错诊断;不确定 ACK 返回 nullable effects,不能声称 zero-write。
  3. ensure_turn_heartbeat_settlement_receipt:在原跨 runtime lock 下先拒绝 foreign binding,再调用新增的可选 callback,最后写回执。callback 执行既有 spend precheck 和 TS start admission,避免败方先占 cadence、另一绑定随后获胜。默认 None 没有新增决策或回执格式。
  4. managed_cadence_start:Codex preparation 与 execute 使用同一 settlement request prefix;其它 Host 保留旧 prefix。保留已持久化的历史 journal recovery,但不能覆盖 started request 拒绝规则。
  5. prepare_turn_host_arguments:从原 Host request helper 抽出现有 transport/validator 检查,给准备阶段复用。journal 的 Host-kind 一致性仍由原 wrapper 校验。error rendering 与 on_claim 回读使 claim 成功后 Host 失败也显示实际写入。

14 个文件中,7 个现有生产文件净增 326 行,4 个测试文件新增 1013 行,3 个文档新增 80 行。两份 RFC 同时更新,仅记录启动前置与未验收项;没有生成文件、私有状态或新增协议版本。

对主干的风险 / Risks

没有发现最终 head 的阻塞缺陷。最强反例是同一 Turn 的两个 CLI/Todo 竞争:简单自动领取成功并不能排除败方抢占启动预约。评审执行的同一个独立 oracle 在 82e5 的两种 CLI × File/SQLite 四项都失败,表现为胜方 minimum_interval_wait;最终提交用原 binding lock 内准入使胜方可执行、败方任务无 lease,并只发生一次 Host 调用。d434 的无效 validator/wait 六项反例在拒绝后仍读到 lease;最终同条件拒绝没有新增 lease、Turn event、journal 或 Host 调用。

真实 File/SQLite 还覆盖 claim ACK 在 journal 前丢失后恢复、原 lease 不变、一次执行/结算、已 settled Turn 的 lease 被释放后仍不重新领取,以及领取成功后 Host missing 的 confirmed write 回读。host_invoked 沿用既有 callback-attempt 语义,不能把 missing binary 当作物理进程或模型已启动。所有故障注入都在隔离 fixture 内。

验证 状态 范围
固定最终源码五个 suite PASS 395 passed,1 native Windows case skipped
独立 final core wheel PASS Python 3.11 上 22 passed,含 File/SQLite 和独立产物 validator
1885 runtime source byte readback PASS 与 final wheel 全部一致;SHA256 bd31e722499c12cc95ff750208ad65f4aecc116233be3989b0799e1d5dba38ac
主干/最终提交配对 CLI PASS 两 backend × plan、preview、已准备 execute/replay,6 对 fixture/observation 完全一致
既有 receipt/quota owner regression PASS 106 passed,1 platform skip
exact-head standard premerge PASS 4 direct、Python compile、10 catalog、8 risk checks、public boundary;含 paired RFC 与 whole-tree vocabulary
远端 CI 观察 FAIL / UNVERIFIED 已独立核实主干既有 Lark F811 导致 Python/Stage 2C 上游资格阻断;这些下游 suite skipped/failed,不记为通过。DCO、dependency、frontend build、real PostgreSQL、repo-health 已通过;其余 job 依当前 readiness。

语义与 CI 对齐

使用既有 execution_preparation_v0、SettlementIdentity、TS cadence 与 nullable effects 词汇,分类为 reuse_existing。diff advisory 的零候选仅是 triage;真正 whole-tree vocabulary、双语 RFC 与公共边界检查已通过。没有放宽任何冻结 budget,也不把之前的性能失败改标通过。Goal 的 change-quality policy 为 disabled,不能称为 receipt qualification pass。最新 CI 的 kernel-static-checks 在未改动的 tests/test_lark_private_conversations.py:2816 报 F811 ordinary 重定义。同一个 full-scope Ruff 命令在 spec_revision 主干与最终 head 上均返回同一唯一错误,完整错误签名 SHA256 4acb58514052cfbb6262b0459d086f547dd48d13101279af7862bde88fc048a5,而本批全部 11 个 Python 改动文件单独 Ruff 通过。CI 的 chat-bundle 要求 static success;其后 Stage 2C、checks、pytest 和 merge-gate 因 failed/skipped 上游拒绝。该文件、workflow 与 review gate 均未被本 PR 改动,因此这是 verified pre_existing_unrelated,保留原失败与下游未执行事实。此判断不会把全 CI 改标通过;admin 仅能依独立授权覆盖 readiness/policy hold,不能覆盖本批缺验证或新回归。

我的整体评价 / Verdict

这是 justified_increment,long_horizon 与 user_experience 在本批启动/恢复边界均为 improved:已有意图和权限下无需新增确认,减少一次手工领取,失败后仍可找回同一 Turn 的结果和成本。检查 loopx/cli_commands/turn.py 与 Codex CLI quickstart 后,确认本批没有改变 apps/ 的渲染页面,visual review 不适用。 unverified_scope:none for changed presentation;实际模型理解和采用仍未验证。

完整 diff 的机制与已重现风险相称,architecture assessment 为 retain。复用既有 validator/锁/spend owner 是本批已完成的简化;删除精确历史预约兼容会损坏既有可恢复 journal,因此保留到相应历史记录迁移。这里的 Python 是现有 transport/effect 整合,不新增第二个决策 owner。合法与只读路径的主干/最终版本比较一致,自动准备与错误效果回读是明确披露的 intentional_change_validated。原目标的真实模型成果、配对完整成本和整体回归仍开放,不能据此关闭 R1 或 Goal。

review policy 26;评审与本地验证覆盖 unchanged exact head b89150097c1cd664c486d46e0de744fb3c370fed,没有遗留 blocking findings。授权合入仍须立即执行 readiness、保留 pending CI 等独立 hold 并回读主干。

English verdict: APPROVE 8669@b89150097c1cd664c486d46e0de744fb3c370fed. Exact advertised claim, locked start admission, truthful effects and original-Turn recovery are covered by real File/SQLite, baseline/head and installed-core checks. No blocking finding; real model adoption/full R1 and native Windows remain unqualified, and verified unchanged Lark F811 and downstream skipped CI remain separate merge-readiness holds.

@cocolord

Copy link
Copy Markdown
Member Author

Maintainer-authorized merge decision for unchanged head b89150097c1cd664c486d46e0de744fb3c370fed.

The full policy-26 review is published and read back, required local validation passed, and review threads are complete with zero unresolved findings. Coverage includes 395 source tests (one platform skip), 22 independent installed-core tests, six paired main/head public paths, 106 receipt-owner tests (one platform skip), changed-file Ruff and standard premerge with the bilingual RFC gate.

Readiness remains false: the full CI Ruff failure is the same sole unchanged Lark F811 ordinary error on immutable main and this head; its dependent Python/Stage 2C qualification lanes were skipped/failed. The original Ark 3.11 job is cancelled, Ark 3.13 and both MemT jobs succeeded; cancellation is retained as an unresolved diagnostic, not relabelled a pass. Browser lanes are still pending. No current changed-invariant failure is observed. The review records the exact baseline comparison and these independent limits.

Use the previously granted maintainer admin authority only for readiness/GitHub policy holds. Preserve CI failures/cancellation, original R1/model-adoption gaps and frozen budgets; merge does not complete the Goal or qualify all CI.

本批评审、必需本地验证与零未解线程已核实。使用既有维护者授权覆盖已记录的 readiness/策略等待,不把失败、取消或未执行的 CI 改标通过,也不关闭完整 RFC 验收。

@cocolord
cocolord merged commit 441c607 into main Nov 13, 2026
38 of 44 checks passed
@cocolord
cocolord deleted the codex/rfc-r1-managed-start-20261113t025250 branch November 13, 2026 05:00
@loopx-agent

Copy link
Copy Markdown
Collaborator

Reviewer: model_agent · gpt-6.1-sol · OpenAI · runtime_reported · reasoning_effort=max

合入后复核。PR head b89150097c1cd664c486d46e0de744fb3c370fed,合入提交 441c6077e7c5c8e896ea79562761fd483baf157e,原主干 167b0a1f3a3307c284b021ea9a09c7c0b5e5a11f。合入提交的 Git tree 与 PR head 相同。

[P2] 显式会话身份不匹配时,拒绝前已领取任务并占用启动间隔。 有资格的 hard-lease Todo 尚无 lease,启动间隔已配置。用 --session-scope todo 和完整 resume 三元组运行内置 Codex,分别只替换 Goal、Agent 或 Todo。 File 和 SQLite 各三个反例都拒绝会话且没有启动 Host。原主干保持 lease 和 cadence 不变,合入版却建立了活跃 lease、Turn 回执和 reserved 启动记录。纠正参数后用新 Turn 重试仍返回 minimum_interval_wait。 复用现有 planner 的会话身份判断,按有效 session scope 在 cadence、Turn 回执与普通领取之前拒绝不匹配的显式 resume。保留原锁内竞争检查及已有效的同一 Turn 恢复。 先执行领取准备 稍后拒绝会话身份

动机 / Motivation

调用内置 Codex CLI 的用户希望下一项任务自动领取后继续执行,也可能通过 resume 参数指定原会话。 选中的 Todo 还没有租约。调用者传入了另一个 Goal、Agent 或 Todo 的会话绑定,命令最终拒绝,但在拒绝前已经改写任务和启动调度。 有效的普通调用现在能自动领取、执行并验证成果,减少一次手工操作。错误会话的输入仍会先创建租约和 Turn 回执,并占用一次启动间隔。 会话身份校验需要先于任何领取、Turn 绑定与 cadence 预约。纠正参数后的合法调用应能在原有授权下恢复。 合入提交与评审 head 的 Git tree 一致。验证使用真实源码 CLI、File 和 SQLite,Codex 子进程使用合成输入。实际模型采用、Windows 和完整 R1 仍待验证。

改动思路 / Approach

现有 Turn planner 已负责会话身份,现有锁负责启动预约和领取。把会话拒绝留在这些写入之后,会让一条无法执行的请求提前占用调度。 这批交付已有 Codex CLI 入口的自动领取和同一 Turn 恢复。它需要沿用现有会话与启动校验,并保留合法请求的单次副作用。 自动领取解决原来要手动执行一次 claim 的问题。保留已有 TypeScript cadence owner 和普通领取,继续在同一锁内拒绝竞争的 Turn。显式 resume 的身份与 scope 在这一阶段已经可得,应先调用已有校验,避免通过回滚来补偿本可提前避免的写入。 原始问题

具体改动 / Changes

关键代码讲解

  • handle_turn_command 解析 resume 参数后就触发自动准备。只有在同一 Todo 读回 ready 后,build_loopx_turn_plan 才处理已给出的会话身份。 准备与计划顺序
  • builtin_execution_preparation_claim 核验公布的普通 claim。它在锁内调用 cadence,随后写原 Turn 回执并走普通 Todo claim。两种持久后端都能从自己的读路看到这笔写入。 启动检查与领取
  • ensure_turn_heartbeat_settlement_receipt 先拒绝同一 Turn 的冲突绑定,再调用启动准入。已合入的竞争防护与本次显式 session 输入拒绝属于两个不同的入口条件。 绑定锁中的启动回调
  • managed_cadence_start 用同一结算身份复用未启动预约,旧 transaction key 保留兼容。纠正参数并使用原 Turn 时能恢复,使用新 Turn 会碰到已经占用的间隔。 预约与兼容回退
  • _session_plan 按 session scope 比较当前身份。它能阻止错误会话的 Host 启动。此时原 Todo 的 lease 与 cadence 已经持久化。 现有会话校验

验收依据为 docs/reference/protocols/loopx-turn-v0.md 在 167b0a1f3a3307c284b021ea9a09c7c0b5e5a11f 的 Turn 顺序。RFC 的双语 checkpoint 和 CLI quickstart 记录了此次交付范围。 Route、Prepare、Execute 与 Spend 现有 CLI 用法

条款 复核结果
route-before-preparation 未满足。错误会话的拒绝晚于预约、Turn 回执和领取。
exact-task-preparation 普通有效请求正确领取并重读同一个 Todo。
scope-bound-resume 外部会话被拒绝。拒绝路径仍会改变当前 Todo 和后续准入。
validated-settlement 两种存储的有效请求各完成一次验证和扣额,错误请求本身无 Host 和扣额。

对主干的风险 / Risks

同一组输入 原主干 合入版
外部 Goal、Agent 或 Todo 的完整 resume 拒绝,lease 和启动预约不变 拒绝前写 lease、Turn 回执及一条 reserved 预约
纠正参数并使用新 Turn 未消耗启动间隔,原版本仍要求手工领取 返回 minimum_interval_wait
纠正参数并复用原 Turn 原版本需要普通领取 原预约恢复,一次 Host 与一次结算

File 和 SQLite 的六项拒绝反例结论一致。合入版在无 Host 进程、无 Host journal 时已写入准备状态;另在隔离夹具中用普通 claim 确认有效 lease 后重试新 Turn,仍被原预约拦下。未使用真实模型或生产状态。

语义与 CI 对齐

300 项源码回归和 standard premerge 的 6 项直接、19 项选中检查通过。常规测试覆盖无效 validator、cadence 等待、锁竞争和同一 Turn 恢复。显式会话范围需要在同一 CLI 入口补上反例。在 File 和 SQLite 的真实 run-once fixture 逐一替换 resume 三元组,核对拒绝后 lease、cadence、Turn 回执、journal 和 Host 日志均无新增,再用纠正后的有效请求验证一次执行与结算。 托管 CI 未作为本次依据。

我的整体评价 / Verdict

保留有效请求的自动领取、锁内竞争检查和同一 Turn 恢复。现有用户在一次输入错误后可能失去一个执行窗口。后续修复应把现有会话校验移到预约及领取之前,并以两种存储的零写入拒绝与正常执行回读验收。本次改动只触及 Turn CLI、控制面和文档,Dashboard 与已安装界面没有改动。评审通过命令输出和持久状态核对用户路径。 合入提交与评审 head 的 Git tree 一致。验证使用真实源码 CLI、File 和 SQLite,Codex 子进程使用合成输入。实际模型采用、Windows 和完整 R1 仍待验证。

English verdict: REQUEST_CHANGES for the follow-up to b891500. In the merged tree, a mismatching explicit resume tuple is rejected only after the lease, Turn receipt and cadence reservation are written. File and SQLite reproduce it. Validate session scope before preparation and preserve same-Turn recovery.

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