← Back to Pull requests

Migrate tree debug stripping to Python #61623

Closed
unknown closed this pull request without merging on Nov 30, 2026 16:39 UTC
View on GitHub
unknown unknown commented on Nov 30, 2026 11:00 UTC
Author

<!--Please give us some feedback on your experience writing this PR ! https://app.datadoghq.com/forms/43db4c02-6837-400c-8083-692e141b1b88 !-->

What does this PR do?

Reworks https://github.com/DataDog/datadog-agent/pull/61348 so that both the implementation and the test change from bash to Python.

It also adds tests for a couple more cases, and simplifies the toolchain wiring (no need to pass a tree_driver explicitly).

Motivation

There was some offline discussion related to https://github.com/DataDog/datadog-agent/pull/61348#discussion_r4709166904 that sparked the attempt to revisit this. There are a few reasons why the change goes in a good direction:

  • It avoids all sorts of shell-related gotchas (the bots were complaining all the time about all the subtle ways in which it could fail) and makes the code easier to follow and to extend.

  • It adheres to the policy of avoiding bash where possible (https://github.com/DataDog/datadog-agent/blob/main/bazel/AGENTS.md#shell-portability--use-bash-as-a-last-resort) with all of the benefits of doing so.

  • It avoids userspace tool usage, facilitating the transition to RBE.

  • It makes it easier to reuse the code across platforms.

  • It sets up a pattern for future work where we can more easily stick to non-bash solutions for these sorts of toolchains.
  • Describe how you validated your changes

    Tests pass, and the affected packaging-related bits (i.e. the stripping of elf files in the integrations folder) show no drift.

    Additional Notes

    There's no significant performance regression at this point that would justify staying with shell (or away from Python in general). A local benchmark around stripping the integrations_runtime tree shows ~1.22s wall time for the original bash version versus ~1.70s for the new Python version.

    The drawback of this approach is that it adds a dependency on Python for this step, such that a Python update would require rerunning the action (which as we've seen has a negligible time cost today) and it requires materializing the Python runtime in Bazel's execution root in order to perform the action (extra setup time in a "cold" environment).

    Possible followups include extending this approach to the single-file action (allowing reuse of the same exact code to do the stripping in both cases) and to other platforms.

    Diff: 296 lines (+222 / -74) across 3 files Reviewer: alopezz Review duration: 339m
    All Vouch review confidence checks passed
    Residual risk 0.25 = Change Risk (0.63) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.63 · 296 lines diff across 3 files
    0.63
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    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.341
    Shallow Review Depth shallow_review_depth
    0.289
    Sensitive Paths sensitive_paths
    0.063
    Real PR Conversation Timeline
    1 comments
    "Review active on #61623"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed sensitive_module
    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: 63.2% (MEDIUM) · Higher = larger blast radius
    63.2%
    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: 60.5% · Lower = rushed or shallow review
    60.5%
    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: 24.9% · Safe to merge
    24.9%