Repository navigation
Resolve native session recovery from built-in host descriptors - #10034
loopx-agent wants to merge 2 commits into
Conversation
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
…t usage to Codex Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
|
This pull request has merge conflicts with Choose the remote for the base repository, not an out-of-date fork. 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 HEADFor a same-repository clone whose Keep the DCO |
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh
Request changes conclusion (author-owned PR; GitHub blocks formal self-review)
- [P2] 冻结时核对整份绑定,保留同 ID 的 profile 更新。File 和 SQLite 上,Turn 已得到有效 Todo 交接后,另一个合法 CAS 写入保留相同 native session ID,仅更换该绑定的 profile digest。锁内只比较 ID,CLI 仍实际启动新会话、传入旧交接并结算,刚写入的绑定被替换。基线同样复现,这次变更仍漏掉所声称的绑定变更保护的一条路径。 将已验证的绑定文档或其稳定摘要与备份锁内读取配对,同时保留显式的无绑定状态。绑定变化时回到现有模式及其 profile 校验,补同 ID 换 profile 的 File/SQLite 回归。 执行入口
动机 / Motivation
原生会话恢复需要验证既有宿主归属并保留并发更换后的绑定。 将合法文件及 schema 交给内置宿主描述符。使用普通会话选择器做所有权校验,并在锁定备份时核对原证据。 Candidate 在 agent 和 todo 都拒绝共享文件里的 DSH 受管记录。保持合法绑定时执行 fresh,备份前换 ID 时改走 resume、保留新绑定。Codex 继续读同 ID 的本机样本 119,DSH 不取该用量。 本轮只运行隔离 CLI 和本地 stdio,未调用远端模型。
改动思路 / Approach
七文件 +206/−29,涉及描述符注册、会话读回、交接冻结和结算计量。 verified handoff 与备份使用相同文件和宿主 owner,但连接两次读取的条件只有 session_id。该存储本身用 session ID、GoalRef 与 profile digest 区分绑定依据。
选择器复用方向正确。把范围、宿主、生命周期和写入版本合为同一冻结读取可避免重复规则。
具体改动 / Changes
- HOST-OWNER。异宿主记录拒绝,独立外部描述符仍无存储权。 独立验证通过。 capabilities.py
- BACKUP-RACE。真正更换绑定时保持已验证原请求边界。 配对反例见 P2。 turn_hooks.py
- CODEX-USAGE。DSH 不能取得同 ID 的 Codex 样本用量。 独立验证通过。 codex_sessions.py
关键代码讲解
- 备份锁之后只对比 session_id。 prepare_planned_iteration_context_for_strategy
- 复用已授权宿主自己的选择器识别缺失与无效。 read_recovery_session_binding
- 从固有描述符查询 record schema。 builtin_native_session_schema
- 只有 Codex 读 Codex rollout。 _append_epoch_ledger_and_measure_baseline
- 新测试覆盖不同 session ID 的替换。 test_binding_replaced_before_backup_keeps_requested_session
对主干的风险 / Risks
109 项相关测试通过。基线和候选分别运行六个实际 CLI 夹具,另配对 agent/todo 的跨宿主拒绝和同编号用量。 standard premerge 6 项直接、10 项选中检查无阻断,含全库维护性 advisory。 正常、不同 ID 替换及异宿主各有独立正反例。
原有完全相同的文档会走有效 fresh,换 ID 回退已验证。同一 native ID 可以由一次新的绑定写入保留并更新 profile。
我的整体评价 / Verdict
需要修改。 宿主归属和用量隔离成立。同 ID 的 binding 更新仍可能被旧交接覆盖。
变更作用于会话存储、宿主描述符和执行冻结。 OAR 验收来自作者的组合分支。本轮结论限所审候选与原有绑定和内置 Codex CLI。
远端同时报告该头与目标分支有冲突。保持 PR 开放。
English verdict: REQUEST_CHANGES at 4fc4fe3. Request changes. Host ownership and usage isolation work, and a changed native ID is protected. The exact head still dispatches a fresh reset with stale handoff facts and overwrites a newer binding when only its profile changes under the same session ID.
| host=host, | ||
| ) | ||
| if isinstance(existing_doc, dict) and not existing_doc.get("malformed"): | ||
| provenance = _as_dict(pending.get("staged_provenance")) |
There was a problem hiding this comment.
[P2] 冻结时核对整份绑定,保留同 ID 的 profile 更新
File 和 SQLite 上,Turn 已得到有效 Todo 交接后,另一个合法 CAS 写入保留相同 native session ID,仅更换该绑定的 profile digest。锁内只比较 ID,CLI 仍实际启动新会话、传入旧交接并结算,刚写入的绑定被替换。基线同样复现,这次变更仍漏掉所声称的绑定变更保护的一条路径。 将已验证的绑定文档或其稳定摘要与备份锁内读取配对,同时保留显式的无绑定状态。绑定变化时回到现有模式及其 profile 校验,补同 ID 换 profile 的 File/SQLite 回归。
Session recovery
The context-strategy hooks used three copies of the same host-name list to decide whether to inspect a native session. The session store kept a fourth copy to select the record format. A built-in host now declares the local record format alongside its ordinary session filename. The store and the hooks use that declaration for handoff verification, pre-launch backup and settlement.
Codex CLI and DSH retain their existing record formats and file locations. An external registry entry or runtime alias cannot opt into another host’s records. Portable capability descriptors keep their current shape. The Codex rollout reader remains specific to its native artifact format.
Cross-host recovery
Codex ordinary sessions and DSH managed operations can use the same legacy filename. Previously a matching session ID in that file passed Codex handoff verification even when the record belonged to DSH. Verification, backup and settlement now use the ordinary-session selector to validate the host, record format, scope and lineage. Preparation keeps the requested session when the binding changes before backup. Only a Codex binding can supply usage from a Codex rollout.
Verification
OAR integration readback
A separate local checkout combined
4fc4fe31b2b3with the OAR ordinary-session transport from #9982, Todo-scoped provenance from #9934 and the conditional session replacement from #10006 adapted to the OAR handle. Each case used the native OAR process, a deterministic model endpoint and an isolated Goal store.The six results qualify this source combination. Shipping the OAR adapter still depends on integrating the context strategy on its own branch.
中文
恢复流程从内置宿主声明读取会话格式。Codex CLI 和 DSH 可以接回已有记录,其他宿主仍会校验交接材料。File 和 SQLite 两种后端均已验证跨进程接续、受管会话保留和失败轮次零扣额。
在独立工作区接入 OAR 传输后,两种存储后端均通过成功换会话、失败回退和并发保留后来写入三种验收。OAR 适配仍待在阶段二分支集成。
补齐共享文件名下的归属检查。Codex 交接遇到 DSH 受管记录时保留原会话,DSH 的结算也排除了同编号 Codex 日志的用量。