Skip to content

Commit e8b2bc4

Browse files
committed
chore(flowcontrol): document panic-free posture and enforce it with forbidigo
The package doc records why invariant panics are unnecessary and points to the files that own the details. A forbidigo rule bans panic() in pkg/epp/flowcontrol non-test files with no allowlist. Signed-off-by: Luke Van Drie <lukevandrie@google.com>
1 parent 724c717 commit e8b2bc4

2 files changed

Lines changed: 43 additions & 0 deletions

File tree

.golangci.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ linters:
1818
- durationcheck
1919
- errcheck
2020
- fatcontext
21+
- forbidigo
2122
- ginkgolinter
2223
- goconst
2324
- gocritic
@@ -53,7 +54,18 @@ linters:
5354
- goconst
5455
- dupword
5556
- prealloc
57+
# The panic ban applies only to pkg/epp/flowcontrol (non-test files); see that package's doc.go.
58+
- path-except: pkg/epp/flowcontrol/
59+
linters:
60+
- forbidigo
61+
- path: _test\.go$
62+
linters:
63+
- forbidigo
5664
settings:
65+
forbidigo:
66+
forbid:
67+
- pattern: ^panic$
68+
msg: "pkg/epp/flowcontrol is panic-free by design (see its doc.go); validate at the boundary and return an error"
5769
importas:
5870
no-unaliased: false # unaliased imports are allowed; only enforce when an alias is used
5971
alias:

pkg/epp/flowcontrol/doc.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
Copyright 2026 The llm-d Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
// Package flowcontrol wires the flow control system: the FlowController data plane and the
18+
// FlowRegistry control plane.
19+
//
20+
// The package tree is panic-free, enforced by a lint rule. Statistics have a single owner per
21+
// level, so there is no duplicated state for an invariant check to guard (see
22+
// registry/managedqueue.go and queue/priorityqueue.go); caller- and plugin-supplied values are
23+
// validated at the boundary and surfaced as errors; long-lived goroutines defer
24+
// utilruntime.HandleCrashWithLogger so an unknown bug is logged with component context before the
25+
// process exits. Recover-and-continue is not used: a goroutine that panicked mid-mutation cannot
26+
// prove its state is consistent.
27+
//
28+
// If SafeQueue ever becomes an injectable extension point again, queue-reported stats become
29+
// plugin output and accounting must move to booked-charge, settle-at-most-once validation at the
30+
// managedQueue boundary.
31+
package flowcontrol

0 commit comments

Comments
 (0)