Skip to content

test(project-lifecycle): align settlement readback fixture - #4859

Merged
huangruiteng merged 1 commit into
loopx-project:mainfrom
Duang777:codex/repair-project-lifecycle-settlement-progress
Sep 22, 2026
Merged

huangruiteng merged 1 commit into
loopx-project:mainfrom
Duang777:codex/repair-project-lifecycle-settlement-progress

Conversation

@Duang777

Copy link
Copy Markdown
Contributor

Summary

  • add the required settlement identity and progress fields to the project lifecycle test readback
  • keep the fixture on the settled path so the test remains scoped to post-writeback hook replay

Validation

  • uvx --from pytest pytest -q tests/cli_commands/test_project_lifecycle_goal_channel.py
  • uvx --from ruff==0.15.22 ruff check tests/cli_commands/test_project_lifecycle_goal_channel.py
  • uv run loopx canary premerge --from-git-diff
  • git diff --check

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

Copy link
Copy Markdown
Contributor Author

Exact-head CI triage for ef440fdd70284184583d94840199fe434aff487c: the completed failures are outside this fixture-only diff.

No #4859 code change is indicated by either failure.

@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:ef440fdd70284184583d94840199fe434aff487c

动机

这项修改修复的是一个真实且已经阻塞其他 PR 的测试夹具漂移。生产 QuotaSettlementReadback 已包含 identityprogresshandle_project_lifecycle_command 在绑定 Todo/turn 的 refresh-state 路径会调用 attach_settlement_progress;旧夹具却只提供 delivery.failure,导致测试在进入它真正要验证的 post-writeback hook 重放之前就因缺少 progress 崩溃。

我在当前 main 上复现了这一点:同一测试文件为 1 failed / 8 passed,失败点正是 readback.progress。在本 PR head 上则为 9/9 通过。这里最小且正确的修复就是把既有 mock 补到当前生产读回合同,而不是给生产代码加一个容忍畸形测试对象的 fallback。

改动思路

PR 没有改变 settlement、hook 或 CLI 的任何生产决策,只把目标测试中的 SimpleNamespace 补成已结算读回:identity.value=None,以及 quota_settlement_progress_v0 / settled / next_step=None / heartbeat。这样第一次调用仍生成 sidecar intent,第二次调用仍从 durable sidecar 重放,原有 calls == 1intent_count == 1replayed_hooks == ['fixture.stage'] 和零外部写断言都能真正执行。

这也保持了正确的所有权:TypeScript settlement readback 与 Python attach_settlement_progress 仍是合同 owner;测试夹具只负责忠实提供该合同,不复制新的结算规则。

具体改动

关键代码讲解

  • tests/cli_commands/test_project_lifecycle_goal_channel.pytest_refresh_state_dispatches_and_replays_post_writeback_sidecar:给 monkeypatch 的 read_heartbeat_settlement 返回值增加 identity 和 typed progress。这是唯一改动,+8/-1,没有生产代码、持久化格式或公开接口变化。
  • progress.state='settled' 很关键:它让测试继续走既有 post-writeback replay 语义,而不是通过构造 pending/failed 状态绕开被测路径。

对主干的风险

风险很低且局限在测试准确性。最强反例是“仅补属性让测试不崩,但没有真正验证重放”;现有后置断言仍覆盖 producer 只调用一次、第二次识别 replay、没有外部写,因此该反例被挡住。

验证结果:

  • 当前 main 对照:目标文件 1 failed / 8 passed,稳定复现缺少 progress
  • PR head:目标文件 9 passed;
  • Ruff、git diff --check、Python compile 与 risk-based premerge gate 均通过;
  • premerge 无 manual hold;当前 main merge-tree 无冲突。

该 PR 不声称证明真实持久化后端;那属于既有 settlement integration 覆盖。就这个 fixture-only 边界而言,没有未解决 blocker。

我的整体评价

这是完整、可回滚、必要的最小修复:它恢复已有 durable regression test 的可达性,同时不把测试兼容逻辑泄漏进生产路径。未来向前看也不需要抽取新的 fixture 框架;单一场景的 typed settled literal 比额外抽象更易读。

结论:APPROVE。此批准只绑定上述 exact head,不授予合并权限。

English verdict: APPROVE - head ef440fd faithfully updates one stale settlement readback fixture; current main reproduces the missing-progress failure, while the reviewed head passes 9 tests, Ruff, diff hygiene, and the risk-based premerge gate.

@huangruiteng
huangruiteng merged commit baf29a9 into loopx-project:main Sep 22, 2026
18 of 22 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.

2 participants