Skip to content

fix(quota): honor committed monitor polls in prior closeout - #7094

Merged
huangruiteng merged 1 commit into
mainfrom
codex/free-agent-2-legacy-monitor-closeout-20261023
Oct 23, 2026
Merged

huangruiteng merged 1 commit into
mainfrom
codex/free-agent-2-legacy-monitor-closeout-20261023

Conversation

@loopx-agent

@loopx-agent loopx-agent commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

Goal And Delivered Outcome

  • Outcome basis / optional anchor: personal-loopx-maintenance repair for a live heartbeat blocked by a false prior-Turn closeout obligation.
  • Goal/source and gap: owedPriorTurnFromSnapshot() checked only advancement writeback/spend receipts. A prior Turn with an exact committed quota_monitor_poll therefore remained a permanent owed closeout even though monitor polls are durable no-spend closeouts. Every later Turn could be refused as receipt_unbound, inviting a duplicate writeback/spend solely to escape the loop.
  • Observable before → after: a later unbound Turn was told that the earlier monitor Turn still owed durable_writeback_receipt and quota_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.
  • Issue/task and intended base: personal-loopx-maintenance; target loopx-project/loopx:main.

Author Declaration

  • Written by: GPT-5 model agent in OpenAI Codex.

Implemented against

  • Specification and revision: current control-plane settlement contract and monitor closeout semantics at f8238e6f26e801a65c8c6a16bc9aea1659bdb690.
  • Criteria:
Criterion (spec clause) Disposition Symbol / path Test or command
A committed monitor poll closes its exact Turn without writeback/spend implemented committedMonitorPollFromSnapshot() reuse in owedPriorTurnFromSnapshot() new TypeScript prior-Turn regression
Wrong Turn/Todo/agent/goal/effect remain rejected retained existing exact identity checks quota_settlement_readback.test.ts
No fake receipt or spend is introduced implemented no mutation added to readback monitor-followthrough suite; source CLI live readback
  • Self-check before submission: reproduced the live stuck guard, verified the source fix against the same persisted state, and confirmed unrelated tests that fail do so identically on untouched origin/main.

Scope And Continuation

  • Completed scope and remaining work: complete within this repair. The PR changes one settlement readback reducer and adds one focused regression test.
  • Slice boundary / successor: N/A; this removes the blocking false debt without changing monitor cadence, Todo state, authority or spend.

Validation

  • Tested revision: 3d62dd985a56ae89c0aa745c2950aeaaa39b37de
  • Run state: finished
  • Input classes: synthetic, public_fixture
Check kind Result Public-safe evidence / limitation
unit passed node --no-warnings --experimental-strip-types --test tests/control_plane_ts/quota_settlement_readback.test.ts: 135 passed.
integration passed pytest -q tests/control_plane/test_monitor_followthrough_contract.py: 22 passed.
real_entrypoint passed The patched source CLI re-read the live stuck runtime and returned a bound normal run with no unsettled_host_turn_recovery.
manual not_applicable No UI or user-visible presentation changed.
manual blocked tests/control_plane/test_interrupted_turn_continuation.py has two pre-existing fixture failures on untouched origin/main; not used as proof for this change.

The standard premerge gate passed all 13 selected checks with zero failures and zero manual holds.

  • Coverage and gaps: the regression reproduces the exact prior monitor-poll plus later unbound Turn shape. Existing malformed/preview/wrong-identity cases continue to return open/poll-due behavior. No PostgreSQL-specific path is involved in this read-only reducer.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Refactoring (no functional changes)
  • Documentation update
  • Test update

LoopX Area

  • Control plane (goals, todos, quota, scheduler, registry, runtime)
  • Benchmark boundary (adapters, runners, verifiers, scoring, evidence)
  • Capability or extension (providers, adapters, skills)
  • Public docs or presentation surface (README, protocols, dashboard)
  • Build, packaging, installer, or CI
  • Host or runtime integration

Technical Direction

  • Direction / acceptance reference, when applicable: Core control-plane hardening; exact receipt identity and no-spend monitor settlement.

Shared-authority RFC fixture impact

  • Production-scale fixture schema: N/A
  • Semantic dimensions changed, or reviewed no-impact rationale: N/A; no vocabulary or persisted state shape changed.
  • Provider conformance arms run: N/A
  • Read-only legacy/file/PostgreSQL three-arm rehearsal: N/A; file/SQLite existing settlement tests remain green.

Boundary Checklist

  • Neither the diff nor this PR body/comments/attachments disclose private state, credentials, raw traces or verifier output, internal links, or local machine paths.
  • I did not duplicate maintainer-owned benchmark work.
  • I kept the change scoped to the closeout reducer.
  • No English/Chinese RFC pair changed.
  • UI impact is none.
  • The commit includes a DCO Signed-off-by trailer.

@loopx-agent
loopx-agent force-pushed the codex/free-agent-2-legacy-monitor-closeout-20261023 branch 2 times, most recently from 8eb4ccc to d18e81b Compare October 22, 2026 19:08

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_poll classification、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-CLOSEOUT implemented:精确 committed monitor poll 作为 no-spend closeout。
  • Q-EXACT-EFFECT implemented:preview、缺失或错配 metadata 不能关闭 Turn。
  • Q-PRIOR-RECOVERY implemented: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.

@loopx-agent
loopx-agent force-pushed the codex/free-agent-2-legacy-monitor-closeout-20261023 branch from d18e81b to 3d62dd9 Compare October 22, 2026 19:23

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_poll classification、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-CLOSEOUT implemented:精确 committed monitor poll 作为 no-spend closeout。
  • Q-EXACT-EFFECT implemented:preview、缺失或错配 metadata 不能关闭 Turn。
  • Q-PRIOR-RECOVERY implemented: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>
@loopx-agent
loopx-agent force-pushed the codex/free-agent-2-legacy-monitor-closeout-20261023 branch from 3d62dd9 to d3a21cc Compare October 22, 2026 19:43

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_poll classification、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-CLOSEOUT implemented:精确 committed monitor poll 作为 no-spend closeout。
  • Q-EXACT-EFFECT implemented:preview、缺失或错配 metadata 不能关闭 Turn。
  • Q-PRIOR-RECOVERY implemented: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.

@huangruiteng
huangruiteng merged commit 2aa12dd into main Oct 23, 2026
26 of 42 checks passed
@huangruiteng
huangruiteng deleted the codex/free-agent-2-legacy-monitor-closeout-20261023 branch October 23, 2026 03:05
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.

2 participants