test(semantics): ratchet inventory after deduplication - #4806
Conversation
2f7bfe8 to
6eed328
Compare
huangruiteng
left a comment
There was a problem hiding this comment.
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
Exact head: 6eed3282147031b0ad6ad4c0a7aa4c1938554ade
动机
这是一组针对当前主干 CI 回归的最小维护修复。主干上的 quota conflict fixture 已落后于 _apply_requested_quota_action_selection_preflight 的 receipt identity 签名,导致四个用例在进入原本的冲突断言前就以 TypeError 失败;与此同时,最近的语义去重已把实际 inventory 降到 17/39/10,但代码与 registry 的预算仍是 18/41/11,因此 mutation test 可以额外加入一个同 runtime fork 而不触发 ratchet。
本 PR 的完整交付目标已经达到:让既有回归用例重新测试真实语义,并把语义 inventory 预算收紧到当前观测值,不改变产品 runtime 行为。
改动思路
改动沿用现有权威边界,没有新建第二套规则:quota 用例在两个直接调用点显式传入 receipt_pending_action_todo_id=None 与 receipt_identity_upgraded=False,准确表达原场景“没有 pending receipt action、没有 identity upgrade”;语义侧同步降低 smoke 中的 BUDGET_ANCHOR 和 registry 中的 inventory_ratchets,继续维持两处必须一致、预算只降不升的既有约束。
render_inventory as render_inventory 是有意的显式 re-export。该符号虽然不在文件内静态调用,但 tests/architecture/test_semantic_inventory_exceptions.py 通过 runpy 使用它;保留 re-export 既满足 Ruff,也保持动态消费者兼容。
正向路径上,quota fixture 现在会进入真正的 typed conflict 分支;semantic smoke 会从完整 tracked tree 计算 inventory,并验证实际值与预算都是 17/39/10。负向反证也成立:在基线 04ba65ac1a37c94d964adeedf3ff1f125c5ffe12 上,四个 quota 用例复现缺参 TypeError,两个 semantic mutation 用例复现 “DID NOT RAISE”;exact head 则消除这两类失败,并会对下一个新增 fork fail closed。
具体改动
tests/control_plane/test_quota_action_selection_conflict.py:两个直接调用点补齐四个中性 receipt identity 参数,测试范围和原断言不变。examples/semantic-vocabulary-drift-smoke.py:三项BUDGET_ANCHOR从18/41/11收紧为17/39/10,并显式 re-exportrender_inventory。loopx/semantics/vocabulary_v0.json:同三项inventory_ratchets同步收紧,继续与代码 anchor 成对约束。
关键代码讲解
_raise(quota conflict fixture)现在把现有生产签名所需的 receipt identity 输入显式设为None/False。它不会制造新的 authority,只让测试重新抵达原本要验证的 conflict precedence。BUDGET_ANCHOR是代码侧独立预算锚点。把它精确设为当前 inventory,意味着下一项重复语义不能再消耗历史松量。inventory_ratchets是 registry 侧公共证据合同。它与 smoke anchor 同步变化,避免仅改单侧来隐藏失败。
对主干的风险
主要风险是预算过度收紧造成误报,或误删动态 re-export 造成 architecture test 回归。两者都已覆盖:真实 smoke 在 exact head 输出 17/17、39/39、10/10;affected suite 共 164 passed,包含 test_semantic_inventory_exceptions.py 的 runpy 消费路径。基线/head 反证证明这不是为了“刷绿”而放宽 mutation,而是恢复原有 fail-closed 约束。
验证结果:Ruff、py_compile、git diff --check 均通过;risk-based canary 选择 6 项,0 failure、0 manual hold,public boundary 通过;exact-head GitHub required checks 全绿,包括 merge-gate、四个 test shard、kernel/static、Windows、Dashboard、Stage2C、wheel/sdist 安装验证与 DCO。presentation 与 release publication 是本 PR 类型下的预期 skip,不属于缺失覆盖。
没有发现 actionable code finding。剩余风险只有流程边界:本 PR 修改公共 semantic evidence budget,即使属于维护修复,也按仓库规则交由 maintainer 合并;这不影响代码层面的 APPROVE 结论。
语义与 CI 对齐
本 PR 复用既有 inventory_ratchets 词汇与所有权,没有创建新语义。预算变化由同一 tracked-tree workload 的 base/head 计数、mutation 反证和 exact-head CI 共同支持;没有改变 scan root、比较 workload 或冻结的产品阈值。
我的整体评价
APPROVE。改动范围小而完整,直接修复两个已复现的主干验证缺口;实现复用现有 typed signature 与 paired ratchet owner,没有新增 runtime 分支、持久化状态、CLI 或迁移成本。未来导向的重构检查也没有发现应在本 PR 顺带抽取的新边界:继续把 receipt 语义留在生产 preflight、把 inventory policy 留在现有 smoke/registry,是更清晰且可逆的所有权安排。
English verdict: APPROVE - exact head 6eed328 restores quota-fixture reachability and exact semantic-inventory ratchets; 164 affected tests, the real 17/17-39/39-10/10 smoke, canary, and all required CI checks passed with no actionable findings. Maintainer merge is required because the PR changes a public evidence budget.
6eed328 to
09cd638
Compare
Signed-off-by: huangruiteng <14976749+huangruiteng@users.noreply.github.com>
09cd638 to
91648be
Compare
Summary
17/39/10render_inventoryconsumer through an explicit re-exportThe earlier quota-fixture repair is now present on
main, so the rebased branch deliberately drops that duplicate commit. This PR now contains only the remaining semantic CI repair that blocks exact-head validation of #4768.Validation
17/17,39/39, and10/10One local validation invocation incorrectly passed the JSON registry to Ruff and produced the expected Python-parser
nullerrors; the corrected Ruff scope passed. This was a command-scope error, not a code failure.Merge boundary
Although the diff is maintenance-only, it changes the public semantic-inventory evidence budget. Per repository policy it is reviewed on the exact head and left for a maintainer to merge.