Skip to content

fix(quota): align deferred priority with action selection projection - #4932

Merged
huangruiteng merged 1 commit into
mainfrom
codex/finance-quota-selection-20260923
Sep 23, 2026
Merged

huangruiteng merged 1 commit into
mainfrom
codex/finance-quota-selection-20260923

Conversation

@huangruiteng

Copy link
Copy Markdown
Collaborator

Summary

  • Reuse the existing ready-deferred priority frontier when building the quota action portfolio, so a P1 candidate that cannot run is not presented as an eligible alternative.
  • Feed the same preemption into the TypeScript-owned explicit-selection qualifier. The result is a typed deferred response instead of a later selection conflict; no false receipt is committed.
  • Preserve independent P1 fallback when the P0 deferred resume condition is still pending, and preserve equal-priority P0 selection.

Validation

  • uv run --extra test python -m pytest -q tests/control_plane/test_quota_settlement_cli.py (70 passed)
  • uv run --extra test python -m pytest -q tests/control_plane/test_quota_action_portfolio.py tests/control_plane/test_quota_selection.py tests/control_plane/test_agent_scope_frontier_contract.py (34 passed)
  • Focused new regressions (2 passed), Ruff, py_compile, git diff --check.

Product path and scope

CLI and Codex App managed quota selection use the corrected shared projection. No frontend or Lark UI change: neither has a separate action-portfolio selection source. No private Goal state or credentials are included. The preexisting deferred-resume priority rule is reused, not broadened to a blanket P0-versus-P1 prohibition.

Residual risk

This is a selection-projection alignment slice. It does not change the deferred lifecycle policy or receipt replay semantics. Control-plane owner review is required before merge.

Signed-off-by: huangruiteng <14976749+huangruiteng@users.noreply.github.com>

@huangruiteng huangruiteng 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.

Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
Reviewed exact head: af65f59

动机

quota should-run 曾把一个 P1 列成可选替代项,但同一批权威 Todo 里已有更高优先级、恢复条件已满足的 deferred successor。显式绑定 P1 时,资格判定先说 qualified,最终 frontier 又选中 deferred 项,形成冲突。这个 PR 要完成的边界是“推荐与绑定一致”,不是重写 P0/P1 调度政策。

改动思路

权威事实仍来自当前 Goal Todo summary;复用现有 _selected_candidate_priority_frontier 判定,而非新建优先级表。候选投影和显式选择两个入口都消费这条判定,后者仍交给 TS qualifyActionSelection 产生 typed deferred。只改一边会留下另一边的矛盾;不发货则继续误导 agent。没有新增持久状态、schema 或交易权限。

具体改动

关键代码讲解

  • quota_runnable_action_candidates:从 capability-gated open advancement 候选构建 portfolio 时,排除会被已就绪高优先级 deferred successor 抢占的候选;同级和未就绪条件不受此规则排除。
  • _delivery_preemptions_for_route:仅在没有更高优先级的既有硬门禁时,把相同 frontier 结果传给 TS 资格判定,显式 P1 因而返回 deferred,而不是先 qualified 再发生 selection conflict。
  • CLI 回归测试覆盖 portfolio 不再推荐 P1、P1 的未提交回执、同轮同级 P0 可绑定,以及未来才恢复的 P0 不阻止独立 P1。

对主干的风险

主要风险是 hot path 多一次现有 Python frontier 调用,以及 Todo summary 若不完整时与最终 frontier 同源的漏判。没有第二套阈值;后续 TS 整笔事务迁移应整体迁走此既有判定,而非在 TS 复制一份。针对最强反例,未就绪 P0 + 独立 P1 的真实 CLI 路径仍通过;未引入跨 agent 授权或 receipt replay 改动。70 个 quota CLI、34 个相邻控制面、28 个下游选择/投影测试通过,Ruff、py_compile 和 diff 检查通过;本 Goal 的 review 配置为不等待/查询远端 CI。

语义与 CI 对齐

现有 quota 契约已规定“严格更高优先级且已就绪的 deferred successor 先做生命周期裁决”,并允许等待中的高优先级项让独立低优先级工作继续。本改动沿用该词汇与决策 owner;无新 schema。合并后仍需在安装版对一个实际 Goal 读回,本地合成 fixture 不冒充生产验收。

我的整体评价

没有发现阻断性问题。这个切片对所报投影矛盾是完整且可回退的修复,保留 agent 对一般 runnable P0/P1 的选择,不实施一刀切禁用 P1。评审结论为可接受;但它改变控制面行为,按仓库规则必须交维护者合并,作者不自合并。

English verdict: APPROVE - exact head af65f59 reuses the existing ready-deferred frontier across portfolio and TS-owned explicit selection; local CLI and downstream validation passed, with post-merge installed readback still required.

@huangruiteng
huangruiteng merged commit 0edbdf2 into main Sep 23, 2026
25 of 26 checks passed
@huangruiteng
huangruiteng deleted the codex/finance-quota-selection-20260923 branch September 23, 2026 10:22
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.

1 participant