migrate-apim: a policy element no rule answers for is dropped with no trace, and the ones with no expression in them vanish completely

オープン
#65 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

  • #66 @santiagxf による — マージされずにクローズ
  • #67 @santiagxf による — マージされずにクローズ

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
25/100
issue の種類
機能追加
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
azure, python
領域
backend, devtools

調査の方向性

Start with plan._policies(), capability.policy_rule(), policy.FAMILIES, and rules.json; the issue reproduces the missing matches offline and outlines the expected behavior. Inspect the related open pull request #66 and the existing compile checks before choosing work. Done means unknown policy elements are represented in plan coverage and compilation reports any elements left to the terminal gap rule.

索引モデルが issue の本文から書いたものです。

説明

bug

Summary

plan._policies() drops any element capability.policy_rule() does not answer for:

rule = self.caps.policy_rule(element["name"], family=..., has_expression=...)
if not rule or rule["verdict"] in {"notApplicable", "handled"}:
    continue

policy_rule runs three passes — element name, then family, then the hasExpression fallback — and returns None when none of them matches. The element is then read, classified, and discarded with nothing recorded anywhere. No item, no gap, no count.

Ten of the 62 elements in policy.FAMILIES resolve to None today:

Element Family What it does
authentication-basic backendAuthentication backend credentials
authentication-certificate backendAuthentication backend credentials
get-authorization-context backendAuthentication backend credentials
check-header authentication gates callers
validate-client-certificate authentication gates callers
emit-metric observability
log-to-eventhub observability
mcp-server mcp
validate-mcp-request mcp
set-service-url routing

Plus every policy APIM ships from here on, since a new element matches no rule by definition.

The selection order makes it worse than it reads

The third pass matches on hasExpression, so an element carrying a policy expression lands on the gap rule and is reported. What disappears completely is the subset with no expression in it:

caps = CapabilityMap.load()
[e for e, f in FAMILIES.items() if caps.policy_rule(e, family=f, has_expression=False) is None]
# 10 elements

[e for e, f in FAMILIES.items() if caps.policy_rule(e, family=f, has_expression=True) is None]
# 0 -- the same elements are answered once an expression is present

So the simpler the policy, the more certainly it vanishes. A literal <authentication-basic username="svc" password="{{secret}}"/> leaves no trace; the same element with an expression in it is reported as a gap.

Impact

This is the project's governing rule failing in the direction it exists to prevent: a failed inference reading as a confident negative. A plan that never saw a policy and a plan that saw it and discarded it are the same document, so "nothing else to migrate" is indistinguishable from "three backend credential policies were dropped on the floor".

collect has already settled the same question one stage earlier — collection.coverage records notCollected precisely because "it is not evidence that nothing is there" (schemas/inventory.schema.json). The inventory holds these elements. The plan is where they disappear.

Relationship to the existing rule-selection work

Worth stating, because it looks adjacent and is not. dispatch.py and compile solve the inverse direction — a rule no selection site can ever choose, which is what dispatch.py's docstring enumerates and what #53 dropped thirteen of. Nothing in that work looks at the other side of the match: an element no rule answers for. Selector.governs can tell you a rule is reachable; it cannot tell you the element vocabulary is covered.

It is also distinct from plan._note_unmapped, which reports source attributes with no target field on an element that did map.

Suggested fix

Three places, because no one of them is sufficient:

  1. A terminal rule in rules.json matching anything, tried after the expression pass, so None becomes unreachable at runtime. What reaches it is a blocking gap — the alternative is migrating past a policy nobody has read. Keeping it as data rather than a default in the planner keeps what an unknown element costs editable.
  2. A compile check, so the net does not quietly become the mapping: hold every element in policy.FAMILIES to a rule of its own or a family rule, and fail naming any left to the terminal rule. FAMILIES is committed data, so this is decidable offline, which is what compile is for.
  3. A coverage tally on the plan, counting every element walked under exactly one disposition with the unrecognised ones named and located. Three of the dispositions raise no item, and while they were uncounted the plan could not be checked against the inventory.

The ten above are answerable by five family rules and one element rule rather than ten entries, so the next member of each family is answered before it is written.


Found while reviewing the fixes for #58/#59/#60. Reproduced offline against ea30225; no Azure or network needed.

主要言語
Python
スター
18
フォーク
9
平均マージ
1日 9時間
マージ済み PR(30日)
22

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Azure/aigateway のほかの issue

Azure/aigateway の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。