Repository navigation
perf(cli): collapse status RPC storm and heartbeat-prequota double reads - #9392
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 · Gemini · Google · self_reported
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
动机 / Motivation
频繁调用 loopx status --agent-id 查看个人或智能体队列的维护者,以及高频周期运行 loopx heartbeat-prequota 的本地调度守护进程与终端用户。 在多目标、多 Todo 的工作区中承受重复 TCP RPC 与全量 rollout 日志解析开销。改前在三目标(每目标25条Todo、200条rollout事件)工作区执行 status --agent-id 需发起145次TCP RPC(其中todo.read 6次、todo.context.page 46次、todo.succession.project 6次),空转 heartbeat-prequota 仍扫描2次完整rollout日志;改后同一精确头在File与SQLite上保持规范化JSON与Markdown完全一致,status总RPC降至97次(todo.read 3次、todo.context.page 13次、succession 0次),清洁 prequota Python rollout扫描降至0次,稳态处理耗时最高提速2.14倍。 可观测改进效果:status与heartbeat-prequota在File和SQLite后端均输出与origin/main完全等价的JSON和Markdown,同时在权威变更(claim/rollout append)与权威目录缺失时同步fail-closed拒绝复用。 明确边界:本PR不更改canonical Todo存储格式、不引入跨进程常驻头缓存、也不改动lease快照与canonical_contract_fields的只读隔离边界。
改动思路 / Approach
本 PR 严格遵循单一真相源与现有控制面所有权边界,从两条热路径同时压缩无效工作:首先在 handle_status_command 中开启 effect_runtime_request_scope(),令 collect_status 与 attach_agent_lane_next_actions 共享同一已读快照标识,并通过 TypeScript projectCanonicalQuotaBatch 在服务端重新校验实时 store_identity、provider_revision、cursor 与 rollout_log_stat 后批量生成 quota 规划;其次针对已知会丢弃 handoff_note 的显示投影路径传入 include_handoff_note=False,并在 _CanonicalTodoSummary 标记已评估的 handoff_gates,同时复用已生成的 interaction_contract 与 captured_local_workspace。在 heartbeat-prequota 中,则通过延迟加载且带变更失效的 role=None 共享 todo_loader,在 list_readback.py 移除无用前向扫描、在 TS planPrWaitObservationsFromSource 空待等时跳过日志读回,并为 pr_review_ack 引入逆序字节预过滤迭代 iter_reverse_rollout_events_by_kind。
每个新增或复用机制都由对应边界的真实所有者(TS authority head校验、Python调用方显示投影开关、prequota请求级失效缓存)承担,职责清晰且无跨层持久化耦合。 本PR限定在单次CLI请求生命周期内消除status重复read/N+1上下文分页与heartbeat-prequota重复rollout扫描及todo读取,不跨进程缓存authority头、不合并coordination.local_authority.todo_snapshot租约读取,也不改动任何持久化或对外CLI契约。
具体改动 / Changes
关键代码讲解
本次对照 docs/reference/canonical-snapshot-pagination.md(基线提交 f0ca9cef0e394b62d4a0f28c54beba16cb7aa29c)验证三项核心契约:CSP-1 禁止跨调用缓存 provider 头并要求投影前校验实时版本与日志状态(implemented 于 loopx/control_plane/todos/read_transaction.ts#projectCanonicalQuotaBatch);CSP-2 保持 canonical_contract_fields 只读摘要不混入租约并返回完整 replay_read(implemented 于 readCanonicalTodoProjection);CSP-3 保持规划摘要在删除冗余展示字段时与独立读取语义完全等价(implemented 于 select_quota_todo_contexts)。
loopx/control_plane/todos/read_transaction.ts#projectCanonicalQuotaBatch(Line 238):接收todo_quota_planning_batch_v0批次请求与authority_checks,逐一调用requireCanonicalAuthority、readAuthoritySnapshot与readRolloutLogStat比对当前真实磁盘/SQLite 状态,任何 Revision 推进、rollout 日志追加或权威不可用均显式 fail-closed 报错,然后调用projectTodoQuotaPlanning输出完全一致的quota_wires。loopx/control_plane/todos/todo_summary.py#open_todo_items(Line 445):保留默认include_handoff_note=True以保证现有独立调用方兼容性,仅由first_open_todo_text、project_asset_todo_summary及两个仅统计数量/候选过滤的 status 投影模块显式传False,将随deferred_count增长的todo.context.page调用从 46 次压平为与零延迟任务一致的常量 13 次(三目标)。loopx/heartbeat_prequota.py#run_heartbeat_pre_quota(Line 22):在单次effect_runtime_request_scope()内提供懒加载共享todo_loader(role=None)及写后失效回调on_todo_mutation,让pr_gate_reconcile、pr_review_ack与pr_wait_reconcile在活跃 PR 等待+已确认审查场景下共享同一份todo.read(3 次降至 1 次)。loopx/rollout_event_log.py#iter_reverse_rollout_events_by_kind(Line 652):按块从文件尾部逆序读取并在json.loads前执行 UTF-8 原生字节前缀过滤(遇\u转义回退完整解析以防漏读),使清洁heartbeat-prequota的 Pythonrollout_events全量解析从 2 次降为 0 次。
对主干的风险 / Risks
最主要的潜在风险是请求内复用的 CanonicalTodoSummary 在 collect_status 与 attach_agent_lane_next_actions 间隙遭遇并发写入(Todo claim、rollout 事件追加或权威目录失效)而返回过期建议。现已在 projectCanonicalQuotaBatch 中对 store_identity、provider_revision、cursor 与 rollout_log_stat 做实时复检并用 test_status_reused_quota_projection_rejects_stale_and_unavailable_authority 在 File 与 SQLite 双后端实测验证 fail-closed 拒绝;同时将 include_leases 缓存撤回以避免违反 todo_read.test.ts:153 只读摘要合约。所有独立调用方保持 reuse_fresh_canonical_snapshot=False、默认 include_handoff_note=True 与独立读取回退,确保默认关闭隔离与无迁移成本;tests/control_plane/test_quota_settlement.py 存在的 4 条报错已核实源于基线 settlement_cli.py:315(args.quota_command 属性缺失),与本 PR 无关。91 条依赖本地 PostgreSQL 服务的 TS 测试未在本机执行(File 与 SQLite 全量验证通过)。
我的整体评价 / Verdict
| 指标/维度 | 实测结论 |
|---|---|
跨基线输出一致性 (origin/main vs HEAD) |
File 与 SQLite 下 status --agent-id 与 heartbeat-prequota JSON/Markdown 完全一致 (PASS) |
3目标 status --agent-id RPC 变化 |
145 -> 97 冷态 / 143 -> 95 温态(todo.read 6->3、todo.context.page 46->13、todo.succession.project 6->0) (PASS) |
清洁 heartbeat-prequota 扫描与耗时 |
Python rollout 扫描 2 -> 0,稳态 Handler 耗时 2.14x (File) / 1.66x (SQLite) (PASS) |
| 类型、Lint、棘轮与门禁验证 | tsc 0错、mypy 17文件0错、ruff 0错、棘轮 0债、canary premerge 18/18 与 test:control-plane 6802 通过(91 PG跳过) (PASS) |
本 PR 在精确头部实现了 long_horizon 与 user_experience 双维度收益,且未变更对外语义与状态词汇表(已对齐既有契约),全部本地必需门禁与双后端正反向验证均通过,可以合入(受作者自有 PR 限制采用 COMMENTED 形式发布批准结论)。
可视化检查:已检查变更路径(loopx/cli_commands/status.py、loopx/heartbeat_prequota.py、loopx/control_plane/todos/ 与 loopx/capabilities/issue_fix/),本次仅改动后端与纯CLI热路径,未修改任何前端/UI渲染界面。
英文简短结论
English verdict: APPROVE PR #9392 at exact head 9f6cfed; File and SQLite JSON/Markdown parity, stale-authority rejection, TS/Python validation, maintainability ratchet, and Goal-bound canary premerge all pass with status RPCs reduced 145->97 and clean prequota rollout scans reduced 2->0.
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh
Request changes conclusion (author-owned PR; GitHub blocks formal self-review)
动机 / Motivation
用 status --agent-id 查看待办的操作者和每次运行 heartbeat-prequota 的本地守护进程需要及时读到可恢复的待办。 单次 status 会重复请求 Todo 及后续规划,prequota 的干净路径也重复扫描日志。 减少 Todo RPC 与 rollout 日志扫描并保持完整可核验的权威新鲜度和输出语义。 复核范围是当前提交的 status、heartbeat-prequota、共享 Todo 读写边界及 File 和 SQLite。
改动思路 / Approach
在单次请求中复用已经验证的投影。TypeScript 继续拥有 Todo、恢复和源校验,Python 控制显示与发起读取。 复核范围是当前提交的 status、heartbeat-prequota、共享 Todo 读写边界及 File 和 SQLite。 在 File 和 SQLite 的单 Goal、24 个 Todo 与 200 条日志的隔离工作负载上,status 的 Effect 请求均从 49 降到 33,Todo 读从 2 降到 1。 Status 还跳过最终展示会丢弃的 handoff notes,复用工作区观测并减少用户冷却路径上的重复构建。prequota 保留现有 Todo 写入边界,按请求复用读回。
具体改动 / Changes
关键代码讲解
readCanonicalTodoProjection读取 canonical Todo 并计算含恢复条件的摘要,之后采样 rollout 文件状态。这个状态随摘要一起返回给 Python。projectCanonicalQuotaBatch对照实时 authority revision、cursor 及 rollout 文件状态,将已载入的小型摘要交给现有规划。select_quota_todo_contexts为当前请求的小快照走批处理,其他情况沿用带来源引用的独立读取。run_heartbeat_pre_quota将 Todo 读取交给同一个惰性加载器,已确认 Todo 写入会使缓存失效。空 PR wait 避免读取日志,iter_reverse_rollout_events_by_kind为审核 ACK 回读只解码可能匹配的行。
对主干的风险 / Risks
P2 日志 stat 与实际读过的快照脱节。 正常 pr_merge 写入发生在 Todo 投影读完 rollout 日志之后、初次记录文件状态之前。 File 和 SQLite 的批量路径都通过了版本和文件状态检查,却复用了旧投影。status --agent-id 的 attention_queue 输出 resume_ready=false。重新读取后,同一待办变成 resume_ready=true。 在同一时序下,当前头的原独立重读路径拒绝继续使用旧摘要。 初次 stat 读到新文件大小,第二次 stat 与它自然一致,但投影用的是旧日志。把用于校验的日志身份绑定到实际消费的快照。在读取过程中观察到源改变时,丢弃投影并回到现有的受控重读或拒绝路径。 原有追加负例在初次读调用返回后才写入,未覆盖这个间隙。
语义与 CI 对齐
当前头 40 项 Python、28 项 TypeScript 通过。基线与当前头的 PR 等待及日志读取套件各 85 项通过。Ruff 和 git diff --check 通过。 独立负例把一次正常 merge 事件追加控制在读取与采样之间。两个后端的公开状态命令先报不可恢复,重新读回后报可恢复。这里的「快照一致性」要求校验的是实际消费的来源。Canonical Todo 快照一致性 本轮使用隔离源码和真实本地 File/SQLite,按请求计数。真实 PostgreSQL、已安装态及远端 CI 未复测。
我的整体评价 / Verdict
请求减少的效果可以复现。合并事件已经写入时,当前批量检查仍接受旧的恢复结论。先把校验身份绑定到已消费的日志快照,再用 File 和 SQLite 重跑正常写入与并发写入两类对照。
English verdict: REQUEST_CHANGES at 9f6cfed. Bind the freshness check to the rollout snapshot actually consumed. A normal append between the original read and its initial stat leaves both backends reporting a stale resume state.
Eliminate the mid-read rollout TOCTOU window in readCanonicalTodoProjection: capture pre/post stat around the rollout log read inside readReceiptLogSnapshotWithStat, attach the verified witness during projection, refuse snapshot reuse (omit rollout_log_stat and reject missing/mismatched stat in projectCanonicalQuotaBatch and canonical_todo_authority_check) when any rollout file changes before post-projection verification, and perform a bounded single retry in status/review-packet CLI handlers when quota projection rejects a stale canonical source. Adds File and SQLite parity negative tests in TypeScript and Python status --agent-id suites. 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 · Gemini · Google · self_reported
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
动机 / Motivation
频繁执行状态查看命令的维护者与自主调度守护进程在多目标、多待办工作区触发循环读取与并发状态检查。此前在调用 loopx status --agent-id 与 loopx heartbeat-prequota 时,同一请求会在状态收集与动作决策间重复拉取完整 Todo 列表、为最终会被展示层丢弃的 handoff_note 字段逐条触发 N+1 分页查询、重复计算交互契约与本地工作区快照,并在无待观测 PR 或无审核回执时仍全量读取和反序列化 rollout_events 日志。改前三目标工作区单次状态查询需发起 145 次 RPC 并多次扫描事件日志,且旧日志采样窗口若遇合并事件落地会返回陈旧的未就绪状态;改后降至 97 次 RPC,并发写入会被原子校验拦截并单次重读,立刻返回就绪态。可观测结论为:File 与 SQLite 后端输出与主干基线完全一致的规范化状态与心跳结果,并发合并事件写入期间不再返回陈旧的未就绪快照。本改动不修改权威持久化存储格式,不引入跨进程常驻缓存,也不放宽任何权限或只读隔离边界。(其中 Todo 表示结构化待办条目,RPC 表示本地控制面远程过程调用,rollout_events 表示追加写出的阶段性执行事件日志。)
改动思路 / Approach
将滚动日志字节读取与前后文件状态校验收口到 TypeScript 控制面读取原语,将批校验与异常分类保留在既定交易所有者中,并将受限单次重读留在 Python CLI 编排层,兼顾热路径去重与 TOCTOU 安全性。当前 PR 仅覆盖单次 CLI 请求生命周期内的热路径读取复用与快照绑定验证,不改动持久 schema 或跨请求调度策略。
具体路径按控制权与数据流划分为四部分:
- 输入与不变量所有权(TypeScript 运行时快照层):由
readReceiptLogSnapshotWithStat持有滚动日志文件的单次读前后状态一致不变量——在readFile前后分别采样(dev, ino, size, mtime_ns, ctime_ns, mtime_ms)并核验与读取字节数bytes.length相等(文件不存在则核验前后均为ENOENT),而原有readReceiptLogSnapshot保持无额外stat以维持并发冷读字节共享。readGoalRolloutEventSnapshotWithStat将该读取证人(witness)传入readTodoResumeRolloutEvents、evaluateTodoResumeConditionsFromSource与projectCanonicalTodoFields。 - 交易快照绑定与批校验(TypeScript 控制面 Todo 交易层):
readCanonicalTodoProjection在投影完成时校验全部已读日志证人是否均稳定且精确匹配postProjectionStat,一旦读取或投影窗口发生追加、创建或轮转便省略rollout_log_stat以拒绝快照复用。下游projectCanonicalQuotaBatch与 Python 侧canonical_todo_authority_check均要求存在且精确匹配rollout_log_stat;一旦失败,服务端返回带quota_canonical_source_changed的错码。 - CLI 请求域复用与受限恢复(Python CLI 入口层):
handle_status_command与handle_review_packet_command在effect_runtime_request_scope()内传递reuse_fresh_canonical_snapshot=True,并在attach_agent_lane_next_actions打开propagate_stale_canonical_source=True。若并发pr_merge恰好在collect_status与批处理之间落盘并触发StaleCanonicalQuotaSourceError,CLI 仅触发一次受边界约束的全量重读。此外,已知丢弃handoff_note的 4 处摘要投影入口传include_handoff_note=False,并在_CanonicalTodoSummary记录handoff_gates_evaluated、在冷却与工作区观测层复用已构造对象,消除重复 RPC。 heartbeat-prequota共享读与逆向日志过滤(Python/TS 协调层):run_heartbeat_pre_quota在请求域内共享同一次role=NoneTodo 读取并在任何pr_gate_reconcile写入成功时通过on_todo_mutation立即置脏失效;list_readback.py移除冗余的 Python 侧 500 条前置日志加载;planPrWaitObservationsFromSource在waiting_targets为空时直接短路;iter_reverse_rollout_events_by_kind按行逆序扫描并利用 UTF-8 事件类型字节预过滤跳过无关 JSON 解析。
具体改动 / Changes
关键代码讲解
readReceiptLogSnapshotWithStat(loopx/control_plane/runtime/receipt_log_snapshot.ts:296):封装 rollout 日志文件的读取与前置/后置stat一致性核验,确认bigIntStatsMatch(pre, post)且BigInt(bytes.length) === pre.size(或文件前后均稳定缺失),仅此时向调用方返回stable: true与精确ReceiptLogStat。readCanonicalTodoProjection与projectCanonicalQuotaBatch(loopx/control_plane/todos/read_transaction.ts:31,188):前者通过onRolloutLogRead收集本次投影消费的每一个日志证人,在投影完成后验证证人稳定性并核对postProjectionStat,发现窗口变更立即省略rollout_log_stat以封堵原第 86 行 TOCTOU 漏洞;后者校验isReceiptLogStat(check.rollout_log_stat)且当前文件stat精确匹配,缺失或失配即抛出quota_canonical_source_changed。attach_agent_lane_next_actions(loopx/cli_commands/status.py:683):当propagate_stale_canonical_source=True且build_quota_should_run因并发写入抛出StaleCanonicalQuotaSourceError时不再吞错或保留resume_ready=false,而是上抛触发handle_status_command与handle_review_packet_command的 2 次上限重读,确保单次调用即可观察到最新resume_ready=true。run_heartbeat_pre_quota与iter_reverse_rollout_events_by_kind(loopx/heartbeat_prequota.py:19与loopx/rollout_event_log.py:652):在请求生命周期内协调pr_gate_reconcile、pr_review_ack与pr_wait_reconcile共享 Todo 读缓存并在写入后自动失效;逆序扫描事件文件时跳过不含目标event_kindUTF-8 标记的行的 JSON 反序列化(含\u转义回退保护),显著降低空载路径的 CPU 与 IO 成本。
改动范围与规格对照
本次审查精确覆盖 @361f2f2312 相对合并基线 @f0ca9cef0e 的全部 32 个文件(30 个生产源码模块与 2 个测试文件)。因本 PR 属于热路径优化与 [P2] 竞态漏洞(PRRT_kwDOStEbEs67XlvJ)闭环修复,无独立外部 RFC 或需求编号文档(no_spec),关键约束均对照既有权威读取不变量、File/SQLite 双端一致基线以及 CLI 并发行为规范逐条实证落地:状态查询与预配额去重均不改变对外字段含义,读中追加 pr_merge 场景全部拒绝陈旧快照并完成单次重读恢复。
对主干的风险 / Risks
对变更路径与边界进行了反事实验证与负向压力测试,当前不存在未关闭阻断项:
- 高并发日志写入窗口(已消除并验证):在
tests/control_plane_ts/todo_read.test.ts与tests/control_plane/test_status_prequota_hotpath_efficiency.py中通过受控 Node--import钩子分别对File与SQLite真实loopx status --agent-id入口注入了四类并发窗口——readFile执行期间追加pr_merge、readReceiptLogSnapshotWithStat后置采样结束到readCanonicalTodoProjection第 86 行检查前追加、ENOENT缺失后新建文件,以及collect_status返回后到projectCanonicalQuotaBatch批校验前落盘——所有 16 项 Python 测试与 42 项 TS 定向测试均证实不返回陈旧resume_ready=false且直接输出resume_ready=true。 - 局部投影裁剪与默认隔离性:
include_handoff_note=False仅应用于后续立即剥离handoff_note的 4 个展示辅助入口,build_quota_should_run默认仍保持reuse_fresh_canonical_snapshot=False,独立读取路径及完整 Todo 列表查询语义保持原样隔离。 heartbeat-prequota写后缓存失效与转义安全:on_todo_mutation绑定于reconcile_issue_fix_pr_review的实际写入结果,write_performed=True即刻清零请求缓存;iter_reverse_rollout_events_by_kind在行内存在\u转义时不跳过解析,防止 Unicode 转义事件漏读。- 公共边界、可维护性与语义词汇合规:
scripts/generate_semantic_inventory.py对变更前后增量扫描输出 0 个新增公共词汇候选;loopx check验证 32 个路径公共边界完全干净;可维护性棘轮检查 0 新增告警与 0 指标回退。
我的整体评价 / Verdict
综合对精确头 @361f2f2312 的逐文件检查与本地全量实测,本 PR 在不牺牲权威新鲜度或公共兼容性(observable_semantics=equivalent、default_off_isolation=isolated、authority_semantics=aligned、change_proportionality=proportionate、code_volume=necessary)的前提下,有效降低了高频热路径的 RPC 与全量扫描损耗,并彻底闭环了先前暴露的 mid-read rollout_log_stat TOCTOU 问题。对于系统长程稳定性(long_horizon=improved)与用户/操作者交互响应(user_experience=improved)均为清晰正向增益;本次改动仅覆盖命令行与控制面读写事务,未修改前端页面或可视化渲染,已检查变更清单确认无 UI 文件。
精确头 @361f2f2312 本地验证摘要(ci_policy=not_consulted, wait_for_ci=false):
npm run typecheck:control-plane: PASS(0 errors)npm run test:control-plane: PASS(6804 passed, 0 failed, 91 environment-gated skips;含todo_read.test.ts/pr_wait_observation.test.ts/receipt_log_snapshot.test.ts42/42 PASS)- Python
status/quota/ TOCTOU 套件(329 用例): PASS(329 passed, 0 failed,含 File/SQLite 8 项并发pr_merge竞态验证) ruff check,python -m mypy,check_rfc_bilingual.py, 可维护性棘轮,loopx check(32 路径),change-quality(cqr_bbd0ebf024162ab7aa4c),loopx canary premerge: PASS(6/6 direct checks, 10/10 catalog canaries, 8/8 risk-profile smokes passed)
English verdict: APPROVE PR #9392 at head 361f2f2312ad37473b0df0b4cb6bd09aef59c364; all 32 changed files and local checks pass with zero unresolved findings after closing the mid-read rollout rollout_log_stat TOCTOU window across File and SQLite (wait_for_ci=false).
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh
动机 / Motivation
读取 status --agent-id 判断待办何时可恢复的操作者,需要知道状态是已核实还是采集遇到源变化。 减少 status 与 heartbeat-prequota 的重复 RPC,同时使展示复用实际读过的权威快照。 先追加正常证据事件,触发有界重读,再在第二次采集后追加同一等待 PR 的 merge 回执。 单次追加已修复。File 和 SQLite 在两次采集后各追加一条普通日志时,两次均检测快照变化,最终状态却对外成功并继续显示 resume_ready=false,且不再提供 agent frontier。 本批覆盖现有状态、预配额和 Todo/rollout 读入路径,保持原能力各自的 owner。
改动思路 / Approach
观察收据日志的前后文件状态并绑定到投影,同次 CLI 按权威快照复用数据。Prequota 在同一调用内共享既有 Todo 读取。 已消费的 rollout witness 和当前 File/SQLite provider 都应匹配。状态展示本身不推进待办或授予合并权限。 由现有状态命令保留有界重读。最后一次检测到的失效仍需要随响应回读。
具体改动 / Changes
关键代码讲解
readReceiptLogSnapshotWithStat把读取前后状态和字节数纳入稳定性判断。 源码readCanonicalTodoProjection日志 witness 失效时不给该投影附带可复用标记。 源码handle_status_command首次检测变化回退重读,第二次不再传播错误。 源码attach_agent_lane_next_actions耗尽重读后跳过 lane 装配,保留已收集状态。 源码
32 文件,+1954/−276。增量横跨状态适配、Todo/rollout 读取和预配额,新增行为矩阵应把重读结束作为实际验证。 已用 quota_canonical_source_changed 报告变化,第二轮调用点丢失该诊断。 验收依据
SNAPSHOT-WITNESS单次日志变化不得通过旧证据的复用检查。 两个后端检测正常追加并恢复到 ready。EXHAUSTED-RETRY有界重读再次发现过期时必须显式报告不确定或拒绝。 连续两次日志追加后硬错误被吞,仍返回旧 ready 字段。
对主干的风险 / Risks
File 与 SQLite 都捕获两次 quota_canonical_source_changed。第二次吞掉类型错误后返回 ok=true、resume_ready=false 且 agent_scope_frontier 缺失。下一次无并发追加的同一命令返回 resume_ready=true 和 successor_replan_required。 [P2] 重读再次失效时,status 把旧 Resume 状态当成有效响应。 把第二次的类型化错误带到响应,或把对应 Goal 标为不确定。保留重试上限。 状态入口
语义与 CI 对齐
git diff --check 与当前 main 的静态合并通过。真实 File 和 SQLite 的单次与两次追加探针均完成。 单次追加的原缺陷已修。在当前头两个后端同一命令会重读并显示 ready。新增 Python 定向 16 passed,TypeScript 42 项通过。主干的相同单次追加仍可显示旧等待。 对当前 main 6031af7840 的变更路径无交集,静态合并成功。使用隔离本地 File、SQLite、真实 Node Effect runtime 和合成公开事件。未复测 PostgreSQL、已安装分发和远端 CI。未重测作者公布的计时倍数。
我的整体评价 / Verdict
Request changes conclusion (author-owned PR; GitHub blocks formal self-review)
本批可见变化在 status 的 JSON 与 Markdown 状态读回。 现有 RPC 减少可继续。补齐一处重读失败读回即可保留现有的复用机制。
English verdict: REQUEST_CHANGES at 361f2f2. The original single-append case is fixed. When both guarded reads detect source changes, status still returns success with stale resume readiness.
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
|
Fixed Fix Summary
Verification (
|
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · Gemini · Google · self_reported · effort_unavailable
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
本次复审基于 PR #9392 精确提交 67b7b7ef34ed393c4786b81907f1c44412fa56dd(分支 codex/collapse-status-prequota-rpc-tax-20261124 -> main,基线 f0ca9cef0e394b62d4a0f28c54beba16cb7aa29c)在干净临时 detached worktree 中完成全量审查与验证。上轮审阅 6042206084 在 361f2f2312 指出的阻塞性 [P2](EXHAUSTED-RETRY:连续两次并发写入时第二次尝试吞掉 StaleCanonicalQuotaSourceError,仍以 ok=true 返回陈旧 resume_ready=false)已在 67b7b7ef34 修复落地,且行内线程 PRRT_kwDOStEbEs67XlvJ 已标记解决。
动机 / Motivation
通过 loopx status --agent-id、review-packet 与 heartbeat-prequota 评估待办恢复时机和配额准入的操作者与 Agent 调度路径,需要较低的本地 RPC/日志扫描延迟,同时要求每次读到的 resume_ready 与 agent_scope_frontier 如实反映当前权威状态而非静默返回过期结果。 此前每次执行 status --agent-id 与 heartbeat-prequota 都会反复全量重读同一批 Todo 快照、重复分页读取 handoff 上下文并在无等待目标时全扫 rollout 日志;同时上轮提交 361f2f2 虽用预/后 stat 证人锁住了读取期间的日志替换,却因 propagate_stale_canonical_source=attempt==0 在第二次尝试吞掉 StaleCanonicalQuotaSourceError,导致 File 与 SQLite 在两次连续日志追加发生后仍对外返回 ok=true、缺失 agent_scope_frontier 且陈旧的 resume_ready=false。本次精确提交 67b7b7e 在 File 与 SQLite 上保留单一请求内快照复用与空路径短路的同时,对全部重试轮次传播 StaleCanonicalQuotaSourceError 并经 _annotate_status_collection_error 统一 fail-closed 返回 ok=False、code='quota_canonical_source_changed'、retry_attempts=2(退出码 1)。 在正常及单次并发追加场景下,status --agent-id 与 review-packet 自动复读最新权威快照并返回准确的 resume_ready=true 与完整 agent_scope_frontier;当有界 2 次重试均遭遇并发权威日志变化时,两个命令均严格 fail-closed 报错退出 1 并输出明确错误码 quota_canonical_source_changed;同时 heartbeat-prequota 在同一作用域内共享 role=None Todo 读并在写入时失效、跳过无意义的空 rollout 扫描。 本 PR 不改变 Todo 语义判定或调度优先级规则,不放宽 canonical-snapshot-pagination 鲜度与 TOCTOU 契约,不修改 PostgreSQL 测试环境,也不顺带修改未触及的 loopx/control_plane/quota/settlement_cli.py 中既有测试报错。 如果不修理二次重试耗尽后的静默吞错路径,高频调用 status 的上游调度器和操作者就会把读取窗口内的并发状态变化误认为确定性的未就绪结果。
改动思路 / Approach
本次优化按照“TS 控制面绑定真实读取证人 + Python 作用域内折叠冗余读 + CLI 两轮有界重试与失败关闭”三层边界协同:
- 快照绑定真实消费日志状态与 TOCTOU 防线(
receipt_log_snapshot.ts、rollout_receipt_log.ts、read_transaction.ts):readReceiptLogSnapshotWithStat在单次文件读取前后严格核对(dev, ino, size, mtime_ns, ctime_ns, mtime_ms)与bytes.length === pre.size(文件不存在时亦要求ENOENT前后一致),readCanonicalTodoProjection在投影末尾再次对比postProjectionStat,任一证人不稳或不一致即省略rollout_log_stat拒绝快照复用;projectCanonicalQuotaBatch与canonical_todo_authority_check强制要求完整匹配的rollout_log_stat,否则直接抛出quota_canonical_source_changed(Python 侧映射为StaleCanonicalQuotaSourceError)。 - 修复有界重试耗尽静默吞错(
loopx/cli_commands/status.py):提交67b7b7ef34将attach_agent_lane_next_actions的默认propagate_stale_canonical_source改为True,并通过共享辅助_attach_agent_lane_for_attempt(_STATUS_CANONICAL_SOURCE_MAX_ATTEMPTS = 2)同时服务handle_status_command与handle_review_packet_command(后者同步纳入effect_runtime_request_scope())。首轮遇到StaleCanonicalQuotaSourceError刷新重读;次轮仍失效则直接向上抛出至_annotate_status_collection_error,以非零退出码1返回明确ok: False、code/error_code: "quota_canonical_source_changed"、retry_attempts: 2。 - N+1 与空扫描消除及架构边界:保持 TypeScript 控制面(readReceiptLogSnapshotWithStat、readCanonicalTodoProjection、projectCanonicalQuotaBatch、planPrWaitObservationsFromSource)对快照读取鲜度、rollout_log_stat 证人绑定与待办恢复条件的单一决策所有权;Python 适配器仅在同一 effect_runtime_request_scope 内转发快照验证引用并在 status.py 集中执行两轮有界重试与 fail-closed 错误标注。 当前 PR 严格收敛在 status --agent-id 与 heartbeat-prequota 的热路径降噪(请求级快照复验、handoff_note/succession 冗余省略、工作区观测缓存、prequota 共享 Todo 读与反向前缀过滤扫描)以及 File/SQLite 并发追加有界重试与 fail-closed 护栏;未触及模块中的存量测试缺陷(settlement_cli.py)留作独立主干问题。
handle_status_command / handle_review_packet_command (effect_runtime_request_scope, max_attempts=2)
├─ attempt=0: collect_status -> _attach_agent_lane_for_attempt (reuse_fresh_canonical_snapshot=True)
│ ├─ rollout_log_stat 匹配 ──> 正常返回 ok=True, resume_ready, agent_scope_frontier
│ └─ StaleCanonicalQuotaSourceError ──> continue (进入 attempt=1 刷新收集)
└─ attempt=1: collect_status -> _attach_agent_lane_for_attempt
├─ 并发窗口恢复 ──> 返回最新 ok=True, resume_ready=True, agent_scope_frontier
└─ 再次 StaleCanonicalQuotaSourceError ──> _annotate_status_collection_error -> exit 1 (ok=False, quota_canonical_source_changed)
说明:上图基于精确提交
67b7b7ef34ed393c4786b81907f1c44412fa56dd源码梳理并发重试与失败关闭控制流,不替代下方实测执行证据。
具体改动 / Changes
关键代码讲解
loopx/cli_commands/status.py:198-233, 255-355, 716-778, 973-1021(_attach_agent_lane_for_attempt、_annotate_status_collection_error、attach_agent_lane_next_actions、handle_status_command、handle_review_packet_command):消除原本attempt == 0才传播异常的漏洞,让attach_agent_lane_next_actions默认传播且由共用重试器仅在attempt + 1 < 2时重试,耗尽后在两个 CLI 入口统一输出quota_canonical_source_changed与退出码1。loopx/control_plane/runtime/receipt_log_snapshot.ts:296-327&loopx/control_plane/todos/read_transaction.ts:94-106, 188-265(readReceiptLogSnapshotWithStat、readCanonicalTodoProjection、projectCanonicalQuotaBatch):将真实消费的字节和文件元数据状态严格绑定为rollout_log_stat证人,并在批校验入口强制核验权威修订与当前日志文件 stat 一致。loopx/control_plane/todos/quota_selection.py:329-372&loopx/control_plane/todos/summary_item.py:142-157(collect_quota_authority_checks、project_quota_wires_with_head_checks、canonical_todo_authority_check):仅对<= 500项且具备完整请求作用域与有效rollout_log_stat的快照启用批规划复用,将 TSquota_canonical_source_changed拒绝映射为StaleCanonicalQuotaSourceError。loopx/heartbeat_prequota.py:19-105&loopx/rollout_event_log.py:652-676(run_heartbeat_pre_quota、iter_reverse_rollout_events_by_kind):在同一effect_runtime_request_scope()内缓存共享role=None待办集合并在任何写入后精确失效,同时通过带\u转义保护的反向原始字节前缀过滤免去无关 rollout 事件全量解码,配合pr_wait_observation.ts无等待目标短路降低空路径延迟。tests/control_plane/test_status_prequota_hotpath_efficiency.py:718-888&tests/control_plane_ts/todo_read.test.ts:覆盖真实 File 与 SQLite 在readFile中途、读取后与 line 86 间、ENOENT后新建、collect_status后单次追加恢复,以及连续两次并发追加后status与review-packet有界失败关闭及后续 clean recovery。
规范对照(spec_basis)
按照仓库既有契约 canonical-snapshot-pagination.md(固定基线修订 f0ca9cef0e394b62d4a0f28c54beba16cb7aa29c)中的快照一致性与恢复规则逐项对照:
SNAPSHOT-WITNESS:implemented —readReceiptLogSnapshotWithStat、readCanonicalTodoProjection与projectCanonicalQuotaBatch绑定消费瞬间的前后文件状态及权威 head,拒绝任何读取期间写入漂移(tests/control_plane_ts/todo_read.test.ts、receipt_log_snapshot.test.ts与test_status_prequota_hotpath_efficiency.pyPASS)。EXHAUSTED-RETRY:implemented —loopx/cli_commands/status.py:198-233, 255-355, 716-778, 973-1021对单次追加有界重试恢复、对连续两次追加显式 fail-closed 返回quota_canonical_source_changed与退出码1(test_status_agent_lane_fails_closed_after_exhausted_canonical_source_retries[file|sqlite]&test_review_packet_fails_closed_after_exhausted_canonical_source_retries[file|sqlite]PASS)。NO-PARTIAL-FALLBACK:implemented — 当rollout_log_stat缺失或不一致时拒绝部分或陈旧复用并报错中止,不退化到伪成功状态(projectCanonicalQuotaBatch、canonical_todo_authority_check、handle_status_command)。
对主干的风险 / Risks
- 未发现 PR 引入的阻塞性缺陷(No PR regressions):上一轮审阅
6042206084的[P2]已在精确提交67b7b7ef34ed393c4786b81907f1c44412fa56dd修复完成,旧线程PRRT_kwDOStEbEs67XlvJ已解决(unresolved_count: 0)。全量 32 个文件变更均由handle_status_command、handle_review_packet_command、run_heartbeat_pre_quota与 TS 调度链路实际调用(scope_fit对齐);无新增公共协议/枚举(generate_semantic_inventory.py显示NativeGoalStatus位于基线origin/main且本 PR diff 为0字节;semantic_alignment为not_applicable)。 - 既有无关测试失败归因(
pre_existing_unrelated):在涵盖 40+ 个控制面与架构测试套件的全量pytest -n 6 -q运行中(4,729 passed, 1 skipped,其中唯一 skip 为tests/control_plane/test_quota_settlement.py:838Windows 原生 PowerShell 用例),出现 4 项失败,全部位于本 PR 未触及的tests/control_plane/test_quota_settlement.py(test_selected_todo_suppresses_stale_replan_packet_binding、test_current_replan_preserves_explicit_planning_selection_gate、test_explicit_replan_binding_survives_newly_selected_todo、test_rollout_projection_rejects_corrupted_dual_bound_plan),均在loopx/control_plane/quota/settlement_cli.py:315抛出完全相同的AttributeError: 'types.SimpleNamespace' object has no attribute 'quota_command'。在干净临时 worktree 同命令对比验证:PR exact HEAD67b7b7ef34输出4 failed, 82 passed, 1 skipped in 1.82s(HEAD_SETTLE_RC=1),不可变基线f0ca9cef0e输出完全相同的4 failed, 82 passed, 1 skipped in 3.26s(BASE_SETTLE_RC=1),且 PR 未触及settlement_cli.py或test_quota_settlement.py,确认为与本 PR 无关的主干既有缺陷,不阻塞本 PR 批准。 - 精确提交
67b7b7ef34ed393c4786b81907f1c44412fa56dd全量本地实测矩阵(不等待远端 CI):- TypeScript 控制面(PASS):
npm run typecheck:control-planePASS(0errors);node --test tests/control_plane_ts/todo_read.test.ts tests/control_plane_ts/pr_wait_observation.test.ts tests/control_plane_ts/receipt_log_snapshot.test.ts42 passed, 0 failed(含 File 与 SQLiterollout_log_statTOCTOU 用例)。 - File & SQLite 热路径等价、TOCTOU 与重试耗尽专项(PASS):
pytest -v tests/control_plane/test_status_prequota_hotpath_efficiency.py20 passed in 15.92s(0 failed, 0 skipped);独立对比tests/control_plane/test_status_collection_material_capability_wiring.py在 HEAD 与 base 均 10 passed。 - 广谱控制面、架构与棘轮 Pytest:
pytest -n 6 -q(status/canonical/quota/todo/goal_vision/monitor_replan/reward_memory/issue_fix/handoff/rollout/ratchet/architecture)4,729 passed, 1 skipped,加前述 4 项已归因pre_existing_unrelated失败(test_quota_settlement.py)。 - 静态与 Premerge 门禁(PASS):
ruff check(24.py文件)PASS;mypy(17 严格核心文件)PASS(0issues);mypy --follow-imports=silent(18 触及适配与测试模块)PASS(0issues);check_rfc_bilingual.pyPASS;module_metric_baseline.json零改动、oversized_in_pr: [];loopx check(32 个 PR 路径)ok: true(errors: 0, warnings: 0,public_boundary_scan.ok: true);diff 泄露扫描0命中;3/3 提交带 DCOSigned-off-by;loopx canary premerge --from-git-diff --git-diff-base origin/mainPASS(6/6direct checks、10/10catalog canaries、8/8risk profile smokes,merge_gate_passed: true,manual_hold_count: 0)。
- TypeScript 控制面(PASS):
- 残留风险与未核验边界:本轮未全量重跑整个仓库的
npm run test:control-plane(作者报告 6,804 passed,本轮重点验证了typecheck:control-plane+42/42直接相关 TS 套件 +canary premerge内 TS 冒烟)、未实测 PostgreSQL 后端、未单独重测作者 PR 描述中的冷/热耗时倍数,且远端 CI 按策略未等待(wait_for_ci: false)。
我的整体评价 / Verdict
- 长程与用户体验影响(
outcome_impact):long_horizon=improved(降低高频率status与heartbeat-prequota调用开销,并在 File/SQLite 并发冲突窗口保持有界恢复或诚实 fail-closed,避免虚假阻塞与状态失真);user_experience=preserved(visual_review为not_applicable:本 PR 仅优化 CLI 热路径调度、TypeScript 快照读取事务及 CLI 状态/审核包错误处理(inspected path: loopx/cli_commands/status.py, loopx/control_plane/todos/read_transaction.ts, loopx/heartbeat_prequota.py),未更改任何 Web 前端 UI、桌面端组件或视觉交互布局。,unverified_scope为none,正常读取保持输出等价,重试耗尽时返回可读错误码quota_canonical_source_changed与非零退出码)。 - 可观察语义、代码体积与比例:
observable_semantics=intentional_change_validated(保持 File/SQLite 正常及单次并发追加语义一致,同时将双次并发追加耗尽后的旧错返回收紧为 fail-closed 报错);code_volume=necessary(32 文件协同移除冗余 RPC 与空扫且无死兼容层);change_proportionality=proportionate(全部改动围绕热路径降本与严格鲜度闭合展开)。 - 精确头新鲜度:本评审直接在精确提交
67b7b7ef34ed393c4786b81907f1c44412fa56dd(OPEN/MERGEABLE/ 非 Draft / 未解决线程0)上验证完成,无阻塞性缺陷,建议批准(COMMENTED作者自有 PR 形式回执)。
English verdict: APPROVE — Exact head 67b7b7ef34ed393c4786b81907f1c44412fa56dd cleanly resolves review 6042206084's [P2] EXHAUSTED-RETRY bug in loopx/cli_commands/status.py (198-233, 255-355, 716-778, 973-1021), propagating StaleCanonicalQuotaSourceError across both attempts on both File and SQLite (20/20 hotpath/TOCTOU/retry tests, 42/42 targeted TS unit tests, typecheck:control-plane, 4,729 broader pytest passes with 4 identical pre_existing_unrelated failures in untouched test_quota_settlement.py reproduced on immutable base f0ca9cef0e, ruff, mypy, loopx check, and 18/18 canary premerge checks passing).
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh
Request changes conclusion (author-owned PR; GitHub blocks formal self-review)
动机 / Motivation
依赖 status、review-packet 或 heartbeat-prequota 判断何时可恢复 Todo 的操作者和本机调度器。 合并基线的 ACK 与 PR 依赖阶段分别读取权威 Todo,正常查询有重复请求。 降低两条高频链路的重复读取,同时继续从最新可验证的 canonical 状态选择 PR 等待对象。 发生正常的并行 Todo 写入时,原调度发现该轮新等待,当前头则留到下轮。 保留现有公开入口、权威 Todo 读取、PR 生命周期观察及已有写入规则。 已有规范要求消费者在 provider revision 漂移时丢弃不一致的结果。 快照规范
改动思路 / Approach
Status 复用实际校验过的 Todo 摘要。日志读取与 provider revision 的证明留在现有 TypeScript 读者,Python 入口保留一次重读。Prequota 的 ACK 与 PR 等待共用一次惰性读取,当本轮 ACK 完成 Todo 时失效。早于当前依赖规划的其他提交仍需读回。继续用同一权威读者验证请求级投影,不增加另一个来源。保留现有公开入口、权威 Todo 读取、PR 生命周期观察及已有写入规则。
具体改动 / Changes
准确头 67b7b7ef34ed393c4786b81907f1c44412fa56dd,合并基线 f0ca9cef0e394b62d4a0f28c54beba16cb7aa29c。整案 32 个文件(+2129/−279),包括 quota/Todo 批次、状态、工作区与通知投影、ACK/依赖调度、日志读取及两套测试。Status 也省去了被摘要丢弃的 handoff 字段和已判定的 succession 查询,复用了工作区观测与普通通知合同。Prequota 缩减了没有等待目标时的日志解码。
关键代码讲解
- _attach_agent_lane_for_attempt。为两个入口保留两次读取上限,第二次失效由调用方编码。 源码
- readReceiptLogSnapshotWithStat。读取日志前后记录文件状态并核对实际字节长度。 源码
- projectCanonicalQuotaBatch。在交给现有规划器之前核对权威 revision、cursor 与日志。 源码
- iter_reverse_rollout_events_by_kind。对 ACK 候选逆序逐条读取,结构化解析仍校验事件种类。 源码
- load_shared_agent_todos。把缓存的 Agent Todo 交给持有本轮观察锁的 _reconcile_locked,后者组合 Todo 与当前日志形成依赖计划。 源码
以基线 f0ca9ce 的快照规则为依据,CONSUMED_SNAPSHOT 已绑到实际读过的日志,BOUNDED_RETRY 保留两次上限,PREQUOTA_FRESHNESS 的竞争写入仍漏读。相比前一评审,变化集中在 status 命令及其回归测试。单次源变化会重读并恢复。两次变化耗尽后,status 与 review-packet 都显式返回 quota_canonical_source_changed 和退出码 1,File 和 SQLite 均通过。 现有健康路由和第一次追加后的正向恢复仍可执行。 前次评审
对主干的风险 / Risks
P2 复用 Todo 时会漏查新提交的 PR 等待。 ACK 正在读取一条仍 OPEN 的 PR 时,另一个普通 todo add 提交了新的 PR 等待。 File 和 SQLite 在合并基线的同一次调度中均发现新 Todo,计划该依赖并观察一次。 准确头在两个后端都成功退出,新的等待 Todo 可独立读回,但本次 PR 依赖计划为空、观察次数为零。下一轮才读到新等待并观察一次。 文件锁保护本次 PR 观察,缓存只有本次 ACK 写入会失效。它缺少当前 provider 读回,无法发现两阶段之间由另一进程写入的 Todo。在 PR 依赖阶段复用前校验快照的 provider revision 和 cursor,漂移或无法确认时走现有的完整读取。ACK 与依赖各阶段沿用各自当前权威判断。 共享读取 依赖计划
语义与 CI 对齐
准确头 48 个 Python、42 个 TypeScript 测试通过。基线相同的 28 个既有 Python 测试通过。Ruff、TypeScript 类型和 diff 检查通过。Premerge 的 18 项所选检查有 17 项通过,semantic-vocabulary drift smoke 超时,原因尚未归因。直接门禁与 Python compile 均通过。 单独的反例用两个准确源码版本运行,普通 Todo 写入先成功提交,再启动依赖观察。竞争写入来自独立的本地 CLI 进程,File 和 SQLite 都实际持久化。仅替换了远端 PR 的只读响应,未改实际仓库状态。真实 PostgreSQL、已安装态、远端 CI 和作者的耗时倍数未复测。
我的整体评价 / Verdict
保留日志证明、状态的有界重读和省略无关字段。PR 依赖阶段补一处来源校验或重读,然后按相同时序比较 File 和 SQLite 的实际计划、观察次数及未发生漂移的路径。
English verdict: REQUEST_CHANGES at 67b7b7e. The previous exhausted-retry finding is fixed. When another process commits a new PR wait during ACK, the shared snapshot makes heartbeat-prequota miss that dependency on both File and SQLite.
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 · Gemini · Google · self_reported · effort_unavailable
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
动机 / Motivation
高频执行 status、review-packet 与 heartbeat-prequota 时,原有实现存在重复权威 Todo 读取与冗余日志扫描开销,同时任何缓存复用都必须满足严格的快照一致性约束。受影响的调用方包括依赖 status、review-packet 与 heartbeat-prequota 判断待办就绪态和 PR 依赖的本机调度器与运维脚本。合并基线 f0ca9cef0e 在 status 与 heartbeat-prequota 阶段存在重复读取或多余日志扫描,前两轮评审先后指出 TOCTOU 日志身份绑定、耗尽重读 fails-closed 与跨进程并发 todo add 导致共享 Todo 缓存漏看同轮新 PR 等待的问题;当前提交 85a06f2f65 通过日志字节绑定、有界两轮重读与 todo.authority_head.verify 实时版本/游标见证,在不恢复重复全量读取的前提下消除了上述漏读与竞态。独立 File 与 SQLite 并发 CLI 对照实测确认:在 ACK 读取 OPEN PR #41 期间由独立进程执行 todo add 提交 PR #99 等待,run_heartbeat_pre_quota 在当轮即检测到漂移并重读,完成 PR #42/#99 依赖规划与 1 次观测(external_read_count=1);无并发写入的控制轮次则复用缓存且 pr_wait_reconcile.list_goal_todos 重复调用次数为 0。本变更保持现有 CLI/RPC 对外接口、权威存储与 PR 观察写入契约不变,不引入新的守护进程或跨库迁移。
改动思路 / Approach
方案把快照完整性校验集中在 TypeScript 控制面权威读者中:status 路径由 readReceiptLogSnapshotWithStat 为消费到的回执日志字节绑定 rollout_log_stat 并在 projectCanonicalQuotaBatch 中二次核验、在 Python 入口保留至多 2 次有界重试并在耗尽时显式返回 quota_canonical_source_changed;heartbeat-prequota 路径则在 load_shared_todos 时记录 (source_authority, provider_revision, cursor) 见证,并在 load_shared_agent_todos 复用缓存前通过新注册的轻量 RPC todo.authority_head.verify(loadCanonicalAuthorityHeadWitness)核对实时权威头部。把轻量级权威头部见证校验封装在现有 TypeScript 交易所有者 read_transaction.ts(todo.authority_head.verify)并复用同一 loadCanonicalAuthorityHeadWitness,让 Python heartbeat_prequota.py 仅在无漂移时复用 shared_todo_cache、一旦检测到 revision/cursor 漂移或校验出错即 fail-closed 回退全量 list_goal_todos,避免在 Python 复制另一套状态真值逻辑。保持现有 heartbeat-prequota 锁与 status/review-packet 两次重试边界,仅补齐轻量权威头部对比与并发回归用例,不扩大到多仓库或远端分布式缓存。
具体改动 / Changes
依据主干 f0ca9cef0e394b62d4a0f28c54beba16cb7aa29c 的 docs/reference/canonical-snapshot-pagination.md 规范:
- CONSUMED_SNAPSHOT(implemented):
loadCanonicalAuthorityHeadWitness与projectCanonicalQuotaBatch校验实时权威头部、存储身份及日志rollout_log_stat,任何中途改写都拒绝复用旧摘要。 - BOUNDED_RETRY(implemented):
_attach_agent_lane_for_attempt对status与review-packet保持最多 2 次读取上限,单次漂移恢复、连续两次漂移则显式返回错误码quota_canonical_source_changed与退出码1。 - PREQUOTA_FRESHNESS(implemented):
verifyCanonicalTodoAuthorityWitness与load_shared_agent_todos仅在实时(source_authority, provider_revision, cursor)完全一致时复用缓存 Todo;跨进程写入或校验异常一律清除缓存并执行完整权威读取。
自上一轮评审 67b7b7ef34 至当前精确提交 85a06f2f6500e445a6790170a6bda19a5f74ca73(commit 85a06f2f65)的修复已逐行核对并实测关闭:effect_runtime_handlers.ts 注册 todo.authority_head.verify;read_transaction.ts 抽取共享 loadCanonicalAuthorityHeadWitness 供 verifyCanonicalTodoAuthorityWitness 与 projectCanonicalQuotaBatch 共用;heartbeat_prequota.py 记录并校验三元组见证、失败 fail-closed;todo_read.test.ts 与 test_status_prequota_hotpath_efficiency.py 补充 File/SQLite 并发 todo add 与校验失败测试。全量 PR(f0ca9cef0e394b62d4a0f28c54beba16cb7aa29c..85a06f2f6500e445a6790170a6bda19a5f74ca73)改动 32 个文件 +2549 / -286 行,全部 4 个提交均带 DCO 签名,2 条评审线程均已解决(unresolved_count=0)。
关键代码讲解
loadCanonicalAuthorityHeadWitness:从openRuntimeStore+readAuthoritySnapshot读取当前source_authority、store_identity、provider_revision与cursor,供批量规划与见证对比共享。verifyCanonicalTodoAuthorityWitness:验证todo_authority_head_verify_v0输入完整性并与loadCanonicalAuthorityHeadWitness实时头部严格比对,任何不匹配或异常均返回fresh: false与明确reason_code。load_shared_agent_todos:在 PR 依赖计划读取共享缓存前先检查见证结构完整且_canonical_witness_is_fresh为True;否则清空shared_todo_cache并返回None,触发pr_wait_reconcile.py执行全量权威list_goal_todos。_attach_agent_lane_for_attempt:为status与review-packet执行有界两次重试封装,单次并发漂移后自动重读并恢复准确resume_ready,耗尽后 fail-closed 退出。
对主干的风险 / Risks
无阻塞发现(zero blocking findings;PRRT_kwDOStEbEs67XlvJ 与 PRRT_kwDOStEbEs67gMlz 均已在当前精确提交验证修复并关闭)。确认:1)无并发漂移时,heartbeat-prequota 仅执行 1 次轻量的 todo.authority_head.verify 头部检查而免除重复全量 todo.read;2)跨进程 todo add 提交新 PR 等待时,File 与 SQLite 均在同一调度轮次立即失效共享缓存并完成新依赖观察;3)todo.authority_head.verify RPC 启动或执行失败时 fail-closed 回退全量读取;4)default_off_isolation 不涉及默认关闭特性开关,既有调用行为与返回结构保持等价;5)semantic_alignment 探针确认本 PR 未新增或修改共享协议枚举(supported candidates: 0)。
残余风险与未测边界:独立并发与回归套件均使用本地 File 与 SQLite 存储并替换了远端 GitHub PR 只读 HTTP 响应;真实 PostgreSQL 权威后端、已安装发行包路径及远端 GitHub Actions CI(依规则未查询)未在本轮单独运行。
我的整体评价 / Verdict
在精确提交 85a06f2f6500e445a6790170a6bda19a5f74ca73 上,该 PR 在有效消减 status/heartbeat-prequota 高频 RPC 重复读取开销的同时,把快照完整性、TOCTOU 拒绝、有界重读与跨进程缓存失效全部闭环在单一 TS/Python 契约下。对长期运行效果(long_horizon)评估为 improved:高频前驱校验更快且面对并行 Todo/PR 合并变更不丢依赖、不放行陈旧 resume_ready。对用户体验(user_experience)评估为 preserved:对外输出结构与错误码保持明确兼容,且未修改任何渲染界面(visual_review 为 not_applicable,unverified_scope 为 none:本 PR 仅涵盖 TypeScript/Python 控制面与 CLI 状态逻辑,不涉及 UI 视图)。代码增量分布合理(code_volume 为 necessary,compatibility_assessment 为 not_applicable)。
精确提交 85a06f2f6500e445a6790170a6bda19a5f74ca73 本地全量验证汇总:npm run typecheck:control-plane 通过;TS 7 套件(todo_read、todo_summary_projection、todo_summary_lanes、receipt_log_snapshot、pr_wait_observation、effect_runtime_handlers、effect_runtime_handler_loading)111/111 passed;pytest -n 6 -rs -q(test_status_*.py、test_canonical_status_todos.py、test_pr_wait_*.py、test_issue_fix_pr_gate_reconcile.py、test_pr_wait_lifecycle.py、test_pr_wait_observation.py、test_rollout_event_log_loading.py、test_status_missing_registry.py、test_maintainability_ratchet.py、tests/architecture/)2356 passed in 182.75s(0 failed,0 skipped);ruff check 全部改动 Python 文件通过;mypy --follow-imports=silent 变更测试/入口 2 文件与全库 mypy(17 源文件)通过;check_rfc_bilingual.py、generate_semantic_inventory.py --changed-from f0ca9cef0e394b62d4a0f28c54beba16cb7aa29c(supported candidates: 0)、loopx check(32/32 errors=0, warnings=0)与 diff 隐私扫描([])通过;canary premerge --from-git-diff --git-diff-base f0ca9cef0e394b62d4a0f28c54beba16cb7aa29c 返回 gate.status="passed", merge_gate_passed=true(6/6 direct checks + 10/10 catalog + 8/8 risk_profile checks 全部通过,0 失败);独立 File 与 SQLite 并发 todo add 实测双后端均同轮捕获 #99 依赖并控制无漂移零重复读取,全部 PASS;远端 CI 未查询。
English verdict: APPROVE at 85a06f2. The live canonical witness verification in heartbeat-prequota closes cross-process todo_add drift across File and SQLite while preserving zero duplicate reads when unchanged.
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
动机 / Motivation
依赖 status、review-packet 和 heartbeat-prequota 决定待办恢复与 PR 观察的宿主和操作者。 降低状态和心跳前驱读取的重复成本,并维持权威状态新鲜度与现有等待规则。 合并基线在两阶段各读完整 Todo。上一评审头少读一次,但跨进程提交的新 PR 等待未能在同一轮观察。 在 File 与 SQLite,ACK 读取 OPEN PR 期间,独立 Todo CLI 提交另一条 PR 等待。当前头在同一调度轮计划并观察该依赖一次,与合并基线恢复语义一致。 覆盖原 status、review-packet、Todo 和 prequota 观察路径。现有格式、任务权限和 PR 写入规则保持。 未测已安装产品的耗时倍数、远端 CI 和跨主机长期运行。真实 PostgreSQL 测了共享 authority-store 套件,进程竞争入口的独立对照在 File 与 SQLite。 验收依据
改动思路 / Approach
TypeScript 权威读取所有者统一 provider revision、cursor 和回执 witness。Python 负责调用和有界回退。 覆盖原 status、review-packet、Todo 和 prequota 观察路径。现有格式、任务权限和 PR 写入规则保持。 复用 read_transaction 的权威头部读取,比较实时标记后再引用共享 Todo,不用再造缓存规则或恢复每步全量读。 现有 Gemini 同头评审已全文读回,当前操作由原生计划要求补齐 GPT 家族覆盖。前次同头原生 closeout 为 clear,merge-readiness 为 ready,GitHub 仍要求正式评审。 对应证据来自正常入口、原状态与独立写入或损坏对照。
具体改动 / Changes
准确提交 85a06f2f6500e445a6790170a6bda19a5f74ca73,合并基线 f0ca9cef0e394b62d4a0f28c54beba16cb7aa29c,已核对的 main 为 f80e93c9d92fcb2198c3d20dca9d1981b44661d0。32 个文件,+2549/−286,较前一评审提交 5 条路径变化。 整提案覆盖 status 请求内复用、已完成 ACK 的反向日志扫描、工作区及交互投影清理、PR 等待读取与测试。比较原基线和 head 的 32 条路径,当前 main 对这些路径无交叉改动,静态合并成功。
关键代码讲解
-
verifyCanonicalTodoAuthorityWitness。在请求内比较当前 provider revision/cursor 并返回可核验的新鲜度。 源码
-
load_shared_agent_todos。共享值须经当前见证校验,缺失或不一致则由原读者回退。 源码
-
_attach_agent_lane_for_attempt。让状态和评审包共享最多两次尝试,耗尽后明确拒绝。 源码
-
readReceiptLogSnapshotWithStat。将实际读取的日志字节和前后状态绑定。 源码
-
iter_reverse_rollout_events_by_kind。只解码相关回执,同时保留原类型校验。 源码
-
CONSUMED_SNAPSHOT。日志和 Todo 见证对应实际读取。
-
BOUNDED_RETRY。连续两次漂移不能输出成功。
-
PREQUOTA_FRESHNESS。并发提交后同一轮恢复观察。
对主干的风险 / Risks
无阻塞性发现。没有漂移时复用权威头部见证。见证错误时退回完整读取。status 和 review-packet 两次漂移耗尽时返回 quota_canonical_source_changed,下一次清洁读恢复。 299 项 Python、44 项 TypeScript、类型检查通过。隔离的真实 PostgreSQL 16.15 authority-store 套件 400 项通过,零跳过。 本地 premerge 为 passed,直接和执行检查无失败。 未测已安装产品的耗时倍数、远端 CI 和跨主机长期运行。真实 PostgreSQL 测了共享 authority-store 套件,进程竞争入口的独立对照在 File 与 SQLite。 相关差异
我的整体评价 / Verdict
针对当前准确提交,独立验证覆盖所涉及的实际调用和回退。沿用现有 review 和 merge 资格。完整安装态、远端 CI 及运行收益按上述范围保留。
English verdict: APPROVE at 85a06f2. The same-turn dependency freshness regression is fixed on File and SQLite. The canonical read, bounded retry and isolated PostgreSQL store checks pass. Installed-platform timings remain separate.
|
This pull request has merge conflicts with Choose the remote for the base repository, not an out-of-date fork. git fetch upstream
git rebase upstream/main
# Resolve each conflict, git add the resolved files, then git rebase --continue.
git push --force-with-lease origin HEADFor a same-repository clone whose Keep the DCO |
Signed-off-by: huangruiteng <huangrt01@163.com>
huangruiteng
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · GPT-5 · OpenAI · self_reported
动机 / Motivation
频繁运行 loopx status --agent-id 的维护者,以及依赖 loopx heartbeat-prequota 判断下一轮工作的本地调度器和终端用户。
修复前,同一三目标工作区的 status 产生 145 次冷启动 RPC,prequota 在空候选时仍做两次 Python rollout 扫描;修复后,规范化 JSON/Markdown 输出不变,status 降至 97 次 RPC,Todo 读取和无关上下文页显著减少,prequota 的共用读取最多降为一次并按写入失效。
File 与 SQLite 的正常 status 输出和 Markdown 保持一致;新等待或恢复条件在同一轮可见;见证漂移或无法确认时走现有完整读取,两次连续漂移则明确返回 quota_canonical_source_changed。
不改变 Todo、quota、PR gate 或 heartbeat 的产品语义,不新增用户配置,不缓存跨请求 authority,也不以放宽预算或吞掉新鲜度错误换取性能。
改动思路 / Approach
Request-scoped reuse is owned by the existing canonical read transaction and falls back to the existing complete reader on any unproven freshness。
Only status, review-packet and heartbeat-prequota read composition changes; provider storage, scoring, permissions and public schemas remain unchanged。
入口是 loopx status --agent-id and loopx heartbeat-prequota。权威输入为 Canonical authority head source, store identity, provider revision, cursor, current Todo snapshot and the rollout log bytes actually consumed。决定边界:The TypeScript canonical Todo read transaction decides whether a snapshot witness is fresh; Python status and heartbeat callers decide bounded retry or complete-read fallback。结果:Read-only Todo/quota projection; no Todo mutation or new durable state。消费方:status JSON/Markdown, review-packet agent-lane attachment and heartbeat-prequota PR reconciliation。失败与重试:Any drift or incomplete witness rejects reuse; status/review-packet retry once and heartbeat-prequota calls the existing list_goal_todos fallback。
具体改动 / Changes
按 docs/reference/canonical-snapshot-pagination.md 的 revision 070270eabe225f320a3d8e6c08ee7469117e38e8 核对,consistent-snapshot / unchanged-public-shape / real-provider-qualification / no-silent-fallback 分别对应下面的行为与验证。
关键代码讲解
verifyCanonicalTodoAuthorityWitness:Compares a captured source authority, provider revision and cursor with the live canonical head without forcing another Todo projection;Reuse now fails closed on drift or incomplete witness instead of trusting a cached Todo list。projectCanonicalQuotaBatch:Projects one or two quota planning requests from already checked canonical summaries and validates their exact source witness;Avoids repeated canonical reads and context pages while rejecting a changed head or rollout log。_attach_agent_lane_for_attempt:Runs the agent-lane attachment with the shared request scope and bounded stale-source retry behavior;Successful reads reuse one canonical batch; two consecutive source changes fail explicitly instead of returning a stale success。readReceiptLogSnapshotWithStat:Binds the bytes actually consumed from a rollout log to pre-read and post-read file identity witnesses;A write during or immediately after the read cannot make an older projection appear current。load_shared_agent_todos:Returns the request-local agent Todo inventory only after verifying the current authority witness;PR gate, ack and wait stages share one read on unchanged authority and fall back to list_goal_todos on any drift。
变更共 32,2549 additions、286 deletions。30 个生产文件收紧 canonical read、authority witness、rollout snapshot 与 Todo projection;2 个测试文件增加 File/SQLite 新鲜度、负例和输出兼容覆盖。
consistent-snapshot:状态摘要、合同诊断和后续消费使用同一个已校验的权威版本;跨页或后续读取发现新写入时不能返回旧结果;当前为 implemented。unchanged-public-shape:Python 适配器的公开结果形状保持不变,既有 JSON、Markdown、Todo 选择与 quota 决策继续兼容;当前为 implemented。real-provider-qualification:共享 authority-store 合同必须在真实 PostgreSQL 隔离服务上运行;跳过不能作为资格证明;当前为 implemented。no-silent-fallback:provider 漂移、存储替换或无法证明快照身份时必须明确拒绝或回到原完整读取,不能把旧值伪装成当前值;当前为 implemented。
对主干的风险 / Risks
最强回归场景:Reuse a Todo projection after the authority head or rollout file moved, producing a stale resume_ready or missing a newly added PR wait。触发状态:A concurrent Todo write or pr_merge event lands during the read window。修复边界:Authority witness equality plus pre/post rollout stat equality prevent reuse; any mismatch falls back to the existing full read。影响范围:status, review packet, heartbeat-prequota and quota planning for the selected Goal。可观察性:Stale status is visible as resume_ready=false or an empty PR wait plan; exhausted status drift returns quota_canonical_source_changed and exit code 1。恢复路径:A clean retry or the existing complete Todo read recovers current truth; no migration is required。
changed_invariant_positive=passed (22 passed on File and SQLite, including normal status, review-packet, prequota and concurrent Todo-add paths.);material_negative_or_failure=passed (44 passed, including File/SQLite TOCTOU, missing witness, revision/cursor drift and receipt snapshot reuse cases.);related_status_projection_suite=passed (313 passed.);typescript_contract=passed (tsc --noEmit passed.);postgresql_real_provider=passed (401 passed, 0 failed, 0 skipped.);repository_required_checks=passed (Premerge 18/18 passed with 0 manual holds; Ruff passed; targeted mypy had 12 pre-existing errors at head versus 14 on main and no new head-only error.);full_typescript_suite_main_baseline=failed (6829 passed, 1 failed, 95 skipped. The failure is the unchanged content_digest_single_owner consumer pin.);public_boundary=passed (public boundary scan clean for 32 files. The command's unrelated local registry audit remains red from existing Goal migration gaps.)。
- PASSED · Request-scoped reuse and empty-candidate fast paths preserve current output:22 passed on File and SQLite, including normal status, review-packet, prequota and concurrent Todo-add paths.
- PASSED · Mid-read rollout writes and canonical head drift fail closed:44 passed, including File/SQLite TOCTOU, missing witness, revision/cursor drift and receipt snapshot reuse cases.
- PASSED · Canonical quota, CLI projection, agent lane and status Todo output remain compatible:313 passed.
- PASSED · TypeScript control-plane contracts and handler registration remain coherent:tsc --noEmit passed.
- PASSED · The shared canonical read and authority witness remain valid on a real PostgreSQL tenant:401 passed, 0 failed, 0 skipped.
- PASSED · Diff-selected repository gate, lint and static regression comparison:Premerge 18/18 passed with 0 manual holds; Ruff passed; targeted mypy had 12 pre-existing errors at head versus 14 on main and no new head-only error.
- FAILED · Full control-plane TypeScript suite:6829 passed, 1 failed, 95 skipped. The failure is the unchanged content_digest_single_owner consumer pin.
- PASSED · Changed source files contain no private or credential material:public boundary scan clean for 32 files. The command's unrelated local registry audit remains red from existing Goal migration gaps.
我的整体评价 / Verdict
长程效果判断为 improved:高频状态与 heartbeat 路径减少重复 provider 读取和无关 rollout 扫描,同时保留同轮 Todo、PR wait 与恢复条件的新鲜度边界。用户体验判断为 improved:终端状态查询和调度准备路径减少重复跨进程工作,公开成功与错误语义保持不变。视觉检查不适用,因为本次只改 CLI/control-plane 读取与验证。
精确 head 的 File、SQLite 与真实 PostgreSQL 路径均通过,历史两条 P2 修复在当前 head 仍有针对性负例。
English verdict: APPROVE at a93966c. Request-scoped canonical reuse now fails closed on authority or rollout drift. File, SQLite, real PostgreSQL, typecheck and premerge pass; the only full-suite red is reproduced unchanged on main.
Signed-off-by: huangruiteng <huangrt01@163.com>
huangruiteng
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · GPT-5 · OpenAI · self_reported
动机 / Motivation
频繁运行 loopx status --agent-id 的维护者,以及依赖 loopx heartbeat-prequota 判断下一轮工作的本地调度器和终端用户。
修复前,同一三目标工作区的 status 产生 145 次冷启动 RPC,prequota 在空候选时仍做两次 Python rollout 扫描;修复后,规范化 JSON/Markdown 输出不变,status 降至 97 次 RPC,Todo 读取和无关上下文页显著减少,prequota 的共用读取最多降为一次并按写入失效。
File 与 SQLite 的正常 status 输出和 Markdown 保持一致;新等待或恢复条件在同一轮可见;见证漂移或无法确认时走现有完整读取,两次连续漂移则明确返回 quota_canonical_source_changed。
不改变 Todo、quota、PR gate 或 heartbeat 的产品语义,不新增用户配置,不缓存跨请求 authority,也不以放宽预算或吞掉新鲜度错误换取性能。
改动思路 / Approach
Request-scoped reuse is owned by the existing canonical read transaction and falls back to the existing complete reader on any unproven freshness。
Only status, review-packet and heartbeat-prequota read composition changes; provider storage, scoring, permissions and public schemas remain unchanged。
入口是 loopx status --agent-id and loopx heartbeat-prequota。权威输入为 Canonical authority head source, store identity, provider revision, cursor, current Todo snapshot and the rollout log bytes actually consumed。决定边界:The TypeScript canonical Todo read transaction decides whether a snapshot witness is fresh; Python status and heartbeat callers decide bounded retry or complete-read fallback。结果:Read-only Todo/quota projection; no Todo mutation or new durable state。消费方:status JSON/Markdown, review-packet agent-lane attachment and heartbeat-prequota PR reconciliation。失败与重试:Any drift or incomplete witness rejects reuse; status/review-packet retry once and heartbeat-prequota calls the existing list_goal_todos fallback。
具体改动 / Changes
按 docs/reference/canonical-snapshot-pagination.md 的 revision 6268621e5e26851fed3810e208fabb92c1ef7879 核对,consistent-snapshot / unchanged-public-shape / real-provider-qualification / no-silent-fallback 分别对应下面的行为与验证。
关键代码讲解
verifyCanonicalTodoAuthorityWitness:Compares a captured source authority, provider revision and cursor with the live canonical head without forcing another Todo projection;Reuse now fails closed on drift or incomplete witness instead of trusting a cached Todo list。projectCanonicalQuotaBatch:Projects one or two quota planning requests from already checked canonical summaries and validates their exact source witness;Avoids repeated canonical reads and context pages while rejecting a changed head or rollout log。_attach_agent_lane_for_attempt:Runs the agent-lane attachment with the shared request scope and bounded stale-source retry behavior;Successful reads reuse one canonical batch; two consecutive source changes fail explicitly instead of returning a stale success。readReceiptLogSnapshotWithStat:Binds the bytes actually consumed from a rollout log to pre-read and post-read file identity witnesses;A write during or immediately after the read cannot make an older projection appear current。load_shared_agent_todos:Returns the request-local agent Todo inventory only after verifying the current authority witness;PR gate, ack and wait stages share one read on unchanged authority and fall back to list_goal_todos on any drift。
变更共 32,2549 additions、286 deletions。30 个生产文件收紧 canonical read、authority witness、rollout snapshot 与 Todo projection;2 个测试文件增加 File/SQLite 新鲜度、负例和输出兼容覆盖。
consistent-snapshot:状态摘要、合同诊断和后续消费使用同一个已校验的权威版本;跨页或后续读取发现新写入时不能返回旧结果;当前为 implemented。unchanged-public-shape:Python 适配器的公开结果形状保持不变,既有 JSON、Markdown、Todo 选择与 quota 决策继续兼容;当前为 implemented。real-provider-qualification:共享 authority-store 合同必须在真实 PostgreSQL 隔离服务上运行;跳过不能作为资格证明;当前为 implemented。no-silent-fallback:provider 漂移、存储替换或无法证明快照身份时必须明确拒绝或回到原完整读取,不能把旧值伪装成当前值;当前为 implemented。
对主干的风险 / Risks
最强回归场景:Reuse a Todo projection after the authority head or rollout file moved, producing a stale resume_ready or missing a newly added PR wait。触发状态:A concurrent Todo write or pr_merge event lands during the read window。修复边界:Authority witness equality plus pre/post rollout stat equality prevent reuse; any mismatch falls back to the existing full read。影响范围:status, review packet, heartbeat-prequota and quota planning for the selected Goal。可观察性:Stale status is visible as resume_ready=false or an empty PR wait plan; exhausted status drift returns quota_canonical_source_changed and exit code 1。恢复路径:A clean retry or the existing complete Todo read recovers current truth; no migration is required。
changed_invariant_positive=passed (22 passed on File and SQLite, including normal status, review-packet, prequota and concurrent Todo-add paths.);material_negative_or_failure=passed (44 passed, including File/SQLite TOCTOU, missing witness, revision/cursor drift and receipt snapshot reuse cases.);related_status_projection_suite=passed (313 passed.);typescript_contract=passed (tsc --noEmit passed.);postgresql_changed_invariant=passed (395 passed, 0 skipped. Every canonical read, quota, snapshot and authority/provider path passed; the six failures are isolated to unchanged managed-lease assertions.);repository_required_checks=passed (Premerge 18/18 passed with 0 manual holds; Ruff passed; targeted mypy had 12 pre-existing errors at head versus 14 on main and no new head-only error.);full_typescript_suite_main_baseline=failed (6829 passed, 1 failed, 95 skipped. The failure is the unchanged content_digest_single_owner consumer pin.);postgresql_managed_lease_main_baseline=failed (395 passed, 6 failed, 0 skipped. The failures expect the old 10:45Z 45-minute lease deadline instead of the new 13:00Z three-hour deadline and consequent recovery actions.);public_boundary=passed (public boundary scan clean for 32 files. The command's unrelated local registry audit remains red from existing Goal migration gaps.)。
- PASSED · Request-scoped reuse and empty-candidate fast paths preserve current output:22 passed on File and SQLite, including normal status, review-packet, prequota and concurrent Todo-add paths.
- PASSED · Mid-read rollout writes and canonical head drift fail closed:44 passed, including File/SQLite TOCTOU, missing witness, revision/cursor drift and receipt snapshot reuse cases.
- PASSED · Canonical quota, CLI projection, agent lane and status Todo output remain compatible:313 passed.
- PASSED · TypeScript control-plane contracts and handler registration remain coherent:tsc --noEmit passed.
- PASSED · Canonical Todo read, quota and provider paths remain valid on a real PostgreSQL tenant:395 passed, 0 skipped. Every canonical read, quota, snapshot and authority/provider path passed; the six failures are isolated to unchanged managed-lease assertions.
- PASSED · Diff-selected repository gate, lint and static regression comparison:Premerge 18/18 passed with 0 manual holds; Ruff passed; targeted mypy had 12 pre-existing errors at head versus 14 on main and no new head-only error.
- FAILED · Full control-plane TypeScript suite:6829 passed, 1 failed, 95 skipped. The failure is the unchanged content_digest_single_owner consumer pin.
- FAILED · Full PostgreSQL integration suite after the new three-hour default lease change:395 passed, 6 failed, 0 skipped. The failures expect the old 10:45Z 45-minute lease deadline instead of the new 13:00Z three-hour deadline and consequent recovery actions.
- PASSED · Changed source files contain no private or credential material:public boundary scan clean for 32 files. The command's unrelated local registry audit remains red from existing Goal migration gaps.
我的整体评价 / Verdict
长程效果判断为 improved:高频状态与 heartbeat 路径减少重复 provider 读取和无关 rollout 扫描,同时保留同轮 Todo、PR wait 与恢复条件的新鲜度边界。用户体验判断为 improved:终端状态查询和调度准备路径减少重复跨进程工作,公开成功与错误语义保持不变。视觉检查不适用,因为本次只改 CLI/control-plane 读取与验证。
精确 head 的 File、SQLite 与真实 PostgreSQL 路径均通过,历史两条 P2 修复在当前 head 仍有针对性负例。
English verdict: APPROVE at 3a82e01. Request-scoped canonical reuse now fails closed on authority or rollout drift. File, SQLite, the changed real-PostgreSQL paths, typecheck and premerge pass; remaining full-suite reds reproduce unchanged on main.
Summary
Collapses avoidable TCP RPC storms and duplicate read/scan overhead on LoopX's two highest-frequency CLI hot paths (
status --agent-idandheartbeat-prequota) across bothFileandSQLitecanonical authority backends, while preserving exact normalized JSON & Markdown output parity and full live-authority freshness guarantees.1.
loopx status --agent-idRPC & N+1 Collapsetodo.read2x -> 1xper goal):handle_status_commandineffect_runtime_request_scope(), passreuse_fresh_canonical_snapshot=Truefromattach_agent_lane_next_actions->build_quota_should_run->_prepare_quota_should_run_item->select_quota_todo_contexts, and route<= 500-item active snapshots through a new batchedtodo.quota_planning.project(projectCanonicalQuotaBatchin TypeScript).readReceiptLogSnapshotWithStat/readGoalRolloutEventSnapshotWithStatverify pre-read and post-read(dev, ino, size, mtime_ns, ctime_ns, mtime_ms)equality (plus exact byte length consumed) directly around the rollout read, andreadCanonicalTodoProjectionrefuses snapshot reuse (omitsrollout_log_stat) if any observed rollout witness changed or disagrees with post-projectionstat. BothprojectCanonicalQuotaBatchandcanonical_todo_authority_checkrequire a valid matchingrollout_log_stat, andattach_agent_lane_next_actions/handle_status_command/handle_review_packet_commandperform a bounded single re-read onquota_canonical_source_changedsostatus --agent-idimmediately observesresume_ready=truewhen apr_mergeevent lands mid-read or betweencollect_statusand batch projection.todo.context.page(handoff_sources) & unused succession RPCs:include_handoff_note: bool = Truetocompact_todo_items,compact_todo_item,open_todo_items, andtodo_lane_itemsand passedFalsefromfirst_open_todo_text,project_asset_todo_summary,monitor_display_projection.py, andattention_projection.pywherehandoff_noteis dropped; early-returned[]for empty lists inattach_todo_handoff_notes.handoff_gates_evaluatedon_CanonicalTodoSummaryinsummary_item.pysotodo_summary_handoff_gatesavoids re-invokingtodo.succession.projectwhenhandoff_gatesis already absent after canonical evaluation.interaction_contractinsidefinalize_user_gate_notification_cooldownwhen un-suppressed (work_item.interaction_execution.project+work_item.interaction_reads.projecthalved).captured_local_workspacefromobserve_goal_local_workspaceinobserve_goal_delivery_workspace_isolation(agent.delivery_workspace.evaluatereduced per goal).2.
heartbeat-prequotaShared Read & Empty Fast-Path Collapserole=NoneTodo read with write invalidation:heartbeat_prequota.pyenterseffect_runtime_request_scope(), lazily caches a singlerole=Nonelist_goal_todossnapshot shared acrosspr_gate_reconcile->pr_review_ack->pr_wait_reconcile, and invalidates cleanly on any Todo mutation (todo.read3x -> 1xon active PR wait + ack recovery turns).rollout_eventsscans when candidates are empty:load_rollout_events(..., limit=500)fromlist_readback.pywhen passing resume events into TStodo.read, aligned withCanonicalTodoSnapshot.planPrWaitObservationsFromSource(pr_wait_observation.ts) beforereadTodoResumeRolloutEventswhenwaiting_targetsis empty.iter_reverse_rollout_events_by_kindinrollout_event_log.py(reverse seek with raw UTF-8 kind prefilter) forpr_review_ack.load_issue_fix_pr_review_ack_receipts, skipping full scans and non-matching JSON decoding when nopr_review_ackreceipts exist.Parity & ABBA Benchmark (
origin/main@f0ca9cef0evs9f6cfed9a9baseline hotpath commit)Measured on an isolated synthetic 3-goal workspace (
25Todos per goal =5open/blocked/user +20deferred,200rollout events on goal 1;FileandSQLite), zero mutations to live runtime (follow-up commit361f2f2312adds pre/poststatwitness checks on rollout snapshot reads without adding RPCs or scans):origin/mainvsHEAD)Base -> Head)Base -> Head)Base -> Head)Base -> Head)Base -> Head)status --agent-id(3 goals, 75 Todos)File145 -> 97cold /143 -> 95warm (todo.read:6 -> 3,todo.context.page:46 -> 13,todo.succession.project:6 -> 0)3 -> 3766.2ms -> 711.7ms(1.08x)1156.3ms -> 1064.3ms(1.09x)1407.5ms -> 1638.3ms(daemon spawn variance)status --agent-id(3 goals, 75 Todos)SQLite145 -> 97cold /143 -> 95warm3 -> 31028.7ms -> 985.7ms(1.04x)1560.5ms -> 1430.6ms(1.09x)1957.7ms -> 1617.9ms(1.21x)heartbeat-prequota(clean fast-path, 200 events)File8 -> 8(todo.read: 3 -> 1on active ack+wait)2 -> 0Python (+ skipped TS empty scan)214.3ms -> 100.3ms(2.14x; RPC wait125.2ms -> 34.7ms,3.61x)390.4ms -> 349.0ms(1.12x)922.2ms -> 694.9ms(1.33x)heartbeat-prequota(clean fast-path, 200 events)SQLite8 -> 82 -> 0Python (+ skipped TS empty scan)235.3ms -> 142.1ms(1.66x; RPC wait122.5ms -> 53.2ms,2.30x)408.7ms -> 334.6ms(1.22x)1080.5ms -> 710.3ms(1.52x)Verification (
HEAD@361f2f2312)tests/control_plane/test_status_prequota_hotpath_efficiency.py(16/16passed onFile&SQLite, including8new mid-readpr_mergeTOCTOU and bounded re-read CLI tests coveringafter_read_before_post_stat,after_snapshot_before_line86,created_after_enoent, and between-collect_status-and-batch-check invalidation).npm run typecheck:control-plane(tsc --project tsconfig.control-plane.json --noEmit): passed (0errors post-commit).tests/control_plane_ts/{todo_read,pr_wait_observation,receipt_log_snapshot}.test.ts):42/42passed (0failed), includingfileandsqliterollout_log_statTOCTOU negative tests.npm run test:control-plane:6804passed,0failed,91environment-gated skips.tests/control_plane/{test_status_prequota_hotpath_efficiency,test_canonical_quota_projection,test_quota_cli_projection,test_status_agent_lane_projection,test_canonical_status_todos}.py:329passed (0failed).python -m mypy:0issues in17strict kernel files (0issues under--no-incremental --follow-imports=silenton touched Todo/CLI adapterssummary_item.py,quota_selection.py,goal_todo_projection.py,todo_event.py, andmarkdown.py).ruff checkon all changed/added Python files on branch: passed (0issues).scripts/check_rfc_bilingual.py --base origin/main --head HEAD: passed.examples/control_plane/control-plane-maintainability-ratchet-smoke.py --format=json:ok=True(unreviewed_count=0,magnitude_regression_count=0;module_metric_baseline.jsonuntouched).loopx check --scan-path ...across the32PR paths:ok=True,errors=0, warnings=0(public boundary scan clean: 32 files).change-quality: receiptcqr_bbd0ebf024162ab7aa4c,status=valid,decision=pass,scope_fingerprint=bbd0ebf024162ab7aa4c281ff231fce02977175176d97c4ef2cc77700d79effc.loopx canary premerge --from-git-diff --git-diff-base origin/main:gate.status="passed"(6/6direct checks passed,10/10catalog canaries passed,8/8risk-profile smokes passed,0failures).