← Back to Pull requests

Verify AI Guard payload carriers across classic, OTLP, and standalone smoke scenarios #8647

Closed
unknown closed this pull request without merging on Dec 02, 2026 14:51 UTC
View on GitHub
unknown unknown commented on Nov 23, 2026 13:52 UTC
Author

What this tests

Adds AI Guard backend-intake smoke coverage (BaseAiGuardSmokeTests) across all five security smoke scenarios:

  • Test_SecuritySmoke_AiGuard in SECURITY_SMOKE

  • Test_SecuritySmokeOtlp_AiGuard in SECURITY_SMOKE_OTLP (inherits the assert_ddot_export fixture; gated in manifests/agent.yml on datadog-agent#60077 for easy-wins activation once bundled DDOT preserves OTLP MetaStruct bytes in a release)

  • Test_Standalone_AiGuard across APPSEC_APM_STANDALONE, APPSEC_STANDALONE_APM_STANDALONE, and AI_GUARD_STANDALONE
  • Verified at backend intake

    Sends a benign ALLOW evaluation (replaying aiguard_evaluate_post_8919fde6.json to reduce the chance of competing AppSec WAF retention) and asserts across both legacy and efficient v1 Agent payloads:

  • Request root span: USER_KEEP priority, AI Guard attribution (chunk samplingMechanism == AI_GUARD on v1 or _dd.p.dm=-13 on legacy; or, in APPSEC_STANDALONE_APM_STANDALONE, where an SDK such as Java may keep the request span as AppSec -5 before AI Guard evaluates, a valid two-hex-character _dd.p.ts carrying the TraceSource.AI_GUARD bit), and ai_guard.event (true/"true").

  • Evaluation span (resource == "ai_guard", matched across split chunks by trace_id): USER_KEEP priority, ai_guard.action=ALLOW, and unchanged structured messages payload (metaStruct["ai_guard"] on legacy, attributes["ai_guard"] on v1).
  • Infrastructure & metadata

  • Enables DD_AI_GUARD_* (FakeDatadogKey.AI_GUARD_API/AI_GUARD_APP, which do not replace the Agent's FakeDatadogKey.DEFAULT key) and attaches VCRCassettesContainer (read-only cassette mount) in utils/_context/_scenarios/security_smoke.py (SecuritySmoke, SecuritySmokeOtlp) and utils/_context/_scenarios/appsec_standalone.py.

  • Maps utils/build/docker/vcr/cassettes/aiguard/aiguard_evaluate_post_8919fde6.json to all smoke scenarios in utils/scripts/libraries_and_scenarios_rules.yml (with tests in tests/test_the_test/test_compute_libraries_and_scenarios.py).

  • Declares activation/markers across manifests/agent.yml and library manifests (java, nodejs, python, ruby, cpp_nginx, dotnet, golang, php), matching existing AI Guard SDK and OTLP MetaStruct gates.
  • Validation

  • ./format.sh and git diff --check passed.

  • ./run.sh TEST_THE_TEST tests/test_the_test/test_compute_libraries_and_scenarios.py tests/test_the_test/test_manifest.py tests/test_the_test/test_scenarios_declaration.py tests/test_the_test/test_conventions.py: 166 passed.

  • Live Docker SECURITY_SMOKE_OTLP (--runxfail) with dev Agent 7.87.0-devel+git.1178.ad44a3c (datadog-agent#60077):

  • - Java (spring-boot, 1.70.0-SNAPSHOT with dd-trace-java#13391): passed.
    - Python (flask-poc, 4.17.2): passed.
  • Live Docker SECURITY_SMOKE_OTLP with unfixed Agent 7.85.4:

  • - Java (1.70.0-SNAPSHOT, --runxfail): failed as expected (lost _dd.p.dm=-13 and flattened ai_guard to a raw base64 string in meta instead of metaStruct).
    - Python (4.17.2, default manifest): xfailed cleanly via manifests/agent.yml.
  • Live Docker AI_GUARD_STANDALONE on Python (flask-poc, 4.17.2) + Agent 7.85.4: passed.

  • Replayed BaseAiGuardSmokeTests against captured Java (spring-boot, 1.70.0-SNAPSHOT) + Agent 7.85.4 traces from SECURITY_SMOKE, APPSEC_APM_STANDALONE, and APPSEC_STANDALONE_APM_STANDALONE: 3/3 passed.
  • Diff: 436 lines (+327 / -109) across 5 files Reviewer: christophe-papazian Review duration: 13018m
    All Vouch review confidence checks passed
    Residual risk 0.27 = Change Risk (0.68) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.68 · 436 lines diff across 5 files
    0.68
    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.364
    Shallow Review Depth shallow_review_depth
    0.289
    Sensitive Paths sensitive_paths
    0.068
    Real PR Conversation Timeline
    1 comments
    "Review active on #8647"
    general weight: 0.35
    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: 68.4% (HIGH) · Higher = larger blast radius
    68.4%
    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: 27% · Safe to merge
    27%