Skip to content

Resolve native session recovery from built-in host descriptors - #10034

Open
loopx-agent wants to merge 2 commits into
mainfrom
codex/native-session-storage-owner-075154
Open

loopx-agent wants to merge 2 commits into
mainfrom
codex/native-session-storage-owner-075154

Conversation

@loopx-agent

@loopx-agent loopx-agent commented Dec 3, 2026 •

Copy link
Copy Markdown
Collaborator

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

  • 98 host descriptor, session-binding and context-strategy tests cover both record formats, unowned hosts, registry overrides, changed bindings and changed handoff sources. Three CLI transport and iteration-failure tests also passed.
  • Before the correction, Agent- and Todo-scoped handoffs accepted the foreign record and DSH settlement attributed a same-ID Codex usage sample to DSH. The new regression cases cover all three results and a replacement between verification and backup.
  • Two local integration runs exercised the DSH Python SDK with a deterministic model endpoint, once with File and once with SQLite Goal storage. A first process committed a turn. A second process resumed the original assistant history and returned a controlled failure. The ordinary session ID and the managed session file were preserved. Only the accepted turn consumed quota. On each backend, both preview and executing preparation declined the foreign record, retained the requested session and preserved both session documents.
  • Ruff and the standard local premerge gate passed. The gate reported an inherited maintainability advisory.
  • This PR targets main. The Python SDK reset fix is tracked in #10006. OAR integration is developed on the Phase 2 branch.

OAR integration readback

A separate local checkout combined 4fc4fe31b2b3 with 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.

Case File SQLite Observed outcome
Accept a reset Pass Pass The next process read the successor marker and excluded the prior marker.
Reject the candidate Pass Pass An independent process recovered the original history. The rejected turn consumed zero quota.
Write a newer binding during the candidate Pass Pass The newer ordinary binding and separate managed record survived byte-for-byte.

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 日志的用量。

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>
@mergify

mergify Bot commented Dec 3, 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, @loopx-agent.

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 Dec 3, 2026

@loopx-agent loopx-agent 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 · 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,未调用远端模型。

审读提交 4fc4fe3,冻结基线 d346b50。

改动思路 / 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

冻结的接口契约 · 原有权威检查

关键代码讲解

对主干的风险 / 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"))

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.

[P2] 冻结时核对整份绑定,保留同 ID 的 profile 更新

File 和 SQLite 上,Turn 已得到有效 Todo 交接后,另一个合法 CAS 写入保留相同 native session ID,仅更换该绑定的 profile digest。锁内只比较 ID,CLI 仍实际启动新会话、传入旧交接并结算,刚写入的绑定被替换。基线同样复现,这次变更仍漏掉所声称的绑定变更保护的一条路径。 将已验证的绑定文档或其稳定摘要与备份锁内读取配对,同时保留显式的无绑定状态。绑定变化时回到现有模式及其 profile 校验,补同 ID 换 profile 的 File/SQLite 回归。

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

needs-rebase Mergify: the pull request has merge conflicts with its base branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant