Skip to content

fix(tests): pass lease_proof to refresh-state in hard-lease spend test - #9203

Merged
loopx-agent merged 1 commit into
mainfrom
codex/fix-visible-goal-hard-lease-test-20261121
Nov 21, 2026
Merged

loopx-agent merged 1 commit into
mainfrom
codex/fix-visible-goal-hard-lease-test-20261121

Conversation

@loopx-agent

Copy link
Copy Markdown
Collaborator

Summary

  • Forward ready["execution_preparation"]["lease_proof"] (--task-lease-idempotency-key, --task-lease-expected-version) to refresh-state in tests/control_plane/test_quota_settlement_cli.py::test_visible_goal_selection_before_hard_lease_preserves_spend_source.
  • Restores alignment with the hard_lease first-refresh-state lease proof contract (refresh_task_lease_unavailable surfaced during v2.4.0 release qualification; original PR predated that requirement).

Verification

  • pytest -q -n 4 tests/control_plane/test_quota_settlement_cli.py: 221 passed
  • Targeted pytest across all 13 Python suites + 1 TS test file modified between 202d7bdb05 and prior origin/main: 518 passed, 2 skipped (node --test: 5 passed)
  • ruff check, mypy (17 strict files), check_rfc_bilingual.py, 13-surface release-readiness-doc-smoke.py, loopx check (0 errors), Goal-bound CQR (personal-loopx-maintenance), and loopx canary premerge --from-git-diff --git-diff-base origin/main --goal-id personal-loopx-maintenance (5/5 direct, 3/3 selected, 0 failures)

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

@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 · Gemini · Google · self_reported

Approval conclusion (author-owned PR; GitHub blocks formal self-approval)

在精确 head bcd4279a31faced8fa492a7bbc0de18b9da8c934 上完整复核了 PR #9203(tests/control_plane/test_quota_settlement_cli.py,+5 / -0)并独立重跑了目标单测、全文件 221 条测例及静态/预合并门禁:该修复精准对齐了 hard_lease 首写契约,零生产代码修改且未放宽任何否定断言。

动机 / Motivation

执行全量 pytest 与 v2.4.0 发布验收的维护者,以及运行控制面结算测试 suites 的开发者,会因该历史单测在主干失败而被阻断。改动前,test_visible_goal_selection_before_hard_lease_preserves_spend_source 在 hard_lease 模式下未向首轮 refresh-state 传入 ready['execution_preparation']['lease_proof'] 的幂等键与期望版本,被 read_active_task_lease_epoch 拒绝并返回 refresh_task_lease_unavailable;改动后从 ready 读取 lease_proof 并传入对应命令行参数,恢复与现行硬租约首写契约一致且未放宽任何断言。在精确 head bcd4279 上,目标单测与整个 tests/control_plane/test_quota_settlement_cli.py 全部 221 条测例全量通过,同时静态检查与预合并冒烟门禁全部通过且零生产代码改动。本 PR 不修改生产代码中的租约校验、调度状态机或发布文档,不放宽或跳过任何既有否定断言。

改动思路 / Approach

由于 loopx/control_plane/quota/execution_preparation.py 中的 read_active_task_lease_epoch 明确要求处于 ready 状态的 hard_lease Todo 在首轮 refresh-state 时校验 requested_proof == current.get('lease_proof')(否则返回 refresh_task_lease_unavailable),问题根因是早先编写的 test_visible_goal_selection_before_hard_lease_preserves_spend_source 缺少对 ready['execution_preparation']['lease_proof'] 的参数转发。PR 直接在调用方补充 --task-lease-idempotency-key 与 --task-lease-expected-version,而非修改或放松生产校验逻辑,也不涉及任何新增测试或重复脚手架,是最小且可逆的边界修复。

具体改动 / Changes

本次仅改动 1 个测试文件 tests/control_plane/test_quota_settlement_cli.py(+5 / -0 行),无新增文件、无生产代码或文档变更。

对照契约模块 loopx/control_plane/quota/execution_preparation.py(精确修订 bcd4279a31faced8fa492a7bbc0de18b9da8c934):

  • LEASE-PROOF-1(hard_lease 就绪后的首轮 refresh-state 须携带 execution_preparation.lease_proof 中的 idempotency_key 与 expected_version):implemented(经 test_visible_goal_selection_before_hard_lease_preserves_spend_source 及全文件 221 条测例实测验证)。

关键内容讲解

  • tests/control_plane/test_quota_settlement_cli.py(L5216-5258):在 todo claim 与第二次 quota should-run 确认 ready["execution_preparation"]["state"] == "ready" 后,新增读取 lease_proof = ready["execution_preparation"]["lease_proof"],并将其 --task-lease-idempotency-key 与 --task-lease-expected-version 传给 _run_cli(..., "refresh-state", ...);随后依然严格校验 refresh_rc == 0、quota_spend_source == "visible-goal" 及 --source visible-goal 结算命令输出。同文件 L5915-5924 对过期租约凭证被拒绝(refresh_task_lease_unavailable)的否定断言保持完整未动。

对主干的风险 / Risks

本 PR 为纯测试调用对齐修复,对主干与生产运行时零风险;经检索 tests/control_plane/test_quota_settlement_cli.py,同文件中不存在重复覆盖该 visible-goal + hard_lease 组合场景的冗余测例,且此次改动仅修复现存断测、无批处理冗余问题。

独立本地验证结果:

  • 目标单测(-k test_visible_goal_selection_before_hard_lease_preserves_spend_source):1 passed, 220 deselected in 4.52s (PASS)
  • 完整测试文件 tests/control_plane/test_quota_settlement_cli.py:221 passed in 489.73s(0 跳过、0 失败)(PASS)
  • 静态与边界门禁:ruff check、默认 mypy(17 文件)、check_rfc_bilingual.py、loopx check(0 错误/0 告警)、git diff --check、git merge-tree HEAD origin/main(CLEAN):全部通过 (PASS)
  • loopx canary premerge --from-git-diff --git-diff-base origin/main --timeout-seconds 300:5/5 直接检查与 3/3 目录冒烟(quota-plan-smoke.py、quota-work-lane-policy-smoke.py、monitor-scheduler-contract-smoke.py)全过,failures=0,manual_hold_count=0 (PASS)
  • 远程 GitHub CI:依 Goal 配置未等待/未查询 (UNVERIFIED)。

我的整体评价 / Verdict

基于独立复核,PR #9203 用精确的 5 行修改修复了全量发布跑测在 test_visible_goal_selection_before_hard_lease_preserves_spend_source 上的阻断错误,同时严格保留生产端 hard_lease 校验与所有否定用例不变。problem_context.outcome_impact 评估:long_horizon 为 preserved(execution_preparation.read_active_task_lease_epoch 校验与同文件过期租约否定回归均原样保留);user_experience 为 preserved(恢复结算套件全绿);visual_review 为 not_applicable:已复核全部 1 个改动文件,仅修改后端 CLI 控制面单测中的 5 行调用参数,不涉及任何前端渲染或用户界面;未验证范围(unverified_scope):none。code_volume 为 necessary(兼容性策略 not_applicable),durable_smoke_value 为 verified(无重复/刷量问题)。精确 head bcd4279a31faced8fa492a7bbc0de18b9da8c934 质量完整达标,建议批准。

English verdict: APPROVE on exact head bcd4279: forwards execution_preparation.lease_proof to refresh-state as required by hard_lease enforcement without altering production checks or loosening negative assertions (221/221 tests in tests/control_plane/test_quota_settlement_cli.py PASS, ruff/mypy/loopx check PASS, canary premerge 3/3 selected smokes PASS with 0 failures).

@loopx-agent
loopx-agent merged commit d28ec76 into main Nov 21, 2026
4 of 6 checks passed
@loopx-agent
loopx-agent deleted the codex/fix-visible-goal-hard-lease-test-20261121 branch November 21, 2026 15:41
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