Repository navigation
fix(manager-context): avoid rereading delivered partial requests before work - #9013
loopx-agent wants to merge 5 commits into
Conversation
…re work 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 |
…eward-inbox-pagination-delivery-20261118t1346 Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com> # Conflicts: # loopx/control_plane/collaboration/peers.py # tests/test_delegation_turn_context.py
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com> (cherry picked from commit 7d17f53524f26038dfafde3d3340d6c129e1a5ee) Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com> (cherry picked from commit bfef2546228e18eeca7411f5357f5043c20d73ee) Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
…eward-inbox-pagination-delivery-20261118t1346 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.2-sol · OpenAI (runtime_reported, max)
Request changes conclusion (author-owned PR; GitHub blocks formal self-review)
-
[P2] 外发摘要页吞掉显式 operation cursor。 在同一次
manager-inbox read传入外发摘要游标和有效的独立操作游标时,当前头成功返回 1 条外发摘要,操作续页是 0 条。同一操作游标单独读取有 2 条,基线组合读取也有 2 条。外发页提前标记完成,让 Python 跳过已有投影。保留外发页的只读行为,并把显式操作查询交给现有 owner。 提前返回 -
[P2] 折叠部分简报前核对该请求的回传收执。 真实本地 Chat 回传恢复样本中,读到的收执带有另一请求的消息 ID。当前头仍将该请求标为已送达并省略全文。健康相邻请求的摘要仍可用。按当前请求及结果核查已送达证明,冲突时交付全文和恢复状态。 折叠判定
动机 / Motivation
每轮恢复委派工作的 Agent 需要先确认哪些任务还有待办,并读到本轮需要处理的收件和已确认操作。 以前必读命令会重复发送已经回过一部分的请求全文。新入口在正常交付时只给剩余工作摘要,遇到回传证据损坏时应继续交付当前简报。 预期可用结果是 Agent 读完有界分页,能找到后续工作并按请求身份取回原文,也能继续独立的操作分页。 改动范围是 Manager Inbox 的读路径与启动指令。决策、回传、操作授权和消费沿用各自现有入口。
改动思路 / Approach
启动 hook 为现有 Inbox 命令选择 --attention-only。TS 读取同一 Goal 的请求、剩余结果和可观察收执,Python 仍负责 CLI 包装。第一个阶段提供待决全文与部分结论摘要,接着从同一游标进入外发阶段。现有 Inbox 投影可以承接摘要和游标选择,修复应保留现有回传证据及 operation handoff owner。 本 PR 交付起始阅读的条件折叠和分页,审核聚焦准确收执、独立读请求与无重复投递。
具体改动 / Changes
审查依据是 docs/reference/required-work-context.md 在 07722b169a4edea313f6a17d12dd73819e3f8843 的约定。scoped-request-pages 的收件页和精读路径可用,unavailable-keeps-source 对可解析却指向他处的回传收执仍失败。原操作页的独立约定也适用于组合参数。 已接受的启动读取契约 独立 operation cursor 契约
关键代码讲解
deliveredRemainderSummary将部分收件按当前修订压缩到现有 agenda 形状。返回结果属于其他消息时,单凭显示状态无法支持折叠。 当前精简判定pendingPage给现有收件游标加外发阶段,并继续把已送达部分 work 显示在摘要中。精确请求仍能读回全部当前简报。 分页分派readCollaborationInbox在外发阶段跳过 peer result 重投递。已给出的独立 operation cursor 需要继续送达操作投影,否则调用者会误以为这一页已读完。 外发阶段短路
对主干的风险 / Risks
PASS 基线和当前头的常规 Turn/Inbox Python 用例分别为 28 与 29 项通过,各有 2 项 PowerShell 相关跳过。当前头的 TS 事务测试与两版 diff 检查通过。FAIL 独立真实 CLI 的两个回归断言只在当前头失败。故障后仍可分开读取操作页,并按 request ID 读完整简报。实际安装端表现和模型成本仍待量化。
语义与 CI 对齐
沿用已有 Inbox、回传与 operation 词汇。修改使启动读默认走摘要模式,调用者要能依赖准确的回传归属及各自游标。补齐两个反例后重跑 tests/test_delegation_turn_context.py 与 CLI 组合分页。本次验证采用本地执行。
我的整体评价 / Verdict
REQUEST_CHANGES。正确折叠可减少每轮重复简报,两个边界缺口会让后续工作调度和恢复读回变得不可信。现有 Inbox 投影可以承接摘要和游标选择,修复应保留现有回传证据及 operation handoff owner。 本 PR 交付起始阅读的条件折叠和分页,审核聚焦准确收执、独立读请求与无重复投递。 本改动沿用 Manager Inbox CLI 与启动文本,没有改动界面布局。修复后在更新的 head 重新判定。
English verdict: REQUEST_CHANGES at f16ed11. Independent CLI checks found an omitted operation page and an incorrect partial-brief summary after a mismatched delivery receipt.
| delete page._cursor_scope; | ||
| const outgoingContinuation = page._outgoing_continuation === true; | ||
| delete page._outgoing_continuation; | ||
| if (outgoingContinuation && operation !== "turn_start") { |
There was a problem hiding this comment.
[P2] 外发页短路时保留独立 operation cursor。真实 CLI 同时持有两个游标时,这个分支给出成功和外发摘要,却吞掉仍可通过独立调用读回的 2 条操作。保留外发页的免重复投递,让显式操作读取继续到现有投影。
| try { | ||
| const results = agendaResults(source.root, row); | ||
| const latest = results.filter(result => result.request_revision === (control?.revision ?? 1)).at(-1); | ||
| return latest?.status === "delivered" |
There was a problem hiding this comment.
[P2] 只在当前部分结论的回传身份验证通过后省略全文。恢复样本中收执的消息 ID 指向另一请求,状态字符串仍通过该判定。身份冲突时保留完整当前简报及恢复提示。
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · Gemini · Google DeepMind · self_reported
Request changes conclusion (author-owned PR; GitHub blocks formal self-review)
-
[P2] 外发摘要续页吞掉显式
--operation-cursor。- Problem: 同时向
manager-inbox read --attention-only传入外发摘要游标--cursor与独立操作游标--operation-cursor时,操作投影被静默吞掉。 - Evidence: 在 inbox_read.ts#L635-L638 中,
outgoingContinuation && operation !== "turn_start"在检查params.defer_recording/operation_cursor前直接返回completed: true;Python 侧_pending_result(inbox.py#L226)遇到snapshot.get("completed")即提前返回,跳过pending_operation_handoffs。独立真实 CLI 实测(22 条submission_unknown操作 + 1 条待决外发请求):组合传入--attention-only --cursor <outgoing> --operation-cursor <op>返回rc=0但operation_handoffs缺失(0 条),而同游标单独读取返回剩余 2 条。 - Impact: 遵循游标续页的调用方误以为已无待确认/待对账操作,导致外部操作被静默遗漏。
- Fix: 保留外发续页对收件读取和
peer_returns的只读隔离,但仅在outgoing_continuation and operation_cursor is None(或由inbox_read.ts结合operation_cursor控制状态)时跳过pending_operation_handoffs,并补入组合游标 CLI 回归测试。
- Problem: 同时向
-
[P2]
--attention-only改写_cursor_scope导致operation_handoff_next_cursor在普通读取报 scope mismatch。- Problem: 启动 hook 默认启用
--attention-only后,其吐出的operation_handoff_next_cursor与操作溢出指引命令不兼容。 - Evidence: inbox_read.ts#L244-L247 在
attentionOnly下将cursorKind切为"pending_attention_v2"并以该摘要视图scope覆盖_cursor_scope(inbox_read.ts#L258 / #L631),inbox.py#L233据此签发操作游标(如op1:364cf86c...)。但operation_agent_handoff.ts#L395的溢出指引(及unfinished_delegations.read_command)仍是Continue with manager-inbox read --operation-cursor(无--attention-only)。真实 CLI 实测:按指引执行manager-inbox read --operation-cursor <op>直接返回rc=1与error: operation cursor scope mismatch。 - Impact: Agent 在存在 >20 条操作交接时按系统指引续页会直接失败,破坏操作分页独立性契约。
- Fix: 让
operation_handoffs统一绑定不受过滤视图影响的请求邮箱作用域(如单独传递operation_cursor_scope固定使用pending_requests_v1维度),或在解析层显式兼容目标一致的操作游标并补测跨模式续页。
- Problem: 启动 hook 默认启用
-
[P2]
deliveredRemainderSummary折叠全文前未校验.delivery.json的请求/消息身份。- Problem: 读到指向其他请求的消息 ID 的交付收执时,当前逻辑仍将请求判定为已送达并省略原文简报。
- Evidence: inbox_read.ts#L209-L227 依赖
agendaResults与replyStatuses(inbox_read.ts#L370-L396)判定latest?.status === "delivered"。replyStatuses仅检查status/error字符串枚举,未核查return_delivery.ts写入.delivery.json的message_id(handoff.<sha256([request_id, key])>)、goal_ref、result_key或request_id。真实本地 Chat 恢复样本实测(两条请求均经drain,随后将请求 2 含不同message_id的conclusion.delivery.json写入请求 1):read_inbox(..., attention_only=True)仍将请求 1 折叠进open_request_summaries(step="review_request_work"、returns[0].status="delivered"),既未在items交付全文,也未提示证据冲突。 - Impact: 损坏或串号的交付收执会被误认为安全已送达,Agent 在看不到原始需求上下文且无恢复告警的情况下继续后续工作。
- Fix: 在
replyStatuses/deliveredRemainderSummary中校验存在字段(message_id、result_key、goal_ref、request_id)与当前请求及结果文件的一致性;冲突时标为未核实/不可用并保留完整简报与恢复状态。
动机 / Motivation
恢复委派工作的 Agent 与调用 manager-inbox read 的 Turn 启动链路需要读到未完成收件、剩余义务和待处理外发请求。 改造前,turn_start_hook 触发的必读命令在每次恢复都会重放已有已送达部分结论的请求原文;改造后,正常已送达部分结论可折叠为带剩余义务的摘要并沿同一游标续读未结外发请求,但在收执身份冲突或组合分页/操作游标续读时当前实现会丢失原文或吞掉操作项。 在 attention_only 模式下,待裁决请求与缺收执/被预留请求仍输出完整 items,健康的已送达部分结论进入 open_request_summaries 并由同一 next_cursor 续读外发请求;然而真实 CLI 复现显示外发续页会吞掉 --operation-cursor,摘要模式产出的操作游标脱离 --attention-only 会报错,且指向他请求的 message_id 收执仍会触发折叠。 本 PR 不修改请求裁决/回传写入契约、不新增 Todo 调度状态,也不涉及前端 Dashboard 200 行键盘展开与稳定快照发布边界。
改动思路 / Approach
本 PR 在现有协作读事务与 Turn 启动 hook 上扩展有界注意视图。入口由 turn_start_hook(loopx/capabilities/manager_context/__init__.py)在必读 manager-inbox read 命令中默认附带 --attention-only,经 loopx/cli_commands/manager_inbox.py 与 loopx/control_plane/collaboration/peers.py 传入 TS readCollaborationInbox。TS 侧在 pendingPage 中对满足 awaiting_conclusion、存在 remaining_work、无活跃预留、读回与 links 完整且当前修订最新结论为 delivered 的收件调用 deliveredRemainderSummary 转为紧凑摘要放入 open_request_summaries(不写入 reads/),收件翻尽后再通过 outgoingSummaryPage 续读 peer-operations 未结外发委派,并复用 projectDelegationTurnItem 保持摘要形状一致。
将条件折叠与外发分页放在现有 TS inbox_read.ts 交易 owner 内并复用 projectDelegationTurnItem 投影格式是合理的,无需新建存储或独立命令;但必须把操作游标作用域与外发续页短路拆清,且必须校验 .delivery.json 归属后再允许折叠。 当前 PR 边界限定为 Manager Inbox 的 --attention-only 条件折叠、外发分页与 turn_start_hook 默认启用;修复上述三个边界缺口后即可闭环,跨文件操作游标统一重构若需兼容旧游标可留作后续。 从状态模型看,open_request_summaries 与 _outgoing_continuation 均为已有 entries/、replies/ 与 peer-operations/ 权威记录上的派生投影,未引入第二套手工同步状态;但将 pending_attention_v2 的分页范围哈希直接复用作操作游标范围、以及在外发续页无条件返回 completed: true,属于越界耦合,引发了上述回归。
具体改动 / Changes
依据基准提交 07722b169a4edea313f6a17d12dd73819e3f8843 上的文档 docs/reference/required-work-context.md(以及操作手递契约 docs/architecture/rfcs/human-confirmed-domain-operations-v0.md)逐项核对验收标准:
scoped-request-pages:implemented —pendingPage、outgoingSummaryPage与turn_start_hook实现了分片分页、外发续页读只读隔离与--request-id精确精读,由tests/control_plane_ts/inbox_read_transaction.test.ts与tests/test_delegation_turn_context.py覆盖(跨模式操作游标问题归入下方独立项)。unavailable-keeps-source:not_met —deliveredRemainderSummary/replyStatuses未校验.delivery.json的message_id等身份归属,实测串号收执仍折叠简报,最小修复为在读取收执状态时校验归属并在冲突时保留items原文与恢复状态。independent-operation-cursor:not_met —inbox_read.ts#L635与inbox.py#L226在外发续页吞掉显式--operation-cursor,且inbox_read.ts#L244使--attention-only发出的操作游标在无--attention-only调用时报错scope mismatch;最小修复为解耦操作游标作用域并取消外发续页对显式操作游标的短路。- 需关注本 PR 同时修改了所引用的
docs/reference/required-work-context.md(+20/-5)与loopx/capabilities/manager_context/README.md(+7/-0)以补充--attention-only语义;代码本身仍须按基线契约满足不因收执冲突丢原文、不吞操作游标的要求。
全量 diff 为 8 个文件(+332/-45):产品运行时/CLI(inbox_read.ts、peers.py、manager_inbox.py、manager_context/__init__.py)、文档(required-work-context.md、manager_context/README.md)与测试(inbox_read_transaction.test.ts、test_delegation_turn_context.py)。
关键代码讲解
deliveredRemainderSummary与replyStatuses(inbox_read.ts#L209-L227、#L370-L396):负责在attention_only模式下判定是否将部分结论请求折叠到open_request_summaries。当前仅通过agendaResults检查修订与latest?.status === "delivered",缺少对.delivery.json内message_id/goal_ref/result_key的核验,是串号收执被误折叠的根因。pendingPage与outgoingSummaryPage(inbox_read.ts#L229-L288、#L452-L471):为收件分页引入pending_attention_v2游标作用域与收件读尽后的pending_outgoing_v1外发续页。若外发目录仅含不可读文件且无有效条目,limit=0探测返回的next_cursor为null(依赖unfinished_delegations暴露unavailable_count);同时将pending_attention_v2摘要传入_cursor_scope造成了与operation_cursor的作用域分裂。readCollaborationInbox与read_inbox(inbox_read.ts#L630-L638、peers.py#L693-L751):外发续页在非turn_start时直接返回completed: true与outgoing_continuation: true,配合peers.py跳过record_read与unfinished_delegations重算;但无条件置completed: true连带触发了inbox.py#L226对pending_operation_handoffs的早退。turn_start_hook(init.py#L286-L303):将 Turn 启动默认生成的operator_inbox必读命令改为附带--attention-only,直接影响turn_start_hook与quota should-run两条宿主必读路径(旧无参行为可通过手工去掉--attention-only保留,非 opt-in 开关而是默认启动命令变更)。
对主干的风险 / Risks
当前头部(f16ed1174c0c1c09cd61864ef347e474fb7d4dc9)在正常无冲突的收件折叠和纯外发分页上可运行,但存在三项高风险边界缺陷:
- 外发续页组合
--operation-cursor静默丢操作:触发条件为从--attention-only获取外发next_cursor后同时携带--operation-cursor调用manager-inbox read;观测结果rc=0但operation_handoffs为空;最小修复为仅在非显式操作查询时跳过,并在inbox.py/inbox_read.ts解耦。 - 启动模式与操作溢出提示失配:触发条件为从
--attention-only读到operation_handoff_next_cursor后按operation_agent_handoff.ts#L395提示执行无--attention-only的manager-inbox read --operation-cursor;观测结果rc=1报错operation cursor scope mismatch。 - 跨请求交付收执未核验即省略全文:触发条件为 Chat 请求的
conclusion.delivery.json带有另一请求的message_id;观测结果全文从items消失且折叠摘要仍显示delivered;最小修复为核验.delivery.json身份并在冲突时回退完整简报与恢复态。
本地验证实测明细:
- PASS TS 单元与事务测试:
node --experimental-strip-types --test tests/control_plane_ts/inbox_read_transaction.test.ts(25/25 通过)。 - PASS Python 回归与真实 CLI/File/SQLite 套件:
pytest --basetemp ... tests/test_delegation_turn_context.py tests/test_inbox_pagination.py tests/test_inbox_receipt_recovery.py tests/control_plane/test_inbox_exact_request.py tests/control_plane/test_inbox_read_recovery.py(76 通过、2 项 Windows PowerShell 跳过;单独重跑tests/test_delegation_turn_context.py为 29 通过、2 跳过)。 - PASS 代码规范与边界扫描:对全部变更 Python/文档运行
ruff check通过;loopx check --scan-path ...对本 PR 6 个受扫文件无泄漏(1 条既有README.md:684: credential告警与本 PR 无关)。 - PASS (受限) TS 类型检查:
tsc --project tsconfig.control-plane.json --typeRoots ... --noEmit在本 PR 修改的inbox_read.ts与inbox_read_transaction.test.ts上零错误(仅content_digest_single_owner.test.ts因隔离 worktree 未安装node_modules/typescript报缺包,非本 PR 变更)。 - FAIL 独立对抗实测(3 项):串号
message_id的 Chat 样本误折叠、外发游标+--operation-cursor吞操作、--attention-only签发的操作游标在默认 CLI 下报scope mismatch。
语义与 CI 对齐
本 PR 沿用既有 inbox_state、remaining_work、step 与 unfinished_delegations 词汇,仅新增读取参数 --attention-only 与分页游标范围 pending_attention_v2 / pending_outgoing_v1,但对 turn_start_hook 的默认启动命令做了有感默认变更,并在文档与测试同步披露。需特别注意:作者在 PR 描述中提及的远程 Ubuntu Dashboard shard 3 失败(键盘展开后 184/200 行可见)及稳定快照构建拒绝,经核对本 PR diff 未触及 apps/ 下任何 Dashboard 代码或浏览器 E2E 场景,属诊断性非因果记录(required=false),不影响对本 PR 自身管理器收件箱问题的独立判定;真正的阻塞项是上述 3 个已复现的 manager-inbox 行为缺陷。
我的整体评价 / Verdict
综合判定:long_horizon 为 regression(外发续页吞操作与串号收执省略全文都会在多轮工作交接中丢失义务或上下文),user_experience 为 regression(--attention-only 签发的操作游标按系统自带 --operation-cursor 指引执行直接报错 scope mismatch);visual_review 为 not_applicable(本 PR 仅涉及 CLI/TS 控制面读取事务、Python 适配器与参考文档,未修改任何前端渲染界面,未验证范围:无),unverified_scope 为无。从代码规模与兼容性看,code_volume 虽集中于单事务文件但存在作用域耦合,需在本次修复中同步拆清(simplify_now);当前不建议合并,请在 f16ed1174c0c1c09cd61864ef347e474fb7d4dc9 上修复上述 3 项问题并补充真实 CLI 组合游标、跨模式操作游标与串号 .delivery.json 回归测试后重新送审。词汇判断:reuse_existing(主要复用既有收件/议程词表,局部扩展了读路径游标作用域,无需新建独立词表)。
English verdict: REQUEST_CHANGES at f16ed11. Independent CLI and local Chat probes reproduced three regressions: outgoing continuation pages silently drop explicit --operation-cursor (inbox_read.ts#L635, inbox.py#L226), --attention-only binds operation_handoff_next_cursor to pending_attention_v2 causing operation cursor scope mismatch under the standard --operation-cursor continuation instruction (inbox_read.ts#L244), and deliveredRemainderSummary/replyStatuses collapse full briefs without verifying .delivery.json message_id/identity (inbox_read.ts#L209-L227, #L370-L396). Focused TS (25/25) and Python (76 passed, 2 skipped) suites pass; Ubuntu Dashboard 184/200 expansion note is unrelated to this diff.
User outcome
The before-work Inbox repeatedly supplied complete briefs for requests that already had a delivered partial answer. Workers still need the remaining obligation and the current source when resuming that work.
The existing Inbox command uses a scoped
--attention-onlyread at both Turn entrypoints. It retains full briefs for requests that need them, including unverified deliveries or active reservations. A verified delivered partial conclusion appears as a paginated summary with the request identity, revision, remaining work and next step. Follow the same cursor to reach unfinished sent requests. Sent-only continuation pages are read-only. Incoming full briefs and sent request status remain available by exact request identity.The receiver adapter and guard tests include the Turn-bound acknowledgement changes now on main. PR #8803
Validation
loopx/control_plane/work_items/interaction_contract.py.CI follow-up
ac6f2e9f2and its base07722b169. GitHub job07722b169and this head. Stable snapshot check