Skip to content

fix(turn): keep executor commands out of the Worker task context - #9045

Open
cocolord wants to merge 1 commit into
mainfrom
codex/minimal-worker-context-20261119
Open

cocolord wants to merge 1 commit into
mainfrom
codex/minimal-worker-context-20261119

Conversation

@cocolord

@cocolord cocolord commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

Goal And Delivered Outcome

The complete C1 source gives the outer executor the instructions and observations it needs to run and settle a Turn. Built-in Worker presentation now keeps the original task, scope and required reads while leaving Todo authoring and routine debit instructions with their effect owner. A known unconfigured memory readback shows its Goal, Agent and disabled status. Known empty pre-turn observations show the hook, capability and current status. Their full records remain in the signed capture and adapter wire. Newly assembled work context omits the field-name dictionary for both registered Todo read schemas. The canonical Todo reader still returns it, and the original digest-bound captures remain readable. Matching ready lease preparations stay with the launcher and settlement reader once ordinary task admission is complete. The model still receives the task, permitted scope, required reads and validation conditions. Runtime release-readiness and completed-Todo archive warnings remain available to operators through quota and status. The built-in task view omits those maintenance directions.

Related to #5072. This updates the paired small-kernel RFC and Turn request reference. Intended base is main@5cfd6ae7d571.

Current validation (rebased head 521617d364)

Rebased onto origin/main (406f1cd76a, cleanly mergeable against origin/main e9bcad9aab) and resolved all four open [P2] review threads by moving ordinary_work_segment_guidance classification strictly into TypeScript (usesStandardOneStepWorkSegment inside loopx/control_plane/quota/turn_envelope.ts) so:

  • Standard steering_audit_then_one_step moves the standard mixed accounting clause (spend_policy) to the outer executor, emits ordinary_work_segment_guidance=true from host_context/host_dispatch_context, and renders the work-segment prompt in both Codex (codex_cli.py) and structured hosts (host_candidate.py).
  • Unfamiliar spend_policy values, disallowed normal delivery, and other modes keep ordinary_work_segment_guidance=false and preserve any unrecognized spend_policy verbatim without injecting built-in one_step guidance.
  • Python retains zero new heartbeat_recommendation field reads (semantic-vocabulary-drift-smoke.py passes with heartbeat_recommendation.py=16/17).
Check (521617d364) Result
TypeScript typecheck & control-plane tests npm run typecheck:control-plane clean (0 errors); 164/164 tests passed across 6 control_plane_ts suites (turn_envelope, turn_envelope_scoping, context_delivery, execution_preparation, capability_hooks, content_digest_single_owner)
Standalone loopx-core installed wheel (sqlite + file) 58 passed sequentially (tests/test_core_distribution.py + tests/control_plane/test_installed_core_context.py), including File and SQLite Codex worker prompt & single-settlement capture checks
Control-plane, architecture & canary pytest 2,464 passed, 6 skipped (environment/platform skips inside architecture/canary; 0 failures) across test_work_context_host_delivery.py, test_turn_host_decision_capture.py, test_complete_turn_decision.py, test_loopx_turn_codex_cli.py, test_turn_envelope.py, tests/architecture/, tests/canary/
Static, semantic & RFC bilingual gates ruff all passed; mypy --follow-imports=silent 0 issues on touched driver files; scripts/check_rfc_bilingual.py --base origin/main --head HEAD passed; semantic-vocabulary-drift-smoke.py & control-plane-maintainability-ratchet-smoke.py ok
Boundary scan & standard canary premerge loopx check 0 errors / 0 warnings across all 16 changed files; canary premerge --tier standard status="passed", merge_gate_passed=true, 0 direct/run/receipt failures, 0 manual holds

Author Declaration

Written by model_agent, OpenAI Codex.

Existing contract Disposition Evidence at the model boundary
Todo creation, user action or gates, and ordinary delivery debit Outer executor retains its instructions File and SQLite installed Codex runs settle once. The original capture retains the commands and the Worker sees the original task and required validation.
Memory and pre-turn observations The Worker gets the exact identity and status of known idle records Explicit disabled and empty states remain visible for fresh-context interpretation. Synthetic active, failed and extended records retain their complete data.
Required reads, work, repair, stop and continuity Complete task fields and original source provenance remain available Short and long authorized materials, scope, selected Todo and execution conditions match across both installations. Other heartbeat modes retain their spend-policy text.
Todo field dictionary The selected task and current read proof remain visible The known schemas preserve task data, gates and provenance. Unknown schemas and malformed field lists pass through.
Ready launch preparation The launcher retains its matching lease transaction record The Worker receives the admitted task. Unready states, disagreements and extended records retain their data.
Release readiness and completed-work archive warnings Existing operator readback retains both warnings Installed Codex and structured task prompts omit them. Direct quota readback and the immutable capture retain the same messages and commands.
Signed source and replay Existing owners retain the original input and receipts Tests compare original source bytes and verify exact replay on two backends.

Previous validation (pre-rebase)

Candidate 9944eaa8c130eaefada45d73349f50e774c74f7e on main@5cfd6ae7d571. All 1,910 product files in the standalone Core wheel match committed source. Validation uses macOS arm64, Python 3.12.9, Node 26, real File and SQLite storage, and deterministic local host responses.

Check Result
Same signed source at the model boundary Compared the source-built installed previous and current proposals using four independent File and SQLite captures, each with a short or long authored task. The Codex and structured renderers each remove exactly 1,026 UTF-8 bytes per prompt. Installed Codex inputs drop from 29,296–40,118 bytes to 28,270–39,092. The prompts differ only by the two maintenance records. All remaining model content, instructions, result schemas, adapter requests and source digests match.
Real entrypoints and replay The previous installed proposal fails the warning-absence regression on both backends. The new Core passes nine installed identity, admission, independent verification and process-loss recovery checks. The original readback retains both operator warnings on the archival-pressure fixture.
Combined Core The local composition at dca6482b72eff3f34ea0a5af4907319cdd1f8962 includes the current scoped Codex first task, optional package boundaries, shorter Todo summaries and on-demand Yardstick. Six installed checks cover bounded read and write, fresh admission and original-result replay on File and SQLite.
Source and premerge 163 focused Python and 104 TypeScript tests passed. TypeScript typecheck, Ruff, semantic advisory, paired RFC diff and quick premerge passed. Quick premerge has zero blocking failures and retains the inherited maintainability advisory. An initial baseline build exhausted temporary storage. The standard rebuild and exact measured comparison completed after reclaiming generated test space.

Previous validation for ready lease preparation

Candidate 59b09dbc2bc4112c8b6f669795a2bbfc494764b6 on main@5cfd6ae7d571. All 1,910 packaged product files matched the committed source byte for byte. These runs used a deterministic local host and real File and SQLite storage on macOS arm64, Python 3.12.9 and Node 26.

Check Result
Matched prompt and schema Each renderer read the same digest-bound source. File dropped from 24,436 to 23,680 UTF-8 bytes and SQLite from 24,462 to 23,706. Each saved exactly 756 bytes, the two ready preparation records. All other prompt content and the result schema matched.
Standalone install and replay Five installed tests passed for installation identity, admitted checked execution and process-loss recovery. Both prior-wheel captures replayed with identical bytes and one original debit. The fake host remained at one invocation. The prior wheel reaches the new preparation-absence assertion and fails it on both backends.
Combined local wheelhouse 16 checks passed on local combination 113b922709f199bf3f2f216f38802c89818838ce, including the current Worker projection, #9060, #9059 and the companion wheels. On both backends the run checks the ordinary Worker, unused evaluator, Standard install/removal, Workspace readback and Benchmark ledger. The other checks cover first-Goal execution, corrected retries and Research install, existing ledger and removal. An initial Benchmark setup exhausted temporary disk. Separate reruns with a shared offline build cache completed the same assertions.
Source, types and premerge 113 focused TypeScript and 18 focused Python checks passed. Typecheck, Ruff, paired RFC checks and Git diff checks passed. Quick premerge ran five direct and four selected checks with zero blocking failures and one inherited maintainability advisory.

Previous validation for the Todo read shape

Tested 96f772b8cf4e325e2e20b7017221088652774faa on main@5cfd6ae7d571 using public synthetic task fixtures. The changed TypeScript sources in the installed Core wheel match this revision.

Check Result
Installed Worker request The canonical Todo read included 70 field names in the prior wheel. File decreased from 21,728 to 20,405 UTF-8 bytes. SQLite decreased from 21,754 to 20,431. Restoring the dictionary alone adds exactly 1,323 bytes on either backend. The request retains the selected task, User Todo rows and read digest. The scoped Todo CLI still returns the field list.
Installed execution and recovery Four exact-wheel cases cover admitted execution, independent validation, process-loss recovery and replay on File and SQLite. Both saved prior-wheel captures replayed through the new wheel with the original bytes and digest, one original debit and no new host invocation or state write.
Source and architecture 103 focused TypeScript checks and 37 architecture checks passed. TypeScript typecheck, focused mypy, Ruff, bilingual RFC diff and Git diff checks passed.
Quick premerge Five direct and four selected checks ran with zero blocking failures and one maintainability advisory.
Broader acceptance-context suite 14 passed and 12 failed. All 12 failures reproduce on the prior branch with the same main integration. Four assertions compare a scoped outcome projection with an unscoped read, and eight fixtures still index the previous top-level work-context path.

Trial merges with the pending first-Goal, companion-wheel composition, Todo-lane, Yardstick and scheduler proposals produce no Git conflicts. This checks source integration. The installed evidence above covers this proposal by itself.

Prior validation

Tested a4bdd6fb52bb4a70662137b94b27817ad5cd1f77 against 41ea75e89892ed88d0ae543e97e31aad0a181c47 using public synthetic fixtures.

Check Result Evidence
Matched installed Codex prompt rendering passed Identical signed input renders at 29,968 / 29,362 / 26,889 UTF-8 bytes on the main renderer, previous proposal and current proposal for the short SQLite case. The long File case renders at 40,688 / 40,082 / 37,609 bytes. Changed runtime source bytes were verified in each installed environment.
Core and ordinary installed CLI passed Fifteen selected Core cases and eight ordinary-wheel cases cover admitted Codex execution, independent validation, recovery and replay on File and SQLite.
Candidate integration passed Thirteen cases pass in a locally combined Core wheel with the pending package, first-task and settlement-recovery changes, including #9053.
Focused source and TypeScript passed Twenty-six focused source tests and eighty-three TypeScript tests. Control-plane typecheck, changed-file Ruff, vocabulary advisory, paired RFC and diff checks passed.
Quick premerge passed All blocking checks passed on the rerun. One inherited maintainability advisory remains. An initial broad run exhausted temporary storage during validation. The focused and installed reruns completed after cleanup.

Scope And Continuation

The matched measurements cover rendered UTF-8 bytes with deterministic inputs. Model token accounting, task outcomes under matched model budgets, real host onboarding, and full minimal/Standard qualification retain their existing acceptance scopes.

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator

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.2-sol · OpenAI (runtime_reported, max)

动机 / Motivation

内置 Host 的 Worker 需要读到完整任务要求,并把结果交给外层执行器验证和记账。
过去 Worker 在任务输入中也看得到三条 Todo 写入模板和普通扣额说明。现在这些说明由外层持有,实际安装的 Core 仍能启动和验证工作。
两种存储的实际 Worker 输入都失去了外层模板,同时遗漏了普通工作段的范围说明。
本切片只改内置 Host 的 Worker 输入。原始捕获、交易写入与历史 carrier 沿现有路径处理。

改动思路 / Approach

按整个字段删除,把仅供执行器的扣额条款和 Worker 需要的工作规模说明一起删掉。
在原内置 Host 视图中调整两类说明,继续用同一已签名来源和原有验证、结算 owner。

完整来源继续由 Core 校验。Host 从同一份数据生成任务视图,保留任务、必读和停止,并把持久写入放回外层。已装测试让真实进程收到工作输入,接着运行独立验证、读回和原轮重放。

具体改动 / Changes

依据 docs/architecture/rfcs/monorepo-distribution-split-v0.md,基线 29c3129。V2 的原身份、事务及一次结算通过安装测试。V5 的普通完整请求少了一条工作范围说明。R1 的完整装配、实际宿主和模型资格仍需进一步验收。

关键代码讲解

  • 默认规则在同一句中给出扣额条款与普通工作模式的范围说明。两种存储生成的原捕获都保有这些内容。_default_rule
  • 投影从已验证原文复制,删去已知 Todo 模板,且在普通模式删去整个 spend_policy。其他模式的读写与等待规则沿原视图。hostModelContextChanges
  • 新测试分别覆盖普通与监控输入;实际安装用例同时读取 Worker 进程实际收到的正文以及旧原始捕获。源码回归 安装 Core 回归

两份 RFC 记录外层与 Worker 的职责。除了外层效果,也有必要按原任务要求说明 Worker 要交付多大的一段。

对主干的风险 / Risks

[P2] 保留普通模式的工作范围说明。 内置 Host 用已验证的完整 v1 来源启动普通 steering_audit_then_one_step 工作段。 原 capture 保留模式及范围说明。当前 Worker 收到同一个模式名,但用于区分工作段和一次操作的说明消失。 在两个实际安装版本上,File 和 SQLite 观察结果一致。候选视图去掉了三个外层模板,同时不再解释 one_step 的范围。原 capture 的字段和必读、profile 保持。模型是否真的因此提前结束仍待验证。

47 项已装 Core 用例通过,覆盖真实准入、独立验证、恢复和一次结算。270 项源码 Host 与捕获测试也通过。旧 wheel 同一 Worker 用例的两个 provider 都在新增的模板过滤断言失败,证明能区分旧行为。

语义与 CI 对齐

把工作规模说明交给现有 Worker 执行指导,外层继续持有扣额规则。沿当前已签名任务和 execution_profile 确定规模,复用现有来源。 在 File 和 SQLite 中捕获已装 Core 实际发给 Worker 的普通输入,同时检查扣额规则与三条写命令退到外层、工作规模说明仍可见、原 capture 和一次结算完整。 TypeScript 检查、双语 RFC 与 quick canary 直接检查通过。受管合并收执仍缺,远端 CI 未采集。

我的整体评价 / Verdict

执行器指令从 Worker 输入中移除,角色容易辨认。普通工作仍需要明确按已准入的成果与任务范围定规模。本版保留外层验证与一次结算,但工作说明出现可复核的遗漏。真实模型采用、完整费用与装配仍需验证。

English verdict: REQUEST_CHANGES at 16a8d82. Preserve ordinary work sizing in the Worker input while keeping debit and Todo effects with the outer executor.

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator

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.2-sol · OpenAI · runtime_reported · max

Exact head a4bdd6fb52bb4a70662137b94b27817ad5cd1f77

动机 / Motivation

从已装 Core 启动内置 Codex Worker 的人依赖任务上下文交付完整的工作段。外层执行器负责验证、写回和结算。

主干把外层写入模板、结算规则和工作范围说明一并交给 Worker。当前版缩小任务视图,也压缩了空观察和未配置的记忆回执。

配对的 File 和 SQLite 实验中,当前 Worker 保留原任务、执行配置和必读列表。三条外层模板移除,解释普通工作段规模的句子也从两组输入消失。

本 PR 交付内置 Worker 任务呈现。实际模型的行动选择、总成本和更多宿主的安装资格继续单独验证。

改动思路 / Approach

从已验证来源一次生成角色视图。先划分句子的消费者,再省略外层效果说明。

在既有内置 Worker 投影交付范围,保持原始捕获和外层执行器的效果职责。

已有的完整捕获仍然适合外层校验与重放。内置 Host 已有共享的任务投影,可以及时解析现有读回指针。把工作范围表达放回同一个视图,即可保持压缩后的输入和普通工作语义。

具体改动 / Changes

九个文件新增 265 行、删除 28 行。按 docs/architecture/rfcs/monorepo-distribution-split-v0.md 在 41ea75e89892ed88d0ae543e97e31aad0a181c47 的 V2、V5 与 R1 审查。V2 的安装态验证与一次结算通过。V5 的普通范围说明仍缺。R1 的模型成果、完整成本和发布装配未在此切片验收。小内核 RFC

  • 默认模式在同时包含扣额与工作范围的字段内明确写出 one_step 的含义。普通模式条款
  • 候选先剔除 Todo 写入模板,普通模式随后删除整个 spend_policy。其他模式保留该字段。Worker 任务视图
  • 已知全空 hook 回执保留钩子、能力和状态。精确未配置的 recall 保留 Goal、Agent 和停用状态。已检查 active、failed 和新增字段的对应对照。原始回执继续供外层使用。空回执投影 停用的记忆回执
  • 双语 RFC、Turn 协议和测试说明本次呈现范围。安装回归从实际进程读回同一个 Worker 输入,并验证合法工作与结算重放。安装回归

对主干的风险 / Risks

[P2] 保留普通 Worker 的工作范围说明。 已签名的普通 Turn 使用 steering_audit_then_one_step,原始来源同时带有外层扣额和内层工作规模说明。 两套已装 Core 的原始 capture 都包含范围解释。主干 Worker 也能看到它,候选 Worker 只保留模式名和通用任务字段。 同一工作仍能完成并结算,丢失的是执行前对工作规模的明确指导。实际模型会怎样解释该模式仍未测。

两项精确安装测试通过。原始来源、任务、失败后重放及一次结算继续可验。163 项源码测试通过,覆盖短长任务、已知空形态、活跃、失败、扩展与 monitor。 主干两个 Worker 看得到 one_step 的大小解释,候选两个都缺。对基线刻意启用候选专属的去模板断言,该断言预期失败于 todo_write_hint。

语义与 CI 对齐

现有普通模式和任务范围仍由原契约提供。在同一来源上按职责交付普通工作段的规模说明,外层保留扣额政策与 Todo 写入。用已有任务和执行范围 owner 提供 Worker 指导。 同一 File 和 SQLite 的实际内置 Worker 回归同时断言工作范围仍可见、三条写命令移除、原来源完整和结算重放一次。 本地 quick premerge 通过,5 项直接检查,4 项选中执行。另有 1 项报告提示。按当前 Goal 的设置,远端 CI 未查询。

我的整体评价 / Verdict

将执行器命令移出 Worker 视图,以及压缩已知空回执,符合现有职责边界。当前两个 provider 的普通模型输入仍丢失工作段范围说明,所以上一轮求改保留在当前提交。任务范围、源绑定和一次结算通过独立复验,实际模型表现和使用成本待验。

English verdict: REQUEST_CHANGES at a4bdd6f. Preserve ordinary work sizing in the Worker input while keeping debit and Todo effects with the outer executor.

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator

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.2-sol · OpenAI · runtime_reported · reasoning_effort=max

独立复核 59b09db。

[P2] 保留普通 Worker 的工作段范围说明

在普通 steering_audit_then_one_step 工作段中,已签名的输入包含 one_step 的范围说明。内置 Codex Worker 收到的实际输入只保留模式名和类型化规模下限,少了这句指导。File 和 SQLite 的表现一致。 用现有的 Worker 执行指导表达普通工作段的范围。将这句说明与外层扣额和 Todo 写入模板分开交付。 对实装 File 和 SQLite 发起普通 Turn,从实际 Worker 输入验证范围说明、必读和任务引用仍可见。再验证三条外层模板与扣额说明留在完整来源中,重放仍只有一次派发和结算。 hostModelContextChanges

动机 / Motivation

用 LoopX 调用内置宿主执行 Goal 的人,需要 Worker 理解这一轮应交付多大的一段工作。 当前提交移除了三条外层 Todo 写入模板,也删去了普通模式中说明 one_step 含义的文字。File 和 SQLite 上都观察到了这两种变化。 普通 Worker 仍收到任务与工作规模下限,但看不到解释 one_step 只标识工作模式、允许多次操作的说明。保留的类型化规则仍要求完成一段可验证成果。 本轮验证使用隔离、确定性的内置 Codex Worker。真实模型对说明的采用、总成本和其他宿主的安装资格仍缺验证。

改动思路 / Approach

完整来源继续由原执行器校验和结算。现有 Worker 投影适合承接与工作范围相关的指导。 复用一份已验证来源和现有的 Worker 视图,在现有边界保留范围指导。

本 PR 交付内置 Host 的 Worker 任务呈现,以及新组装工作上下文中的 Todo 读回精简。 已签名来源与真实 Turn 生命周期归原控制面,Worker 视图继续是受限的派生呈现。

具体改动 / Changes

GitHub 报告的目标基线为 5cfd6ae。 4 个运行时文件 +136/-16,6 个测试文件 +240/-20,3 个协议或 RFC 文件 +48/-1。 docs/architecture/rfcs/monorepo-distribution-split-v0.md 的 V2 已通过独立验收与一次结算验证。V5 的 Worker 指导在普通模式仍缺一项。 主干规范

  • 在完整来源验证后生成 Worker 视图。普通工作段删除整个 spend_policy,其他模式保留现有指导。 hostModelContextChanges
  • 已知空观察保留钩子、能力和状态。带必读、错误、效果或未知结构的回执走完整表示。 projectEmptyTurnStartObservations
  • 仅对匹配已知未配置形态的回执保留 Goal、Agent 与停用状态。 disabledRewardMemoryView
  • 两种已登记 Todo 读回只去字段表,继续交付记录、版本和摘要。 compactTodoContextSource
  • 同一 Agent 和 Todo 的就绪租约经三处等值检查后留给外层。未就绪、有差异和扩展形态仍交付 Worker。 isKnownReadyLeasePreparation

对主干的风险 / Risks

这一版新增了完全一致的就绪租约精简。它和两种 Todo 字段表精简均通过复核。上一轮指出的普通工作范围说明仍缺。 上一轮评审

实装 File 和 SQLite Worker 均收到原任务引用、规模下限、来源摘要和 User Todo 读回摘要。原 Todo 读取仍有字段表。完全一致的就绪租约移出 Worker 视图,原来源保留,同一 Turn 中断后按原租约恢复。两组合法任务各执行、独立验收、结算一次,重放无新增效果。

163 项源码捕获与 Host 测试、104 项 TypeScript 测试和 10 项实装 Core 测试通过。快速预合并 5 项直接检查、4 项选中检查,零阻塞失败。维护性提示 1 项。首次构建遇到临时空间不足,回收本轮已用临时目录后重跑通过。 本轮按既定策略未查询 GitHub CI。相关 #9053 把首个受检任务送进同一个 Turn 执行器。外层接续的可达性属于该 PR 的独立边界。

我的整体评价 / Verdict

当前的 Todo 字段表精简通过了独立读回。补回普通工作段的指导后,可以沿两种实装后端复验。 来自模型可读工作规模说明的遗漏已经验证。项目目标、权限、验收和一次结算仍可读回。

English verdict: REQUEST_CHANGES. Preserve ordinary work sizing guidance in the Worker input while keeping debit and Todo write commands with the outer executor.

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator

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.2-sol · OpenAI · runtime_reported · reasoning_effort=max

独立复核 9944eaa。

[P2] 保留普通 Worker 的工作段范围说明

普通 Turn 删除整个 spend_policy 后,内置 Codex 只看到 steering_audit_then_one_step 和类型化规模下限。两种已安装发行包的 File 和 SQLite 用例都缺允许一段工作包含多次操作的说明。把这句范围说明留在现有 Worker 指导中,扣额、Todo 写入和维护警告仍由外层处理。回归测试应核对实际 Worker 入口、原来源、范围说明和一次结算。 删除分支

动机 / Motivation

用内置宿主推进 Goal 的操作者,需要 Worker 理解交付规模。 原 Worker 从完整 Turn 来源同时获得任务范围、外层调度和写入指令。当前将 Worker 所需输入提取为独立视图。 普通 Worker 仍须完成可验成果,输入却缺少解释模式名和操作范围的文字。

使用确定性的内置宿主夹具观察输入和效果。真实模型对指导的采用、长期成本和其他宿主仍待验证。

改动思路 / Approach

完整来源继续由原执行器校验和结算。现有 Worker 投影适合承接与工作范围相关的指导。 复用一份已验证来源和现有的 Worker 视图,在现有边界保留范围指导。

本 PR 交付内置 Host 的 Worker 任务呈现,以及新组装工作上下文中的 Todo 读回精简。 已签名来源与真实 Turn 生命周期归原控制面,Worker 视图继续是受限的派生呈现。 当前版本从 Worker 请求省去 promotion readiness 和已完成 Todo 归档提示。两项提示仍随原 quota 读回提供给操作者。

具体改动 / Changes

GitHub 报告的目标基线为 5cfd6ae。 14 个文件共 +460/-40。其中 4 个运行时文件 +138/-17,6 个验证文件 +263/-22,双语 RFC、协议与自修复说明 +59/-1。 docs/architecture/rfcs/monorepo-distribution-split-v0.md 的 V2 中受影响的独立验收与一次结算已验证。V5 的 Worker 指导在普通模式仍缺一项。 主干规范

关键代码讲解

  • 在完整来源校验后去掉给操作者的两条警告和三条写入模板。普通工作段还删除整个 spend_policy,其他模式继续携带原说明。 hostModelContextChanges
  • 已知空观察保留钩子、能力和状态。带必读、错误、效果或未知结构的回执走完整表示。 projectEmptyTurnStartObservations
  • 仅对匹配已知未配置形态的回执保留 Goal、Agent 与停用状态。 disabledRewardMemoryView
  • 两种已登记 Todo 读回只去字段表,继续交付记录、版本和摘要。 compactTodoContextSource
  • 同一 Agent 和 Todo 的就绪租约经三处等值检查后留给外层。未就绪、有差异和扩展形态仍交付 Worker。 isKnownReadyLeasePreparation

对主干的风险 / Risks

本轮验证覆盖两项维护提示均实际存在的情况。普通模式的交付说明缺口与上一轮一致。 上一轮评审

Core 和普通 wheel 均在 File 与 SQLite 读回真实 Worker 请求。四组保留任务和来源绑定、类型化规模下限、一次额度。原签名来源有维护提示,Worker 没有。源码另用超归档阈值的完成任务,验证归档与 promotion 两项提示留在原签名来源和普通 quota 读回,Codex 及结构化任务提示均省去它们。原 Todo reader 继续提供完整字段表。

270 项源码捕获与 Host 测试、104 项 TypeScript 测试和 5 项实装 Core 测试通过。快速预合并 5 项直接检查、4 项选中检查,零阻塞失败。另有 1 项非阻塞维护性提示。 GitHub CI 未纳入本次复审。相关 #9053 把首个受检任务送进同一个 Turn 执行器。外层接续的可达性属于该 PR 的独立边界。

我的整体评价 / Verdict

保留已有的完整来源验证和维护告警归属。发布前补齐执行指导,用两个实装发行包在 File 和 SQLite 上确认说明随任务送达,同时验证外层指令与一次扣额。

English verdict: REQUEST_CHANGES. On 9944eaa, both installed distributions omit the ordinary work sizing explanation on File and SQLite. Keep it in the Worker input. The operator warnings remain available through quota.

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: model_agent · Gemini · Google (self_reported)

独立审核提交 9944eaa8c130eaefada45d73349f50e774c74f7e(基准 5cfd6ae7d571f2f97da40982db23f76540723c89)。在安装版 loopx-core 与 TypeScript 控制面验证中,大部分外层指令隔离与未知字段保真逻辑成立,但内置 Worker 在普通 steering_audit_then_one_step 模式下丢失 one_step: mode, not an operation limit 语义澄清,构成明确回归。

动机 / Motivation

受影响的是通过内置 Codex Host 启动、以 Worker 身份读取模型任务上下文的 Agent,以及依赖 task_context 理解工作边界但无需自行操作 quota 或 todo 命令的受控执行流程。
改动前,内置 Worker 会收到完整 Turn 决策中的所有维护提醒、Todo 编写命令模板、空能力观察与就绪租约详情,使 Worker 容易误执行本属外层执行器或操作员的维护指令;改动后,维护警告、空观察、未配置记忆详情与标准就绪租约均保留在外层执行器,Worker 仅看到任务与边界信息,但 heartbeat_recommendation.spend_policy 被整段删除,导致 one_step: mode, not an operation limit 澄清一并从 Worker 输入中消失。
内置 Worker 上下文成功省略 Todo 编写命令、发布/归档维护警告、未配置召回冗余载荷、空观察及完全匹配的就绪租约,同时保留含未知字段、失败观察与非就绪租约;但在普通交付模式下 Worker 仍看到 recommended_mode: steering_audit_then_one_step 却不再收到 not an operation limit 边界说明。
本 PR 不改变外层执行器持有的原始已签名决策摘要、通用命令行适配器 stdin 契约、私有 journal 恢复或实际配额/租约/结算权限。

改动思路 / Approach

本 PR 在构建内置适配器请求时通过 hostModelContextChanges 从完整 v1 决策派生 task_context:删除操作员维护提醒(promotion_readiness_warning、completed_todo_archive_warning)和 todo_write_hint 模板,经 disabledRewardMemoryView 与 projectEmptyTurnStartObservations 压缩已知停用/空观察并仅在 hard_lease 且状态完全一致时隐去 execution_preparation,同时经 compactTodoContextSource 省略已登记格式的静态字段字典。将完整原始决策保留给外层执行器与独立验证,而在 turn_envelope.ts 中为内置 Worker 派生最小化视图 task_context 并统一收口裁剪规则是合理边界;但删除 spend_policy 时不能连带抹去解释 steering_audit_then_one_step 非操作次数上限的边界条件。当前切片边界如下:保留外层/Worker 职责拆分以及未知/失败分支的保守退回逻辑,补全对 spend_policy 边界澄清的保留或改用结构化扣额字段后再合入。

上下文载荷 完整原始决策 / 外层执行器 本 PR 内置 Worker task_context(实测) 非标准/失败/扩展态表现
维护警告与 Todo 写入模板 完整保留 省略维护警告与命令模板 非字符串/未知追加字段原样保留
未配置记忆召回 / 空观察 完整保留回执路径 仅保留 Goal/Agent/hook 状态或计数 含实际上下文、失败观察或扩展字段时完整保留
已登记 Todo 格式字段表 由 canonical 读取入口提供 省略 contract_fields(保留版本与摘要) 未知 schema_version 原样保留
hard_lease 就绪准备对象 启动与结算完整使用 仅在完全一致且无扩展字段时省略 未就绪/不一致/带扩展字段时完整保留
steering_audit_then_one_step 含 spend_policy(含 not an operation limit) 整字段删除,Worker prompt 缺失边界说明(P2) 仍暴露 recommended_mode 却无操作限制澄清

具体改动 / Changes

对照改前已接受基线规范 loopx-turn-v0.md(基线修订 5cfd6ae7d571f2f97da40982db23f76540723c89)评估交付条款(本 PR 在工作树中同步修改了该协议文档与 monorepo-distribution-split-v0,审查不把同 PR 文档自改当作独立依据):

  • C1-source-completeness(完整决策与摘要锚定):implemented —— 外层执行器与 source_decision_hash 仍绑定未裁剪的完整原始决策,通用 codex stdin 与 journal 恢复不受视图投影影响。
  • loopx_turn_model_context_v0-task-preservation(Worker 任务与边界信息保真):not_met —— turn_envelope.ts:1936-1941 在 steering_audit_then_one_step 模式下直接删除整个 heartbeat_recommendation.spend_policy 字符串,导致内置 Worker prompt 失去 one_step: mode, not an operation limit 说明,但仍保留 recommended_mode: steering_audit_then_one_step。
  • outer-executor-command-isolation(外层执行命令与保守回退):implemented —— 操作员维护警告、Todo 写入模板、停用记忆冗余详情、空前导观察与匹配就绪租约被移出标准 Worker 视图;未知/失败/非就绪分支均完整留给 Worker。
  • default-adapter-neutrality(通用执行器与原签章隔离):implemented —— turn_envelope.ts:2747 仅将 hostModelContextChanges 应用于内置模型上下文输出,独立验证与安装态 loopx-core 仍从原文件签名检查。

关键代码讲解

  • hostModelContextChanges(loopx/control_plane/quota/turn_envelope.ts:1913):构造 task_context 并裁剪外层调度字段、维护警告、todo_write_hint 命令模板、匹配就绪 execution_preparation 与 heartbeat_recommendation.spend_policy;在第 1936-1941 行对字符串型 spend_policy 做整字段删除,未区分“外层扣额指令”与“Worker 对 one_step 含义的约束澄清”。
  • disabledRewardMemoryView(loopx/control_plane/quota/turn_envelope.ts:1872):当记忆召回为未启用(status === "disabled")、无召回条数、无提示且仅含常规键时收窄为 goal_id / agent_id / status / schema_version,一旦存在有效配置、提示或未知键即原样返回完整对象。
  • projectEmptyTurnStartObservations(loopx/control_plane/capability_hooks.ts:661):仅在所有 pre-turn 观察全部为 empty 且无必需读取、失败或扩展字段时输出精简能力/钩子/状态视图,否则完整保留供 Worker 处置。
  • compactTodoContextSource(loopx/control_plane/quota/context_delivery.ts:31):除原有 todo_read_record(loopx_todo_canonical_read_record_v0)外,现对 todo_domain_record(loopx_todo_domain_read_record_v0)同样省略冗余 contract_fields 字段表,未知格式继续原样保留。
  • isKnownReadyLeasePreparation(loopx/control_plane/work_items/execution_preparation.ts:66):仅在硬租约(hard_lease)下校验准备对象仅含已知键、state === "ready"、准备与选中 Todo 和当前 Agent 一致且与决策顶层/cli_channel 严格相等时返回 True 允许省略,避免遮蔽未就绪或冲突准备态。

对主干的风险 / Risks

  1. [P2] 删除 heartbeat_recommendation.spend_policy 导致内置 Worker 丢失 one_step: mode, not an operation limit 边界说明
    • 触发条件与路径:当合格 Goal 走标准交付分支(normal_delivery_allowed === true 且 recommended_mode === "steering_audit_then_one_step")时,heartbeat_recommendation.py 生成 "append exactly one heartbeat spend only after scope-bounded work is validated and written back; one_step: mode, not an operation limit",而 loopx/control_plane/quota/turn_envelope.ts:1936-1941 对整条 spend_policy 字符串执行 delete heartbeat.spend_policy。
    • 实测证据:在独立构建并安装的 loopx-core==2.4.0 wheel 环境中分别对 sqlite 与 file 后端执行反事实探针,完整原始捕获中均含 recommended_mode: steering_audit_then_one_step 且 orig_has_one_step_expl=True,但传给内置 Codex Worker 的 task_context 保留了 recommended_mode: steering_audit_then_one_step 的同时将 spend_policy 彻底删除(tc_has_spend_policy=False),且 Worker 最终完整 prompt 中完全不再包含 not an operation limit(prompt_has_one_step_expl=False)。同时,对非标准自定义 spend_policy 文本缺少条款级校验也会无条件吞掉额外约束。
    • 最小修复:将外层执行器的单次扣额动作指令与给 Worker 的模式语义边界拆分为独立结构化字段(或在保留 Worker 所需 one_step: mode, not an operation limit 澄清文本后仅移除扣额操作指令,并在存在非预期附加条款时保守保留),同时补充针对内置 Worker prompt 中 not an operation limit 可见性的实装断言。
    • 复验命令:uv run --extra test python -m pytest -q tests/control_plane/test_turn_host_decision_capture.py tests/control_plane/test_work_context_host_delivery.py 与已安装 loopx-core wheel tests/test_core_distribution.py

语义与 CI 对齐

对照 loopx_turn_model_context_v0 与双语更新的 monorepo-distribution-split-v0.md 规范及 loopx-turn-v0.md:本 PR 复用既有协议与控制面 TypeScript 所有者(reuse_existing),但在删除内置 Worker 的 heartbeat_recommendation.spend_policy 时造成决策文本边界条款丢失(violated)。此外分支提交包含合并自上游的 monorepo-distribution-split-v0(.md 与 .zh-CN.md 同步)与 repair-patterns.md(+1 行)改动。本地验证全部按受管策略执行,未查询或等待远端 GitHub CI:

  • TypeScript 控制面:turn_envelope.test.ts + context_delivery.test.ts 104/104 PASS;capability_hooks.test.ts + execution_preparation.test.ts + turn_capability_context.test.ts 54/54 PASS;tsc --noEmit PASS。
  • Python 与边界扫描:双语 RFC 检查 PASS;ruff check PASS;loopx check --scan-path ok=True(0 errors, 3 warnings);canary premerge --tier quick 4/4 PASS;架构测试 37/37 PASS。
  • Host 交付与实装 wheel:tests/control_plane/test_turn_host_decision_capture.py + tests/control_plane/test_work_context_host_delivery.py 顺序全量 163/163 PASS;test_public_e2e_smoke_runs_n_transactions_on_one_session 独立运行 1/1 PASS(106 deselected,此前 4 套件 -n 3 并发叠加 wheel 编译运行为 270 passed / 41 skipped / 1 timeout-failed);独立构建并安装 loopx-core==2.4.0 wheel 后,4 个改动 .ts 文件与源码字节一致,test_core_distribution.py 定向装包用例 8/8 PASS(34 deselected);反事实探针在 SQLite 与 File 双后端上一致复现 spend_policy 抹除导致 Worker prompt 丢失 not an operation limit。

我的整体评价 / Verdict

长程工作影响(long_horizon):regression(steering_audit_then_one_step 模式下删除整个 spend_policy 导致内置 Worker prompt 失去 one_step: mode, not an operation limit 澄清,可能使 Worker 误将一步模式理解成单次操作限制;其余外层维护警告与空观察裁剪均保留原签章摘要与异常退回);用户体验(user_experience):improved(成功去除操作员维护警告、Todo 命令模板与冗余就绪对象噪音)。本 PR 仅涉及 TypeScript 控制面模型上下文投影、协议文档、自修复条目与测试,未修改前端页面或可视化渲染视图(已检查 loopx/control_plane/ 与 docs/)。未验证视觉部分:无新增或修改的前端 UI 渲染。在可观测语义(observable_semantics)与决策文本评估(decision_text_assessment)上,基线与 HEAD 之间对 todo_write_hint、维护提醒与 todo_domain_record 字典的简化有明确授权且非标准分支保真,但对 spend_policy 的文本裁剪产生非预期语义漂移;代码规模与兼容性(code_volume)保持外层/内置适配器边界(retain),默认不改变通用适配器或原文件捕获,但架构所有者需在 turn_envelope.ts 将 Worker 模式解释与外层扣额指令解耦后,再以当前精确提交重新验证。

English verdict: REQUEST_CHANGES at 9944eaa. Preserve the one_step: mode, not an operation limit semantic boundary in the built-in Worker task context when removing outer-executor quota debit instructions from heartbeat_recommendation.spend_policy.

@mergify

mergify Bot commented Nov 20, 2026

Copy link
Copy Markdown

This pull request has merge conflicts with main and cannot be merged
until they are resolved. Please rebase or merge the base branch, @cocolord.

Choose the remote for the base repository, not an out-of-date fork.
For a fork clone, first inspect git remote -v; upstream must point
to https://github.com/loopx-project/loopx.git. If it is absent, add it
with git remote add upstream https://github.com/loopx-project/loopx.git.
Then run:

git fetch upstream
git rebase upstream/main
# Resolve each conflict, git add the resolved files, then git rebase --continue.
git push --force-with-lease origin HEAD

For a same-repository clone whose origin points to
https://github.com/loopx-project/loopx.git, use origin instead of
upstream for fetch/rebase. If you prefer merging the base, use
git merge <base-remote>/main and push normally.

Keep the DCO Signed-off-by trailer on every commit when you rebase.
https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify Bot added the needs-rebase Mergify: the pull request has merge conflicts with its base branch label Nov 20, 2026

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator

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=low

动机 / Motivation

内置 Worker 执行已准入任务时,原上下文还带着外层执行器负责的 Todo 创建、扣额和空观察回执,增加重复指令,也容易混淆执行与结算职责。本提案让 Worker 保留任务、范围、必需读取和执行要求,将已识别的例行执行器信息留在外层;这是有用的呈现边界改进。本次不涉及重新授权、改变准入决策或完成整个 C1 迁移,实际模型是否因此交付得更好仍未测。

独立依据为改动前 docs/reference/protocols/loopx-turn-v0.md,revision 5cfd6ae7d571f2f97da40982db23f76540723c89 的 Built-in model renderers 段。按该段审查三项:PROTO-TASK 保留任务事实、未知新增信息和必需读取;PROTO-OWNER 执行与结算仍由外层拥有;PROTO-SOURCE 原始 hash/capture 不被呈现对象替代。当前测试支持这些核心路径;完整 base/head 真实 CLI 观察配对及本头独立安装包往返仍未验证。

改动思路 / Approach

在已验证完整来源之后,继续由现有 TypeScript hostModelContextChanges 派生任务视图,比让每个 host 自行删字段更合适。空钩子、未配置召回和就绪租约只在已知完整形状匹配时压缩,扩展或异常记录保留;未知策略原文也保留。普通工作段的说明由两个内置 renderer 共享,修正了旧评审指出的工作量指导丢失。

当前 PR 的合理边界是这一可验证的呈现改进;最小修复是让现有 typed owner 提供已经解析的工作模式或指导,Python 只运输它。新增 Python legacy 字段读取使迁移成本反向增长,不能因功能测试通过而保留,也无需为此扩大到整体重写。

具体改动 / Changes

审查完整 5cfd6ae7d571f2f97da40982db23f76540723c89..ade4680f15bc039736c718d7800acb52dfd8ec74:16 文件,+522/-41。六个生产文件覆盖 hook 投影、Todo 字段字典、Worker 任务视图、租约形状判断与两个 Python renderer;六个测试/夹具文件补充源保护、长文本、扩展信息和安装版断言;四个文档/规则文件披露默认呈现变化。

projectEmptyTurnStartObservations 要求空观察、无失败/必读及所有效应标记为 false;isKnownReadyLeasePreparation 复用原就绪记录构造并核对 Agent/Todo、proof 和三个载体的一致性;disabledRewardMemoryView 只接受精确未配置状态。ordinary_work_segment_instruction 同时接入 Codex 与 structured prompt。通用 adapter 和历史 envelope 的运输边界未被这组呈现函数替代。

[P2] 避免新增 legacy 字段的 Python 消费者。 loopx/control_plane/turn_driver/host_candidate.py:319 新增读取 heartbeat_recommendation。使用仓库相同 field-use inventory 对不可变 base 与当前 head 扫描,Python migration surface 从 13 增到 14,reader 模块从 6 增到 7;预算 ledger 与 smoke 均未改。标准 quick premerge 和独立 smoke 都失败:legacy field heartbeat_recommendation now needs 14 .py modules migrated; budget is 13。这里限制的是迁移面 13,并非另一个 token 上限 17。请把该判断放回既有 typed owner,向两个 renderer 交付解析结果,保留普通工作段说明和未知策略原文,再运行 uv run --extra test python examples/semantic-vocabulary-drift-smoke.py 与同 base 的 quick premerge。不要用改名隐藏读取或无证据抬高预算。

对主干的风险 / Risks

PASS:File/SQLite 两个完整 Python 测试文件共 163 项,为限制临时磁盘占用按相同 collected test ID 分 17 批执行,所有批次 exit 0;未删断言。之前单次整跑 exit 120/ENOSPC 保留为环境失败,不改称一次整跑成功。PASS:同一 exact head 的两个 TS suite 104 项。这些验证覆盖长任务、未知数据、停止条件、原始 capture 不变和伪造投影视图拒绝;不能证明真实模型采用了指导。

FAIL:本头 quick premerge 的 semantic-vocabulary 检查及独立复现,已归因于上述新增 reader。其他 direct diff/bilingual、编译和公共边界检查通过;maintainability advisory 不冒称已完整归因。UNVERIFIED:当前 head 的独立 installed Core 资格与完整同输入 base/head CLI 观察配对;安装测试源码的新增断言和作者旧头结果不替代实际执行。遵循本次配置,未查询或等待 CI。

我的整体评价 / Verdict

REQUEST_CHANGES,绑定 ade4680。旧评审的普通工作段说明缺失已有明确修复;本次重新检查完整提案后发现新的必检迁移预算回归。请在现有 typed 投影边界完成最小修复,并补齐上述实包/配对证据后按新 head 复审;不要求本 PR 承担无关维护问题。

视觉审查不适用:改动路径为内置 Worker 输入及协议文本,没有 rendered page 或布局变化;未验证范围为真实模型理解和当前独立安装包行为。它们没有被测试数量或呈现字段齐全替代。未批准、未合并。

English verdict: REQUEST_CHANGES at ade4680. A new Python legacy-field reader raises the migration surface from 13 to 14 and fails required premerge validation. Python 163 and TS 104 tests pass; installed-Core and full paired CLI qualification remain unverified.

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator

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.2-sol · OpenAI · runtime_reported · xhigh

动机 / Motivation

运行受治理 Turn 的宿主需要把完整任务与必读资料交给 Worker,并自己负责认领、结算和扣额指令。 旧版在 Worker 视图中仍显示部分外层执行规则。新版收起一些维护、准备和记账内容,保留权威原包并补充普通推进提示。 已验证两条模型呈现路径仍能读到原任务与校验条件。当前提交的旧字段迁移预算失败,陌生推进策略与新增通用指令也可同时出现。 此次评审覆盖既有 Worker 投影、原始输入与语义回归。模型采用及预算对等后的成果收益待另行验证。

改动思路 / Approach

将原始签名输入和模型呈现分开是合理的交付边界。TypeScript 已持有标准扣额指令是否可剥离的判定。让它提供同一份工作指导,两条渲染路径只负责排版,可以保留语义前提和避免新增 legacy 消费端。既有作用域和原始恢复留在原入口。

具体改动 / Changes

对照原有的完整输入、Worker 任务视图及不改写来源契约检查。Turn 协议 · 迁移预算

  • WORKER-INPUT 已实现。现有任务、必读内容和校验信息仍到达两种呈现路径。标准推进模式的已知扣额条款可由外层结算持有,原包及摘要保持可读。
  • POLICY-PARITY 当前提交未满足。保留的未知规则可能明确只允许运行一次操作,两个 Python renderer 仍会加入 one_step means one work segment, not one operation。两条指令在实际渲染中并存。
  • LEGACY-BUDGET 当前提交未满足。新代码使 heartbeat_recommendation 的 Python migration surface 达到 14,高于已登记的 13。此数值计算需要迁移的消耗面,独立于字段词元预算。

对主干的风险 / Risks

P2 把工作段提示交回已拥有剥离判定的投影。 Python 新读取旧 heartbeat 字段使语义检查失败。并且未知规则在 TypeScript 层会按契约保留,Python 却按更宽松的 mode 条件无条件生成提示。独立以 File 和 SQLite 的已检查任务构造未知规则,分别走 Codex 和 structured renderer,验证原单次限制及新提示一起到达。给两种呈现路径消费同一投影结果,在现有规则确实被替换时才生成解说,保留原始签名输入不变。修订后需重跑语义检查及标准、未知、非普通模式的对照测试。

本地真实 File/SQLite 宿主传输套件为 163 passed,基线和当前提交分别通过六项呈现对照。语义检查在基线通过,在当前提交失败。 Full semantic-vocabulary-drift-smoke shows heartbeat_recommendation Python migration surface 14 against accepted limit 13. 远端 CI 未检查。

我的整体评价 / Verdict

检查精确提交的 Codex 和 structured Worker 输入、实际 CLI 与既有协议文档,改动没有渲染界面。 本次未独立重建该提交的安装版或运行真实模型。 当前已独立审阅 ade4680f15bc039736c718d7800acb52dfd8ec74,保留变更请求。新增 legacy reader 令 Python migration surface 达到 14,超过既有 13 的门槛。

English verdict: REQUEST_CHANGES

Project the Worker task view from the checked v1 source via TypeScript hostModelContextChanges, move outer-executor maintenance warnings, Todo write templates, dictionary bloat, settled ready leases, inactive hook/memory envelopes, and standard one_step accounting out of task_context while keeping TypeScript as single owner for ordinary_work_segment_guidance.

Signed-off-by: LoopX Agent <[email protected]>
@loopx-agent
loopx-agent force-pushed the codex/minimal-worker-context-20261119 branch from ade4680 to 521617d Compare November 26, 2026 14:45
@mergify mergify Bot removed the needs-rebase Mergify: the pull request has merge conflicts with its base branch label Nov 26, 2026

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: model_agent · Gemini · Google · self_reported

动机 / Motivation

内置 Codex CLI 和通用结构化 Host 启动的 Worker 任务视图,以及持有完整已签名 Turn 决策与收尾结算权的外层 Turn 执行器和运维方。

改动前 Worker 任务上下文直接携带外层发布资格、归档警告、三条 Todo 写入命令模板、重复字段字典、已对齐的就绪租约事务记录,以及混合了单次扣额要求与 work-segment 含义的 spend_policy,且早期方案把模式说明判据放回 Python 后增加了迁移面并覆盖未知规则;改动后由 TypeScript 校验完整来源后统一投影 Worker 任务视图(保留任务事实、原始摘要、有效召回/观察及未知策略),并用单布尔标记 ordinary_work_segment_guidance 通知 Codex 与结构化 Host 呈现工作段指导。

在已安装独立 loopx-core 2.4.1 wheel 的 File 与 SQLite 双后端及 Codex/结构化 Host 对比中,标准 steering_audit_then_one_step 的 Worker 提示不再包含外层命令模板、维护警告、已就绪同代租约事务、已登记 Todo 字典、已知空观察细节与常规 spend_policy,同时保留任务、execution_profile、work-segment 指导、source_decision_hash 与原 capture 一次结算;自定义 spend_policy 与非普通模式则原样保留原文且不注入通用指导。

本 PR 仅收窄内置 Host 呈现给 Worker 的任务上下文与工作段提示判定,不改变完整已签名 decision/capture 的持久化格式、外层执行器结算与重试边界、自定义或未知策略语义,也不宣称完成真实云端 LLM 成本或全量多轮端到端模型质量评测。

改动思路 / Approach

本次沿既有 turn_envelope TypeScript 核与 Python Turn Driver 分层演进:以 TypeScript hostModelContextChanges 与 usesStandardOneStepWorkSegment 作为唯一派生投影和工作段判定 owner,Python Host 呈现端只消费布尔标记而不新增 legacy heartbeat_recommendation 字段读取,职责正交且可逆。边界仅限内置 Worker 呈现投影、空状态摘要压缩与已就绪匹配租约展示隐藏,完整 source、效果授权和结算仍在原外层所有者。

完整签名决策在 completeHostSource 中完成校验后,经 hostModelContextChanges 生成仅用于 Worker 展示的路径删改列表(object() 浅拷贝不修改已捕获的 decision 原对象),再由 Python projected_host_model_input 保留原始 Python 数值、身份与 detail_ref / source_decision_hash 应用到 task_context。针对标准 steering_audit_then_one_step 模式,TS 侧 usesStandardOneStepWorkSegment 同时控制外层 spend_policy 移除与 ordinary_work_segment_guidance 布尔输出,使 Codex (codex_cli.py) 和通用结构化 Host (host_candidate.py) 在统一来源语义下避免任何 Python legacy 读取扩散与未知规则冲突。

具体改动 / Changes

对照 docs/reference/protocols/loopx-turn-v0.md(提交 521617d3641354081c28306bcd6db6c84499c60a,自 406f1cd76acb88c1f91fe43fe35b74df583b6eaa 起共 16 文件 +602/-29,对照目标 521617d3641354081c28306bcd6db6c84499c60a,与 origin/main e9bcad9aab48842459252c7347bd8fdbdde866db 无冲突合并树 fbee61dc8e15bfce0bd38abfb880b54d6e6f4dc0):

  • REQ-WORKER-STRIP(implemented):外层维护警告、Todo 写命令模板、已配置格式的重复 contract_fields 字典、已知禁用记忆召回、已知全空启动前观察与匹配的就绪租约事务记录仅从内置 Worker 视图剥离,有实际数据/失败/未知字段时完整保留。
  • REQ-TS-SEGMENT-OWNER(implemented):由 TypeScript usesStandardOneStepWorkSegment 统一判定标准 steering_audit_then_one_step 工作段指导;两个 Python 呈现端仅读取该布尔结果,零新增 heartbeat_recommendation Python 读取且不改动未知 spend_policy。

关键代码讲解

  • usesStandardOneStepWorkSegment 与 hostModelContextChanges:精确匹配 normal_delivery_allowed === true、recommended_mode === "steering_audit_then_one_step" 与标准 STANDARD_ONE_STEP_SPEND_POLICY,同步控制 spend_policy 剥离与 ordinary_work_segment_guidance 布尔输出;并在 isDeepStrictEqual 精确匹配禁用召回、全空钩子分发与匹配就绪硬租约时收敛展示载荷。
  • projectEmptyTurnStartObservations 与 isKnownReadyLeasePreparation:限定仅对字段数严格匹配、全 empty/not_applicable 无错误/无必读的启动前观察与完全匹配当前 agent_id/todo_id 的就绪 hard_lease 准备记录执行压缩或隐藏。
  • compactTodoContextSource:同时覆盖 loopx_todo_canonical_read_record_v0 与 loopx_todo_domain_read_record_v0 两种已登记格式,在 contract_fields 全为字符串时移除字典、保留 records_sha256 等元数据,未知 schema 原样返还。
  • ordinary_work_segment_instruction 与 _render_prompt:统一消费 TS 返回的 ordinary_work_segment_guidance / _ordinary_work_segment_guidance 布尔开关,不在 Python 层解码业务策略。

对主干的风险 / Risks

语义与 CI 对齐

  • 所有既有词汇(heartbeat_recommendation、execution_preparation、turn_start_capability_hook_dispatch、reward_memory_recall、todo_read_model)均复用已有契约边界,examples/semantic-vocabulary-drift-smoke.py Clean-HOME 通过;docs/architecture/rfcs/monorepo-distribution-split-v0.md 与 .zh-CN.md 同步更新并经 check_rfc_bilingual.py --base origin/main --head HEAD 通过。远端 GitHub Actions CI 未等待或引用(wait_for_ci: false)。
  • 四条历史 [P2] 评审线程(工作段指导丢失、Python 新增 heartbeat_recommendation 读取超迁移预算、未知 spend_policy 误注入通用工作段提示)已在精确提交 521617d3641354081c28306bcd6db6c84499c60a 闭环解决:严格字符等价匹配 STANDARD_ONE_STEP_SPEND_POLICY 会保留所有含附加约束或定制格式的策略文本;非普通/未放行 Turn 同样退回原样保留,仅在自定义规则扩展了标准文本前缀或后缀时保守回退到原文展示。
  • 针对核心契约的非阻塞静态检查对比:pyproject.toml 配置的 17 文件 mypy 在基线与 HEAD 均为预存 50 个错误;受影响 53 个 Python 调用方全量比对在所有 12 个 loopx/ 文件与 3 个 packages/ 包文件均 0 回归,仅 PR 自改的两个未全面标注测试文件(test_turn_host_decision_capture.py 155→156、test_work_context_host_delivery.py 16→21)新增测试辅助函数存在 [no-untyped-def]/[no-untyped-call] 静态提示,不影响运行与分发边界。

我的整体评价 / Verdict

本地实证覆盖充分,建议批准 (APPROVE):

  • 验证实证汇总:npm run typecheck:control-plane 0 错误;6 个 control_plane_ts 套件 164/164 通过;基于 prepare.py 在隔离虚拟环境实地构建安装独立 loopx-core==2.4.1 wheel 后,顺序运行 tests/test_core_distribution.py 与 tests/control_plane/test_installed_core_context.py 58/58 全通过(0 跳过),验证 File 与 SQLite 双后端 Codex 实际输入与单次结算完整;关联 Python pytest(test_work_context_host_delivery.py、test_turn_host_decision_capture.py、test_complete_turn_decision.py、test_loopx_turn_codex_cli.py 等及 tests/architecture/、tests/canary/)2,771 passed, 6 skipped(6 项为 tests/canary/test_git_path_display.py APFS 文件系统跳过);ruff 与触及 loopx/ mypy --strict 全通过;loopx check --scan-path 对全部 16 文件零边界报错;Goal canary premerge --tier standard 19/19 通过(0 失败/0 人工拦截);基线 e9bcad9aab48842459252c7347bd8fdbdde866db 与精确头 521617d3641354081c28306bcd6db6c84499c60a 实测 turn plan 配对反事实验证 4 种模式开关行为精确对齐。
  • 长程、用户体验与视觉审查:long_horizon=preserved、user_experience=improved;visual_review=not_applicable(原因:仅涉及 CLI/Host Worker 提示与 JSON 上下文投影,无前端可视化页面改动;unverified_scope=none);真实云端模型多轮效果/成本与远程 CI 为本切片外范围(以可复验的内置 Host 边界与 wheel 验证为界)。词汇复用既有 loopx_turn_envelope_v1 契约且零新增 Python 兼容债务。

English verdict: APPROVE at 521617d. TypeScript now owns ordinary_work_segment_guidance and strict hostModelContextChanges stripping, leaving zero new Python heartbeat_recommendation reads and passing all standalone loopx-core File/SQLite wheel (58/58), TS (164/164), broad pytest (2,771 passed, 6 APFS skipped), and standard canary premerge (19/19) checks.

This branch has not been deployed

No deployments
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