Repository navigation
fix(relay): let a draining cell pass restart-safe through refused redials - #24347
Conversation
…ials A draining cell refuses every control and host proof, so once no session, splice, or queued byte remains, an in-flight or reserved connection unit can only belong to a dial the cell is about to refuse. The restart-safe wait no longer resets its pace-window streak on those units, and its progress line now prints every counter the gate reads. Claude-Session: ced32ebb-7155-4413-adad-1eccd14c2010
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe restart safety check now allows nonzero in-flight and reserved connection units when the runtime is draining. Other listed activity counts must remain zero. Restart progress events now report runtime state, counters, and director heartbeat freshness, with a runtime heartbeat fallback. Tests cover refused redials, persistent controls, non-draining states, timeout samples, and progress data. Priority: ➖ Normal Merge Risk: 🟡 Moderate · up to During draining, malformed reserved-connection data can be overlooked and a sample can be counted as restart-safe. Fix the counter validation before merging. Security Architecture ReviewSecurity architecture risk: 🟡 Moderate · up to The restart gate can now accept malformed reservation data under a particular draining state. Existing identity, admission, migration, and active-work checks constrain the impact, but the assessment did not establish that every deployed cell version enforces the refusal behavior on which the relaxed gate depends. Retained concerns
Security review detailsSecurity Blast Radius
Security Findings and Attack Paths
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 14b2dda9-513c-42a7-8243-4e75591bef7d
📒 Files selected for processing (2)
cloud/dev/scripts/verify-relay-capacity-transition.mjscloud/dev/scripts/verify-relay-capacity-transition.test.mjs
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
| ].every((value) => integer(value, 'live runtime count') === 0) | ||
| ]) && | ||
| // Still validated on a draining cell so a malformed runtime fails closed. | ||
| (liveIdle([runtime.runtime?.inFlightConnections, runtime.runtime?.reservedConnectionUnits]) || |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
sed -n 360,395p cloud/dev/scripts/verify-relay-capacity-transition.mjs
rg -n 'reservedConnectionUnits|inFlightConnections|const integer|function integer' cloud/dev/scripts/verify-relay-capacity-transition.mjsRepository: stablyai/orca
Length of output: 2339
🏁 Script executed:
sed -n '1,25p' cloud/dev/scripts/verify-relay-capacity-transition.mjs
sed -n '250,330p' cloud/dev/scripts/verify-relay-capacity-transition.mjs
sed -n '396,521p' cloud/dev/scripts/verify-relay-capacity-transition.mjsRepository: stablyai/orca
Length of output: 9868
Validate both counters before applying draining tolerance.
When inFlightConnections is nonzero, liveIdle stops before it parses reservedConnectionUnits. transitionObservation does not make this safe because aggregateCount converts malformed values to null instead of throwing. A draining sample can therefore count as restart-safe with malformed reservedConnectionUnits.
🐛 Suggested fix
const liveIdle = (values) =>
- values.every((value) => integer(value, 'live runtime count') === 0)
+ values.map((value) => integer(value, 'live runtime count'))
+ .every((value) => value === 0)
|
…ing cell Claude-Session: ced32ebb-7155-4413-adad-1eccd14c2010
ELI5
Before a same-cap rollout restarts a drained relay cell, a wait step checks that the cell holds no real work for one full drain window, about 61 clean samples five seconds apart. On production-gce-c29 that wait kept restarting from zero. Phones and hosts that still remembered the old cell kept dialling it, and the cell was about to turn every one of them away. The step timed out and left the cell isolated. This change stops counting those doomed dials as work.
What Changed
Before. The restart-safe wait treated any in-flight or reserved connection unit on the cell as live work. The 2026-10-01 c29 roll was run 36839965464. The cell drained from 2,750 hosts to zero between 09:05:34 and 09:10:39Z. The streak then reset about 20 times between 09:10:50 and 09:21:52Z. The step's 20-minute timeout expired at 09:25:42Z with the streak at 38 of 61.
What reset it. c29's per-minute runtime metrics show the same shape every time the cell held a connection: one physical socket, one reserved unit, two enforced units, zero in-flight units, and zero controls. That is the phone admission path, which reserves a host-data unit beside the phone's socket. The cell keeps that unit through the first frame, the assignment lookup, and the credential check, then answers wrong-cell or host-offline. Host control redials, the earlier suspect, briefly hold an in-flight unit and then a physical socket. The gate never read physical sockets, and its in-flight check would only fire if a sample landed inside a microsecond window. The progress line did not print the reserved counter, so the job log alone could not show this.
After. On a cell whose live runtime reports draining, restart-safe still requires zero controls, splices, pending splices, and queued bytes, plus zero incoming and outgoing migrations from the director. It tolerates in-flight and reserved units. Those counters are still parsed, so a malformed runtime still fails the step. Non-draining runtimes behave as before, and the quiescent and allowed modes are untouched. The progress line now prints the admission state, the draining flag, every runtime counter, and director heartbeat freshness, so the next reset can be diagnosed from the job log.
Why it is safe. The cell's draining flag is read live, in the same synchronous response as the counters, and the cell only ever sets it to true. A draining cell closes every new control upgrade with a draining code. It also refuses any host proof that completes after the drain began. So once controls are zero, no session can appear, and a reserved or in-flight unit can only belong to a dial that ends refused. Explicit migrations are gated separately on the director's counters. A restart loses nothing such a dial holds; the dialler simply redials and the director places it.
Why
Follow-up, not in this PR. The cell should refuse a control upgrade while draining before it reserves a ledger unit and completes the WebSocket upgrade. It should do the same for the phone path when the host is not here. Desktop and mobile clients update independently of cells. That change needs an old-client check that a pre-upgrade HTTP refusal still makes every shipped client re-ask the director, rather than back off as if the relay were down.
Linked Issue
N/A. This is a maintainer change, and the incident has no existing issue.
Visual Proof
N/A. This changes a rollout verification script, with no UI.
Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
The new tests are in the script's existing test file. A draining cell reaches the 61-sample window while phone-shaped and control-shaped refused dials alternate. A persistent control beside those dials never counts a sample. A runtime that is not draining never passes. Quiescent transitions still reject both dial shapes. The progress line carries every counter the gate reads.
I tightened the existing suite named "restart gate rejects live or durable cell work". Its zero timeout meant every case timed out whether or not the blocker worked. It now asserts that the blocked sample did not count.
Mutation checks. Disabling the draining tolerance fails the new redial test. Dropping controls from the gate fails eight tests.
New fail-closed tests send a negative, fractional, or non-numeric in-flight or reserved counter to a draining cell, and the step must throw. Removing that validation fails them.
The cloud script list from the
testscript incloud/package.jsonpasses withnode --test.AI Disclosure
Review
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
There is no client, SSH, mobile, or wire impact. The change only touches operator tooling that reads cell and director admin status.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)