Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
claude-code/src/bridge/pollConfig.ts at main · ssw-python/claude-code · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
See all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
ssw-python
claude-code
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
main
Breadcrumbs
claude-code
/
src
/
bridge
/
pollConfig.ts
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
110 lines (108 loc) · 4.46 KB
main
Breadcrumbs
claude-code
/
src
/
bridge
/
pollConfig.ts
Copy path
Top
File metadata and controls
Code
Blame
110 lines (108 loc) · 4.46 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import
{
z
}
from
'zod/v4'
import
{
getFeatureValue_CACHED_WITH_REFRESH
}
from
'../services/analytics/growthbook.js'
import
{
lazySchema
}
from
'../utils/lazySchema.js'
import
{
DEFAULT_POLL_CONFIG
,
type
PollIntervalConfig
,
}
from
'./pollConfigDefaults.js'
// .min(100) on the seek-work intervals restores the old Math.max(..., 100)
// defense-in-depth floor against fat-fingered GrowthBook values. Unlike a
// clamp, Zod rejects the whole object on violation — a config with one bad
// field falls back to DEFAULT_POLL_CONFIG entirely rather than being
// partially trusted.
//
// The at_capacity intervals use a 0-or-≥100 refinement: 0 means "disabled"
// (heartbeat-only mode), ≥100 is the fat-finger floor. Values 1–99 are
// rejected so unit confusion (ops thinks seconds, enters 10) doesn't poll
// every 10ms against the VerifyEnvironmentSecretAuth DB path.
//
// The object-level refines require at least one at-capacity liveness
// mechanism enabled: heartbeat OR the relevant poll interval. Without this,
// the hb=0, atCapMs=0 drift config (ops disables heartbeat without
// restoring at_capacity) falls through every throttle site with no sleep —
// tight-looping /poll at HTTP-round-trip speed.
const
zeroOrAtLeast100
=
{
message
:
'must be 0 (disabled) or ≥100ms'
,
}
const
pollIntervalConfigSchema
=
lazySchema
(
(
)
=>
z
.
object
(
{
poll_interval_ms_not_at_capacity
:
z
.
number
(
)
.
int
(
)
.
min
(
100
)
,
// 0 = no at-capacity polling. Independent of heartbeat — both can be
// enabled (heartbeat runs, periodically breaks out to poll).
poll_interval_ms_at_capacity
:
z
.
number
(
)
.
int
(
)
.
refine
(
v
=>
v
===
0
||
v
>=
100
,
zeroOrAtLeast100
)
,
// 0 = disabled; positive value = heartbeat at this interval while at
// capacity. Runs alongside at-capacity polling, not instead of it.
// Named non_exclusive to distinguish from the old heartbeat_interval_ms
// (either-or semantics in pre-#22145 clients). .default(0) so existing
// GrowthBook configs without this field parse successfully.
non_exclusive_heartbeat_interval_ms
:
z
.
number
(
)
.
int
(
)
.
min
(
0
)
.
default
(
0
)
,
// Multisession (bridgeMain.ts) intervals. Defaults match the
// single-session values so existing configs without these fields
// preserve current behavior.
multisession_poll_interval_ms_not_at_capacity
:
z
.
number
(
)
.
int
(
)
.
min
(
100
)
.
default
(
DEFAULT_POLL_CONFIG
.
multisession_poll_interval_ms_not_at_capacity
,
)
,
multisession_poll_interval_ms_partial_capacity
:
z
.
number
(
)
.
int
(
)
.
min
(
100
)
.
default
(
DEFAULT_POLL_CONFIG
.
multisession_poll_interval_ms_partial_capacity
,
)
,
multisession_poll_interval_ms_at_capacity
:
z
.
number
(
)
.
int
(
)
.
refine
(
v
=>
v
===
0
||
v
>=
100
,
zeroOrAtLeast100
)
.
default
(
DEFAULT_POLL_CONFIG
.
multisession_poll_interval_ms_at_capacity
)
,
// .min(1) matches the server's ge=1 constraint (work_v1.py:230).
reclaim_older_than_ms
:
z
.
number
(
)
.
int
(
)
.
min
(
1
)
.
default
(
5000
)
,
session_keepalive_interval_v2_ms
:
z
.
number
(
)
.
int
(
)
.
min
(
0
)
.
default
(
120_000
)
,
}
)
.
refine
(
cfg
=>
cfg
.
non_exclusive_heartbeat_interval_ms
>
0
||
cfg
.
poll_interval_ms_at_capacity
>
0
,
{
message
:
'at-capacity liveness requires non_exclusive_heartbeat_interval_ms > 0 or poll_interval_ms_at_capacity > 0'
,
}
,
)
.
refine
(
cfg
=>
cfg
.
non_exclusive_heartbeat_interval_ms
>
0
||
cfg
.
multisession_poll_interval_ms_at_capacity
>
0
,
{
message
:
'at-capacity liveness requires non_exclusive_heartbeat_interval_ms > 0 or multisession_poll_interval_ms_at_capacity > 0'
,
}
,
)
,
)
/**
* Fetch the bridge poll interval config from GrowthBook with a 5-minute
* refresh window. Validates the served JSON against the schema; falls back
* to defaults if the flag is absent, malformed, or partially-specified.
*
* Shared by bridgeMain.ts (standalone) and replBridge.ts (REPL) so ops
* can tune both poll rates fleet-wide with a single config push.
*/
export
function
getPollIntervalConfig
(
)
:
PollIntervalConfig
{
const
raw
=
getFeatureValue_CACHED_WITH_REFRESH
<
unknown
>
(
'tengu_bridge_poll_interval_config'
,
DEFAULT_POLL_CONFIG
,
5
*
60
*
1000
,
)
const
parsed
=
pollIntervalConfigSchema
(
)
.
safeParse
(
raw
)
return
parsed
.
success
?
parsed
.
data
:
DEFAULT_POLL_CONFIG
}
You can’t perform that action at this time.