migrate-apim: partialWhen conditions are declared in the schema and implemented in the planner, and nothing checks the two agree
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 57/100
Hướng nghiên cứu
Start with plan._apply_partial_when() and the rule checks in compile; trace how partialWhen keys are loaded and validated, then inspect schemas/rules.schema.json and the existing tests for expression conditions. Add coverage showing that an unimplemented condition key is rejected during strict compilation. Done means the schema and planner condition names have one checked source of truth and the reported ip-filter rule can no longer compile silently with an inert condition.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
partialWhen is the one part of the rules vocabulary with two independent declarations and no join between them:
schemas/rules.schema.jsondecides which condition keys are legal. Onmainit is"partialWhen": {"type": "object"}— every key is legal.plan._apply_partial_when()decides which condition keys do anything. It reads exactly one,attributeIsExpression.
Nothing checks that the two agree. A rule author who writes a condition the planner does not implement gets a rule that passes every gate and never fires — so an element the rule exists to demote keeps the stronger verdict.
This is the defect class compile was built for. Its own module docstring says the rules "carried eight entries no selection site could ever choose", and dispatch.py exists so that selection criteria are "declared once so it can be checked", because "a second declaration drifts from the first, which is how the problem started". match keys and rule fields are covered by Selector.keys / Selector.reads. partialWhen's contents are not: capability._POLICY_FIELDS lists partialWhen as a field that gets read, which satisfies the checker, and the condition names inside it are never examined by anything.
Impact
The rules that carry partialWhen are the ones that stop a lossy mapping reading as a clean one, so an inert condition fails in the direction the project's governing rule forbids — a failed inference reading as a confident negative.
Concretely, on main the only partialWhen in the file is what keeps an llm-token-limit with an expression counter-key from being reported as a native mapping. Rename its key and the demotion silently stops; the token limit reports native while APIM is partitioning by arbitrary C# the target cannot evaluate.
Reproduction
Offline, against ea30225, no Azure and no network. ip-filter is a native rule with no partialWhen; this adds the condition an author would reach for first.
# capabilities/rules.json, on the ip-filter rule
"partialWhen": {"hasExpression": true},
"partial": {"itemKind": "accept-loss", "options": ["accept", "retain-in-apim"],
"proposal": "retain-in-apim", "rationale": "Expression-driven filter."}
Every gate passes:
jsonschema.validate(rules, schema) -> rules.json VALIDATES
python -m migrate_apim compile --strict -> 0 error(s), 0 warning(s), exit 0
python -m pytest -q -> 553 passed, 1 skipped
And the rule is inert:
rule = CapabilityMap.load().policy_rule("ip-filter", family="access")
el = {"path": "inbound/ip-filter[1]", "expressionIds": ["e1"], "attributes": {"action": "allow"}}
_apply_partial_when(rule, el)["verdict"]
# 'native' -- the rule author wrote partial
What the test suite does and does not cover
Worth separating, because the suite is not silent here:
- Renaming
attributeIsExpressionto something unimplemented is caught —test_a_native_policy_is_not_demoted_by_an_expressionandtest_an_element_rule_wins_over_the_expression_fallbackboth fail, because they pin the behaviour of the one condition that exists. - Adding a condition that is never implemented is not caught, and cannot be: there is no behaviour to pin, so no existing test fails and the author's own new test is the only thing standing between an inert rule and
main.
The second is the live risk, because adding conditions is how partialWhen grows.
Suggested fix
Give the conditions one owner, the way Selector already does for match keys and rule fields:
plan._apply_partial_when()declares the condition names it implements, next to the code that implements them.compilechecks everypartialWhenkey inrules.jsonagainst that set and errors on one nothing implements — decidable offline from committed data, which is whatcompileis for.- The schema's key list then follows from the declaration rather than being a second hand-maintained copy of it.
Narrowing the schema alone is not sufficient. #59 closed it to additionalProperties: false with the three keys named, and the forward direction still passes: adding a key to the schema and a rule, and forgetting the planner, compiles clean.
Context
Found while reviewing the fix for #59, which adds two conditions (hasExpression, underConditional) to this vocabulary — tripling the number of places the two declarations can disagree. The defect itself is on main today and independent of that change.
- Ngôn ngữ chính
- Python
- Star
- 18
- Fork
- 9
- Merge trung bình
- 1 ngày 16 giờ
- Pull request đã merge (30 ngày)
- 23
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của Azure/aigateway
-
How do I use the AI Gateway to route to ADO Remote MCP Server?Có thể đã có người làm @santiagxf đã nhận hôm nay. Đang mởquestion
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 48/100
Azure/aigateway#72 · 2 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Playground testing to external claude enterprise fails from AI GatewayCó thể đã có người làm @santiagxf đã nhận hôm nay. Đang mởinvestigate
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 53/100
Azure/aigateway#71 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 62/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
Azure/aigateway#5 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của Azure/aigateway
Issue tương tự
-
roadmap/v1.3.0 scope/entitlement type/improvement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
databrickslabs/ontos#1778 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
bug good first issue help wanted up-for-grabs
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
ClickHouse/loom#2075 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug]: pip install -U cudaq-qec fails with a conflict that names cudaq-qec itselfCó thể đã có người làm @fedonman đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 69/100
StevenBlack/hosts#3314 ·
-
task
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
SparseLinearAlgebra/spla#316 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày