Skip to content

ci(prcheck): use 'azldev component changed' for affected-component detection#17065

Merged
christopherco merged 1 commit intomicrosoft:tomls/base/mainfrom
dmcilvaney:damcilva/4.0/pipelines/delta_2_changed_detection
May 10, 2026
Merged

ci(prcheck): use 'azldev component changed' for affected-component detection#17065
christopherco merged 1 commit intomicrosoft:tomls/base/mainfrom
dmcilvaney:damcilva/4.0/pipelines/delta_2_changed_detection

Conversation

@dmcilvaney
Copy link
Copy Markdown
Contributor

@dmcilvaney dmcilvaney commented May 6, 2026

Replace the bash git diff … | grep '/sources$' step with structured azldev commands for lock validation, change detection, and scoped render verification.

Pipeline step order

  1. Lock checkazldev component update --check-only. Validates without writing; exits nonzero if any lock would change. Output JSON published as a triage artifact.
  2. Changed-component detectionazldev component changed --include-unchanged. Writes the full per-component JSON to disk, published as a triage artifact. azldev hard-fails natively if any component has sourcesChange == true without a corresponding identity change (changeType not in {added, changed, deleted}) — supply-chain drift tripwire. Prevents unauthenticated rewrites of the rendered sources file under an existing component's identity.
  3. Render verification — render the union of (azldev-flagged components) + (components whose spec tree was edited directly in the PR), in --check-only mode: azldev renders to a staging area and diffs against on-disk output without writing. Exits nonzero if any component's rendered output would change, catching both stale renders and direct hand-edits.
  4. Prcheck API — switches from --components <csv> to --changed-components-file <path>, filtering to entries with sourcesChange == true and changeType in {added, changed} (allow-list).

PR check remains advisory until ADO task 19179 removes job-level continueOnError.

Upload set filter

changeType sourcesChange Included? Why
added true yes New component with tarballs to upload
changed true yes Existing component whose tarballs changed
changed false no Inputs changed but sources file didn't — rebuild only
unchanged * no Not in allow-list
deleted * no Not in allow-list
(unknown) * no Fail closed — not in allow-list

New files

  • verify_locks.sh — runs azldev component update --check-only, publishes the lock-update JSON for triage.
  • compute_changed.sh — runs azldev component changed, publishes the changed-components JSON for triage. azldev's native consistency tripwire (Patch lua CVE-2019-6706, CVE-2020-15888, nopatch CVE-2020-24342 #169) is what hard-fails on sourcesChange + unchanged.
  • render_and_verify.sh — computes the render set (azldev-flagged ∪ specs-diff) and runs azldev component render --check-only against it.
  • compute_render_set.py — computes the render set as the union of azldev-flagged components and components with hand-edited specs. Deleted and unknown components are filtered out using the full --include-unchanged JSON.

Also

  • Add --changed-components-file flag (mutually exclusive with --components) and _load_components_from_file() to run_prcheck.py.
  • Document AZLDEV_ALLOW_ROOT in ADO pipeline instructions (OneBranch containers run as root, azldev refuses by default). Set inline as a per-command prefix, not at step level.
  • Switch API_BASE_URL to $(ApiBaseDirectUrl) (bypasses Azure Front Door).
  • Mark changedComponentsFile pipeline variable as isreadonly=true.

Requires

  • azldev versions with component update --check-only, component render --check-only, native consistency-check hard-fail in component changed, and [] (not null) for empty JSON output. Pinned via AzldevCommit in the variable group.

@dmcilvaney dmcilvaney force-pushed the damcilva/4.0/pipelines/delta_2_changed_detection branch 10 times, most recently from 023bba4 to 427cb41 Compare May 8, 2026 04:40
@dmcilvaney dmcilvaney marked this pull request as ready for review May 8, 2026 04:41
Copilot AI review requested due to automatic review settings May 8, 2026 04:41
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the Control Tower “sources-upload” ADO PR check to rely on structured azldev outputs (locks + changed-components JSON) instead of ad-hoc git diff | grep '/sources$', enabling scoped spec rendering and a safer upload allow-list.

Changes:

  • Add --changed-components-file support to run_prcheck.py and derive the upload set from azldev component changed JSON.
  • Introduce compute_render_set.py to union “azldev-changed” components with components whose rendered specs were edited directly.
  • Reorder/expand the ADO pipeline steps to: validate locks, compute changed-components, enforce a sources/identity tripwire, scoped render + rendered-tree verification, and call the prcheck API.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 9 comments.

File Description
.github/workflows/scripts/control-tower/run_prcheck.py Adds --changed-components-file option and filters upload components from azldev’s changed-components JSON.
.github/workflows/scripts/control-tower/compute_render_set.py New helper to compute the render set from changed-components JSON + specs-dir git diff.
.github/workflows/ado/templates/sources-upload-stages.yml Pipeline now validates locks, computes changed-components JSON, enforces a sources/identity consistency check, and does scoped rendering before prcheck submission.
.github/instructions/ado-pipeline.instructions.md Documents AZLDEV_ALLOW_ROOT=1 usage for CI runs.

Comment thread .github/workflows/scripts/control-tower/run_prcheck.py Outdated
Comment thread .github/workflows/scripts/control-tower/compute_render_set.py
Comment thread .github/workflows/scripts/control-tower/compute_render_set.py
Comment thread .github/workflows/ado/templates/sources-upload-stages.yml Outdated
Comment thread .github/workflows/ado/templates/sources-upload-stages.yml Outdated
Comment thread .github/workflows/ado/templates/sources-upload-stages.yml Outdated
Comment thread .github/workflows/ado/templates/sources-upload-stages.yml Outdated
Comment thread .github/workflows/ado/templates/sources-upload-stages.yml Outdated
Comment thread .github/instructions/ado-pipeline.instructions.md Outdated
@dmcilvaney dmcilvaney force-pushed the damcilva/4.0/pipelines/delta_2_changed_detection branch from 427cb41 to fe7fc1c Compare May 8, 2026 05:58
Comment thread .github/workflows/ado/templates/sources-upload-stages.yml Outdated
@dmcilvaney
Copy link
Copy Markdown
Contributor Author

ymls have gotten a bit messy, going to break them into scripts

@dmcilvaney dmcilvaney requested a review from Copilot May 8, 2026 19:54
@dmcilvaney dmcilvaney force-pushed the damcilva/4.0/pipelines/delta_2_changed_detection branch from b463476 to 09756ae Compare May 8, 2026 19:55
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.

Comment thread .github/workflows/scripts/control-tower/verify_locks.sh Outdated
Comment thread .github/workflows/scripts/control-tower/compute_changed.sh Outdated
Comment thread .github/workflows/scripts/control-tower/compute_changed.sh Outdated
Comment thread .github/workflows/scripts/control-tower/consistency_check.sh Outdated
Comment thread .github/workflows/scripts/control-tower/render_and_verify.sh
Comment thread .github/instructions/ado-pipeline.instructions.md Outdated
@dmcilvaney dmcilvaney marked this pull request as draft May 8, 2026 20:11
Comment thread .github/workflows/scripts/control-tower/compute_changed.sh Outdated
Comment thread .github/workflows/ado/templates/sources-upload-stages.yml Outdated
Comment thread .github/workflows/ado/templates/sources-upload-stages.yml Outdated
Comment thread .github/workflows/ado/templates/sources-upload-stages.yml Outdated
echo "##[endgroup]"

echo "##[group]Changed components (non-unchanged only)"
jq '(. // []) | [.[] | select(.changeType != "unchanged")]' "$json_file"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like we're removing unchanged components. If that's the case, what's the point of --include-unchanged above?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Useful later in the pipeline for other filtering, it gives us a full list of every expected component.

json_file="$artifact_dir/changed-components.json"
mkdir -p "$artifact_dir"

# 'azldev component changed' compares the source and target commits and emits one
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will azldev component changed catch changes if the branches are in an invalid state. As in: someone forgot to update the lock files or render the specs?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a bunch of validatoin logic in azldev, but right now its off by default. Once it turns on bad configurations will generate errors.

@dmcilvaney dmcilvaney force-pushed the damcilva/4.0/pipelines/delta_2_changed_detection branch from 09756ae to 310132d Compare May 9, 2026 00:58
@dmcilvaney dmcilvaney marked this pull request as ready for review May 9, 2026 04:59
@dmcilvaney dmcilvaney force-pushed the damcilva/4.0/pipelines/delta_2_changed_detection branch from e511c8e to 5a8c62b Compare May 9, 2026 23:03
@dmcilvaney dmcilvaney requested a review from Copilot May 9, 2026 23:31
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Comment thread .github/workflows/scripts/control-tower/verify_locks.sh
Comment thread .github/workflows/scripts/control-tower/render_and_verify.sh
Comment thread .github/workflows/scripts/control-tower/verify_locks.sh
Comment thread .github/workflows/scripts/control-tower/compute_changed.sh
Comment thread .github/workflows/scripts/control-tower/run_prcheck.py
Comment thread .github/workflows/scripts/control-tower/compute_changed.sh
Comment thread .github/workflows/scripts/control-tower/render_and_verify.sh
…tection

Replace the bash 'git diff | grep /sources' step with structured azldev
commands for lock validation, change detection, and scoped rendering.

Pipeline step order:
  1. Lock check -- 'azldev component update -a -q -O json', fail if any
     component has changed == true. Lock-update JSON published as a
     pipeline artifact for triage.
  2. Changed-component detection -- 'azldev component changed
     --include-unchanged' writes the full per-component JSON to disk,
     published via ob_outputDirectory. The --include-unchanged flag
     ensures the JSON contains every known component, which is needed
     for the renderable-set filter in step 4.
  3. Source/identity consistency tripwire -- hard-fail if any component
     reports sourcesChange == true with a changeType not in the
     allow-list {added, changed, deleted}. Prevents unauthenticated
     rewrites of the rendered 'sources' file under an existing
     component's identity. Data path is severed (subsequent steps
     skip); PR check remains advisory until ADO task 19179 removes
     job-level continueOnError.
  4. Scoped render -- render set is the union of components flagged by
     'azldev component changed' (inputs differ) and components whose
     spec tree was touched directly in the PR (git diff under specs/,
     mapped back to component names by compute_render_set.py). Deleted
     and unknown components are excluded via a renderable-set filter
     built from the full --include-unchanged JSON.
  5. Prcheck API -- switches from --components <csv> to
     --changed-components-file <path>, filtering to entries with
     sourcesChange == true and changeType in {added, changed}
     (allow-list, mirroring the consistency tripwire).

Also:
* Add --changed-components-file flag (mutually exclusive with
  --components) and _load_components_from_file() to run_prcheck.py.
  Uses an allow-list of changeType values for defense-in-depth.
* Add compute_render_set.py for render-set computation.
* Document AZLDEV_ALLOW_ROOT in ADO pipeline instructions (OneBranch
  containers run as root, azldev refuses by default).
* Mark changedComponentsFile pipeline variable as isreadonly=true.
* Switch API_BASE_URL to $(ApiBaseDirectUrl) (bypasses AFD).
@dmcilvaney dmcilvaney force-pushed the damcilva/4.0/pipelines/delta_2_changed_detection branch from e47001f to 9647ebc Compare May 10, 2026 05:14
@christopherco christopherco merged commit a73bdeb into microsoft:tomls/base/main May 10, 2026
10 checks passed
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.

4 participants