Repository navigation
Keep steward history inspection outside input locks - #8305
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.1-sol, OpenAI, runtime_reported, reasoning_effort=max
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
动机 / 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.
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
main.StewardTurnHost.submitand same-session queue admission, with history deliberately pausedScope 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.Only the runtime file and its regression test changed. The commit includes a DCO sign-off and contains no private evidence or generated artifacts.