Repository navigation
fix(auth): route every Azure DevOps egress through one auth chain owner - #3790
Conversation
AuthResolver.try_with_fallback is now the single entry for authenticated host access. A new core/auth_outcome.py owns auth-outcome classification (401/403, a redirect to the ADO sign-in service, an HTML sign-in page, Git auth errors) and core/auth_chain.py walks ADO_APM_PAT -> az bearer -> path-scoped git credential fill, recording an AuthAttemptLog that diagnostics render. - Route install validation, clone, ref resolution, install --update preflight, ADO file downloads, org policy discovery (ADO, GitHub with per-org PAT, GitLab) and marketplace REST/ref paths through the chain. - Helper credentials keep their username (GitHelperCredential) and are sent as Basic username:password, cached per (host, port, path). - git credential fill sets GCM_INTERACTIVE=0 when stdin is not a TTY or CI is set; APM never calls credential approve/reject. - Azure DevOps requests use only the credential chosen by the auth chain. - #3753: az token failures show the Azure CLI reason; the exhausted chain lists every step in order; "bearer token" is no longer redacted. - Remove execute_with_bearer_fallback; is_ado_auth_failure_signal and is_public_github_auth_failure become thin classifier wrappers. - Static guard transport-platform-auth-outcome-owner on the host-credential-resolution owner record, with a mutation case. No live Azure DevOps organization was available: behavior follows the documented contracts and is validated by hermetic tests. Fixes #3752 Fixes #3758 Fixes #3753 apm-spec-waiver: auth chain owner refactor with no spec surface change Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved redirect handling and legacy-host credential scoping can prevent credential-helper authentication, while a tenant-cache race permits redundant concurrent Azure CLI calls.
4 open issues
What changed in this PR
This PR centralizes Azure DevOps authentication across APM’s install, policy and marketplace flows to address #3752, #3758 and #3753. It adds repository-scoped credential-helper fallback and preserves Azure CLI token-acquisition errors for diagnostics.
Changes:
- Routes Azure DevOps operations through one credential chain and shared outcome classifier.
- Preserves helper usernames and repository scope, suppresses ambient netrc credentials on Azure DevOps HTTP paths, and improves failure reporting.
- Adds regression fixtures, lifecycle coverage, architecture guards and authentication documentation.
| File | Description |
|---|---|
tests/utils/simulated_ado_chain.py |
Adds shared auth-chain test doubles. |
tests/utils/local_ado_org_fixture.py |
Simulates Azure DevOps and credential helpers. |
tests/unit/test_list_remote_refs.py |
Migrates ref-listing mocks to the chain API. |
tests/unit/test_auth.py |
Updates bearer fallback and exhaustion assertions. |
tests/unit/scripts/test_architecture_runner.py |
Registers the new guard in the expected inventory. |
tests/unit/policy/test_discovery.py |
Updates policy authentication tests. |
tests/unit/policy/test_discovery_policy_resolution.py |
Removes tests for the deleted token helper. |
tests/unit/policy/test_discovery_phase3w4.py |
Removes obsolete token-helper coverage. |
tests/unit/policy/test_cache_merged_effective.py |
Adapts cache tests to resolver-based authentication. |
tests/unit/marketplace/test_ref_resolver.py |
Checks SSH bypasses the credential chain. |
tests/unit/marketplace/test_client_ado.py |
Tests chain-selected headers and helper scope. |
tests/unit/install/test_validation_proxy.py |
Removes obsolete bearer-fallback mocks. |
tests/unit/install/test_validation_ado_bearer.py |
Exercises validation fallback and attempt diagnostics. |
tests/unit/install/test_pipeline_auth_preflight.py |
Tests preflight chain routing and exhaustion. |
tests/unit/install/phases/test_resolve_ref_resolver_reuse.py |
Adapts ref-resolution authentication doubles. |
tests/unit/deps/test_github_downloader_input_validation.py |
Checks validation reuses the successful credential. |
tests/unit/deps/test_git_reference_resolver.py |
Updates ref-listing chain coverage. |
tests/unit/deps/test_download_strategies_selection.py |
Uses the shared simulated chain. |
tests/unit/deps/test_download_strategies_phase3.py |
Migrates download fallback tests. |
tests/unit/deps/test_clone_engine_bearer_env.py |
Checks bearer retry environment preservation. |
tests/unit/deps/test_clone_connect_retry.py |
Keeps connection retries within chain attempts. |
tests/unit/core/test_auth_validation.py |
Removes tests for deleted fallback APIs. |
tests/unit/core/test_auth_phase3.py |
Updates helper records and exhaustion diagnostics. |
tests/unit/core/test_auth_outcome.py |
Adds classifier and helper-scope contracts. |
tests/integration/test_marketplace_ado_rest.py |
Captures headers applied by the auth hook. |
tests/integration/test_github_credential_scope_lifecycle.py |
Covers org-scoped GitHub policy credentials. |
tests/integration/test_git_reference_resolver_resolution.py |
Updates chain routing and diagnostic coverage. |
tests/integration/test_commands_auth_flow.py |
Removes obsolete fallback-result tests. |
tests/integration/test_azure_cli_failure_diagnostic_lifecycle.py |
Covers Azure CLI failure reasons and redaction. |
tests/integration/test_architecture_owner_rule_mutations.py |
Adds and retargets auth-boundary mutations. |
tests/integration/test_ado_preflight_bearer_fallback_e2e.py |
Updates a comment to name the new chain API. |
tests/integration/_ado_auth_kit.py |
Adds a shared Azure DevOps lifecycle harness. |
tests/fixtures/lifecycle_bug_ledger.json |
Links reported bugs to regression scenarios. |
src/apm_cli/utils/github_host.py |
Delegates legacy auth detection to the classifier. |
src/apm_cli/policy/discovery.py |
Routes policy fetches through authentication chains. |
src/apm_cli/policy/_gitlab.py |
Reports raw HTTP outcomes to the auth owner. |
src/apm_cli/marketplace/ref_resolver.py |
Routes Azure DevOps ref probes through the chain. |
src/apm_cli/marketplace/client.py |
Uses chain-selected authentication for REST reads. |
src/apm_cli/install/validation.py |
Runs Azure DevOps validation through the chain. |
src/apm_cli/install/pipeline.py |
Integrates the chain into update preflight. |
src/apm_cli/deps/github_downloader_validation.py |
Routes ref validation through shared authentication. |
src/apm_cli/deps/git_reference_resolver.py |
Integrates chain-based ref and tag lookup. |
src/apm_cli/deps/download_strategies.py |
Adds chain-based Azure DevOps file downloads. |
src/apm_cli/deps/clone_engine.py |
Replaces clone-specific bearer fallback. |
src/apm_cli/deps/bare_cache.py |
Includes exhausted-chain details in clone errors. |
src/apm_cli/core/token_manager.py |
Preserves helper credentials and controls interaction. |
src/apm_cli/core/azure_cli.py |
Retains acquisition errors and caches tenant lookup. |
scripts/lint-auth-signals.sh |
Retargets checks to the chain entry point. |
scripts/architecture_linter/groups/transport_platform.py |
Includes the auth-outcome guard. |
scripts/architecture_linter/checks/transport_auth_platform.py |
Updates routing and netrc-isolation checks. |
scripts/architecture_linter/checks/transport_auth_outcome.py |
Adds classifier and chain-ownership enforcement. |
packages/apm-guide/.apm/skills/apm-usage/authentication.md |
Documents fallback behavior and remediation. |
docs/src/content/docs/getting-started/authentication.md |
Explains shared authentication and diagnostics. |
CHANGELOG.md |
Records authentication and policy-fetch changes. |
.apm/skills/auth/SKILL.md |
Updates maintained authentication guidance. |
.apm/architecture/owners/transport-auth-platform.json |
Registers chain and classifier ownership. |
.agents/skills/auth/SKILL.md |
Synchronizes agent-facing authentication guidance. |
Review effort: Balanced
APM Review Panel:
|
| Persona | B | R | N | Takeaway |
|---|---|---|---|---|
| Auth Expert | 0 | 0 | 0 | Auth chain redesign is sound: credential precedence, escalation gating, Basic encoding, helper cache, GCM_INTERACTIVE, and diagnostics are correct with no regressions. |
| Supply Chain Security Expert | 0 | 0 | 0 | ADO credential host-binding, netrc suppression, helper path derivation, and secret redaction are sound; no credential reaches an unintended host. |
| Test Coverage Expert | 0 | 1 | 0 | Multi-tier coverage: 8 hermetic regression traps, 4 lifecycle modules with scripted HTTPS proxy, classifier table, guard mutations. One marketplace error-path gap. |
| Python Architect | 0 | 1 | 0 | Clean ownership split (classifier, ADO walker, entry point); no routed site re-derives auth; cycle-free; under 2100 lines; extensible for approve/reject. |
B = blocking-severity findings, R = recommended, N = nits.
Counts are signal strength, not gates. The maintainer ships.
Top 2 follow-ups
- [Test Coverage Expert] Add a test for RefResolver ADO exhausted-chain-to-GitLsRemoteError conversion (ref_resolver.py:544). -- Missing regression trap on a user-facing error contract; a refactor could silently degrade the remediation hint.
- [Python Architect] Widen the
_CREDENTIAL_STORE_MUTATIONguard to also catch unquoted shell-string and f-string forms of credential approve/reject. -- Closes a theoretical evasion path of the never-approve/reject decision; cheap to implement.
Recommendation
Ship. The auth and supply-chain experts returned zero findings on a security-critical 12-site auth refactor, backed by 8 hermetic regression traps and 79 passing lifecycle tests. The two recommended follow-ups are genuine improvements worth folding before merge but do not represent security regressions or user-facing breakage on this commit.
Full per-persona findings
Python Architect
- [recommended] _CREDENTIAL_STORE_MUTATION guard needle only catches quoted-argv form; shell-string and f-string construction evade it. at
scripts/architecture_linter/checks/transport_auth_outcome.py
The never-approve/reject invariant is security-grade; add an unquoted text pattern to close evasion via shell strings or f-strings.
Suggested: Addre.compile(r"\bcredential\s+(?:approve|reject)\b")and forbid it across src with the same scan.
Supply Chain Security Expert
No findings.
Auth Expert
No findings.
Test Coverage Expert
- [recommended] RefResolver ADO exhausted-chain to GitLsRemoteError conversion has no test at any tier. at
src/apm_cli/marketplace/ref_resolver.py:544
marketplace/ref_resolver.py catches AdoAuthChainExhaustedError and converts it to GitLsRemoteError with a remediation hint; no test reaches that path.
Suggested: Add a test where PAT and az bearer fail and no helper credential exists; assert GitLsRemoteError carries the exhausted summary and hint.
Proof (missing at):tests/integration/test_ado_ref_resolution_fallback.py-- proves: When marketplace ref resolution exhausts the ADO auth chain, the user sees a helpful error naming every tried credential and remediation steps. [secure-by-default,devx]
This panel is advisory. It does not block merge. Re-apply the
panel-review label after addressing feedback to re-run.
Generated by autopilot-pr-review-worker. This comment is AI-generated and may contain errors.
…ject guard Fold panel follow-ups on #3790: RefResolver converts an exhausted ADO chain into GitLsRemoteError naming every step (new integration test), and transport-platform-auth-outcome-owner also rejects shell-string forms of git credential approve/reject. Co-authored-by: Copilot App <[email protected]>
…-in redirects - Legacy *.visualstudio.com remotes query the credential helper with the Project/_git/repo path the helper stores. - Tenant id lookup is single-flight under a lock. - ADO file downloads and marketplace ADO REST fetches no longer follow redirects; a sign-in 3xx reaches the classifier and the chain escalates. apm-spec-waiver: review folds inside the approved auth owner scope Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
…e chain Co-authored-by: Copilot App <[email protected]>
The cause-chain walk follows __cause__/__context__ only through real exceptions, and any other error value is read as text. apm-spec-waiver: hardening inside the approved auth classifier owner Co-authored-by: Copilot App <[email protected]>
…he redirect owner The ADO items fetch sends only the chain-selected Authorization header, disables ambient credentials, and refuses the cross-origin sign-in redirect so the auth chain classifies the 3xx and escalates. apm-spec-waiver: adapts the approved auth owner to the redirect owner API Co-authored-by: Copilot App <[email protected]>
…lls; widen resolve fakes - Add RT1's lock replay (0.35.1 / 0.36.0 locks) and ADO adjacent-egress installed-CLI scenarios byte-for-byte. - Resolver test doubles accept the port/host_type keywords the chain now passes. Co-authored-by: Copilot App <[email protected]>
… main Co-authored-by: Copilot App <[email protected]>
APM Review Panel:
|
| Persona | B | R | N | Takeaway |
|---|---|---|---|---|
| Auth Expert | 0 | 0 | 0 | Delta keeps auth correct: chain-selected credential only via authorization_headers + ambient_credentials=False, sign-in redirect classified and escalated, helper path correct for legacy hosts, tenant cache single-flight sound. |
| Supply Chain Security Expert | 0 | 0 | 0 | Credential scoping across redirects is tightened; marketplace ADO fetch routes through the origin-bounded owner with ambient exclusion; exemption entry is sound; no residual credential-follow risks in the delta. |
| Test Coverage Expert | 0 | 0 | 0 | All seven delta behavior changes are locked by mutation-break tests at their surface floor; no silent-drift risk detected. |
B = blocking-severity findings, R = recommended, N = nits.
Counts are signal strength, not gates. The maintainer ships.
Recommendation
All three panelists agree, with zero findings, and the prior follow-ups are already folded. The delta tightens credential scoping and adds test coverage; it opens no new risk surface. Merge when CI stays green.
Full per-persona findings
Auth Expert
No findings.
Supply Chain Security Expert
No findings.
Test Coverage Expert
No findings.
This panel is advisory. It does not block merge. Re-apply the
panel-review label after addressing feedback to re-run.
Generated by autopilot-pr-review-worker. This comment is AI-generated and may contain errors.
…n fallback - Every ADO chain step's git env carries only its own Authorization header, suppresses credential helpers, and holds no PAT, bearer, or ambient GitHub token from another step (PAT -> bearer -> helper and tokenless). - A failing AuthResolver never lets the GitHub policy fetch fall back to GITHUB_TOKEN, GITHUB_APM_PAT, or GH_TOKEN from the environment. Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
…hain The TestDownloadAdoFile host doubles left auth_resolver.try_with_fallback as a bare MagicMock, so download_ado_file returned a mock instead of exercising 404 fallback, auth exhaustion, and network errors. They now install the simulated chain the unit twin uses, which runs the real AuthResolver chain against the mocked transport. Co-authored-by: Copilot App <[email protected]>
…ted-egress-guard #3790's squash differs from the previously merged head 74ef67d only in three test files; those deltas are applied here. Co-authored-by: Copilot App <[email protected]>
) Co-authored-by: Copilot App <[email protected]>
) * fix(uninstall): route every deploy through one effective-selection owner (#3760) apm uninstall re-integrated surviving packages without their skills: selection, so every skill of a surviving bundle was redeployed and left unrecorded in the lockfile. Add effective_dependency_selection() in install/package_resolution.py as the single owner of the effective deploy selection and route install preflight, install deploy, audit replay and uninstall re-integration through it. skill_subset is now a required keyword of integrate_package_primitives and prepare_package_deployment. apm-spec-waiver: deploy-time skill selection routing fix; no OpenAPM spec requirement covers uninstall re-integration selection Co-authored-by: Copilot App <[email protected]> * fix(install): guard the effective deploy-selection owner (#3760) Add the install-deployment-effective-selection architecture guard: every integrate_package_primitives, prepare_package_deployment and DeployableSourcePlan.create call passes skill_subset (and any dep_target_subset) from effective_dependency_selection, with allowlisted hooks-only and plan-derived sites, and skill_subset stays a required keyword. Register the dependency-selection owner, add its MutationCase and mutation-break cases, update the audit-replay guard and its tests to the owner call, pass skill_subset explicitly in direct test callers, add a TypeError unit test and the uninstall L7 lifecycle test (project and -g), and document the uninstall rebuild selection. apm-spec-waiver: deploy-time skill selection routing fix; no OpenAPM spec requirement covers uninstall re-integration selection Co-authored-by: Copilot App <[email protected]> * docs(changelog): uninstall keeps skills: selection (#3784) Co-authored-by: Copilot App <[email protected]> * test: pass skill_subset in spec conformance callers; register effective-selection rule (#3760) apm-spec-waiver: test-only call-site update for the required skill_subset argument; no spec behavior change Co-authored-by: Copilot App <[email protected]> * fix(install): route lockfile record and target resolution via owner Panel follow-ups on #3784. The lockfile builder recorded the skill subset by calling effective_deploy_skill_subset itself, and uninstall hook reconcile plus the explicit-target preflight read dep_ref.target_subset directly, so the owner covered less than its registry entry claimed. All three now take the selection from effective_dependency_selection. The install-deployment-effective-selection guard now also checks every resolve_effective_package_targets call, keeps effective_deploy_skill_subset internal to the owner module, and resolves aliased imports of the deploy functions; four new bypass mutations prove each case. The #3760 lifecycle test is now lifecycle_smoke (runs in the PR-time lifecycle job) and gains a survivor targets: narrowing case. apm-spec-waiver: install deploy-selection routing with no OpenAPM requirement change Co-authored-by: Copilot App <[email protected]> * test(install): lockfile records the owner's deployed selection (#3784) Traps the lockfile builder's route through effective_dependency_selection: it records the persisted plus CLI --skill union for skill bundles only. Co-authored-by: Copilot App <[email protected]> * test(skills): make the U1 x legacy layout assert unconditional (#3784) #3793 guarded the post-uninstall legacy-root assertion with an xfail until #3760 landed. With the effective-selection owner in place the survivor keeps only its selected skill, so the conditional would only mask a future U1 regression. Co-authored-by: Copilot App <[email protected]> * test(uninstall): PR-time U1 trap for the legacy skill layout (#3784) The U1 x --legacy-skill-paths assertion in the #3793 lifecycle module only runs in the merge queue. Add a cheap local-path case to the lifecycle_smoke module so a survivor-selection regression on the legacy layout fails on every PR. Fails on pre-fix src (all 4 skills re-integrated), passes at head. Co-authored-by: Copilot App <[email protected]> * Merge main (dfb6a83) into #3784; slot CHANGELOG bullet Co-authored-by: Copilot App <[email protected]> * test: follow #3790 rename in the preflight target mutation anchor (#3784) Co-authored-by: Copilot App <[email protected]> --------- Co-authored-by: danielmeppiel <[email protected]> Co-authored-by: Copilot App <[email protected]>
#3735) (#3786) * fix(uninstall): route every deploy through one effective-selection owner (#3760) apm uninstall re-integrated surviving packages without their skills: selection, so every skill of a surviving bundle was redeployed and left unrecorded in the lockfile. Add effective_dependency_selection() in install/package_resolution.py as the single owner of the effective deploy selection and route install preflight, install deploy, audit replay and uninstall re-integration through it. skill_subset is now a required keyword of integrate_package_primitives and prepare_package_deployment. apm-spec-waiver: deploy-time skill selection routing fix; no OpenAPM spec requirement covers uninstall re-integration selection Co-authored-by: Copilot App <[email protected]> * fix(install): guard the effective deploy-selection owner (#3760) Add the install-deployment-effective-selection architecture guard: every integrate_package_primitives, prepare_package_deployment and DeployableSourcePlan.create call passes skill_subset (and any dep_target_subset) from effective_dependency_selection, with allowlisted hooks-only and plan-derived sites, and skill_subset stays a required keyword. Register the dependency-selection owner, add its MutationCase and mutation-break cases, update the audit-replay guard and its tests to the owner call, pass skill_subset explicitly in direct test callers, add a TypeError unit test and the uninstall L7 lifecycle test (project and -g), and document the uninstall rebuild selection. apm-spec-waiver: deploy-time skill selection routing fix; no OpenAPM spec requirement covers uninstall re-integration selection Co-authored-by: Copilot App <[email protected]> * docs(changelog): uninstall keeps skills: selection (#3784) Co-authored-by: Copilot App <[email protected]> * fix(deps): merge diamond skill and target selections through one owner (#3735) WIP: selection-merge owner, resolver edge accumulator, uninstall shrink, audit via the owner, frozen selection reason, static guard. Co-authored-by: azevedo-luis <[email protected]> Co-authored-by: Copilot App <[email protected]> * test(deps): real-binary diamond selection lifecycle (#3735) Co-authored-by: azevedo-luis <[email protected]> Co-authored-by: Copilot App <[email protected]> * test(deps): fold RT4 selection-merge lifecycle suite; deterministic parent ties; docs (#3735) resolved_by ties among equal-depth parents break by lowest parent key, so manifest order no longer changes apm.lock.yaml bytes. Co-authored-by: azevedo-luis <[email protected]> Co-authored-by: Copilot App <[email protected]> * docs(changelog): selection merge entry (#3786) apm-spec-waiver: lockfile skill_subset/target_subset meaning clarified in lockfile-spec.md only; the normative requirement is deferred to #3763 per approved decision D7. Co-authored-by: azevedo-luis <[email protected]> Co-authored-by: Copilot App <[email protected]> * test(audit): declared-selection wording in subset replay lifecycle (#3786) Co-authored-by: azevedo-luis <[email protected]> Co-authored-by: Copilot App <[email protected]> * fix(deps): keep download annotations on merged references; trim resolve phase (#3786) Co-authored-by: azevedo-luis <[email protected]> Co-authored-by: Copilot App <[email protected]> * test(deps): trap audit target_subset, marketplace keys and dev edges (#3786) Addresses panel follow-ups FU1-FU3 (test-coverage-expert): the audit target_subset mismatch branch, the marketplace declaration mapping in declared_node_selections, and a devDependencies edge contributing its selection, each proven by a mutation that breaks it. Co-authored-by: azevedo-luis <[email protected]> Co-authored-by: Copilot App <[email protected]> * test: pass skill_subset in spec conformance callers; register effective-selection rule (#3760) apm-spec-waiver: test-only call-site update for the required skill_subset argument; no spec behavior change Co-authored-by: Copilot App <[email protected]> * fix(install): route lockfile record and target resolution via owner Panel follow-ups on #3784. The lockfile builder recorded the skill subset by calling effective_deploy_skill_subset itself, and uninstall hook reconcile plus the explicit-target preflight read dep_ref.target_subset directly, so the owner covered less than its registry entry claimed. All three now take the selection from effective_dependency_selection. The install-deployment-effective-selection guard now also checks every resolve_effective_package_targets call, keeps effective_deploy_skill_subset internal to the owner module, and resolves aliased imports of the deploy functions; four new bypass mutations prove each case. The #3760 lifecycle test is now lifecycle_smoke (runs in the PR-time lifecycle job) and gains a survivor targets: narrowing case. apm-spec-waiver: install deploy-selection routing with no OpenAPM requirement change Co-authored-by: Copilot App <[email protected]> * test(install): lockfile records the owner's deployed selection (#3784) Traps the lockfile builder's route through effective_dependency_selection: it records the persisted plus CLI --skill union for skill bundles only. Co-authored-by: Copilot App <[email protected]> * fix(deps): merge replaced, aliased and marketplace diamonds; audit fails closed (#3786) Addresses the four Copilot inline findings: - replace: diamonds now lock and reload the merged selection (the binding original carries the union; lock evidence re-merges every request); - audit treats an incomplete declaration walk as unverified unless an unrestricted edge absorbs the unread declarations; - the reachability walk reads an aliased node where the lock materialized it; - marketplace declarations map to their locked entry at every depth. Each fold is proven by a mutation that breaks its new test. Co-authored-by: azevedo-luis <[email protected]> Co-authored-by: Copilot App <[email protected]> * fix(deps): expand same-repo path children of fetched packages in the walk (#3786) The declared-selection walk loaded package manifests without their origin, so a fetched package's same-repository path: child stayed a consumer-local path, never reached its locked node, and audit reported it unverified (test_mcp_dev_dependency_lifecycle). Mark the origin as install and DeclaredTransportIndex do. Co-authored-by: azevedo-luis <[email protected]> Co-authored-by: Copilot App <[email protected]> * test(skills): make the U1 x legacy layout assert unconditional (#3784) #3793 guarded the post-uninstall legacy-root assertion with an xfail until #3760 landed. With the effective-selection owner in place the survivor keeps only its selected skill, so the conditional would only mask a future U1 regression. Co-authored-by: Copilot App <[email protected]> * test(uninstall): PR-time U1 trap for the legacy skill layout (#3784) The U1 x --legacy-skill-paths assertion in the #3793 lifecycle module only runs in the merge queue. Add a cheap local-path case to the lifecycle_smoke module so a survivor-selection regression on the legacy layout fails on every PR. Fails on pre-fix src (all 4 skills re-integrated), passes at head. Co-authored-by: Copilot App <[email protected]> * test(deps): replaced diamond locks and audits its union end to end (#3786) Addresses delta panel follow-ups: an integration trap installs a replace: diamond whose parents select different skills and audits the locked union; the unit trap now round-trips the lock; the resolver keeps an explicitly empty merged selection as the replacement path does. Co-authored-by: azevedo-luis <[email protected]> Co-authored-by: Copilot App <[email protected]> * Merge main (dfb6a83) into #3784; slot CHANGELOG bullet Co-authored-by: Copilot App <[email protected]> * test: follow #3790 rename in the preflight target mutation anchor (#3784) Co-authored-by: Copilot App <[email protected]> * docs(changelog): drop duplicate #3784 bullet after main merge (#3786) Co-authored-by: azevedo-luis <[email protected]> Co-authored-by: Copilot App <[email protected]> --------- Co-authored-by: danielmeppiel <[email protected]> Co-authored-by: Copilot App <[email protected]> Co-authored-by: azevedo-luis <[email protected]>
…3823) * fix(auth): route every Azure DevOps egress through one auth chain owner AuthResolver.try_with_fallback is now the single entry for authenticated host access. A new core/auth_outcome.py owns auth-outcome classification (401/403, a redirect to the ADO sign-in service, an HTML sign-in page, Git auth errors) and core/auth_chain.py walks ADO_APM_PAT -> az bearer -> path-scoped git credential fill, recording an AuthAttemptLog that diagnostics render. - Route install validation, clone, ref resolution, install --update preflight, ADO file downloads, org policy discovery (ADO, GitHub with per-org PAT, GitLab) and marketplace REST/ref paths through the chain. - Helper credentials keep their username (GitHelperCredential) and are sent as Basic username:password, cached per (host, port, path). - git credential fill sets GCM_INTERACTIVE=0 when stdin is not a TTY or CI is set; APM never calls credential approve/reject. - Azure DevOps requests use only the credential chosen by the auth chain. - #3753: az token failures show the Azure CLI reason; the exhausted chain lists every step in order; "bearer token" is no longer redacted. - Remove execute_with_bearer_fallback; is_ado_auth_failure_signal and is_public_github_auth_failure become thin classifier wrappers. - Static guard transport-platform-auth-outcome-owner on the host-credential-resolution owner record, with a mutation case. No live Azure DevOps organization was available: behavior follows the documented contracts and is validated by hermetic tests. Fixes #3752 Fixes #3758 Fixes #3753 apm-spec-waiver: auth chain owner refactor with no spec surface change Co-authored-by: Copilot App <[email protected]> * docs(changelog): reference #3790 for the ADO auth chain fixes Co-authored-by: Copilot App <[email protected]> * test(auth): cover marketplace exhausted-chain error; widen approve/reject guard Fold panel follow-ups on #3790: RefResolver converts an exhausted ADO chain into GitLsRemoteError naming every step (new integration test), and transport-platform-auth-outcome-owner also rejects shell-string forms of git credential approve/reject. Co-authored-by: Copilot App <[email protected]> * fix(auth): fold Copilot review on ADO helper path, tenant cache, sign-in redirects - Legacy *.visualstudio.com remotes query the credential helper with the Project/_git/repo path the helper stores. - Tenant id lookup is single-flight under a lock. - ADO file downloads and marketplace ADO REST fetches no longer follow redirects; a sign-in 3xx reaches the classifier and the chain escalates. apm-spec-waiver: review folds inside the approved auth owner scope Co-authored-by: Copilot App <[email protected]> * chore(lock): refresh auth skill deployed hash Co-authored-by: Copilot App <[email protected]> * test(auth): route remaining preflight and bare-clone tests through the chain Co-authored-by: Copilot App <[email protected]> * fix(auth): classification never raises on non-exception error objects The cause-chain walk follows __cause__/__context__ only through real exceptions, and any other error value is read as text. apm-spec-waiver: hardening inside the approved auth classifier owner Co-authored-by: Copilot App <[email protected]> * arch: add authenticated-egress ownership guard Add transport-platform-authenticated-egress, an AST architecture-linter rule that keeps HTTP egress primitives (requests verbs and sessions, urllib urlopen) and literal credential header keys in their owner modules or in a frozen, reasoned inventory that can only shrink. The rule carries two guard ids registered on host-credential-resolution and credential-origin-scope. lint-auth-signals.sh drops stale Rule A exemptions and Rule B now defers to the architecture linter. Refs #3752, #3726 Co-authored-by: Copilot App <[email protected]> * fix(marketplace): ADO REST fetch sends the chain credential through the redirect owner The ADO items fetch sends only the chain-selected Authorization header, disables ambient credentials, and refuses the cross-origin sign-in redirect so the auth chain classifies the 3xx and escalates. apm-spec-waiver: adapts the approved auth owner to the redirect owner API Co-authored-by: Copilot App <[email protected]> * test(auth): carry RT1 upgrade-replay and adjacent-egress lifecycle cells; widen resolve fakes - Add RT1's lock replay (0.35.1 / 0.36.0 locks) and ADO adjacent-egress installed-CLI scenarios byte-for-byte. - Resolver test doubles accept the port/host_type keywords the chain now passes. Co-authored-by: Copilot App <[email protected]> * test(policy): drop T2 xfail now that canonical targets (#3774) are on main Co-authored-by: Copilot App <[email protected]> * test(auth): re-lock per-step credential isolation and policy env-token fallback - Every ADO chain step's git env carries only its own Authorization header, suppresses credential helpers, and holds no PAT, bearer, or ambient GitHub token from another step (PAT -> bearer -> helper and tokenless). - A failing AuthResolver never lets the GitHub policy fetch fall back to GITHUB_TOKEN, GITHUB_APM_PAT, or GH_TOKEN from the environment. Co-authored-by: Copilot App <[email protected]> * test(auth): assert the narrow exhausted-chain exception Co-authored-by: Copilot App <[email protected]> * arch: route remaining credential egress through the owners Policy fetches (URL, GitHub, Azure DevOps, GitLab), the Artifactory boundary probe and the install validation GitHub probe now send through origin_bounded_request. Policy and probe redirects away from the requested resource stay unfollowed and are reported as before. Literal credential headers move to AuthResolver.github_rest_headers, AuthResolver.bearer_headers and RegistryAuthContext.headers. The authenticated-egress inventory drops every pending entry; the origin-bounded-redirect inventory drops the policy and Artifactory entries; lint-auth-signals Rule B also defers auth-outcome-owner. Refs #3752, #3726 Co-authored-by: Copilot App <[email protected]> * fix(marketplace): drop final-URL HTTPS recheck owned by origin_bounded_request The origin-bounded owner sends every hop without automatic redirects and refuses HTTPS downgrades, so the response URL check in _fetch_url_direct could never fire. The test now drives a downgrade redirect through the owner instead of faking a final URL. Refs #3726 Co-authored-by: Copilot App <[email protected]> * arch(auth): route the ADO file download through the redirect owner DownloadDelegate.resilient_get takes redirect_base instead of allow_redirects; when set, every retry attempt goes through origin_bounded_request bounded to that base, with ambient netrc excluded. download_ado_file passes its request URL, so no redirect is followed and a sign-in 3xx still reaches the auth-outcome classifier. The 429/503/connection retry and backoff loop is unchanged. A shared owner helper, unfollowed_redirect_request, returns the refused 3xx instead of raising; policy fetches and the Artifactory boundary probe use it too. The download_strategies entry leaves the origin-bounded-redirect inventory. apm-spec-waiver: redirect routing inside the approved auth and redirect owners Refs #3752, #3726 Co-authored-by: Copilot App <[email protected]> * test(install): retarget the GitHub probe integration double to the owner seam Refs #3752 Co-authored-by: Copilot App <[email protected]> * test(arch): pin the urllib metadata vector in the egress mutation case The authenticated-egress owner case now reintroduces urllib.request.urlopen in the marketplace metadata fetch; direct requests.get egress stays covered by the rule's unit tests. Refs #3726 Co-authored-by: Copilot App <[email protected]> * fix(auth): fold review panel findings on the egress guard - unfollowed_redirect_request now follows no redirect (max_hops=0), so a same-path 3xx is returned like any other; pinned with a real-socket test plus Artifactory and ADO download retry cases. - The validation GitHub probe treats a refused redirect as inconclusive and leaves the decision to the download step, with a verbose reason. - The egress guard reads its credential header vocabulary from CREDENTIAL_HEADER_NAMES (adds Proxy-Authorization) and pins an exact site count per inventory entry; the resilient_get reason now states what the code does. - deps/registry/auth.py header ownership narrows to RegistryAuthContext; owner records name the new helpers and consumers. - Tests assert the probe's token header and the REST header builders. apm-spec-waiver: review folds inside the approved auth and redirect owners Refs #3752, #3726 Co-authored-by: Copilot App <[email protected]> * fix(policy): keep URL credentials on direct policy fetches; widen egress prefilter - policy_get moves userinfo from a direct policy URL into an explicit Basic header through the new http_credentials.split_url_credentials owner helper, matching the previous requests behaviour. Redirect targets that embed userinfo stay refused. Covered by a transport-level test that only mocks the adapter send. - The egress guard prefilter also matches 'session', so session-receiver calls in modules without other HTTP tokens are scanned. - The no-follow regression test covers query and descendant-path shapes. apm-spec-waiver: review folds inside the approved auth and redirect owners Refs #3726 Co-authored-by: Copilot App <[email protected]> * test(install): make the Artifactory same-path redirect trap probe a real candidate Refs #3726 Co-authored-by: Copilot App <[email protected]> --------- Co-authored-by: danielmeppiel <[email protected]> Co-authored-by: Copilot App <[email protected]>
Reverts the previous wording change at @danielmeppiel's direction: #3752, #3753 and #3758 are closed by #3790. Co-authored-by: Copilot App <[email protected]>
The GitLab routing tests clear os.environ, but since #3790 the REST fallback reads git config through get_git_executable(). On Windows, with PATH cleared, git cannot be found unless an earlier test on the same xdist worker already cached it, so the tests fail depending on test order (build-release run 44233799606 on e217a53). Keep PATH, SYSTEMROOT and PATHEXT in the cleared env, and mark the module windows_compat so the PR-time Windows gate runs it. Co-authored-by: danielmeppiel <[email protected]> Co-authored-by: Copilot App <[email protected]>
* chore: release v0.36.1 Bump apm-cli to 0.36.1 in pyproject.toml and the apm-cli entry of uv.lock (no uv lock re-resolve), and cut the [Unreleased] CHANGELOG block into [0.36.1] - 2026-11-18 with upgrade notes. The #3771 and #3776 notes move into [0.36.0], where they shipped. Lint mirror (ruff check, ruff format --check, pylint R0801, auth-signals) is clean on main 70554b6. Post-merge: run the pre-tag gate on the merge commit, then tag v0.36.1. Co-authored-by: Copilot App <[email protected]> * docs(changelog): do not claim ADO issues fixed before a live-org check Co-authored-by: Copilot App <[email protected]> * docs(changelog): close the Azure DevOps issues in the 0.36.1 entry Reverts the previous wording change at @danielmeppiel's direction: #3752, #3753 and #3758 are closed by #3790. Co-authored-by: Copilot App <[email protected]> * docs(changelog): note SSE removals and the COPILOT_HOME skill scope in 0.36.1 upgrade notes Co-authored-by: Copilot App <[email protected]> * docs(changelog): drop the 0.36.1 upgrade-notes paragraph Patch releases carry upgrade details in their entries, as before. Co-authored-by: Copilot App <[email protected]> --------- Co-authored-by: danielmeppiel <[email protected]> Co-authored-by: Copilot App <[email protected]>

Description
fix(auth): route every Azure DevOps egress through one auth chain owner
TL;DR —
AuthResolver.try_with_fallbackis now the only way an authenticated request reaches a Git host. A new classifier (core/auth_outcome.py) decides what counts as an auth failure, and a new chain (core/auth_chain.py) walksADO_APM_PAT→azbearer → path-scopedgit credential fillfor every Azure DevOps operation. Users without a PAT orazsession can now install from Azure DevOps and read ADO-hosted org policy through Git Credential Manager, andazfailures report their real cause.Note
No live Azure DevOps organization was available. Behavior follows the documented Azure DevOps, Git credential and GCM contracts and is validated by hermetic unit tests and installed-binary lifecycle scenarios (local HTTPS proxy impersonating
dev.azure.comwith realgit http-backend; no network).Problem (WHY)
apm installstill never asks the Git credential helper for Azure DevOps packages; #2610 covered only the marketplace #3752 — install/validation/clone/ref resolution/--updatepreflight/file download each decided "auth failure" locally and only retried a PAT with theazbearer. With no PAT and noaz, the configured Git credential helper was never asked, althoughgit clonesucceeded with it.302 → *.vssps.visualstudio.com/_signinwas reported asRefusing HTTP redirect, so the chain never ran andfetch_failure_default: blocksuppressed lifecycle scripts.az login, or says a token was rejected, whenazfailed to issue a token #3753 — everyazfailure was mapped to "not logged in" and dropped; the diagnostic then claimed "Your az cli session … returned a bearer token, but Azure DevOps rejected it (HTTP 401)" even when no token was issued (for exampleAADSTS50076)._SECRET_REalso redacted the words "bearer token".status in (401, 403)lambdas,_check_html_signin, a magic"unauthorized"word, a hand-raisedRuntimeError). The architecture rule this violates: "Every durable decision, vocabulary, outcome, write, or contract has exactly ONE canonical owner."Approach (WHAT)
core/auth_outcome.py::classify_auth_outcomeAuthResolver.try_with_fallback(newremote_url=andattempts=kwargs)core/auth_chain.py::run_ado_chain,ADO_SERVICES_CHAIN/ADO_SERVER_CHAIN,AuthAttemptLogcore/token_manager.py::GitHelperCredential(host, port, path, username, password)AuthResolver._build_git_env(only formatter); HTTP reuses it viahttp_authorization_headers/AttemptAuthCall sites now report raw outcomes (
raise AuthAttemptFailed(response=…)or let Git errors propagate); they never classify.Implementation (HOW)
core/auth.pyrun_ado_chain;execute_with_bearer_fallback,BearerFallbackOutcome,build_ado_bearer_git_envremoved;is_public_github_auth_failureis a classifier wrapper; outcome-reported failures escalate only when classified as auth;build_error_context(attempts=…)renders #3753; helper cache per (host, port, path); ADO children get no echo askpass on POSIX. 2007 → 1820 lines.core/auth_outcome.py(new)AuthOutcomeKind(ok,auth_required,credential_rejected,not_found,throttled,network,tls,other),AuthOutcome,AuthAttemptFailed, frozenADO_SIGNIN_HOSTS,redact_secrets(token-shaped values only after whitespace),sanitize_diagnostic_detail(ASCII, redacted, picks the AADSTS line).core/auth_chain.py(new)run_ado_chain,AuthAttemptLog,AdoAuthChainExhaustedError(attempts=…),HelperCredentialCache(singleflight),ado_helper_path(org/project/_git/repo),authorization_headers,AttemptAuth(explicitauth=hook → no ambient netrc).core/token_manager.pyresolve_git_helper_credentialkeeps username + scope;credential_fill_envsetsGCM_INTERACTIVE=0when stdin is not a TTY orCIis set.core/azure_cli.pylast_errorkept on the provider; tenant lookup cached (≤1az account show).install/validation.py,install/pipeline.py,deps/github_downloader_validation.py,deps/clone_engine.py,deps/git_reference_resolver.py,deps/download_strategies.py::download_ado_file(allow_netrc=False),marketplace/ref_resolver.py,marketplace/client.py::_fetch_ado_rest,policy/discovery.py(ADO + GitHub withorg=ownerper-org PAT),policy/_gitlab.py.scripts/architecture_linter/checks/transport_auth_outcome.py→transport-platform-auth-outcome-owner, registered onhost-credential-resolution; one sortedMutationCase. Existing host-credential needles retargeted to the chain.getting-started/authentication.md,apm-guide/.../authentication.md,authskill, CHANGELOG.Diagram
Every ADO operation enters the owner once; each step runs only after the classifier reports an auth failure.
flowchart LR S["Call site: validation / clone / refs / preflight / download / policy / marketplace"] --> T["AuthResolver.try_with_fallback"] T --> P["ADO_APM_PAT or resolved bearer"] P -->|"auth failure"| B["az CLI bearer (Services only)"] B -->|"auth failure or no token"| H["git credential fill (org/project/_git/repo)"] H -->|"auth failure or none"| X["AdoAuthChainExhaustedError + AuthAttemptLog"] P -->|"network / TLS / not found"| R["re-raise unchanged"] C["classify_auth_outcome"] -.->|"decides every edge"| TTrade-offs
X-TFS-FedAuthRedirect(D4a) — the classifier handles 302/203 instead; the header is not documented.git credential approve/reject(D3a) — APM never mutates the user's store; a misclassified rejection cannot erase a credential. Guarded statically.AuthAttemptFailedoutcomes are classified, to avoid regressing GitHub/GitLab callers in a patch release.xfail(strict=False)— they depend on T2 (compilation-target policy check ignores the plural targets: key #3732), not on auth.Benefits
--frozen/-g/APM_HOMEsucceed with only GCM configured (lifecycle-proven).foundafter a sign-in redirect;compile/uninstalllifecycle scripts run underfetch_failure_default: block.azfailures show theAADSTSreason andaz login; at most oneaz account showper run.ADO_APM_PAT,az CLI bearer,git credential fillin order with each outcome.Issue and approved scope
Issue: Fixes #3752, Fixes #3758, Fixes #3753
Human scope-approval comments:
apm installstill never asks the Git credential helper for Azure DevOps packages; #2610 covered only the marketplace #3752 — [BUG]apm installstill never asks the Git credential helper for Azure DevOps packages; #2610 covered only the marketplace #3752 (comment)az login, or says a token was rejected, whenazfailed to issue a token #3753 — [BUG] Azure DevOps auth error tells users to runaz login, or says a token was rejected, whenazfailed to issue a token #3753 (comment)This PR completes all three. Out of scope (separate PRs): the origin-bounded redirect owner for registries/marketplace builder (#3726, PR 2) and the broad egress guard plus
lint-auth-signalscleanup (PR 3).Type of change
Testing
Validation
Regression tests were written first and failed on unmodified code (8/8):
Pre-fix run of tests/unit/core/test_ado_auth_chain_regressions.py
Post-fix results (all commands run locally, -p no:xdist)
pytest tests/unit/core/test_ado_auth_chain_regressions.py tests/unit/core/test_auth_outcome.pypytest tests/unit/marketplace tests/unit/test_install_command.py tests/unit/install/test_validation_ado_bearer.pypytest tests/integration/test_architecture_owner_rule_mutations.py tests/unit/scripts/test_architecture_runner.py(+ ADO/MCP/host-identity architecture tests)APM_BINARY_PATH=.venv/bin/apm pytest tests/integration/test_ado_credential_helper_install_lifecycle.pyAPM_BINARY_PATH=.venv/bin/apm pytest tests/integration/test_ado_policy_signin_redirect_lifecycle.py tests/integration/test_azure_cli_failure_diagnostic_lifecycle.py tests/integration/test_github_credential_scope_lifecycle.pypytest tests/quality·check_test_assertions.py·check_exact_test_duplicates.pyuvx [email protected] check/format --check(CI paths)pylint --enable=R0801 ...bash scripts/lint-auth-signals.sh·bash scripts/lint-architecture-boundaries.shrelative_toguardsScenario evidence
apm install <ado-url>with no PAT/noaz, GCM has a credential (brief sc. 1)test_ado_cli_install_uses_credential_helper_without_pat_or_az--frozen→outdated→update,-g,APM_HOME(sc. 2)test_ado_manifest_install_frozen_update_outdated_through_credential_helper,test_ado_user_scope_install_through_credential_helperpolicy status --no-cache,compile,uninstallwith ADO policy behind_signinredirect (sc. 3)test_policy_status_follows_signin_redirect_into_credential_helper,test_compile_/test_uninstall_lifecycle_runs_when_ado_policy_needs_credential_helperazfails with AADSTS50076 (sc. 4)test_azure_cli_token_failure_reports_aadsts_cause_not_a_rejected_tokentest_ado_exhausted_chain_names_every_step_in_orderCI=1→GCM_INTERACTIVE=0(sc. 8)test_ado_noninteractive_credential_fill_disables_helper_ui_in_citest_ado_pat_keeps_precedence_over_credential_helper,test_ado_resolved_credential_is_not_replaced_by_ambient_netrcGITHUB_APM_PAT_<ORG>test_github_policy_discovery_uses_org_scoped_credentialHow to test
uv run pytest tests/unit/core/test_ado_auth_chain_regressions.py tests/unit/core/test_auth_outcome.py -p no:xdistAPM_E2E_TESTS=1 APM_BINARY_PATH=$PWD/.venv/bin/apm uv run pytest tests/integration/test_ado_credential_helper_install_lifecycle.py -p no:xdistbash scripts/lint-architecture-boundaries.sh— then reintroduceif response.status_code in (401, 403):inpolicy/discovery.py::_fetch_ado_contentsand watchtransport-platform-auth-outcome-ownerfire.Spec conformance (OpenAPM v0.1)
CONFORMANCE.{md,json}regeneratedCo-authored-by: Copilot [email protected]