Commit c9645f3
fix(server): size agent JWT TTL to the run's own wall-clock budget (RBR-1035 AC1/AC4) (#29)
RBR-1014 root cause: a flat instance-wide JWT TTL (default 3600s) that agent
runs routinely outlive, causing a 401 mid-run that the client's retry/timeout
path was masking as host-saturation.
RBR-1034 (CISO) decided agents must not hold or mint their own JWT signing
secret, which forecloses in-process refresh (option b from the RBR-1035
plan). This lands option (a): mint the token with a TTL derived from the
run's own configured max wall clock (adapter timeoutSec) plus a 5-minute
margin, falling back to the existing instance default when no run timeout is
configured (unbounded runs) or when the derived minimum does not exceed the
default.
- server/src/agent-auth-jwt.ts: createLocalAgentJwt takes an optional
minTtlSeconds and uses it when it exceeds the configured default TTL.
- server/src/services/heartbeat.ts: derive minTtlSeconds from
resolveHeartbeatRunTimeoutPolicy(agent.adapterType, runtimeConfig) +
AGENT_JWT_RUN_TIMEOUT_MARGIN_SECONDS at the JWT-minting call site.
- server/src/__tests__/agent-auth-jwt.test.ts: RBR-1035 AC1/AC4 regression
tests — long-budget run gets a TTL that outlives the flat 1h default and
is still valid past it; short-budget run keeps the tighter default and is
provably dead before a long-budget token minted at the same instant;
non-finite/non-positive minTtlSeconds falls back to the default.
AC #2 (401 fail-fast taxonomy) and AC #3 (JWT-secret exposure policy) are out
of scope here per the CEO's rescoping comment on this issue: AC#2 is already
in progress on RBR-1036 (cli/src/client/http.ts, separate worktree) and AC#3
is closed by RBR-1034's decision, which this change complies with (no
agent-held or agent-minted signing secret anywhere in this path).
Verification: `npx vitest run src/__tests__/agent-auth-jwt.test.ts` — 21/21
passing (17 pre-existing + 4 new). Touched files parse clean under esbuild.
Full `tsc --noEmit` was not run this pass — host load was 13-19 on a 12-core
box (RBR-974 guardrail) and a prior foreground tsc attempt exceeded the
600s budget without completing; a narrower, targeted check was used per the
AGENTS.md verification guidance instead of forcing a full workspace
typecheck under saturation.
Co-authored-by: Ben Hamilton <benhami@gmail.com>1 parent 6f0a5be commit c9645f3
3 files changed
Lines changed: 165 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
218 | 218 | | |
219 | 219 | | |
220 | 220 | | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
221 | 338 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
91 | | - | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
92 | 98 | | |
93 | 99 | | |
94 | 100 | | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
95 | 116 | | |
96 | 117 | | |
97 | 118 | | |
98 | 119 | | |
99 | 120 | | |
100 | 121 | | |
101 | 122 | | |
102 | | - | |
| 123 | + | |
103 | 124 | | |
104 | 125 | | |
105 | 126 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
| 95 | + | |
95 | 96 | | |
96 | 97 | | |
97 | 98 | | |
| |||
255 | 256 | | |
256 | 257 | | |
257 | 258 | | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
258 | 265 | | |
259 | 266 | | |
260 | 267 | | |
| |||
10915 | 10922 | | |
10916 | 10923 | | |
10917 | 10924 | | |
| 10925 | + | |
| 10926 | + | |
| 10927 | + | |
| 10928 | + | |
| 10929 | + | |
| 10930 | + | |
| 10931 | + | |
| 10932 | + | |
| 10933 | + | |
| 10934 | + | |
| 10935 | + | |
| 10936 | + | |
| 10937 | + | |
| 10938 | + | |
| 10939 | + | |
| 10940 | + | |
| 10941 | + | |
10918 | 10942 | | |
10919 | | - | |
| 10943 | + | |
10920 | 10944 | | |
10921 | 10945 | | |
10922 | 10946 | | |
| |||
0 commit comments