← Back to Pull requests

clusterapi: add NewProvider for in-memory configs and context lifecycle #10428

Open
patrostkowski opened this pull request with 527 lines diff across 5 files
View on GitHub
patrostkowski patrostkowski commented on Oct 14, 2026 08:09 UTC
Author

What type of PR is this?

/kind feature
/area provider/cluster-api

What this PR does / why we need it:

adds NewProvider so the clusterapi provider can be built from in-memory rest.Configs with a context bound lifecycle, for programs that run the CA core as a library

today BuildClusterAPI only reads kubeconfig paths, never stops its informers and calls klog.Fatal on every error

this PR adds:

  • NewProvider(ctx, ProviderOptions): takes management and workload rest.Configs, informers stop when ctx is done, returns errors instead of exiting

  • RegisterProcessors(cp, processors): wires the scale down upgrade processor, which needed the unexported controller before

  • Cleanup now stops the informers
  • BuildClusterAPI is a thin wrapper over both, same flags and same fatal on error behaviour for the stock binary

    Which issue(s) this PR fixes:

    Fixes #

    Special notes for your reviewer:

  • the scale down upgrade processor is now registered after controller.run() instead of before, it only holds a pointer to the controller so no effect

  • ExitCleanUp skips CloudProvider.Cleanup when --write-status-configmap=false, so ctx is the main way to stop it
  • Does this PR introduce a user-facing change?

    ``release-note
    clusterapi: add NewProvider for in-memory configs and context lifecycle, BuildClusterAPI behaviour is unchanged

    
    #### Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:
    
    
    docs
    NONE
    ``

    🤖 Generated with Claude Code

    Diff: 527 lines (+464 / -63) across 5 files Reviewer: sarkar-deb Review duration: 21014m
    All Vouch review confidence checks passed
    Residual risk 0.06 = Change Risk (0.70) × (1 − Review Confidence (0.92)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.70 · 527 lines diff across 5 files
    0.70
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.92 · 5 substantive comment(s)
    0.92
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    91%
    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.375
    Sensitive Paths sensitive_paths
    0.070
    Real PR Conversation Timeline
    11 items
    kubernetes-prow[bot] kubernetes-prow[bot] commented on Oct 14, 2026 08:09 UTC
    Bot

    This issue is currently awaiting triage.

    If SIG Autoscaling contributors determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

    The triage/accepted label can be added by org members by writing /triage accepted in a comment.

    <details>

    Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.
    </details>

    kubernetes-prow[bot] kubernetes-prow[bot] commented on Oct 14, 2026 08:09 UTC
    Bot

    Welcome @patrostkowski! <br><br>It looks like this is your first PR to <a href='https://github.com/kubernetes/autoscaler'>kubernetes/autoscaler</a> 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval. <br><br>You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation. <br><br>You can also check if kubernetes/autoscaler has its own contribution guidelines. <br><br>You may want to refer to our testing guide if you run into trouble with your tests not passing. <br><br>If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs! <br><br>Thank you, and welcome to Kubernetes. :smiley:

    kubernetes-prow[bot] kubernetes-prow[bot] commented on Oct 14, 2026 08:10 UTC
    Bot

    [APPROVALNOTIFIER] This PR is NOT APPROVED

    This pull-request has been approved by: <a href="https://github.com/kubernetes/autoscaler/pull/10428#" title="Author self-approved">patrostkowski</a>
    Once this PR has been reviewed and has the lgtm label, please assign elmiko for approval. For more information see the Code Review Process.

    The full list of commands accepted by this bot can be found here.

    <details open>
    Needs approval from an approver in each of these files:

  • cluster-autoscaler/cloudprovider/clusterapi/OWNERS
  • Approvers can indicate their approval by writing /approve in a comment
    Approvers can cancel approval by writing /approve cancel in a comment
    </details>
    <!-- META={"approvers":["elmiko"]} -->

    kubernetes-prow[bot] kubernetes-prow[bot] commented on Oct 14, 2026 08:10 UTC
    Bot

    Hi @patrostkowski. Thanks for your PR.

    I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

    Regular contributors should join the org to skip this step.

    Once the patch is verified, the new status will be reflected by the ok-to-test label.

    I understand the commands that are listed here.

    <details>

    Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.
    </details>

    linux-foundation-easycla[bot] linux-foundation-easycla[bot] commented on Oct 14, 2026 08:10 UTC
    Bot

    <a href="https://api.easycla.lfx.linuxfoundation.org/v2/repository-provider/github/sign/18706487/87990209/10428/#/?version=2"><img src="https://s3.amazonaws.com/cla-project-logo-prod/cla-missing-id.svg?v=2" alt="CLA Missing ID" align="left" height="28" width="328" ></a><br/><br ><ul><li>:white_check_mark: login: patrostkowski / name: Patryk Rostkowski (6207cf74dfeb3079788141040d27f9b26026517e)</li><li> :x: The email address for the commit (6207cf74dfeb3079788141040d27f9b26026517e) is not linked to the GitHub account, preventing the EasyCLA check. Consult <a href='https://linuxfoundation.atlassian.net/wiki/spaces/LP/pages/160923756/Missing+ID+on+Commit+but+I+have+an+agreement+on+file' target='_blank'>this Help Article</a> and <a href='https://help.github.com/en/github/committing-changes-to-your-project/why-are-my-commits-linked-to-the-wrong-user' target='_blank'>GitHub Help</a> to resolve. (To view the commit's email address, add .patch at the end of this PR page's URL.) For further assistance with EasyCLA, <a href='https://easycla.lfx.linuxfoundation.org/' target='_blank'>please visit our EasyCLA portal</a> and chat with our support bot.</li></ul>

    One or more co-authors of this pull request were not found. You must specify co-authors in commit message trailer via:

    Co-authored-by: name <email>
    

    Supported Co-authored-by: formats include:

    1) Anything <id+login@users.noreply.github.com> - it will locate your GitHub user by id part.
    2) Anything <login@users.noreply.github.com> - it will locate your GitHub user by login part.
    3) Anything <public-email> - it will locate your GitHub user by public-email part. Note that this email must be made public on Github.
    4) Anything <other-email> - it will locate your GitHub user by other-email part but only if that email was used before for any other CLA as a main commit author.
    5) login <any-valid-email> - it will locate your GitHub user by login part, note that login part must be at least 3 characters long.

    Alternatively, if the co-author should not be included, remove the Co-authored-by: line from the commit message.

    Please update your commit message(s) by doing git commit --amend and then git push [--force] and then request re-running CLA check via commenting on this pull request:

    /easycla
    

    coderabbitai[bot] coderabbitai[bot] commented on Oct 14, 2026 08:10 UTC
    Bot

    <!-- This is an auto-generated comment: summarize by coderabbit.ai -->
    <!-- review_stack_entry_start -->

    <a href="https://app.coderabbit.ai/change-stack/kubernetes/autoscaler/pull/10428?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&amp;cs_source=review_comment"><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=3"><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3" alt="Review in Change Stack →" height="32"></picture></a>

    <!-- review_stack_entry_end -->
    <!-- This is an auto-generated comment: skip review by coderabbit.ai -->

    [!IMPORTANT]

    ## Review skipped

    > Auto reviews are limited based on label configuration.

    > <details>

    <summary><strong>:no_entry_sign: Review skipped — only excluded labels are configured.: 2</strong></summary>

    <dl>

    <dd>

    > do-not-merge/work-in-progress

    cncf-cla: no

    > </dd>

    </dl>

    </details>

    > Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

    > <details>

    <summary><strong>⚙️ Run configuration</strong></summary>

    <dl>

    <dd>

    > - Configuration used: Repository: kubernetes/autoscaler/.coderabbit.yaml

    - Review profile: CHILL

    - Plan: Advanced

    - Run ID: dd0288bc-828b-4395-901a-c4d802b9e4d4

    > </dd>

    </dl>

    </details>

    > You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

    > Use the checkbox below for a quick retry:

    - [ ] <!-- {"checkboxId":"e9bb8d72-00e8-4f67-9cb2-caf3b22574fe"} --> 🔍 Trigger review

    <!-- end of auto-generated comment: skip review by coderabbit.ai -->

    <!-- finishing_touch_checkbox_start -->

    <details>
    <summary><strong>✨ Finishing Touches: 💡 1</strong></summary>
    <dl>
    <dd>

    <!-- finishing_touch_suggestion:fix_ci -->
    <details open>
    <summary><strong>🛠️ Fix failing CI checks: 💡</strong></summary>
    <dl>
    <dd>

  • <!-- {"checkboxId": "9f0d24fb-b419-4f01-baf0-8b26b6424f34", "radioGroupId": "fix-ci-output-choice-group-unknown_comment_id"} --> Commit to this branch

  • <!-- {"checkboxId": "6d21cfe8-ec3f-40e2-9222-b8318b64d3b0", "radioGroupId": "fix-ci-output-choice-group-unknown_comment_id"} --> Create a new PR
  • </dd>
    </dl>
    </details>
    <details open>
    <summary><strong>🧪 Generate unit tests (beta)</strong></summary>
    <dl>
    <dd>

  • <!-- {"checkboxId": "f47ac10b-58cc-4372-a567-0e02b2c3d479", "radioGroupId": "utg-output-choice-group-unknown_comment_id"} --> Create a new PR
  • </dd>
    </dl>
    </details>

    </dd>
    </dl>
    </details>

    <!-- finishing_touch_checkbox_end -->

    <!-- autopilot:start -->

  • <!-- {"checkboxId":"2708ad07-9f24-4260-9c11-7dc76a49f2e3"} --> <strong title="Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts">Autofix</strong> · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

  • <!-- autopilot:end -->
    <!-- tips_start -->

    <sub>Comment @coderabbitai help to get the list of available commands.</sub>

    <!-- tips_end -->

    patrostkowski patrostkowski commented on Oct 14, 2026 08:12 UTC
    Author

    /easycla

    sarkar-deb sarkar-deb commented on code on Oct 15, 2026 16:57 UTC
    Code Review
    cluster-autoscaler/cloudprovider/clusterapi/clusterapi_constructor.go:1
    @@ -0,0 +1,149 @@
    +/*
    +Copyright The Kubernetes Authors.
    +
    +Licensed under the Apache License, Version 2.0 (the "License");
    +you may not use this file except in compliance with the License.
    +You may obtain a copy of the License at
    +
    +    http://www.apache.org/licenses/LICENSE-2.0
    +
    +Unless required by applicable law or agreed to in writing, software
    +distributed under the License is distributed on an "AS IS" BASIS,
    +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +See the License for the specific language governing permissions and
    +limitations under the License.
    +*/
    +
    +package clusterapi
    +
    +import (
    +	"context"
    +	"fmt"
    +
    +	"k8s.io/client-go/discovery"
    +	"k8s.io/client-go/discovery/cached/memory"
    +	"k8s.io/client-go/dynamic"
    +	"k8s.io/client-go/kubernetes"
    +	"k8s.io/client-go/rest"
    +	"k8s.io/client-go/restmapper"
    +	"k8s.io/client-go/scale"
    +
    +	"sigs.k8s.io/cluster-autoscaler/pkg/cloudprovider"
    +	ca_processors "sigs.k8s.io/cluster-autoscaler/pkg/processors"
    +	"sigs.k8s.io/cluster-autoscaler/pkg/processors/scaledowncandidates"
    +)
    +
    +// ProviderOptions configures a Cluster API cloud provider built from in-memory REST configs.
    +// The configs are copied before use, client side rate limits (QPS, Burst) must be set on them by the caller.
    +type ProviderOptions struct {
    +	// ManagementConfig is the REST config of the cluster holding the Cluster API objects.
    +	ManagementConfig *rest.Config
    +	// WorkloadConfig is the REST config of the cluster whose nodes are autoscaled.
    +	WorkloadConfig *rest.Config
    +	// DiscoveryOptions selects the node groups, same as the --nodes and --node-group-auto-discovery flags.
    +	DiscoveryOptions cloudprovider.NodeGroupDiscoveryOptions
    +	// ResourceLimiter holds the cluster wide resource limits, it may be nil.
    +	ResourceLimiter *cloudprovider.ResourceLimiter
    +}
    +
    +// providerClients are the clients a Cluster API provider needs.
    +type providerClients struct {
    +	management dynamic.Interface
    +	workload   kubernetes.Interface
    +	discovery  discovery.DiscoveryInterface
    +	scale      scale.ScalesGetter
    +}
    +
    +// NewProvider builds a Cluster API cloud provider whose informers stop when ctx is done
    +// or when Cleanup is called. Unlike BuildClusterAPI it returns errors instead of exiting.
    +func NewProvider(ctx context.Context, opts ProviderOptions) (cloudprovider.CloudProvider, error) {
    +	if opts.ManagementConfig == nil {
    +		return nil, fmt.Errorf("management cluster config must not be nil")
    +	}
    +	if opts.WorkloadConfig == nil {
    +		return nil, fmt.Errorf("workload cluster config must not be nil")
    +	}
    +
    +	clients, err := newProviderClients(rest.CopyConfig(opts.ManagementConfig), rest.CopyConfig(opts.WorkloadConfig))
    +	if err != nil {
    +		return nil, err
    +	}
    +
    +	p, err := newProviderFromClients(ctx, clients, opts)
    +	if err != nil {
    +		return nil, err
    +	}
    +
    +	return p, nil
    +}
    +
    +func newProviderClients(managementConfig, workloadConfig *rest.Config) (providerClients, error) {
    +	// Grab a dynamic interface that we can create informers from
    +	managementClient, err := dynamic.NewForConfig(managementConfig)
    +	if err != nil {
    +		return providerClients{}, fmt.Errorf("could not generate dynamic client for config: %w", err)
    +	}
    +
    +	workloadClient, err := kubernetes.NewForConfig(workloadConfig)
    +	if err != nil {
    +		return providerClients{}, fmt.Errorf("create kube clientset failed: %w", err)
    +	}
    +
    +	managementDiscoveryClient, err := discovery.NewDiscoveryClientForConfig(managementConfig)
    +	if err != nil {
    +		return providerClients{}, fmt.Errorf("create discovery client failed: %w", err)
    +	}
    +
    +	cachedDiscovery := memory.NewMemCacheClient(managementDiscoveryClient)
    +	managementScaleClient, err := scale.NewForConfig(
    +		managementConfig,
    +		restmapper.NewDeferredDiscoveryRESTMapper(cachedDiscovery),
    +		dynamic.LegacyAPIPathResolverFunc,
    +		scale.NewDiscoveryScaleKindResolver(managementDiscoveryClient))
    +	if err != nil {
    +		return providerClients{}, fmt.Errorf("create scale client failed: %w", err)
    +	}
    +
    +	return providerClients{
    +		management: managementClient,
    +		workload:   workloadClient,
    +		discovery:  managementDiscoveryClient,
    +		scale:      managementScaleClient,
    +	}, nil
    +}
    +
    +func newProviderFromClients(ctx context.Context, clients providerClients, opts ProviderOptions) (*provider, error) {
    +	ctx, cancel := context.WithCancel(ctx)
    +
    +	controller, err := newMachineController(clients.management, clients.workload, clients.discovery, clients.scale, opts.DiscoveryOptions, ctx.Done())
    +	if err != nil {
    +		cancel()
    +		return nil, err
    +	}
    +
    +	if err := controller.run(); err != nil {
    +		cancel()
    +		return nil, err
    +	}
    +
    +	return &provider{
    +		providerName:    ProviderName,
    +		resourceLimiter: opts.ResourceLimiter,
    +		controller:      controller,
    +		stop:            cancel,

    The cancel function is saved inside your provider struct, but it hasn't been executed yet.
    If applications creates and destroys these providers over time, or if the main application runs for months, this tracking memory will slowly pile up and never be cleaned up by the Garbage Collector.

    patrostkowski patrostkowski commented on code on Oct 16, 2026 08:21 UTC
    Code Review
    cluster-autoscaler/cloudprovider/clusterapi/clusterapi_constructor.go:1
    @@ -0,0 +1,149 @@
    +/*
    +Copyright The Kubernetes Authors.
    +
    +Licensed under the Apache License, Version 2.0 (the "License");
    +you may not use this file except in compliance with the License.
    +You may obtain a copy of the License at
    +
    +    http://www.apache.org/licenses/LICENSE-2.0
    +
    +Unless required by applicable law or agreed to in writing, software
    +distributed under the License is distributed on an "AS IS" BASIS,
    +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +See the License for the specific language governing permissions and
    +limitations under the License.
    +*/
    +
    +package clusterapi
    +
    +import (
    +	"context"
    +	"fmt"
    +
    +	"k8s.io/client-go/discovery"
    +	"k8s.io/client-go/discovery/cached/memory"
    +	"k8s.io/client-go/dynamic"
    +	"k8s.io/client-go/kubernetes"
    +	"k8s.io/client-go/rest"
    +	"k8s.io/client-go/restmapper"
    +	"k8s.io/client-go/scale"
    +
    +	"sigs.k8s.io/cluster-autoscaler/pkg/cloudprovider"
    +	ca_processors "sigs.k8s.io/cluster-autoscaler/pkg/processors"
    +	"sigs.k8s.io/cluster-autoscaler/pkg/processors/scaledowncandidates"
    +)
    +
    +// ProviderOptions configures a Cluster API cloud provider built from in-memory REST configs.
    +// The configs are copied before use, client side rate limits (QPS, Burst) must be set on them by the caller.
    +type ProviderOptions struct {
    +	// ManagementConfig is the REST config of the cluster holding the Cluster API objects.
    +	ManagementConfig *rest.Config
    +	// WorkloadConfig is the REST config of the cluster whose nodes are autoscaled.
    +	WorkloadConfig *rest.Config
    +	// DiscoveryOptions selects the node groups, same as the --nodes and --node-group-auto-discovery flags.
    +	DiscoveryOptions cloudprovider.NodeGroupDiscoveryOptions
    +	// ResourceLimiter holds the cluster wide resource limits, it may be nil.
    +	ResourceLimiter *cloudprovider.ResourceLimiter
    +}
    +
    +// providerClients are the clients a Cluster API provider needs.
    +type providerClients struct {
    +	management dynamic.Interface
    +	workload   kubernetes.Interface
    +	discovery  discovery.DiscoveryInterface
    +	scale      scale.ScalesGetter
    +}
    +
    +// NewProvider builds a Cluster API cloud provider whose informers stop when ctx is done
    +// or when Cleanup is called. Unlike BuildClusterAPI it returns errors instead of exiting.
    +func NewProvider(ctx context.Context, opts ProviderOptions) (cloudprovider.CloudProvider, error) {
    +	if opts.ManagementConfig == nil {
    +		return nil, fmt.Errorf("management cluster config must not be nil")
    +	}
    +	if opts.WorkloadConfig == nil {
    +		return nil, fmt.Errorf("workload cluster config must not be nil")
    +	}
    +
    +	clients, err := newProviderClients(rest.CopyConfig(opts.ManagementConfig), rest.CopyConfig(opts.WorkloadConfig))
    +	if err != nil {
    +		return nil, err
    +	}
    +
    +	p, err := newProviderFromClients(ctx, clients, opts)
    +	if err != nil {
    +		return nil, err
    +	}
    +
    +	return p, nil
    +}
    +
    +func newProviderClients(managementConfig, workloadConfig *rest.Config) (providerClients, error) {
    +	// Grab a dynamic interface that we can create informers from
    +	managementClient, err := dynamic.NewForConfig(managementConfig)
    +	if err != nil {
    +		return providerClients{}, fmt.Errorf("could not generate dynamic client for config: %w", err)
    +	}
    +
    +	workloadClient, err := kubernetes.NewForConfig(workloadConfig)
    +	if err != nil {
    +		return providerClients{}, fmt.Errorf("create kube clientset failed: %w", err)
    +	}
    +
    +	managementDiscoveryClient, err := discovery.NewDiscoveryClientForConfig(managementConfig)
    +	if err != nil {
    +		return providerClients{}, fmt.Errorf("create discovery client failed: %w", err)
    +	}
    +
    +	cachedDiscovery := memory.NewMemCacheClient(managementDiscoveryClient)
    +	managementScaleClient, err := scale.NewForConfig(
    +		managementConfig,
    +		restmapper.NewDeferredDiscoveryRESTMapper(cachedDiscovery),
    +		dynamic.LegacyAPIPathResolverFunc,
    +		scale.NewDiscoveryScaleKindResolver(managementDiscoveryClient))
    +	if err != nil {
    +		return providerClients{}, fmt.Errorf("create scale client failed: %w", err)
    +	}
    +
    +	return providerClients{
    +		management: managementClient,
    +		workload:   workloadClient,
    +		discovery:  managementDiscoveryClient,
    +		scale:      managementScaleClient,
    +	}, nil
    +}
    +
    +func newProviderFromClients(ctx context.Context, clients providerClients, opts ProviderOptions) (*provider, error) {
    +	ctx, cancel := context.WithCancel(ctx)
    +
    +	controller, err := newMachineController(clients.management, clients.workload, clients.discovery, clients.scale, opts.DiscoveryOptions, ctx.Done())
    +	if err != nil {
    +		cancel()
    +		return nil, err
    +	}
    +
    +	if err := controller.run(); err != nil {
    +		cancel()
    +		return nil, err
    +	}
    +
    +	return &provider{
    +		providerName:    ProviderName,
    +		resourceLimiter: opts.ResourceLimiter,
    +		controller:      controller,
    +		stop:            cancel,

    this only leaks if the caller skips Cleanup, which is already breaking the contract, cancel runs in Cleanup and on the error paths, and in that case the informers leak too

    what I think we should do tho is make Cleanup call Shutdown() on both informer factories after cancel() so it blocks until the goroutines exit.

    wdyt @sarkar-deb?

    elmiko elmiko commented on Oct 16, 2026 18:15 UTC
    Contributor

    thanks for proposing this @patrostkowski , it's going to take me a few days to review. cc @LucasAndFlores you might want to take a look too.

    Reviewers
    Assignees
    patrostkowski patrostkowski
    Labels
    risk: low confidence: 91.7% 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: 69.5% (HIGH) · Higher = larger blast radius
    69.5%
    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: 91.7% · Lower = rushed or shallow review
    91.7%
    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: 5.8% · Safe to merge
    5.8%