Repository navigation
fix(tasks): manage execution leases through ordinary task operations - #7510
Conversation
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent; gpt-6.1-sol; OpenAI; runtime_reported; reasoning_effort=max
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
动机 / Motivation
使用普通 CLI 领取、推进和完成任务的已注册 Agent。在 hard_lease Goal 中,明确认领给自己的 Agent 过去仍须另做 lease acquire 并复制 key/version;本 PR 让同一次自认领准备执行,后续进展和完成沿原 claim reference 继续。
真实 File/SQLite CLI 对照确认:新头可用原认领完成任务,错误引用不会改写任务,进展重放不增加 provider revision;基线同输入仍因缺少 lease 拒绝。本切片只简化普通 CLI 的既有执行流程,不扩大 Agent 权限,不改变 Goal policy、只读 guard、App 手工完成资格或外部进程监督,也不证明安装采用和长期净收益。
改动思路 / Approach
执行引用与按需续租归同一 TS coordination owner,继续调用现有 acquire、lifecycle、workspace 和 provider CAS;Python 只运输请求与生成命令,避免增加第二套租约决策或后台监督。
当前 PR 保留自认领、进展和终态三个紧密相连的入口;只在显式 actor 与 assignee 相同且未给显式 proof 时改变 CLI 默认,独立租约命令和其它调用方保持原边界。
原 claim ID 用来选择“当初接受的哪次执行”,不是从 store 任取最新 lease 的快捷方式。初次准备、进展维护与完成释放分别保留原 owner,receipt recovery 先于维护,避免丢响应后的重试延长执行。保留这个组合比另建 supervisor 更符合普通任务的边界。
| 触发 | 本次行为 | 仍然拒绝的情况 |
|---|---|---|
| 明确 CLI 自认领 | 同事务取得或复用该执行,返回原路由命令 | 不合法 actor、原 acceptance/scope/claim 冲突 |
| 用原引用写进展 | 原 lease 最后三分之一才按原 TTL 续租 | 过期、换代、foreign holder、source/CAS 失败 |
| 完成及原 Turn 收尾 | 原 terminal owner 释放,同 Turn 可升级 closeout | 新 operation 借已释放 proof 执行新工作 |
该表解释源码分支,执行证据来自下面的真实 CLI/backend 对照。
具体改动 / Changes
已核完整 20 个路径(+545/−37),包括 CLI 参数、Python transport、TS claim/update/terminal、Markdown、两语言文档及跨 provider 回归。以变更前 docs/reference/handoff-mode.md 的 4b87417637126856ff23b5230c215201d278875a 为依据:Goal handoff mode、Recover a canonical Todo edit with retained lease history、Choose the policy independently of storage 三项均落实;原 App 手工完成与独立 policy migration 边界保留。原合同
关键代码讲解
handle_todo_command只为明确 self-claim 选择新默认。返回命令保留 registry/runtime 与原 claim ID,显式 proof 输出继续保留诊断。claimExecutionProof先核原 receipt 的 Goal、Todo、actor,再比较当前 key、epoch、workspace/repository;续租可增加 version,换代不能冒用原引用。maintainClaimExecution只维护仍 active 的 grant,使用原 TTL 和现有 lifecycle decision;并入 progress 的同一 CAS,没有独立续租半成功状态。executeCoordinationTodoUpdate先恢复已接受操作,再解析引用、通过原 admission,最后原子写入进展与维护。重试不会再次续租。executeCoordinationTodoTerminalLifecycle复用原 completion/release;已释放执行仅供原已完成任务的同 Turn closeout,不授予新 completion 操作。
新 claim v2、update v6、terminal v4 对旧 wire 携带新字段明确拒绝;升级前 plain-claim 原 ID 重试恢复旧 assignment,不悄悄转成 managed execution。新增 helper 集中引用解析和可选维护,未再造 lease policy。
对主干的风险 / Risks
最大风险是便利入口借用了后来执行,或重放不断续租。本次独立 File/SQLite CLI 检查了 missing reference、foreign actor、cross-Todo 和混用显式 proof:均拒绝且 task/provider revision 不变;拒绝后原合法引用仍能继续完成。同一 Goal 的独立显式任务可在原任务 active 时完成,新建任务必须以自己的新 claim 执行。显式 proof 控制在 base/head 保持 scope、completion 和 replay;soft-claim 的新输出多了引用与命令,但仍不创建 lease,这个差异不冒称整包字节相等。
PASS:24 项真实 CLI 回归;1,182 项 File/SQLite/NoKV/runtime 测试;隔离真实 PostgreSQL 16.15 的 376 项测试,均无失败/跳过。near-expiry、expired/replaced、失响应重放、source/CAS 故障、旧 wire 拒绝和原 Turn 收尾分别有覆盖。typecheck 通过;标准 premerge 的 6 项 direct 与 19 项 selected 全过,0 manual holds。最初 reviewer probe 误取 revision 字段而失败,修正为真实 authority_read.provider_revision 后严格对照通过;没有修改产品或放宽断言。未查询或等待 CI。
PR 正文另报告四项 browser CI 失败:两项缺 pytest、两项初始行数 20 与预期 3 不符,作者也未完成匹配基线归因。本次按 wait_for_ci=false 未查询这些 jobs 或日志,不将作者描述认证为无关基线问题,更不将远端红检查改记通过。当前代码判断依据本次真实共享 authority/CLI、显式旧路径和负例的独立覆盖;这些未核远端观察及其 merge hold 单独保留。
语义与 CI 对齐
本次扩展既有 transport vocabulary,不改变 handoff enum 或 Goal policy。immutable base 的 advisory 未检出其支持的闭集载体;schema 字符串与新增字段仍做了人工逐项核对,不能把空报告当完整语义证明。next actions 是指导,receipt/actor/generation/expiry/CAS 是强制规则;原 Turn settlement 义务明确保留。
我的整体评价 / Verdict
APPROVE,绑定 2c9a2a6e43e15ca21aba9275050ab048f5bba3b6。普通 CLI 从“先补 lease 操作并手抄计数”变成可继续到完成的现有任务旅程;无需额外人类确认。长期执行约束保留,工程成本限于一个同域组合 helper、显式版本门和现有事务接入,当前范围合适。本次检查的是 CLI 命令、JSON/Markdown 读回及共享 authority owner;未改 App 组件、报告布局或其它 rendered presentation,截图不适用。未验证正式 App 安装、自然模型遵从、长期空闲外部进程或匹配条件下的成本净收益。原 App 手工完成仍遵循既有权限说明。作者 wheel 与安装宣称未当作本次独立实测;本结论基于当前源码、真实 CLI 及隔离后端,也不构成 merge 授权。
English verdict: APPROVE 2c9a2a6; the ordinary CLI lifecycle is usable while original execution, replay and authority fences remain intact. Local and real PostgreSQL validation passed.
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
2c9a2a6 to
b4237bb
Compare
Ordinary Agent CLI work currently needs separate lease preparation and hand-copied execution counters even when the caller is already claiming its own task. This change prepares execution atomically with a CLI self-claim and returns ready progress/completion commands using the original claim operation. Near expiry, progress renews the still-active execution in the same write transaction; completion uses the existing terminal/release owner. JSON and Markdown keep the normal output focused on these task operations.
The default changes only for CLI self-claim with an explicit actor matching the assignee and no explicit lease proof. Other assignment callers, explicit lease commands, soft-claim policy and Goal policy keep their existing semantics. The shared TypeScript helper reuses the current acquire, lifecycle, workspace and provider CAS owners. Read-only guards do not acquire or renew. This does not add supervision for an idle external process or change the App's manual completion authority.
Progress/completion resolve only the execution accepted by the original claim. Expiry, a replaced generation, a foreign holder, policy loss, unavailable receipts and source/CAS failures reject without silently acquiring a new grant. Exact operation recovery runs before maintenance. Pre-upgrade plain-claim retries retain their original assignment semantics; same-Turn completion closeout can reuse its retained released execution without authorizing new work. Versioned claim/update/terminal request contracts reject these new fields on old wire versions.
Validation:
2c9a2a6e43e1: all selected checks passed, with no failures or manual holds. No merge or benchmark-outcome qualification is implied by these engineering checks.The bilingual handoff reference documents activation, changed defaults, recovery and scope. No frontend presentation changes or private benchmark evidence are included. The bounded refactor centralizes execution-reference resolution and optional maintenance while keeping authority with the existing owners.
Current head is rebased onto
15471f8e832d7fb5893539fa053170ea233de5a7:b4237bb86edad5d145aaff7c40a3aa4732e8fbc5. Range-diff confirms the original implementation patch is unchanged. This brings in the independently merged #7508 fixture and scenario corrections.At the rebased head, the File/SQLite claim and execution-reference CLI tests passed (19), local canonical runtime tests passed (36), control-plane typecheck passed, and standard premerge passed all 6 direct and 19 selected checks. After rebuilding the production Chat bundle, the two packaged browser scenarios
managed-agent-sessionsandresearch-finding-readerboth passed. An initial browser invocation correctly rejected stale pre-rebase assets; the matching build fixed that prerequisite.Old-head hosted CI remains failed: four browser jobs plus the dashboard build reached the same two failure categories addressed by #7508 (missing pytest and the finding-reader's obsolete collapsed-row assertion). These are retained historical failures. The two scenarios were independently rechecked at the new head; full new-head hosted CI and review remain pending. The published review for the old head is historical, and these checks grant no merge authority.