← Back to Pull requests

[CONTP-2223] Cover DDGR fields and preserve monitor hash precision #3754

Closed
unknown closed this pull request without merging on Nov 10, 2026 17:13 UTC
View on GitHub
unknown unknown commented on Nov 10, 2026 10:57 UTC
Author

What does this PR do?

Follow-up to #3743, targeting levan/monitor-force-sync-remote-hash, with three commits:

1. Include supplied DDGR fields in monitor hashes. Add the top-level keys from jsonSpec to the existing definition fields and assets. The Go SDK preserves unknown keys through AdditionalProperties, so this detects drift in fields used before an SDK upgrade. If a supplied field is missing from the API response, keep the hash empty and retain force updates. The existing restriction-policy fallback remains.
2. Preserve JSON number precision. Use json.Decoder.UseNumber while building the hash projection. Adjacent integers such as 9007199254740992 and 9007199254740993 must produce different hashes, including inside options.
3. Document response-only fields. Note in the DDGR docs and in a code comment that every top-level jsonSpec field is hashed, so response-only fields belong out of jsonSpec.

Motivation

Addresses the DDGR allowlist review comment on #3743. A DDGR field can be sent successfully through the typed SDK yet be absent from the fixed hash projection, allowing external edits to go unnoticed.

The number change is defensive hardening discovered during adversarial review: converting SDK-preserved JSON numbers to float64 can erase a real difference before hashing. No current writable monitor API field requiring integers of this size was identified.

Additional Notes

  • DDGR augments the existing projection rather than hashing the whole response or expanding a global list for each new field. Unspecified response-only extras remain excluded. DatadogMonitor's field selection is unchanged.

  • Response-only fields left in jsonSpec (such as state or overall_state) are hashed too, so they cause extra updates. This is deliberate: a list of fields to filter out would bring back the risk of hiding drift if it wrongly excluded a writable field, while hashing them only costs updates. The DDGR docs now ask users to keep response-only fields out of jsonSpec, as the migration guide's jq step already does.

  • No additional API calls, API type changes, CRD changes, or dependency changes.

  • A changed numeric representation can cause an affected stored baseline to refresh through one force-sync update. Supplied fields absent from responses conservatively retain periodic writes.
  • Minimum Agent Versions

    No minimum Agent versions; this only affects Operator monitor hashing.

    Agent: N/A
    Cluster Agent: N/A

    Describe your test plan

  • The SDK/HTTP reconcile regression reproduced the unknown-field drift failure before the first fix; afterward, the field is repaired with one PUT and the following sync skips.

  • Cover supplied versus unspecified unknown fields, absent response fields, explicit null, and the existing restriction-policy fallback.

  • Large-integer regressions cover top-level additional properties and nested options. Both fail with the original decoder and pass with UseNumber.

  • GOTOOLCHAIN=go1.26.10 go test ./internal/controller/datadoggenericresource ./internal/controller/datadogmonitor ./internal/controller/utils -count=1 — passed.

  • GOTOOLCHAIN=go1.26.10 make lint — passed, zero issues.
  • These follow-up commits have not been live-tested against Datadog; the earlier kind QA covered parent commit f39c86866.

    Checklist

  • PR has at least one valid label: bug, enhancement, refactoring, documentation, tooling, and/or dependencies

  • PR has a milestone or the qa/skip-qa label

  • All commits are signed (see: [signing commits][1])
  • [1]: https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits

    Diff: 471 lines (+353 / -118) across 5 files Reviewer: levan-m Review duration: 375m
    All Vouch review confidence checks passed
    Residual risk 0.18 = Change Risk (0.46) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.46 · 471 lines diff across 5 files
    0.46
    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.368
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #3754"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% 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: 45.7% (MEDIUM) · Higher = larger blast radius
    45.7%
    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: 18.1% · Safe to merge
    18.1%