Skip to content

test(semantics): ratchet inventory after deduplication - #4806

Merged
huangruiteng merged 1 commit into
mainfrom
codex/quota-selection-test-signature
Sep 20, 2026
Merged

huangruiteng merged 1 commit into
mainfrom
codex/quota-selection-test-signature

Conversation

@huangruiteng

@huangruiteng huangruiteng commented Sep 20, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • ratchet semantic-inventory budgets to the lower counts produced by the latest main-branch deduplication
  • keep the code anchor and public registry contract synchronized at 17/39/10
  • preserve the dynamic render_inventory consumer through an explicit re-export

The 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

  • 160 passed: semantic vocabulary drift and inventory exception suites
  • 4 passed: inherited quota conflict regression suite on the updated base
  • semantic-vocabulary-drift-smoke: passed with 17/17, 39/39, and 10/10
  • Ruff, py_compile, and git diff --check: passed
  • loopx canary premerge --from-git-diff: passed (3 selected, 0 failures, 0 manual holds; public boundary passed)

One local validation invocation incorrectly passed the JSON registry to Ruff and produced the expected Python-parser null errors; 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.

@huangruiteng huangruiteng changed the title test(quota): align conflict fixture receipt identity test(ci): restore quota and semantic regression guards Sep 20, 2026
@huangruiteng
huangruiteng force-pushed the codex/quota-selection-test-signature branch from 2f7bfe8 to 6eed328 Compare September 20, 2026 13:36

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

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=Nonereceipt_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_ANCHOR18/41/11 收紧为 17/39/10,并显式 re-export render_inventory
  • loopx/semantics/vocabulary_v0.json:同三项 inventory_ratchets 同步收紧,继续与代码 anchor 成对约束。

关键代码讲解

  1. _raise(quota conflict fixture)现在把现有生产签名所需的 receipt identity 输入显式设为 None/False。它不会制造新的 authority,只让测试重新抵达原本要验证的 conflict precedence。
  2. BUDGET_ANCHOR 是代码侧独立预算锚点。把它精确设为当前 inventory,意味着下一项重复语义不能再消耗历史松量。
  3. inventory_ratchets 是 registry 侧公共证据合同。它与 smoke anchor 同步变化,避免仅改单侧来隐藏失败。

对主干的风险

主要风险是预算过度收紧造成误报,或误删动态 re-export 造成 architecture test 回归。两者都已覆盖:真实 smoke 在 exact head 输出 17/1739/3910/10;affected suite 共 164 passed,包含 test_semantic_inventory_exceptions.pyrunpy 消费路径。基线/head 反证证明这不是为了“刷绿”而放宽 mutation,而是恢复原有 fail-closed 约束。

验证结果:Ruff、py_compilegit 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.

@huangruiteng
huangruiteng force-pushed the codex/quota-selection-test-signature branch from 6eed328 to 09cd638 Compare September 20, 2026 14:46
@huangruiteng huangruiteng changed the title test(ci): restore quota and semantic regression guards test(semantics): ratchet inventory after deduplication Sep 20, 2026
Signed-off-by: huangruiteng <14976749+huangruiteng@users.noreply.github.com>
@huangruiteng
huangruiteng force-pushed the codex/quota-selection-test-signature branch from 09cd638 to 91648be Compare September 20, 2026 14:49
@huangruiteng
huangruiteng merged commit 05cd018 into main Sep 20, 2026
20 checks passed
@huangruiteng
huangruiteng deleted the codex/quota-selection-test-signature branch September 20, 2026 15:05
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