Skip to content

fix(control-plane): restore current quota contracts - #4847

Merged
huangruiteng merged 8 commits into
loopx-project:mainfrom
Duang777:codex/fix-quota-crowded-output-budget
Sep 21, 2026
Merged

huangruiteng merged 8 commits into
loopx-project:mainfrom
Duang777:codex/fix-quota-crowded-output-budget

Conversation

@Duang777

@Duang777 Duang777 commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Summary

  • assert that settled replay omits the retired protocol_action_packet
  • provide the required evidence-linked goal-vision contract when the selection reentry test executes its generated refresh-state command
  • restore typed blocked-transition notices that 9ee5c6fbc accidentally removed while widening explicit --todo-id lookup

Root cause

Three mainline changes left contract regressions behind. aa81a2aed removed the legacy protocol action packet, 129bb1fe7 made Todo-bound long-chain replans require --agent-vision-json, and 9ee5c6fbc dropped blocked_transition_notices while adding authoritative Todo lookup.

The original CLI output-budget changes in this branch were superseded by #4823. This PR now contains only the three focused contract repairs above.

Validation

  • focused blocked-transition, explicit Todo, selection, replay, and conflict suite: 30 passed
  • CLI output budget and differential suite: 85 passed
  • Ruff, py_compile, and diff checks: passed
  • loopx canary premerge --from-git-diff: passed, 16/16 selected checks, no manual holds

Exact head: 11df6db8b.

This PR is awaiting maintainer review and will not be self-merged.

Signed-off-by: duanjialing.777 <duanjialing.777@bytedance.com>
@Duang777

Copy link
Copy Markdown
Contributor Author

@huangruiteng 请审阅这个主干基线修复。它只更新 129bb1fe7 引入 vision writeback 后的 crowded CLI 输出预算,并让 differential 的 base probe 只负责测量继承输出;candidate 仍执行绝对预算和 base/head 比较。exact head 1eddaf7e5 的 CLI output smoke、83 项相关测试、Ruff、py_compile 和 premerge 12/12 均通过。本 PR 不自合并,合入后我会同步并复验 #4818

…ed-output-budget

Signed-off-by: duanjialing.777 <duanjialing.777@bytedance.com>
@Duang777

Copy link
Copy Markdown
Contributor Author

已用普通、带 Sign-off 的 merge commit 同步最新 main@61b8311b7,当前 exact head 为 8509666e3。同步后复验:CLI output budget smoke 通过,预算与 differential 测试 83 passed,Ruff/py_compile/diff check 通过,premerge 12/12 passed、0 manual holds。请按当前 head 审阅;本 PR 不自合并。

Signed-off-by: duanjialing.777 <duanjialing.777@bytedance.com>
Signed-off-by: duanjialing.777 <duanjialing.777@bytedance.com>
@Duang777

Copy link
Copy Markdown
Contributor Author

@huangruiteng 已用普通、带 Sign-off 的 merge commit 同步 main@c57879af3,当前 exact head 为 b317a085a。主干移除 legacy packet 后,turn plan crowded 绝对输出仍为 12,757 chars / 351 lines,但 small 降到 8,030 chars,增长变为 4,727 / 35 = 135.1 chars/Todo;因此仅把增长预算从 125 调到 140,绝对 chars/lines 上限未变。新 head 复验:预算与 differential 测试 83 passed,budget regression smoke 通过,base/head differential 102/102、candidate-only 0、review-required 0,Ruff/py_compile/diff check 通过,premerge 12/12 passed、0 manual holds。请按当前 head 审阅;本 PR 不自合并。

Signed-off-by: duanjialing.777 <duanjialing.777@bytedance.com>
Signed-off-by: duanjialing.777 <duanjialing.777@bytedance.com>

# Conflicts:
#	examples/control_plane/cli-output-base-head-differential-smoke.py
#	examples/control_plane/cli-output-probe-runner.py
#	loopx/control_plane/testing/cli_output_budget.py
@Duang777 Duang777 changed the title fix(test): restore CLI output budget gate test(control-plane): align replay fixtures with current contracts Sep 21, 2026
@Duang777

Copy link
Copy Markdown
Contributor Author

@huangruiteng 已同步 main@9982ee0d0,当前 exact head 为 0cbc9fa50184224fc0435d9084e7d4934ba9c0ab#4823 已覆盖原预算修复,所以当前 PR 仅更新两处过期测试:settled replay 不再期待已移除的 protocol_action_packet,selection reentry 为生成的 refresh-state 命令提供必需的 evidence-linked vision contract。验证结果:相关测试 100 passed,CLI budget smoke 通过,base/head differential 102/102 且无 review signals,Ruff、py_compile、diff check 和 premerge 3/3 均通过。请按当前 head 审阅;本 PR 不自合并。

…ed-output-budget

Signed-off-by: duanjialing.777 <duanjialing.777@bytedance.com>
@Duang777

Copy link
Copy Markdown
Contributor Author

@huangruiteng 已用普通、带 Sign-off 的 merge commit 同步 main@ee5b14322,当前 exact head 为 b251577cb482b1d7e9b2c29501155b2ce6fe739f,无冲突。新 head 验证:20 项直接相关 quota 回归和 85 项 CLI 输出预算/differential 测试通过;Ruff、py_compile、diff check 通过;premerge 3/3 passed、0 manual hold。请按当前 head 审阅;本 PR 不自合并。

Signed-off-by: duanjialing.777 <duanjialing.777@bytedance.com>
@Duang777 Duang777 changed the title test(control-plane): align replay fixtures with current contracts fix(control-plane): restore current quota contracts Sep 21, 2026
@Duang777

Copy link
Copy Markdown
Contributor Author

@huangruiteng 旧 head 的 test-shard (3) 暴露了一个可在其主干父提交复现的回归:9ee5c6fbc 保留了通用 fallback 文案,却误删了 typed blocked_transition_notices 的构造。当前 head 11df6db8b 以 9 行改动恢复原有 notice 收集,同时保留新的 authoritative --todo-id lookup。验证:相关组合 30 passed,CLI 输出预算/differential 85 passed,Ruff/py_compile/diff check 通过,premerge 16/16、无 manual hold。远端 CI 已按新 head 重跑,请审阅当前 head。

@Duang777

Copy link
Copy Markdown
Contributor Author

@huangruiteng 当前 exact head 11df6db8b5d0e033d3536e794a3cf21abd80fd32 的 26 项检查已全部结束:0 failed、0 pending,四个 test shard、kernel static、coverage pytest 与最终 merge gate 均通过。分支可合并,现仅等待审阅;本 PR 不自合并。

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

评审 exact head:11df6db8b5d0e033d3536e794a3cf21abd80fd32

动机

这个 PR 收敛的是三处已经进入主线、但彼此没有完全对齐的 contract regression:protocol_action_packet 已退役后 settled-replay 测试还在读取它;Todo-bound long-chain replan 已要求 evidence-linked Goal vision 后,selection-reentry 测试仍直接执行带占位符的 refresh-state;以及显式 --todo-id lookup 扩展时误删了 blocked_transition_notices 的生产 caller,导致 quota 明明设置 notify_user=true,interaction contract 却只能退回通用的一句话,丢失 task、cause、impact、recovery 和 next action。

当前 exact-head diff 已去掉被 #4823 supersede 的 output-budget 工作,只保留 9 行生产恢复和两处 current-contract fixture 修正。范围与根因匹配,是一个完整、可独立验证的 repair slice。

改动思路

生产实现没有发明第二套 notice:_blocked_priority_fallback 继续拥有“哪个 higher-priority item 真正阻塞”的判定,复用现有 build_blocked_transition_notice 生成 typed payload;blocked_transition_notice.py 仍独占 task/cause/evidence/impact/responsible party/recovery/next action 的内容规则;interaction_contract 继续只消费首个 notice 并保留 legacy prose fallback。

这也保留了关键的 authority separation:notice attachment 是 machine-enforced projection,但 delivery.state 仍是 pending,没有把“应通知”伪装成“已投递/已读”;agent-owned blocker 不要求 owner action,且 fallback execution、quota spend、scheduler 与 Todo 状态都没有被这次恢复修改。

两个测试改动同样选择了现有 contract owner:selection reentry 在 tmp_path 生成合法的 goal_vision_replan_contract_v0,再替换 CLI 生成命令中的 evidence placeholder;settled replay 则明确断言 retired field 不存在,而不是重新引入兼容字段。

具体改动

关键代码讲解

  1. loopx/control_plane/quota/should_run_prepare.py:213_blocked_priority_fallback 先固定 executable fallback,再扫描它前面的 open items。scheduled future monitor 仍只算 deferral;普通 open advancement 仍不算 blocker;只有 status=blocked 或未满足的 normalized resume_when 才设置 owner-visible blocker。
  2. loopx/control_plane/quota/should_run_prepare.py:275 对上述真实 blocker 调用已有 build_blocked_transition_notice(item, selected_executable=selected),因此 notice 的 impact 能说明 fallback 仍在继续,同时 responsible-party 规则决定 owner_must_act,quota caller 不复制这些语义。
  3. loopx/control_plane/quota/should_run_prepare.py:305 只在现有 blocked_priority_fallback_v0 上恢复 blocked_transition_notices[:3]blocked_itemsselected_executablenotify_user 与 recommended action 均沿用既有路径。
  4. tests/control_plane/test_selection_replan_reentry.py:90 为 Todo binding 补 evidence-linked vision/path-delta fixture,继续真实执行生成的 refresh command,证明 reentry 能在当前 contract 下完成且只 settle 一次。
  5. tests/control_plane/test_settled_replay_construction.py:20protocol_action_packet 加入 absent-field 集合,固定 settled turn 不重建 successor、replan 或已退役 packet 的语义。

历史对照也支持这个边界:e35a97d5d 最初接入 typed notice,9ee5c6fbc 在扩展 authoritative --todo-id lookup 时删除了 caller;本 PR 恢复原有调用,同时完整保留 9ee5c6fbc 的 lookup 行为,没有回滚或复制那条功能。

对主干的风险

最强回归风险有三类:把 future monitor 当成 blocker 造成噪声通知;把 agent-owned blocker 误投影成 owner gate;或者 notice 恢复意外阻止已选 fallback。现有路径和本地 counterfactual validation 覆盖了这些边界:blocked advancement、resume-pending advancement 会得到 typed notice;future monitor 仍是 quiet deferral;普通 open item不生成 blocked fallback;agent-owned notice 保持 owner_must_act=false;selected fallback id 不变。legacy payload 没有 notice 时仍能渲染 generic reason。

验证结果:五个相关模块共 34 passed in 74.20s;Ruff、py_compilegit diff --check 全部通过;loopx canary premerge --from-git-diff 运行了 16 个 control-plane/planning/monitor/refresh-state/architecture/canary-runner checks,16/16 通过,无 failure、warning 或 manual hold。按 capability 配置 wait_for_ci=false,没有等待远端 CI。

当前 PR 显示 BEHIND,但与最新 origin/main 的 merge-tree 没有冲突。rebase 会改变 exact head 并可能使这次 review 失效,届时应按新 head 复核;这不构成当前代码语义 blocker。

语义与 CI 对齐

本 PR 复用而非扩展 vocabulary:blocked_priority_fallback_v0blocked_transition_notice_v0goal_vision_replan_contract_v0 和 settled-replay 的 absent-field contract 都已经存在。没有 substring/prose classification,没有把 guidance 写成 obligation,也没有把 pending delivery 宣称为 completed delivery。premerge 的 quota/work-lane、monitor、autonomous-replan、refresh-state 与 semantic-vocabulary smokes 均通过,和这一判断一致。

我的整体评价

这是一个比例合适、ownership 清晰的 control-plane repair。生产 diff 仅恢复既有 typed caller,测试修正把真实 CLI/replay fixture 对齐当前主线 contract;没有新持久化状态、CLI 参数、scheduler/quota authority 或 speculative framework。bounded future-facing pass 已经体现在复用单一 notice builder/renderer,当前相邻边界不需要额外重构。

我没有发现阻塞问题,批准该 exact head。残余边界是:本 PR 不实现 notice delivery/readback ledger,payload 也诚实地保持 delivery.state=pending;批准不把这个 future slice 视为已交付。

English verdict: APPROVE - head 11df6db8b5d0e033d3536e794a3cf21abd80fd32 restores the existing typed blocked-transition notice caller without changing fallback, spend, scheduler, or delivery authority; 34 focused tests, Ruff, py_compile, diff/merge-tree checks, and all 16 selected premerge canaries pass, with external notice delivery correctly remaining out of scope and pending.

@huangruiteng
huangruiteng merged commit 154f71a into loopx-project:main Sep 21, 2026
26 checks passed
huangruiteng added a commit that referenced this pull request Sep 21, 2026
…backoff

Conflict was tests/control_plane/test_selection_replan_reentry.py: main's
#4847 fixed the same stale contract independently (authoring the
evidence-linked vision packet for the todo binding). Take main's reviewed
version verbatim; this branch's equivalent repair is superseded.

Signed-off-by: LoopX Agent <agent@loopx.local>
Signed-off-by: huangruiteng <14976749+huangruiteng@users.noreply.github.com>
huangruiteng added a commit that referenced this pull request Sep 21, 2026
…backoff

Conflict was tests/control_plane/test_selection_replan_reentry.py: main's
#4847 fixed the same stale contract independently (authoring the
evidence-linked vision packet for the todo binding). Take main's reviewed
version verbatim; this branch's equivalent repair is superseded.

Signed-off-by: LoopX Agent <agent@loopx.local>
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