Repository navigation
fix(turn): preserve original decision across Host detail and retry - #6350
Conversation
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent | gpt-6-astra | OpenAI | runtime_reported | reasoning effort: high
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
动机
运行原生 Turn 的调用者在任务变化后补读上下文时,会遇到短包与详情不一致。旧版在任务已更新后重新运行 guard,详情变成新内容;本提交让实际 Host 补读和失败重试始终拿到首次观察。同一真实 CLI 对照在 File 和 SQLite 上均复现旧版错误,并在本提交保留原观察;重试只结算一次。本次不宣告整个上下文迁移、Python 退役、真实模型效果或 App/Lark 验收完成。现有 RFC 中的统一 Host 投影、真实 App/Lark 消费和整体效率验收仍未完成。
改动思路
原决策绑定复用 TypeScript owner,Python 只负责文件 IO;现有 journal 已有身份与重试归属,无需另建状态机。本 PR 一次交付原生 CLI 生产者、持久化、实际 Host 消费和恢复,统一投影与 App/Lark 验收留在既有 RFC。不修改当前任务选择、lease 或结算规则。保存的完整决策是历史证据,不能代替当前准入。第一次执行由已有 journal 锁保护原子发布,之后由同一 journal 引用读取;原文件不存在或哈希不符时必须恢复原证据。只传一个路径无法保证首次观察存在,仅复用 quota 的显式开关也覆盖不到真实原生生产者,因此本次连接生产者、TS 校验与 Host 消费具有必要性。quota 原子 JSON 写入体合并复用,是本次有界的去重复。
具体改动
精确 head:8896684ccc2c6e66c6a29b088f14e90ae770f47f。按接受的 docs/architecture/rfcs/agent-loop-effect-interpreter-v0.md,版本 71304fcbdd7402cfd4355fffc397079fe37d0c34 审查,随后检查本次 checkpoint 是否夸大结果。
Adopt one typed projection in real host renderers:本次实现 native producer/detail 子路径;真实 File/SQLite 和实际子进程验证原观察与一次结算。Reconcile execution/context requirements across heartbeat and TurnEnvelope:deferred,现有 RFC 继续承接完整上下文与可选能力矩阵,没有宣告 Python 投影已退役。Qualify the context shape and migration default:deferred,不把这次传输修复当作整体效率或自然运行验收。
关键代码讲解
execute_turn_run_once接收原完整 decision 并要求真实执行捕获;resume 从 journal 取原观察,预览仍在任何写入前返回。prepare_turn_decision_capture读取或首次保存快照;位置在 journal 子目录之外的文件枚举范围,权限为私有;缺失、损坏和旧 journal 无来源时都明确拒绝重启 Host。bindTurnDecisionCapture留在既有 TS owner,核对 Goal/Agent、canonical source hash 和已绑定的 Turn/key/path;只替换详情引用,保留原 action signature。run_loopx_turn_once在现有 recovery 判定后且 Host/admission 效果前调用捕获;终态回读和已有 typed result 的结算恢复不再启动 Host,因此不要求补造快照。
新增测试覆盖两种真实存储、正常与失败重试、原始子进程输入、native CAS 源变化、缺失/损坏拒绝和终态无副作用。两份文档披露 native execute 默认保留历史观察及旧 journal 恢复限制;没有新增产品开关、配置页或独立能力。
对主干的风险
主要风险是历史文件丢失使重试停下,以及私有上下文随 journal 保留。代码不会以新 guard 静默代替原观察;恢复原文件后,实际 File/SQLite 重试能够提交并保持单次 spend。第一次失败的模型 provider 是协议替身,故不能据此宣称真实模型、App/Lark 或长期运行已通过。原未知网络错误夹具不属于既有 capacity 分类,已改用明确受支持的失败状态;未声称修复一般未知进程退出。
167 个既有 driver/CLI 测试、16 个捕获/opt-in 测试、31 个 TS 测试与类型检查通过。正常 wheel 的四种隔离安装场景通过,1095 个模块均来自安装包,七个运行时文件与本 head 字节一致。同一对照脚本在不可变基线与 head 均通过真实 CLI:旧版两种存储补读均返回 B,新版均保持 A,spend 都为一次。风险 canary 的执行检查通过,独立基线可维护性债务仍记录 failed:未改动模块 2007 行超过 2000;完整 base/head 诊断相同,没有调大预算。CQR 对 PR 不可变基线有效;主干在验证期间继续前进,最新 main 的集成/CQR 刷新仍是独立合并前置。按本 Goal 策略未查询或等待 CI。
语义与 CI 对齐
复用既有 capture/detail 与 source hash 词汇,bind_capture 是 owner 内部操作,不新建共享状态协议。默认改变明确限定原生执行;普通 quota 的捕获关闭路径以及计划预览保持原契约。机器强制完整性校验与给 Host 的说明分开,旧观察不授予权限;无领域专用义务或字符串黑名单。
我的整体评价
没有发现该精确提交的阻塞性问题,结论为 APPROVE。long_horizon 与 user_experience 在本地传输范围内 improved:失败重试能继续使用同一历史上下文,普通执行无需人工准备文件,损坏状态有明确恢复路线。此判断不等于长期自然运行或整体迁移完成。旧 journal/低层 adapter 的兼容保留有真实调用方与持久化依据;无需引入第二状态机,当前去重复已完成。PR 当前基线之后的主干更新、维护者合并授权和实际安装验收独立保留,未执行合并或全局安装。
English verdict: APPROVE - 8896684; original native Host decision capture and retry are verified through real File/SQLite CLI and installed protocol-host scenarios. Baseline maintainability debt, moving-main integration and live App/model acceptance remain separate; no merge performed.
Goal And Delivered Outcome
Native Turn Hosts previously received a detail command that reran the guard. After the canonical Todo changed, that command returned a new decision although the signed compact frame still described the original observation. This change captures the full decision before Host invocation and reuses that exact observation for detail reads and failed-attempt retries.
Base:
mainat71304fcbdd7402cfd4355fffc397079fe37d0c34. This closes the native producer-to-detail transport gap in the existing agent-loop convergence work.Author Declaration
Written by: model_agent — OpenAI GPT-6 (Codex).
Implemented against
docs/architecture/rfcs/agent-loop-effect-interpreter-v0.md(remaining native Host adoption row) anddocs/reference/protocols/turn-envelope-v0.mdat the base above.Scope And Continuation
Native
turn run-once --executenow retains private full-decision evidence by default. Ordinary quota capture remains opt-in; planning/inspection stays read-only. No new capability or switch is introduced. TS owns binding semantics; Python handles private atomic file IO. The bounded refactor shares the existing quota capture writer rather than creating another decision owner.Old terminal journals and cached-result settlement recovery remain readable. An old journal without the original capture cannot safely launch another Host: preserve its pending effects, recover them through the existing path, then start a new admitted Turn. Missing/corrupt captures never trigger automatic guard reconstruction. Captures stay outside journal-file enumeration.
This is complete as a native transport repair; the existing RFC retains remaining host projection and live App/Lark/model acceptance. No global install or merge is included.
Validation
Tested source:
8896684ccc2c6e66c6a29b088f14e90ae770f47f; finished; synthetic/public fixtures only.npm run typecheck:control-plane, semantic advisory/full drift smoke, registry IO manifest and diff checkscanary premerge --from-git-diff --git-diff-base 71304fcbdd7402cfd4355fffc397079fe37d0c34: gate passed with valid CQR; unchanged maintainability debt remains separately failed/advisory. Main advanced during validation, so current-main integration is still separate.goal_frontier/__init__.pyhas 2007 lines against 2000. No budget changed.The Host model provider is a protocol fixture. This does not qualify actual models, packaged App/Lark journeys, PostgreSQL authority changes, Windows or sustained natural operation. Initial author wiring and fixture failures were repaired and superseded by the final affected suites; the original broader program's unresolved failures are not closed here.
Frontend / Visual Evidence
UI impact: none. This repairs an existing native Host transport; no frontend settings, capability editor or public first screen changes. Packaged App/Lark convergence remains separately open.
Type / Area / Direction
Bug fix, focused IO reuse, protocol documentation and regression tests. Control plane / Host runtime integration; existing agent-loop Effect interpreter convergence. No provider promotion, storage routing or authority-store refactor, so PostgreSQL three-arm promotion qualification is not claimed.
Boundary Checklist