fix(quota): unify scoped gate fallback under typed dependency rules - #4253
Conversation
huangruiteng
left a comment
There was a problem hiding this comment.
Request changes conclusion (author-owned PR; GitHub blocks formal self-review)
复审绑定 exact head:1ff5ede19e7fe283aadeb40d73ddbfc0c7f143cc。结论:REQUEST_CHANGES。
动机
这个 PR 修的是一个重要的 authority 缺陷:旧 fallback 会根据 action_kind 的英文 token 是否重叠来猜两个 Todo 是否独立。不同语言、同义词或宽泛标签都会让这种猜测产生 false positive/negative,而“看起来不相关”不能成为绕过 user gate 的机器证据。
改成 exact dependency、decision_scope 与 global_gate 等结构化关系优先是正确方向;equal legacy action key 可以继续作为保守 blocker,但不同或缺失 label 在没有结构证据时应该 fail closed。这个 breaking behavior 也已经在 PR body 中披露。
改动思路
decision_scope.ts 现在拥有 relation 与 fallback selection,agent_scope.py 不再维护 prose overlap authority,只把 legacy Todo facts 交给 typed owner 并解码结果。selection 仍只在 already-eligible Todos 中选择,不会创建权限、改写 gate 或 author dependency。
问题在于这次规则迁移没有覆盖仓库中已有的 durable behavior scenarios。新 helper tests 证明新规则本身,但原来的真实 quota/tool fixture 只有不同的 action_kind,没有 unblocks_todo_id 或非覆盖的 decision_scope,却仍断言 successor 会执行。按新语义它现在必然 hold,所以必须逐条决定这些场景究竟是“真实独立、补结构关系”,还是“关系未知、把 oracle 改成 hold”。
具体改动
真实 base fa57253a7888a33eb98b3b6d49d69726f54e5034 到 head 为 12 个文件、+369/-108。核心是 decision_scope.ts 的 typed selection、缩薄后的 Python adapter、focused tests 和 breaking-change disclosure。
我在 exact head 上运行了 21 个 focused Python tests 与 6 个 focused TypeScript tests,共 27 passed。exact base/head 对照运行 test_gate_notice_plus_executed_successor_proves_non_blocking_semantics:base 通过,head 以 qualification_passed=false 失败。该 fixture 的 gate 是 approve_product_first_screen,successor 是 quality_hardening,但二者没有结构 dependency/scope;这正是新规则不再允许仅凭文案判定独立的兼容迁移点。
此外,base mypy 有 7 个既有错误,head 有 8 个;新增的是 loopx/control_plane/todos/decision_scope.py:240 的 no-any-return:声明返回 dict[str, Any] | None 的函数直接返回 _evaluate() 的 Any。因此这不是可以归到 baseline 的静态错误。
对主干的风险
-
[P1] durable scoped-gate scenarios 尚未迁移。 当前四个 required Python shards、aggregate 和 merge gate 都是红的。请逐个分类失败场景:如果 successor 确实独立,就补明确的
unblocks_todo_id或非覆盖decision_scope并保留 execute oracle;如果关系未知,就把场景改成期望 hold。不要为了让旧测试变绿而恢复 label/token heuristic。 -
[P1] 新 adapter 引入 mypy regression。
decision_scope.py:240需要在返回前把 effect runtime 的结果收窄为 mapping/None,或复用现有 typed decoder;不能把Any直接从 typed API 漏出去。
Future-facing pass:typed decision_scope 是正确且足够的 owner。后续重点应该是让 Todo authoring/fixtures 能明确地产生结构关系,并保留一对真实 public-entrypoint regression:显式独立必须 execute,关系未知即使文案不同也必须 hold。
我的整体评价
我支持删除 lexical authority,也认可 conservative hold 的新默认;但 breaking migration 必须把现有行为组合和静态契约一起收敛。当前 focused helper tests 不能覆盖全部真实 caller,required matrix 的系统性失败说明 exact head 尚未达到可合并状态。
English verdict: REQUEST_CHANGES on exact head 1ff5ede19e7fe283aadeb40d73ddbfc0c7f143cc. Moving gate fallback to typed structural relations is the right authority model, and 27 focused tests pass. But the exact head leaves durable quota/tool scenarios on legacy label-only facts, causing all four required test shards and the merge gate to fail, and it adds a new mypy no-any-return error at decision_scope.py:240. Migrate each real scenario to explicit structural independence or an intentional hold oracle, narrow the adapter result, and rerun the full required matrix.
Signed-off-by: huangruiteng <huangrt01@163.com>
Signed-off-by: huangruiteng <huangrt01@163.com>
Signed-off-by: huangruiteng <huangrt01@163.com>
1ff5ede to
48e5a81
Compare
Review follow-up — both P1 findings addressedReviewed head:
No remaining actionable blocker found in this review. The motivation and placement remain sound: dependency authority cannot be inferred from prose, and the existing typed decision-scope owner is sufficient. Python handles source facts and presentation, not a second selector. The future-facing pass was applied through deletion/reuse rather than adding a framework. Unknown legacy relations intentionally become conservative holds; this compatibility change remains documented in the protocol, bilingual RFCs and PR body. It grants no permission, changes no default provider and does not promote an active Goal. Exact-head evidence
The historical private snapshot rehearsal in the body is explicitly identified as prior-revision evidence, not an exact-head rerun or private PostgreSQL three-arm claim. No live automation soak or paid-model qualification was run. This bounded read-policy refinement is covered by public production-entrypoint tests, complete TS tests and isolated real backend checks; it does not alter provider transactions or migrations. Premerge executed 18/18 catalog, risk and boundary checks plus 4/4 direct checks successfully, including the previously failing hot-path budget check. The initial overall gate rejected a stale receipt when an unrelated dashboard PR advanced main during execution. The PR diff was checked byte-identical against the updated base and re-reviewed; the receipt was refreshed rather than rerunning unchanged tests. This is not a claim that the initial overall gate passed. Final receipt verification returned |
…rotation fixture The showcase fixture gave its Gate and agent Todos no structural scope, so the typed fallback owner could only compare legacy action_kind labels. Since #4253, distinct labels no longer prove independence and a missing scope is projection_repair_required, so the fixture stopped exercising the scoped user-gate safe bypass it documents. Give the Todos stable todo_ids and let the Gate target the ALE lane explicitly, then assert the same fixture stays unproven when that link is removed so the rule cannot be relaxed back to label matching. Signed-off-by: huangruiteng <14976749+huangruiteng@users.noreply.github.com>
…rotation fixture (#4491) The showcase fixture gave its Gate and agent Todos no structural scope, so the typed fallback owner could only compare legacy action_kind labels. Since #4253, distinct labels no longer prove independence and a missing scope is projection_repair_required, so the fixture stopped exercising the scoped user-gate safe bypass it documents. Give the Todos stable todo_ids and let the Gate target the ALE lane explicitly, then assert the same fixture stays unproven when that link is removed so the rule cannot be relaxed back to label matching. Signed-off-by: huangruiteng <14976749+huangruiteng@users.noreply.github.com> Co-authored-by: huangruiteng <14976749+huangruiteng@users.noreply.github.com>
Summary
Behavior and architecture
This intentionally changes legacy heuristic-only fallback: an unscoped gate can now withhold work previously offered on the basis of different words. It does not remove, retarget or expand a User gate, grant permission, promote a provider, or change notification policy. Explicitly independent work still proceeds; unknown relations fail closed even when labels differ.
The existing typed decision-scope owner is sufficient. The future-facing pass removes duplicate business knowledge and reuses the established decoder; no new module, provider or recovery framework. Prose tokenization used for unrelated lesson warnings remains outside gate authority. This closes one T3 consumer, not all T3, T1/T2 or D1–D3 qualification.
Review refinement and validation
Tested head:
48e5a8168abab5cd017a21de37870d47cd8ba673. Rebased after #4252; all source edits below were validated before the final signed commit, with no later source edits.Run state: finished for the checks above. Current qualification inputs: synthetic and public fixtures. The earlier PR revision also used an authorized read-only snapshot: baseline/head compared ten lanes on legacy and File sources, finding one intentionally more conservative hold in each arm and nine unchanged. That historical rehearsal was not rerun for this refinement; it is not exact-head private three-arm parity. PostgreSQL evidence here is independent synthetic conformance. No active Goal was promoted or mutated, and no paid model qualification or live automation soak was performed.
Premerge executed all 18 catalog/risk/boundary checks and four direct checks successfully. Its initial overall result was rejected only because an unrelated dashboard merge advanced the base during execution and made the receipt stale. The PR diff is byte-identical against the new base; it was re-reviewed and requalified without repeating unchanged tests.
Refreshed exact-scope receipt:
cqr_8294625ee9761bb66446for 15 files. Fingerprint:8294625ee9761bb6644658d447b1a714733135ab69d3bdb75d2e7911b21cf337. One bounded safe-fix pass; zero unresolved quality blockers. Final readback and merge decision are recorded in the review response.Compatibility and boundary checklist
main; no unrelated main history is included.