← Back to Pull requests

Incremental state step 2: central recompute and diff #629

Closed
unknown closed this pull request without merging on Oct 06, 2026 15:01 UTC
View on GitHub
unknown unknown commented on Oct 05, 2026 19:03 UTC
Author

Implements Step 2 of [docs/incremental-state.md](docs/incremental-state.md) ("Central recompute and diff").

Key Changes


1. All inputs live in State:
- GatewayClass and GatewayAddresses are recorded into State.
- Stamped with a monotonically increasing revision counter (uint64) only on actual input mutations (spec, relevant metadata labels, secret data, configmap data, service ports/IP, etc.).
- Replaced len(gw.Status.Addresses) > 0 in CompileModel so status computation never reads the status we wrote.
2. Pure Output Computation (ComputeOutputs):
- Pure function computing desired statuses per Gateway, HTTPRoute, ListenerSet, BackendTLSPolicy, GatewayClass, proxy config, certificates, and resolved gateways.
- Status merging (preserving LastTransitionTime and foreign controller entries) happens purely at write time.
3. Central Recompute & Diff:
- State centrally recomputes and diffs desired statuses against previous outputs, emitting change events on per-kind channels.
- Background coalescing/debouncing worker batches rapid bursts of watch events.
- Updates the proxy and calls OnGatewaysUpdate centrally once per recompute when outputs change.
4. Simplified Reconcilers:
- Reconcilers now strictly record inputs into State and write merged status via WatchesRawSource(source.Channel(...)).
- Deleted all 19 cross-object EnqueueRequestsFromMapFunc mapping functions across all reconcilers.
5. Tests & Benchmarks:
- Added unit tests in pkg/state/state_test.go verifying diffing and dependency propagation without mapping functions (e.g. Namespace label change, ReferenceGrant deletion, ConfigMap corruption).
- Added BenchmarkState_Recompute in pkg/state/state_benchmark_test.go testing 100 Gateways and 1000 HTTPRoutes (~6.7ms per recompute).
- All unit tests and conformance/e2e suites pass.

Fixes #628

Diff: 239 lines (+179 / -60) across 2 files Reviewer: justinsb Review duration: 1197m
All Vouch review confidence checks passed
Residual risk 0.15 = Change Risk (0.37) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.37 · 239 lines diff across 2 files
0.37
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.328
Shallow Review Depth shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #629"
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: 37.2% (MEDIUM) · Higher = larger blast radius
37.2%
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: 14.7% · Safe to merge
14.7%