Skip to content

feat(azure-devops): add the Azure DevOps integration - #251

Merged
artempartos merged 27 commits into
developfrom
artempartos/review-azure-devops-integration
Sep 14, 2026
Merged

artempartos merged 27 commits into
developfrom
artempartos/review-azure-devops-integration

Conversation

@artempartos

@artempartos artempartos commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Adds azure_devops as a project-scoped integration alongside GitHub and GitLab, and revises the design doc it is built from after a review of both the code baseline and Microsoft's current documentation.

What a user can do

Connect an Azure DevOps organization and one Azure project inside it, attach repositories, and give agents tools for pull requests, review threads and Azure Boards work items. Agents clone, fetch and push with ordinary git; pull requests, threads and work items go through eighteen azure_devops_* tools.

Setup is operator-assisted by design (rake azure_devops:approve / :verify / :scope / :disable / :list), because a successful app-only API call proves the application can reach an organization and proves nothing about whether the company asking owns it. There is no separate enable flag: the feature is offered exactly when an operator has configured an Entra application (or switched on the PAT fallback), since a boolean beside those credentials could only ever disagree with them.

Review findings the design changed for

The doc was written against 1a1d660d; most of its claims about this codebase check out exactly. Five did not:

  • The git credential endpoint was to be authenticated by the session's mcp_key. That key is handed into the container as the aixle-tools X-Session-Key header, so the agent-driven process already holds it — and CloudAuth::SessionKey records this repository having made the opposite call once already, for the same two reasons (reach, and coupling revocation to disable_mcp_token). The endpoint now uses a derived per-session key in that shape, and a test asserts the mcp_key is rejected.
  • The remote Azure DevOps MCP server is no longer "documented as preview" — Microsoft's current guidance is "choose remote first"; only its ELM toolset is preview. (The resource GUID and the no-DCR claim were correct.)
  • Four Repository rules block an Azure row and none were named: the CODE_HOST_PROVIDERS allowlist, set_clone_url, the full_name format (which rejects a space as firmly as the : discriminator, so the doc's own example failed twice over), and owner_name's meaning.
  • A service principal cannot be added to an MSA-backed organization at all, which makes PAT the only path there rather than a preference.
  • The git transport risk ordering was inverted: Microsoft documents header injection via --config-env, and documents no authtype-negotiating helper. The core release ships the documented path; authtype is detected per image and falls back.

Shape

  • AzureDevopsInstallation is the approved company→organization binding and holds the encrypted client-credentials token cache; Integration stays the project connection and points at it.
  • AzureDevops::CredentialProvider is the single authorization chain — active connection, company-owned installation, approved project scope, enabled capability — and every surface goes through it.
  • Repository identity is the organization + project + repository GUID triple; full_name is display only, so a rename cannot orphan a row.
  • Tools::CallExecutor's GitHub expansion is now declared (repository_binding :legacy_github) rather than inferred from an argument spelled repository_id. Container tools keep it unconditionally; no session app tool had declared that argument, so nothing needed migrating.
  • Checkout paths are resolved once per session and persisted, so two repositories named api stop overwriting each other.
  • Agent mutations run through an operations ledger: a replayed key returns the first result, a different payload is a conflict, and a dispatched write whose answer never arrived is outcome_unknown rather than retried.

Two defects found by the tests

  • AzureDevops::Client let Faraday::ConnectionFailed escape as a vendor exception instead of becoming an unknown outcome on a write.
  • A new connection could never be verified, because the credential resolver required the integration to already be active — connect and repair now pass an explicit allow_inactive that nothing else does.
  • Building the integrations page listed every approved organization's Azure projects, putting a live Azure call and a token acquisition on the critical path of a page most visitors are not connecting anything from. The connect modal now asks for one organization's projects when it needs them.

Parity extension (§11 and the §8.1 parity tools)

Reviewers, votes, branch-policy evaluations, Pipelines builds, and pull request completion. Completion has three guards and none is optional: the pull_requests.complete capability, which a new connection does not get; the source commit the caller reviewed, so a push landing in between makes Azure refuse rather than merge unseen code; and bypassPolicy: false with a re-read, because Azure completes asynchronously and a 200 is acceptance rather than a merge.

Service Hooks arrive at an endpoint whose id routes and whose subscription password authenticates — Azure sends no signature, so copying the GitHub receiver's HMAC verification would have accepted every request. Deliveries are recorded and deduplicated before being acted on, and a duplicate is acknowledged rather than failed, because failing one only earns another redelivery and pushes the subscription towards probation, where it silently stops delivering.

Nothing trusts a payload: the job re-reads the build or the policy evaluations, since git.pullrequest.merged fires for a merge that failed on a conflict exactly as for one that landed. Gates route on the repository GUID rather than through Repository.project_ids_for, whose full_name fan-out would deliver one organization's build to another's board, and a verdict about a commit the gate was not created for leaves it pending.

Service Hooks are the one part that needs a publicly reachable host, since Azure posts inbound; AZURE_DEVOPS_WEBHOOK_BASE_URL covers a deployment whose own domain is not reachable from Azure.

Not in this PR

Submodules and Git LFS are untested.

Checks

rubocop, brakeman, zeitwerk:check, tsc, eslint, steiger clean. Backend 5298 runs / 0 failures, line coverage 91.11% (floor 85). Frontend 1328 tests / 107 files passing, coverage above every floor. Backend runs used a throwaway per-run Postgres rather than the shared aixle_test.

No public URL is involved anywhere in the core release — every call is outbound (Entra, dev.azure.com, and the container-internal credential endpoint), there is no OAuth redirect, and webhooks belong to the parity extension. A PAT-mode connection is the shortest path to a working local smoke test.

Not yet exercised against a live Azure tenant — the design's §13 spike (a tenant distinct from the app's home tenant, two organizations sharing one principal, a long-lived session, a non-default work-item process) is the next step.

🤖 Generated with Claude Code

@artempartos
artempartos force-pushed the artempartos/review-azure-devops-integration branch from 1813c4c to 7343572 Compare September 11, 2026 21:13
artempartos and others added 15 commits September 13, 2026 01:26
…review

Credential-endpoint authentication moves off the session mcp_key to a derived
per-session key, matching the decision CloudAuth::SessionKey already records;
the Repository validations that block an Azure row are named explicitly; the
Git transport is reordered so the Microsoft-documented header-injection path
ships first and authtype negotiation follows a live spike; and the MSA-backed
organization limit, the Entra token lifetime, and the service-principal
onboarding identifiers are stated rather than assumed.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>
Adds azure_devops as a project-scoped provider alongside GitHub and GitLab:
an approved company-to-organization installation carrying the Entra
client-credentials token cache, a project connection bound to one Azure
project, GUID-based repository identity, REST services for repositories,
pull requests and Boards work items, and eighteen agent tools behind an
explicit authorization chain.

Session git works through a credential helper and a derived per-session
key rather than the session mcp_key, matching the decision CloudAuth::
SessionKey already records, and clone credentials travel as a 0600 file
read into the environment git inherits rather than through argv.

Repository expansion in Tools::CallExecutor is now declared with
repository_binding rather than inferred from an argument named
repository_id, so a native provider handler keeps its own arguments.
Checkout paths are resolved once per session and persisted, so two
repositories named api no longer overwrite each other.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>
The connect modal offers only organizations the company has been approved
for, and only the Azure projects inside that approval's scope — an
arbitrary organization URL is never enough. PAT mode is behind a
deployment switch and says plainly that it acts as the token's owner
rather than as the application.

The repository picker carries the Azure repository GUID alongside the
display name, because a name would reach a same-named repository in
another project and would break on a rename.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>
…edential vending

Adds the operator onboarding rake tasks, the user-guide section, and the
tests for what the integration actually promises: the credential endpoint
rejects the session mcp_key and another session's key, an approved
binding is what grants access rather than a submitted id, a dispatched
write whose answer never arrived is reported as unknown instead of
retried, and two repositories named api get different checkout paths.

Two real defects surfaced and are fixed: AzureDevops::Client let
Faraday::ConnectionFailed escape as a vendor exception instead of
becoming an unknown outcome on a write, and a new connection could never
be verified because the credential resolver required the integration to
already be active.

The GitHub repository expansion tests now state the declared contract:
container tools keep it unconditionally, an app tool opts in, and one
that does not opt in keeps its own arguments.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>
The installation's unique key is (company, tenant, organization slug)
rather than the four-column identity the design proposed: three of those
columns are null until verification and Postgres treats NULLs as
distinct, so that index would have allowed unlimited duplicate pending
rows. The credential resolver's one allow_inactive exemption, the split
between the clone's header injection and the helper's ongoing vending,
and the operator rake tasks are stated where the design left them open.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>
develop landed 20260911140000_normalize_asset_folders while this branch
was open, and two migrations sharing a version abort db:migrate outright.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>
Building the integrations page listed every approved organization's Azure
projects, which put a live Azure call and a token acquisition on the
critical path of a page most visitors are not connecting anything from.
The connect modal now requests one organization's projects the first time
it is selected, the same partial-reload shape the repository picker uses.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>
…the enable flag

AZURE_DEVOPS_ENABLED sat next to the credentials it duplicated and could
only ever disagree with them: "enabled but unconfigured" fails at the
first Azure call with a confusing error, and "configured but disabled" is
a switch somebody has to remember to flip after doing all the real work.
The feature is now offered exactly when an operator has set up something
that can reach Azure.

PAT mode keeps its setting because it cannot be derived — that credential
arrives per connection from a user rather than from deployment
configuration, and permitting connections that act as a person is a
policy decision rather than a copy of one.

The credential-failure test moved with the meaning: clearing the client
secret now means "nobody configured this", so the operator-problem case
is exercised where it actually occurs, with Entra rejecting the
credential. Adds the positive PAT connect coverage, including that the
wire carries Basic rather than a bearer token and that no Entra exchange
happens in that mode.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>
Completes the design's §11 and the §8.1 parity tools.

Reviewers, votes, branch-policy evaluations, Pipelines builds and pull
request completion. Completion carries three guards and none is optional:
it needs the pull_requests.complete capability, which a new connection
does not get because merging should not be acquired by accepting a form's
defaults; it requires the source commit the caller reviewed, so a push
landing in between makes Azure refuse rather than merge unseen code; and
branch policies are never bypassed, with a successful response treated as
acceptance rather than a merge until a re-read confirms it.

Service Hooks arrive at an endpoint whose id routes and whose
subscription password authenticates — Azure sends no signature at all, so
copying the GitHub receiver's HMAC verification would have accepted every
request. Deliveries are recorded and deduplicated before they are acted
on, and a duplicate is acknowledged rather than failed, because failing
one only earns another redelivery and moves the subscription towards the
probation state where it silently stops delivering.

Nothing trusts a payload. The job re-reads the build or the policy
evaluations, because git.pullrequest.merged fires for a merge that failed
on a conflict exactly as for one that landed. Gates route on the
repository GUID rather than through Repository.project_ids_for, whose
full_name fan-out would deliver one organization's build to another's
board, and a verdict about a commit the gate was not created for leaves
it pending.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>
Three findings made half the parity extension dead code. The two Azure
gate types were known to Gate, GateService and Ci::GateProbe but not to
BoardCreateGate's allowlist, so no Azure gate could be created at all;
SubscriptionService's create and status calls had no caller, so no
subscription ever existed and the receiver always answered 401; and
ensure_all! built a second row for an event type the unique index already
covered, raising a DB error no rescue caught.

Two were unsafe. The build resolver routed gates on the repository id
taken from the webhook payload without checking this connection owns it,
where the gate scope looks repositories up across every project — the
repository now comes from Azure's own answer and is verified. And
System.TeamProject is the project NAME, so scoping a work item compared
it to a GUID: the only check that ever ran was against a cached display
name, absent or stale, and both failed every read permanently.

The rest: mark_error raised out of the error handler in exactly the case
that reaches it; raw provider text went into settings, which is
serialized to the browser whole, and survived a repair; a process-rule
rejection was reported as a revision conflict, which loops an agent
forever; the payload limit ran after the body was already parsed; the
credential helper and three URL builders hardcoded dev.azure.com while
api_host is configurable; the authtype probe had no caller; the workspace
path map was overwritten by a recomputation, contradicting its own
docstring; capabilities were unfiltered on create and unclearable on
update; and WIQL escaping ran before truncation, which can split an
escaped quote pair.

Adds FakeAzureDevops and stub_azure_devops! per docs/testing.md R3/R4 and
moves the tool tests onto them, leaving WebMock in the adapter contract
tests where the doctrine puts it. The fake runs every call through the
real CredentialProvider, so the authorization chain those tests are about
stays live and only the HTTP call is replaced.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>
The design says what the onboarding sequence is; this is the operator
walking through it, in order, with the errors they will actually hit and
the one distinction that matters when something fails — whether Entra
refused the credential or Azure DevOps refused the identity.

Leads with the mode decision, because it is the only choice that changes
the work: a single-tenant registration skips cross-tenant provisioning
entirely and is the same code path, so a first live test should not start
by solving the hardest version of the problem.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>
The portal now offers four account types under new labels, two of which
are never right here — a personal Microsoft account cannot be a service
principal in Azure DevOps. Also records the check that decides between
the two that are: single-tenant reaches only organizations backed by that
directory.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>
The runbook recommended single-tenant for a first run on the grounds that
it skips cross-tenant provisioning. It does not: a multi-tenant
registration creates its service principal in the home tenant the same
way, so a first test against an organization in your own directory is
identical work either way and §3 is skipped either way.

Single-tenant is a dead end rather than a simpler start — another tenant
cannot provision a service principal for such an application at all — so
the advice traded a future migration for no present saving.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>
…g it

Replaces operator-assisted onboarding. The rake task is deleted, and no
admin console step takes its place: the operator was never adding
information, they were vouching, which is unauditable and is the one
place a mistyped company id grants one customer access to another's
organization.

The requester proves it instead. They name the organization; its Entra
tenant comes from Azure's own WWW-Authenticate header rather than from
anyone pasting a GUID. They supply a personal access token, which is used
to call an endpoint only an organization administrator can call — the
same authority that would otherwise add the application by hand, so
holding it is the claim being made. That token then adds the application
to the organization with a Basic access level and Contributor rights on
the chosen project, using the application's object id from the oid claim
of the token Entra just issued. Access is confirmed with the
application's own credential before the binding is recorded, so a binding
never promises access nobody has demonstrated.

The token lives for one request: never stored, never logged, and not what
the connection runs on afterwards. It is asked for only on the first bind
of an organization and when widening its approved projects — after that
the binding is the proof.

The page no longer lists the organizations a company holds. Enumerating
them told every project member which Azure organizations the company
works with and bought nothing, since the user names the one they mean.
Checking whether our application has access instead would have been the
hole this whole model exists to close: with a multi-tenant application
that is legitimately true for every customer who installed us.

Azure answers an invalid personal access token with a 302 to an HTML
sign-in page rather than a 401, so the rule is whether JSON came back.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>
Caught by CI, not locally: the check I was running piped eslint through
grep for the word error, and eslint colourises it, so the pattern never
matched and the check could not fail. Exit status from here on.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>
@artempartos
artempartos force-pushed the artempartos/review-azure-devops-integration branch from fb3e1b2 to 1507637 Compare September 12, 2026 21:34
artempartos and others added 12 commits September 13, 2026 02:51
…ve tenant

Both defects were invisible to the suite for the same reason: the contract
tests pin the adapter to payloads I wrote myself, so wherever my picture of
Azure was wrong, the test agreed with me. Only real traffic disagreed.

A pull request has no `_links.web`. Azure returns self, repository, branches
and commits there and nothing else, so reading a browser link meant every tool
result promised a `url` and shipped none. It is now built from the
repository's own `webUrl` — provider data rather than a guess — and still
rejected unless it is https on the configured API host.

A failed JSON Patch `test` on `/rev` is 412, not 409. That test is the
optimistic lock the work item guard is built on, so every stale-revision
write reached the agent as a generic provider error instead of a conflict
carrying the revision to re-read. The guard worked; the instruction to retry
did not survive the trip.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>
…n the picker

An earlier draft exposed the 23 handlers as an attachable "Azure DevOps"
picker group. That was the wrong shape twice over. The project already says
everything the attachment would say — there is a connection, and the session
has an Azure clone — so picking was a second, weaker way to repeat it. And
because a picker takes a subset, it let someone attach half a working set:
an agent that can open a pull request and then cannot answer the review it
just triggered.

Two rules rather than one, matching how the tools are scoped:

  azure_repositories_attached   the 13 tools taking a repository_id, which
                                must already be attached to the session
  azure_integration_connected   the 10 taking an integration_id — work items,
                                builds, list_connections

The split is load-bearing. A repository tool has nothing to act on without a
clone, so injecting it unconditionally would only produce a tool that answers
"not attached to this session". A work item tool is scoped by the connection,
so a project keeping its Boards in Azure while its code lives elsewhere still
reaches it — a case a repository-only rule would make unreachable, with no
picker left to work around it.

The tag is hidden and every handler declares user_attachable false, so nothing
falls through to the ungrouped list. RegistryTest asserts the two halves meet:
no Azure tool may be both unpickable and uninjected, which is how one would
quietly become unreachable.

Nothing here widens what an agent may do. Injection decides what is offered;
AzureDevopsContext still decides what a call may touch, and the connection's
capability profile still decides which calls are sent at all —
complete_pull_request is injected like the rest and still refuses unless
pull_requests.complete is ticked, which it is not by default.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>
Three defects, all found by pointing the integration at a live tenant and a
real pipeline rather than at payloads this repository wrote itself.

Policy Evaluations has never left preview. Asking for plain 7.1 gets a 400
VssInvalidPreviewVersionException, so every azure_devops_pr_policies_satisfied
probe came back `validation_failed` and the gate went stale on a pull request
whose policies were perfectly readable. The gate type could not resolve at all.

The stale-gate diagnostic read `metadata['repo_full_name']`, which Azure gates
do not carry — they route on the repository GUID, because a display name there
is mutable and a gate keyed on one breaks when somebody renames a repo. The
operator message came out as "pull request 813 on  cannot be read", naming no
repository. `Gate#repository_label` now resolves the GUID back to a name and
both the reconciler and the probe use it.

Service Hooks were provisioned once, at connect time, best effort — and the
comment pointed at a rake task that was deleted with the rest of the operator
onboarding. A connection made while webhooks were switched off, or by an
identity that could not create them yet, would never get them, and its gates
would depend on the five-minute recovery sweep forever. Testing the connection
is now the retry path; `ensure_all!` is idempotent.

Verified end to end against dualbootpartners: a pipeline created by the
service principal itself, a queued build, a board task whose
azure_devops_build_completed gate the sweep resolved with Azure's own verdict
(`resolved`, conclusion `succeeded`). The webhook fixture is now shaped from
Microsoft's published event reference, with the three fields the resolver
routes on pinned against their documented names.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>
Creating a Service Hook subscription needs *View subscriptions* and *Edit
subscriptions*, which Azure grants to project administrators only. The
application is entitled as a project Contributor, so it could never create one:
CI gates still resolved, but always through the five-minute recovery sweep,
never on the event that caused them.

The obvious fix was to create the subscriptions during onboarding with the
administrator's own token, which is already in hand. That works and is worse.
Azure does not trigger a subscription whose creator has lost access to the
resource, so the events would stop on the day that person left the company and
nothing would say so — the sweep would quietly cover for it. A webhook that
stops silently is worse than one that was never created, and "an employee
leaving changes nothing" is the reason this integration runs on a service
principal at all.

So the token is spent on a grant instead: one access control entry, View + Edit
on the ServiceHooks namespace scoped to the approved project, and from then on
the application creates and re-creates its own hooks — at connect time and on
every later connection test. The namespace id and the permission bits are read
off the organization itself rather than remembered.

Microsoft documents the ServiceHooks namespace as internal and publishes no
token format for it, so `PublisherSecurity/{projectId}` is not taken on trust:
onboarding proves the grant by having the application actually create a
subscription afterwards, and a wrong token shape surfaces as a failed
provisioning rather than as an entry that grants nothing.

The grant is best effort. An organization that refuses it gets a connection
that works, with gates resolving on the sweep. The administrator's token now
needs Security (manage) alongside Member Entitlement Management; the modal and
both guides say so, and say what the second scope is spent on.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>
A connection named exactly one Azure project, which was wrong for the ordinary
case. A company keeps its code and its boards in several projects, and one
connection per project multiplied the connections without adding any isolation:
they all run on the same service principal, against the same approved
organization. The GitHub shape — one installation, many repositories — is the
one that fits.

Two lists now, and they are deliberately not the same list. The INSTALLATION
records what the company approved when it proved control of the organization;
the INTEGRATION records which of those the connector chose. Both are checked on
every call, because an installation's approved scope can be narrowed after a
connection was made.

The project is now an argument rather than a property of the credential.
`CredentialProvider.resolve!(integration, project_id:)` refuses an id the
connection does not cover — the ids are visible to anyone who can read the
organization, so naming one is not authority to reach it — and refuses to guess
when several are possible. `azure_default_project_id` is nil unless there is
exactly one: returning "the first" would make which project an agent just filed
a bug in depend on row order. Repository-scoped calls take the project from
`repository.external_project_id` and never need one; work item and build tools
take an explicit `azure_project_id`.

Service Hook subscriptions needed a migration. `publisherInputs.projectId` is
part of the subscription, not of the connection, so the old unique index on
(integration, event_type) would have left every project but one silently
without events, with its CI gates falling back to the recovery sweep and
nothing saying why.

Repository discovery spans the set: one unreadable project no longer hides the
others, and a repository GUID is searched for across the covered projects
rather than assumed to live in "the" one. Connection verification now proves
EVERY selected project is readable — a connection that half works is one whose
failures arrive later, on a tool call, with nothing pointing at the cause.

Connections made before this keep working: the old scalar `azure_project_id` in
settings reads as a one-element list rather than being migrated, because for
those rows the scalar is the truth.

Also in here, both from live use:

Merging is enabled by default. An integration that can open a pull request but
never land it leaves the last step to a person for no security gain — Azure's
branch policies decide whether a merge is allowed, `bypassPolicy` is never
sent, and the expected-commit guard still refuses a source branch that moved.
Unticking it stays a real switch: the request is then not sent at all, and the
test now proves that rather than proving the default.

A token that administers the organization but cannot list its projects used to
verify happily and hand back an empty dropdown — nothing to pick, nothing to
explain, because any non-200 became `[]`. It now names the missing scope. The
administrator's token needs Project and team (read) alongside Member
Entitlement Management and Security (manage); all three are behind "Show all
scopes" in Azure's token form, which the guides now say.

BREAKING CHANGE: `IntegrationService#create_with_installation` and
`#create_with_pat` take `azure_project_ids:` instead of `azure_project_id:`.
The HTTP endpoint still accepts the old single value.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>
Subscriptions carried `buildStatus: "Completed"`. It reads perfectly and is not
one of the values Azure accepts — `""`, Succeeded, PartiallySucceeded, Failed,
Stopped, as `_apis/hooks/publishers/tfs/eventtypes` will say if asked. Azure
does not reject an unrecognized filter value: it accepts the subscription,
reports it `enabled`, records no error, and matches nothing.

So the only symptom was silence. Three healthy-looking subscriptions, a build
that completed, zero notifications queued on Azure's side, zero deliveries on
ours, and gates closing ten minutes late on the recovery sweep as though
webhooks had simply never been configured. Nothing in any log, status or
dashboard pointed at the cause.

Filtering by result would be wrong even spelled correctly. A gate has to hear
about a FAILED build too, or it waits for a verdict that already happened, and
`build.complete` fires only on completion — the event is the filter, and the
resolver re-reads the build for the verdict rather than trusting the payload.

Verified end to end against dualbootpartners after the fix: pipeline → build
3636 → Service Hook → ngrok → the webhook endpoint → the delivery ledger →
the resolver → gate 12 resolved `succeeded`, with no `source: reconciliation`
in its resolution data and the sweep never run. The event closed it.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>
Service Hooks had their own environment variable with no default, while the
comment beside it claimed it defaulted to the deployment's domain. It did not.
`webhooks_enabled?` was literally "is that variable set", so a production
deployment with DOMAIN configured correctly had Service Hooks off — every CI
gate closing ten minutes late on the recovery sweep, nothing in any log or
status saying why, and the feature looking simply unreliable.

The app already has one answer to "where are we": `Settings.protocol` and
`Settings.domain`, which is how `Gitlab::RepositoryService` builds its hook URL.
Azure now uses the same source. The variable stays as an OVERRIDE, for the one
case the default cannot cover — a domain Azure cannot resolve, which in
practice means a tunnel in development.

With a default there has to be a floor, because the default can be
`localhost:4000`. A subscription pointing somewhere Azure cannot reach is worse
than no subscription: Azure accepts it, reports it enabled, and fails every
delivery quietly until it disables it — the same silent shape as an
unrecognized event filter. So an effective host that is loopback, a private
range, .local or has no dot at all provisions nothing.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>
Three defects between a connected integration and a repository on disk, all
found by starting a real session against a real Azure organization. Each was
invisible to the suite for its own reason, and each produced an empty
/workspace/repo with the explanation buried in session metadata nobody reads.

A PEM does not survive YAML interpolation. `private_key: "<%= ENV[...] %>"`
puts a multi-line value inside a double-quoted scalar, and YAML folds line
breaks there into spaces: the key arrived intact by length and without a single
newline, so OpenSSL answered "Neither PUB key nor PRIV key" about a file that
was perfectly correct. `to_json` quotes it with the breaks escaped, which YAML
reads back as real newlines. Every test fixture was a single-line key, so
nothing here was ever exercised.

The git credential path resolved without naming a project. A connection now
covers several, and resolution refuses to guess — correctly — so a clone on a
two-project connection failed with "Azure credential unavailable
(validation_failed)". The repository knows its own project; that is what is
used. The two Service Hook maintenance calls had the same hole and would have
failed on the next status refresh or disconnect.

The credential file was owned by root. `exec` runs as the container's own user,
so a root-owned 0600 file is one the clone script can neither read — "cat:
Permission denied" — nor delete, which left the token sitting in /tmp after the
failure. It is written as the session's uid now: still 0600, still only one
user, and the one that git actually runs as.

SessionGitSetup had no tests at all, which is why this shipped. It has three
now: who owns the credential file, that the token never reaches argv, and that
a failed clone still removes it. FakeRuntime records ownership so the first is
assertable. The multi-project credential case is covered too — no test had ever
built a connection with more than one project.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>
…ot the image

An agent audit of every tool in a real session found four things. Three were
defects; the fourth was the interesting one.

The credential helper lived in docker/base/Dockerfile, which made the platform
and every agent image a matched pair. The image in use was five weeks old — built
before the helper existed — so the clone configured the checkout to call
/usr/local/bin/git-credential-aixle-azure, the file was not there, and every push
and ls-remote failed with "could not read Username for https://dev.azure.com".
Nothing in that message points at a stale image, and the audit reasonably read it
as a broken promise in the docs.

Rebuilding the image would have fixed this instance and left the coupling. So the
platform writes the helper into the session at clone time instead, under
/workspace/.aixle, owned by the session's user and 0700. The script and the code
that configures it now travel together and cannot disagree about the protocol
between them, and no rebuild is needed when either changes. It also stops being
something every agent image carries whether or not it will ever speak to Azure:
installing it is part of cloning an Azure repository, which is asserted.

The other three, all found by using the tools rather than by reading them:

A work item conflict promised a revision and returned null. The re-read that
finds the current revision called `get` without a project, which a connection
covering several projects refuses — and the rescue around it turned that refusal
into `current_revision: null`, forcing the caller into an extra round trip to
learn what the error was supposed to tell it. `link_work_item` had the same
unqualified read.

`all_blocking_satisfied` was false on a pull request with no policies at all —
`blocking_count: 0`, `unsatisfied: []`, and a verdict telling the caller not to
merge. The `blocking.any? &&` guard existed for two internal consumers that both
branch on blocking_count before they ever read the flag, so it protected nothing
and misled only the tool an agent actually follows.

Voting with an unknown reviewer surfaced Azure's own complaint about `isFlagged`
and `hasDeclined` — fields this adapter never sends and no caller can set. It now
says the reviewer is unknown and where reviewer ids come from.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>
…m a no-op

Two gaps a second tool audit found by using the tools rather than reading them.

Voting was unreachable. `azure_devops_vote_pull_request` needs an identity that
is already a reviewer, `azure_devops_list_pull_request_reviewers` reports only
the ones that are, and nothing could add one — so a pull request with no
reviewers was a loop with no exit. `PullRequestService#add_reviewer` had existed
the whole time with no tool in front of it, which is the same shape of mistake
as shipping a code path with no production caller.

It is optional by default. A required reviewer is an obligation on other
people's work that blocks completion until they vote, and that is not something
to acquire from a parameter's default.

Completion could not be told apart from a no-op. Called on a pull request that
had already landed, it answered `completed: true` — the same answer as for a
merge it had just performed. An agent retrying after a timeout had no way to
know which happened, on exactly the operation where that matters most. It now
reads the pull request first and returns `already_completed: true` without
sending anything, which also drops a pointless write. FakeAzureDevops mirrors
that, and records the completion only when one is actually attempted so
`calls_to(:complete)` stays the honest question the guard tests ask.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>
A third tool audit, run against the real organization, completed a pull request
with an expected commit of all zeros. It merged.

`expected_commit` is sent to Azure as `lastMergeSourceCommit`, and the tool's
own description called it "what stops this merging code you did not review".
That was an assumption about Azure, never a verified fact: Azure accepts the
field and completes anyway. The parameter was taken, echoed back, and compared
to nothing. The only documented protection against landing unreviewed work did
not exist.

It is enforced here now, against the same read the caller was told to take the
commit from, and the completion request is not sent at all when they differ.
The read was already being made for `already_completed`, so the guard costs
nothing. FakeAzureDevops mirrors it — a fake that merged regardless would let
the protection rot with every test still green.

Three more from the same audit:

Adding a reviewer wiped their vote. The request carried a flat `vote: 0`, so
adding someone to a pull request they had already approved silently destroyed
the approval — and on a policy-protected branch, un-blocked and re-blocked the
merge with nothing said. Membership and verdict are different things; the
current vote is read and preserved.

`link_work_item` leaked Azure's own conflict text, leaving callers to regex
`VS403351: Test Operation for path /rev failed` for the revision that
`update_work_item` hands over in `details.current_revision`. Same shape now.

Four descriptions disagreed with the code. Voting does not require prior
reviewer membership — Azure adds the voter itself, which is also why
`add_pull_request_reviewer` is for putting SOMEONE ELSE on a review rather than
for making voting possible. Commenting bumps a work item's `rev`, so a revision
read before a comment is stale immediately after. And `description` is stored
verbatim and rendered as HTML, so escaped text shows up as visible tags.

Also: an organization already bound could only ever offer the Azure projects the
FIRST connection approved. `complete!` could widen the installation all along;
nothing ever showed the wider list to choose from, so a company adding a second
Azure project later had no way in. A token on the connect screen now lists
everything the administrator can administer — widening the boundary being the
same act as establishing it, and needing the same proof.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>
…rnals

There was no instruction for connecting Azure DevOps that said what differs
between the hosted deployment and a self-hosted one. The answer is exactly one
thing — who owns the Entra application — and everything below it is identical,
which is worth saying plainly rather than leaving a reader to infer.

The new page covers both: the operator-side registration self-hosted needs, the
`az ad sp create` step both need in their own directory, the three
personal-access-token scopes and what each is spent on, choosing Azure projects
and widening that set later, and the failures worth recognising.

It does NOT print a client id. The id is not a secret, but it differs per
deployment, and a literal in shared documentation would send half its readers to
create a service principal for somebody else's application. The connect dialog
shows the command with this deployment's own id filled in, before anything is
typed — that step happens in another portal, usually by another person, so
learning about it from a failed verification means going away and coming back.

Publishing a page turns out to need five edits: the repository copy, the bundled
markdown, the page registry, the nav, the search index, and the routable-slug
list in Ruby. The first attempt missed the last one and answered 404 — which
reads as a missing document rather than a missing line. A test now compares the
Ruby list against the registry in both directions.

The portal's Integrations page did not mention Azure DevOps at all — that
section lived only in the repository mirror. It has one now, plus a row in the
webhooks table, which also corrected the claim underneath it: Azure sends no
signature of any kind, so the subscription's own password is the whole
credential, and the endpoint id in the URL is a route rather than a secret.

Antigravity and Kiro were missing from two runtime lists that had been written
when there were five. The Runtimes page itself was already right.

And two public pages carried "Deliverable for issue #550" / "#551", plus a
reference to the `develop` branch and a block of instructions addressed to
whoever would write the guide. Internal working notes in a public portal.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>
@artempartos
artempartos merged commit ab91508 into develop Sep 14, 2026
11 of 12 checks passed
artempartos added a commit that referenced this pull request Sep 17, 2026
The new reference test caught its first drift on the rebase: the Azure
DevOps integration (#251) landed 15 settings variables with no row in
docs/reference/configuration.md, which is exactly the gap the test exists
to close. Documented with real defaults, including the two that are easy to
get wrong — the OAuth resource that only looks like a legacy ADAL value, and
the webhook base URL whose blank default means "use the deployment's domain".

Also folds azure_devops.git_credentials_url into the same `internal_base`
local the MCP and cloud-credential URLs now derive from. The resolved value
is unchanged (http://web:4002/azure/git/credentials), but it is no longer a
third hardcoded copy of the internal host — and that host is wrong in the
cluster, where port 4002 belongs to the mcp service and not to web, so the
one variable now fixes all three.

CONTAINER_RUNTIME's row said "docker or kubernetes"; the deployed ConfigMaps
set `k8s`, which ContainerRuntime.build accepts as well.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>
artempartos added a commit that referenced this pull request Sep 17, 2026
* refactor(config): make Settings the single configuration surface

An inventory of the environment surface found 125 variables reaching the app
through config/settings.yml, 16 settings keys nothing read, 4 keys read by code
that no settings file defined, and three documents describing all of it that
disagreed with each other and with the code. This lands the whole cleanup.

The one real defect: the Active Record pool fell back to RAILS_MAX_THREADS || 5
while config/puma.rb fell back to 10, so a deployment that never set the
variable ran 10 request threads against an 8-connection pool. Compose and the
cluster both set it, which is why nothing caught it.

Derived values are now bound once as ERB locals (domain, thread budget, internal
base URL, OTLP endpoint, Traefik base) instead of re-reading the same variable
in two places, and agent runtime images are derived from a registry prefix
rather than enumerated seven times in three files. Every resolved image is
byte-identical in development, staging and production.

Deletions are all "read by nobody", verified against the infra repo before
removal: the variables stay inert in existing ConfigMaps rather than breaking
anything. The four phantom keys are either defined now (tool-result retention,
context token budget, GitHub private-key path) or folded into the constant they
always fell back to (the Claude base OAuth client id).

Documentation drift is now mechanically prevented: docs/reference/configuration.md
is the single source, the docs portal serves a generated copy of it, a test
fails when a variable gains no row or a row names a variable nothing reads, and
a rubocop cop keeps app code from reading ENV behind that file's back.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>

* docs(config): document the Azure DevOps variables

The new reference test caught its first drift on the rebase: the Azure
DevOps integration (#251) landed 15 settings variables with no row in
docs/reference/configuration.md, which is exactly the gap the test exists
to close. Documented with real defaults, including the two that are easy to
get wrong — the OAuth resource that only looks like a legacy ADAL value, and
the webhook base URL whose blank default means "use the deployment's domain".

Also folds azure_devops.git_credentials_url into the same `internal_base`
local the MCP and cloud-credential URLs now derive from. The resolved value
is unchanged (http://web:4002/azure/git/credentials), but it is no longer a
third hardcoded copy of the internal host — and that host is wrong in the
cluster, where port 4002 belongs to the mcp service and not to web, so the
one variable now fixes all three.

CONTAINER_RUNTIME's row said "docker or kubernetes"; the deployed ConfigMaps
set `k8s`, which ContainerRuntime.build accepts as well.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>

* refactor(azure-devops): read the git-credential URL from Settings only

`container_env` fell back to a literal "http://web:4002/azure/git/credentials"
behind the setting, which made four copies of the internal host in the tree and
one of them wrong: that address is only correct under compose, where a single
`web` container runs both pumas and publishes 4002. In the cluster port 4002
belongs to the separate `mcp` service, `web` serves only 4000, and the runtime
NetworkPolicy admits exactly those two pairs — so a fallback to `web:4002`
cannot connect even in principle.

The setting always has a value (config/settings.yml derives it from
INTERNAL_BASE_URL alongside mcp.server_url and cloud.credentials_url), so the
fallback was unreachable code that only served to duplicate a bad default.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>

* feat(config): let PORT and MCP_PORT move the whole stack

The two ports were already read from the environment by config/puma.rb and
config/puma_mcp.rb, but everything derived from them was a literal: `domain`,
`asset_host` and `container_asset_host` hardcoded 4000, the internal base URL
hardcoded 4002, and Compose published, health-checked and routed 4000/4001/4002
by hand. Overriding PORT therefore moved the listener and left every derived
host pointing at the old number — so a second stack on one machine (a worktree
under review, for instance) could not be brought up cleanly.

The settings file now binds both ports as ERB locals and derives those four
values from them, and Compose takes `${PORT}`, `${MCP_PORT}` and
`${VITE_RUBY_PORT}` for the published ports, the Traefik service label, the
health check and the container env.

  PORT=4010 MCP_PORT=4012 docker compose up
  -> domain=localhost:4010  container_asset=web:4010
     mcp=http://web:4012/action_mcp  cloud=http://web:4012/cloud/aws/credentials

Deployed environments are unaffected: they set the derived values explicitly
(DOMAIN, CONTAINER_ASSET_HOST, and in the cluster the internal base), so the
defaults these ports feed are never reached there.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>

* fix(config): stop treating a blank ASSET_HOST as a configured one

The image declares ASSET_HOST as an ENV, so an image built without that build
arg carries it as "" — present to the process, blank to anyone who means it.
`ENV['ASSET_HOST'] || "localhost:4000"` therefore never reached its default:
an empty string is truthy in Ruby, so the setting resolved to "" rather than to
anything usable.

The default is gone rather than fixed, because nothing in development or test
ever read `Settings.asset_host` — `localhost:4000` was a value with no consumer.
Blank now means what it says: Rails serves the assets itself.

config/environments/production.rb keyed its guard off the raw variable
(`if ENV["ASSET_HOST"].present?`), which is what hid this; it now reads the
setting it is about to assign. Production sets a real value, so nothing changes
there.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>

* chore(config)!: remove the qa environment, and the uat leftover beside it

Nothing deploys `qa`. The infra repo has no match for it at all: helmfile
declares prod and staging, terraform's live stacks are bootstrap/global/iam/
mgmt/prod/staging, the kubeconfig knows `aixle-staging` and `palad-prod`, and
the only RAILS_ENV values set anywhere are staging, production and development.
The deploy repo's branches are develop, main, main-images and staging.

In this repo it was a full environment all the same: config/environments/qa.rb
(93 lines — longer than production.rb, and three times staging.rb, which is just
`require_relative "production"` plus one override), config/settings/qa.yml, and a
`qa:` key in database.yml, cable.yml, queue.yml and recurring.yml. No code reads
`Rails.env.qa?`; the "qa" occurrences that remain in app code are the job
position in onboarding (`POSITIONS = %w[qa pm_po_ba dev ...]`). It arrived in
4179ec1, the same scaffold commit that brought the unread `ui_url` keys.

Removed in one go rather than piecemeal: the comment above the `qa:` key in
queue.yml records why. Solid Queue looks that file up by Rails.env and falls
back to its own gem defaults SILENTLY when the key is missing — staging once ran
three threads polling ten times a second that way. Leaving qa.rb while dropping
its queue key would have rebuilt exactly that trap.

`uat:` in database.yml went with it: there is no config/environments/uat.rb, so
RAILS_ENV=uat cannot boot at all, and that line was the only occurrence of the
word in the repository.

Verified staging still resolves its own config after the removal:
`RAILS_ENV=staging bin/rails runner` boots and reads the staging key out of
queue.yml (dispatchers present, not the gem fallback).

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>

* test(config): drop qa from the deployed-environment list

RecurringTasksTest asserted the queue watchdog is scheduled in
`%w[production staging qa]`; with the qa environment gone, `config_for` returns
nil for it and the test dies on the nil rather than on a missing schedule.

The list is the test's definition of "every deployed environment", so it follows
the removal. That this test is what broke is the point of it existing: the
watchdog is exactly the entry that must never silently stop being scheduled.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>

---------

Signed-off-by: Artem Petrov <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
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.

1 participant