← Back to Pull requests

fieldpath: preallocate capacity in PathElementSet and SetNodeMap set operations #352

Open
unknown opened this pull request with 650 lines diff across 8 files
View on GitHub
unknown unknown commented on Oct 28, 2026 19:27 UTC
Author

What type of PR is this?


/kind cleanup

What this PR does / why we need it


In fieldpath.PathElementSet and fieldpath.SetNodeMap, set operations (Union, Intersection, Difference, and RecursiveDifference) previously initialized result slices with zero capacity. As matching or differing elements were encountered, repeated append operations caused multiple internal slice reallocations and memory copies.

This PR preallocates output slice capacity up front when sizes are known or bounded, and short-circuits empty set cases cleanly without extra allocations while preserving nil slice semantics for empty sets (ensuring full compatibility with reflect.DeepEqual tests).

For Union, output slices are preallocated to max(len(s.members), len(s2.members)) rather than len(s.members) + len(s2.members) to avoid 2x overallocation and retained excess capacity when sets are identical or subsets (common across Server-Side Apply reconciliations and shared non-leaf schema paths).

Which issue(s) this PR fixes


Fixes #

Special notes for your reviewer


Authentic benchmark comparison on linux/amd64 using benchstat with n=10 iterations.

Reproduction command:

go test -run=^$ -bench='BenchmarkPathElementSetUnion|BenchmarkFieldSet/(union|intersection|difference|recursive-difference|leaves)' ./fieldpath -benchmem -count=10

Benchstat summary (n=10)

goos: linux
goarch: amd64
pkg: sigs.k8s.io/structured-merge-diff/v7/fieldpath
cpu: Intel(R) Xeon(R) CPU @ 2.20GHz
                                      │  before.txt   │              after.txt               │
                                      │    sec/op     │    sec/op     vs base                │
PathElementSetUnion/identical-20-24      1.805µ ±  9%   1.120µ ±  1%  -37.95% (p=0.000 n=10)
PathElementSetUnion/overlap50-20-24      1.813µ ±  5%   2.054µ ±  3%  +13.29% (p=0.000 n=10)
PathElementSetUnion/disjoint-20-24       2.840µ ±  7%   1.854µ ±  4%  -34.74% (p=0.000 n=10)
PathElementSetUnion/identical-100-24     6.761µ ±  9%   5.174µ ±  8%  -23.47% (p=0.000 n=10)
PathElementSetUnion/overlap50-100-24     7.598µ ±  5%   8.333µ ±  5%   +9.67% (p=0.000 n=10)
PathElementSetUnion/disjoint-100-24     10.373µ ±  4%   7.990µ ± 17%  -22.97% (p=0.000 n=10)
PathElementSetUnion/identical-500-24     26.84µ ±  6%   23.43µ ±  7%  -12.71% (p=0.000 n=10)
PathElementSetUnion/overlap50-500-24     40.10µ ±  5%   35.72µ ±  1%  -10.92% (p=0.000 n=10)
PathElementSetUnion/disjoint-500-24      41.00µ ±  6%   38.52µ ±  2%   -6.05% (p=0.000 n=10)
FieldSet/union-20-24                     10.14µ ±  4%   14.58µ ± 23%  +43.86% (p=0.000 n=10)
FieldSet/intersection-20-24              4.201µ ±  4%   6.604µ ±  2%  +57.20% (p=0.000 n=10)
FieldSet/difference-20-24                7.712µ ±  4%   8.873µ ±  4%  +15.05% (p=0.000 n=10)
FieldSet/recursive-difference-20-24      7.886µ ± 51%   9.189µ ± 20%        ~ (p=0.315 n=10)
FieldSet/leaves-20-24                    5.392µ ±  3%   7.431µ ± 38%  +37.82% (p=0.000 n=10)
FieldSet/union-50-24                     27.28µ ±  2%   36.09µ ±  3%  +32.28% (p=0.000 n=10)
FieldSet/intersection-50-24              11.47µ ±  4%   16.52µ ±  3%  +44.02% (p=0.000 n=10)
FieldSet/difference-50-24                19.40µ ±  4%   25.52µ ± 17%  +31.55% (p=0.000 n=10)
FieldSet/recursive-difference-50-24      21.27µ ±  3%   30.79µ ± 13%  +44.77% (p=0.000 n=10)
FieldSet/leaves-50-24                    18.41µ ±  4%   31.47µ ± 51%        ~ (p=0.143 n=10)
FieldSet/union-100-24                    55.95µ ±  2%   47.39µ ±  5%  -15.30% (p=0.000 n=10)
FieldSet/intersection-100-24             26.53µ ± 76%   24.81µ ±  2%   -6.46% (p=0.000 n=10)
FieldSet/difference-100-24               46.59µ ±  3%   37.53µ ±  2%  -19.44% (p=0.000 n=10)
FieldSet/recursive-difference-100-24     48.69µ ±  4%   38.98µ ±  3%  -19.94% (p=0.000 n=10)
FieldSet/leaves-100-24                   60.75µ ±  2%   56.43µ ±  2%   -7.11% (p=0.000 n=10)
FieldSet/union-500-24                    235.3µ ±  1%   199.1µ ±  1%  -15.37% (p=0.000 n=10)
FieldSet/intersection-500-24             127.7µ ±  1%   127.3µ ±  2%        ~ (p=0.739 n=10)
FieldSet/difference-500-24               211.5µ ±  4%   172.0µ ±  2%  -18.66% (p=0.000 n=10)
FieldSet/recursive-difference-500-24     218.3µ ±  2%   181.0µ ±  2%  -17.11% (p=0.000 n=10)
FieldSet/leaves-500-24                   348.5µ ±  1%   337.5µ ±  1%   -3.16% (p=0.000 n=10)
FieldSet/union-1000-24                   552.9µ ± 45%   473.3µ ±  8%  -14.41% (p=0.001 n=10)
FieldSet/intersection-1000-24            291.8µ ±  1%   289.9µ ±  1%        ~ (p=0.190 n=10)
FieldSet/difference-1000-24              484.9µ ±  3%   409.8µ ±  1%  -15.49% (p=0.000 n=10)
FieldSet/recursive-difference-1000-24    501.0µ ±  1%   442.3µ ±  2%  -11.70% (p=0.000 n=10)
FieldSet/leaves-1000-24                  794.5µ ±  1%   816.4µ ±  5%        ~ (p=0.075 n=10)
geomean                                  34.65µ         34.60µ         -0.13%

                                      │  before.txt   │              after.txt               │
                                      │     B/op      │     B/op      vs base                │
PathElementSetUnion/identical-20-24       2168.0 ± 0%     728.0 ± 0%  -66.42% (p=0.000 n=10)
PathElementSetUnion/overlap50-20-24      2.117Ki ± 0%   2.086Ki ± 0%   -1.48% (p=0.000 n=10)
PathElementSetUnion/disjoint-20-24       4.367Ki ± 0%   2.086Ki ± 0%  -52.24% (p=0.000 n=10)
PathElementSetUnion/identical-100-24     9.117Ki ± 0%   3.398Ki ± 0%  -62.72% (p=0.000 n=10)
PathElementSetUnion/overlap50-100-24     9.117Ki ± 0%   9.773Ki ± 0%   +7.20% (p=0.000 n=10)
PathElementSetUnion/disjoint-100-24     18.617Ki ± 0%   9.773Ki ± 0%  -47.50% (p=0.000 n=10)
PathElementSetUnion/identical-500-24     36.62Ki ± 0%   16.02Ki ± 0%  -56.24% (p=0.000 n=10)
PathElementSetUnion/overlap50-500-24     68.62Ki ± 0%   42.65Ki ± 0%  -37.85% (p=0.000 n=10)
PathElementSetUnion/disjoint-500-24      84.62Ki ± 0%   56.02Ki ± 0%  -33.79% (p=0.000 n=10)
FieldSet/union-20-24                     4.049Ki ± 0%   3.523Ki ± 0%  -13.00% (p=0.000 n=10)
FieldSet/intersection-20-24                683.0 ± 0%     731.0 ± 0%   +7.03% (p=0.000 n=10)
FieldSet/difference-20-24                2.457Ki ± 0%   1.546Ki ± 0%  -37.08% (p=0.000 n=10)
FieldSet/recursive-difference-20-24      2.458Ki ± 0%   1.547Ki ± 0%  -37.06% (p=0.000 n=10)
FieldSet/leaves-20-24                    2.661Ki ± 0%   2.533Ki ± 0%   -4.81% (p=0.000 n=10)
FieldSet/union-50-24                    11.273Ki ± 0%   9.604Ki ± 0%  -14.80% (p=0.000 n=10)
FieldSet/intersection-50-24              2.097Ki ± 0%   2.241Ki ± 0%   +6.87% (p=0.000 n=10)
FieldSet/difference-50-24                6.126Ki ± 0%   4.588Ki ± 0%  -25.11% (p=0.000 n=10)
FieldSet/recursive-difference-50-24      6.212Ki ± 0%   4.578Ki ± 0%  -26.31% (p=0.000 n=10)
FieldSet/leaves-50-24                    8.132Ki ± 0%   7.924Ki ± 0%   -2.55% (p=0.000 n=10)
FieldSet/union-100-24                    25.07Ki ± 0%   22.54Ki ± 0%  -10.10% (p=0.000 n=10)
FieldSet/intersection-100-24             4.007Ki ± 0%   4.001Ki ± 0%        ~ (p=0.138 n=10)
FieldSet/difference-100-24              15.886Ki ± 0%   9.415Ki ± 0%  -40.73% (p=0.000 n=10)
FieldSet/recursive-difference-100-24    16.542Ki ± 0%   9.415Ki ± 0%  -43.09% (p=0.000 n=10)
FieldSet/leaves-100-24                   30.36Ki ± 0%   30.35Ki ± 0%   -0.02% (p=0.002 n=10)
FieldSet/union-500-24                   119.72Ki ± 0%   91.26Ki ± 0%  -23.77% (p=0.000 n=10)
FieldSet/intersection-500-24             13.80Ki ± 1%   13.93Ki ± 1%   +0.92% (p=0.005 n=10)
FieldSet/difference-500-24               71.57Ki ± 0%   38.01Ki ± 0%  -46.90% (p=0.000 n=10)
FieldSet/recursive-difference-500-24     71.74Ki ± 0%   38.03Ki ± 0%  -46.99% (p=0.000 n=10)
FieldSet/leaves-500-24                   157.9Ki ± 0%   157.8Ki ± 0%   -0.08% (p=0.001 n=10)
FieldSet/union-1000-24                   207.8Ki ± 0%   189.7Ki ± 0%   -8.71% (p=0.000 n=10)
FieldSet/intersection-1000-24            34.02Ki ± 1%   34.28Ki ± 1%   +0.79% (p=0.023 n=10)
FieldSet/difference-1000-24             145.40Ki ± 0%   84.52Ki ± 0%  -41.87% (p=0.000 n=10)
FieldSet/recursive-difference-1000-24   146.12Ki ± 0%   84.39Ki ± 0%  -42.24% (p=0.000 n=10)
FieldSet/leaves-1000-24                  358.4Ki ± 0%   358.2Ki ± 0%        ~ (p=0.105 n=10)
geomean                                  16.14Ki        11.76Ki       -27.18%

                                      │ before.txt  │               after.txt               │
                                      │  allocs/op  │  allocs/op   vs base                  │
PathElementSetUnion/identical-20-24      7.000 ± 0%    2.000 ± 0%  -71.43% (p=0.000 n=10)
PathElementSetUnion/overlap50-20-24      7.000 ± 0%    3.000 ± 0%  -57.14% (p=0.000 n=10)
PathElementSetUnion/disjoint-20-24       8.000 ± 0%    3.000 ± 0%  -62.50% (p=0.000 n=10)
PathElementSetUnion/identical-100-24     9.000 ± 0%    2.000 ± 0%  -77.78% (p=0.000 n=10)
PathElementSetUnion/overlap50-100-24     9.000 ± 0%    3.000 ± 0%  -66.67% (p=0.000 n=10)
PathElementSetUnion/disjoint-100-24     10.000 ± 0%    3.000 ± 0%  -70.00% (p=0.000 n=10)
PathElementSetUnion/identical-500-24    11.000 ± 0%    2.000 ± 0%  -81.82% (p=0.000 n=10)
PathElementSetUnion/overlap50-500-24    12.000 ± 0%    3.000 ± 0%  -75.00% (p=0.000 n=10)
PathElementSetUnion/disjoint-500-24     12.000 ± 0%    3.000 ± 0%  -75.00% (p=0.000 n=10)
FieldSet/union-20-24                     39.00 ± 0%    34.00 ± 0%  -12.82% (p=0.000 n=10)
FieldSet/intersection-20-24              21.00 ± 0%    21.00 ± 0%        ~ (p=1.000 n=10) ¹
FieldSet/difference-20-24                32.00 ± 0%    27.00 ± 0%  -15.62% (p=0.000 n=10)
FieldSet/recursive-difference-20-24      32.00 ± 0%    27.00 ± 0%  -15.62% (p=0.000 n=10)
FieldSet/leaves-20-24                    55.00 ± 0%    52.00 ± 0%   -5.45% (p=0.000 n=10)
FieldSet/union-50-24                     130.0 ± 0%    119.0 ± 1%   -8.46% (p=0.000 n=10)
FieldSet/intersection-50-24              66.00 ± 0%    66.00 ± 0%        ~ (p=1.000 n=10) ¹
FieldSet/difference-50-24               101.00 ± 0%    92.00 ± 1%   -8.91% (p=0.000 n=10)
FieldSet/recursive-difference-50-24     102.00 ± 0%    92.00 ± 0%   -9.80% (p=0.000 n=10)
FieldSet/leaves-50-24                    183.0 ± 0%    178.0 ± 0%   -2.73% (p=0.000 n=10)
FieldSet/union-100-24                    261.0 ± 0%    209.0 ± 0%  -19.92% (p=0.000 n=10)
FieldSet/intersection-100-24             127.0 ± 0%    127.0 ± 0%        ~ (p=1.000 n=10)
FieldSet/difference-100-24               210.0 ± 0%    168.0 ± 0%  -20.00% (p=0.000 n=10)
FieldSet/recursive-difference-100-24     217.0 ± 0%    168.0 ± 0%  -22.58% (p=0.000 n=10)
FieldSet/leaves-100-24                   719.0 ± 0%    719.0 ± 0%        ~ (p=1.000 n=10) ¹
FieldSet/union-500-24                    899.0 ± 0%    725.5 ± 0%  -19.30% (p=0.000 n=10)
FieldSet/intersection-500-24             437.0 ± 1%    438.0 ± 0%        ~ (p=0.513 n=10)
FieldSet/difference-500-24               755.0 ± 0%    578.0 ± 1%  -23.44% (p=0.000 n=10)
FieldSet/recursive-difference-500-24     757.0 ± 0%    579.0 ± 1%  -23.51% (p=0.000 n=10)
FieldSet/leaves-500-24                  3.752k ± 0%   3.748k ± 0%   -0.11% (p=0.000 n=10)
FieldSet/union-1000-24                  2.066k ± 0%   1.825k ± 0%  -11.64% (p=0.000 n=10)
FieldSet/intersection-1000-24           1.081k ± 1%   1.079k ± 1%        ~ (p=0.930 n=10)
FieldSet/difference-1000-24             1.692k ± 0%   1.449k ± 0%  -14.34% (p=0.000 n=10)
FieldSet/recursive-difference-1000-24   1.705k ± 0%   1.446k ± 0%  -15.19% (p=0.000 n=10)
FieldSet/leaves-1000-24                 8.599k ± 0%   8.593k ± 0%   -0.07% (p=0.029 n=10)
geomean                                  116.7         77.06       -33.96%
¹ all samples are equal

Integration Benchmark (BenchmarkRequestCost in kubernetes/kubernetes, n=6)


To verify real-world server impact and ensure no regressions across Kubernetes API server operations, structured-merge-diff PR #352 (commit 450d1cd87be6f72d7da0bc0c4c04e09c27b0b46b) was vendored into kubernetes/kubernetes (base master commit 704449b06d6551d0b95c9f0257f225ef63636f6e) and evaluated using the upstream integration benchmark suite test/integration/apiserver/flowcontrol/cost/cost_test.go.

The test ran on a dedicated c3-standard-44 GKE node (Intel(R) Xeon(R) Platinum 8481C CPU @ 2.70GHz, Guaranteed QoS pod, static CPU pinning Cpus_allowed_list: 1-2,23-24, GOMAXPROCS=4, n=6 iterations).

Reproduction command:

go test -run=^$ -bench='^BenchmarkRequestCost$' ./test/integration/apiserver/flowcontrol/cost -benchmem -count=6

Benchstat summary: sec/op, B/op, allocs/op (n=6)

goos: linux
goarch: amd64
pkg: k8s.io/kubernetes/test/integration/apiserver/flowcontrol/cost
cpu: Intel(R) Xeon(R) Platinum 8481C CPU @ 2.70GHz
│  before.txt   │             after.txt              │
                                                                     │    sec/op     │    sec/op     vs base              │
RequestCost/Method=LIST/Options=N=100_rv=0/Format=json-4               6.476m ± 154%   6.475m ±  1%       ~ (p=0.699 n=6)
RequestCost/Method=LIST/Options=N=100_rv=0/Format=cbor-4               20.81m ±  36%   20.19m ±  1%  -2.99% (p=0.015 n=6)
RequestCost/Method=LIST/Options=N=100_rv=0/Format=table-4              6.057m ±  83%   5.851m ± 18%       ~ (p=0.818 n=6)
RequestCost/Method=WATCH/Options=N=100_rv=FIRST_RV/Format=protobuf-4    1.001 ±   0%    1.001 ±  0%       ~ (p=0.937 n=6)
RequestCost/Method=WATCH/Options=N=100_rv=FIRST_RV/Format=table-4       1.001 ±   0%    1.001 ±  0%       ~ (p=0.937 n=6)
RequestCost/Method=POST/Options=create/Format=json-4                   3.783m ±   5%   3.739m ±  8%       ~ (p=0.485 n=6)
RequestCost/Method=POST/Options=create/Format=protobuf-4               3.397m ±  43%   3.338m ± 21%       ~ (p=0.589 n=6)
RequestCost/Method=PATCH/Options=apply/Format=json-4                   5.540m ± 111%   5.391m ± 28%       ~ (p=0.699 n=6)
RequestCost/Method=PATCH/Options=apply/Format=protobuf-4               5.277m ±   7%   5.308m ± 15%       ~ (p=0.937 n=6)
RequestCost/Method=PATCH/Options=status_kubelet/Format=json-4          3.728m ±  17%   3.714m ± 15%       ~ (p=0.485 n=6)
RequestCost/Method=PATCH/Options=status_kubelet/Format=protobuf-4      3.524m ±   8%   3.547m ± 14%       ~ (p=1.000 n=6)
RequestCost/Method=DELETECOLLECTION/Options=N=100/Format=protobuf-4    444.0m ±  17%   500.1m ± 28%       ~ (p=0.132 n=6)
geomean                                                                18.67m          18.68m        +0.05%

│   before.txt   │              after.txt               │
                                                                     │      B/op      │      B/op       vs base              │
RequestCost/Method=LIST/Options=N=100_rv=0/Format=json-4               1013.6Ki ±  0%   1013.6Ki ±  0%       ~ (p=0.394 n=6)
RequestCost/Method=LIST/Options=N=100_rv=0/Format=cbor-4                6.869Mi ±  1%    6.868Mi ±  1%       ~ (p=1.000 n=6)
RequestCost/Method=LIST/Options=N=100_rv=0/Format=table-4               5.590Mi ± 10%    5.590Mi ± 10%       ~ (p=0.788 n=6)
RequestCost/Method=WATCH/Options=N=100_rv=FIRST_RV/Format=protobuf-4    732.0Ki ±  3%    731.0Ki ±  0%       ~ (p=0.420 n=6)
RequestCost/Method=WATCH/Options=N=100_rv=FIRST_RV/Format=table-4       3.126Mi ±  1%    3.126Mi ±  0%       ~ (p=0.818 n=6)
RequestCost/Method=POST/Options=create/Format=json-4                    553.8Ki ±  7%    530.3Ki ± 14%       ~ (p=0.485 n=6)
RequestCost/Method=POST/Options=create/Format=protobuf-4                508.1Ki ± 15%    517.4Ki ±  8%       ~ (p=0.937 n=6)
RequestCost/Method=PATCH/Options=apply/Format=json-4                    1.317Mi ±  4%    1.331Mi ±  8%       ~ (p=0.818 n=6)
RequestCost/Method=PATCH/Options=apply/Format=protobuf-4                1.215Mi ±  2%    1.249Mi ±  5%       ~ (p=0.180 n=6)
RequestCost/Method=PATCH/Options=status_kubelet/Format=json-4           737.0Ki ±  6%    750.9Ki ± 10%       ~ (p=0.699 n=6)
RequestCost/Method=PATCH/Options=status_kubelet/Format=protobuf-4       642.1Ki ±  5%    653.3Ki ±  5%       ~ (p=1.000 n=6)
RequestCost/Method=DELETECOLLECTION/Options=N=100/Format=protobuf-4     70.58Mi ±  0%    70.62Mi ±  0%       ~ (p=1.000 n=6)
geomean                                                                 1.801Mi          1.808Mi        +0.40%

│  before.txt  │             after.txt             │
                                                                     │  allocs/op   │  allocs/op   vs base              │
RequestCost/Method=LIST/Options=N=100_rv=0/Format=json-4               7.657k ±  0%   7.655k ± 0%       ~ (p=0.470 n=6)
RequestCost/Method=LIST/Options=N=100_rv=0/Format=cbor-4               92.76k ±  0%   92.75k ± 0%       ~ (p=0.961 n=6)
RequestCost/Method=LIST/Options=N=100_rv=0/Format=table-4              6.156k ±  0%   6.156k ± 0%       ~ (p=0.727 n=6)
RequestCost/Method=WATCH/Options=N=100_rv=FIRST_RV/Format=protobuf-4   2.429k ±  1%   2.428k ± 1%       ~ (p=0.859 n=6)
RequestCost/Method=WATCH/Options=N=100_rv=FIRST_RV/Format=table-4      15.03k ±  0%   15.02k ± 0%       ~ (p=0.372 n=6)
RequestCost/Method=POST/Options=create/Format=json-4                   5.901k ±  1%   5.900k ± 7%       ~ (p=0.853 n=6)
RequestCost/Method=POST/Options=create/Format=protobuf-4               5.686k ± 17%   5.710k ± 1%       ~ (p=0.699 n=6)
RequestCost/Method=PATCH/Options=apply/Format=json-4                   19.37k ±  2%   19.34k ± 8%       ~ (p=1.000 n=6)
RequestCost/Method=PATCH/Options=apply/Format=protobuf-4               19.12k ±  1%   19.08k ± 4%       ~ (p=0.368 n=6)
RequestCost/Method=PATCH/Options=status_kubelet/Format=json-4          8.406k ±  3%   8.156k ± 4%       ~ (p=0.240 n=6)
RequestCost/Method=PATCH/Options=status_kubelet/Format=protobuf-4      7.950k ±  0%   7.926k ± 0%       ~ (p=0.065 n=6)
RequestCost/Method=DELETECOLLECTION/Options=N=100/Format=protobuf-4    530.7k ±  0%   531.4k ± 0%       ~ (p=0.818 n=6)
geomean                                                                14.25k         14.22k       -0.27%

The complete 11-metric benchstat comparison and verbatim 72-run benchmark outputs (before.txt and after.txt) are documented in the PR comments:

  • Full 11-metric benchstat comparison and pod metadata

  • Verbatim raw benchmark logs (before.txt and after.txt)
  • Does this PR introduce a user-facing change?


    ``release-note
    NONE
    ``

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: mauriciopoppe Review duration: 47789m
    All Vouch review confidence checks passed
    Residual risk 0.33 = Change Risk (0.59) × (1 − Review Confidence (0.45)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.59 · 650 lines diff across 8 files
    0.59
    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%
    44%
    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.388
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #352"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 44.7% 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: 59% (MEDIUM) · Higher = larger blast radius
    59%
    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: 44.7% · Lower = rushed or shallow review
    44.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: 32.6% · Safe to merge
    32.6%