Skip to content

fix(quota): bound blocked-frontier Vision baseline initialization - #8574

Merged
huangruiteng merged 3 commits into
loopx-project:mainfrom
xiaobaifly7:codex/blocked-missing-vision-wait
Nov 23, 2026
Merged

huangruiteng merged 3 commits into
loopx-project:mainfrom
xiaobaifly7:codex/blocked-missing-vision-wait

Conversation

@xiaobaifly7

@xiaobaifly7 xiaobaifly7 commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Goal And Delivered Outcome

Author Declaration

  • Written by: model_agent — OpenAI Codex (GPT-6).

Implemented against

  • Specification and revision: #8572, issue body as read on 2026-11-11; no maintainer comments were present. Existing agent_scope_frontier_v1 / agent_scope_wait behavior is reused.
  • Criteria:
Criterion (spec clause) Disposition Symbol / path Test or command
Finite baseline initialization before blocked-only wait implemented quota/vision_baseline_admission.ts::boundVisionBaselineAdmission first admission, fresh-Turn and independent-process readback regression
Durable closeout/re-entry rule implemented runtime/Goal/Agent-scoped admission; original initialization Turn retained scope isolation, concurrent admission and receipt-bound re-entry tests
Retain missing baseline pending without authorizing blocked delivery implemented typed agent_scope_frontier, existing interaction/scheduler projection test_missing_vision_baseline_wait.py::assert_wait checks no attempt/delivery, quiet wait and scheduler backoff
Preserve independent work, resume proofs and original settlement implemented complete scoped work counts; due-monitor and receipt guards; unchanged resume owners File/SQLite independent-work and due-monitor tests; resume/replan/wait contract suites
Owner Stop and legal no-debit boundaries implemented existing stopped/paused entry and settlement owners remain authoritative existing run-decision contracts and original owed replan regression
Actual host/model loop or installed UI qualification out_of_scope this changes control-plane admission only no installed runtime, model or host test claimed
  • Self-check before submission: read the repository instructions, applicable contribution/quality/frontend-delivery boundaries, issue and fix(quota): wait when the only scoped work is blocked #8511 wait contract; ran typed tests, real should-run projection and isolated File/SQLite readback, baseline reproduction, semantic advisory/full-tree checks, typecheck, Ruff, diff/RFC checks and quick premerge. No RFC pair changed.

Scope And Continuation

  • Completed scope and remaining work: complete within this scoped policy proposal. No new action enum, CLI option, Python decision owner or installed-host change.
  • Slice boundary / successor: fix(quota): wait when the only scoped work is blocked #8511 remains the broader blocked-only wait change; Clarify replan admission after compute quota is exhausted #8571 governs exhausted-window admission separately. This PR does not define a quota exception or replace receipt recovery.
  • Adjacent refactoring: unnecessary; the existing TypeScript run-decision owner composes the bounded admission, and Python only transports facts and the typed frontier.

POLICY CHOICES

  1. Allow exactly one initialization Turn per runtime root / Goal / Agent, consumed when that fully qualified runtime-bound should-run admission is issued. A projection without an explicit runtime root, Agent and Turn remains stateless and does not consume or claim this durable allowance.
  2. The initial Turn may re-enter with its original identity to finish work/settlement. Receipt-bound original Todo/replan work bypasses this fresh-Turn limit. A new Turn ID or changed missing-checkpoint timestamp does not reset the allowance.
  3. Apply the limit only with complete same-Agent runnable counts, at least one explicit scoped blocked advancement/blocker, no due monitor/schedule gap, and only missing-baseline checkpoint gaps/triggers. Unknown sources and independent repair/replan obligations retain their original owner decision.
  4. Runnable work, due monitors and meaningful independently triggered replans can run again; they do not erase the initialization record. This proposal does not automatically grant another baseline-only attempt after an owner lifecycle action or add a reset UI. Maintainers may choose a different explicit rearm policy.
  5. Use existing quiet agent_scope_wait / scheduler backoff while retaining the pending Vision obligation and the original admission identity in the frontier. No quota debit or successful-baseline receipt is fabricated.

These are proposed conservative defaults, not a claim of a prior maintainer ruling. Maintainers may change the allowance, consumption point, scope or rearm rule.

Validation

  • Tested revision: 2938c33.
  • Run state: finished.
  • Input classes: synthetic, public_fixture.
Check kind Result Public-safe evidence / limitation
unit / integration passed 122 distinct focused Python cases across six files, including 8 new cases; affected shared-fixture cases rerun after updating the nullable frontier result
unit passed 91 focused TypeScript cases: run decision, baseline admission, resume planning, replan semantics and Vision wait coverage; concurrent fresh-Turn initialization and malformed persisted-state rejection included
real_entrypoint / real_backend passed build_quota_should_run with disposable runtime and real File/SQLite authority; fresh Python process reads the durable admission and waits
regression_parity passed pinned main reproduces repeated autonomous_replan_required; same synthetic scenario on this branch waits after initialization
static passed control-plane typecheck; focused Ruff; diff advisory including the new source; full semantic vocabulary smoke; public-boundary scan of all 10 outgoing files with empty registry; staged/diff/RFC checks
integration passed quick premerge: maintainability, semantic vocabulary and quota-plan canaries, direct checks and changed-Python compilation
environment failed then resolved for validation first quick premerge hit Windows default-codepage subprocess JSON decoding; independently reproduced on pinned main; command-local PYTHONUTF8=1 passes without a source/config change
regression_parity failed then fixed initial fixture comparison omitted the new nullable frontier field; shared Python/TypeScript fixture updated and all 31 affected cases pass on rerun
  • Reproducible selections (checkout-installed test environment, LOOPX_USAGE_PING=0; Windows commands also use PYTHONUTF8=1):
python -m pytest -q tests/control_plane/test_missing_vision_baseline_wait.py tests/control_plane/test_quota_run_decision.py tests/control_plane/test_quota_decision_summary.py tests/control_plane/test_agent_scope_frontier_contract.py tests/control_plane/test_monitor_replan_agent_scope.py tests/control_plane/test_vision_wait_coverage.py
node --no-warnings --experimental-sqlite --experimental-strip-types --test --test-concurrency=4 tests/control_plane_ts/quota_run_decision.test.ts tests/control_plane_ts/vision_baseline_admission.test.ts tests/control_plane_ts/resume_planning.test.ts tests/control_plane_ts/replan_semantics.test.ts tests/control_plane_ts/vision_wait_coverage.test.ts
npm run -s typecheck:control-plane
python -m loopx.cli canary premerge --tier quick --from-git-diff --git-diff-base origin/main
  • Coverage and gaps: focused validation, not full Python/TypeScript-suite, model-behavior, PostgreSQL, installed Driver or desktop qualification. Public should-run and existing interaction/scheduler contracts are exercised; no live registry is scanned. Root npm installation attempts failed on network resets; an existing compatible dependency tree was reused read-only without manifest/lock changes.

Frontend / Visual Evidence

  • UI impact: none.
  • Before / After / First viewport and preview / States and viewports shown: N/A; no visual surface or layout change.
  • Source data: synthetic.
  • Attention review / Craft review: N/A. Existing CLI/interaction/scheduler wait presentation consumes the same typed frontier; no new UI capability or control.

Type of Change

  • Bug fix
  • Test update

LoopX Area

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

Technical Direction

  • Direction / acceptance reference: governed continuation; finite missing-baseline initialization and existing scoped wait. No migration/promotion claim.

Shared-authority RFC fixture impact

  • Production-scale fixture schema: N/A; no shared-authority migration or promotion claimed.
  • Semantic dimensions changed, or reviewed no-impact rationale: local admission identity/once policy; authority routing, Todo/lease records and acceptance schemas unchanged.
  • Provider conformance arms run: isolated File/SQLite consumers.
  • Read-only legacy/file/PostgreSQL three-arm rehearsal: N/A; no provider promotion, runtime-routing or compatibility projection change.

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.
  • No duplication of maintainer-owned benchmark work.
  • Change scoped to the linked issue.
  • No paired RFC changed; bilingual RFC check passes.
  • UI impact marked none.
  • Every commit includes a DCO Signed-off-by trailer.

Maintainer update

The updated branch integrates current main and preserves the original contributor commit.

  • An agent_scope_wait receipt retains the pending Vision diagnosis. It carries no Todo or replan settlement binding, so replay of the same Turn stays quiet.
  • A positive, newline-committed heartbeat receipt consumes the one-time baseline initialization. The existing rollout append lock checks the scoped predicate before committing, so competing guards converge to the same admitted Turn. The typed replan admission reader verifies the original receipt and exact Goal lifetime.
  • File and SQLite public CLI tests cover an append failing before any commit, a complete JSON row with its committing newline missing, an error after the row was committed, and a competing Turn whose receipt wins before the first append. They verify reopening the allowance only for uncommitted work, replaying the admitted identity, an unbound wait, and zero debits during admission.

Exact PR head e94e81ea7310e3ec29992b685c523e661d720895. The focused suites passed 82 Python and 106 TypeScript cases. Typecheck, Ruff and the public-boundary scan passed. The final change after those runs preserves the Python AST and meets the changed-file line ceiling. Exact-head standard premerge is running. Independent review remains pending.

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

评审提交 2938c338851793a4e487bf4381ce7b8b10a4cb0d。结论 REQUEST_CHANGES。

P2 等待回执在重试时绕过一次性初始化限制

等待回执绑定了重规划身份。用同一个等待 Turn ID 重读后,回执升级,返回 should_run=true、must_attempt=true 和结算计划。 从原始正向准入回执派生豁免。安静等待应保留诊断义务,避免写入能在重试时绕过限制的结算身份。

P2 准入回执写失败仍消耗唯一初始化机会

只在真实 CLI 的 rollout 追加点注入 OSError。首次 guard 返回 heartbeat_receipt_write_failed,磁盘上已有准入 sidecar。修复 IO 后,新的 Turn 返回 agent_scope_wait。仍持有失败 Turn ID 的调用方可以原样重试并成功准入。 在现有回执提交边界确认一次性初始化,或把预留与真实回执对账,在明确失败后恢复资格。

动机 / Motivation

处理阻塞 Todo 的 Agent 需要一次有明确结算身份的 Vision 基线初始化,并能在后续唤醒进入安静等待。 自治重规划只剩缺失的 Vision 基线时,主干会为没有可执行 Todo 的 Agent 再次返回 run_now。 候选首次等待是安静的。两个新的 Turn 各自在相同身份下重试后都重新取得执行权,正常重试可以绕过单次初始化上限。 检查覆盖真实 CLI、回执和调度投影,执行范围到启动判定为止。

改动思路 / Approach

复用现有 agent_scope_wait,保留原始初始化身份,让等待和回执协调读取同一个有效准入事实。 新增本地准入记录需要与已有 heartbeat receipt 的真实状态一致,现有回执协调负责解释重试资格。 设计问题 #8572

具体改动 / Changes

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

对主干的风险 / Risks

额度 1/0,原 Turn 已获得正向回执。另开两个 Turn,各自第一次查询均安静等待,使用各自同一 ID 再读 guard 后均升级成正向重规划。 只在真实 CLI 的 rollout 追加点注入 OSError。首次 guard 返回 heartbeat_receipt_write_failed,磁盘上已有准入 sidecar。修复 IO 后,新的 Turn 返回 agent_scope_wait。仍持有失败 Turn ID 的调用方可以原样重试并成功准入。

首次真实准入返回 autonomous_replan_required,首次新 Turn 安静等待。独立任务和到期监控的 File、SQLite 对照通过。 Python 109 项、TypeScript 91 项、控制面 typecheck、Ruff、quick premerge 6 项直接检查及 3 项选定检查均通过。

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

我的整体评价 / Verdict

从原始正向准入回执派生豁免。安静等待应保留诊断义务,避免写入能在重试时绕过限制的结算身份。 用同一夹具验证原身份、新 Turn 和重复读取的结果。另加回执追加故障并验证修复后的重新准入。

English verdict: REQUEST_CHANGES for 2938c338851793a4e487bf4381ce7b8b10a4cb0d. A quiet wait receipt becomes executable on same-Turn replay. A failed guard append also consumes the sole initialization admission.

Comment thread loopx/control_plane/quota/should_run.py Resolved
@mergify

mergify Bot commented Nov 11, 2026

Copy link
Copy Markdown

This pull request has merge conflicts with main and cannot be merged
until they are resolved. Please rebase or merge the base branch, @xiaobaifly7.

Choose the remote for the base repository, not an out-of-date fork.
For a fork clone, first inspect git remote -v; upstream must point
to https://github.com/loopx-project/loopx.git. If it is absent, add it
with git remote add upstream https://github.com/loopx-project/loopx.git.
Then run:

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 HEAD

For a same-repository clone whose origin points to
https://github.com/loopx-project/loopx.git, use origin instead of
upstream for fetch/rebase. If you prefer merging the base, use
git merge <base-remote>/main and push normally.

Keep the DCO Signed-off-by trailer on every commit when you rebase.
https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify Bot added the needs-rebase Mergify: the pull request has merge conflicts with its base branch label Nov 11, 2026
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
@mergify mergify Bot removed the needs-rebase Mergify: the pull request has merge conflicts with its base branch label Nov 22, 2026
loopx-agent
loopx-agent previously approved these changes Nov 22, 2026

@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.2-sol · OpenAI · runtime_reported · xhigh

动机 / Motivation

仅有受阻事项的 Agent 需要保留原 Vision 诊断,同时避免每轮反复创建初始化任务。 主干在 File 与 SQLite 的独立进程对照里,把四次守卫全判为自主重规划,得到四个不同 Turn 绑定。 有可办任务、到期 Monitor、其他 Agent 或其他 Goal 沿用原独立执行规则。被阻塞的同一范围仅限制缺失基线所引起的重复初始化。 候选将唯一一次批准绑定到成功提交的正向回执。竞争失败者保留诊断和安静等待。 改动在缺失基线的阻塞前沿、回执持久化与原 Turn 的重放。

改动思路 / Approach

TypeScript 的 quota owner 给出类型化值,使用原 rollout append lock 串联实际提交。 按当前 Goal lifetime、Agent 和原 Turn 区分,相同身份的未完成结算保持原跟进。 沿用现有 rollout log 的提交条件。等待只携带诊断,正常激活和原 Turn 同一绑定继续走原 owner。

具体改动 / Changes

准确头 e94e81e,merge base c563a47,15 个文件,+584/-10。按实际远端主干逐项检查原 contributor 与后继修复。核验初始化票据、并发、原结算和已有标准等待。 按修订 c563a47 的现有规范核对各项要求。 目标规范

关键代码讲解

  • boundVisionBaselineAdmission 基于完整工作计数和已提交的正向 receipt。 规则

  • _check_vision_baseline_admission 在追加锁内检查同一范围的回执。 追加

  • quota_rollout_settlement_binding 让等待诊断回执保持无绑定。 绑定

  • 普通 CLI 回归模拟追加前后错误和竞争者。 回归

  • initialization_receipt 核验换行提交和竞争。

  • original_turn 核验赢家和等待者重放。

  • ordinary_scope 核验独立工作和到期 Monitor。

对主干的风险 / Risks

两种存储各用四个真实并行 CLI 进程,在同一 Goal 与 Agent 上竞争初次初始化。主干每种存储均准入四个独立 Turn。候选均只有一个准入、三个等待。再次调用赢家保持原结算身份,再次调用等待者仍无结算绑定,预检查未产生扣额。 在 File 和 SQLite 上注入追加前失败、缺提交换行以及提交后丢失响应。前两种恢复后重新准入,提交后的重试恢复同一原身份。新可办工作或到期 Monitor 保留正常执行分支。 定向 130 项 Python 和 106 项 TypeScript 通过。独立并发对照每侧各覆盖 File 与 SQLite,TypeScript 类型检查和 Ruff 通过。 另外重验原票据、回放与旧等待场景,保留实测结果 126 passed。 GitHub PR 的 base 快照仍显示旧引用。以经 GitHub compare 与本地 Git 双重确认的当前 main 为评审基准,其净差异为 15 个文件。主干随后合入 #9235,六处更新与本提案路径无交集,已核对三方合并。标准预合并的 CLI output budget 检查触发 120 秒外层时限,原标准结果仍失败。 独立运行同一命令,主干 311 秒与候选 292 秒均完成,通过内容与大小断言。 签名安装、远端 CI 和 PostgreSQL 在本轮未独立验证。

我的整体评价 / Verdict

批准当前提交,未发现阻断项。原两项求改所列故障已在当前提交通过独立回归。代码结论限当前主干上的上述 15 处改动。 CLI guard 和结算语义改变,当前 diff 无首屏渲染变化。

English verdict: APPROVE at e94e81e. Approve the 15-file source delta against the verified current main. Four independent guards converge to one committed admission on both File and SQLite. Failure before commit preserves an opportunity to retry, and waiting receipts cannot bind a replan on replay. The outer premerge CLI budget result and GitHub base comparison discrepancy are recorded separately.

@xiaobaifly7
xiaobaifly7 dismissed loopx-agent’s stale review November 22, 2026 12:49

The merge-base changed after approval.

Signed-off-by: huangruiteng <huangrt01@163.com>

@huangruiteng huangruiteng 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 · OpenAI · self_reported

No blocking finding.

动机 / Motivation

阻塞型 Agent 如果只剩缺失的 Vision baseline,旧行为会在每个新 Turn 再次返回 autonomous_replan_required。Agent 没有可执行 Todo、没有到期 Monitor,却持续消耗 guard 与诊断回合,实际进展仍为零。当前 head 把允许范围限定为完整且同 Agent 的 blocked-only frontier:第一次可以初始化,成功回执提交后,新的 Turn 进入安静的 agent_scope_wait,但仍保留缺失 baseline 的义务。独立工作、到期 Monitor、原 receipt-bound replan 和其他 Goal/Agent 不受影响。

The affected callers are ordinary Codex App and CLI quota guards, plus the Agents and operators relying on blocked-only lanes to wait without repeated quota turns. Before the change, a blocked-only Agent with only vision_checkpoint_missing gaps is admitted again on each new Turn. At the reviewed head, the first Turn is admitted, the committing receipt records that one initialization, and later fresh Turns return quiet agent_scope_wait while retaining the pending Vision obligation. A blocked-only Agent is admitted once and then waits quietly; independent runnable work, due monitors, receipt-bound replans and original settlement continue through their existing owners. This PR does not add a reset UI, replace receipt recovery, define a general quota exception, or claim installed-host and live-model qualification.

改动思路 / Approach

决策仍由 TypeScript quota.run_decision owner 产生。admitQuotaRunDecision 先执行原有 run decision,再由 boundVisionBaselineAdmission 判断是否属于唯一可收敛的 missing-baseline 场景。允许消费的时间点不是 projection,而是现有 rollout log 的提交换行:只有完整、同 Goal instance、同 Agent 且 admitsAutonomousReplan 的正向 receipt 才算已初始化。CLI append 继续复用原锁和 precondition;等待回执不携带 Todo/replan settlement identity,因此同 Turn 重放不会变成可执行计划。实现复用了现有 scheduler wait、heartbeat receipt 和 settlement owner,没有新增 store、命令或并行决策器。

The policy uses the existing decision and receipt owners, preserves wait semantics and adds no parallel scheduler. Ship the once-only blocked-only admission and its receipt-bound failure handling; defer installed, PostgreSQL and live-model qualification.

具体改动 / Changes

  • boundVisionBaselineAdmission 只在 counts 完整、advancement 为零、无 Monitor 缺口、blocker 全部同 Agent 且 trigger/gap 全为 vision_checkpoint_missing 时参与。已有 committed initialization 时,新 Turn 投影 agent_scope_wait,原 admitted Turn 仍保留原决策。
  • _check_vision_baseline_admission 在原 append lock 内读取 committed-only receipt,确保两个并发 guard 只有一个初始化赢家。
  • quota_rollout_settlement_binding 对 should_run=false 的 agent_scope_wait 返回空 settlement binding,解决原 review 指出的“等待重试后变成可执行”问题。
  • committedGoalRolloutEvents 排除没有提交换行的 torn row;Python CLI 同样使用 committed-only 读取,解决 append 失败却消耗唯一机会的问题。

规范依据 issue #8572,revision 8572。single-initialization:每个 runtime root、Goal 和 Agent 只允许一次初始化;committed-receipt:只有提交回执消费机会;quiet-wait:后续 Turn 安静等待且无 settlement identity;independent-continuation:真实工作、到期 Monitor 和原结算继续;installed-qualification:安装态与真实模型明确超出本切片。

对主干的风险 / Risks

最强反例是“旧回执已被误认为提交”或“竞争 guard 各自准入”,这会永久饿死唯一初始化或产生两个初始化 Turn。File/SQLite 测试分别覆盖提交前失败、缺少换行的 torn row、提交后响应丢失和并发赢家;结果均只有一个合法 admitted Turn,等待方无 settlement identity,原赢家 replay 保持原身份。其他 blocker 类型、unknown counts、repair lane、独立工作和到期 Monitor 仍走原 owner。

本地 exact head 验证:130 个定向 Python case、106 个定向 TypeScript case、control-plane typecheck、focused Ruff 和 loopx canary premerge --tier quick 均通过。远端 CI 在新 merge head 刚入队;安装宿主、PostgreSQL、真实模型和长时间生产遥测未验证,保留为独立风险。

我的整体评价 / Verdict

长程上,该改动把“无工作却反复重规划”收敛为一次可观察初始化加安静等待,同时保留真实工作、原结算和更换 owner 后继续运行的能力。用户侧 JSON 更诚实,不需要额外配置或人工重置。改动通过现有 typed decision 与 receipt owner 完成,属于 proportionate、必要的局部修复。

English verdict: APPROVE at 6fa26c1. One committed Vision-baseline initialization now precedes quiet scoped waiting; File/SQLite failure, race, replay, independent-work and due-monitor cases pass, while installed-host, PostgreSQL and live-model qualification remain unverified.

@huangruiteng
huangruiteng merged commit 80db8df into loopx-project:main Nov 23, 2026
9 of 11 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.

Clarify blocked-only wait when an Agent Vision baseline is missing

3 participants