Skip to content

ADR-0032: Azure DevOps as a second GitProvider

  • Status: Proposed
  • Date: 2026-11-13

This ADR took number 0032. The ADR for #166 is written at the same time and would take 0031, so this one skips it. If that ADR takes another number, this one keeps 0032.

Nothing in it is built. The adapter, the settings fields and the identity wiring are planned. Every statement about what Azure DevOps does cites the page it comes from in the section "Sources", or is marked as something the first slice must check against the test organization.

Context

ADR-0004 put Azure DevOps on the list of later adapters and left two things for later: the identity that completes a pull request, and branch policies with path filters, "against the same approvalRequired semantics". ADR-0013 says the interface is designed around what Shadewright needs, not around the first vendor. ADR-0006 solved the identity for GitHub with an App whose key stays in Key Vault, because GitHub accepts no Entra token. ADR-0028 added reading comments and reviews and a required check run, and lists Azure DevOps as planned with a sample comment payload.

An Azure DevOps organization is now available for tests. GitProvider (internal/providers/git.go) has twenty methods, some shaped by GitHub: check runs, installation tokens, an EnableAutoMerge that the GitHub adapter does not implement either (Capabilities reports AutoMerge false, #20). Two more interfaces sit behind the same adapter: FeedbackSource (three methods, ADR-0028) and AncestryChecker (one, used by the delivery check).

Questions to answer before any code:

  1. Which of the twenty-four methods have a direct equivalent, which need a different shape, and which have none.
  2. Which identity writes to Azure DevOps, and how it stays separate from the analyzer's (invariant 6).
  3. What the repository must already enforce before the adapter writes, since Shadewright's own checks are not the last line of defence (invariant 3).
  4. How a restart finds its own work again (invariant 5), where Azure DevOps offers no idempotent create.
  5. What the first build task is.

Out of scope: the adapter itself, Azure Pipelines, and Azure DevOps Server (on premises). The adapter targets Azure DevOps Services at dev.azure.com.

Decision

1. One adapter package, bound to one repository

A new package internal/providers/azuredevops implements GitProvider, FeedbackSource and AncestryChecker. As the GitHub adapter is, it would be bound at construction to one organization, project and repository (the repository by its ID, checked against every response) and to one target branch, talks to two hosts only, https://dev.azure.com and https://vssps.dev.azure.com (pinned in code; the second serves the Azure DevOps Graph read for reviewer hints and nothing else, see the row CanWrite in section 3; no other host, and none for Microsoft Graph; no redirects, bounded response bodies, fixed-text errors, the kill switch checkpoint before every write and every retry), and writes only to branches named shadewright/<name>. The Entra client library is imported only in a subpackage azuredevops/auth (ADR-0013). The adapter has an in-memory fake through the existing fake package and a recorded-fixture test suite. A task to add with the package: an import test for azuredevops in the style of the existing ones (the core has TestNoVendorImports, ADR-0013) that keeps the Entra client library out of every package but azuredevops/auth and checks that nothing outside the composition root imports azuredevops. It does not exist yet.

RemediationSettings gets a provider value AzureDevOps and an azureDevOps block beside github, with the same CEL rule that exactly one block matches provider. This is an additive API change (feat(api)). Its fields are listed in section 7, where one point is still open.

Decided 2026-11-13: the core types change before the feedback and check slices. FeedbackAuthor.ID (Go, internal/providers/feedback.go) becomes an opaque string with a new field IDScheme (GitHubUserID or AzureDevOpsIdentity; not named Kind, which FeedbackAuthor already has as AuthorKind). CreateCheckRun takes the change request number besides the commit, so the adapter reads the pull request by number and checks that its head is that commit, instead of finding it from a commit. The GitHub adapter ignores the number: a check run belongs to a commit there, so its behaviour is unchanged, and the controller still passes the head it recorded. This is its own task (refactor for the Go types, feat(api) for the CRD below), done before the status and feedback slices, in line with ADR-0013. Rejected: mapping the GUID into an int64 and looking the pull request up from the commit (see Alternatives).

The API change this needs, which is not only Go. HintAuthor in api/v1alpha1/hint_types.go has id as an int64 with Minimum=1, required, and login with the pattern ^[A-Za-z0-9][A-Za-z0-9._-]*$ (GitHub logins); the controller repeats both (internal/controller/hints.go: Author.ID < 1 and hintLoginPattern). It is in a release: git tag --contains shows HintAuthor in v0.4.0-rc.1 and v0.4.0, and the released CRD carries id as an integer. The type is v1alpha1, so a breaking change is allowed, but turning id into a string would fail to decode any stored RemediationRequest that already has a hint. The recommendation is additive, with no conversion: id becomes optional, a new optional string subject (1 to 128 characters, a pattern that fits a GUID) is added, and a CEL rule requires exactly one of the two, which the executor sets from IDScheme (id for GitHub, subject for Azure DevOps). login keeps its pattern for GitHub; a request whose source is AzureDevOps needs a second rule or a wider pattern, because an Azure DevOps display name or unique name has spaces or @. HintSource gets the value AzureDevOps (its comment says Azure DevOps is planned). Change: feat(api), with a refusal test per rule, make manifests generate chart-crds api-docs. The alternative, id as a string for both hosts, is a feat(api)! that needs a migration of stored requests: not chosen. This is open (see Open questions).

2. The identity: a federated Entra identity, no key, no token in a Secret

The executor reaches Azure DevOps with a Microsoft Entra access token for the Azure DevOps resource, acquired through workload identity from the executor's own service account. Microsoft's guidance for application identities is the same: prefer a managed identity for an Azure-hosted workload and workload identity federation or a certificate over a client secret for a service principal, and use Entra tokens in place of personal access tokens (service principals and managed identities).

  • In Azure DevOps the identity is added to the organization as a user, with the lowest access level that gives it Azure Repos (Basic), and is a member of one purpose-specific group that holds the permissions of section 5 on the one repository, never a broad default group. The page above says Azure DevOps does not use Entra application permissions to authorize an application identity: access is an access level, group membership and resource permissions, like any member.
  • The token carries the whole identity, not one repository: it is not scoped per request the way a GitHub installation token is. The only scoping is the permissions in Azure DevOps. This is weaker than ADR-0006 on one point, and the consequence section says so. The adapter treats the token as opaque and never depends on its lifetime (the page tells clients not to); it reuses the credential object, so the library caches and renews it.
  • No Key Vault key and no Signer. There is no long-lived credential to protect: no private key, no PAT, nothing in a Secret. The Key Vault role of ADR-0006 does not exist for Azure DevOps.
  • Separate identities (invariant 6). Only the executor's service account has the federated credential. The analyzer and the verifier have no Azure DevOps identity, no federated credential and no token, so a compromised analyzer cannot write to Git or read the repository through Azure DevOps. The identity is one Entra identity per executor, not shared with the analyzer's (ADR-0029 already creates one managed identity per component).
  • Cost. An access level is billed per organization for each application identity ("each identity consumes a license in every organization where it's assigned a paid access level", same page). Price it before the test organization gets the identity (workspace rule on lab spending).
  • Tenant. The identity must exist in the Entra tenant the organization is connected to; a managed identity of another tenant cannot be added (same page). Decided 2026-11-14: the test organization is connected to the lab's Entra tenant, so the lab can use option (a) below.

Decided 2026-11-13. Option (a), the executor's user-assigned managed identity as in ADR-0029, is the identity in the lab. Option (b), a service principal (app registration) with a federated credential from the cluster's OIDC issuer, is the supported option elsewhere (an organization in another tenant, a cluster not on Azure). Both use the same adapter and the same azureDevOps block. A personal access token in Key Vault is not supported. Decided 2026-11-14: the test organization is connected to the lab's Entra tenant, so the lab uses option (a). Option (b) stays the supported path wherever the organization is in another tenant. The rejected option and its cost are under Alternatives.

3. Method map

"Direct" means one documented call does what the method says. "Shape" means the same result needs a different sequence. Rows marked spike state something the first slice must confirm against the test organization before the method is built, because the page read for this ADR does not say it. Statements marked with a source were read in the pages of "Sources".

Method Azure DevOps Fit
Capabilities AutoMerge false at first, as for GitHub (#20). RequiredReviews true, since the minimum reviewers policy exists. Whether the policies are really in place is the preflight of section 5, not this flag. Direct
ReadFile Items API at a commit version. Needs the checks the GitHub adapter makes: only regular files (symbolic links and submodules refused), the size known before the content is downloaded, at most MaxFileBytes read, content checked against its Git object ID. Items and Trees pages not read for this ADR. Direct, spike (size before content, how links and submodules show, whether the object ID can be checked)
ListDir Trees API without recursion, or Items with a one-level scope. Same checks as ReadFile, plus the 1000 entry bound and ErrInvalidEntry. Direct, spike (as above)
BranchHead Refs API list with filter=heads/<branch>, returns the object ID. The page says filter is a "starts with" match, so a filter for one branch also returns longer names: the adapter takes only the entry whose name is exactly refs/heads/<branch> and follows the continuation token ($top is at most 1000 on the page). The page does not state an order, so none is assumed (Refs - List). Only the target branch and shadewright/ branches are accepted, as in the GitHub adapter. Direct
CreateBranch Refs API, update with oldObjectId all zeros and the new object ID; the result carries updateStatus per ref, and staleOldObjectId means the caller lost a race (Update Refs). An existing branch at the same commit is success by reading BranchHead first, at another commit ErrConflict. The base must be the head of the target branch or an ancestor (IsAncestor). Shape
CommitFile One request. Pushes API with refUpdates[{name, oldObjectId}] and one commit with one edit change whose newContent is the file (rawtext or base64encoded); the page shows the same call creating a branch from a base commit and updating one (Pushes - Create). GitHub needs blob, tree, commit and a GraphQL ref update. The adapter sends oldObjectId as the expected head and never a force. Always base64encoded, so bytes are not re-encoded. Shape, spike (a stale oldObjectId in a push must be refused, not applied: the Refs page names staleOldObjectId, the Pushes page does not say; does an edit keep the file mode and line endings; how a moved head shows as an error)
AppendCommit The same push, oldObjectId the expected head; the commit's one parent is that head in the page's examples. Shape, spike (as CommitFile)
CheckBranch, CheckChain, CheckCommit, CheckMerged, Parents Commits API for parents (GitCommitRef.parents) and Trees API to compare trees along the path, as the GitHub adapter does, not the diff API: the commit object has a commitTooManyChanges field, "indicates that commit contains too many changes to be displayed", so a change list could be cut off (Commits - Get Commits, GitCommitRef). A cut-off or unreadable answer is an error, never a pass. CheckMerged needs the merge commit of section 6. Shape, spike (trees by commit, same-mode comparison)
CommentChangeRequest Pull request threads: create a thread with one comment. To find the marker first, list the threads and read the comments written by the adapter's own identity, compared by identity ID, not by name; the marker must be a whole line. A pull request with more comments than the bound is ErrTooManyComments. A thread is active when created, and the optional policy "check for comment resolution" makes unresolved threads block completion (branch policies): the adapter creates its threads already resolved. Shape, spike (the thread status value, own identity ID, paging)
OpenChangeRequest Pull requests create with sourceRefName, targetRefName as refs/heads/..., title and description (Create). The create is not idempotent by itself: the adapter lists active pull requests for the source and target first (as openFor does) and returns the one found; the race of two creates is settled only if Azure DevOps refuses a second active pull request of the same pair, which the pages read do not say (spike; if it does not refuse, a create after a lost response needs the list again before and after). The description is limited to 4000 characters (Update), against GitHub's 65536: a body over the limit is ErrRejected. This is open (see Open questions). Shape, spike
FindChangeRequest Pull requests list with the source ref and all statuses. The "most recent" one is the one with the highest pull request ID; the adapter does not rely on the order of the list, which the page read for this ADR does not state (the list call was not read). A pull request from a fork (forkSource set, a field of GitPullRequest on the Update page) or to another target is ignored. Shape, spike (list parameters, paging)
GetChangeRequest Pull request by ID. Refused as not Shadewright's unless the repository ID is the bound one and the source is a shadewright/ branch. A pull request whose target a person changed to another branch of the repository is answered, never not found: its target is the change request's base, and the executor compares it with the target branch (amendment of 2026-11-19). A base name outside the rule for target branches is left out of the answer, the pull request is not. State: active is Open, abandoned is Closed, completed is Merged; mergeStatus fills fields and never withholds the answer (section 6). HeadSHA and MergeCommit: section 6. Direct, with section 6
EnableAutoMerge Pull request update with autoCompleteSetBy set to the adapter's identity and completionOptions (mergeStrategy squash, deleteSourceBranch). Auto-complete always waits for the required policies; the page says autoCompleteIgnoreConfigIds applies to optional policies only, and Shadewright sets none. There is no "only if the head is still X" condition on this call, which GitHub's expectedHeadOid gives. The guard is the required policies themselves (votes and status reset on a push) plus a read of the head before and after, and cancelling the auto-complete when it moved. bypassPolicy is never sent: the type of the adapter's request has no such field. Decided 2026-11-13: not implemented for Azure DevOps. AutoMerge stays false and people complete the pull request. Turning it on later takes an amendment of this ADR, after the spike on how a cancel behaves and a red-team look at the missing head condition. Shape, weaker guard, not built
ListChangeRequestsAnyBase Pull requests list with the source ref and no target ref, active only or all statuses as asked, for the request's own branch only; a pull request from a fork or of another repository is ErrUntrustedAnswer for the whole call, as in the interface, the bound MaxBranchChangeRequests holds (ErrTooLarge past it), and a base name outside the rule for target branches is left out of an entry, never the entry (amendment of 2026-11-19). Shape, spike (list parameters, paging, as FindChangeRequest)
CloseChangeRequestAnyBase As CloseChangeRequest, for a pull request from a shadewright/ branch of the bound repository to any target branch of it: the finalizer closes the request's own marked pull request wherever a person moved it, as ADR-0043 decides (amendment of 2026-11-19). Direct, spike (as CloseChangeRequest)
CloseChangeRequest Pull request update with status abandoned. The result for an already abandoned and for a completed pull request is not in the pages read: the adapter reads the state first and treats abandoned as done and completed as ErrConflict. Direct, spike (the update of a closed pull request)
UpdateChangeRequest Pull request update of title and description (both are on the list of updatable properties). Same 4000 character limit. Direct
CreateCheckRun No equivalent. A check run belongs to a commit and an App. The closest thing is a pull request status with a genre and a name, posted to a pull request; a status policy on the target branch requires genre/name to be succeeded (status policy, available checks). Genre shadewright, name review; the page says only the latest status of each unique context is shown, which is what "the latest run counts" needs (pull request status). States: InProgress is pending, Success is succeeded, Failure is failed. The method gets the change request number and the commit (section 1; the GitHub adapter ignores the number): the adapter reads that pull request and refuses unless it is Shadewright's and its source head is that commit. The status is posted on the pull request iteration whose source commit is that commit (iterationId in the request body), never on the pull request alone: section 4. Section 4 covers the gate. No equivalent, shape, interface change (decided, section 1), spike
ListComments (FeedbackSource) Pull request threads and their comments, each with an author identity and an update date. An Azure DevOps identity ID is a GUID; FeedbackAuthor.ID becomes an opaque string with an IDScheme (section 1), so the GUID is kept as it is; the stored hint uses the subject field of the API change in section 1. Shape, interface change (decided, section 1)
ListReviews (FeedbackSource) The reviewers of a pull request with their votes: 10 approved, 5 approved with suggestions, 0 none, -5 waiting for author, -10 rejected (GitPullRequest). A vote has no body and no commit ID. The commit it was cast on is not in the data. Personal votes only. A group or team can be a reviewer but cannot vote; when a member votes, the vote is rolled up into the group's entry, and the member's own entry lists those groups in votedFor (IdentityRefWithVote). So the vote of a hint author can show up under a group's ID. The adapter counts only entries of an individual identity (a group entry is recognized by the type of its descriptor, since isContainer is deprecated, same page) and compares the entry's own id with the hint author's identity, never through votedFor. A group entry is not an approval and never "someone who wrote no hint". No equivalent for the commit, section 4, spike (that a member's own vote always has an entry of their own identity, and how a group entry is told from a person's)
CanWrite (FeedbackSource) Whether a person may write to the repository. Azure DevOps permissions come from groups and inheritance, so "has the Contribute right" is an evaluation of another identity's effective permissions, not a field. ADR-0028 left the call open for this reason. Decided 2026-11-14: the test is membership, transitively, of one group named in the settings, read through the Azure DevOps Graph API on vssps.dev.azure.com (the memberships calls, for example Check Membership Existence). The calls take descriptors, not the identity GUID that comments carry, so a descriptor lookup comes first. A membership list traverses one level only (depth supports only 1; GraphRestClient), so "transitive" is the adapter's own bounded walk. It covers groups made in Azure DevOps and Entra groups added to it (Graph overview). The host pin of section 1 has the second host, and the read is in section 5. A failed read is an error for a retry, never "not a member" and never a pass. Reaching the bound of the walk is an error too (the identity is then not shown to be a member, and the call returns the error, never true). Whether the Graph API lists the members of an Entra group at all is not settled by the pages: the access FAQ says Azure DevOps "doesn't store or sync member status for Microsoft Entra groups" (Access via Microsoft Entra FAQs), while the Graph overview says memberships cover Entra groups added to Azure DevOps, and changes in Entra "might take up to 1 hour to be visible in Azure DevOps" (Manage access with Microsoft Entra groups). Not verified, spike: whether Azure DevOps materializes the members of an Entra group (when, and for a member who has never signed in), and how stale that can be. Until it is shown, a group that holds Entra groups is treated as unverified and hints stay off for it. Rejected: Microsoft Graph, the commenter's effective permission, and counting reviewers (see Alternatives). Decided, spike (the exact right, the descriptor lookup, Entra group members and their staleness)
IsAncestor (AncestryChecker) Merge bases or commit history on the Commits API; SHA-1 only is assumed, as for GitHub. spike

4. The merge gate of ADR-0028 on Azure DevOps

ADR-0028 section 5 needs a required check that completes with success only when the latest head has an approval from someone who wrote no hint. On GitHub the control is a required check run bound to the App as its source. Two things differ:

  • The check is a status policy bound to an identity. The required status policy shadewright/review is set to apply by default, so a pull request cannot complete before a succeeded status exists, and its authorized identity is the executor's identity, which the page describes as the setting that makes only that account's status count; left blank, any account counts (available checks). It also resets when new changes are pushed. This is the equivalent of "required with the App as expected source", and like it the adapter cannot make it so (see section 5 for what it can read). The same pages say a status of notApplicable removes a policy that applies by default. Whether one posted by another account lifts a policy that has an authorized identity is something this ADR cannot state: spike, case (5) below, and red-team item.
  • A vote carries no commit. GitHub's commit_id on a review lets the executor decide "an approval of this head". Azure DevOps has none. What it offers is the policy option that resets all reviewer votes when the source branch changes, and the option that the most recent pusher's vote does not count (branch policies). The executor therefore decides from recorded state and never compares timestamps. The rule, whatever the answer to the reset question below: the pass is bound to an iteration ID (the iteration the status is posted to, next bullet), and a vote counts only if it was cast on that iteration. A vote has no iteration, so the executor records, when it first posts pending on iteration N, the personal votes then present (the baseline). A personal approval counts for N only if it is not in that baseline, or it was seen at 0 after the baseline and cast again; and the iterations list, read before and after the votes, names the same N as the latest in both reads and N carries the recorded head. All of this is Azure DevOps's own IDs, no clock. The policy that resets votes is one of the preconditions of section 5, and where it resets together with the ref update the baseline is empty. A vote cast between a push and the server's reset would be a window GitHub does not have in this form; the rule closes it by failing closed (the vote does not count until it is re-cast). Reset on a push: not verified, spike. The pages say the votes are reset "whenever the source branch changes" (branch policies) but not that the reset and the new iteration appear together; the spike measures the window.
  • A vote can be taken back. A reviewer can reset their own vote to 0 at any time (\"Reset feedback\", review pull requests). Since #748 the GitHub gate reads the reviews and its own check run on every caught-up look while the request waits for approval, and writes the run when it shows something other than the reviews call for (ADR-0028, second #748 entry). For Azure DevOps the executor keeps reading the votes while the pull request is active: on every look at the pull request, the same one that reads the comments (the interval of --pull-request-poll-interval, no new timer). The state it compares is the record of the pass: the iteration ID and the reviewer identities whose personal approvals the pass rested on, written with the succeeded post. When none of those approvals stands any more on that iteration, the executor posts pending to the same iteration (the latest status of the context counts) and records the check as in progress again. The status is never left succeeded on a vote that no longer exists; a failed read of the votes is an error for a retry and leaves the record as it is. The CRD rule on ReviewCheck allows that move since #748 (on one head only Failed is final). Between two looks the status can be stale: the window is one poll interval, and the required minimum reviewers policy still counts the real votes, so completing needs an approval that stands.
  • The same hole on GitHub, closed by #748. A dismissed review had the same effect there: the gate did not look at a head again after it passed, so the check stayed success after the approval it rested on was dismissed. Since #748 the GitHub gate takes the pass back on the next look (ADR-0028, second #748 entry).
  • The status is bound to the iteration, not to the pull request. A status posted for the pull request alone is not tied to any code: a push between the executor's last head read and its succeeded post would leave an approval on a head nobody reviewed. The Create status call accepts an iterationId ("ID of the iteration to associate status with", minimum 1) (Pull Request Statuses - Create). The status page says a new iteration is created when the source branch changes, that posting to an iteration "guarantees that status applies only to the code that was evaluated and none of the future updates", and that with iteration statuses the policy's reset condition should be "reset status whenever there are new changes", which keeps the pull request from completing "until the latest iteration has a status of succeeded" (pull request status). So the executor reads the iterations of the pull request (Iterations - List), takes the iterations whose sourceRefCommit.commitId equals the head it recorded and, of those, the one with the highest iteration id. That one must be the last iteration of the pull request. No match is an error for a retry. When a newer iteration has the same commit (the list can hold several for one commit), the executor posts again to it. When a newer iteration has another commit, the head moved and nothing is posted. The status goes to the chosen iterationId. A push after that read creates a newer iteration with no succeeded status, and the required policy blocks it. The pages do not state every case, so these are spikes before the status slice, each against the test organization: (1) a succeeded posted on iteration N while the pull request is already at N+1 does not satisfy the policy; (2) a status posted without an iterationId does not satisfy a policy whose reset condition is on, or the adapter never posts one; (3) what the "requiring an iteration ID" advanced option mentioned on GitHub Advanced Security status checks means for this policy; (4) that a pull request without iteration support (supportsIterations false, or over 100000 modified files per the status page) is refused, never given a pull request level status; (5) that a notApplicable status posted by another account does not lift a policy that has an authorized identity. Until (1) and (5) are confirmed, hints stay off on Azure DevOps. Posting without an iteration is a rejected alternative.

If the vote-reset policy is missing, reviewer hints stay off for the repository, as ADR-0028 already does when the ruleset cannot be checked.

5. What the adapter must find in place before it writes

The adapter runs a preflight before the first write of a reconcile that opens or changes a pull request, and refuses to write when it fails. A failed read of the policies is an error for a retry, never "not found" and never a pass. The result is not stored in the cluster. The preflight only reads.

On the target branch:

  1. Policies exist and are enabled and blocking: minimum number of reviewers (at least one), with the option that resets all reviewer votes on new changes, and the option that bars the most recent pusher. Documented in branch policies. The same policy must not have Allow requestors to approve their own changes on (creator-vote-counts false in the CLI): the page says that otherwise the creator's vote counts toward the minimum, and the executor creates the pull requests. The same option of each automatically included reviewers policy (item 2) must be off too, since the page says each policy has its own setting. This is the counterpart of "it cannot approve its own PRs" in design 8.4: the contribute-to-pull-requests right lets the executor vote, so the policy is what makes the vote not count.
  2. Required reviewers by path who are people, for the paths that hold pipelines, policies, RBAC and Flux config. This is the Azure DevOps counterpart of CODEOWNERS in design 8.4: automatically included reviewers with path filters.
  3. The required status policy of section 4, with the executor as authorized identity, applying by default, reset on new changes. Only when reviewer hints are on.
  4. A required status or build policy that fails a pull request touching anything outside the allowed paths (the trusted path guard of design 8.4). Which pipeline runs it is out of scope.

On the executor's identity, which the preflight reads as its own effective permissions: it has Contribute, create branch and contribute to pull requests on the repository; it does not have "Bypass policies when completing pull requests", "Bypass policies when pushing", the exempt-from-policy permission, force push, edit policies or manage permissions (bypass permissions). The forcePushRequired update status of the Refs API is what a missing force push right looks like.

Membership read (decided 2026-11-14, held always unless the spike shows otherwise). The executor identity also reads group membership through the Azure DevOps Graph API on vssps.dev.azure.com. The scope vso.graph ("read user, group, scope and group membership information") is listed for OAuth apps (OAuth scopes); an Entra token for a managed identity carries no such scope, and the service principal page says Azure DevOps does not use Entra application permissions to authorize an application identity, only the access level, group memberships and resource permissions of an organization member. So the read is probably a right every organization member has by default, and the ADR words it as held at all times, with no grant that hints switch on or off. Not verified, spike: that the identity can read the Graph of the organization with the access it has for the five permissions, and whether anything narrower can be denied to it. No Entra directory permission is granted and no Microsoft Graph application permission. The preflight does not grant it.

Decided 2026-11-13: the preflight is in code, not a documented requirement. This is conditional on a spike in the first slice: can the executor read the policy configurations and its own effective permissions with only the access it is meant to have? The Policy API page read for this ADR (policy evaluations) says its scope is read of code and metadata; the policy configurations page and the permission evaluation call were not read. If either needs a right Shadewright must not have, the preflight is replaced by what the GitHub adapter has today: a requirement stated in the docs that the adapter cannot verify, and reviewer hints stay off for that repository (auto-complete is off anyway). The identity never gets such a right to make the preflight work. The diagram and the sequence below show the case where the preflight works.

6. Head and merge commit: what Azure DevOps reports

Two fields would be easy to misuse, and invariants 3 and 5 and ADR-0030's merge receipt depend on them.

  • lastMergeSourceCommit is "the commit at the head of the source branch at the time of the last pull request merge", and mergeStatus can be queued. It can lag behind the branch. So ChangeRequest.HeadSHA is the head of the source ref from the Refs API, not lastMergeSourceCommit. mergeStatus never turns an answer into an error, because GetChangeRequest returns an error only when the state is unknown (internal/providers/git.go) and an active pull request that is queued or conflicted must still be readable. It is mapped to fields of ChangeRequest: conflicts on an active pull request is Open with the Conflicted field that open PR #693 adds (not on main yet; this ADR depends on it); queued and notSet (not computed yet) are Open and not conflicted; succeeded is Open and not conflicted; rejectedByPolicy and failure are Open and not conflicted too, since a policy or a failed merge is not a conflict the executor can end the request for, and the reason stays in the logs. No value of mergeStatus is ever read as an approval: approval comes from the votes and the status of section 4. Values are those of PullRequestAsyncStatus on the Update page.
  • lastMergeCommit is "the commit of the most recent pull request merge", described as empty when the merge is in progress or failed (Update). While a pull request is active this is the host's trial merge. The adapter fills MergeCommit only when the status is completed, and only with a full commit ID that IsAncestor finds on the target branch; otherwise it is empty and the caller waits, which the ChangeRequest type already allows. spike: that for a completed squash and a completed no-fast-forward merge this is the commit on the target.
  • Merge types. Decided 2026-11-13: the preflight requires no merge type, but accepts only the types the spike has confirmed. ADR-0030's merge receipt works with a merge commit as well as a squash, since MergeCommit is read from the target branch as above. The spike covers all four types Azure DevOps offers (squash, no-fast-forward, rebase and fast-forward, semi-linear): for each, a completed pull request must give a commit on the target that IsAncestor finds. The preflight reads the allowed merge types of the branch policy and accepts the repository only when every type it allows is one the spike confirmed. A type that is not confirmed, or whose result cannot be read, is refused as unsupported, and a completed pull request whose merge commit cannot be shown stays without a receipt (NoMergeReceipt, ADR-0030, fail closed). The fallback, requiring only the confirmed types, needs the same policy read as requiring squash only, so Alternatives does not count it against squash only any more. Rejected: requiring squash only (see Alternatives).

7. Settings

The azureDevOps block holds the organization, the project, the repository, and the client ID and tenant ID of the executor's Entra identity (the counterpart of appClientID, with no installation ID and no signer). Organization and project are validated as the names Azure DevOps allows. When reviewer hints are on, the block would also name the group whose members may give hints (a group identifier, section 3, row CanWrite); the membership read is decided (section 3), but the field and the spike of its right come with the slice that builds CanWrite, and hints stay off for Azure DevOps until then. No value is a secret, and no organization name appears in the docs. This is open (see Open questions).

8. How the invariants hold

  • 3, Git only. Every write is a push to refs/heads/shadewright/..., a pull request, a thread, a status or an abandon. The adapter has no call to the policy, the security or the pipeline APIs that writes, and an import and endpoint allow-list test, to be written with the package (not existing yet), is meant to fail if one appears. The identity cannot bypass or force by permission (section 5), and the request types have no bypassPolicy. A merge that skips a required policy would need a permission the preflight refuses.
  • 5, idempotency. Branch and marker names come from the core unchanged. Branch create is idempotent by reading first and by oldObjectId; pushes by oldObjectId; pull request open by listing first; status by its unique context; abandon by repeating to the same value (auto-complete is not implemented); comments by the marker line. A write that may have gone through is never repeated in the same call.
  • 6, identities. Section 2. The analyzer and the verifier hold nothing for Azure DevOps, and the executor's identity has no right the analyzer would need. The one read beyond the five permissions is the group membership read of section 5, limited to the one organization and probably held by every organization member, so it is held always unless the spike shows otherwise; no Entra directory permission is granted to the identity that writes to Git.

9. First build task after this ADR: a read-only slice

One task: internal/providers/azuredevops with auth, Capabilities, ReadFile, ListDir and BranchHead, no write, no settings block yet (the constructor takes the values), a recorded-fixture test suite and the fake. It also answers every spike row of section 3 that is a read, the read of policies and own permissions of section 5, and writes down the answers as an amendment here, before any write method is built. The identity in the test organization gets the read permissions only for this slice.

Later slices, each its own task: the preflight and the commit and branch writes; pull requests and comments; the settings block and the executor wiring; the core interface change of section 1, then the status gate. Feedback and CanWrite come after the spike of the membership right (section 5). Auto-complete has no slice: it is not planned (section 3). The tenant question of section 2 is decided (2026-11-14) and is not part of slice 1. Order of work, decided 2026-11-14: Azure DevOps and Argo CD (ADR-0033) come after v0.5.0 and before the control plane (#559).

Overview and sequences

Planned. The cluster has three identities and only the executor has an Azure DevOps identity, through workload identity and a federated credential in Entra ID that yields a short-lived token for Azure DevOps. In Azure DevOps that identity is a user with Basic access in one dedicated group, allowed to contribute, create branches and contribute to pull requests on one repository, with a separate read of the organization's users, groups and memberships through the Graph API, and denied the two bypass permissions, force push, editing policies and managing permissions. The target branch has policies found in place before any write: minimum reviewers with votes reset on new changes, required reviewers by path, and a required shadewright/review status whose authorized identity is the executor. People approve and complete the pull request.

The planned path of one change, without auto-complete:

sequenceDiagram
    participant E as Executor
    participant I as Entra ID
    participant A as Azure DevOps
    participant G as Azure DevOps Graph
    participant H as Reviewer
    E->>I: Token for Azure DevOps, from the federated credential (planned)
    E->>A: Read policies and own permissions, refuse to write if any is missing (planned)
    E->>A: Read the head of the target branch (planned)
    E->>A: Push to shadewright/..., oldObjectId is the expected head (planned)
    Note over E,A: A moved head is refused, never forced
    E->>A: List active pull requests for the pair, open one if none (planned)
    E->>A: Post status shadewright/review pending on the iteration of the head (planned)
    H->>A: Vote approve
    A->>A: A push resets the votes, the status resets
    E->>G: Read the commenter's group membership, only when hints are on (planned)
    E->>A: Read the vote and the head, post status succeeded on that iteration (planned)
    H->>A: Complete the pull request
    E->>A: Read completed status and the merge commit on the target (planned)

Open questions

The six questions of the first draft are all decided: five on 2026-11-13 (identity: section 2; auto-complete: section 3; core interface: section 1; preflight: section 5; merge types: section 6) and CanWrite on 2026-11-14 (section 3, with the permission in section 5). Some of the decisions depend on a spike and say what follows if it fails. What is still open:

  • Spikes against the test organization: the rows marked spike in section 3, the five iteration status cases in section 4, the vote reset on a push and the personal vote entries (sections 3 and 4), the policy and permission reads of section 5, the merge commit of section 6, and the membership read for CanWrite (that the Graph read works, the descriptor lookup, Entra group members and their staleness, section 3 and section 5). The first slice (section 9) answers the reads; the others are answered before their slice is built.
  • Login rule: the exact pattern login takes for an Azure DevOps author (section 1): the characters a unique name can hold are not in the pages read, so the rule waits for a spike against the test organization.
  • Pull request body length: can the body for the largest plan pass 4000 characters (section 3, row OpenChangeRequest)?
  • Settings shape: one repository entry with organization and project repeated, or an organization level block (section 7)?
  • Withdrawn approval after a pass (GitHub): answered by #748 in ADR-0028 (second #748 entry): the GitHub gate reads the reviews and its own check run on every caught-up look while the request waits for approval, as long as it waits, and takes the pass back when the approval is gone.
  • Red team: the vote reset window and the status policy bound to an authorized identity (section 4) need a red-team pass before this ADR is accepted.

Amendments this ADR would need

Nothing below is changed by this draft. If the ADR is accepted, each of these texts gets a dated amendment, as the choices of 2026-11-13 change them. Each text was read for this section.

AGENTS.md invariants. Only invariant 6 changes.

  • Invariant 3 ("Changes go through Git only. Branch and PR, never a push to a protected branch, never bypassing branch protection or required checks. No changes to policies, pipelines, RBAC or secrets through the remediation path.") names no host. No change.
  • Invariant 6 says the executor has "the Git App" and the verifier has "no Git App". It needs wording that covers the executor's Azure DevOps identity and the verifier's lack of one. The same invariant text, as amended by ADR-0028, names "the commenter's permission" and "the check run shadewright/review"; on Azure DevOps the second is a pull request status on an iteration (section 4), and the first is a read of group membership through the Azure DevOps Graph API on vssps.dev.azure.com, decided 2026-11-14 (section 3), probably held by every organization member and so held always unless the spike shows otherwise (section 5). The text says so, and says that no Entra directory permission is granted to the executor.
  • Invariants 1, 2, 4 and 5 name no Git host. No change.

docs/design/8-gitops-on-github.md section 8.4. Line by line, with the Azure DevOps counterpart:

Line in 8.4 Counterpart
Required status checks, including a trusted path guard A required status or build policy (section 5, item 4).
.github/, CODEOWNERS, Flux config, RBAC and policy files owned by a human Automatically included required reviewers with path filters (section 5, item 2).
Stale approvals dismissed on new pushes, approval of the most recent push required The option that resets all reviewer votes and the one that bars the most recent pusher (section 5, item 1).
No direct pushes or force pushes to main Direct pushes are refused where a branch policy applies (about pull requests); force push is a permission. The preflight reads only the executor's own permissions, which must not include force push. It cannot show that nobody else has force push or the bypass rights on the branch: that is the permissions of other identities, and this ADR has not shown that the executor may read them (the clarification in section 5). That part stays a documented requirement the adapter cannot verify.
The App is never on a ruleset bypass list The executor's identity lacks the bypass permissions (section 5). Same limit: the identities of others are not checked.
Only five permissions, on one repository No counterpart in kind. The identity holds Contribute, create branch and contribute to pull requests, and its token is not scoped to a repository (see Consequences). One more read, decided 2026-11-14: group membership through the Azure DevOps Graph API (held always unless the spike shows otherwise), scoped to the one organization, with no Entra directory permission (section 5).
It cannot approve its own PRs None before this draft: the right to contribute to pull requests lets the executor vote. Added to the preflight in section 5, item 1 (the requestor's vote must not count).
The reviewer hints paragraph (shadewright/review, checks: write, the required check with the App as expected source) The status policy bound to an authorized identity, section 4. No fifth permission for the check; the hint author test ("the commenter's permission") needs the membership read of section 5.
Scenario clusters, cluster/<cluster> with mirrored rules The same preflight on that branch; a policy can apply to a branch prefix.

Other texts.

  • docs/design/9-identity.md section 9.2 ("Executor and the GitHub App key"): the executor signs the App JWT through Key Vault and exchanges it for an installation token. On Azure DevOps there is no key and no signing: the executor's federated identity asks Entra ID for a token for Azure DevOps. Section 9.2 gets a short counterpart and says its key text is the GitHub case. The rule "no PATs, no client secrets, no long-lived API keys" in the introduction still holds.
  • docs/threat-model.md, asset table (about line 19): "The GitHub App private key and its installation tokens", "the only write access to Git". For Azure DevOps the asset is the executor's identity and its short-lived tokens, which are not scoped to a repository. A second row or a wider wording. It also gets a line for the membership read: the identity can probably read users, groups and memberships of the one organization on a second host at all times, not only while hints are on (an organization member can do so by default; section 5), so a stolen token can read the organization's directory but no Entra tenant data.
  • docs/threat-model.md G6.1: the verifier has "no Git App", the invariant 6 wording. G6.4 ("The App key never exists in a pod") also names the key: its counterpart is that there is no key at all.
  • ADR-0028, line 30: "No new GitHub App and one new permission" describes the GitHub adapter and lists Azure DevOps as planned. This ADR says what the planned adapter needs (an authorized-identity status, no new permission).
  • ADR-0028, line 39 (section 2 rule 1) and the Azure DevOps example (about line 267): "the Contribute right on the repository" as the test of who may give a hint. The decision of section 3 (membership of one group, read through the Azure DevOps Graph API) replaces it on Azure DevOps, so this text gets an amendment saying the test is host specific.
  • ADR-0028, section 5 (the merge gate) and its alternatives (about line 310): the gate is "a required check run" with "the Shadewright App as the expected source", and a commit status is rejected because anyone with push access can post one. On Azure DevOps the gate is a pull request status bound to an authorized identity, so this ADR adds a second form of the gate and relies on a protection that ADR-0028 judged unclear on GitHub.
  • ADR-0004, line 17: "Azure DevOps-specific behaviour (auto-complete identity, branch policies with path filters) is designed later, against the same approvalRequired semantics." This ADR is that design; ADR-0004 gets a pointer here. Auto-complete is not planned for Azure DevOps (section 3).
  • internal/providers/git.go (code, not text) and its doc comments: FeedbackAuthor.ID becomes an opaque string with an IDScheme and CreateCheckRun takes the change request number (section 1), a change in the GitHub adapter, the fake and the ADR-0028 controller code, with the additive HintAuthor API change of section 1 (api/v1alpha1/hint_types.go, released in v0.4.0). docs/design/2-architecture.md (about line 249) names CreateCheckRun and the author identity and is re-read when that task lands.
  • ADR-0030: no change. The merge receipt works with any merge type (section 6).
  • ADR-0006: no change; it stays the GitHub case.
  • ADR-0029 needs a dated amendment (section 6) and a runbook step. It says the executor "may only sign with the one key" and pins every Azure role assignment by test. That test sees Azure RBAC only. The executor's Azure DevOps rights (organization user, access level, membership of the dedicated group, section 2) are outside Azure and outside the test, and no Microsoft Graph app role assignment is granted for the membership read (section 5), so the test has no Entra grant to miss. The amendment says that the pinned test covers Azure role assignments, lists the Azure DevOps grants as a second, documented set that a reviewer checks by hand (or a Terraform check, if the organization side is managed as code), and that this set is part of invariant 6. The managed identities are in foundation/ and outlive a lab, so under option (a) of section 2 the organization membership is added once, not each session; the federated credentials are in lab/ and are recreated with the cluster. Under option (b) the app registration's federated credential names the cluster's OIDC issuer, which changes with the cluster, so it is recreated each session. The runbook step (organization user, group membership, and for (b) the credential) belongs with the lab runbook, written with the first slice.

Consequences

  • A second host needs no change in the controller or the analyzer. The change in the core is section 1 (an opaque author ID and a change request number on the check, with an additive change to HintAuthor), and the settings enum grows by one value.
  • No key and no secret for Git access, so ADR-0006's Key Vault signing has no counterpart. In exchange the token is not scoped to a repository, so a mistake in the group or the permissions of the identity is a wider mistake than a GitHub App installed on one repository. The preflight and the denied permissions are what hold it. That is the one place this is weaker than ADR-0006.
  • Reviewer hints on Azure DevOps rest on votes that carry no commit and on a status whose protection is the authorized identity. Both need the red team and the test organization before hints are turned on for it.
  • Azure DevOps gives one push for a commit where GitHub needs four requests, which is simpler, but its atomicity and mode handling are unconfirmed (spike rows).
  • The pull request description limit of 4000 characters may force a shorter body on this host.
  • Each application identity costs an access level in every organization it is in.
  • Azure DevOps Server is not covered; its REST versions differ.

Alternatives considered

  • Azure DevOps first, as in the original plan. Rejected in ADR-0004; nothing here changes that.
  • A PAT in Key Vault (identity option c). Easier to start, the same everywhere. Tied to a person's account and lifecycle, which Microsoft's page lists as the thing application identities avoid, and a stolen value is usable from anywhere until revoked. Not supported.
  • Only a service principal, for lab and elsewhere (identity option b alone). One option to maintain, but the lab then needs an app registration and its federated credential where a managed identity already exists (ADR-0029). Kept as the supported option for other tenants.
  • Auto-complete for Azure DevOps (option b of the former question 2). Saves a click, but the call has no "only if the head is still X" condition, so the guard would be the policies plus a head read before and after and a cancel, a weaker control than GitHub's expectedHeadOid. Not chosen: people complete the pull request.
  • Map the GUID to an int64 and find the pull request from the commit (core option b). No core change, but a hash of an identity is a bad key and a commit can match more than one pull request, so the check could land on the wrong one. The cost of the chosen change is one task touching the GitHub adapter, the fake and the ADR-0028 code.
  • Drop the preflight for a documented requirement from the start. No read rights to worry about, but nothing then shows that the policies are in place before the first write. It is the fallback if the spike of section 5 fails.
  • Hint rights by effective permission, or by being a reviewer (CanWrite options a and c of the first draft). Effective permission is an evaluation for another identity under inheritance, with no single field to read; "is a reviewer" lets anyone made a reviewer give hints. Group membership is explicit and checkable.
  • Microsoft Graph for the membership read. Host graph.microsoft.com, a third host and a second token audience. checkMemberGroups is transitive and takes up to 20 groups, but for another user the least privileged application permissions are User.ReadBasic.All plus GroupMember.Read.All, granted by app role assignment to the identity and tenant wide: it can read every user and every group membership in the Entra tenant, far beyond one repository (checkMemberGroups). That is a tenant wide directory read on the identity that writes to Git, which invariant 6 is meant to keep small. Groups with hidden membership would need Member.Read.Hidden. It also sees Entra groups only, not groups that exist only in Azure DevOps, and needs the commenter's Entra object ID, which a pull request comment does not carry. Not chosen.
  • Require squash only on the target branch. A simpler receipt, but it refuses repositories that use another merge type for no reason the receipt has. It needs the same policy read as the chosen rule (accept only spiked types), so it saves nothing there.
  • A service hook or webhook design instead of polling. Out of scope; the executor polls pull requests today, and Azure DevOps would be the same.
  • Mirror to GitHub and open pull requests there. Avoids the adapter, but pull requests in a second system are not where the code lives and break the "branch and PR in the repository that holds the code" idea of invariant 3.
  • Post the status on the pull request without an iteration. Rejected: it is tied to no code, so a push between the head read and the post leaves an approval on a head nobody reviewed (section 4).
  • Use the diff API for the branch checks. Shorter, but a commit can report too many changes to show, so a cut-off answer could pass as a small one. Trees are compared instead.
  • One generic Git adapter over plain Git (clone and push). No pull request or policy model, so nothing to find in place and no status. Not chosen.

Sources

Read for this ADR on 2026-11-13, Microsoft Learn:

Not read yet, so nothing is stated from them: Items, Trees, the pull request list call, Pull Request Threads, Policy Configurations, the Security pages, the Graph descriptor and storage key pages, and the rate-limit page. Slice 1 and later slices read them.

Amendments

  • 2026-11-19: the method map follows the GitProvider interface as built for #892 and recorded in ADR-0030 (entry of 2026-11-19) and decided in ADR-0043. GetChangeRequest no longer refuses a pull request whose target is another branch of the repository: it answers it with that target as its base, so an adapter built from this map does not answer a pull request a person moved to another target with not found, which the executor would take for gone and release the lock. Two rows are added, ListChangeRequestsAnyBase and CloseChangeRequestAnyBase.