Repository navigation
fix(quota): honor committed monitor polls in prior closeout - #7094
Conversation
8eb4ccc to
d18e81b
Compare
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · GPT-5 · OpenAI · self_reported
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
审查精确 head:d18e81bc11bde151fa0e1bc3193ec8fcc98f36d8。
动机
monitor_only 或 due monitor 的 Agent lane,以及依赖 heartbeat 连续性的维护者。
上一 Turn 提交精确 monitor poll 后,旧代码把该 Turn 报告为仍欠 durable_writeback_receipt 和 quota_spend_receipt;新代码在同一 snapshot 上先按 Goal、Agent、Turn、Todo 和 effect 验证 committed monitor poll,验证通过即视为已关闭,不再把假债务带到当前 Turn。
新的回归用例覆盖“上一 Turn 精确 committed monitor + 当前 Turn 尚未绑定”,当前 Turn 仍正确报告 receipt_unbound,但不再携带 owed_prior_turn;既有 wrong Turn/Todo/agent/goal/effect 负例继续失败关闭。
不修改 monitor cadence、Todo 生命周期、quota 扣费、CLI 参数或持久化 schema;不把 preview、缺失 commit 或错误 identity 的 observation 当成关闭凭据。
改动思路
读路径从 readQuotaSettlement 进入 resolveIdentity。当当前 Turn 的 receipt 尚未绑定时,owedPriorTurnFromSnapshot 会遍历更早、且明确要求 closeout 的候选 Turn。旧实现只向 writeback/spend 链寻找结算;新实现先复用 committedMonitorPollFromSnapshot,用同一份 snapshot 验证 monitor run 的 classification、owner、Goal、Agent、Turn、Todo 与 committed effect。精确匹配后,该候选按现有合同视为 no-spend closeout;否则继续走原来的 fail-closed 读回。
这个边界是可逆且比例合适的:生产代码只改一个 reducer 分支,没有新增状态、调度、权限、CLI 参数或 schema。修复属于 settlement invariant,放在既有 readback owner;没有新增机制或默认策略。当前 PR 边界:只修正 prior-Turn closeout 消费,不扩展 monitor 产品流程。monitor 的产生、到期、材料变化和 Todo 生命周期仍由原 owner 管理。
具体改动
关键代码讲解
owedPriorTurnFromSnapshot(loopx/control_plane/quota/settlement_readback.ts:1071)在 Todo-bound 候选上调用现有 committed-monitor helper。匹配时不再查询不适用于 monitor 的 writeback/spend;不匹配时保留原missingCloseoutReceipts行为。committedMonitorPollFromSnapshot(同文件:420)没有扩张语义;它继续要求quota_monitor_pollclassification、owner、Goal、Agent、Turn、Todo 和精确 effect 全部一致。这里的关键不是新建“monitor 已读”状态,而是让另一个既有消费者复用同一 authoritative fact。- 新回归
a prior committed monitor poll never blocks a later unbound Turn rebind(tests/control_plane_ts/quota_settlement_readback.test.ts:979)构造“上一 monitor Turn 已提交、当前 Turn 仍未绑定”的交叉快照,并断言当前 Turn 仍为receipt_unbound,但不再附带owed_prior_turn。
Spec ref: docs/quota-allocation.md @ revision 630c68a1cb871996fbe491292e95681c1c9b87c3。heartbeat settlement 条款位于 docs/heartbeat-automation-prompt.md,但本条 immutable review basis 固定到前述 quota contract revision。
Q-MONITOR-CLOSEOUTimplemented:精确 committed monitor poll 作为 no-spend closeout。Q-EXACT-EFFECTimplemented:preview、缺失或错配 metadata 不能关闭 Turn。Q-PRIOR-RECOVERYimplemented:same-Turn 与 prior-Turn 读取复用同一 exact effect 身份。
对主干的风险
最强反例是匹配过宽:只要同 Turn 存在类似 monitor 的行就错误关闭真实缺口。当前 predicate 对 owner、Goal、Agent、Turn、Todo、classification 与 effect 逐项匹配;既有 negative table 还覆盖 wrong Agent/Goal/Todo/Turn/effect、preview、空 commit 与 malformed commit,均要求 Turn 保持 open。新增用例同时证明修复没有伪造当前 Turn 的 binding。
验证为 135/135 TypeScript settlement tests、22/22 Python monitor follow-through tests,以及 canary premerge 的 13/13 项检查,零失败、零 manual hold。剩余未验证项是本机私有 live runtime 的再次回放;这不影响此次只读 reducer 的合成与仓库原生门禁证据,也不应外推为模型遵循或 UI 证明。
我的整体评价
Long-horizon impact 为 improved:已关闭的 monitor 不再让后续 heartbeat 反复承担假债务;当前未绑定 Turn 仍会明确要求自己的重绑定,恢复语义没有被删除。User experience 也为 improved,因为 Agent 和维护者不再被不存在的历史欠账引向重复写回或扣额。没有 blocking finding;主要残余风险是未来有人削弱 exact-effect predicate,现有 identity 负例应继续保留。
批准该精确 head。合并仍需要独立的 exact-head readiness 与仓库 merge authority;本评论不授予合并权限。
English verdict: APPROVE at d18e81bc11bde151fa0e1bc3193ec8fcc98f36d8; exact committed monitor polls now close their prior Turn without suppressing real identity failures. 135 TypeScript tests, 22 monitor integration tests, and 13/13 premerge checks passed. No blocking finding; remaining risk is limited to the private live-runtime replay and future weakening of the exact-effect guard.
d18e81b to
3d62dd9
Compare
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · GPT-5 · OpenAI · self_reported
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
审查精确 head:3d62dd985a56ae89c0aa745c2950aeaaa39b37de。
动机
monitor_only 或 due monitor 的 Agent lane,以及依赖 heartbeat 连续性的维护者。
上一 Turn 提交精确 monitor poll 后,旧代码把该 Turn 报告为仍欠 durable_writeback_receipt 和 quota_spend_receipt;新代码在同一 snapshot 上先按 Goal、Agent、Turn、Todo 和 effect 验证 committed monitor poll,验证通过即视为已关闭,不再把假债务带到当前 Turn。
新的回归用例覆盖“上一 Turn 精确 committed monitor + 当前 Turn 尚未绑定”,当前 Turn 仍正确报告 receipt_unbound,但不再携带 owed_prior_turn;既有 wrong Turn/Todo/agent/goal/effect 负例继续失败关闭。
不修改 monitor cadence、Todo 生命周期、quota 扣费、CLI 参数或持久化 schema;不把 preview、缺失 commit 或错误 identity 的 observation 当成关闭凭据。
改动思路
读路径从 readQuotaSettlement 进入 resolveIdentity。当当前 Turn 的 receipt 尚未绑定时,owedPriorTurnFromSnapshot 会遍历更早、且明确要求 closeout 的候选 Turn。旧实现只向 writeback/spend 链寻找结算;新实现先复用 committedMonitorPollFromSnapshot,用同一份 snapshot 验证 monitor run 的 classification、owner、Goal、Agent、Turn、Todo 与 committed effect。精确匹配后,该候选按现有合同视为 no-spend closeout;否则继续走原来的 fail-closed 读回。
这个边界是可逆且比例合适的:生产代码只改一个 reducer 分支,没有新增状态、调度、权限、CLI 参数或 schema。修复属于 settlement invariant,放在既有 readback owner;没有新增机制或默认策略。当前 PR 边界:只修正 prior-Turn closeout 消费,不扩展 monitor 产品流程。monitor 的产生、到期、材料变化和 Todo 生命周期仍由原 owner 管理。
具体改动
关键代码讲解
owedPriorTurnFromSnapshot(loopx/control_plane/quota/settlement_readback.ts:1071)在 Todo-bound 候选上调用现有 committed-monitor helper。匹配时不再查询不适用于 monitor 的 writeback/spend;不匹配时保留原missingCloseoutReceipts行为。committedMonitorPollFromSnapshot(同文件:420)没有扩张语义;它继续要求quota_monitor_pollclassification、owner、Goal、Agent、Turn、Todo 和精确 effect 全部一致。这里的关键不是新建“monitor 已读”状态,而是让另一个既有消费者复用同一 authoritative fact。- 新回归
a prior committed monitor poll never blocks a later unbound Turn rebind(tests/control_plane_ts/quota_settlement_readback.test.ts:979)构造“上一 monitor Turn 已提交、当前 Turn 仍未绑定”的交叉快照,并断言当前 Turn 仍为receipt_unbound,但不再附带owed_prior_turn。
Spec ref: docs/quota-allocation.md @ revision 2ad0e88be2859e3a53836c32e9f467b2b40ad377。heartbeat settlement 条款位于 docs/heartbeat-automation-prompt.md,但本条 immutable review basis 固定到前述 quota contract revision。
Q-MONITOR-CLOSEOUTimplemented:精确 committed monitor poll 作为 no-spend closeout。Q-EXACT-EFFECTimplemented:preview、缺失或错配 metadata 不能关闭 Turn。Q-PRIOR-RECOVERYimplemented:same-Turn 与 prior-Turn 读取复用同一 exact effect 身份。
对主干的风险
最强反例是匹配过宽:只要同 Turn 存在类似 monitor 的行就错误关闭真实缺口。当前 predicate 对 owner、Goal、Agent、Turn、Todo、classification 与 effect 逐项匹配;既有 negative table 还覆盖 wrong Agent/Goal/Todo/Turn/effect、preview、空 commit 与 malformed commit,均要求 Turn 保持 open。新增用例同时证明修复没有伪造当前 Turn 的 binding。
rebase 到最新 main 后重新执行:135/135 TypeScript settlement tests、22/22 Python monitor follow-through tests,以及 canary premerge 的 13/13 项检查,零失败、零 manual hold。剩余未验证项是本机私有 live runtime 的再次回放;这不影响此次只读 reducer 的合成与仓库原生门禁证据,也不应外推为模型遵循或 UI 证明。
我的整体评价
Long-horizon impact 为 improved:已关闭的 monitor 不再让后续 heartbeat 反复承担假债务;当前未绑定 Turn 仍会明确要求自己的重绑定,恢复语义没有被删除。User experience 也为 improved,因为 Agent 和维护者不再被不存在的历史欠账引向重复写回或扣额。没有 blocking finding;主要残余风险是未来有人削弱 exact-effect predicate,现有 identity 负例应继续保留。
批准该精确 head。合并仍需要独立的 exact-head readiness 与仓库 merge authority;本评论不授予合并权限。
English verdict: APPROVE at 3d62dd985a56ae89c0aa745c2950aeaaa39b37de; exact committed monitor polls now close their prior Turn without suppressing real identity failures. 135 TypeScript tests, 22 monitor integration tests, and 13/13 premerge checks passed. No blocking finding; remaining risk is limited to the private live-runtime replay and future weakening of the exact-effect guard.
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
3d62dd9 to
d3a21cc
Compare
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · GPT-5 · OpenAI · self_reported
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
审查精确 head:d3a21cc20ee159aaa18c3cd9c628a7f8b3f88c7e。
动机
monitor_only 或 due monitor 的 Agent lane,以及依赖 heartbeat 连续性的维护者。
上一 Turn 提交精确 monitor poll 后,旧代码把该 Turn 报告为仍欠 durable_writeback_receipt 和 quota_spend_receipt;新代码在同一 snapshot 上先按 Goal、Agent、Turn、Todo 和 effect 验证 committed monitor poll,验证通过即视为已关闭,不再把假债务带到当前 Turn。
新的回归用例覆盖“上一 Turn 精确 committed monitor + 当前 Turn 尚未绑定”,当前 Turn 仍正确报告 receipt_unbound,但不再携带 owed_prior_turn;既有 wrong Turn/Todo/agent/goal/effect 负例继续失败关闭。
不修改 monitor cadence、Todo 生命周期、quota 扣费、CLI 参数或持久化 schema;不把 preview、缺失 commit 或错误 identity 的 observation 当成关闭凭据。
改动思路
读路径从 readQuotaSettlement 进入 resolveIdentity。当当前 Turn 的 receipt 尚未绑定时,owedPriorTurnFromSnapshot 会遍历更早、且明确要求 closeout 的候选 Turn。旧实现只向 writeback/spend 链寻找结算;新实现先复用 committedMonitorPollFromSnapshot,用同一份 snapshot 验证 monitor run 的 classification、owner、Goal、Agent、Turn、Todo 与 committed effect。精确匹配后,该候选按现有合同视为 no-spend closeout;否则继续走原来的 fail-closed 读回。
这个边界是可逆且比例合适的:生产代码只改一个 reducer 分支,没有新增状态、调度、权限、CLI 参数或 schema。修复属于 settlement invariant,放在既有 readback owner;没有新增机制或默认策略。当前 PR 边界:只修正 prior-Turn closeout 消费,不扩展 monitor 产品流程。monitor 的产生、到期、材料变化和 Todo 生命周期仍由原 owner 管理。
具体改动
关键代码讲解
owedPriorTurnFromSnapshot(loopx/control_plane/quota/settlement_readback.ts:1071)在 Todo-bound 候选上调用现有 committed-monitor helper。匹配时不再查询不适用于 monitor 的 writeback/spend;不匹配时保留原missingCloseoutReceipts行为。committedMonitorPollFromSnapshot(同文件:420)没有扩张语义;它继续要求quota_monitor_pollclassification、owner、Goal、Agent、Turn、Todo 和精确 effect 全部一致。这里的关键不是新建“monitor 已读”状态,而是让另一个既有消费者复用同一 authoritative fact。- 新回归
a prior committed monitor poll never blocks a later unbound Turn rebind(tests/control_plane_ts/quota_settlement_readback.test.ts:979)构造“上一 monitor Turn 已提交、当前 Turn 仍未绑定”的交叉快照,并断言当前 Turn 仍为receipt_unbound,但不再附带owed_prior_turn。
Spec ref: docs/quota-allocation.md @ revision 770b11c9512eb7f9097329417072a4ad72d0af78。heartbeat settlement 条款位于 docs/heartbeat-automation-prompt.md,但本条 immutable review basis 固定到前述 quota contract revision。
Q-MONITOR-CLOSEOUTimplemented:精确 committed monitor poll 作为 no-spend closeout。Q-EXACT-EFFECTimplemented:preview、缺失或错配 metadata 不能关闭 Turn。Q-PRIOR-RECOVERYimplemented:same-Turn 与 prior-Turn 读取复用同一 exact effect 身份。
对主干的风险
最强反例是匹配过宽:只要同 Turn 存在类似 monitor 的行就错误关闭真实缺口。当前 predicate 对 owner、Goal、Agent、Turn、Todo、classification 与 effect 逐项匹配;既有 negative table 还覆盖 wrong Agent/Goal/Todo/Turn/effect、preview、空 commit 与 malformed commit,均要求 Turn 保持 open。新增用例同时证明修复没有伪造当前 Turn 的 binding。
再次 rebase 到最新 main 后重新执行:135/135 TypeScript settlement tests、22/22 Python monitor follow-through tests,以及 canary premerge 的 13/13 项检查,零失败、零 manual hold。剩余未验证项是本机私有 live runtime 的再次回放;这不影响此次只读 reducer 的合成与仓库原生门禁证据,也不应外推为模型遵循或 UI 证明。
我的整体评价
Long-horizon impact 为 improved:已关闭的 monitor 不再让后续 heartbeat 反复承担假债务;当前未绑定 Turn 仍会明确要求自己的重绑定,恢复语义没有被删除。User experience 也为 improved,因为 Agent 和维护者不再被不存在的历史欠账引向重复写回或扣额。没有 blocking finding;主要残余风险是未来有人削弱 exact-effect predicate,现有 identity 负例应继续保留。
批准该精确 head。合并仍需要独立的 exact-head readiness 与仓库 merge authority;本评论不授予合并权限。
English verdict: APPROVE at d3a21cc20ee159aaa18c3cd9c628a7f8b3f88c7e; exact committed monitor polls now close their prior Turn without suppressing real identity failures. 135 TypeScript tests, 22 monitor integration tests, and 13/13 premerge checks passed. No blocking finding; remaining risk is limited to the private live-runtime replay and future weakening of the exact-effect guard.
Goal And Delivered Outcome
personal-loopx-maintenancerepair for a live heartbeat blocked by a false prior-Turn closeout obligation.owedPriorTurnFromSnapshot()checked only advancement writeback/spend receipts. A prior Turn with an exact committedquota_monitor_polltherefore remained a permanent owed closeout even though monitor polls are durable no-spend closeouts. Every later Turn could be refused asreceipt_unbound, inviting a duplicate writeback/spend solely to escape the loop.durable_writeback_receiptandquota_spend_receipt. It now recognizes the exact committed monitor-poll identity and reports no prior-Turn debt, while unrelated or malformed poll identities still fail closed.personal-loopx-maintenance; targetloopx-project/loopx:main.Author Declaration
Implemented against
f8238e6f26e801a65c8c6a16bc9aea1659bdb690.committedMonitorPollFromSnapshot()reuse inowedPriorTurnFromSnapshot()quota_settlement_readback.test.tsorigin/main.Scope And Continuation
Validation
3d62dd985a56ae89c0aa745c2950aeaaa39b37deunitpassednode --no-warnings --experimental-strip-types --test tests/control_plane_ts/quota_settlement_readback.test.ts: 135 passed.integrationpassedpytest -q tests/control_plane/test_monitor_followthrough_contract.py: 22 passed.real_entrypointpassedunsettled_host_turn_recovery.manualnot_applicablemanualblockedtests/control_plane/test_interrupted_turn_continuation.pyhas two pre-existing fixture failures on untouchedorigin/main; not used as proof for this change.The standard premerge gate passed all 13 selected checks with zero failures and zero manual holds.
Type of Change
LoopX Area
Technical Direction
Shared-authority RFC fixture impact
Boundary Checklist
Signed-off-bytrailer.