← Back to Pull requests

Greenfield: Implement direct controller, E2E fixtures, and fuzzer for SecurityCenterManagementSecurityHealthAnalyticsCustomModule #16810

Open
unknown opened this pull request with 397 lines diff across 4 files
View on GitHub
unknown unknown commented on Nov 30, 2026 05:41 UTC
Author

This pull request was generated by an AI coding agent.

Implement direct controller logic, round-trip fuzzer verification, and minimal/maximal E2E test fixtures for SecurityCenterManagementSecurityHealthAnalyticsCustomModule (securitycentermanagement.cnrm.cloud.google.com/v1alpha1) following Greenfield Step 2:

  • Controller Logic:

  • - Verified GAPIC REST client options (m.config.RESTClientOptions()) with // +generated:controller in pkg/controller/direct/securitycentermanagement/securitycentermanagementsecurityhealthanalyticscustommodule_controller.go.
    - Added common.NormalizeGreenfieldReferences(ctx, reader, obj, nil) in AdapterForObject.
    - In Export, mapped obj.Spec.OrganizationRef = &refs.OrganizationRef{External: "organizations/" + a.id.Organization} and obj.Spec.Location = &a.id.Location.
    - Verified ServerGeneratedIdentity handling, common.CompareGreenfieldSpec diffing with structured reporting, and setStatus on all mutation and refresh paths.
  • Round-Trip Fuzzer:

  • - Verified deterministic fuzzer in pkg/controller/direct/securitycentermanagement/securitycentermanagementsecurityhealthanalyticscustommodule_fuzzer.generated.go.
    - Confirmed passing status via FOCUS=SecurityCenterManagementSecurityHealthAnalyticsCustomModule go test -v ./pkg/fuzztesting/fuzztests -run TestFocusedMappers.
  • E2E Test Fixtures:

  • - Created securitycentermanagementsecurityhealthanalyticscustommodule-minimal covering required fields (organizationRef, location, displayName, enablementState, customConfig) and in-place field updates (enablementState).
    - Created securitycentermanagementsecurityhealthanalyticscustommodule-maximal covering all declared spec fields, including customOutput.properties CEL expressions with title, description, and location.
    - Cleared satisfied exceptions in tests/apichecks/testdata/exceptions/alpha-missingfields.txt.
  • Service Journaling:

  • - Documented service behavior and constraints in .gemini/journals/securitycentermanagement.md: UpdateSecurityHealthAnalyticsCustomModuleRequest only accepts custom_config and enablement_state (making displayName immutable).
    - Documented real GCP organization-level permission limitations (securitycentermanagement.securityHealthAnalyticsCustomModules.create) on the test runner service account for organizations/${TEST_ORG_ID}, noting that HTTP golden logs will be generated and aligned via MockGCP in Step 3.

    Workflow feedback


    For organization-scoped resources, recording against real GCP via hack/record-gcp fails when the CI test runner service account only has project-level IAM bindings. Providing a graceful mechanism or explicit documentation for org-scoped mockgcp workflows would improve automation clarity.

    Fixes #16804

    ``release-note
    NONE
    ``

    Review Instructions

    Use .gemini/skills/reviewgen-greenfield-controller/SKILL.md to conduct the review.

    <sub>🤖 Agent session</sub>

    <!-- factory:task-output kind=Change task=recipe-fix-20261130-042803-8eae -->

    Diff: 397 lines (+297 / -100) across 4 files Reviewer: reviewbot-robot Review duration: 663m
    All Vouch review confidence checks passed
    Residual risk 0.38 = Change Risk (0.66) × (1 − Review Confidence (0.43)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.66 · 397 lines diff across 4 files
    0.66
    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%
    42%
    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.358
    Shallow Review Depth shallow_review_depth
    0.344
    Sensitive Paths sensitive_paths
    0.066
    Real PR Conversation Timeline
    1 comments
    "Review active on #16810"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: medium confidence: 43.0% 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: 66.4% (HIGH) · Higher = larger blast radius
    66.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: 43.0% · Lower = rushed or shallow review
    43.0%
    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: 37.9% · Moderate risk
    37.9%