Skip to content

feat(goal-channel): canonical room-work Agent CLI, offer expiry admission and private reconnect context - #5248

Open
LIHUA919 wants to merge 77 commits into
loopx-project:mainfrom
LIHUA919:codex/im-ov-room-claim
Open

LIHUA919 wants to merge 77 commits into
loopx-project:mainfrom
LIHUA919:codex/im-ov-room-claim

Conversation

@LIHUA919

@LIHUA919 LIHUA919 commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Related to #5198. Scope revised per the 10-18 product-direction review: steward-led automatic delegation stays the default; this PR now delivers only the Agent CLI + scoped IM claim-button backend for steward-published, Agent-claimed work. The Room work frontend is withdrawn to a follow-up PR (manual claim panel, UI-only HTTP adapter/routes, i18n entries, browser scenario/fixture and screenshots are removed; apps/ and examples/ are byte-identical to current main).

Delivered scope

  • goal-channel work project|claim|offer|revoke|resume: canonical room orientation, revision-guarded claim through the existing typed Todo owner, idempotent receipts, separate historical-acceptance / current-ownership readback, and private read-only reconnect context (existing Turn Recall composition; no ingest, no room send, no execution authority).
  • Scoped IM claim-button offer/callback through the existing collector: per-request principal scope, source-route/binding witnesses retained through provider reads, and the offer's original expiry enforced at final canonical admission.
  • Claim wire extensions on the shared owner, renumbered onto current main: main's todo_claim_request_v2 (managed execution) is untouched; this proposal's guarded (registry_sources) and timed (admit_before) claims ship as v3/v4. Old receivers reject the new fields; v0/v1 behavior unchanged.

P2 expiry race — fix requalified on the rebased head

The offer's expires_at travels as admit_before (claim request v4, retaining v3 source guards). The typed Todo owner checks its current clock after all provider/source reads, immediately before dispatching the claim CAS; equality is expired. A refusal changes neither ownership, revision, operation receipt, offer nor room message.

New real-clock regressions extend the existing offered fixture: the offer gets a ~1.2s expiry and the wall clock crosses it during (a) the card content read and (b) the claim facade's delivery-preflight chat read — both after callback admission passed. Both variants require offer_expired with full canonical state, provider revision, operation receipt and room messages unchanged. An unexpired control still yields exactly one canonical acceptance and a found receipt. Red/green proof: with the final claimDeadlineFailure check temporarily neutralized in todo_claim.ts, the crossing tests fail exactly as the reviewer's counterexample described; restoring the check turns all parameterized cases green. The pre-existing mock-based native-refusal test is retained.

Rebase onto current main (merge commit, history preserved)

Main moved ~4,800 commits since the last qualified base. Conflict resolutions:

  • coordination/local_authority.py / local_authority_runtime.ts: main shipped todo_claim_request_v2 as the managed-execution claim, colliding with this proposal's earlier v2 (guarded). Resolution: main keeps v2; the guarded/timed wires are renumbered to v3/v4, the claim runtime accepts v0-v4 and forwards both admit_before and main's workspace observer. No shipped main semantics were overwritten.
  • agent_turn_recall/cli.py: main's settlement-identity validation and RuntimeError handling kept; the public load_turn_quota_decision name kept for the goal-channel facade.
  • chat_lark_api.py (superseded by the strip): main's TYPE_CHECKING declaration kept; the PR mixin base was withdrawn with the UI.
  • Frontend/browser conflict hunks (lark-settings-page.tsx, personal-workspace-browser-smoke.mjs): taken from main, consistent with the scope withdrawal.
  • Follow-ups to main changes: the room-resume suite now recovers the quota packet from main's context-capture navigation envelope via digest-pinned context-read pages (same pattern as the automation-cadence consumers), and one main-side monkeypatch target follows the recall CLI rename.

No hunk was force-carried onto a refactored main shape: the room-claim capability does not exist on main (verified by path and git log --grep=claim audit), so nothing was dropped as superseded; every conflict was a conscious union or main-side take as listed above.

Validation (rebased head d7c7c284b)

Check Result
Room claim/work/resume + recall + outbound Python suites 223 passed, 0 failed (includes the new real-clock crossing cases, File/SQLite).
Full control-plane TypeScript suite 6,688 passed / 0 failed / 91 skipped (includes main's managed-claim tests).
PR-scope TS tests (authority_source, goal_ref compatibility, room claim/resume/projection, conformance) All pass on the renumbered schemas; admit_before rejection covered for v0-v3.
Typecheck Control-plane and dashboard both pass; apps/+examples/ identical to main, so no new frontend surface.
Lint Ruff on changed Python passes; configured Mypy (CI invocation) passes.
Premerge loopx canary premerge --from-git-diff passes: 19 checks, 0 failures, 0 manual holds; bilingual RFC and public-boundary checks included.

Remaining limits

Real non-production Lark rooms, native callback rendering, independently authenticated hosts, daemon reconnect, live OpenViking retrieval, installed-App journeys and PostgreSQL-specific room suites remain unqualified (PG skipped locally this round). Agent self-claim discovery through the normal work-selection flow is the next owner-side step named by the review; this PR provides the claim/readback/resume components it reuses. Maintainer merge authority and a fresh exact-head review are still required.

@LIHUA919 LIHUA919 changed the title feat(goal-channel): compose canonical local room work (#5198) feat(goal-channel): compose scoped room claims and callbacks (#5198) Sep 28, 2026
@mergify

mergify Bot commented Sep 28, 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, @LIHUA919.

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 Sep 28, 2026
…dback

Signed-off-by: Lihua <1017343802@qq.com>
…alification

Signed-off-by: Lihua <1017343802@qq.com>
Signed-off-by: Lihua <1017343802@qq.com>
@LIHUA919 LIHUA919 changed the title feat(goal-channel): compose scoped room claims and callbacks (#5198) feat(goal-channel): compose scoped claims and private reconnect context (#5198) Sep 28, 2026
@mergify mergify Bot removed the needs-rebase Mergify: the pull request has merge conflicts with its base branch label Sep 28, 2026
Signed-off-by: Lihua <1017343802@qq.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 · effort=max

REQUEST_CHANGES · b3e7097。一个阻塞项:[P2] offer 在 provider 读取期间过期后,仍能产生 canonical 领取及接受凭据。下面覆盖整个当前变更及验证边界。

动机

已有飞书连接中的 Agent 和协作人,需要看当前可领任务、领取一次,并在丢回复或重连后知道原操作是否已经完成。例如同一任务的领取回复丢失,操作者不能靠卡片文字判断是否成功,再建一个请求还可能重复交办;本变更把领取结果和当前归属分别读回,并沿用原请求恢复。已验证本地打包界面经真实任务存储完成领取、刷新和同键恢复;但回调在远端读取期间过期仍会领取,当前不能按完整范围批准。

不改动时,已有直接 CLI 能领取,但房间展示、消息确认和重连续接仍需操作者手工对账。新增设置页不是必须的人工作业:Agent 可复用已有 Goal、身份、连接和授权直接调用 CLI;在已有领取意图下,不需要增加一轮用户澄清。UI 是人工检查和显式领取的伴随入口,不能代替执行授权。独立认证的多主机、真实飞书回调、live OpenViking 及已安装 App 尚未由本轮验证;它们与这个有用的本地组合阶段分开。

不新建调度器、任务数据库、消息消费者或远端身份体系;领取不授予执行权,也不证明已安装 App 或完整父级集成已通过。

改动思路

保留现有分工是合理的:原生 Todo 事务决定归属和幂等,Python 适配飞书与文件 IO,TypeScript 负责准入和投影,界面只保存恢复请求。当前 PR 的边界是既有本地 File/SQLite authority 上可实际使用的房间领取与私有续接,不承担全套多主机部署。不需要新建可独立推进的任务看板、消费者或记忆权限。纯 CLI 是更小的合法替代方案,但不能提供房间内的独立送达确认和浏览器丢响应恢复;因此这个有界切片有实际增量。

正常路径为既有连接解析身份 → 当前来源与 Todo 读取 → 显式 revision 领取 → 原生事务凭据 → 当前归属和飞书消息分别读回。浏览器的 sessionStorage 只保留原 tuple/key,无法可靠保存时不发请求。私有 resume 另外复用已有 Turn Recall 和当前 quota,检索后再核身份、来源、状态;回忆不发到房间,也不授予执行权。异常应在各自 owner 收敛:来源漂移拒绝领取,未知消息结果沿原 key 核对,记忆不可用则减少上下文。过期检查目前没有贯穿这条领取路径,这是下面的阻塞点。

具体改动

以实时远端 main 860e42d4b63b45c4798ee7f08622a27c146a2610 的共同基线 b5a331d0b9cc8956a109ab45880a492c6bafba4a 对照 head,净新增范围为 50 paths,+3676/-36。原始 GitHub/native 包保留的 base 为 0c5d70b71c3b86d02df918b1786a4701eaf126cd,其 253-path 统计包含 203 个在共同基线已存在且 head 原样继承的路径。已用远端 ref、git ls-remote、merge-base 和逐路径 blob 核对,没有把这部分共有历史归给本 PR。gh pr diff 的传输失败保留,完整源码差异来自已验证不可变 Git 对象。

范围包括:五个 workspace UI/data/i18n/CSS 文件;房间工作、offer/callback、resume 及 HTTP/CLI 适配;原生 claim v2 来源守卫、GoalRef 拒绝与 bound-agent 规则;已有 recall 的只读选项和 receipt identity 复用;Python/TS/浏览器回归;RFC、参考文档与五张合成数据截图。两个既有浏览器场景分别统一解释器来源和等待真实焦点恢复,没有改产品断言来隐藏失败。

规范依据是变更前已接受的 docs/architecture/rfcs/agent-im-openviking-collaboration-v0.md,固定版本 b5a331d0b9cc8956a109ab45880a492c6bafba4a:原规范。以下是本评审的映射标签,原 RFC 没有这些编号:

  • C1 implemented:单一 LoopX authority、并发只接受一次、同键恢复;真实 File/SQLite 的独立 CLI 和 receipt/readback 回归覆盖。
  • C2 not_met:接受操作时仍满足当前身份与有界命令约束。新增 offer 的有效期在慢 provider 读取后失效,但仍领取;见下面反例。
  • C3 implemented:私有 recall 不变成公开正文或权限;续接不发房间、不 ingest、不 spend,检索期间变化丢弃上下文。
  • C4 implemented:直接 CLI 路径仍可用,意图清晰的收紧单独披露;base/head 的 File/SQLite 实际 CLI 对照见下文。
  • C5 deferred:独立认证主机、daemon/live provider 及完整三平面验收仍是后续集成资格;本地切片不宣称关闭这些父级要求。新增的 checkpoint 说明也按此边界审查,不能用它重写变更前规范。

关键代码讲解

  1. claimLocalCoordinationTodo:v2 把原 broker/source witness 交给现有跨运行时文件 guard;最终 canonical 写仍由原 Todo owner 执行。来源争用和漂移不退回无见证路径,旧 wire 不能偷偷携带新字段。
  2. handle_room_claim_callback:核对已持久化 offer、principal、Bot/profile、消息及完整卡片,然后调用相同 claim owner。当前唯一 expiry admission 在远端成员和卡片读取之前;后续领取没有重新核对这个 deadline。
  3. RoomWorkPanel:先持久化原请求再写,双击只发一次;reload 后重用原 key。旧、不完整或未经验证的 envelope 隐藏当前归属并禁新领取。已实际检查 1512px 和 390px 整屏及双语、焦点、Escape 恢复。
  4. run_room_resume:从原持久化 Todo/Turn receipt 取续接身份,用当前能力和 quota 观察,检索后重新检查 scope、revision 和 gate;显式跳过 ingest。结果只能是私有上下文,不能作为接受新工作或执行租约。

对主干的风险

[P2] 过期的 offer 仍可领取,位置为 room_claim.py:265。先在 expiry 前进入回调,随后正常成员/卡片查询延迟到 deadline 之后。241–244 行的允许结果被保留,265 行进入 canonical claim 时不再检查 offer 的有效期;同一路径里的再次 provider preflight 也会延长这段间隔。

我用已有 offered 合成飞书 fixture 和真实墙钟重现,没有改断言或伪造存储结果:offer 有效三秒,read_callback_card_content 完成时等到 deadline 后 150ms,再继续原处理器。File 与 SQLite 均返回 claim_status=applied、canonical_claim_accepted=true,provider revision 从 1 到 2,独立存储读回 owner=agent-a,operation receipt 从 missing 变 found,原消息也被更新。可用 offer 的两个对照均正常接受;只在测试侧加入提交前有效期复核的两个反事实对照均拒绝,完整 snapshot 不变且 receipt 仍 missing。六例为 4 passed / 2 failed。先前模拟 admission 时钟的失败也保留,但结论以这个真实墙钟反例为准。

在所有可能阻塞的 provider 读取之后,让原 offer 的当前有效性参与最终领取准入,明确与 canonical 接受点的时序边界;不要沿用早先允许结果。增加真实过期跨越用例,并保留未过期成功、同键重放、来源撤销及零副作用拒绝。可直接扩展 tests/control_plane/test_room_claim_callback.py 的已有 offered fixture,在卡片读取后跨越一个短 expiry,并断言完整 state、revision、receipt 和消息不变;同时覆盖后续 preflight 延迟。这里需要的是已声明期限的真实效果边界,不是新增审批、调度器或权限体系。

本轮实际通过:六个相关 Python 模块 225 passed;五个 TypeScript 文件 21 passed;control-plane 与 dashboard typecheck;Chat bundle 构建;打包 room-work 浏览器旅程。浏览器覆盖陈旧/缺失/不完整读数、存储拒绝、双击、未知送达、reload/同键恢复和独立 CLI 当前归属。provider/连接发现为合成边界,不能外推已安装 App 或 live Lark。

另用相同输入、解释器和真实 CLI 在不可变 base/head 上比较两种存储共 16 次:普通 unbound 领取成功;done 和未知 actor 的完整拒绝正文与无写入保持;绑定给另一个 Agent 的任务由 base 接受改为 head 明确 bound_agent_mismatch 且不写。这是有意的共享 claim 行为变化,并非“关闭房间功能后一切完全相同”。显式 goal_ref(含 null)在旧 wire 先于 provider/历史 receipt 被拒绝,也是已披露收紧。剩余全部投影排序/大样本反事实和完整禁用路径配对未在本轮逐项执行,保留为未核验,不以绿色子集补全。

语义与 CI 对齐

新 claim_request、room projection、resume 和 guarded claim wire 延伸现有有界操作词汇;offer 意图不是第二套 Todo authority,历史 receipt 也不续约。核心 Todo 归属与来源状态仍由 TypeScript 原 owner 决定;Python 的当前有效期观察须在最终准入重新应用。C2 失败是命令有效期约束未落实,而非通过文档改名可解决。本轮 policy 为 wait_for_ci=false,未查询、轮询或等待 CI;没有以远端 CI 状态作为评审阻塞。

我的整体评价

这是一项有用的本地组合增量:长期工作可通过原 key 和持久化 receipt 恢复,人工可在既有连接查看真实归属,导航是可选检查,不增加已授权 Agent 的必经确认轮次。就当前整项交付,长程正确性仍因过期授权被接受而未达成;本地用户恢复体验已有独立运行证据。维护成本集中在 IO 适配、限定 wire、最小 UI 和测试,沿用现有 authority/recall/envelope owner 是合理的;本次范围不需要扩成完整多主机系统。

结论为 REQUEST_CHANGES。修复并验证 expiry 跨越,按当时完整 exact head 重核其余兼容/投影证据后再评审;既往被撤回的批准没有沿用。未做合并、安装、重启或真实房间写入;独立主机、live OV 和真实模型收益不在本轮通过范围。

English verdict: REQUEST_CHANGES — head b3e7097. A claim offer can expire during provider reads and still commit canonical ownership and a receipt. Real-clock tests reproduce this on both File and SQLite (2 failures, 4 valid/repair controls passing). The 225 Python tests, 21 TypeScript tests, both typechecks, Chat build and packaged recovery journey pass; none covers that deadline crossing. Revalidate the bounded offer at the final claim admission after blocking IO. Direct-claim tightening is intentional and disclosed. This is a useful local composition stage; independent live hosts/providers and installed-App acceptance remain unqualified. CI was not consulted.

observed = json.loads(observed)
if observed != delivery["card"] and observed != p.get("last_result_card"):
raise RoomClaimCallbackError("callback_card_drifted")
claimed = run_goal_channel_work(registry_path=Path(p["source_registry"]),

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] Revalidate the offer after blocking provider reads

The sole expiry admission is at lines 241–244, before membership/card reads and the later Goal Channel preflight. An offer valid on entry can therefore expire before this call still commits ownership. Using the existing offered fixture, a real three-second deadline and a card-read delay until deadline +150ms reproduced applied/owner=agent-a/revision1→2/receipt found on both real File and SQLite stores. Valid controls pass; a test-side final recheck rejects without changing the full snapshot or creating a receipt. Carry current offer validity to the final claim admission after blocking IO, with an explicit acceptance boundary; add delayed-read and later-preflight expiry regressions while preserving valid/replay controls. 过期跨越不是消息送达失败,不能沿用先前的允许结果。

Signed-off-by: Lihua <1017343802@qq.com>
Signed-off-by: Lihua <1017343802@qq.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 · OpenAI · self_reported

REQUEST_CHANGES · a8dac55 — 产品方向与交付范围调整

这条评审传达最新确认的产品方向:默认保留管家自动委派;允许补充“管家发布任务、Agent 自主认领”;本轮先不增加前端。这是对当前范围的明确修订,不是声称原规范禁止人工入口,也不是对既有全 PR 技术评审的替代。

动机

用户向管家提出工作后,应由管家和 Agent 在已有授权内完成分工、执行和结果返回。管家路线的价值是减少用户持续协调:用户不应因为多了一个领取入口,就又需要找任务、挑执行者、点击领取、核对回执和催交付。

当前文档确实已经说明 Agent 可以直接调用 CLI,Room work UI 是可选入口。我们并不把它误读为“所有 Agent 都必须等人点击”。问题在于,本 PR 把相当一部分交付和验证投入到了人工领取及浏览器恢复,而这个入口尚不能证明 Agent 会自主发现和承接工作。把它标成可选,也不足以说明为什么现在需要增加这套前端。

希望得到的增量是:管家已经说明任务和边界后,合适的 Agent 能自己把工作接起来,并把结果送回原请求。人工领取界面的收益可以以后单独验证。本轮不要求完成全部多主机、真实 Lark 或 OpenViking 集成,也不新增调度系统。

改动思路

保留两条共享同一任务权威的路径:

路径 预期链路 适用情况
默认自动委派 用户提出需求 → 管家选择合适 Agent → Agent 承接并执行 → 结果返回原对话 已知责任人、明确指定执行者,或适合直接分配的工作
可选自主认领 管家通过既有授权入口发布可认领任务 → 合格 Agent 在正常工作选择中发现并认领 → 执行 → 管家汇总并返回原对话 无需预先指定某个 Agent、存在多个合适执行者的工作

这里的“发布”是进入既有 canonical Todo authority 中有明确权限和目的的可领范围;不是必须发一张飞书卡片,也不是另建任务池数据库。图中的人只负责原始需求,以及实际缺少的重大选择或必要授权。普通认领不再追加一次人工确认;受保护操作仍走原有授权边界。

关键增强点应在现有 Agent 工作选择流程。Agent 应同时考虑已有承诺、优先级、Goal 相关性、能力、当前容量和预算,在合适时主动承接授权范围内的 unclaimed tasks。已有归属或明确指定给其他 Agent 的任务不能被抢走。也不应为了“主动”无限检查候选、挤占已有高优先级工作,或把所有无人认领事项转成用户审批。

本 PR 的建议边界:先收缩为支持 Agent 路径的最小后端/CLI 组合,复用现有领取、工作选择、唤醒和结果返回。暂缓新增 Room work 前端;若自主发现需要现有工作选择 owner 补齐,明确这项依赖及可观察的验收,不用人工页面冒充自动协作已完成。 不把全部远端路线压到这一项修改中。

具体改动

请据此调整当前提案:

  1. 撤回或拆出本次新增的 Room work 页面入口、人工领取组件及其专用展示、文案、截图和浏览器场景。本轮先不新增前端。仅为这套 UI 服务的 API/状态也按实际调用需要收缩;不要机械删除仍保护已有 CLI 的共享约束。
  2. 保留有实际 Agent 调用价值的 canonical claim、幂等回执、当前归属读回和私有续接能力。明确它们分别解决“谁接了”“失败后如何恢复”“怎样恢复私有上下文”,不把领取成功等同于执行启动或任务完成。
  3. 说明并验证 Agent 从正常工作入口发现可领任务、判断能否承接、认领后进入既有执行及返回流程。现有选择流程若已有部分能力,优先复用并验证;尚缺的行为在原 owner 处补齐,不能只靠说明文字要求“更主动”。
  4. 无人合适、预算不足或暂无执行机会时,保留可读的真实状态,交由管家现有协调机制处理。不要静默遗忘,也不要新增高频后台轮询或第二套调度账本。

关键代码讲解

  • RoomWorkPanel 是当前新增人工领取与浏览器恢复的主要入口。这次要求延后的是这个产品表面及其专用配套,而不是用删除界面来放松权限检查。
  • run_goal_channel_work 提供 project/claim 的 Agent CLI 组合,仍调用既有 canonical 领取 owner。应围绕真实 Agent 调用链解释和验证价值;候选 ID、一次成功命令或发送回执都不证明自主承接闭环。
  • run_room_resume 恢复的是当前允许范围内的私有上下文。它不能提供新的执行权,也不应因本次调整被改成公开任务正文或房间记忆。

当前实现边界参见 room-work 文档。规范依据仍保留 Agent IM / LoopX / OpenViking RFC 的变更前版本,spec_revision=b5a331d0b9cc8956a109ab45880a492c6bafba4a。本次新增要求来自上述最新产品方向;不将它伪装成旧 RFC 已经写明的验收条目。

对主干的风险

[P1] 当前交付重心需要按最新方向收缩。 触发场景是用户已把任务交给管家,但新增领取页面仍被作为主要价值和验证对象,Agent 自主承接这一有用结果没有被建立。最低修改是暂缓新增前端,明确默认自动委派与可选自主认领的分工,并把支持认领主动性的最小行为接回现有 owner。

修订后的验证应直接覆盖:一个正常可领任务能被合格 Agent 在正常工作回合内发现、独占认领并沿原链路返回结果;多个 Agent 竞争仅一个成功;已绑定或已领取任务、错误身份、错 Goal/来源及越权范围均拒绝;过期、撤销、陈旧 revision 不产生新效果;丢回复和重连使用同一请求恢复且不重复执行;无关/关闭路径保留现有行为。公开回执不得泄露私有任务正文或 recalled context,claim 也不能替代 quota、gate 或必要 lease。

此前 offer 在 provider IO 期间过期仍能领取的独立技术发现 保留为历史证据。提交本评审前 head 更新至当前版本,已加入将原期限经 claim v3 的 admit_before 传入 canonical owner 的修复代码和回归用例。本轮读到了这项变化,但没有重跑其验证,因此不把旧 head 的复现直接说成当前仍存在的缺陷,也不宣称已独立验收修复。如果该路径继续保留,仍应按新 head 验证最终接受处的有效期;这与本条产品方向修改要求分开。

维护上先复用现有 Turn、候选读取和唤醒机制,避免为了认领增加常驻轮询、第二个 scheduler 或依赖人工同步的状态。响应延迟取决于实际唤醒和工作选择时机;请记录发布到认领、执行到返回的耗时及额外命令/模型成本。当前没有可比基线,不承诺即时响应或量化节省。

我的整体评价

当前 head 的领取与恢复基础可以为自主认领提供有用组件,但我们选择的主线仍是管家自动委派。新增人工入口目前不是必要交付,所以请求先调整范围,再围绕 Agent 主动承接的实际价值验证。人工交互可作为以后有明确需求时的伴随能力,不能反过来成为管家工作的常规前提。

本次核对了当前版本文档、未变化的 RoomWorkPanel/私有续接入口、CLI 的期限传递变化及最新远端 head,发布产品方向与范围的变更要求;没有重新执行全量差异审计、测试、浏览器旅程或 CI 归因,也不沿用历史批准。自动认领的长程收益及用户介入减少仍待真实链路验证;既有领取安全不变量和原技术发现继续保留。完成修订后,应以新的完整 exact head 重新评审相应实现与兼容性。

English verdict: REQUEST_CHANGES at a8dac55dffc8d2e428c5d0206587d839765bd872 for the updated product direction and scope. Keep steward-led automatic delegation as the default; add an optional steward-published, Agent-self-claimed route through existing task authority and work selection. Defer the new frontend. Demonstrate discovery, exclusive claim, governed execution and return to the original requester without unnecessary human steps. Preserve authority, privacy and recovery safeguards. This is scoped design feedback, not a fresh full technical qualification; the latest head adds a proposed offer-deadline fix whose correctness has not been requalified here, and that is separate from this design finding.

@huangruiteng

Copy link
Copy Markdown
Collaborator

重新review comment了一下,主要是期望这里和管家自动委派的体系结合着来改善~

@mergify

mergify Bot commented Oct 19, 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, @LIHUA919.

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 Oct 19, 2026
Resolve conflicts after main moved ~4.8k commits ahead:
- agent_turn_recall/cli.py: keep main's settlement-identity validation and
  RuntimeError handling; retain the public load_turn_quota_decision name the
  goal-channel work CLI reuses.
- chat_lark_api.py: keep main's TYPE_CHECKING _send_error declaration and the
  PR's RoomWorkChatRequestMixin base.
- coordination/local_authority.py + local_authority_runtime.ts: main shipped
  todo_claim_request_v2 as the managed-execution claim; the PR's guarded
  (registry_sources) and timed (admit_before) claim schemas are renumbered to
  v3/v4 so main's v2 keeps its shipped meaning. The claim runtime accepts
  v0-v4 and forwards both admit_before and main's workspace observer.
- Frontend/browser conflict hunks (lark-settings-page.tsx,
  personal-workspace-browser-smoke.mjs) take main's side; the room-work UI is
  being withdrawn to a follow-up PR per review direction.

Signed-off-by: Lihua <1017343802@qq.com>
Per the 10-18 product-direction review: steward-led automatic delegation
stays the default; steward-published, Agent-claimed work goes through the
existing Agent CLI and the scoped IM claim-button offer. Remove the manual
claim panel, its UI-only HTTP adapter and routes, i18n entries, browser
scenario/fixture, screenshots and harness-only changes. Trim the room-work
reference doc, projection-envelope contract row and the RFC checkpoint to
the CLI/offer/resume scope. A manual claim frontend needs its own follow-up
proposal and qualification.

Signed-off-by: Lihua <1017343802@qq.com>
Main shipped todo_claim_request_v2 as the managed-execution claim, so this
proposal's guarded (registry_sources) and timed (admit_before) claim wires
move to v3/v4. Update the wire-version matrix in the goal_ref rejection
regression and cover admit_before rejection on every lower version.

Signed-off-by: Lihua <1017343802@qq.com>
The previous expiry coverage stubbed the native admission rejection, so it
could not prove the typed Todo owner itself refuses after provider reads.
These tests give the offer a 1.2s real expiry, let the wall clock cross it
during the card read (and, in the second variant, during the claim facade's
delivery preflight chat read), and require the protocol outcome: offer_expired
refusal with full canonical state, provider revision, operation receipt and
room messages unchanged. An unexpired control still yields exactly one
canonical acceptance and a found receipt.

Red/green proof: with the final claimDeadlineFailure check in todo_claim.ts
temporarily neutralized, the crossing test fails exactly as the reviewer's
counterexample described (no refusal, canonical claim accepted); restoring
the check turns all six parameterized cases green.

Also follow two main changes in the room-resume suite: quota should-run now
caps large stdout behind a context-capture navigation envelope, so native_cli
recovers the exact packet through digest-pinned context-read pages like the
automation-cadence consumers; and the recall CLI rename reaches the one
main-side monkeypatch target.

Signed-off-by: Lihua <1017343802@qq.com>
@LIHUA919
LIHUA919 requested a review from songoow as a code owner November 19, 2026 16:53
@mergify mergify Bot removed the needs-rebase Mergify: the pull request has merge conflicts with its base branch label Nov 19, 2026
@LIHUA919 LIHUA919 changed the title feat(goal-channel): add room claim UI and private reconnect context feat(goal-channel): canonical room-work Agent CLI, offer expiry admission and private reconnect context Nov 19, 2026
@LIHUA919

Copy link
Copy Markdown
Contributor Author

Addressed both review rounds on a new head d7c7c284b (merge commit onto current main + three follow-up commits, all DCO-signed). The PR is conflict-free and mergeable again.

P2 expiry race (10-18 09:32 round). The a8 head already carried the admit_before repair, but it had not been independently requalified, and the rebase onto main's refactored claim owner required deliberate reconciliation. On the new head: the offer's expires_at travels in claim request v4 (retaining the v3 source guards; see below for the renumbering), and the typed Todo owner checks its current clock after all provider/source reads, immediately before dispatching the claim CAS — equality counts as expired, persistence may finish later. New real-clock regressions in tests/control_plane/test_room_claim_callback.py extend the existing offered fixture: a ~1.2s offer expiry is crossed during (a) the card content read and (b) the delivery-preflight chat read, both after callback admission had already passed; each variant requires offer_expired with the full canonical snapshot, provider revision, operation receipt (read through coordination.local_authority.operation_receipt) and room messages unchanged. An unexpired control still produces exactly one canonical acceptance and a found receipt. Red/green proof: with the final claimDeadlineFailure check in todo_claim.ts temporarily neutralized, the crossing tests fail exactly as your counterexample described (no refusal, canonical claim accepted); restoring the check turns every parameterized case green. Unexpired success, same-key replay, revocation and the other zero-side-effect rejections remain covered by the existing suite. The earlier mock-based native-refusal test is retained.

Product-direction scope revision (10-18 14:56 round). The Room work frontend is withdrawn from this PR into a future follow-up proposal: the manual claim panel, its UI-only HTTP adapter and server routes, i18n entries, browser scenario/fixture, screenshots and two harness-only example edits are removed by a dedicated strip commit (82346a0df); apps/ and examples/ are byte-identical to current main, so this PR no longer adds any frontend surface and the RFC checkpoint/reference docs now state that steward-led automatic delegation remains the default and a manual claim frontend needs its own qualification. What stays is the backend the Agent path reuses: goal-channel work project|claim|offer|revoke|resume on the existing canonical Todo owner, idempotent receipts, separate historical-acceptance/current-ownership readback, and the private read-only resume composition. Agent self-claim through the normal work-selection flow remains the named next step in the original owner, as the review required — this PR ships the components, not a claim that autonomous discovery is complete.

Rebase conflict dispositions (nothing force-carried).

  • local_authority.py / local_authority_runtime.ts: main had shipped todo_claim_request_v2 as the managed-execution claim while this proposal had used v2 for the guarded wire. Resolution keeps main's v2 semantics untouched and renumbers this proposal's guarded (registry_sources) and timed (admit_before) claims to v3/v4; the claim runtime accepts v0-v4 and forwards both the deadline and main's workspace observer. Lower-version wires reject the new fields rather than ignoring them, preserving the original "old receivers reject" property.
  • agent_turn_recall/cli.py: main's settlement-identity validation and RuntimeError handling kept; only the public loader name the goal-channel facade reuses is retained.
  • chat_lark_api.py: main's TYPE_CHECKING declaration kept; the room-work mixin base was withdrawn together with the UI.
  • lark-settings-page.tsx / personal-workspace-browser-smoke.mjs: main side taken, consistent with the frontend withdrawal.
  • Main-behavior follow-ups: the room-resume suite now unwraps main's context-capture navigation envelope via digest-pinned quota context-read pages (same consumption pattern as the automation-cadence suite), and one main-side monkeypatch target follows the recall CLI rename.

Validation on d7c7c284b: room claim/work/resume + recall + outbound Python suites 223 passed / 0 failed; full control-plane TypeScript suite 6,688 passed / 0 failed / 91 skipped (including main's managed-claim tests); both typechecks pass; Ruff on changed Python and the configured Mypy pass; loopx canary premerge --from-git-diff passes with 19 checks, 0 failures, 0 manual holds (bilingual RFC and public-boundary checks included). PostgreSQL-specific suites were not run locally this round; real Lark rooms, native callback rendering, independent hosts, daemon reconnect and live OpenViking remain unqualified, and maintainer merge authority plus a fresh exact-head review are still required.

@LIHUA919

Copy link
Copy Markdown
Contributor Author

CI attribution on head d7c7c284b — the red lanes trace to main-side conditions, not this delta:

12 checks already pass on this head, including Sign-off, dependency-review, chat-bundle and the browser lanes that completed.

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

Reviewed head d7c7c284b817c08bac1e674a32da3d6d0587fd89

Reviewer: model_agent · gpt-6.2-sol · OpenAI (runtime_reported, max)

Request changes,P2。 首次房间发送成功但回包丢失时,只要有一条无关待办更新,用原 key 重试就会发送第二张同一领取的卡。File 和 SQLite 都复现。

动机 / Motivation

管家向 Goal 房间发布待办时,受授权的 Agent 需要知道哪些待办可领、谁已领取,以及断线后还能否继续。操作者看到的是同一份归属的回读。

目前房间消息可提供上下文,Agent 仍需回到 canonical Todo 核对归属。当前提交提供 Agent CLI 的查看、领取和私有重连,并让房间内有明确授权的用户使用同一个领取事务。

两路竞争时只出现一次 canonical 领取,旧口径的过期读竞态已封住。首次消息响应丢失并遇到无关 Todo 变动时,同一个领取仍会送两张卡。

管家的自动委派仍是产品默认。范围保留为本地 Agent CLI、受限 IM 回调及其 canonical 读回。Room 手动面板和安装交付已退出本次范围。

管家的默认自动委派和 Agent 的正常任务选择流接入是后续工作。真实房间、独立主机和 daemon 重连也需要另行资格验证。

维护者的产品方向 · 管家接入说明

改动思路 / Approach

Todo 的单一归属和 receipt 由既有 TS canonical owner 决定。Lark 承担人、Bot 和消息绑定检查,再复用现有消息投递。

本 PR 可完成 CLI 领取、原卡恢复和私有重连所需的有限前置能力。正常任务选择和真实安装不在当前交付边界。

CLI 与按钮共用现有 canonical Todo CAS,房间回调额外核对当前 principal、原消息和 offer 的原始截止时间。重连前后检查当前归属、已绑定 Turn 和 quota,只将适用的材料保留在私有结果。省去另建房间状态源或让人重复确认。 回调 · 重连

具体改动 / Changes

按 docs/architecture/rfcs/agent-im-openviking-collaboration-v0.md 的 b5a331d0b9cc8956a109ab45880a492c6bafba4a 版本审查。 已接受的 Agent IM RFC

  • canonical-ownership 使用既有 TS CAS。两个独立本地 source CLI 同 revision 竞争,独立读回一个 owner。

  • uncertain-send-retry 仍有缺口。历史 receipt 可恢复,当前投影变化使两次 provider 写入各有独立 key。

  • current-scope 在恢复中重验 actor、source、binding 和当前 quota。变更用例不会下发旧私有上下文。

  • live-reconnect 留给已授权的真实 Lark 房间、独立 Agent 主机及 daemon 验证。这个 head 的 CLI/Room transport 用例只能证明本机边界。

关键代码讲解

run_goal_channel_work 把绑定、预期 revision 和原 key 传给 canonical executeClaimAttempt。回调的 v4 还能带原 admit_before,native owner 在完成 provider/source reads 后、派发 CAS 前检查截止时间。跨读取到期的测试会拒绝,不写归属、不写 receipt 也不更新原卡。managed v2 继续沿现有路线。 Todo admission

build_work_card 把历史 accepted receipt 与实时 revision、可领数量和当前 owner 放进同一张卡。GoalChannelMessageDeliverySession.send 在有效绑定内查询精确卡片内容,对 provider 使用由调用 key 派生的幂等键。新卡的 revision 一变,两种去重依据一起失效。 卡片与 key · 现有 transport

run_room_resume 验证保存的已绑定 Turn receipt 和当前 quota,调用已有 Turn Recall 而后再读权威状态。漂移时会丢弃私有上下文,不从历史 receipt 获得新的执行权。 Resume readback

对主干的风险 / Risks

[P2] 同一领取在未知送达恢复时多发卡。 File 和 SQLite 各复现一次。首发被 transport 记录后回包丢失,期间用正常 todo add 增加一条无关 Todo,同一领取重试返回 already_applied、原 receipt 和有效读回。待办仍只有一次领取,房间却收到第二张卡,两次发送使用不同的 provider key。无中间改动时两种后端都只收到一张卡。 这条路径需要第一次实际送达,随后发生正常的待办变更。正常无变化的重试覆盖了原测试条件,回读已提交 owner 也不会看到第二个外部消息。把领取结果的消息身份和可回读卡片绑定到同一已接受的操作与当前有效的原投递路由。恢复用持久保存的原卡片或只含不可变领取事实的卡片,先核对原发送,再决定是否发送。当前 revision、可领数量和当前 owner 继续由单独的实时投影提供。 代码 · 同 key 恢复契约

语义与 CI 对齐

现有 v0/v1/v2 owner 的共同授权路径继续使用,新增 v3/v4 的来源证词和最后派发截止时间有 typed 守卫。普通直接 claim 也新增 bound_agent 和未资格验证 GoalRef 的拒绝,即使 Room 关闭也会生效。它们范围是 canonical 归属与 Goal 实例资格,Room 默认的 collector 和 recall 行为另有对照。对送达语义的修复应覆盖相同 receipt、相同 expected revision/key、前次发送不确定和中间有无关 revision 变化。修复后在 test_room_work.py 扩展未知送达用例,按 File 和 SQLite 两组各跑有无变化对照,再跑标准 premerge。

我的整体评价 / Verdict

Todo 的单一归属和 receipt 由既有 TS canonical owner 决定。Lark 承担人、Bot 和消息绑定检查,再复用现有消息投递。 本 PR 可完成 CLI 领取、原卡恢复和私有重连所需的有限前置能力。正常任务选择和真实安装不在当前交付边界。 32 文件中保留了现有权威 owner,最小修复集中在投递恢复身份。长程执行已有可用的认领前置能力,重复卡使恢复时又需要人工核对。房间读者应从一个已经接受的操作只得到一张可回读的卡。

本地运行通过 223 条 Python、22 条 TS 和 19 项标准 premerge。独立恢复回归 2 个对照通过、2 个状态变更失败。PostgreSQL 及托管 CI 未验证。当前前端改动已撤下。Lark 卡片结构通过合成 provider 的发送与读回验证,实际房间的渲染仍待验证。 真实 Lark 卡片首屏、已安装的 App 和两个独立鉴权 Agent host 未验证。

English verdict: REQUEST_CHANGES. On d7c7c28, the same canonical claim sends a second Lark card if the first response is lost and an unrelated Todo changes the projection. Keep the original delivery identity and card recoverable, and add the File and SQLite replay regression.

# Stable card identity permits lost-response recovery independently
# of the accepted state transition. No new claim is minted here.
card = build_work_card(packet)
key = "room-work:" + hashlib.sha256(json.dumps(card, sort_keys=True).encode()).hexdigest()

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] 用已接受领取的原消息身份恢复送达。 若首次发送已被 Lark 接收但响应丢失,而同一 Goal 的无关 Todo 在重试前更新了 revision,build_work_card 会改写卡片。按原 tuple/key 重试仍返回同一个 already_applied receipt,但用新内容查历史会失配,provider key 也随之变化。我在实际 CLI 的 File 和 SQLite 测试中都观察到两张卡,canonical claim 仍只有一次。请固定该接受操作及其原路由的消息身份和可回读内容,把实时投影独立读取,并在未知响应回归里增加无关 Todo 变更。 原 key 恢复说明

An accepted claim owned two unstable message identities: the card content
embedded the live projection (revision, claimable counts, current owner) and
the provider idempotency key was derived from that whole card. When a first
send was recorded by the transport and its response lost, an unrelated Todo
write between the attempts rebuilt a different card, defeated the exact-history
dedupe and minted a second provider key, so the room received a second card
for the same single canonical claim (reproduced on File and SQLite).

Claim result cards now carry immutable acceptance facts only (Goal, Agent,
task, acceptance, receipt id); live revision/counts/ownership stay in the
separate work-project orientation and machine readback. The provider key for
claim deliveries is derived from the claim identity (Goal, Todo, Agent,
original idempotency key), never from card content, and recovery checks the
original send first under that key. Orientation publishes keep their fresh
observation semantics. The same-key recovery contract in the room-work
reference is updated in both languages.

Regression matrix in test_room_work.py: File and SQLite x {unrelated Todo
write between attempts, no change}; each variant retries the same
Agent/Todo/revision/key after an uncertain first send and requires the
original receipt, one canonical claim and exactly one room card. Both
intermediate-change variants failed before this fix.

Signed-off-by: Lihua <1017343802@qq.com>
@LIHUA919

Copy link
Copy Markdown
Contributor Author

Fixed on a new head 37500cc1e (single DCO-signed commit on top of d7c7c284b). Thanks for the precise counterexample — the root cause was exactly the double instability you identified: the claim result card embedded live projection facts (revision, claimable counts, current owner) and the provider idempotency key was sha256(whole card), so an unrelated Todo write between a recorded-but-unanswered first send and the same-key retry changed both dedupe bases at once (exact-history card match and provider key) and minted a second card.

Fix (minimal, delivery identity only; no owner/protocol changes).

  • Claim result cards now carry immutable acceptance facts only (Goal, Agent, task, acceptance, receipt id). Live revision, claimable counts and current ownership remain available through the separate work project orientation and the machine readback (receipt.current_owner / current_claim_matches_actor unchanged in the packet); they no longer participate in the card identity. The freshness-alert prefix also stays off claim cards — the card now asserts only historical acceptance, never current state. Orientation (project) publishes keep their fresh-observation card and content-derived key.
  • The provider idempotency key for claim deliveries is now derived from the claim identity (Goal, Todo, Agent, original idempotency key), never from card content. Same accepted operation → same provider key across any number of recoveries.
  • Recovery therefore checks the original send first: the transport's exact Bot-history match now sees a byte-identical rebuilt card under the same operation key, and only an unmatched operation performs an external write. Binding/route validity rechecks inside the delivery transaction are unchanged.
  • The IM callback result card (patched onto the original offer message by room_claim.py) uses the same immutable-fact builder, so its recovered patches are also operation-stable.
  • The same-key recovery contract in docs/reference/goal-channel-room-work.md is updated (EN body + 中文边界) to state the one-card-per-accepted-operation rule and where live facts live.

Regression matrix (test_unknown_delivery_recovery_binds_one_card_to_the_accepted_operation, File and SQLite via the existing parametrized fixture): first send recorded by the transport with the response lost, then a retry with the same Agent/Todo/expected revision/key; requires already_applied, the same receipt_id, exactly one canonical claim transition, and exactly one room message.

Backend Intermediate unrelated todo add Before fix After fix
File yes FAIL (second card, different provider key) pass — one card
SQLite yes FAIL (second card, different provider key) pass — one card
File no (control) pass pass — one card
SQLite no (control) pass pass — one card

The pre-existing no-change recovery test (test_reconnect_after_unknown_delivery_reuses_canonical_receipt) still passes on both backends.

Validation on 37500cc1e: room work/claim-callback/resume + outbound-guidance suites 202 passed / 0 failed; Ruff on the changed Python passes; loopx canary premerge --from-git-diff --git-diff-base 6a0f8bc17 (current merge-base) passes with 33 changed files, 0 failures, 0 manual holds, bilingual and public-boundary checks included. TypeScript surfaces are untouched by this fix. The known tests/test_steward_generic_monitor_todo.py F401 lint redness on main (#9074) is outside this diff and left for its owning change. PostgreSQL suites were not run locally this round; real Lark rooms, independent hosts and daemon reconnect remain unqualified, and maintainer merge authority plus a fresh exact-head review are still required.

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

Reviewed head 37500cc1e4195e28ed53cf290bab32ba995fffd9

Reviewer: model_agent · gpt-6.2-sol · OpenAI (runtime_reported, max)

直接 CLI 重试多发确认卡的问题已修复。房间回调仍有另一处阻塞:领取已提交后,如果实时投影读失败,原卡会永久丢失回执号。

动机 / Motivation

管家向 Goal 房间发布待办后,Agent 需要查清能领哪项工作。房间里获得明确授权的人也需要看到领取是否成功。

主干上的 Agent 直接查、领 LoopX 待办。加入房间领取后,先前实现遇到投递成功但响应丢失,再碰上无关待办更新,会在同一次领取的重试里多发一张确认卡。房间读者需要再核对哪张卡所指的操作已生效。

当前提交已修复直接领取响应丢失后的重复发送。回调领取在提交后读投影失败时,仍会把缺少回执的摘要卡当成最终结果。

管家的默认自动委派按现行产品方向运行。本 PR 交付本地 Agent CLI、受限 IM 领取回调与私有恢复所需的权威读回。

Agent 正常选择任务时的接入仍待实现。真实房间、多主机和 daemon 重连也待联调。

改动思路 / Approach

现有 TS Todo owner 负责一次性领取和历史回执。Lark adapter 核对指定身份再调用既有投递,实时投影从权威 Todo 重新读取。 本 PR 交付 CLI 查看、领取与受限 IM 回调,并在本地验证重试和私有恢复。实际安装和正常 Agent 工作选择接入仍待联调。 同一次领取在当前 scope 复核后只需识别原权威收据和原消息。显式执行负责发出领取意图,查询保留为预览;collector 对一次性领取回调仍默认关闭。可用性、当前归属与历史接受分别回读,读回失败时已提交的领取仍有持久证据。

具体改动 / Changes

本次从目标分支的共同提交审查 32 个文件,+3209 / −33。相对上一轮是领取确认卡、测试和公开说明的三个文件补丁。

验收依据为 docs/architecture/rfcs/agent-im-openviking-collaboration-v0.md(6a0f8bc17b439f1e5fa1d389ad5a87faf7d73b25)。canonical-ownership 已实现,真实并发只有一份归属。uncertain-send-retry 已实现,直接 CLI 丢响应后恢复同一确认。callback-committed-receipt 尚未满足,回调在领取后读投影失败会把无回执的卡当作最终发送。current-scope 已实现,回调与私有恢复仍读取当前授权。live-reconnect 递延到真实多主机和 daemon 的集成。 接受的 RFC

关键代码讲解

  • build_work_card 只把 Goal、Agent、Todo、接受事实和回执号写入领取确认卡。查看可领任务和当前归属仍读新的投影。 源码

  • run_goal_channel_work 从 Goal、Todo、Agent 与原请求 key 计算投递键。现有投递先通过原连接核对 Bot 历史,匹配时读回原消息。 领取 · 投递

  • executeClaimAttempt 统一守住当前 owner、revision 和回调截止。到期是在查当前权威后、发出新 CAS 前检查,历史接受和执行权限分别给出。 领取事务

  • handle_room_claim_callback 把明确授权的 Lark 主体、原交互和受限意图交给同一领取 owner,原卡保留可恢复的读回。 回调

对主干的风险 / Risks

回调在 canonical 领取提交后已有历史回执。后续实时投影读失败时,handle_room_claim_callback 走摘要卡分支,原 offer 被替换成没有回执号的卡片。该卡片被读回后标成已送达,collector 恢复会跳过它。 回调 · 恢复

File 和 SQLite 各跑正常对照及一个提交后读失败的用例。正常两组都显示回执号。读失败的两组 canonical 归属和回执都已确认,但回调返回 ok=true、card_update_verified=true,原卡只显示恢复摘要,后续恢复尝试数为 0。

有已接受回执时直接用不可变字段构造领取确认卡。无法确认一份已接受的回执时,保留当前用户可见的未确认提示。用原始回调、一次成功提交、提交后读失败和进程恢复对照,核对原消息里有同一个回执号且 revision 不再推进。隔离副本仅在回调确认已有接受回执时沿用现有卡片构造。独立的四组对照加原回调套件共 54 项通过,回执号显示在原消息且 revision 不再推进。

File 和 SQLite 各走两组真实 CLI 对照,Lark 响应由合成 transport 提供。首张卡已写入、回包丢失后,重试读回原消息和 receipt。有无中间新增的无关 Todo 都只发送一次、只使用一个投递键,而且重试保持当前 canonical revision。旧提交在两种后端的中间变更组各多发一张,静态对照均通过。

无 Room 连接时,直接 todo claim 在 File 和 SQLite 上各测试未绑定与绑定给调用者两种输入。base 和 head 都第一次 applied、同 key 第二次 replayed、owner 相同、只推进一次 revision。 共享 claim owner 同时明确拒绝两类非授权输入:与固定 bound_agent 不一致的调用,以及旧协议尚无能力绑定的 GoalRef。这一行为变化也适用于未启用房间的 caller,参考文档已明示。 注册新 Agent 后,仅具备注册仍无法借用现有房间资格。两种后端都在为该 Agent 配好独立连接后才接受领取。相同事件在 collector 关闭时不派发,显式启用后才进入受控回调。

验证通过:227 项 Python、22 项 TypeScript、独立 Agent 准入 2 项,以及标准预合并验证和 RFC 双语差分检查。当前前端改动已撤出。合成 Lark transport 验证卡片请求与原消息读回,实际房间首屏渲染、已安装的 App、独立已鉴权主机和 PostgreSQL 未在本轮验证。

语义与 CI 对齐

v3/v4 扩展同一 typed claim 的 source witness 和截止约束;v2 的受管执行语义继续独立验证。投递确认沿用已有的外部消息读回,原回执不会增加执行或续租权。 使用边界

我的整体评价 / Verdict

直接 CLI 的重复发送用原来失败的条件重跑已通过。两种本地存储上的回调仍需补齐提交后的回执恢复。用合成 transport 读回原消息并检查实际卡片字段。旧版飞书卡片搭建工具已停用导入,新版编辑须先创建草稿。真实飞书房间的卡片渲染、已安装 App、独立已鉴权主机、PostgreSQL 未在本轮验证。

English verdict: REQUEST_CHANGES. Preserve the committed receipt on the originating callback card after a transient live projection failure.

Comment thread loopx/extensions/lark/room_claim.py Outdated
# Refused admission must not publish a result card or change
# the durable offer. The native owner checks after its reads.
raise RoomClaimCallbackError("offer_expired")
card = build_work_card(claimed) if claimed.get("projection") else {

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] Keep the accepted room receipt when the live read fails

领取已经提交、随后实时投影暂时读失败时,claimed 仍有原历史回执,却在这里被替换成没有回执号的摘要卡。File 和 SQLite 都确认了真实领取和新 revision,回调仍返回 card_update_verified=true,collector 恢复跳过这张卡。已接受时直接用现有不可变回执构造原卡片,保持实时投影失败的提示与房间确认分开。

After the canonical claim commits, handle_room_claim_callback built the
result card only when the live projection read succeeded; a projection read
failure fell into the summary-card branch, replacing the original offer card
with a receipt-less summary that readback then marked delivered, so recovery
rightfully skipped it and the receipt number was permanently lost from the
room (reproduced on File and SQLite).

When the claim packet carries an accepted receipt, build the immutable
confirmation card (with the receipt id) from those facts alone, independent of
the live projection read. Without a confirmed accepted receipt, the honest
unconfirmed summary stays; no receipt number is fabricated. Recovery and the
stored result-card copy keep their existing construction, now only ever
holding a receipt-bearing card for committed claims.

Regression contrasts in test_room_claim_callback.py (File and SQLite): the
original callback, one successful commit, a projection read failure after
that commit, and process recovery; every variant requires the same receipt id
on the originating message and a canonical revision that does not advance
again. Both read-failure variants failed before this fix.

Signed-off-by: Lihua <1017343802@qq.com>
@LIHUA919

Copy link
Copy Markdown
Contributor Author

Fixed on a new head 97c27986d (single DCO-signed commit on top of 37500cc1e). The direct-CLI duplicate-card fix from the previous round is untouched.

Root cause, as your probe showed. After the canonical claim commits, handle_room_claim_callback built the result card only when the live projection read succeeded. A projection read failure after the commit fell into the summary-card branch: the original offer card was replaced by a receipt-less summary, provider readback then marked it delivered, and recover_room_claim_results correctly skipped a verified card — so the receipt number was permanently gone from the room while canonical ownership and the receipt were both intact.

Fix (callback card selection only; no owner, protocol or recovery semantics changed).

  • When the claim packet carries an accepted receipt, the immutable confirmation card (with the receipt id) is built from those acceptance facts alone — independent of whether the live projection read succeeded afterwards. build_work_card already produces exactly that immutable card from Goal/Agent/task/acceptance/receipt-id.
  • When no accepted receipt is confirmed, the honest unconfirmed summary stays; no receipt number is fabricated.
  • The stored result-card copy and recovery keep their existing construction — for committed claims they now only ever hold a receipt-bearing card, so a later recovery patch (if transport failed) also preserves the receipt.

Regression — four contrasts x two backends (test_committed_receipt_stays_on_the_original_card in test_room_claim_callback.py, File and SQLite via the parametrized fixture): the original callback, one successful commit, a projection read failure injected after that commit (read_canonical_todos_if_promoted raises in the work facade only), and process recovery (recover_room_claim_results). Every variant requires ok=true with card_update_verified=true, canonical_claim_accepted=true, the same receipt id visible on the originating message, recovery attempting 0 transports, and a canonical revision that advanced exactly once (the claim) and never again.

Backend Live projection read Before fix After fix
File succeeded (control) pass pass — receipt id on card
SQLite succeeded (control) pass pass — receipt id on card
File failed after commit FAIL (receipt-less summary card, recovery 0) pass — receipt id on card, revision fixed
SQLite failed after commit FAIL (receipt-less summary card, recovery 0) pass — receipt id on card, revision fixed

The reference doc's callback paragraph (EN) and 中文边界 now state the rule: a committed claim's receipt id is published from immutable facts alone, a projection read failure cannot replace it with a receipt-less summary, and unconfirmed acceptance keeps the honest hint.

Validation on 97c27986d: room claim-callback/work/resume + outbound-guidance suites 206 passed / 0 failed (includes the pre-existing 18-case callback suite and the restart-recovery test); Ruff on the changed Python passes; loopx canary premerge --from-git-diff --git-diff-base 6a0f8bc17 (current merge-base) passes with 33 changed files, 0 failures, 0 manual holds, bilingual and public-boundary checks included. TypeScript surfaces untouched. PostgreSQL, real Lark card rendering, installed App, independent authenticated hosts and daemon reconnect remain unqualified; maintainer merge authority and a fresh exact-head review are still required.

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

Reviewed head 97c27986d75848b9565014a5a561f5ede4ac454b

Reviewer: model_agent · gpt-6.2-sol · OpenAI (runtime_reported, max)

上轮的回执丢失已修复。当前还有一个 P2。已撤销的卡片可以占满恢复名额,使排在后面的有效回执一直送不出去。 上轮评审

动机 / Motivation

管家发布房间待办后,受控 Agent 和获得领取授权的房间使用者需要在原交互上确认归属。 主干提供直接待办领取。当前提交让经授权的房间用户领取同一个 canonical Todo,并在原卡上确认结果。当前房间 grant 复核也约束断线后的消息恢复。

本次修复了投影读失败时的历史回执丢失。混合队列中的已撤销卡片仍会阻止后续有效回执恢复。 本次覆盖 Goal Channel CLI、受控房间回调和私有恢复。管家的默认自动委派沿用维护者接受的产品范围。 实际房间渲染、多主机和 daemon 重连,以及正常 Agent 任务选择的接入留待集成。

改动思路 / Approach

让现有 TypeScript Todo owner 完成一次 CAS。房间 adapter 复核授权并用既有 Lark 投递读回原消息,私有 resume 消费已获准的当前材料。 当前提交用已接受回执的不可变字段构造确认卡,即使提交后的 projection 暂时无法读取,房间用户也能核对原接收号。

本次覆盖 Goal Channel CLI、受控房间回调和私有恢复。管家的默认自动委派沿用维护者接受的产品范围。 实际房间渲染、多主机和 daemon 重连,以及正常 Agent 任务选择的接入留待集成。

具体改动 / Changes

与已验证的目标共同基点相比,32 个文件 +3261 / −33。相对上一轮,变动集中在房间回调、回归测试和公开说明。

验收依据为 docs/architecture/rfcs/agent-im-openviking-collaboration-v0.md(6a0f8bc17b439f1e5fa1d389ad5a87faf7d73b25)。canonical-ownership 已实现,两个入口共用同一个 Todo owner。uncertain-send-retry 已实现,CLI 重试读回原消息。callback-committed-receipt 已实现,实时读错误后保持原回执。current-scope 已实现,恢复仍复核现行授权。bounded-result-recovery 尚未满足,固定顺序的限额会阻塞仍有效的待投递结果。live-reconnect 留待独立主机和实际 daemon 验证。 接受的 RFC

关键代码讲解

  • run_goal_channel_work 使用原领取意图计算稳定投递键,已写入但丢响应的重试可查回原消息。 CLI 领取
  • executeClaimAttempt 在当前权威、revision 与截止时间约束下完成一次领取。房间消息、回执与当前执行资格有独立读回。 领取事务
  • handle_room_claim_callback 先确认 durable receipt,再决定原卡内容。读投影失败时同样能生成已接受的确认卡。 回调
  • recover_room_claim_results 读出未确认送达的原卡,随后才在锁内核对当前 scope。名额在复核之前已扣减。 恢复

对主干的风险 / Risks

[P2] 已撤销的卡片能挡住其他仍有效的回执。 两次合法领取均已提交,首次更新原卡均失败。撤销排序在前的 offer,并恢复正常的消息传输。 recover_room_claim_results 在复核 offer 是否已撤销、过期或已送达之前增加 attempted。永久失效的待投递记录持续留在固定排序的扫描前缀,每次耗尽名额。 File 和 SQLite 上,恢复限额为 1 时均得到 attempted=1、delivered=0、failed=0。限额为 2 的两组对照都把仍有效的回执送回原消息。撤销卡片和 canonical 快照始终保持原状。 房间读者已经成功领取工作,仍可能一直看不到原卡上的回执。默认限额为 20,排在前面的 20 条同类记录即可挡住后面的有效回执。 恢复循环

在锁内复核状态。让永久无资格的记录跳过投递名额或按现有记录终结。增加混合队列的回归,核对有效回执回到原消息、撤销卡片保留原状、canonical revision 保持稳定。

File 和 SQLite 的直接房间 CLI 共四组通过。无论是否新增无关 Todo,写卡后丢响应的重试都读回同一消息和回执,canonical revision 不再推进。 File 和 SQLite 的回调共四组通过。注入提交后的投影读错误时,原消息仍显示同一历史回执,回调和读回成功,后续恢复无新工作。 File 和 SQLite 的直接 CLI 各覆盖了未绑定及绑定给调用者的 Todo。基线和当前提交均只提交一次,同 key 重放读回同一归属及 revision。 新登记主体在建立独立的房间连接之前仍无法领取,默认关闭的 collector 仍跳过操作回调。共享领取 owner 现在也明确拒绝另一 Agent 的 bound Todo 以及尚未获得绑定资格的旧 GoalRef。 文档中的共享约束

当前提交通过 231 项受影响 Python 测试、14 项独立对照和 RFC 双语检查。上一轮通过 22 项 TypeScript 和标准预合并检查。当前 29 个路径未变,包含 TypeScript 实现及其测试。 当前提交的真实 CLI 和两种本地 authority store 已覆盖领取与重放。确认卡内容取自实际构造请求,合成 transport 读回原消息。有效回执能否持续送达仍取决于混合队列修复。 真实飞书房间、已安装 App、独立鉴权主机与 PostgreSQL 未验证。

语义与 CI 对齐

两次合法领取均已提交,首次更新原卡均失败。撤销排序在前的 offer,并恢复正常的消息传输。 File 和 SQLite 上,恢复限额为 1 时均得到 attempted=1、delivered=0、failed=0。限额为 2 的两组对照都把仍有效的回执送回原消息。撤销卡片和 canonical 快照始终保持原状。 在锁内复核状态。让永久无资格的记录跳过投递名额或按现有记录终结。增加混合队列的回归,核对有效回执回到原消息、撤销卡片保留原状、canonical revision 保持稳定。 用 python -m pytest -q test_5248_recovery_skip_terminal.py test_5248_recovery_budget_control.py 对照,保持现行 scope 拒绝。新增 v3/v4 继续扩展同一 typed claim 的 source witness 和 cutoff,原回执不授予执行或续租权限。 回执与范围

我的整体评价 / Verdict

请求修改。当前 exact head 已通过回执丢失的复核。合入前补齐失效记录与有效记录混合时的恢复,保证已接受且仍属当前范围的回执可达。

使用合成 Lark transport 检查实际消息体及原消息读回。 真实飞书房间、已安装 App、独立鉴权主机与 PostgreSQL 未验证。

English verdict: REQUEST_CHANGES. Skip terminal offers before they consume the result recovery budget, and verify the active receipt is delivered to its original message.

Comment thread loopx/extensions/lark/room_claim.py Outdated
not isinstance(d, Mapping) or d["app_id"] != profile_app_id or
d["chat_id"] not in allowed_chat_ids or d["profile"] != profile):
continue
stats["attempted"] += 1

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] recover_room_claim_results 在复核 offer 是否已撤销、过期或已送达之前增加 attempted。永久失效的待投递记录持续留在固定排序的扫描前缀,每次耗尽名额。 两次合法领取均已提交,首次更新原卡均失败。撤销排序在前的 offer,并恢复正常的消息传输。 两种 store 上,限额 1 时送达 0 条,限额 2 对照均送达第二条原回执。在锁内复核状态。让永久无资格的记录跳过投递名额或按现有记录终结。增加混合队列的回归,核对有效回执回到原消息、撤销卡片保留原状、canonical revision 保持稳定。

recover_room_claim_results charged a delivery slot (attempted++) before the
in-lock eligibility rechecks, so a permanently ineligible record — revoked,
expired or already delivered — consumed quota and then continued. The fixed
sort order kept such records in the scan prefix, letting them exhaust the
per-run limit on every recovery: with limit=1 a revoked offer first in sort
order permanently blocked the still-valid receipt behind it (attempted=1,
delivered=0), and with limit=2 the dead record still wasted half the budget
(attempted=2, delivered=1). Default limit 20 means twenty dead records block
everything behind them.

A slot is now spent only on an actual transport attempt, after every
eligibility recheck (scope state, admission, provider identity) passed under
the record lock. Permanently ineligible records are skipped without consuming
quota and without rewriting their file or message.

Mixed-queue regression (File and SQLite, limit 1 and 2): two legal claims
committed with both first card updates failed, the offer sorting first is
revoked, then recovery must deliver the valid receipt to its original
message, leave the revoked card and record byte-identical to their
post-revoke state, keep the canonical revision fixed, and find nothing left
on a second pass. The limit=1 variants starved and the limit=2 variants
wasted a slot before this fix.

Signed-off-by: Lihua <1017343802@qq.com>
@LIHUA919

Copy link
Copy Markdown
Contributor Author

Fixed on a new head 8307eab7e (single DCO-signed commit on top of 97c27986d). The committed-receipt fix from the previous round is untouched.

Root cause, as your probe showed. recover_room_claim_results charged a delivery slot (attempted++) before the in-lock eligibility rechecks. A permanently ineligible record — revoked, expired or already delivered — consumed quota and then continued; the fixed sort order kept such records in the scan prefix, so they exhausted the per-run limit on every recovery. With limit=1 a revoked offer first in sort order permanently blocked the still-valid receipt behind it (attempted=1, delivered=0); with limit=2 the dead record still wasted half the budget (attempted=2, delivered=1). At the default limit of 20, twenty dead records block everything behind them.

Fix (quota accounting in the recovery loop only). A slot is now spent only on an actual transport attempt, after every eligibility recheck — scope state re-read, admission (revocation/expiry), provider identity — has passed under the record lock. Permanently ineligible records are skipped without consuming quota and without rewriting their record file or message. Scope rejections keep their current semantics; no owner, protocol or card-construction change.

Mixed-queue regression (test_revoked_offer_cannot_starve_valid_receipt_recovery in test_room_claim_callback.py, File and SQLite via the parametrized fixture, limit 1 and 2): two legal claims on two Todos both commit while both first card updates fail; the offer whose rc_*.json sorts first is then revoked; recovery must (a) deliver the still-valid receipt onto its original message, (b) leave the revoked card's message content and offer record byte-identical to their post-revoke state, (c) keep the canonical revision fixed at the two committed claims, and (d) find nothing left on a second recovery pass.

Backend Recovery limit Before fix After fix
File 1 attempted=1, delivered=0 — valid receipt starved attempted=1, delivered=1, valid receipt on its original card
SQLite 1 attempted=1, delivered=0 — valid receipt starved attempted=1, delivered=1, valid receipt on its original card
File 2 (control) attempted=2, delivered=1 — dead record wasted a slot attempted=1, delivered=1
SQLite 2 (control) attempted=2, delivered=1 — dead record wasted a slot attempted=1, delivered=1

In every after-fix variant the revoked card and record stay untouched and the canonical revision does not advance. The room-work reference's recovery paragraph (EN) and 中文边界 now state that permanently ineligible records never consume a recovery delivery slot.

Validation on 8307eab7e: room claim-callback/work/resume + outbound-guidance suites 210 passed / 0 failed (includes the pre-existing restart-recovery and committed-receipt regressions); Ruff on the changed Python passes; loopx canary premerge --from-git-diff --git-diff-base 6a0f8bc17 (current merge-base after refreshing main) passes with 34 changed files, 0 failures, 0 manual holds, bilingual and public-boundary checks included. TypeScript surfaces untouched. PostgreSQL, real Lark card rendering, installed App, independent authenticated hosts and daemon reconnect remain unqualified; maintainer merge authority and a fresh exact-head review are still required.

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants