Skip to content

fix(botmux): read a dispatch back by its own trigger id, never the session latest - #8684

Merged
loopx-agent merged 6 commits into
loopx-project:mainfrom
Duang777:codex/botmux-status-unaccepted-dispatch-20261113
Nov 14, 2026
Merged

loopx-agent merged 6 commits into
loopx-project:mainfrom
Duang777:codex/botmux-status-unaccepted-dispatch-20261113

Conversation

@Duang777

@Duang777 Duang777 commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

Goal And Delivered Outcome

  • Outcome basis / optional anchor: self-found core defect. No public issue; the request in this PR is the basis.
  • Goal/source and gap: _status_botmux_runtime in loopx/control_plane/goals/botmux_runtime.py read back a dispatch with the session's trigger-result, which is the session's latest turn. On a reused session that is not necessarily the turn the receipt belongs to: a dispatch the provider never accepted (attempting, rejected, or an unknown that was never queued) has no turn in it, and an accepted one can be overtaken by a newer turn another client started.
  • Observable before → after, with the validation row that proves it: (1) After a second trigger was rejected with 409, status returned completed, ok=True, readback_verified=True, and status --execute raised invalid botmux dispatch transition: rejected->completed. After: rejected, ok=False, readback_verified=False; an attempting receipt is promoted to unknown and persisted, and repeated status keeps a never-queued unknown unknown. (2) After an accepted second turn failed and another client completed a third turn, status reported the third turn's completion for this dispatch and --execute persisted it. After: status asks for the receipt's stored trigger_id, promotes a provider state only when the response names that same id, and otherwise reports unknown (trigger_identity_unverified) without promoting. Rows: regression_parity, unit.
  • Issue/task and intended base: none. Base is main at 7bb1b01.

Author Declaration

  • Written by: agent, Claude Sonnet 5.5, for @Duang777

Implemented against

  • Specification and revision: no written specification; the request in this PR is the basis.
  • Criteria:
Criterion (spec clause) Disposition Symbol / path Test or command
Status must not vouch for a dispatch the provider did not accept implemented _status_botmux_runtime tests/control_plane/test_botmux_goal_channel_runtime.py::test_status_never_vouches_for_rejected_dispatch_on_reused_session, ::test_status_promotes_unresolved_attempt_on_reused_session_without_provider_result
A never-queued unknown stays unknown on repeated status implemented _status_botmux_runtime ::test_repeated_status_never_adopts_previous_result_for_interrupted_dispatch, ::test_status_recovers_accepted_dispatch_after_a_status_read_failure
An accepted dispatch is read back by its own trigger id, and only a response naming it promotes a state implemented _status_botmux_runtime ::test_status_reads_the_turn_this_receipt_was_queued_under, ::test_status_does_not_promote_a_result_attributed_to_another_turn, ::test_status_without_a_stored_trigger_id_asks_the_provider_nothing
  • Self-check before submission: reproduced the defect on the unfixed code, then confirmed the new test fails before and passes after. Did not run the full suite or CI-equivalent gates locally. The botmux tests ran with a stub loopx.cli because the local tree could not import the real one; test_runtime_cli_parses_setup_doctor_trigger_and_status was deselected.

Scope And Continuation

  • Completed scope and remaining work: status read-back of a Botmux dispatch. The ?triggerId= query and the echoed triggerId follow the Botmux async-trigger contract as read from its source at the commit the reviewer cited; no live Botmux was contacted. A dispatch whose POST response was lost, so no trigger_id was stored, stays unknown rather than being recovered automatically; recovering it needs a per-turn provider lookup keyed by something LoopX already holds.
  • Slice boundary / successor: N/A, one independent defect.

Validation

  • Tested revision: 6681ca1ad179e20a16bf3599ba9f41a9576e3969 for the diff; local runs used a working tree whose touched files were blob-identical to main 7bb1b01 before the change.
  • Run state: finished
  • Input classes: synthetic
Check kind Result Public-safe evidence / limitation
regression_parity passed Both new tests fail on the unfixed code and pass with the fix.
unit passed test_botmux_goal_channel_runtime.py and tests/test_state_migration.py together: 25 passed, 1 deselected; ruff check clean.
  • Coverage and gaps: Not run against a real botmux backend; the provider is mocked.

Frontend / Visual Evidence

  • UI impact: none

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Refactoring (no functional changes)
  • Documentation update
  • Test update

LoopX Area

  • Control plane (goals, todos, quota, scheduler, registry, runtime)
  • Benchmark boundary (adapters, runners, verifiers, scoring, evidence)
  • Capability or extension (providers, adapters, skills)
  • Public docs or presentation surface (README, protocols, dashboard)
  • Build, packaging, installer, or CI
  • Host or runtime integration

Technical Direction

  • Direction / acceptance reference, when applicable: Core control-plane hardening.

Shared-authority RFC fixture impact

N/A

Boundary Checklist

  • Neither the diff nor this PR body/comments/attachments disclose private state, credentials, raw traces or verifier output, internal links, or local machine paths (including .loopx/, .codex/goals/, and live ACTIVE_GOAL_STATE.md).
  • I did not duplicate maintainer-owned benchmark work unless a maintainer split out a public issue for it.
  • I kept the change scoped to the linked issue/task.
  • Existing English/Chinese RFC pairs (including ledger entries) both have a diff, and the local premerge check passes, or no paired RFC changed. No RFC changed.
  • I completed the visual evidence section for UI changes, or marked UI impact none.
  • Every commit includes a DCO Signed-off-by trailer (git commit -s).

🤖 Generated with Claude Code

On a reused botmux session the status read asked the provider for the
session's trigger-result whenever the session held an active dispatch key,
even when that dispatch's local receipt was still `attempting` (crash before
the provider replied) or `rejected`. The session result then describes the
previous, completed turn, so status reported the never-accepted dispatch as
`completed` with `readback_verified: true`, and `--execute` crashed with
"invalid botmux dispatch transition: rejected->completed" (or
attempting->completed), leaving the receipt unresolved forever.

Resolve ATTEMPTING and REJECTED receipts from the local receipt alone, the
same path used when no session exists: attempting is promoted to unknown and
rejected is reported as rejected.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: duang777 <duangjl007@gmail.com>

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator

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

评审提交 6681ca1ad179e20a16bf3599ba9f41a9576e3969,PR 目标基线 7bb1b01687c5ecb36971b19fc432d6019d3e5492,本轮主干 5890cecd436e7d76b0bb5a033aca175c3a2650d9。两版主干在受影响的生产文件一致。

[P2] 第二次查询把未被接收的 dispatch 标成完成。 同一 BotMux session 已完成第一笔。第二次 trigger 在 provider 接收前中断,留下 attempting。对该 Goal 连续运行两次 status --execute。 第一次返回并保存 unknown。第二次读取整个 session 的上一笔结果,用第二笔 dispatch key 返回 completed 和 readback_verified=true,并将它持久化。HTTP 对照确认 provider 只接收了第一笔。 问题位置

动机 / Motivation

通过 LoopX Goal Channel 触发 BotMux 的用户,需要确认最近一次请求是否完成。 先完成一笔,再向同一会话发第二笔。用户希望查询当前请求,即使会话仍保留上一笔结果。 候选修复了明确拒绝路径。两次执行均返回 rejected,未查询 provider。正常接收的请求仍可读回完成,已接收后的查询故障也能恢复。 验证使用公开 CLI、真实本地 HTTP 客户端和隔离文件状态。HTTP 服务为 BotMux 协议夹具,线上 BotMux 与 Lark 未验证。

改动思路 / Approach

BotMux 负责实际接收和执行,LoopX 的 dispatch receipt 绑定本次触发。status 只能把匹配的观察写回当前 receipt。 复用现有触发接收凭据可区分两类 unknown,继续沿现有状态机恢复已接收的请求。 触发先写 attempting,provider 接收时再写 queued 和对应会话。当前修复让 attempting 和 rejected 走本地路径;原先已经接收的请求仍用现有 provider 读取。 已接收凭据

具体改动 / Changes

关键代码讲解

两个文件分别修改 _status_botmux_runtime 和定向测试。分支先检查 attempting/rejected,只有执行查询才把 attempting 写成 unknown。随后同一 session 的下一次查询走旧 provider 分支,把上一笔完成写到当前 dispatch。 当前分支 第一次状态转换 验证标记

基线 docs/integrations/botmux-goal-channel-runtime.md 在 7bb1b01687c5ecb36971b19fc432d6019d3e5492 的 preserve-unknown-dispatch 保留中断后不确定性。 observe-current-accepted-result 已经在正常接收和已接收后的故障恢复中通过。 原有失败语义

对主干的风险 / Risks

同输入在 PR 目标和当前 main 上,预览均错误返回 completed,执行查询随后被 attempting→completed 状态机拒绝,未把第二笔写成完成。 候选第一次正确记录 unknown,第二次却写 completed。隔离对照只给未确认接收的 unknown 保留本地分支,两次都读到 unknown,provider 查询为零。已接收后 status 传输失败的对照仍能在第二次读回完成。

沿同一份本地 receipt 判断当前 dispatch 是否有 provider 接收凭据。未确认的 unknown 继续报告 unknown,直到有与该笔匹配的观察。已经确认接收、只是 status 读取失败的 unknown 保留现有恢复。 在现有真实 CLI/HTTP 对照连续查询两次,分别核对未接收中断、明确拒绝、正常接收、已接收后的查询故障与恢复。核对当前 receipt、此前 receipt 和 provider 请求次数。

语义与 CI 对齐

原生 CLI 入口和迁移定向 27 项通过。Standard premerge 六项直接和十项自动检查通过。HTTP 矩阵在目标、当前主干、候选及隔离对照各运行四种场景。 托管 CI 未查询。

我的整体评价 / Verdict

请求修改。请把同一条保护延续到重复查询,并保留已接收请求的恢复。测试需核对第二次执行及落盘状态,才能覆盖这次状态转换。HTTP 对照应确认这笔请求从未进入已接收记录。

English verdict: REQUEST_CHANGES. At 6681ca1, the first status stores an interrupted dispatch as unknown, then the next status falsely persists completion using the preceding accepted turn's result.

)
unaccepted_dispatch = bool(dispatch_key) and _dispatch_state(
local_receipt.get("state") if isinstance(local_receipt, Mapping) else None
) in {BotmuxDispatchState.ATTEMPTING, BotmuxDispatchState.REJECTED}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] 第二次查询把未被接收的 dispatch 标成完成。 同一 BotMux session 已完成第一笔。第二次 trigger 在 provider 接收前中断,留下 attempting。对该 Goal 连续运行两次 status --execute。 第一次返回并保存 unknown。第二次读取整个 session 的上一笔结果,用第二笔 dispatch key 返回 completed 和 readback_verified=true,并将它持久化。HTTP 对照确认 provider 只接收了第一笔。 沿同一份本地 receipt 判断当前 dispatch 是否有 provider 接收凭据。未确认的 unknown 继续报告 unknown,直到有与该笔匹配的观察。已经确认接收、只是 status 读取失败的 unknown 保留现有恢复。 在现有真实 CLI/HTTP 对照连续查询两次,分别核对未接收中断、明确拒绝、正常接收、已接收后的查询故障与恢复。核对当前 receipt、此前 receipt 和 provider 请求次数。

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.

已在 4dbe7bf 修复:除 ATTEMPTING、REJECTED 外,从未进入 QUEUED 的 UNKNOWN 也只用本地 receipt 判断,不再读取整个 session 的上一笔结果。判断依据是 receipt 是否有 queued_at(QUEUED 时写入,后续状态转换会保留)。因此中断的 attempt、transport_failure、invalid_provider_receipt 产生的 unknown 重复查询仍是 unknown;接收之后只是 status 读取失败(status_transport_failure,带 queued_at)的 unknown 仍通过 provider 恢复。

新增两个测试:

  • test_repeated_status_never_adopts_previous_result_for_interrupted_dispatch:复用 session,第二次 trigger 在 provider 接收前传输中断,连续三次 status --execute 都返回 unknown、readback_verified=False、落盘仍为 unknown,且没有任何 provider 读取。旧实现下失败,复现你描述的第二次变 completed。
  • test_status_recovers_accepted_dispatch_after_a_status_read_failure:接收后 status 读取失败再恢复为 completed。新旧实现都通过,用来保证这条恢复路径没被误伤。

本地 test_botmux_goal_channel_runtime.py 27 项通过(需用桩 loopx.cli 并排除 test_runtime_cli_parses_setup_doctor_trigger_and_status,因为我的本地树缺 chat_event_cache),ruff 干净。

没有覆盖:没有走真实 HTTP 协议夹具,provider 用的是 requester 替身,也没有核对 provider 请求次数以外的对照矩阵。托管 CI 尚未在新 head 上跑完。

… status

The first status turned an interrupted attempt into an unknown receipt, but the
next status took the provider path again and, on a reused session, adopted the
previous accepted turn's trigger-result for the new dispatch key: completed and
readback_verified, persisted.

Treat an UNKNOWN receipt that was never QUEUED (an interrupted attempt, a
transport failure or an unverifiable receipt) like ATTEMPTING and REJECTED and
resolve it from the local receipt alone. An UNKNOWN that was QUEUED and only
lost its status read still recovers through the provider.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: duang777 <duangjl007@gmail.com>

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator

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
Reviewed commit: 4dbe7bf7a1d98c616e054aa99009499bc9401476 · merge base 7bb1b01687c5ecb36971b19fc432d6019d3e5492.

[P2] 已接收的请求仍会采纳另一笔的完成结果。 同一 Botmux 会话中,LoopX 的当前请求已得到接收凭据;它失败后,另一客户端发起并完成新请求。 状态 GET 查的是会话最后一笔,会把新请求的完成结果确认为当前请求的结果;预览谎报完成,--execute 会持久化错误回执。这个问题基线已有,属于本次 status 修复同一个请求归属边界。 有接收凭据时按已存的 trigger_id 查 ?triggerId=…,并核验返回身份。缺 ID、身份不匹配或无法确认时,保留原回执或明确返回未验证,不能用会话最新结果晋升状态。 代码位置

动机 / Motivation

调用 goal-channel runtime status 的操作者用回执判断某笔 Botmux 请求是否完成。 复用会话时,旧版会把上一次完成写给这次未确认接收的请求;已接收分支也一直按会话取最新结果。 当前头修复本地未确认接收路径;已接收的本次请求仍可能拿到另一笔请求的结果。 这次审查覆盖现有状态读写路径;无需新增重试协议、接入切换或 Goal 更新。

改动思路 / Approach

本地回执决定是否有资格查询;Botmux 的逐请求结果负责说明请求进度;LoopX status 负责把二者关联。 新的分支根据已有状态和 queued_at 判断是否读取 provider,并保留已接收请求的中断恢复。 --execute 只把观察保存到当前本地回执;是否验证完成依赖同一请求身份,不能依据同一会话或据此改变 Goal。 Botmux 已支持按 triggerId 查询,不带 ID 会选会话最新记录,完成响应带回 triggerId。

具体改动 / Changes

按 docs/integrations/botmux-goal-channel-runtime.md 在 614ce03d36d36adb2a9f0d83fee2c2d7798c9c99 的条款评估。Typed lifecycle result 仍不满足。Failure Semantics 相关路径保持:不确定时不盲目重试或推断;可确认的 provider 观察只更新本地回执,不推动 Goal 转移。

关键代码讲解

生产代码 24 增 1 删,定向测试新增 183 行;本次加的是一个使用已有回执字段的判定分支。 上一轮评审 的反例在当前提交重新验证。旧头误读上一笔完成的原反例已修复;以下反例属于同一路径中已取得接收凭据后的另一分支。

对主干的风险 / Risks

PASS:已有成功请求作对照时,后续拒绝仍是 rejected,尝试中断、传输失败和无效接收回执在预览和两次执行查询中仍是 unknown,不再发 GET。已有接收凭据时,状态读取断开后仍能再次读取并完成。 分支基线 25 个、当前头 29 个定向测试通过;另用真实 LoopX CLI、隔离的本地 binding 和回环 HTTP 夹具对照基线、旧头和当前头。 夹具也覆盖 provider 实际接收、但 POST 响应丢失:没有确认身份时继续返回 unknown,这比读最新结果安全;这与已取得接收凭据后状态 GET 中断的可恢复场景不同。

FAIL:让当前已接收的第二笔先失败、尚未写回,然后从另一客户端在同会话提交并完成第三笔。按第二笔 triggerId 查得 failed;当前 LoopX 预览和 --execute 都返回 completed、readback_verified=true,执行还把第二笔回执存成 completed。分支基线同样复现,无需并发。 建议用同会话两个 triggerId(当前 failed、较新 completed)回归预览和写回,并继续检查已接收请求的状态读取中断恢复。

语义与 CI 对齐

保留已接收与未确认接收两条状态路径,复用回执里已有 trigger_id 做逐笔读回即可。 Git 差异检查与提交签署通过;与检查时的主干模拟合并有实质差异且无冲突。可重跑 uv run --extra test pytest -q tests/control_plane/test_botmux_goal_channel_runtime.py tests/test_state_migration.py 并加入上述对照。验证了真实 LoopX CLI;provider 使用与公开路由一致的回环 HTTP 夹具,未连部署中的 Botmux/Lark,也未检查 hosted CI 或完整 premerge。

我的整体评价 / Verdict

一笔已失败的请求能被写成已验证完成,后续消费者可能跳过重查或补做;错误回执不会因为本轮修好了未确认接收的分支而消失。 已确认接收的单一请求仍能恢复。多客户端复用会话时,调用者仍不能用这个完成标志确认自己那一笔。 没有新增 UI 或首屏变化。 已有私有 trigger_id 足以关联;无需公开 ID、扩展状态集合或改变 Goal 权限。

English verdict: REQUEST_CHANGES — the unaccepted-dispatch fix works, but the same status path still marks an accepted dispatch complete from a different session turn. This is a reproduced pre-existing gap, not a new regression.

…n's latest

An accepted dispatch was read back with the session's trigger-result, which is
the latest turn of the session. When another client started and finished a
newer turn after this one failed, status reported that turn's completion for
this dispatch: the preview said completed and --execute persisted it.

Ask for the trigger id stored on the receipt and promote a provider state only
when the response names that same id. A response for another turn, one that
names no turn, or a receipt with no stored trigger id is reported as unknown
with unknown_reason trigger_identity_unverified, never as a completion; a
terminal local state is still not overwritten by it.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: duang777 <duangjl007@gmail.com>
@Duang777

Copy link
Copy Markdown
Collaborator Author

已在 08c59e7 修复,按你给的方向。先说明我核实了什么:你引用的 Botmux 契约(提交 1f4c927)里 trigger-result?triggerId= 确实按该 id 查询,所有状态的响应都带回 triggerId(not_found 带回请求的 id),查不到指定 id 时返回 400。我是读那几处源码确认的,没有连真实 Botmux。

改动:

  • 状态 GET 带上 receipt 里已存的 trigger_id:/trigger-result?triggerId=…。
  • 只有响应带回的 triggerId 与存的一致,才采用 provider 的状态。响应是另一笔、没说是哪一笔,或 receipt 里没有存 trigger_id,都当作未验证:返回 unknown、readback_verified=false、output_available=false,--execute 落盘 unknown(unknown_reason: trigger_identity_unverified),不会晋升为 completed。本地已是终态的 receipt 仍不会被覆盖。
  • 没有存 trigger_id 时不再请求 provider。

新增三个测试,都在上一版实现下失败:

  • test_status_reads_the_turn_this_receipt_was_queued_under:同会话第二笔(trigger-two)已失败、另一客户端完成了第三笔;请求带 triggerId=trigger-two,预览和 --execute 都得到 failed、readback_verified=false,落盘 failed。
  • test_status_does_not_promote_a_result_attributed_to_another_turn:provider 忽略 pin、返回第三笔的 completed,得到 unknown、不晋升、不报输出可用。
  • test_status_without_a_stored_trigger_id_asks_the_provider_nothing。
    接收后读取失败仍可恢复的测试继续通过。

另外两个既有测试的假 provider 没带回 triggerId,我把它们改成像真实 provider 那样带回(而不是放宽校验),_requester 也同样处理。

本地 test_botmux_goal_channel_runtime.py 与 test_state_migration.py 共 31 项通过(仍需桩 loopx.cli 并排除 CLI 解析那个测试,因为我的局部树缺 chat_event_cache),ruff 干净。

没有覆盖:没有连真实 Botmux/Lark,provider 是回环替身;没有测多客户端的真实并发;--trigger 时 POST 响应丢失、但 provider 实际已接收的情形,receipt 里没有 trigger_id,会一直是 unknown,比读最新结果安全,但不能自动恢复;托管 CI 在新 head 上尚未跑完。

@Duang777 Duang777 changed the title fix(botmux): do not read provider results for unaccepted dispatches fix(botmux): read a dispatch back by its own trigger id, never the session latest Nov 14, 2026

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator

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
Reviewed commit: 08c59e71034ad2619ecadd855df3103285f5df27 · merge base 7bb1b01687c5ecb36971b19fc432d6019d3e5492.

[P2] 错请求的 not_found 能永久封死本轮回执。 同会话已经确认接收第二笔。GET 明确发送第二笔 ID,provider 回包却给第三笔 ID、not_found 与其 output。 回环服务收到第二次的 triggerId 后返回第三次 ID、not_found 及其 output。两次真实 CLI 状态均报告 not_found、output_available=true。--execute 保存不可再晋升的 not_found。随后同一请求的真实 completed 响应到达,执行仍留在 not_found。 保留明确的旧式会话级缺失分支。对于已确认 trigger 的响应,任何显式不匹配的 ID 都应留在 unknown 并撤掉其输出标志。仅接受明确归属于本次请求的缺失结果。 代码位置

动机 / Motivation

复用 Botmux 会话的操作者用 Goal Channel 状态确认本轮的进展,执行模式需要把该笔结果持久化。 状态只能按当前 dispatch 的身份接受 provider 的生命周期结果;缺 ID 或错误 ID 不能写入该回执。

分支基线和旧头按会话读取最近一次请求。同一会话复用时,预览和 --execute 都能把第三次完成写给尚在运行的第二次。 回环服务收到第二次的 triggerId 后返回第三次 ID、not_found 及其 output。两次真实 CLI 状态均报告 not_found、output_available=true。--execute 保存不可再晋升的 not_found。随后同一请求的真实 completed 响应到达,执行仍留在 not_found。

真实 LoopX CLI 在回环 HTTP 夹具中使用第二次的 triggerId。第三次已完成时,第二次仍准确显示并保存 running。协议形状的真实会话缺失仍返回 not_found 且不显示输出。查询未知 trigger 得到 HTTP 400,未改变已排队回执。 真实 LoopX CLI 使用按公开协议构造的回环 HTTP 夹具。错 ID 是对代答或陈旧响应的故障注入。未连部署中的 Botmux/Lark,未检查托管 CI。

改动思路 / Approach

已接收回执中的 trigger_id 决定 provider 查询范围。回包身份校验在本地状态转换前。特判 not_found 无条件经过校验,写入后由已有终态规则拒绝任何晋升。 真实 LoopX CLI 使用按公开协议构造的回环 HTTP 夹具。错 ID 是对代答或陈旧响应的故障注入。未连部署中的 Botmux/Lark,未检查托管 CI。 预览只读。执行仅更新当前本地回执,两个状态分支都不会改变 Goal。

具体改动 / Changes

依据 docs/integrations/botmux-goal-channel-runtime.md 在 af9b668ff7fb6ddfd0b78022bf22563bd5891378 的条款。上游当前正常的缺失回包也带回所查询的 triggerId。协议形状的匹配 ID 和不匹配 ID 已各自复验。 Botmux 路由 · 上游缺失结果 规范

  • typed_lifecycle_attribution · 未满足。所有会改变本轮回执终态的 provider 响应都需有本轮范围。
  • dispatch_id_query · 通过。已确认接收的回执按自己的 triggerId 查询。

关键代码讲解

上一轮的直接反例已在同源命令中复验。 上一轮评审

对主干的风险 / Risks

Botmux CLI 与 state migration 本地套件当前提交 32 项通过,分支基线 25 项通过。 Git 差异检查、分支签署与检查时主干的模拟合并均通过。真实 LoopX CLI 使用按公开协议构造的回环 HTTP 夹具。错 ID 是对代答或陈旧响应的故障注入。未连部署中的 Botmux/Lark,未检查托管 CI。

语义与 CI 对齐

回环服务收到第二次的 triggerId 后返回第三次 ID、not_found 及其 output。两次真实 CLI 状态均报告 not_found、output_available=true。--execute 保存不可再晋升的 not_found。随后同一请求的真实 completed 响应到达,执行仍留在 not_found。 可重跑 uv run --extra test python -m pytest -q tests/control_plane/test_botmux_goal_channel_runtime.py tests/test_state_migration.py,并加入上面的对照。

我的整体评价 / Verdict

保留明确的旧式会话级缺失分支。对于已确认 trigger 的响应,任何显式不匹配的 ID 都应留在 unknown 并撤掉其输出标志。仅接受明确归属于本次请求的缺失结果。 status 只允许当前回执写入其本地观察。Botmux 结果无 Goal 转换权。

English verdict: REQUEST_CHANGES. Exact trigger lookup fixes the previous counterexample. A not_found response carrying a different trigger ID still persists a terminal state, advertises foreign output, and prevents later valid completion.

The identity check skipped not_found, on the reasoning that a missing result
echoes the id it was asked for. A response that names another turn as not_found
was therefore accepted: status reported not_found with that turn's output
attached and --execute persisted a terminal not_found that no later state may
replace, so this request's real completion could never be recorded.

Verify the triggerId of every response for a pinned turn, not_found included.
The bare session-level missing branch (404 unknown_session naming no turn) is
kept as it was; a 404 that does name a turn is checked like any other.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: duang777 <duangjl007@gmail.com>
@Duang777

Copy link
Copy Markdown
Collaborator Author

已在 8365adc 修复。这是我上一版的疏漏:我把 not_found 排除在身份校验之外,理由是真实 provider 也会带回请求的 id,结果带着别人 id 的 not_found 能把回执写成不可再晋升的终态,这笔请求之后真实的 completed 就永远记不上了。

现在对固定了 trigger 的请求,所有响应(包括 not_found)都要带回本次请求的 triggerId 才被采用;否则留在 unknown 并撤掉输出标志。保留的只有你说的旧式会话级缺失分支:404 unknown_session 且不带任何 triggerId,它没有指向任何一笔,不会被误归属于别的请求。404 如果带了 triggerId,就和其它响应一样校验。

测试:

  • test_a_not_found_naming_another_turn_cannot_seal_this_receipt:你描述的情形(第二笔已接收,GET 发的是第二笔 id,回包是第三笔 id + not_found + output)。预览和 --execute 都得到 unknown、output_available=false,落盘 unknown;随后本请求真实的 completed 到达,仍能记为 completed。上一版实现下失败。
  • test_a_not_found_for_this_turn_is_accepted_without_output:带回本次 id 的 not_found 仍被接受(新旧实现都通过,防止矫枉过正)。
  • 既有的 test_status_maps_confirmed_unknown_session_to_not_found 继续通过。

本地 test_botmux_goal_channel_runtime.py 与 test_state_migration.py 共 33 项通过(仍需桩 loopx.cli,排除 CLI 解析那个测试),ruff 干净。没有覆盖:没有真实 CLI 对回环 HTTP 夹具的跑法,是 requester 替身层面的测试;托管 CI 在新 head 上尚未跑完。

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator

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
Reviewed commit: 8365adc837bc7863b706203c48c7ea49af8ef0b6 · merge base 7bb1b01687c5ecb36971b19fc432d6019d3e5492.

[P2] 无身份的通用 404 仍能把派发永久写成未找到。 以同一会话成功派发两笔,让第二笔已有 triggerId;状态查询返回无 ID 的通用 404,随后让同一 ID 正常完成。 服务返回 HTTP 404 和 {"state":"not_found"},没有 triggerId,也没有 unknown_session。预览报告 not_found,--execute 将其持久化。随后同一 ID 返回 completed,状态仍停在 not_found,readback_verified=false。 只让明确写明 unknown_session 且没有 triggerId 的旧式 404 走会话缺失分支;通用 not_found 必须核对本次 ID。无 ID 时保留可恢复的 unknown,再用同一次派发的 completed 验证恢复。 代码位置

动机 / Motivation

操作者复用同一个 Botmux 会话派发多笔任务,再用 LoopX 状态命令确认其中一笔是否已完成。 已接收的派发应只接受能够归到本次请求的观察;保留已有的明确会话缺失兼容分支。

基线只查询会话的最近一笔;第二笔仍运行时,第三笔已完成就会把第二笔误标完成。当前提交按第二笔请求 ID 查询,能在第三笔完成后仍正确返回第二笔在运行。 当前提交已拒绝带其他 ID 的 HTTP 200 和 404 缺失响应,也拒绝不带 ID 的 200;它仍把不带 ID、也未标明会话缺失的 404 写成终态,之后收不到本次真实完成。 此改动限于 Botmux 状态查询及本地回执,不修改 Goal 进度、重新派发规则、外部消息或界面。

改动思路 / Approach

派发回执已有 trigger_id;复用现有 Botmux 适配器、同一把绑定锁和既有状态转换。只有响应身份已验证或明确属于旧式会话缺失时才进入终态。分开判断会话缺失与普通的无身份 404,可以在适配器内修完。 此改动限于 Botmux 状态查询及本地回执,不修改 Goal 进度、重新派发规则、外部消息或界面。

老的明确会话缺失仍有兼容测试。普通 404 没有提供同样的身份依据;当后续结果可能恢复时,要让已有的状态命令继续查这一笔。现有状态机可保留,不需要迁移回执。

具体改动 / Changes

依据 docs/integrations/botmux-goal-channel-runtime.md 在 af9b668ff7fb6ddfd0b78022bf22563bd5891378 的约定复验。集成规范 · Botmux 状态路由 · 上游缺失响应

  • dispatch_id_query:通过。后续轮次沿用已有会话;状态读取本次已接收的派发。

  • typed_lifecycle_attribution:未满足。只将本次派发的类型化提供方观察写进它自己的回执。 当前上游的状态型缺失用 HTTP 200 并回送查询 ID;当前 404 兼容分支把没有身份的通用缺失也当成了会话缺失。

  • local_receipt_only:通过。状态命令只在显式执行时持久保存观察,不据此改变 Goal。

  • 从未排队的未知派发留在本地,不能借用已接收的先前结果。 unaccepted_dispatch

  • 已接收的派发用持久化 ID 调用 Botmux 的逐笔查询。 pinned_trigger_id

  • 404 错误处理将通用 not_found 与明确会话缺失一并归类。 session_level_missing

  • 除会话级例外外比对响应 ID;外来 ID 不再提供输出。 identity_unverified

  • 执行模式保存类型化状态,随后只允许保留终态,不能晋升错误的 not_found。 _persist_dispatch_receipt

上一次的错 ID 问题 已复验。带外来 ID 的 200 和 404 现在都保留可恢复状态;真实完成抵达后可以正常写入回执。

对主干的风险 / Risks

Botmux 和迁移测试:分支基线 25 项、当前提交 34 项通过;Git 差异、签署和针对当时主干的模拟合并通过。 用实际 LoopX CLI 和回环 HTTP 夹具模拟 Botmux 响应,核对落盘;未连接真实 Botmux/Lark,未读取托管 CI。

真实 CLI 核对了按当前 ID 查询、拒绝外来 ID(200 和 404)、无 ID 的 200 后恢复、匹配的会话缺失及旧式 unknown_session;预览只读,执行只改当前回执,正式禁用后无 HTTP 请求。 分支基线和早先的补丁都能复现通用 404 的误终结;这是本次身份修复仍覆盖不到的入口。仅在临时副本收窄旧式例外后,通用 404 仍保持可恢复,同一笔的后续完成可落盘,其余对照和 34 项测试仍通过。重跑 uv run --extra test python -m pytest -q tests/control_plane/test_botmux_goal_channel_runtime.py tests/test_state_migration.py,并补上 HTTP 404 两个分支及同一笔完成的对照。

我的整体评价 / Verdict

只让明确写明 unknown_session 且没有 triggerId 的旧式 404 走会话缺失分支;通用 not_found 必须核对本次 ID。无 ID 时保留可恢复的 unknown,再用同一次派发的 completed 验证恢复。 提供方响应是本地派发回执的观察;仅 --execute 持久化,不能据此完成 Goal 或再派发。 建议把这一步一起修在现有 Botmux 适配器中,再复验预览和写入;不需要改变终态规则。

English verdict: REQUEST_CHANGES on 8365adc. The new code correctly rejects mismatched trigger IDs and preserves explicit legacy session misses. A generic HTTP 404 with no trigger identity is still treated as a confirmed session miss and seals the local receipt before its later valid completion can be recorded.

# A bare "this session is gone" names no turn, so it cannot be
# attributed to another one; a missing result that does name a turn
# is checked like any other response.
session_level_missing = not echoed_trigger_id

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] 仅凭通用 404 就把回执写成终态。 回环 HTTP 对第二笔已接收的请求返回 404、state=not_found,未带 triggerId 或明确的 unknown_session。CLI 执行后保存 not_found;下一次匹配的 completed 也无法更新回执。将无 ID 例外限为明确的旧式会话缺失,并用同一请求回包序列复验。

…issing

The exception for a not_found that names no turn accepted any 404 with state
not_found, so a generic 404 with no triggerId could still seal an accepted
receipt as a terminal not_found that no later state may replace.

Treat a response as session-level missing only when it is an explicit
unknown_session naming no turn. A generic 404 not_found, or one naming a turn,
is verified against the request's trigger id like every other response.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: duang777 <duangjl007@gmail.com>
@Duang777

Copy link
Copy Markdown
Collaborator Author

已在新提交修复:无 id 的例外现在只保留明确的 unknown_session(且不带任何 triggerId)。泛化的 404 + state=not_found、或带了 triggerId 的 404,都和其它响应一样要带回本次请求的 id 才被采用,否则留在 unknown,不会被写成不可再晋升的 not_found。

我上一版保留旧式分支时写宽了:条件是 error == unknown_session 或 state == not_found,而我把整个 404 分支都算作会话级缺失。

测试:

  • test_a_generic_404_not_found_cannot_seal_an_accepted_receipt:你描述的序列。第二笔已接收,404 + state=not_found、无 triggerId 也无 unknown_session,预览和 --execute 都得到 unknown、落盘 unknown;随后本请求匹配的 completed 到达仍能记为 completed。上一版实现下失败。
  • test_a_404_naming_another_turn_is_not_a_session_level_missing:unknown_session 但带了别的 triggerId,仍是 unknown(这一条上一版已经满足,作为防回退的保护)。
  • 既有的 test_status_maps_confirmed_unknown_session_to_not_found 继续通过。

本地 35 项通过,ruff 干净。没有覆盖:仍是 requester 替身层面的测试,没有走真实 CLI 对回环 HTTP 夹具;托管 CI 在新 head 上尚未跑完。

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator

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
Reviewed commit: 176e817b768c3cc7cd7509d6d3493e305bad16fc · merge base 7bb1b01687c5ecb36971b19fc432d6019d3e5492.

无阻塞发现。 通用 404 后同一笔任务的有效完成可写入回执,明确旧式会话缺失仍能读回。

动机 / Motivation

操作者复用一个 Botmux 会话派发多笔任务,通过 LoopX 确认其中一笔是否完成。 已接收的派发只读取本次请求的状态,并保留旧式明确会话缺失的兼容行为。

基线按会话读最近一笔。第二笔仍在运行时,第三笔的完成可能被写到第二笔回执。 现在状态查询携带第二笔的请求 ID,并先核对响应身份,因此第二笔仍然显示在运行。 上轮的通用 404 会把已接收的派发写成终态。当前它保持可恢复的 unknown,随后同一 ID 返回 completed 时正常落盘。 这次改动覆盖 Botmux 状态查询及本地回执。状态命令只读预览或按 --execute 保存观察。

改动思路 / Approach

继续在 Botmux 适配器内使用已保存的触发 ID、共享传输、文件锁与类型化回执。只有明确的旧式会话缺失可以省略 ID。 这次改动覆盖 Botmux 状态查询及本地回执。状态命令只读预览或按 --execute 保存观察。 已有的状态命令和回执格式足以完成处理。旧式会话缺失有明确的响应形状和回归测试。无归属的观察可以在下一次查询获取真实结果。

具体改动 / Changes

按 docs/integrations/botmux-goal-channel-runtime.md 在 af9b668ff7fb6ddfd0b78022bf22563bd5891378 的合同复验。上游正常缺失使用 HTTP 200 并回送请求 ID。 集成规范 · Botmux 路由 · 上游缺失处理

  • dispatch_id_query。复用会话时按实际派发身份读取状态。

  • typed_lifecycle_attribution。仅接受归属已核实的派发状态,保留明确会话缺失兼容。

  • local_receipt_only。预览保持只读,显式执行只持久化当前派发观察。

  • 从未排队的派发保留自己的本地状态。 unaccepted_dispatch

  • 请求携带回执中的触发 ID。 requester

  • 只为明确会话缺失保留无 ID 的旧式 404。 session_level_missing

  • 缺失或错用 ID 时保留可再次查询的状态,不提供其他派发的输出。 identity_unverified

  • 在执行模式下写当前回执并保留既有终态。 _persist_dispatch_receipt

对主干的风险 / Risks

基线 25 项、当前提交 36 项 Botmux 和迁移测试通过。Git 差异、分支签署及检查时主干的模拟合并通过。 真实本地 CLI 配合回环 HTTP 夹具验证请求和持久回执。部署中的 Botmux/Lark 和托管 CI 未纳入验证。

第三笔完成后第二笔仍报告 running。无 ID 的通用 404、无 ID 的 200 及携带外来 ID 的 200/404 均保持 unknown,匹配的后续完成均能写入。 明确旧式 unknown_session 和匹配 ID 的缺失仍写入 not_found。普通 HTTP 错误保留已排队状态。正式禁用后无状态查询请求,已保存回执字节不变。 在上一提交,通用 404 写入终态后重复读取仍挡住真实完成。当前重跑使用同一请求及同一 HTTP 对照。 上轮评审

我的整体评价 / Verdict

通过当前提交。Botmux 观察由本地持久派发身份限定。终态由已有类型化的回执转换写入,Goal 生命周期仍由已有控制面处理。 后续普通查询可以继续确认这笔任务的结果,现有明确缺失仍可展示。历史上已经写成终态的回执由原状态机保留。

English verdict: APPROVE 176e817. The current CLI retains explicit legacy session absence, qualifies ordinary not_found by trigger identity, and records the same dispatch's later valid completion after an ambiguous response.

@loopx-agent
loopx-agent merged commit dd53ca5 into loopx-project:main Nov 14, 2026
9 of 11 checks passed
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