config: reject non-positive periodic intervals before ticker creation
#2,475 opened on Jul 12, 2026
Repository metrics
- Stars
- (4,293 stars)
- PR merge metrics
- (PR metrics pending)
Description
Summary
Validate every ticker-driving duration before runtime construction and make periodic start/close lifecycle idempotent. Owner surfaces: src/semantic-router/pkg/selection/elo.go, src/semantic-router/pkg/selection/rl_driven.go, src/semantic-router/pkg/selection/lookuptable/file.go, src/semantic-router/pkg/extproc/router_selection.go, and src/semantic-router/pkg/config/validator_learning.go.
Current behavior
Syntactically valid zero or negative durations can reach ticker construction and panic the process or leave periodic behavior silently inactive. At least one storage close path also uses a check-then-close pattern that is unsafe under concurrent close.
Public API boundary
The listed Elo, RL-driven, and lookup-table files are legacy/internal cleanup surfaces on current main. Fixing their ticker/lifecycle safety must not reintroduce their historical names as supported public Router Learning configuration; #2242 owns that migration boundary.
Expected behavior
Every periodic duration is positive and bounded at config ingestion and constructor boundaries, and start/close behavior is concurrency-safe and idempotent.
Acceptance
- Require every ticker-driving duration to be positive and below a documented maximum.
- Return a field-addressed config error before runtime construction.
- Defensively reject invalid intervals in constructors.
- Define and synchronize start, closing, and closed transitions.
- Make repeated and concurrent close safe.
Validation
- Add table tests for zero, negative, overflow, malformed, and maximum-boundary durations.
- Add repeated-start and high-concurrency close tests under
-race. - Run
cd src/semantic-router && go test -race ./pkg/selection ./pkg/selection/lookuptable ./pkg/extproc ./pkg/config. - Run the selection changed-surface gates reported by
make agent-report.
Related
- Parent audit: #2375