← Back to Pull requests

Fix correctness, concurrency, and style in DLPContentPolicy controller and mock #15467

Closed
unknown closed this pull request without merging on Nov 13, 2026 21:25 UTC
View on GitHub
unknown unknown commented on Nov 12, 2026 06:18 UTC
Author

Following review of PR #15398, this PR addresses correctness, concurrency safeguards, encapsulation, and code organization across pkg/controller/direct/dlp/ and mockgcp/mockdlp/:

Key Changes


  • Valid Kubernetes Resource Name in Export(): Updated Export() to set metadata.name using a.id.ContentPolicy instead of the full slash-separated GCP resource path a.id.String(), preventing RFC 1123 naming violations during apply.

  • Concurrency & In-Memory Isolation in ListContentPolicies: Cloned protobuf items prior to running defaulting logic and appending to response in mockdlp/contentpolicy.go, preventing data races and memory corruption on stored objects.

  • HTTPS URL Support & Error Propagation in AdapterForURL: Extended prefix matching to support both //dlp.googleapis.com/ and https://dlp.googleapis.com/, returning descriptive errors instead of silently swallowing malformed URLs.

  • Eliminated Redundant Project Lookups: Reused the parsed parent project and location in CreateContentPolicy to avoid duplicate Projects.GetProject() calls.

  • Encapsulation & Constructors: Added constructor functions newDLPServiceServer and newContentPolicyAdapter instead of direct cross-file struct literal instantiations.

  • Stepdown Call-Tree Ordering: Attached parsing helpers to dlpServiceServer and placed private helper methods directly below their first callers.

  • Unit Tests: Added comprehensive unit test suites with Arrange-Act-Assert structure in pkg/controller/direct/dlp/dlpcontentpolicy_controller_test.go and mockgcp/mockdlp/contentpolicy_test.go.
  • Fixes #15465

    ``release-note
    NONE
    ``

    This pull request was generated by an AI coding agent.

    <sub>🤖 Agent session</sub>

    <!-- factory:task-output kind=Change task=recipe-fix-20261112-055953-c50d -->

    Diff: 243 lines (+182 / -61) across 3 files Reviewer: anhdle-sso Review duration: 2347m
    All Vouch review confidence checks passed
    Residual risk 0.15 = Change Risk (0.39) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.39 · 243 lines diff across 3 files
    0.39
    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.329
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #15467"
    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: 38.8% (MEDIUM) · Higher = larger blast radius
    38.8%
    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: 15.3% · Safe to merge
    15.3%