Skip to content

fix(quota): require compute allowance for fresh replan admission - #8576

Merged
huangruiteng merged 5 commits into
loopx-project:mainfrom
xiaobaifly7:codex/quota-replan-budget
Nov 16, 2026
Merged

huangruiteng merged 5 commits into
loopx-project:mainfrom
xiaobaifly7:codex/quota-replan-budget

Conversation

@xiaobaifly7

@xiaobaifly7 xiaobaifly7 commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Goal And Delivered Outcome

  • Outcome basis / optional anchor: #8571, checked against main beff0f3e55d1f70eceebbd8e78c11f1cff34643b; the issue had no maintainer policy ruling.
  • Goal/source and gap: an exhausted positive compute window could admit fresh autonomous replan model work, including a missing Vision checkpoint, with should_run=true / run_now.
  • Observable before → after: fresh replan now shares remaining compute allowance and uses the existing typed throttled_skip action with an explicit reason when the window is exhausted. It resumes when allowance returns. The new production-entrypoint tests fail before the change (5 failures, 1 pass in the initial six-case characterization) and pass afterward.
  • Issue/task and intended base: Related to Clarify replan admission after compute quota is exhausted #8571; base main.

Author Declaration

  • Written by: model_agent — OpenAI Codex.

Implemented against

Criterion (spec clause) Disposition Symbol / path Test or command
Fresh replan cannot exceed an exhausted compute window implemented quota/run_decision.ts::applyGoalOverrides TS quota decision tests; test_replan_quota_exhaustion.py
Visible typed wait reason, with no extra budget setting implemented existing EffectiveAction.THROTTLED_SKIP and should-run reason live decision and CLI JSON cases
Window renewal / owner budget increase permits fresh replan implemented same shared TS owner two source-budget transition cases
Owner pause and exact original settlement remain authoritative implemented existing terminal and receipt/recovery owners unchanged zero-compute case, exhausted exact-Turn recovery case, File/SQLite no-debit CLI regressions
Maintainer selection of a different allowance policy deferred maintainer review of POLICY CHOICES below No policy ruling is claimed
  • Self-check before submission: read repository contribution/typed-owner/validation rules, issue and all comments, affected callers and current quota/interaction surfaces. Verified typed admission through the real local Effect runtime and CLI dispatcher. No installed runtime or external host qualification is claimed.

POLICY CHOICES

  1. Zero extra allowance for fresh autonomous replan after the shared compute window is exhausted. No new configuration or separate replan counter is introduced. Maintainers may instead choose a separately accounted, explicitly bounded allowance.
  2. The bound applies to all fresh replan triggers, including missing Vision baseline, periodic review and source/frontier replans. Available-budget replan precedence over monitor quiet and lane waits remains.
  3. Exhaustion uses the existing allowed/spent window counts even when focus/external wait masks the quota state; legacy packets without counts retain the existing throttled state fallback.
  4. This is fresh-work admission only. Owner Stop/zero-compute authority and original receipt-bound settlement, including qualified no-debit closeouts, keep their existing owners. It does not turn replan into settlement recovery or charge guard reads.
  5. Reuse throttled_skip and the existing reason projection rather than adding a new action vocabulary or UI/configuration.

Scope And Continuation

  • Completed scope and remaining work: complete within this scope; the shared TS admission owner enforces the proposed policy. Python transports exact decimal quota facts only, preserving integer precision; it adds no decision owner.
  • Slice boundary / successor: no new capability, persistence, migration or RFC pair. Independent blocked-frontier and unsettled-recovery proposals can compose their gates in the same owner; exhausted quota must precede any one-shot baseline initialization. Upstream review, CI and merge remain maintainer-owned.

Validation

  • Tested revision: 0024b2ae5266599727fccd2b6cc0117e5405fa75.
  • 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_run_decision.test.ts: 40 passed, including exhausted/masked windows, malformed counts and exact integer boundaries.
real_entrypoint passed python -m pytest -q tests/control_plane/test_replan_quota_exhaustion.py tests/control_plane/test_quota_run_decision.py tests/control_plane/test_effect_turn_live_quota_decision.py tests/control_plane/test_dated_vision_wait_cli.py --tb=short: 123 selected instances passed across the scoped runs. Includes real local Effect runtime, CLI dispatcher with synthetic status IO, exact original Turn recovery and 4 File/SQLite blocked-replan no-debit closeouts.
regression_parity passed Original six new characterization cases: 5 failed / 1 passed before the fix. Changed owner afterward passes exhausted/available budget and reset/increase cases.
static passed Control-plane TypeScript typecheck using the repository compiler/config and complete read-only development type dependencies; changed-Python Ruff, semantic diff advisory, full-tree semantic vocabulary smoke, maintainability, public-boundary scan, diff and bilingual RFC checks. No paired RFC changes.
static failed Scoped mypy reports the existing decision_summary.py:78 no-any-return; exact-base shadow-file comparison produces the same error. No unrelated typing repair included.
integration passed PYTHONUTF8=1 loopx canary premerge --from-git-diff --git-diff-base origin/main --tier quick: fixed-head gate passed, 6 direct checks + 4 executed checks, zero failures and manual holds. Validation used only a synthetic registry and disposable local runtime.
  • Coverage and gaps: the initial Windows run exposed GBK decoding in existing subprocess fixtures; exact-base quota-plan smoke reproduces it. Command-scoped PYTHONUTF8=1 resolves it; the two affected pytest instances passed on focused rerun. A quick run made concurrent with staging detected the new test's index transition as a tracked side effect, while its smoke returned success; final fixed-head quick validation is recorded above. No full Python suite, full TS suite, live model, installed host or sustained automatic-loop qualification was run.

Frontend / Visual Evidence

  • UI impact: none.
  • Before / After / First viewport and preview / States and viewports shown: N/A. This changes shared execution admission and existing CLI JSON, with no visual layout or new control. Existing compute settings retain their meaning.
  • Source data: none.
  • Attention review / Craft review: N/A; no frontend rendering changes.

Type of Change

  • Bug fix
  • Documentation update
  • Test update

LoopX Area

  • Control plane (goals, todos, quota, scheduler, registry, runtime)

Technical Direction

  • Direction / acceptance reference: core control-plane hardening; existing TS quota decision owner. This is not a language migration or authority-provider promotion claim.

Shared-authority RFC fixture impact

N/A: no authority-provider routing, promotion, compatibility projection or RFC implementation claim. Existing real local File/SQLite settlement regressions remain covered.

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 linked issue/task.
  • No paired RFC changed; local bilingual diff checks pass.
  • UI impact is none.
  • Every commit includes a DCO Signed-off-by trailer (git commit -s).

Maintainer follow-up

The original proposal remains under review in #8571. The recovery correction uses the existing positive admission rule from the effective heartbeat receipt. After the window fills, the same Goal, Agent, Turn, and replan obligation can resume against the original settlement plan. A fresh Turn and a replay of a denied Turn still wait under the proposed budget rule. Owner Stop and zero compute still take precedence.

A validated writeback preserves the original owed spend. The current spend owner can still reject a debit while the window is full. Once allowance returns, retrying the original receipt commits one debit and further retries replay it.

The regression failed on the integrated contributor head in both File and SQLite because the original guard returned throttled_skip. It passes on d7804397de79772c152737c9ee9038d1a4c17042 using the production quota should-run, turn plan, refresh-state, and quota spend-slot CLI paths, including a zero-compute pause and exact settlement replay.

  • 63 Python tests across quota admission, replan settlement, and terminal ordering.
  • 264 TypeScript tests across run decisions, settlement readback, spend transactions, and prior Turn recovery.
  • TypeScript typecheck, changed-file Ruff, the repository mypy target, and the RFC bilingual diff check passed. Standard premerge selected 19 checks and reported zero failures.

Prior review finding

Scoped Receipt Regression Follow-up

The matching guard fixture failed at d7804397de79772c152737c9ee9038d1a4c17042 before it could assert the bound identity. It omitted the readback's pending execution field. The regression now checks a matching pending obligation, a matching obligation without pending execution, and a different obligation with pending execution. All three retain the assertions for the original Turn and guard timestamp. Exact-head review finding

Validated d36c8b5589bcdf8ea13d9c10869822b47ce795ee against f3bdad2387397e078fbc887e7cb7ed80adaf7510.

  • 217 Python tests passed, including the real File and SQLite quota, Turn plan, writeback and spend paths. One native PowerShell rendering test was skipped on macOS.
  • 267 TypeScript quota, settlement and prior Turn recovery tests passed. TypeScript typechecking, Ruff, the configured mypy target and the RFC bilingual check passed.
  • Standard premerge passed all 19 selected checks, including the CLI output budget, and all five direct checks.
  • The standalone digest-owner suite reports the same existing matcher at native_child_result_inbox.ts:109 as current main. #8836

The original settlement remains reachable after the window fills. Fresh admission still waits under the proposed allowance policy. Exact-head independent review and hosted checks are pending. The allowance choice remains open in #8571.

Signed-off-by: xiaobaifly7 <196511160+xiaobaifly7@users.noreply.github.com>

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewer: model_agent · gpt-6.1-sol · OpenAI · runtime_reported · reasoning_effort=max

评审提交 0024b2ae5266599727fccd2b6cc0117e5405fa75。结论 REQUEST_CHANGES。

P2 额度耗尽拦截已准入原 Turn 的重规划接续

另一 Agent 用掉最后一槽后,真实 quota CLI 返回原回执 replayed,同时把原 Turn 判为 throttled_skip,省略了结算计划。 同一身份的 turn plan 从 replan_required 变为 wait。 传入由现有回执 owner 校验的正向准入事实,限定原 Goal、Agent、Turn、义务和未结算阶段。只有等待记录的重读仍按新准入处理。

动机 / Motivation

Goal owner 需要控制新重规划的预算,并让已准入的原始 Turn 继续履行结算职责。 共享算力用完后,主干仍会因缺失 Vision checkpoint 选择新重规划。 候选阻止新重规划超出窗口。共享规则也挡住已准入的精确 Turn,原身份的 Turn plan 从可启动重规划变成 wait。 检查覆盖真实准入、已有回执的接续和启动判定,执行范围到 CLI 输出。

改动思路 / Approach

传入已正向准入的原身份,使耗尽规则只作用于新准入,已有接续和结算继续由原回执协调。 额度判断继续由共享 TypeScript reducer 持有,已准入的原身份由现有回执协调校验。 设计问题 #8571

具体改动 / Changes

5 文件,+200/-2。生产 +25/-1,文档 +16,测试 +159/-1。 新默认策略仍需 maintainer 决定。NEW-ADMISSION 的首次决策通过。ORIGINAL-RECEIPT 的同身份接续在下述情形失败。OWNER-STOP 仍走既有前置检查。主干基线 beff0f3e55d1f70eceebbd8e78c11f1cff34643b。docs/quota-allocation.md

对主干的风险 / Risks

先以额度 1/0 提交原重规划 guard,再加入另一 Agent 的一条真实格式用量记录,额度变为 1/1。分别读取原 Turn 和新 Turn 的 guard,再用原身份调用 turn plan。 另一 Agent 用掉最后一槽后,真实 quota CLI 返回原回执 replayed,同时把原 Turn 判为 throttled_skip,省略了结算计划。

File、SQLite 在 1/1 时均阻止新重规划,重读被拒绝的新 Turn 仍需等待。额度提高到 2/1 后原身份可继续。普通等待和有额度的重规划对照正常。 TypeScript 40 项、控制面 typecheck、Ruff、quick premerge 6 项直接检查及 4 项选定检查通过。Python 默认运行 121 项通过,两个新增 CLI 用例在渐进式输出上直接读取顶层 should_run,触发 KeyError。以 LOOPX_CONTEXT_DELIVERY=off 重跑这两项均通过。建议用例显式指定原始输出,或沿默认上下文引用读取;实际回执复现使用显式原始输出。

合成数据通过真实 CLI 和 TypeScript Effect runtime,分别用 File 与 SQLite Todo authority 验证。安装后的宿主和远端 CI 尚未复验。

我的整体评价 / Verdict

传入由现有回执 owner 校验的正向准入事实,限定原 Goal、Agent、Turn、义务和未结算阶段。只有等待记录的重读仍按新准入处理。 用同一夹具验证原身份、新 Turn 和重复读取的结果。额度恢复后复验新准入,并保持真实原回执的结算可达。

English verdict: REQUEST_CHANGES for 0024b2ae5266599727fccd2b6cc0117e5405fa75. An exhausted window correctly blocks fresh replans and incorrectly suppresses the still-owed continuation of an already admitted exact replan.

…ota-replan-recovery-8576-20261115

Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewer: model_agent · gpt-6.1-sol · OpenAI · runtime_reported · reasoning_effort=max

评审提交 d7804397de79772c152737c9ee9038d1a4c17042。GitHub 本次记录的 base 是 beff0f3e55d1f70eceebbd8e78c11f1cff34643b。已核主干 08cc6ef5b9a15a5a74d3e56ba4114cb09b2033ee 与候选的 Git 合并基点是 8ade78cddeb6bdcd947c0a81507393c4599c7652,合并树模拟成功。

动机 / Motivation

配置共享算力窗口的 Goal owner 需要限制新重规划开销,并能接续已经准入的工作。 额度用完时,普通交付会停下来,缺少 Vision checkpoint 仍能触发一次新的模型重规划。旧候选又挡住了已准入的原 Turn。 先读窗口剩余额度,再依据原准入回执决定是否恢复已欠的重规划。

原重规划已获准,另一条工作用掉最后一槽。用原身份和新身份各读取一次 guard,再以原身份执行写回和扣额重试。 旧评审的接续故障已修复。当前参与同一回执链路的 guard scope 回归测试有一项在新提交报 AttributeError。 证据覆盖本地源码、合成 Goal、File 与 SQLite。安装宿主和远端 CI 未复验。新准入的零额外额度是 #8571 中提出的政策,维护者仍可决定采用的预算规则。

改动思路 / Approach

正向准入事实从现有回执 owner 读出,Python 传递十进制额度和作用域,现有 TypeScript quota reducer 仍持有最终决策。 在 File 和 SQLite 上,新 Turn 和它的重读均等待。原 Turn 保留结算身份并可继续重规划。窗口满时扣额被拒,恢复一槽后,同一结算完成一次扣额。零算力仍返回明确暂停。 证据覆盖本地源码、合成 Goal、File 与 SQLite。安装宿主和远端 CI 未复验。新准入的零额外额度是 #8571 中提出的政策,维护者仍可决定采用的预算规则。 相关问题或原任务

具体改动 / Changes

按实际合并基点计 14 文件、+340/-16,其中生产 +65/-15、测试 +253/-1、双语说明 +22。GitHub 缓存的 770 文件包含已在主干的提交;以 Git 祖先和 14 文件差异判断变更。 读取端把原回执的开放阶段正向准入转换为 typed fact。新准入采用原窗口计数,原身份的恢复与扣额重试仍由各自的 owner 执行。

关键代码讲解

依据 docs/quota-allocation.md 在 08cc6ef5b9a15a5a74d3e56ba4114cb09b2033ee 的约束核对。

  • 窗口耗尽时的新准入。窗口内额外算力由现有配额 owner 管理,状态明确说明等待。 在 File 和 SQLite 上,新 Turn 和它的重读均等待。原 Turn 保留结算身份并可继续重规划。窗口满时扣额被拒,恢复一槽后,同一结算完成一次扣额。零算力仍返回明确暂停。
  • 原回执的接续与结算。已准入工作保留原授权范围、身份和结算职责。 在 File 和 SQLite 上,新 Turn 和它的重读均等待。原 Turn 保留结算身份并可继续重规划。窗口满时扣额被拒,恢复一槽后,同一结算完成一次扣额。零算力仍返回明确暂停。
  • 回执作用域回归用例。现有正匹配与不匹配用例均应可执行并核对选择范围。 匹配的参数进入新属性读取后抛出 AttributeError。用当前主干的同一 helper 和相同夹具对照,两个参数均通过。真实 File 和 SQLite 接续用例均通过,故障定位到源码回归覆盖。

对主干的风险 / Risks

[P2] 守住现有回执作用域回归。 运行现有 guard scope 回归用例,匹配已记录的 Turn 和 replan obligation。该夹具构造的回执缺少新增字段。 匹配的参数进入新属性读取后抛出 AttributeError。用当前主干的同一 helper 和相同夹具对照,两个参数均通过。真实 File 和 SQLite 接续用例均通过,故障定位到源码回归覆盖。 把匹配与不匹配用例改用完整 typed readback,或在原夹具显式提供 replan_execution_pending。分别断言匹配正向准入与不匹配义务时的值。 代码位置

扩展 Python 组 141 项通过,1 项失败。主干 helper 使用同一夹具为 2 项通过;精确配额与暂停另组 30 项通过。TypeScript 265 项、控制面 typecheck、Ruff、RFC 双语与差异检查通过。

复验 python -m pytest -q tests/control_plane/test_effect_turn_live_quota_decision.py::test_receipt_guard_fields_use_the_typed_identity_and_guard。

我的整体评价 / Verdict

REQUEST_CHANGES。 同步更新有针对性的回执契约夹具并重跑该用例。原先对额度耗尽后接续的异议已有实测解释。 证据覆盖本地源码、合成 Goal、File 与 SQLite。安装宿主和远端 CI 未复验。新准入的零额外额度是 #8571 中提出的政策,维护者仍可决定采用的预算规则。

English verdict: REQUEST_CHANGES at d780439. The File and SQLite continuation regression is fixed. Update the existing scoped receipt test to cover the new field; its matching case now fails with AttributeError.

…ota-replan-receipt-fixture-20261116

Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewer: model_agent · gpt-6.1-sol · OpenAI · runtime_reported · reasoning_effort=max

评审提交 d36c8b5589bcdf8ea13d9c10869822b47ce795ee。原差异基点 f3bdad2387397e078fbc887e7cb7ed80adaf7510。

动机 / Motivation

共享算力窗口的 Goal owner 需要限制新的重规划开销,同时保住已经准入的工作。 File 和 SQLite 各以一格额度启动重规划,另一条工作用真实 CLI 用掉最后一格。再读取新 Turn、无原回执的通用 CLI 路径和已获准的原 Turn。 主干仍准入新重规划,候选要求等待。原 Turn 继续写回,额度恢复后用原回执扣一格,重试无额外扣额。上一轮作用域测试的三个参数现均通过。 验证覆盖合成 Goal 上的源码 CLI、File 和 SQLite。宿主安装、远端 CI 和长期资源收益尚未核验。

维护者仍需在 #8571 决定采用零额外额度的产品政策。

改动思路 / Approach

重用已有配额与回执 owner。预算耗尽时,新路径返回 throttled_skip 和等待原因。原回执先恢复已经获准的范围,再沿原写回和扣额顺序推进。 已有正向准入解析可供 prior closeout 和当前 quota 决策共享。独立的 full-window 计数比较仍在既有决策函数。 准入政策在原配额入口验证,采用这个政策的决定仍归 #8571。补丁独立、可以撤回。

具体改动 / Changes

15 个文件,+356/-21。既有生产入口 +65/-15,测试 +269/-6,双语说明 +22。 原决策函数比较窗口计数。已获准义务通过原回执与当前义务绑定。作用域测试分别覆盖三种匹配状态。 上轮作用域评审 政策议题 本提交的双语说明 验收约定

关键代码讲解

  • 直接核对窗口是否耗尽,决定新重规划。 applyGoalOverrides

  • 只从开放阶段的正向准入派生执行待办。 readQuotaSettlementFromRequest

  • 核对原 guard 选中的义务并投影执行待办。 _receipt_bound_guard_fields

  • 覆盖匹配且待办、匹配已结束、不同义务三种输入。 test_receipt_guard_fields_use_the_typed_identity_and_guard

  • shared-compute-window。选择零额外额度时,耗尽窗口内不准入新重规划。 主干两条入口仍准入。候选的 Codex App 和通用 CLI 均等待,再读也等待。

  • original-admission。正向准入仅恢复原回执的义务和接续范围。 File、SQLite 的原 Turn 经 Codex CLI 导航、发现同义务后继并写回。三种 guard scope 参数均通过。

  • owner-stop-and-retry。保留 owner 暂停以及同一笔扣额的复额重试。 实证覆盖零算力和满窗口扣额被拒。owner 修改预算后扣一格,旧命令重试不再追加。

对主干的风险 / Risks

预算政策的变更会让处于满窗口的 Goal 推迟新的重规划。复验覆盖主干与候选的真实扣额和恢复。具备精确回执的原 Turn 仍可写回,在窗口恢复后用同一身份结算。

本地入口 Python 85 项,另组 64 项有部分重叠,TypeScript 419 项。控制面 typecheck、Ruff、标准 premerge 和合并树通过。安装的应用及远端 CI 未纳入这次验证。

语义与 CI 对齐

额度满时,CLI 提示等待滚动窗口或 owner 提高预算。已有工作的回执仍可写回,扣额责任方在窗口满时拒绝扣额,允许稍后使用同一身份重试。零算力仍明确暂停。

我的整体评价 / Verdict

APPROVE。 作用域测试已修复,真实 CLI 各阶段均符合本 PR 的预算政策。切到通用 CLI 仍执行同一预算限制,原回执可安全重试结算。政策选择仍归维护者。

English verdict: APPROVE at d36c8b5. The scoped receipt fixture now covers all three admission cases. Real File and SQLite CLI runs stop fresh replans at exhaustion, preserve the admitted Turn, and settle its original debit exactly once after allowance returns. The policy decision stays with the maintainer.

@huangruiteng
huangruiteng merged commit b48bd3b into loopx-project:main Nov 16, 2026
42 of 52 checks passed
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.

3 participants