Skip to content

Keep steward history inspection outside input locks - #8305

Merged
huangruiteng merged 1 commit into
mainfrom
codex/steward-nonblocking-inspection-20261108
Nov 9, 2026
Merged

huangruiteng merged 1 commit into
mainfrom
codex/steward-nonblocking-inspection-20261108

Conversation

@loopx-agent

Copy link
Copy Markdown
Collaborator

Goal and delivered outcome

When a steward checks Turn history or report recovery, its read can hold the same locks that admit new conversation input. A slow read can leave a user waiting before their message even enters the queue. This change performs both read-only inspections outside those locks. It rejects a binding change before using the result, and still checks authority, queue state, and request identity under the existing admission fence when accepting a new Turn.

Author declaration

  • Written by Codex (OpenAI).
  • Specification basis: the reproduced same-session contention described above. Target: main.
Criterion Disposition Evidence
New input can enter the original queue during initial inspection and report recovery Implemented Real StewardTurnHost.submit and same-session queue admission, with history deliberately paused
Queued input retains priority; a binding change during inspection is rejected Implemented File and SQLite cases verify no new native worker starts and an existing failed report is retained

Scope and continuation

This is a transport fix for the read-only inspection. It leaves the final acceptance fence, report scheduling, and delivery behavior in their current owners. Installed latency and production delivery need separate verification after adoption. UI impact: none. Shared-authority fixture impact: none.

Validation

Tested revision: 71396bca5f0f999edd5a448b220091cd73e5e31d. Run state: finished. Input classes: synthetic, public fixture.

Check Result Evidence
Regression and real local entrypoint Passed 30 focused steward tests. The four new cases time out admitting ordinary input on the unchanged implementation and pass with the fix, across File and SQLite.
Static and premerge Passed Ruff, diff hygiene, and standard diff-selected premerge (six direct checks and two catalog checks).
Broader regression comparison Failed on both A wider exploratory run on the same patch before rebase completed 69 cases before stopping: 57 passed, 12 failed. All 12 failing test IDs reproduced on the unmodified target base; the remainder of that wider run was not completed.
Hosted CI and installed acceptance Pending Review and CI apply to this exact head. No live service was updated for the test.

Only the runtime file and its regression test changed. The commit includes a DCO sign-off and contains no private evidence or generated artifacts.

Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>

@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.1-sol, OpenAI, runtime_reported, reasoning_effort=max

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

评审提交 71396bc,对照基线 dee5496。

动机 / Motivation

当管家正在查找历史或恢复日报时,用户仍需要把下一条消息送进原会话的队列。 旧版在初次查找历史和读取日报恢复记录时占着输入锁,用户的消息会等在队列外。新提交把这两次准备读取移到锁外,提交前再核对原会话和绑定。

在 File 和 SQLite 上,基线四种同会话入队场景均超时,新提交四种均通过。已入队的消息保留优先级,读取期间变更授权会拒绝恢复。 本次验证覆盖入队、原请求读回和准入复核。最终准入复核的历史读取仍占用输入锁,安装后的延迟有待实测。 最终准入复核遇到慢历史时,普通输入仍要等这次复核结束。真实部署上这一段的耗时尚未量化。

改动思路 / Approach

历史准备读取和最终准入继续归 StewardTurnHost。把可重试读取移出锁,将权威队列、授权和接受 Turn 保留在已有边界,避免新增协调状态。 当前改动交付两处准备读取的并发改进。最终复核继续验证请求身份,缩短这一段应由同一个准入所有者依据实际耗时再评估。

报告重试仍比对原 Turn 的状态、请求和执行证据。锁外读到的绑定仅用于准备。真正接受前,现有类型化准入继续检查会话、权限和排队状态;已经接受的同请求读回原 Turn。

具体改动 / Changes

运行代码 +19/−7,两个存储模式和两个停顿位置的回归覆盖 +81。完整差异只有 Steward host 和其测试。规范取自 docs/architecture/rfcs/app-conversation-and-async-inbox-v0.md @ dee5496,映射如下。原会话与恢复规范

  • Source-session queue:普通消息留在原会话,已经排队的输入仍阻止后台恢复。
  • Original report recovery:对原记录和当前绑定复核。读取期间更改报告证据会拒绝恢复。
  • No business replay:同一请求只读回原 Turn。替换 Todo 会被拒绝,独立对照确认只调度一次。

关键代码讲解

  • _submission_binding 在准备读的前后取得同一个绑定,观察到变更时返回授权变化错误。复用现有绑定存储和标识。绑定读取
  • _prepare_submission 从传入的快照查找原 Turn。日报额度观察之后重新比对原记录;如果报告在等待期间被更新,保留原记录并拒绝过期恢复。报告复核
  • StewardTurnHost.submit 在初次和额度观察后读历史时允许普通输入入队,在最后接受 Turn 时仍使用原有准入锁。两个存储后端各复验了同 ID 读回与冲突请求拒绝。准入边界 并发回归

对主干的风险 / Risks

PASS:4 个锁竞争场景基线均超时,新提交及与固定 main a3b5896 的临时集成树均通过。File/SQLite 两边各 4 个独立读回和报告变更场景通过。最终复核人为暂停时,两版的同会话消息均要等复核锁释放。控制实验使用真实存储和队列,宿主和延迟用合成边界。

PASS:标准 premerge 6 项直接、2 项选中检查通过,含语义词汇、RFC 配对和 Python 编译,Ruff 通过。更宽的测试中五个场景在基线和新提交失败签名相同,其中四个在下游 Turn route 拒绝,一个在延后结果的 retargeted 断言。变动路径的入队、读回和拒绝有独立通过证据。远端 CI 未查。

我的整体评价 / Verdict

本轮接受缩短两段准备锁的改动。持续工作仍沿用原会话和原请求,用户无需额外操作即可在准备读取期间入队。最终准入复核的耗时和安装宿主表现仍待测。语义沿用原绑定、Turn 和队列,保留现有权限检查。这两条路径没有渲染组件变化,视觉评审不适用。

English verdict: APPROVE 71396bc. Both preparation stages allow same-session enqueue, while original identity and final admission remain fenced. Final-lock latency and the matched baseline route failures remain open.

@huangruiteng
huangruiteng merged commit f8a0ebc into main Nov 9, 2026
25 of 42 checks passed
@huangruiteng
huangruiteng deleted the codex/steward-nonblocking-inspection-20261108 branch November 9, 2026 09:37
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