Repository navigation
fix(memory): consume committed selection receipts in turn recall - #7098
Conversation
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent; model=gpt-6.1-sol; provider=OpenAI; declaration_source=runtime_reported; reasoning_effort=max
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
Reviewed exact head: be108100c49c8b9f991b15623590e188ebb1903f. No blocking findings.
动机
使用原生 quota 选定任务后调用记忆的 Agent 会遇到这个问题。原先,任务选择已经提交,记忆入口仍把升级后的收据判为未提交;现在同一份身份一致的收据可以直接进入召回。隔离的 File 与 SQLite 原生入口验证了召回成功、同轮重试去重以及错误身份零查询。本 PR 只修复这个 CLI 衔接,不证明记忆提升任务效果,也不改安装、调度或发布权限。
改动思路
身份校验留在既有 CLI 输入边界,规范身份由现有 TypeScript 结算 owner 生成;provider I/O、记忆策略和收据存储继续由原 owner 处理。当前 PR 完成交付选定收据到召回的源码修复、文档与回归测试;安装后的真实采用与收益仍由现有记忆实践验收。
原生选择会把原来未绑定任务的心跳收据升级为 upgraded。这是已经提交的收据状态,不是一次新的选择授权。单纯把该字符串加入白名单会漏掉身份矛盾,因此先核外层 Goal、Agent、Turn,再用既有 SettlementIdentity 解析绑定并生成规范 effect 身份;Todo 或 replan 必须与同一包里的选定工作一致。重复执行继续走既有记忆收据,不另造状态、记忆库或 provider。自动 hook 是另一个既有调用入口,本次修复文档中独立的显式 CLI 消费路径。
具体改动
规范依据为 loopx/capabilities/agent_turn_recall/README.md,spec_revision=770b11c9512eb7f9097329417072a4ad72d0af78:固定版本契约。按变更前契约逐项验收:Usage-exact-packet 已实现原包消费;Guidance-authority 保留记忆无执行授权边界;Turn-repeat 保留同轮去重;Freshness-failure 保留身份、freshness 和失败零副作用。README 新增七行仅说明恢复支持和兼容范围,没有反过来改写规范来证明实现。
关键代码讲解
_validate_quota_identity:保留外层身份错误优先级;允许原生upgraded,但必须携带精确绑定。复用 TypeScript owner 的规范身份和现有 replan 提取器,拒绝缺失、错任务或伪 effect。旧committed/replayed无绑定请求继续接受;若主动提供绑定,则现在也校验一致性,这是明确披露的收紧。handle_agent_turn_recall_command:仍先检查实验配置,再读取原始 packet;身份通过后才构造 situation、去重或调用 provider。配置关闭时甚至不解析坏输入;重复调用使用原收据且不追加查询。_runtime_unavailable_payload:合并两个 provider 调用前的安全错误投影,覆盖身份运行时和权限 checkpoint 读取失败。不把 provider 已开始后的错误包成“零调用”,也不输出原始启动详情。
四个文件共 +323/-20;生产 CLI +62/-20,文档 +7,其余为原生与单元回归覆盖。新原生测试直接执行 quota → 显式选 Todo → CLI 预览/召回 → 重试,对隔离 FileAuthorityStore、SQLite 检查真实状态与收据。记忆端通过真实 adapter 调用无凭证子进程 fixture;不是 live service 验收。
对主干的风险
最强反例是外层身份正确、内部 Todo/effect 却被改写:仅放行状态字符串仍会错误召回。当前在 provider 前拒绝,旧收据字节保持不变。错误 Goal/Agent/Turn、未提交、缺绑定、freshness conflict 和身份运行时故障都有针对性反例;既有 provider 检索和独立 Agent 绑定套件也纳入验证。
本地 66 项测试通过,原生 File/SQLite 两项最终读回通过。另以相同隔离 fixture 对固定 base 与当前 head 跑 14 组真实 CLI 对照:12 组保持完整错误、状态和副作用边界;两组有意变化是原生升级收据从拒绝变可用,以及不一致的已提供绑定从忽略变拒绝。旧版本确实在同一原生测试报“receipt is not committed”,修复版通过。重复执行只查询一次,冲突与关闭均零查询、零 quota spend。
语义与 CI 对齐
复用既有 upgraded 与结算身份词汇,没有新协议、权限或第二套决策 owner。生产语义 advisory、Ruff、17 文件配置类型检查、公开边界及双语 RFC 差异检查通过;标准 premerge 为 6 个直接检查和 15 个选中检查,全通过,精确 diff 的质量收据有效。当前 Goal 明确 wait_for_ci=false,未拉取、轮询或等待远端 CI。初始 fixture/setup 调整和错误扫描范围的失败保留在本地证据,后续按正确作用域验证,未作为全仓通过。
我的整体评价
源码修复任务达到 goal_achieved;完整记忆收益任务仍未据此完成。长程维度判为 preserved:恢复入口后,同轮重试和后续状态仍由既有 owner 保证,无重复花费;没有把一次召回当作效果提升。使用体验 improved:同一个已经授权的命令即可继续,不要求重新选任务、手改 packet 或增加确认。
检查 loopx/capabilities/agent_turn_recall/cli.py 的 CLI 返回路径;没有渲染界面或布局变化,无需视觉验收。未验证范围为全局安装、Windows、真实外部记忆服务及因果收益;它们不在本次源码验收声明内。保留历史无绑定输入有实际兼容依据,局部错误投影合并有两个真实调用点;不再扩展框架。当前改动范围与确定性故障相称,无阻塞发现。此结论是作者账号的 COMMENTED 自审记录;合并权限、合并就绪和安装后采用仍是独立判断。
English verdict: APPROVE — be108100c49c8b9f991b15623590e188ebb1903f fixes the native selected-receipt CLI failure using the existing canonical identity owner. Focused tests, real File/SQLite CLI flows, 14 baseline/head comparisons and repository premerge passed. Live-provider/installed adoption and causal utility are not claimed; this author-owned COMMENTED review does not authorize merge.
Goal and delivered outcome
The documented
quota should-run→ explicit Todo selection →agent-turn-recallpath rejects the selection's committedupgradedreceipt as “not committed.” This prevents the selected work from reaching memory retrieval even though its settlement identity is valid.The CLI now accepts that native receipt after checking its Goal, Agent, Turn, selected Todo or replan obligation, and canonical effect identity through the existing settlement owner. Inconsistent or missing upgraded bindings fail before provider access. Legacy unbound
committed/replayedinputs remain supported. Runtime verification failures use the existing safe zero-provider-call response.main.Implemented against
Specification: Agent Turn Recall usage and failure contract, with the existing quota receipt owner.
_validate_quota_identity; native selection-to-recall cases for File and SQLiteSelf-check: read the receipt producer, TypeScript-owned identity adapter and existing recall caller; ran the focused suites, original-defect counterfactual, static checks, boundary scan and managed premerge. No new configuration or shared state owner.
Scope and continuation
Complete source repair for this CLI handoff, with capability documentation and regression coverage. The error-response extraction only consolidates the two pre-provider failure sites. Automatic hooks, storage protocols, scheduling, publication permissions and memory policy are unchanged. Installed rollout and causal memory benefit are separate from this source proposal.
Validation
be108100c49c8b9f991b15623590e188ebb1903f.770b11c9512eb7f9097329417072a4ad72d0af78with the original pre-provider rejection, then passes on the candidate; exact source restoration verifiedReproduction:
uv run --extra test python -m pytest -q tests/control_plane/test_selected_turn_recall_cli.py. The existing memory suites cover default-off and provider boundaries. No PostgreSQL authority or persistence implementation changes.Frontend / visual evidence
UI impact: none. This repairs the existing CLI consumer; no frontend journey or visual layout changes.
Type / area / boundary