Skip to content

refactor(migrate-apim): select APIM objects, resolve policy scope, decide from rules.json - #70

Merged
Facundo Santiago (santiagxf) merged 54 commits into
mainfrom
fix/apim-api-coverage
Dec 2, 2026
Merged

Facundo Santiago (santiagxf) merged 54 commits into
mainfrom
fix/apim-api-coverage

Conversation

@santiagxf

@santiagxf Facundo Santiago (santiagxf) commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Supersedes #66, #67 and #69, squashed in.

What this does

Improves capabilities/rules.json to cover all the objects in APIM. Every rule names the APIM object it is about, and compile --strict holds each one to inventory.schema.json.

{ "selects": "apim.apis[]",                "where": { "type": "mcp", "pattern": "passthrough" } }
{ "selects": "apim.policies[].elements[]", "where": { "name": ["ip-filter"] } }

Also in this branch

  • Policy scope is resolved by what governs an element, not the document it sits in — extracting a policy into a fragment no longer changes the answer.
  • Every API is accounted for. apim.apis[] carries each API with either the asset it became or why it became none. A superseded revision used to be dropped in silence.
  • Apply reconciles an object already in the gateway instead of creating it again, and carries the prerequisites it cannot perform itself.
  • Both MCP patterns APIM serves. Passthrough registers as an mcp endpoint on its upstream; tool projection as an openApi endpoint built from the source API's exported contract. The export needed two fixes: ARM honours export=true only when the request does not ask for application/json, and the link is read at the valuePath the recipe records.
  • Lab 17 provisions both kinds of MCP server and teaches the migration as it now runs.

Verification

  • 1043 tests pass, 1 skipped; migrate-apim compile --strict exits 0
  • Run end to end against a live APIM: both MCP servers register, tools/list through the gateway returns the projected tools, and a chat completion through the migrated alias returns a real completion

🤖 Generated with Claude Code

`excludedApis` is the list that proves no API was lost: every API the collector
saw and did not inventory, with the reason. A non-current revision never reached
it. It left at a bare `continue` at the top of the API loop -- no entry, no
coverage record, nothing -- which made it the one thing this collector dropped
in silence, in a file whose whole premise is that nothing is.

The consequence is small and exactly the kind this list exists to prevent: an
operator auditing what moved cannot tell a revision that was considered and set
aside from one that was never seen.

It is now an `excludedApis` entry with `reason: "notCurrentRevision"`, and the
fixture carries a superseded `aoai-api;rev=1` so the path is exercised rather
than asserted. A second test pins the other half -- recording it must not
promote it, because callers do not reach it.

No plan item changes.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
It took a union of four lists: three asset families, plus `excludedApis`, with
model providers in a fifth that has no API behind it at all. APIM answers that
question in one call, and an inventory that cannot makes every caller
reassemble it -- each the same way, each able to forget a list. `summary.py`
reported "N APIs excluded as non-AI" without the denominator for exactly this
reason: the total was not anywhere to read.

`apim.apis[]` is every API on the service, inventoried or not, with two fields
that cannot be read off APIM: the asset it became, or why it became none.
Exactly one of the two is set, which is what makes an API the inventory holds
and says nothing about impossible rather than merely unlikely.

The fields come from `_api_source`, called rather than copied -- the same
function that builds each asset's `source` block. A second copy of an API's
fields with nothing joining them is a second description, and this codebase has
been bitten by every second description it has kept. A test pins that they
agree, so the join is checked rather than assumed.

Nothing moves. `shared.*`, `assets.*` and `excludedApis` are untouched, so no
rule's `selects` path and no selection site changes. This is an index over what
was already there, not a reshaping of it.

`summary` now reads "8 APIs on the service, 6 inventoried, 2 not" with the
reasons broken out, which is the question an operator was asking when they
reached for the excluded count.

No plan item changes.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Squashed from PRs #67 and #69, which were closed in a branch cleanup. #66 is
not folded in separately: three of its five commits are in this history
verbatim, and the other two are the narrow version of the fragment handling
that #67 then redid properly -- `test_a_fragment_the_global_policy_includes_is_governed_globally`
is that concern, generalised.

Two things, which were two PRs because the second rests on the first.

**A policy is judged by what it governs, not by where it is written.** Scope
resolution now follows fragments, inheritance and operations: an element knows
which scope's chain pulled it in, which is not the document it sits in. That
distinction is the whole point -- extracting a policy into a fragment used to
change the answer, so the same policy reported a different verdict depending on
how it had been factored. A fragment that cannot be read stays visible instead
of silently reading as absent, and a policy element can no longer be dropped for
want of a rule: the terminal rule makes "no rule" unreachable, and the elements
that used to vanish were the simple ones, since anything carrying an expression
at least fell into the pass above.

**A rule says which inventory objects it is about.** `selects` is a path into
the inventory with `[]` for "each of these", and `where` narrows on fields of
the object that path names, in three forms and no others: `key: value`,
`key: [a, b]`, `key: {"present": bool}`. Both halves are checked against
inventory.schema.json, so a rule matching on a field no record carries is an
error rather than a rule that never fires. It replaces a label like
`publishedSurface` that appeared nowhere in the inventory, with the binding from
key to field living inside the resolver where nothing could check it.

With that, the decisions the architecture already called data stop living in
plan.py: 55 rules where there were 27, and `_opt(` calls in the planner drop
from 44 to 12.

`compile` gains the checks that make those claims non-vacuous -- every `where`
predicate is one of the three forms, every policy element the collector
classifies is answered by a rule of its own or a family rule rather than falling
to the terminal one, every fragment disposition the planner can produce is named
by a rule, and every inventory path a site decides about is answered by at least
one rule.

Folded commits, in order:

  Stop an object the plan marked incomplete from failing mid-phase
  Stop a handled policy being excluded before anything reads it
  Make a policy element impossible to drop for want of a rule
  Answer "which policy governs this API" once
  Plan policy from what it governs, not from where it is written
  Say in the contract what the gateway does with a fragment
  Test the resolution where the logic is
  Make the documented contract the one the code keeps
  Drop an import the test no longer needs
  Say 'no proposal' rather than printing one that is None
  Report a skipped parent against the scope that actually said something
  Answer the routes a policy arrives by, not just the one
  Judge a policy by where it arrives, not where it is written
  Read an order where order decides, and an identity where identity does
  Keep an unreadable fragment visible, and a decision honest about its facts
  Pin the scenario the ordering fix was for, in the shape it was reported
  Say what a rule is about instead of implying it
  Move the decisions the architecture already said were data
  Check that the decisions stay in the file
  Let the rule say what the planner offers
  Say which tie it is, and check the whole path
  Declare the status the resolver writes
  Say where the object a rule judges actually lives
  Fold the computed predicates into the ones that read a field
  Say whether an answer is a pick or a form

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@santiagxf Facundo Santiago (santiagxf) changed the title fix(migrate-apim): account for every API the service has refactor(migrate-apim): make rules.json the contract, resolve policy scope, account for every API Nov 24, 2026
A rule says which objects it is about by naming a path, so the path is the
claim -- and half of them named a shape this tool invented rather than one the
service has. `shared.*` was a box with no counterpart in APIM. `workspaces[]`
and `policies[]` sat at the top level beside `assets`, as though a workspace and
this tool's reading of an API were the same kind of thing.

Two names were worse than misplaced, they were wrong:

* `credentialProviders` is APIM's `authorizationProviders`. We renamed a
  resource that exists, so a rule could not name it the way the portal, the ARM
  API and the operator all do.
* `telemetry` was a box holding `loggers` and `diagnostics`. APIM has the two;
  the box is ours, and a rule had to select the box to reach either.

Everything APIM has now lives under `apim`, under APIM's name for it, and a
rule's path is a path through the service's own object graph. 36 of 55 rules
select an APIM object, up from 34, and the remaining asset rules are the next
commit.

`foundryAccounts` moves out to the top level rather than in: it is a
Microsoft.CognitiveServices account, read to resolve what a Foundry backend
serves. Putting it under `apim` would make the one claim that region makes --
these are APIM's objects -- false.

`collection.coverage[]` stays where it is, and should. It is a record of what
this run managed to read, not a thing the service has.

No item id moves. The certificates and credential-provider items keep
`item:shared/certificates` and `item:shared/credentialProviders`: an id is what
carries an operator's decision across re-runs, so it answers to the decision and
not to the shape of the document underneath it. The loop that builds them now
carries the collection and the aspect separately to make that deliberate rather
than incidental.

Plan output is unchanged.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
A rule names the object it judges, so the name is the claim. Eighteen of them
named this tool's decomposition: `assets.mcpServers[]`, `assets.agents[]`,
`assets.models[].endpoints.surface`. APIM has none of those. It has APIs, and an
API carries a `type` saying `mcp` or `a2a` outright.

So the rules ask about APIs:

  assets.mcpServers[]                 ->  apim.apis[]  type: mcp, pattern: passthrough
  assets.agents[]                     ->  apim.apis[]  type: a2a
  assets.models[].endpoints.surface   ->  apim.apis[].endpoints.surface

`type` is APIM's own discriminator. `pattern` and `role` are this tool's reading
*of that API* -- `role` because an http-typed API can still be a model API and
APIM has no field that says so. Both are selectable and a reader can tell which
is which, which was the point of separating them rather than folding one into
the other.

`apim.apis[]` carries those blocks, copied from the asset by the one function
that already builds the API's APIM fields. One reading, rendered once, so there
is nothing to drift; the test that holds the `_api_source` fields to agreement
covers these the same way.

Three sites now name the same object and are told apart by what they narrow on:
the MCP registration site, the agent site and the alias-naming site are three
questions about one API. That is the shape the vocabulary should have had from
the start, and it surfaced a latent assumption in `saying`, the test helper that
rewrites "the rule this site reads": it found rules by `selects` alone, which
stopped identifying a site the moment two of them shared a path. It asks
`governs` now, which is what that phrase means.

53 of 55 rules select an APIM object. The two that do not say why in a `note`,
because they are not oversights:

* a model provider is an upstream model endpoint, which APIM reaches through a
  backend *or* through an API's serviceUrl -- no single APIM object is all of
  them, and selecting `apim.backends[]` would quietly drop the service-URL ones;
* `collection.coverage[]` is a record of what this run managed to read. A failed
  read is unknown rather than absent, and only this tool can say so.

Plan output is unchanged.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The docs still named `assets.models[].endpoints.surface` and `shared.*` as the
paths a rule takes, which stopped being true one commit ago. The selector
vocabulary is the thing this contract is for, so a doc describing the old one is
worse than no doc.

ARCHITECTURE.md now says the paths are APIM's object graph, names the three
`where` keys that pick which APIs a rule means, and records the two paths that
are deliberately not APIM's and why. README's output shape leads with the three
regions and what being in each one claims.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@santiagxf Facundo Santiago (santiagxf) changed the title refactor(migrate-apim): make rules.json the contract, resolve policy scope, account for every API refactor(migrate-apim): select APIM objects, resolve policy scope, decide from rules.json Nov 24, 2026
`apim.apis[].endpoints.surface` compiled clean, and should not have. APIM's API
resource has no `endpoints` property -- that is this tool's decomposition -- and
`surface` is a judgment about the *target*, computed by `summarize_surface`
against AI Gateway's four publishable routes. Eleven paths were like it: the
root was APIM's and everything after it was ours.

It passed because `check_paths_are_fields` asks inventory.schema.json, and the
schema is a file we write. I had widened it by hand to hold the blocks, so the
checker certified them. A path check against a hand-written declaration can only
ever confirm the declaration.

Three changes.

**The decomposition comes back off `apim.apis[]`.** `endpoints`, `models`,
`routing` and `toolDiscovery` were copied there to give the rules something to
point at, which is backwards -- it widened the object until the path looked
true. Their rules select `assets.*` again, where the path says whose reading it
is.

**The surface question moves to operations, which APIM does return.** An
unbounded surface is a wildcard operation, so the rule selects
`apim.apis[].operations[]` and narrows on `group: wildcard`; the partial one
narrows on `publishable: false`. `publishable` is null for a wildcard -- unknown,
not false, which is exactly why the two rules do not overlap. The item is still
one per API, so no id moves. `sessionAffinity` goes to
`apim.backends[].pool.sessionAffinity`, which really is APIM's.

**A check, so it cannot happen again.** `apim-path-is-apim` walks each segment
of an `apim.*` path and asks whether the object before it gets that field from
ARM -- asking `_api_source`, the one place an APIM API's fields are written
down, rather than a list kept in the checker. It catches the path that shipped,
and catches an invented block nobody has thought of yet the same way.

The rule it encodes is narrower than "no derived data on an APIM object", which
would be too strict to be useful: `apim.apis[]` narrowed on `pattern` is honest,
an APIM object and this tool's reading of it, and a reader can tell which is
which. What a reading may not be is a path *segment*, because the path is the
claim about whose object it is.

42 of 55 rules now select a path that is APIM's all the way down, 11 select this
tool's readings under a path that says so, and 2 say in a `note` why they are
neither.

Plan output is unchanged.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The selector section listed the paths as they were two commits ago, when half
of them had an APIM root and this tool's decomposition after it. It now
separates the two, and states the rule a path under `apim.` has to keep --
APIM's objects the whole way down, with a reading allowed as a `where` key and
never as a segment -- with the path that broke it as the example.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Listing every selection site beside the rules it governs turned up three
defects, none of which failed a test or a compile.

**`plan._mcp` governed the agent rule.** `governs` is a subset test, so a site
reading `(type, pattern)` claims a rule pinning only `type` unless it says which
literals it compares `type` against. It did not, so two sites claimed one rule.
Nothing picked the wrong rule at runtime -- the criteria still sorted them --
but `rule-field-unread` asked a site that never builds that item what fields it
reads, which is the one question that check exists to ask correctly.

**The surface site's vocabulary did not follow its keys.** When the surface
question moved onto operations, `keys` became `("group",)` and `values` still
said `status`. A `values` entry for a key the site does not read constrains
nothing, so it looked like a vocabulary while being dead weight, and any `group`
literal passed -- `group: "wildcrd"` compiled clean.

**`publishable` had no vocabulary at all**, for the same reason: it was added
with the key and never given one.

Two checks, because each defect generalises:

* `rule-one-site` -- a rule is governed by exactly one site. This is the shape
  of the first defect, and the fix for it is almost always a `values` entry on
  the wider site.
* a test that every `values` entry names a key its site actually reads. That is
  what let the stale `status` survive the move.

Plan output is unchanged; none of this changed which rule was selected.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
`assets.models[].models` was the clearest case of a path that is not an object
APIM has. Neither half is: `assets.models[]` is this tool's collection of
classified APIs, and `.models` is a catalogue resolved from
Microsoft.CognitiveServices deployments. The rules on it ask one question --
can we enumerate what this API serves -- and the subject of that question is an
API, which APIM does have. The catalogue is the evidence, not the subject.

Same for the others. "Does this API translate dialects" is about an API; the
dialect comparison is evidence. "Do we know this server's tools" is about an
API; the runtime fetch is evidence. Each was selecting its evidence.

They select the API now, and narrow on a scalar reading of it:

  assets.models[].models                 ->  apim.apis[]  catalogueFetched, discoverySource
  assets.models[].endpoints.translation  ->  apim.apis[]  translation
  assets.mcpServers[].toolDiscovery      ->  apim.apis[]  toolDiscovery, toolsFromGateway

This is the shape `type` and `pattern` already had, and I should have reached
for it two commits ago. When the derived blocks came off `apim.apis[]` I moved
those rules back to `assets.*` instead of adding scalars, which fixed the path
and left the subject wrong. A block as a path segment is a lie about whose
object it is; a scalar as a `where` key is a reading of an object that is
APIM's, and reads as one.

`rule-one-site` -- added two commits ago for a different reason -- caught the
collision this created: the alias rule pins `{role}`, which is a subset of
`{role, translation}`, so the dialect sites claimed it. `role` comes off those
rules, because it was never carrying anything: only a model API has a
translation status or a catalogue.

One substantive correction on the way. `catalogue` in those rules was a presence
test on the *fetched model list*, not `models.status`; I mapped it to the status
first and the meta-ai item changed verdict. It is `catalogueFetched`, a boolean,
which is what the presence test was asking and reads better as an equality.

52 of 55 rules now select an APIM object. The three that do not say why in a
`note`: an upstream reachable through a backend or a serviceUrl, a Foundry
deployment, and a record of what this run managed to read.

Plan output is unchanged.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
`service.networking.targetRequirement` was the same defect as
`apim.apis[].endpoints.surface` -- `networking` is synthesised from the service
resource and `targetRequirement` is a judgment about what the gateway would
need -- and it survived the pass that caught the other one for no better reason
than that its root is spelled `service` rather than `apim`.

The subject is the service, which APIM does have. The reading is whether the
target needs a delegated subnet, worked out from `virtualNetworkType` and
`publicNetworkAccess`, both of which ARM returns. So the rules select `service`
and narrow on `needsSubnet`, the same shape as every other reading now.

`_service_source` is split out of `_service` for the reason `_api_source`
already was: it is the one place the service's own fields are written down, so
`compile` can ask it what APIM returns instead of asking a schema we wrote.
`apim-path-is-apim` now covers any site whose root names an APIM object, not
only those spelled `apim.`, and the two paths that defect produced are pinned as
tests.

52 of 55 rules select an APIM object, and the three that do not each say why.
Every one of those 52 is now APIM's the whole way down.

Plan output is unchanged.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
`apim.policies[]` claimed every policy document and only ever saw fragments.
The narrowing lived in `graph.fragments()`, which filters `scope.level ==
"fragment"` -- so the rule named one thing, the code meant another, and the
comment beside the site said so outright: "a fragment is a policy document like
any other, which is why the path is `policies[]`".

APIM has a policyFragments resource. It is already collected, already carries
`name`, `elementCount`, `parseError` and a `policyId` pointing at its body, and
it is what these five rules are about. Selecting it removes the filter rather
than relocating it: there is nothing left to narrow, because the collection is
the fragments.

This is the shape the workspace rule had before #69 moved its condition into
the file -- a rule naming a collection it is only ever shown part of, with the
part chosen somewhere a reader of the rule cannot see.

The item id is unchanged: it was keyed on the document id, which is the
fragment's `policyId`.

The fixtures were inventing only half the shape. A fragment is two objects and
the collector emits both -- the resource the rules select and the document
holding its body -- so `policy_document` now registers the resource whenever it
makes a fragment-scoped document, and the one test that set `parseError` after
the fact re-syncs it. A fixture producing a shape no collection produces is a
test that passes for the wrong reason.

Plan output is unchanged.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
`rules.json` is the AI Gateway mapping, versioned with the capability catalog it
names in `targetCapabilities`. The test for a rule is whether it moves when the
target moves: "AI Gateway exposes no A2A building block" and "no caching on the
typed gateway" are claims about a release, and a release that changed them would
change the rule.

Applied to all 29 rules that name no capability, 28 pass. One does not. "A
failed control-plane read is unknown rather than absent, and unknown coverage
cannot be accepted as a loss" holds whatever AI Gateway ever ships. It is a fact
about the collection run and about what may be concluded from silence.

So it was the only rule in the file answering to nothing in the catalog it is
versioned against -- and, not coincidentally, the only one whose `selects` named
no APIM object. I spent a while defending that path as honestly named, and
longer arguing about which object a failed read should hang off. Both were the
wrong question: the path never fit because the rule was never a mapping.

It moves to `plan._structural`, where the gate already lived in all but its
wording. This adds a decision to code, which is against the direction of the two
commits that pulled 44 option vocabularies out of it -- but that work was about
mappings, and the test that justified it is the same one that sends this the
other way.

`test_capability` asserted the rule's `cannotAccept` and `blocking` fields. The
behaviour is already held in `test_plan.TestCoverageGapCannotBeAccepted`,
against the item -- blocking, cannot be accepted, offering no `accept` option --
which was always the stronger of the two tests. The weaker one goes.

54 rules, 14 paths, every one of them a mapping. ARCHITECTURE.md now says what
this file is and is not for, so the next rule like this lands somewhere else.

Plan output is unchanged.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
`supported_endpoints` iterated the capabilities map and asked only whether a
route's name was there. Foundry writes those values as the strings "true" and
"false", so `chatCompletion: "false"` -- a deployment stating it cannot serve
chat completions -- published the model on `/openai/v1/chat/completions`.

Found by migrating a live instance. `Microsoft-Decision-1` registered, read
back clean, and was reported as migrated. It can only fail at the upstream, on
the first call a caller makes, which is the worst place to learn it.

The obvious fix is the second bug: the values are strings, and `bool("false")`
is True, so the value has to be compared rather than tested. Both are pinned.

With that, a model can have no publishable route at all, which was never a
representable state. `publishable` is that reading, on the resolved record the
rules already select, and `rules.json` answers it: the existing native rule
narrows to `publishable: true`, and a new rule asks what to do about false --
accept the loss, or keep that model's callers on APIM.

`None` is in neither rule. A backend whose dialect could not be read has not
been shown to lack a route, and the dialect rules ask about that; collapsing
unknown into absent is the thing the coverage gate exists to stop. It keeps
the native default, so nothing that worked stops working.

Two halves of the same guarantee, because an empty endpoint list reaching
`model create` is not "no routes" -- the flag is simply omitted and the gateway
picks a default. The planner builds no object for an unpublishable model, and
the builder refuses one before it writes the deployment config.

The fixture carries both shapes now, a denied `chatCompletion` and a model
whose only capability the gateway has no route for, so the path is exercised
rather than asserted. The golden plan gains those two items and nothing else:
the resolution table is asserted unchanged as part of regenerating it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
`override` was offered on every alias-naming item and read by nothing. The
names came from the registrations whichever option was chosen, so an operator
who supplied their own got the proposals, no warning, and a plan that recorded
a decision the generator ignored.

`plannerGaps` cannot catch this one. It asks whether a settled item produced a
target object, and this produced them -- correct in shape, built from the
wrong names. The gap is between the decision and the object, which nothing was
comparing.

The two documents also disagreed about how to answer it. The rule said "set
them in this item's members"; SKILL.md says to set only `status` and
`decision`, and it is right -- `evidence.members` is rebuilt from the
registrations on every run, so an edit there is overwritten by the next `plan`,
which the skill tells the operator to do routinely. The rule now describes the
decision, in the shape `list-models` already uses.

A name is two things here and only one of them moves. `routingName` is what
clients send and is the operator's to choose; `backendModels[].modelName` is
the model registered under the proposal, so renaming what callers send must
not repoint the alias at a model nothing registered. Pinned, because the
obvious implementation gets it wrong.

Settling on `override` and naming nothing now carries `needsFact` rather than
quietly publishing the proposals, which is the answer the operator explicitly
did not choose.

The member digests move, so alias items settled before this are re-asked. That
is the honest outcome: they were answered when one of the two options did
nothing.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
"One reading, rendered once, so there is nothing to drift" was true of
collection and of nothing after it. `resolve-models` and `discover-tools` --
the two commands the skill requires an agent to run -- rewrite an asset in
place, and the readings on `apim.apis[]` are a copy taken when the asset was
collected.

So on a live migration, after both had run and reported success, the inventory
said `catalogueFetched: false` for a provider whose catalogue had just been
fetched, and `toolDiscovery: runtimeOnly` for a server whose two tools had
just been listed through the gateway.

Nothing selected on the stale values, because the planner reads the asset and
passes the reading in. That is what makes it worth fixing rather than worth
leaving: the point of moving these onto `apim.apis[]` was to give rules a
vocabulary to narrow on, and the vocabulary was wrong from the first runtime
command onward. The first rule to use it would have been wrong with it, with
no test failing.

`api_readings` is the one place they are computed, and `refresh_api_readings`
re-runs it over an inventory against the assets as they are now. Both commands
call it before they write.

The test that held these fields to their asset ran after collect, which is the
one moment they could not disagree. This one moves an asset first.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The collector records `notCollected` because "not collected" must never read
as "none exist". Nothing downstream carried it. The gate asked for `failed`
entries, SKILL.md told the agent to check for `failed` entries, and on a live
migration an agent that read the whole coverage array put `notCollected` in
its allow-list, concluded "coverage is clean", and moved on -- over 132 unread
operation policies across six APIs.

The inventory was honest the whole time. The plan is what an operator works
from and what drives apply, and it said nothing, so a token limit or a rate
limit sitting in one of those documents would migrate as though it were not
there.

It is not the same question as a failed read, so it is not the same item. A
failed read is unknown and unrecoverable without new access, which is why it
blocks and cannot be accepted. A skip is unknown and one flag away from being
read, so it does not block and "I know, and I am migrating without it" is an
answer -- made once, knowingly, instead of by nobody noticing.

One item per collection rather than per scope: six APIs with unread operation
policies are one question with a count, not six.

The option names the flag. An unknown an operator can resolve themselves is
worth more than one they are only told about.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
`prereq:appinsights-otlp` carried `"commands": []`. An empty list reads as
"nothing to run here", so the only prerequisite standing between a migration
and any telemetry at all looked like a portal trip.

It is an ARM property. Enabling it is a PATCH setting
`AzureMonitorWorkspaceIngestionMode`, which provisions the managed Azure
Monitor workspace, collection endpoint and rule, and fills in the three OTLP
endpoints. The second command reads back the one the telemetry item is settled
with.

What made it look otherwise is worth recording, because it is a mistake the
tool itself is built to avoid: the field is absent from a component that has
OTLP off, and reading that absence off your own freshly created resource says
the feature is unset, not that the API lacks it. `az monitor app-insights
component update` has no flag for it and the portal blade does not show it,
which makes the wrong conclusion easy to reach twice.

Without this, the honest move available to an agent was to settle telemetry on
`gateway-metrics-only` and move on -- a gateway that reports nowhere, chosen
because the endpoint could not be had rather than because nobody wanted it.
That happened on a live migration before the command was found.

SKILL.md already says to offer the prerequisites that are commands and to get
agreement first. This one just never looked like one.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
`cliVersion` is `cliEvidence.documentedVersion` -- a fact about the catalog
file. Printed alone it read as a fact about the machine: a plan built on a
host running extension b26 announced "against CLI 1.0.0b31", and the only
qualifier was a "(declared, not probed)" that most readers will take as
hedging rather than as "this number is not your CLI".

They are different questions and both are worth answering, so the installed
version is reported beside the documented one rather than folded into it. A
probe records it; without a probe it is null, which is the honest value for a
question nobody asked.

The reconciliation existed and nothing pointed at it. `--probe-cli` is opt-in,
`apply` never probes, and SKILL.md does not mention probing at all, so a
command the catalog declares and the installed extension lacks was discovered
when its step failed -- halfway through a phase, which is the one moment
preflight exists to prevent.

Preflight now says so, as a note rather than a block. On a real instance the
gap was one capability (`provider.import`) that no item used, so refusing to
proceed would be wrong far more often than it was right; being told, before
the first write, is the part that was missing.

Probing at preflight was the other option and is worse: it shells out once per
capability on every rehearsal, and the rehearsal is the thing an operator runs
repeatedly.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Four corrections to the prose, each one something a live migration got wrong
by following it.

**Coverage has two unknown statuses and the skill named one.** "Check
`collection.coverage` for `failed` entries" is what an agent did, over 132
unread operation policies, and then reported coverage clean. It now names
`notCollected` too, and says why a deliberate skip is still an unknown.

**`--acknowledge` had one rule for two different acts.** "Never acknowledge a
prerequisite" reads as a blanket prohibition, and the thing it is actually
against is acknowledging work you have not done. An agent that enabled an
endpoint itself and verified it was then told never to record that -- which
misreports finished work as outstanding. The rule is now about which of the
two you are doing.

**A decision can name alias names, and nothing said so.** Added to the shapes
beside `list-models`, now that the option is read.

**Reads leak credentials too.** The skill was careful about secrets as command
arguments and said nothing about secrets in output. `app-insights component
create` and a plain ARM GET both return a connection string carrying an
instrumentation key, and both put one in a transcript during the run. Project
the field, not the resource.

ARCHITECTURE gains what `publishableRoutes` is now used for a second time, and
README the third place a skipped read is recorded.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Caught by running the fixed planner over an inventory collected before it: the
plan came out exactly as it had, `Microsoft-Decision-1` ready to register on a
route its own capabilities deny, and nothing said why the fix had not applied.

`publishable` absent and `publishable: null` are different facts and the code
had one branch for both. Null is a backend whose dialect could not be read,
which the dialect rules already ask about, so it keeps the native default.
Absent is a record from a collector that never asked the question -- and those
records' `supportedEndpoints` were computed by reading capability keys and
ignoring their values, which is the defect itself. The record cannot say which
of its routes are real, so nothing in the planner can recover it.

It is a `plannerGap`, which is the channel for exactly this: SKILL.md already
tells the reader to re-collect when the inventory is older than the tool. One
per affected model, which in an old inventory is all of them, because in an
old inventory all of them are unverified. A single `collect` clears the lot.

A fix that silently does not apply to the inventories people already have is
most of a fix.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
`publishable` was a verdict about a model stored beside the model. The thing
that decides whether a registration is possible is the route itself --
`model create` takes it as `--supported-endpoints` -- so the rules now narrow
on `inferenceRoutes`, and a rule asking whether this model has one is asking
the same question the command does.

It was also the wrong name twice over. `publishable` already existed as a
`where` key, on `apim.apis[].operations[]`, meaning something related but not
the same; two objects answering to one key in a closed vocabulary is how a
rule ends up reading as though it were about the other one.

The three-way reading survives, and moves to where it belongs. A non-empty
list is native. An empty list is the claim -- the capabilities were read and
none maps to a route -- and is the blocking decision. Null is not a claim at
all, and `{"present": bool}` tests `bool(value)`, so a rule cannot tell it
from the empty list; asking the rules would answer "serves nothing" for a
backend whose dialect simply could not be read.

So null never reaches the rules. SKILL.md already puts an unreadable dialect
on this tool rather than on the operator, which makes it a `plannerGap`, and
`model create` requiring a route is exactly why: there is no registration to
make, not a loss to accept.

Verified against the live instance again after the reshape: of fourteen
resolved models, `Decision-1` alone comes back with no route and is the one
blocking decision, with no target object to register.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Found by migrating the same instance a second time, with the fixes in. The
planner correctly raised `Microsoft-Decision-1` as a model the gateway has no
route for, the operator accepted the loss, the registration built no object --
and the alias item went on proposing `Decision-1` as a callable name.

The aliases phase resolves each alias to a model id by reading the gateway, so
it would have looked for a model the models phase was never going to create.
An accepted loss would have failed as a broken step two phases later.

`_alias_naming` was handed every resolved model because, until the previous
commits, every resolved model was registered. That is no longer true, and the
question of which ones are is already answered on the record: a model with no
inference route has no registration to resolve to.

The filter is falsy for an empty list, for null, and for a record predating
the reading, which is right in all three -- a model in any of those states is
either an accepted loss or already blocked by a planner gap, and none of them
is a model an alias can point at.

The invariant is now a test rather than an observation: every alias in the
plan resolves to a model the same plan registers.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
A model provider's authentication was read from the backend entity alone, so
four of the ways APIM actually credentials an upstream went unseen.

- `authentication-managed-identity` in an API's policy rather than on the
  backend record, which is how a hand-built Foundry backend is wired. The
  provider reported `undetermined`, no identity item was raised and no role
  assignment planned, while the provider object still shipped
  `authentication.kind: ManagedIdentity`.
- An API key passed by `set-header`, verdicted "no request or response
  rewriting" and proposed for acceptance, while the provider got a null key
  under a hardcoded header name. Detection requires both a credential
  parameter name and a value that indirects to a stored secret, so a header
  like `x-mcp-caller` carrying a literal is not mistaken for one.
- `authentication-basic`, which contributed no mode at all, so the record
  claimed the upstream "appears to be called unauthenticated". It ranks above
  the modes that do have a target field: a backend carrying both does not
  migrate by registering the key and calling it done.
- Backends an API names only at runtime through `set-backend-service`. Such an
  API linked to no provider, so its own policy went unread. Both directions of
  that link now share one statement of which backends an API can reach.

Also: a publishable route is necessary and not sufficient, because a model
behind the API has to serve it. Left-behind operations carry `noTargetRoute`
or `noModelServes`, and an API where nothing survives both readings proposes
`retain-in-apim` rather than a `split` naming a half that does not exist.

The golden moves deliberately. It encoded the first defect: `aoai-west` was
registered as a Foundry provider with `ManagedIdentity` while excluded from the
identity item, with no role assignment planned on `aif-west` -- a plan that
deploys and fails on the first call.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
A backend reached with a client certificate, a basic credential or an APIM
credential-manager connection produced two contradictory statements: the policy
element raised a gap proposing `retain-in-apim`, while the provider item read
`native`, "registers directly", carrying an invented
`{"kind": "ApiKey", "headerName": "api-key", "value": null}`. `_custom_auth`
never looked at the auth mode, so the header name was a hardcoded default and
the key was absent. An operator could answer the gap item `retain-in-apim` and
still have the plan register the thing they had just decided to keep.

The decision now sits where the consequence is. `_custom_auth` returns nothing
for a mode the target cannot express, so the provider object carries no
authentication rather than a false one, and a new rule on
`assets.modelProviders[].auth` gives that provider the gap. The
`backendAuthentication` family rule becomes `handled`, cross-referenced to the
provider item the way `authentication-managed-identity` already is.

`handled` is a promise, and the element can reach a backend that is no model
provider at all -- an MCP server's upstream, a content-safety backend -- where
nothing would carry it. So the rule names its carrier and the planner checks
it, falling back to raising the element itself when the promise cannot be kept.
Carried means the provider item actually raised the gap, not merely that a
provider exists: a backend holding both a managed identity and a client
certificate registers with the identity, which wins the precedence, and would
otherwise have swallowed the certificate with nothing asking about it.

The golden moves by exactly six rows: those three elements, with and without an
expression, from `gap` to `handled`. No fixture provider carries one of the
three modes, so the plan is unchanged.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
… never read

Two more modes reached `_custom_auth` and left it as an invented api key under
verdict `native`.

`authorizationHeader` is a backend's `credentials.authorization`, which carries
a scheme. It was registered under the hardcoded `api-key` header name with the
scheme dropped -- wrong twice. The gateway would have to send `Bearer <secret>`,
and a secret reference is substituted verbatim wherever it appears, so nothing
can prepend the scheme without reading the secret, which this tool never does.
It gets its own rule proposing `compensate` rather than `retain-in-apim`,
because a correct shape exists: store the whole header value including the
scheme as one secret and register it as an ApiKey named `Authorization`.

`undetermined` means the upstream credential could not be established at all --
an unresolved policy fragment, or no policy read and no backend credential.
Registering an api key for a credential nobody read asserts more than anything
knows. It becomes a blocking decision proposing `retain-in-apim`, following the
`catalogueFetched: false` precedent, and offers no `compensate`: there is
nothing to compensate for until someone has read the credential. One rule
rather than two, because the plan's answer is the same for both causes; the
collector's own sentence is appended, so the item names the fragment when there
is one.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
An API with no `backendId` that names its upstreams through several
`set-backend-service` elements records them in `routing.candidates` while
`routing.targets` stays empty. Model resolution walks targets, so no Foundry
account was ever looked up: no models resolved, no model or alias objects
built, and the provider reported `kind: unknown` with no endpoint.

It was not silent, but what it said was wrong. The blocking item claimed the
provider "could not be inferred from the backend URL" when `providerIds` had
already named both providers and no backend URL was ever consulted, so the
operator was asked to hand-list models ARM had already resolved. Meanwhile the
`set-backend-service` item proposed compensating in the priority and weight of
the alias backend models, for an alias that was never built: an answer the plan
had constructed nothing to carry.

The candidate records are now resolved alongside their names and passed to
`_backend_urls` and `_routing_targets`, so each candidate becomes a target and
the catalogue, the provider classification and the alias members all work
unchanged. Those targets carry no priority and no weight, because a `choose`
declares neither, and `routing.mode` stays `conditional`, so a runtime choice
is never reported as a declared pool.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…tream

`none` was the last mode `_custom_auth` still answered with
`{"kind": "ApiKey", "headerName": "api-key", "value": null}` -- a header name
nothing set, holding a key nothing has, for an upstream the collector says is
called unauthenticated. Every other mode now either registers correctly or
refuses, so this one was the odd one out.

It returns nothing for a different reason than the rest, and the two are kept
apart in code so they cannot be confused. The others are a refusal to invent an
object the target has no field for, and each raises a gap. This one has nothing
to state: an upstream reached without a credential registers without
authentication, and that is the configuration rather than a question. So `none`
stays outside `UNREGISTRABLE_PROVIDER_AUTH`, and therefore outside the
provider-auth rule's vocabulary, where a rule pinning it would fail `compile`
rather than quietly raise a decision the source has already answered.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The same gap one asset kind over. A model API that chooses its backend at
runtime now reads its candidates as targets; `_mcp_asset` still called
`_routing_targets` without them, so a tool server behind a `choose` reported no
upstream at all. `mcp create` takes the absolute URL of the endpoint, so a
server with no upstream registers nothing.

The tool-projection path had it twice over: it discarded the candidates with
`record, _ =` and never passed the source API's policy elements to
`_resolve_backend` in the first place, so a runtime choice there was invisible
rather than merely dropped. The source API routes the tool calls, so a choice
in its policy is this server's upstream just as much as a declared backend is.

Resolving the candidate names to records was about to be written a second time,
so it is `_candidate_records` now and both callers share it. A name matching no
backend is dropped rather than carried as None: `set-backend-service` names a
backend by id, and one APIM does not have is a dangling reference in the
source, not an upstream to report.

An A2A agent reads `backend_record.url` directly rather than through
`_routing_targets`, so it has the same gap in a different shape. Left alone.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
A key written inline is the same credential as one written `{{name}}`, but only
the second reached the upstream. `policy.parse` redacts a hard-coded credential
and registers a ref for reading it back, and that ref lived only on the
document -- while `_backend_auth` is handed elements. So an api-key header
carrying a literal reported `mode: apiKey`, correctly, with no secret behind
it, and the provider registered `kind: ApiKey` with a null key: the mode right
and the registration empty, which is the shape that mode exists to avoid.

The ref now goes on the element too, beside `namedValueRefs`, so whoever reads
one way of writing the credential reads the other. `register_literal` returns
None rather than the redaction placeholder when there is no registry to mint a
ref, so a caller can tell "no secret here" from "a secret nothing can resolve";
the placeholder is a value, not a reference.

The same ref is now also named for an `authentication-basic` password. It was
withheld while `_custom_auth` answered every mode with an ApiKey object, since
`secretRefs` is what fills that object's value and naming the password
published a basic credential as a working api key. `basic` is refused outright
now, so the ref reaches nothing that would misread it -- and the `compensate`
option asks an operator to compose `Authorization: Basic ...` by hand, which
they cannot do without knowing where the password is. A test pins the guard
that makes this safe, so the ref cannot outlive the refusal.

Neither credential's value travels: the inventory carries references, and the
tests assert the literals appear nowhere in it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
`present` reads as "the key exists", which is the one thing it does not test.
It is truthiness: `[]`, `""` and `0` are all empty, and the schema had to spell
that out because the name said otherwise.

The distinction is load-bearing. On `inferenceRoutes` an empty list is a model
declaring it serves no route -- a real decision, answered by the rule that
pins the form false -- while null means the dialect could not be read and is
filtered out before any predicate runs. Someone reading `present` as a null
check and "fixing" it would stop matching the empty list, and a model that
serves nothing would register as though it served something.

A rename and nothing else: the matcher, the compile check that closes the form,
the schema, the five rules that use it, and the tests that build one. The
golden does not move, because a rule is identified by what it decides and not
by how it is matched.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Selection was first-match, so a rule's correctness depended on which other
rules existed and which order they sat in. The file emulated specificity
without ever saying so: `matches` was driven by the caller's criteria, so a key
a rule left out was compared against `None`, and omission became a negative
claim. The general catalogue rule could not match a provider whose source a
more specific rule also named -- not because it disagreed, but because it had
declined to mention the field.

`holds_all` is driven by the rule's own keys instead. A rule that pins nothing
about a field makes no claim about it and is not narrowed by it, which is what
lets two rules apply to one subject and both be right. `Selector.first` becomes
`Selector.all`, which collects every governed rule whose `where` holds, and
`Selector.decide`, which is the one call a planner site makes. The two stay
separate so `compile` can ask what matched without asking what it adds up to.

What they add up to is decided here rather than in the rules that happen to
ship. `notApplicable` is dropped before the verdicts are counted -- plumbing
claims nothing, so it cannot outvote a rule that does -- one survivor wins, and
disagreement is `partial`: a rule saying a thing maps and another saying some
property of it does not are both true, and together they describe native
support with gaps. A combined proposal takes the most conservative of them, on
the principle that a decision assembled from several rules should not be bolder
than any single rule that made it.

Rules gain an `id` so a combined decision can say which ones contributed. It
decides nothing and selects nothing: a subject matches on `where`, never on it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
`model-provider create` and `model create` both emitted no `--display-name`,
and the resource provider rejects either without one: "(ValidationError) The
displayName property is required." So the `providers` and `models` phases could
not complete at all against `az aigateway` 1.0.0b34 -- not for a particular
source, for any of them. A live run of lab 17 got through `gateway`, `identity`
and `aliases` and had to create the provider and the model by hand to reach an
inference call. The telemetry builder had carried the flag all along, so the
shape to follow was already in the file.

The title has to come from the planner, because only it knows what APIM called
the thing. A provider takes the backend's `title`, else the backend's `name`,
else the registration name. The title first because APIM carries it for no
purpose other than being read; most backends have none, so the usual answer is
the backend name, which is what an operator greps APIM for and what
`migrated-gateway.bicep` titles a provider with. The registration name is last
because it is a slug: a `claude-backend` in the `finance` workspace registers
as `finance-claude-backend`, and titling it that shows a name APIM does not use
anywhere. A model takes the deployment name as the source spells it, before
slugging -- `_slug` keeps only what follows a colon, so `gpt-4o:2024-08-06`
would otherwise be titled `2024-08-06`.

Both builders refuse an untitled object before they write the settings file,
rather than dropping the flag and letting the service reject it. A refused step
leaves no temp file behind, as the `supportedEndpoints` guard already does, and
the message quotes the service so the cause is not something the reader has to
reconstruct. Only a hand-edited plan or one written before this change can
reach it: the fallback chain ends at a value that always exists.

`--display-name` stays out of the catalog's `required` lists. The catalog is a
claim about the b31 CLI surface, which does not mark the flag required, and
those tables move together with the apply builders under one test.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
`endpoint` on a model provider is a base URL the gateway appends the route to.
The planner copied APIM's backend URL into it, and an Azure OpenAI backend in
APIM ends in `/openai` -- so the gateway composed
`.../openai/openai/v1/chat/completions` and returned 404. The provider read
back `verified` either way, so nothing surfaced until a caller tried inference.
Patching the endpoint to the account root by hand is what turned a live lab 17
run into an HTTP 200.

The right value was already being derived in the same process: a resolved
deployment's `providerEndpoint` is built from the Foundry account's own hosts.
One plan therefore held two different answers to the same question, the model's
right and the provider's wrong. `provider_endpoint(account)` now names that
derivation once, the collector records it on the provider beside the other
account-derived facts, and the planner only reads -- so neither side recomputes
and they cannot drift apart again. It goes on the provider record rather than
being read off the provider's first model, because an account with no
deployments still registers a provider.

An account nobody read has no base URL to offer, and falling back to APIM's URL
would reinstate the defect silently. The endpoint is omitted and the item
carries a `plannerGap`, which is a blocking preflight finding, so the run stops
while the plan can still be fixed rather than building a provider that fails at
the first call. The gap says which provider, that the base URL is unknown, why
APIM's URL is not it, and how to re-collect with Foundry resolution on.

A `Custom` provider keeps the source URL verbatim. There is no account behind a
custom upstream to be asked where it lives, so APIM's backend URL is the only
statement of it the source has, and it is the URL APIM itself calls. A
`/v1`-suffixed custom backend carries a related hazard, but nothing in the
inventory separates a dialect prefix from a base path, and rewriting it would
be inventing an answer rather than correcting one.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
`apply` reads every object back and diffs it against the plan, and the service
does not store what the plan sends. A live lab 17 run reported
`learn-mcp: the object exists but does not match the desired state` for an MCP
server that `mcp create` had just created successfully, that `mcp show`
returned as `Succeeded`, and that answered `initialize` and `tools/list` with
its three tools. Nothing was wrong with it. The plan sends `required: true` and
a flat `mcp.url`; the service stores `mode: "failClosed"` and nests the URL at
`mcp.endpoint.url`.

Both sides are now rewritten toward one spelling before the subset check,
rather than the desired side being translated into the read's names. A
desired-only shaper has to pick a release: the catalogue pins b31, whose reads
are flat, while b34 stores the nested shape, so teaching it b34 would break b31
and the suite pins a b31-shaped read today. Rewriting both handles either, and
leaves `_DESIRED` and `_NOT_RETURNED` doing the per-capability job they already
did. The renames are the ones the installed extension's own write serializer
performs, so every value survives: a read saying `failOpen` where `failClosed`
was planned, or a different URL, namespace, transport, account or rate, still
fails. The server-generated `id` needed nothing -- subset semantics never
demanded it of the plan.

The same defect reached providers, where `kind` is stored as
`modelProviderType`, the endpoint is wrapped and the credential is lifted out
of its section, and a request rate limit, where `count`/`period` are stored as
`callsPerPeriod`/`periodSeconds`. That last rename is gated on the policy type:
a token limit's `count` is a token ceiling, and spelling it as a call rate
would compare a model's quota against a request rate. Model, alias, ipFilter
and identity writes were checked and do not diverge.

The message now names up to three diverging fields with both values, because
"does not match the desired state" told the operator nothing about which field
to look at. An unmatched list element is diffed against the nearest observed
one, since a source that read back with a single field wrong is a near miss and
"no element matches" sends the reader after the wrong thing. Write-only fields
are skipped, so no credential reaches the message.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
`_run_object` read before writing already, and the matching case worked. The
hole was disagreement: a read that found the object and did not match it fell
through to the create, so a provider somebody had registered by hand got the
identical command sent at it again, the service refused it again, and the step
reported `failed` for an object that was in the gateway serving traffic. That
is the live run ending `8 in the plan, 3 failed, 5 verified` while all eight
existed and answered -- the journal was accurate about the writes and wrong
about the gateway.

Reading first is the only thing that can stop an overwrite before it happens,
and the catalogue warns that `model-provider create` is not guaranteed
create-only, so the bad outcome was never a rejection but silently replacing
what an operator had just repaired. A refusal is the backstop: a read that
could not be performed and one that found nothing both arrive as nothing, so
when the write is then refused the step asks once more before concluding. That
rests on evidence rather than on matching an "already exists" string the repo
has no live reading of.

Divergence is a conflict only for a create. A `set` states the whole object and
converges by being run again -- that write is the reconcile -- and making those
conflict would leave an alias nobody could repoint and a token ceiling nobody
could correct. So each builder now declares what its command does to an object
already there. A create that finds something different reports `conflict`,
names the diverging fields, and writes nothing; one that finds something with
nothing comparable in it reports `unverified` rather than claiming a match.

`conflict` joins failed and mutationUnknown as stuck, so a conflicted phase
stops and `--next-phase` returns it; nothing here makes the journal optimistic.
What it does make it is current: a phase's status is derived from the read on
every run, so a phase recorded `stopped` whose objects a person then puts right
reads `complete` next time without the create being re-sent. Running a phase
twice now leaves the same state and the same report.

A latent half came with it. `steps_for` writes the settled `decision` onto
every object of an item carrying one, and for the capabilities with no desired
projection that annotation was part of the compared shape -- no read returns
it, so such an object could never match. Harmless while the answer to a
divergence was "write it again"; a permanently stuck phase once the answer
became "do not overwrite". It is stripped before comparison.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The telemetry item proposed `reuse-appinsights` -- enable the OTLP endpoint on
the resource APIM already reports to -- without ever establishing that such a
resource exists. A live lab 17 source had one logger of type `azureMonitor`
with a null `resourceId`, no Application Insights component in the resource
group, and no diagnostic settings, and was still offered the option. The agent
driving the migration had to run two `az` reads of its own to find out the
proposal was empty before it could advise anybody. The null `resourceId` was in
the inventory the whole time, and this repo's rule for that is explicit: if the
answer is derivable from APIM configuration, it is a collector bug.

`reuse-appinsights` is now absent from the options rather than merely
unproposed, because an option the operator cannot take is worse than one not
offered, and the proposal moves to `gateway-metrics-only` -- telemetry that is
configured and landing nowhere the gateway can follow means the gateway's own
metrics are what the migration actually produces. `new-appinsights` stays
offered, since it is the one answer that does get telemetry into Application
Insights, but proposing it would be proposing a resource the source never had.
The rationale no longer asserts that APIM reports to Application Insights,
which in this case was simply untrue.

A logger resolves when its `resourceId` names a `microsoft.insights/components`
segment, or when its type is `applicationInsights`. The segment rather than
mere non-emptiness, because `resourceId` is also where an `azureEventHub`
logger carries its namespace; the type as well, because the resource is as
often identified by an instrumentation key or connection string, which this
tool will not read -- but it exists and the operator can name it, so the choice
is takeable. Reporting through diagnostic settings is neither: there is no
resource there to enable an OTLP endpoint on.

The split follows the house rule about where mapping knowledge lives. Which
options exist, the proposal, the rationale and which options leave a
prerequisite are one rule each in `rules.json`, selected on a new computed
`where` key; `plan.py` keeps only the reading of the inventory, which is a fact
about APIM's records and answers for no capability. The prerequisite is decided
from that same reading, so an option that was never offered cannot withdraw a
prerequisite raised for it, and evidence carries the findings -- each logger's
type and resource id, whether any resolved, and the component ids -- instead of
a list of names.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
`summary` ships with the tool and the skill never named it, so an agent
following this document reached for `inventory.json` directly. On a live run it
spent twelve of twenty-eight tool calls in one turn rebuilding, with ad-hoc
`python3 -c` one-liners, the asset counts, policy surface, access model and
secret list that one call prints formatted. Lab 17 tells the human operator to
run it; the document that drives the agent did not.

It goes in `1. Collect`, at the point where there is an inventory in hand and
the next thing to do is look at it. After the coverage paragraph would have put
the hand-rolled reading first, and the preamble's command list is the
collect-plan-adapt flow, which is not where a reader is looking for this.

Two things about it are worth the lines they cost. `collect` already prints the
same summary on stderr at the end of its own run, so the standalone command is
for an inventory from an earlier turn -- which is exactly the situation the
live agent was in. And it is not the coverage check: a `failed` read shows up
under its gaps heading, a `notCollected` one shows up nowhere, so a summary
with no gaps heading is not an inventory with no gaps. The skill already asks
for both statuses to be read, and that still has to come from
`collection.coverage`.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
`summary` reads an inventory and nothing read a plan's items, so the operator-
facing view of the one thing §2 is about -- the question, why it is asked, what
each option costs, which is proposed, whether it blocks -- existed only as
`json.load`. A live run re-derived it four times in one session: once to find
the open items, again for their options, again for the telemetry item, again
for the prerequisites. Every session was going to reinvent that reading,
differently and worse.

It goes behind `summary`, which is already the verb for reading an artifact,
rather than a second reading command with a rule about which artifact takes
which. `--unsettled` prints every open item in full and `--item` takes an id or
any fragment naming exactly one, because the short view prints
`[choose] model:azure-openai/publishedSurface` and never the id -- demanding
the full `item:telemetry/destination` would send the reader back to the parser
this replaces. An ambiguous fragment lists its matches instead of picking one,
since resolving it quietly answers about an item nobody asked after.

Dispatching on the artifact's `kind` is what makes that possible, and it closes
a hole worth closing on its own: `summary plan.json` used to render a plan as
`APIM AI inventory: None` with no assets and exit 0, so an agent that mixed up
two files got a confident report of an empty instance. A journal now says its
view is `apply --status`, and an artifact the tool does not write says so.

What the skill calls not-a-question is marked on the header line, so a scan
catches it without reading the body. `rulesGap`, `cannotAccept` and an item
named in `plannerGaps` are `[not a question]`, each saying what to do instead;
`targetSupports` and `appliedByHand` are `[ask it differently]`, because those
are decisions asked on a false premise -- the gateway can do it. Both views end
with the planner gaps and orphaned decisions, as an unsettled view that omitted
them would read as permission to apply when a gap blocks it.

`target.objects` is deliberately absent. `apply --phase` prints those verbatim
with the command that will run them, at the point they matter, and repeating
them here would double the view for a reader who is deciding rather than
executing. Evidence is never truncated, because cutting it is what sends
somebody back to a one-liner.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Acknowledging a prerequisite changed nothing anybody could see. The note
printed the same three ids before and after, so the operator who had just
granted a role and read it back had to open `journal.json` to find out the flag
had done anything. Working through them one at a time gave no feedback and no
shrinking list.

The note is now the list as it stands: outstanding ones first, acknowledged
ones kept below them and marked, so what the migration depended on stays on the
record rather than disappearing once it is done. It still gates nothing -- a
gateway builds cleanly with every prerequisite outstanding, and fails to serve
traffic, which is the whole reason they are listed.

Where a prerequisite can be read, the reading and the acknowledgement are
reported as two different things, because they are. An acknowledgement is a
claim about work performed; a role assignment on the resource is evidence. When
they disagree the line reads CONTRADICTED and prints both halves, and the
remedy says to take the read. A reading that agrees is said too, and one nobody
could perform says nothing at all -- an unread scope leaves the prerequisite
unestablished rather than present, so absence of evidence never prints as
evidence. `prereq:name-collision` is owned by this tool and preflight is where
it is performed, so preflight's own check is its reading.

`--acknowledge` now records on its own. A flag documented as "remember to also
pass `--preflight` or it silently does nothing" was a defect, and lab 17 had
written the workaround down. It is state rather than a mode, so it lands
alongside `--status`, `--phase`, `--next-phase` or nothing, prints what it
recorded and what is still outstanding, and is idempotent. An id the plan does
not raise is refused with the real ids listed, before any phase runs: a typo
must not leave somebody believing a prerequisite is recorded while a write goes
ahead.

The header no longer says "only an administrator can do". Two of these are
owned by this tool and by the operator, not by an administrator.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
A rehearsal prints the command it would run, and that print is the thing an
operator reads before authorising a write. It was not reviewable. Half the
arguments could not be pasted -- `--location Sweden Central` is two shell
words, `--display-name Foundry AI endpoint` is four, and
`--backend-model {resource-id:...,priority:1,weight:80}` is brace expansion
that bash turns into several arguments before `az` sees any of them. And
everything that mattered was behind `@<tempfile>`: the endpoint, the resource
ids, the authentication mode, none of them shown.

The live run made the cost concrete. The provider's endpoint carried APIM's
`/openai` suffix and would have 404'd every inference call, and the agent
reviewing the rehearsal could not answer "is the endpoint right?" from it. It
had to go and read this tool's source. A rehearsal that hides the field under
review is not a rehearsal.

Commands now print through `shlex.quote`, which leaves ordinary words bare so
the common case still reads as a command, and each `@file` argument prints the
payload beneath it in the builder's own key order -- that is the file the
command would read, and `endpoint` first is how somebody scans it. Nothing
about execution changed; argv still goes to `az` as a list and never through a
shell.

Showing a payload must not show a credential, and the guard that matters is
structural rather than a pattern: the printable copy is taken before secrets
are resolved, so a resolved value exists only on an `--execute` run, only
between that call and its 0600 file, and is not reachable from the display at
all. On top of that a `$secretRef` renders as the reference it is, because
which credential is wired in is the reviewable half and the value is not, and a
field named like a connection string is redacted -- the telemetry item asks the
operator to write one straight into a decision, and it matches none of the key
patterns.

Payloads are rehearsal-only and never journalled. Printing is bounded by the
run that prints it, a file is not, and once the write has happened a payload is
a disclosure in exchange for a review nobody can still act on.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…here

The skill told the agent to build its phase checklist "with whatever task tool
your host gives you -- `TodoWrite` in Claude Code", and on a live run in Claude
Code the host exposed `TaskCreate`, `TaskUpdate` and `TaskList` instead. The
agent went looking for the name it had been given, did not find it, and had to
spend a tool search discovering what it already had. The clause meant to be
helpful was the only part that misled.

The same sentence pattern was in §2, where unsettled items were to be worked
through "with `AskUserQuestion`". That one failed in the same run and more
quietly: the session had no such tool, so it put the decisions to the operator
as prose, which was the right thing to do and which the document never said was
allowed. Both now say to look at the tools the host exposes, and both keep a
fallback for a host with none -- print the checklist in every reply, ask in
prose and wait before the next question.

The substance is untouched: one entry per phase, in phase order, before the
first write, ticked from what each run printed; one dependency-ready question
at a time. What goes is the idea that either is tied to a particular tool,
since host tooling varies and will keep varying.

`apply --preflight` already asks for the list without naming anything, so the
skill now reads as the same instruction rather than contradicting it. The one
remaining mention of a Claude Code name stays: `${CLAUDE_PLUGIN_ROOT}` is a
sentence about where that host puts the plugin root, which is its whole
content.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
`migrate_apim/secrets.py` took the name of a stdlib module, and Python puts the
working directory on `sys.path`, so a shell sitting in the package directory
broke `az` -- the one external command this tool depends on. `msal`, `oauthlib`
and `msrest` all `import secrets`, got this file, and failed on its relative
import. The traceback named oauthlib, so nothing in it pointed at the tool that
caused it, and the person most likely to be in that directory is whoever is
working on the package.

Normal invocation was never affected: `PYTHONPATH=<tool-dir> python3 -m
migrate_apim.cli` puts `tools/migrate-apim` on the path, not the package
directory. That is why this survived so long, and it is also why the fix is
worth its churn -- the failure costs nothing to avoid and is bewildering to
diagnose.

`secretrefs` says what the module holds. Its own first line is that the
inventory carries a reference and never a value, which is the invariant the
whole file exists to keep, and `credentials` would name the one thing it is
built not to contain. It also matches the vocabulary already in the data:
`secretRefs` in the inventory, `$secretRef` in a plan payload, `ids.secret`.
`credentials` would have been a second collision in Azure and Google SDK
namespaces anyway, one rung down from this one.

The API is unchanged. Two call sites imported it `as secrets_mod` to
disambiguate a name that no longer collides, so the alias went with it.

`compile.py` shadows a builtin rather than a module, which cannot be hijacked
by anyone else's import and costs only the builtin inside the one file that
imports it; it is left alone.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Eleven fixes landed in a row and six of them edited this README as they went,
so what was left was partly a description of a tool that no longer exists and
partly two paragraphs saying adjacent things about one behaviour. The stale
half is now corrected and the duplicated half merged.

What was simply wrong: rule selection was still described as four passes ending
in a terminal rule, which is not how selection has worked since every
applicable rule began to apply and combine; the compile table claimed "no rule
is ambiguous", a check that no longer exists and has been replaced by one that
asks whether co-applying rules name different capabilities and whether a
combined proposal is among the combined options; `{"present": bool}` was named
in three places that the schema and `compile` have called `nonEmpty` since it
was renamed; and the architecture diagram named a method the module does not
have.

What was missing: the provider endpoint and why a base URL is not APIM's
backend URL, the titling of every provider and model and the fallback chain
behind it, and the bringing of both sides to one spelling before a read-back is
compared. The telemetry section had drifted into contradicting itself, one
paragraph implying four options always and another saying reuse can be absent.

Printed output had never been run. The phase checklist showed a phase with zero
steps, which the renderer drops; the unmapped-attributes block had invented
column widths and a per-object form the code does not produce. Both are now
verbatim from the CLI, as is the new per-item view.

The audit section presented one round as the whole story. It now carries the
second: four of the live run's findings are the same defect family it already
names, each pointing at where it is described, and three are not -- a flag the
service requires and no argv carried, a rehearsal nobody could review, and an
acknowledgement that recorded only alongside another flag. The test count moved
from 187 to 993.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
`--item` resolved a fragment against the item id, and the short view labels an
item by asset and aspect and never prints an id. For a model item the two
overlap enough that it worked. For a policy or access item the id carries a
hash, so `--item set-header` failed for the item the reader was looking at,
printed one line above as `[choose] policy/set-header`, and the only way to
find `item:policy/da79943af481` was to open the plan -- which is the round trip
the flag exists to remove. The commit that added it claimed a fragment naming
exactly one item would do; that was true of the items it was tried on.

The label is now built in one function that the short view, the item view and
the matcher all call. It was already spelled out twice by hand in this module,
identically and independently, which is how a matcher comes to disagree with
the thing it is supposed to match. A test scrapes the rendered line and asserts
the matched text is the printed text, rather than trusting that they stay the
same.

A fragment that hits one item's id and another's label is an ambiguity, not an
id winning. Preferring the id would answer about one item without ever saying
the other existed, to a reader who typed what was on the page -- the same
defect as this one, a layer further in. The ambiguity message now names every
match by id and label together, because a reader who typed a label and got back
a list of hashes still cannot choose. That is the one place an id is worth
printing, and now the only place it is.

The short view still prints no ids. Adding them would re-establish the id as
the thing to copy, widen a view whose whole purpose is to be short, and leave
the label unaskable anyway.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Fourteen fixes landed on the tool this lab teaches, and the lab documents
several of the defects they fixed as permanent behaviour the reader is told to
work around. Everything substantiable without a gateway is corrected here; the
blocks that only a live `--execute` run can produce are left untouched rather
than adapted by hand, because a plausible-looking output nobody ran is worse
than a stale one somebody did.

The factual error worth naming first is the decision table. It said `split`
moves chat completions and embeddings and keeps image generation on APIM. Only
chat completions moves: the sample's account deploys `gpt-5-mini`, which serves
chat and responses, so embeddings is `noModelServes` and stays behind too. The
same sentence was in the Bicep and Terraform comments, which the README
includes, so those are fixed at the source and the regions regenerated by
`npm run sync`.

The telemetry row had four options and the premise that APIM reports to
Application Insights. The sample's logger is `azureMonitor` with no resource
id, nothing resolves, and the planner no longer offers reuse at all -- so the
row is three options and the lab's own justification for its recommendation,
which assumed a shared resource to leave alone, is replaced by the one the tool
gives.

Every regenerable block was regenerated rather than edited: the inventory
summary line the renderer no longer prints, the plan blocks whose grouping,
item labels, ordering, byte counts and prerequisite wording all moved, the
policy item hashes, and the preflight note, which `c5de51b` rewrote into a
per-prerequisite list with its own readings. The acknowledge step loses the
`--preflight` the lab told readers to add, and the troubleshooting row for that
quirk is replaced by the refusal a mistyped id now gets. The row about an
undetermined auth mode goes: the branch fixed it, and the plan carries the
identity step and the Foundry grant.

Two tracked rows in TROUBLESHOOTING and the `--execute` blocks in the README
stay as they are, listed for the live run that has to confirm them.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
A tool server projected from a REST API registered its contract as
`{"type": "url", "$fromExport": "<api>"}`, and `$fromExport` stood for "apply
will run the export recipe and fill this in". Nothing did. The only placeholder
`apply` resolves is `$secretRef`, and this one sat beside `type` as an ordinary
key, so it was written into the `--endpoints` file verbatim and the literal
string would have gone to the service. The write fails before any read-back, so
none of the comparison work could have caught it.

This is derivable and therefore ours, not a question. The document is APIM's
own configuration, the export is an ARM read, and `collect` already writes the
recipe down -- an operator cannot supply a contract APIM is holding, so
`needsFact` would be the wrong shape, and the builder exists, so is
`appliedByHand`. It is what `plannerGaps` is defined as: a required field no
source supplied, a defect in this tool.

So the planner stops emitting the endpoint, says in the rationale that it does
not perform this mapping and that registering the server publishes it without
its REST surface, lists the APIs in evidence, and raises a gap once the item is
settled on anything that migrates. Settled on retaining or blocking it raises
nothing, because nothing is built and a blocking finding would stop a whole
migration over a server nobody is moving.

`apply` now refuses any `$`-prefixed key it cannot resolve, before the temp
file exists and in rehearsal as well as execution. A hand-edited plan cannot
reach a write with one, and neither can the next marker somebody adds without a
resolver.

Resolving it properly is a capability rather than a patch -- an ARM export, a
fetch of a short-lived SAS link the collector says never to persist, a
base64 inline source, a decision about how a read-back treats it and how a
rehearsal prints a whole spec -- and none of it can be exercised from here.
Shipping an unwritten path as fixed is the thing this commit refuses to do.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
`migrate_apim/mcp.py` took the name of the Model Context Protocol SDK, so a
process started from the package directory got this file instead of the
installed package and died on its relative import -- the same mechanism, and
the same misleading traceback, as the stdlib `secrets` collision fixed
earlier. Narrower, because it needs the SDK present as well as that working
directory. Less theoretical than it sounds: this repo's own labs import it,
so anyone with the lab requirements installed has the colliding package.

`tooldiscovery` names what the module holds rather than the protocol it speaks.
It is not a general MCP client -- its first line is that it asks a server what
tools it exposes, and the transport half exists to serve that. What it produces
is the `toolDiscovery` reading on each inventoried server, which is a required
key in the inventory schema, a predicate in the rules schema, a `where` match
in the rules, and what the `discover-tools` verb writes. A name starting with
the colliding token would have kept the hazard, and a bare verb would have been
a third unqualified one beside `detect`, `resolve` and `collect`.

A rename and nothing else: two import sites, no aliases to drop, no packaging
entry, and nothing in the architecture notes or the README names the file.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
A live run of this lab against a fresh copy of its own sample completed all
eight phases through `migrate-apim`, with no by-hand `az aigateway` creates,
and the gateway it built answered a chat completion. So the lab's central
detour goes: the prose saying the `providers` phase fails, the two hand-written
`model-provider create` and `model create` blocks, the `toolServers` mismatch
and the `mcp show` check that existed to prove the server was really there, the
`--next-phase` warning, and the explanation of why `providers` stayed pending.
Every output block in the section is now that run's, not a reconstruction.

One step appears, because a fix removed something the lab was relying on
without saying so. `az aigateway model-provider create --foundry-resource-id`
granted **Foundry User** as a side effect, and the tool builds the provider
from a `--foundry @file` payload instead, so nothing grants it now. The role
has to be granted between `identity` and `providers` -- the principal does not
exist before, and the provider cannot serve without it -- and a reader who
misses it gets a gateway that builds cleanly and fails every call. The plan
carries the command; `--acknowledge` records standalone, so it belongs in that
step rather than at the end.

The `providers` rehearsal is the block worth reading twice: the arguments are
quoted so the command can be pasted, the payload behind `@<tempfile>` is
printed, and the endpoint in it is the account's root rather than API
Management's `/openai` backend URL. Those are three separate fixes, and what
they add up to is that the one field that silently broke inference last time is
now visible before anybody writes anything.

Troubleshooting loses the four rows for defects that are fixed and gains two
for the grant: the authorization failure a reader without the permission gets,
and the tool's own `foundryRoleMissing` finding, which is what a skipped grant
looks like from the inside.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
An APIM MCP server built from a REST API is an OpenAPI MCP server on the
target, and a passthrough one is a federated server with a single MCP backend.
Both are native. The planner was building neither for a projection: it took the
upstream `collect` resolves through the source API -- that API's *REST* backend
-- appended `/mcp` and registered it as an MCP endpoint, so the gateway was
pointed at a host that has never spoken the protocol. The collector had the
right answer written down the whole time, in the note on its export recipe:
the document is consumed as an `openApi` source, inline or by URL.

The previous pass read the missing builder as a missing capability and raised a
planner gap. That premise was wrong and the gap is gone. The narrow case it
should have described is now its own outcome: when the source API has no
contract to give, the item is a `gap`, blocking, with no target object and
`retain-in-apim` proposed. Which of the three applies is decided from APIM's
own API type, so `openApiSources[]` now carries the `apiId` to join on, the
type APIM reported, and this tool's reading of whether that type exports --
both halves, because "no contract" has two causes and two different remedies,
collect the API or accept that APIM has none.

The transport leak is closed by construction rather than patched. The
inventory's vocabulary is APIM's (`jsonRpc`, `http`) and the target's is
`streamableHttp`/`sse`; one table maps between them and a word outside it
shapes no source at all. Defaulting it would be inventing a protocol on the
operator's behalf.

Carrying the contract means one request that leaves the management plane,
because every export format at this API version answers with a SAS link and
none returns the document inline. It is not an `ArmClient` method: that client
attaches the operator's token to whatever it is given, and an address that
merely arrived in a response body is how a management token reaches somebody
else's host. So it sends no credential, refuses plaintext, follows no redirect,
and bounds both size and time. The link is never quoted in an error, because
the link is the credential. A rehearsal exports nothing and shows the marker
instead, so what gets approved is that the export will run.

What the document says is not repaired. A missing or relative `servers[].url`
fails the step, because which host the tools are called at is a migration
decision and not a blank for this tool to fill.

Every part after the ARM read is unexercised against a real service.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The sample had one MCP server and it was a passthrough, so every run of this
lab exercised one of the two mappings and the other was never built by anybody.
A tool-projected server -- APIM synthesising MCP tools from a REST API's
operations -- maps to a different thing on the target, a tool server with an
`openApi` source rather than an MCP backend, and that path had no source to run
against.

`orders-rest` is a plain REST API with two operations, and `orders-mcp`
projects a tool from each. It carries no `backendId` and no `serviceUrl`, which
is how an inventory tells this kind apart: there is no upstream that speaks
MCP, only a contract. The backend host is a placeholder, because what migrates
is the contract and the sample never calls it.

Verified against a live BasicV2 instance: API Management accepts `mcpTools` at
`2025-09-01-preview` with each tool naming its operation by resource id, and
reads the server back with `type: mcp`, both nulls, and the tools intact. The
Bicep type does not declare `mcpTools` yet, so it is suppressed the same way
`backendId` already is on the server above.

The export those tools migrate through was run against this API as well: it
answers `{"link": ...}` at the top level, matching the recipe the collector
records, and the document behind the link is OpenAPI 3.0.1 JSON whose
`servers[].url` is absolute and points at API Management's gateway.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The first live migration of a tool-projected MCP server failed with "the
OpenAPI export of orders-rest returned no link" for an export that had
succeeded. The executor read `$.value.link`, hardcoded, because that is the
shape `ApiExportResult` has in the published spec. At 2025-09-01-preview the
service answers `{"link": ...}` flat, which is what `collect` records in the
recipe's `valuePath` and what the recipe's own `az rest --query link` form
reads. So the one place the answer's location is stated was ignored in favour
of a second opinion, and the two disagreed.

It now follows the recorded path, which is the point of recording it: the
collector and the executor cannot drift apart if only one of them says where
to look. The traversal is deliberately a chain of object keys rather than a
JSONPath, because that is all any recipe this tool writes needs, and a query
language would be another thing to keep in agreement.

The failure message guessed too. It asserted the export had answered without a
link, when what had happened was that nothing was read at the path tried; it
now names the path and what the body actually carried, which is the difference
between a defect somebody can see and one they have to reproduce.

The test fake carried the same wrong shape, built from the same spec, which is
why the suite agreed with the bug. It is pinned to the live shape now, and a
test asserts the link is read at the recipe's `valuePath` rather than anywhere
this file happens to believe in.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The export failed again after the path fix, and the path was never the whole
story. API Management honours `export=true` only when the request does not ask
for `application/json`, and `ArmClient` asks for it by default. So ARM returned
the plain API resource -- `id`, `name`, `properties`, `type` -- with no link in
it anywhere, and every reader of every path found nothing. The step reported a
missing link for an export that had not been performed.

Observed against a live instance, one URL and three headers:

    Accept: application/json   ->  id, name, properties, type   (no link)
    Accept: */*                ->  {"link": ...}
    Accept omitted             ->  {"format", "id", "value": {"link": ...}}

Which also settles why the previous commit looked like the fix and was not.
`$.value.link` and the recorded `$.link` were each correct, for the header the
person who wrote them happened to send: the spec documents the no-Accept
shape, and `collect`'s `az rest` form sends `*/*`. Two right answers to
different questions, and the one the tool actually asked returned neither.

It asks for `*/*` now, which is the recipe's own form and the shape its
`valuePath` describes. Honouring the recorded path stays the right thing and
is what makes the two agree rather than coincide.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The sample grew a tool-projected MCP server beside its passthrough one, and
the lab described only the passthrough. The two migrate by different mappings,
which is the reason to have both: a passthrough is a federated tool server
with one MCP backend, and a projection is a tool server whose source is the
REST API's OpenAPI contract, exported from API Management and sent inline.

Every block that moved is regenerated from the run, not adjusted: the summary
now counts two MCP servers and four APIs of which three are inventoried, the
plan carries eleven items and seven decisions, the `toolServers` phase has two
steps and verifies both, and `--status` reads nine of nine. `orders-rest` is
kept and not inventoried -- it is not an AI asset, and the server that projects
from it is -- which is worth a sentence because it looks like an omission.

The new decision is whether to accept that APIM's per-tool policies and name
overrides do not come with the contract. The lab accepts, and says why that is
reasonable here rather than in general: both tools carry no tool policy, so the
loss the rule warns about is empty on this instance. A reader whose projection
does carry policy is being told something different.

Two things the run taught that the lab now states. The names round-trip --
APIM's `get_order` comes back as `orders-mcp_get_order`, built from the
contract rather than from the operation id `get-order` -- and the contract is
write-only on the target, so the read-back cannot confirm it and the tool says
so; what proves it arrived is the tool list. Both are in Verify, which now
lists the tools of both servers.

The Bicep and Terraform references still build the passthrough server only,
and the gap is written down in both tracks rather than papered over: an inline
contract means a template has to carry the document or take it as a parameter,
and saying so is honest where a template that quietly omits it is not.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.

2 participants