← Back to Pull requests

AI-7283 Compare branch dependency changes against their base branch before triggering the Agent build #25545

Open
unknown opened this pull request with 650 lines diff across 8 files
View on GitHub
unknown unknown commented on Oct 07, 2026 14:55 UTC
Author

What does this PR do?


Makes build-agent-auto compare a branch's dependency changes against the branch it was cut from, instead of against the previous push:

  • On non-master branches, rules:changes uses compare_to: refs/heads/master. Master keeps the previous-push comparison.

  • ddev release branch create rewrites that compare_to to the new release branch, in the same commit that points the trigger at the Agent release branch. Branches cut from a release branch inherit its YAML and compare against the release. This rewrite always happens: unlike the trigger branch, it doesn't wait for the DataDog/datadog-agent branch to exist.

  • The dependency-bump PR notice now says to run build-agent-manual when no Agent build was triggered.
  • Tracked in AI-7283.

    Motivation


    On 2026-09-17, a bulk rebase of month-old PRs triggered hundreds of datadog-agent pipelines (thread). Without compare_to, branch pipelines diff against the previous push. Rebasing a stale branch onto master therefore pulls in master's .deps changes. For example, the force-push a3000d85cb -> ff99b109c3 on #24422 had an 803-file diff that included .deps/*, even though the PR only changes traefik_mesh/tests/test_unit.py.

    compare_to only sees the branch's own changes, because GitLab diffs the branch against its merge base with compare_to, not against the tip of compare_to. When compare_to is set, the rules:changes clause calls Ci::Pipeline#modified_paths_since:

    project.repository.diff_stats(project.repository.merge_base(compare_to_sha, sha), sha).paths
    

    It has worked this way since compare_to was introduced in gitlab!90968. I also checked it on a scratch gitlab.com project with real pushes. old-rule is the current rule, and new-rule is the one in this PR:

    | Push | old-rule | new-rule |
    |---|---|---|
    | New branch, tests only | runs | skipped |
    | Second push to that branch, tests only | skipped | skipped |
    | Master bumps .deps | runs | runs |
    | Stale branch rebased onto master and force-pushed | runs | skipped |
    | Stale branch merges master | runs | skipped |
    | New branch that bumps .deps | runs | runs |
    | Follow-up push to that branch, tests only | skipped | runs |

    The first row comes from GitLab treating a branch's first push as having no previous push to compare against, so changes without compare_to matches whatever files changed (Gitlab::Git::Push#branch_added?, return true unless modified_paths). That's what happened when I pushed directly to gitlab.com. I didn't see it on gitlab.ddbuild.io, where branches come in through the GitHub mirror. The first GitLab pipeline of five recent branches (kyle.neale/iris-pp-assets, nubtron/velero-kubectl-download-retry, guillermo.julian/kueue-ha, aarakke/github-async-for-new-features, zhengda.lu/mongodb-9-support) triggered no datadog-agent pipeline, while this PR's first pipeline triggered one. Between 2026-09-20 and 2026-10-06, 415 branches ran GitLab pipelines and 99 Agent builds were triggered.

    The last row is the trade-off. Once a branch changes dependencies, every later push to it triggers an Agent build, not just pushes that touch .deps. After the lockfile commit, extra pushes to dependency-bump PRs are already discouraged, because they invalidate wheel promotion.

    Release branches

    #22302 removed an earlier compare_to: "master" for branches cut from release branches. Comparing those branches to master counts every commit that exists only on the release branch as the branch's own change. That includes the release's .deps lockfiles and the branch: 7.x.x trigger rewrite. On the current release branches:

    7.82.x: release-only commits=16, deps/build_agent paths differing from merge-base=8
    7.83.x: release-only commits=16, deps/build_agent paths differing from merge-base=7
    7.84.x: release-only commits=17, deps/build_agent paths differing from merge-base=8
    

    With the compare_to rewrite, a dependency bump cut from a release branch triggers the Agent build against that release when its own changes touch .deps, and backports that don't touch dependencies don't trigger it. datadog-agent already uses the same pattern on our GitLab instance: its COMPARE_TO_BRANCH is main on main and 7.84.x on 7.84.x. Release branches cut before this change keep their own copy of the YAML, so their previous-push rule is unchanged. This needs to land before 7.86.x is cut.

    Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)

  • Add qa/required if this PR needs QA validation, or qa/skip-qa if it does not. Exactly one of the two is required.

  • If you need to backport this PR to another branch, you can add the backport/<branch-name> label to the PR and it will automatically open a backport PR once this one is merged
  • [AI-7283]: https://datadoghq.atlassian.net/browse/AI-7283?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: iliakur Review duration: 7372m
    All Vouch review confidence checks passed
    Residual risk 0.28 = Change Risk (0.52) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #25545"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 27.7% · Safe to merge
    27.7%