Repository navigation
Conversation
…n the warm-up budget, fence the self-heal probe
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe relay region resolver now uses shared selection rules with deterministic tie-breaking and latency thresholds. Warm-up probes use a longer timeout than sample probes. Incomplete catalogs can retain a measured incumbent or withhold a region hint and record Merge Risk: 🟡 Moderate · up to The change can preserve a relay-region hint from an unverified legacy cache during an incomplete catalog and renew it for 24 hours. Cache eligibility tracking and regression coverage should be added before merge. 🚥 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: Team
Run ID: 45f195fe-c3f2-464a-83dc-f2cdc03633a3
📒 Files selected for processing (6)
src/main/runtime/relay/relay-region-catalog-fetch.tssrc/main/runtime/relay/relay-region-preference.test.tssrc/main/runtime/relay/relay-region-preference.tssrc/main/runtime/relay/relay-region-probe-log.tssrc/main/runtime/relay/relay-region-probe.tssrc/main/runtime/relay/relay-region-selection.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — a focused fix to the desktop relay region probe, addressing the three post-merge adversarial-review findings on #19233.
- Never cache a one-region hint —
refresh()now withholds the hint (1 hNO_HINT_TTL_MS) when the catalog drops a region, logged ascatalog-incomplete. This closes the roll-wave / heartbeat-stall case where a lone healthy region won against nothing and pinned the desktop for 24 h. - Wider warm-up budget —
RelayProbecarries a'warmup' | 'sample'phase; the discarded first request now getsWARMUP_TIMEOUT_MS = 3 × PROBE_TIMEOUT_MSso a cold TLS path on a lossy link no longer drops the whole region. - Fenced self-heal probe —
invalidateIfAssignedCellIsFarearly-returns unless the assigned cell origin is under the director's hostname (reusing the existingisProbeOriginForDirectorownership rule), preventing an unauthenticatedGET /healthagainst an arbitrary host. - Mechanical extraction —
measuredRegions/bestMeasurement/selectRegionMeasurementmove torelay-region-selection.tswith no behavior change, keeping the resolver under the line budget.
The three new tests each pin the fix (and fail on the pre-fix code): the one-region catalog test asserts an exact 1 h expiresAt and the catalog-incomplete reason, the warm-up test counts AbortSignal.timeout arguments (2 × 4500 ms warm-up vs 7 × 1500 ms sample/catalog), and the fence test asserts the attacker origin is never fetched and the cache is untouched.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — two commits landed since the prior pullfrog review; both are clean.
- Refuse a malformed assigned-cell origin —
isProbeOriginForDirectornow returnsfalsewhennew URL(...)throws instead of throwing, so a non-URL cell cannot reject the fire-and-forget self-heal probe. The fence test now also drives'not a url'throughinvalidateIfAssignedCellIsFarand confirms no fetch, no probe, and an untouched cache. - Aggregate unreplayable-pending-connection logging —
replayPendingConnectionslogs one[relay]warn per ack with an entry count instead of one per unreplayable pending entry, the bundled #19238 follow-up. The dialing path is unchanged; the single-entry test still passes, though no test exercises the multi-entry → one warn case.
Both additions address edge cases without altering the previously reviewed region-probe behavior.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
…achability before catalog shape - the catalog fetch is the coldest request of the sequence (DNS, TCP, TLS to the director) and ran on the 1.5 s sample clock; a timeout withheld the hint for an hour - a lone region that is unreachable or flapping now logs all-unreachable / all-rejected, so a census of client-side network breakage is not hidden by a roll wave - tests pin the budget sequence, the requestTimeoutMs override, and the aggregated warning text
There was a problem hiding this comment.
ℹ️ No critical issues — one minor observation inline.
Reviewed changes — one commit (27e685a) landed since the prior pullfrog review; the region-probe behavior is otherwise unchanged.
- Gave the catalog request the warm-up budget —
probeCatalognow fetches/v1/regionsonWARMUP_TIMEOUT_MS(4.5 s) instead of the sample budget, since it is the coldest request in the sequence and a catalog timeout previously withheld the hint for an hour. - Reported reachability before catalog shape —
refreshReasonnow classifiesall-unreachable/all-rejectedbeforecatalog-incomplete, reservingcatalog-incompletefor a lone healthy region so a support census of client-side breakage is not hidden by a roll wave. - Pinned the budget sequence and override — tests now assert the exact
[4500 × 3, 1500 × 6]timeout sequence, thatrequestTimeoutMsoverrides every budget, and the aggregated one-line unreplayable-connection warning.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
…ot all-unreachable
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — one commit (2c2fa3d) landed since the prior pullfrog review, closing that review's single inline finding.
- Classified an empty catalog as
catalog-incomplete—refreshReasonnow returnscatalog-incompletewhenreports.length === 0before the reachability checks, so a total drain (every region losing its general/ready/heartbeating cell at once,regionCatalog()→[]) no longer falls through the vacuously-true[].every(unreachable)and mislabels asall-unreachable. Thecatalog-incompletepath is now reserved for catalog-shape cases andall-unreachablestays meaningful for the client-side-breakage census. - Pinned the empty-catalog classification — a new test drives
catalogFetch([])and asserts the exact{ reason: 'catalog-incomplete', regions: [] }event; it fails on the pre-fix code.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
…alog An expiry that lands during the other region's roll wave saw a one-region catalog and withheld the hint, sending a correctly homed desktop to the director default for an hour. The incumbent was earned against a full catalog, so it is kept; a lone survivor that is not the incumbent is still never promoted.
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Team
Run ID: d81e4631-f5e1-4b34-a4fe-6d08ae8cc6b6
📒 Files selected for processing (2)
src/main/runtime/relay/relay-region-preference.test.tssrc/main/runtime/relay/relay-region-preference.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 0 remain after this review.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — one commit (43d31d4b) landed since the prior pullfrog review, and it is a clean refinement of the round-3 reordering.
- Held a still-measured incumbent through an incomplete catalog —
refresh()now derivescomplete = measurements.length === reports.length && reports.length === RELAY_REGIONS.lengthand, when incomplete, selectsincumbent ?? null(the previous region if still listed and measured) instead of always withholding. An expiry that lands during the other region's roll wave now keeps a correctly homed desktop on its incumbent with the 24 hCACHE_TTL_MSrather than bouncing it to the director default for an hour. - Still refused to promote a lone survivor — a lone region that is not the incumbent remains withheld (
region: null), so the core "never cache a one-region hint" property is preserved; only the incumbent, earned against a full catalog, is exempt. - Added two regression tests —
holds a still-measured incumbent through an incomplete catalogdrives an expiredasia-east2cache through a one-region catalog and asserts the 24 h re-cache plus the loggedchosenRegion;does not promote a lone survivor that is not the incumbentpins the non-incumbent-withhold invariant. Both exerciserefresh(the helper'sexpiresAtdefault is999againstnow: 1_000), so neither is a vacuous cache-hit.
The change is client-side only (no wire or shared-type impact) and the prior inline finding is already retired.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
… the cache proves it won a full one The cache now records fullCatalog: true on a hint earned against every served region. A cache without the marker (older build, or a lone survivor) is re-earned, not renewed.
There was a problem hiding this comment.
ℹ️ No critical issues — one minor suggestion on test coverage inline.
Reviewed changes — one commit (7835c05) landed since the prior pullfrog review, refining the incumbent-hold exception that review approved.
- Gated the incumbent-hold on a
fullCatalogmarker — the cache schema gains an optionalfullCatalog: z.literal(true), andrefresh()now holds a still-measured incumbent through an incomplete catalog only whenprevious?.fullCatalogproves that hint was earned against a full catalog. A cache written by an older build (which may hold a lone survivor) is treated as unverified and re-earned, closing the gap where the incumbent exception could have resurrected the one-region-hint bug for pre-existing caches. - Marked full-catalog wins and held incumbents, never no-hint entries —
writeCachewritesfullCatalog: trueon theselected-region branch (both a fresh full-catalog win and a held incumbent) and never on theregion: nullbranch. The invariant chains by induction:fullCatalog: true⟺ won against a full catalog, or held from a region that did. - Added two regression tests —
does not hold an incumbent an older build cached without the full-catalog marker(fails on pre-fix code) andmarks a hint earned against a full catalog, and never a no-hint entry.
The change is client-side only (no wire or shared-type impact); production logic is sound.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
| const lone = sampledProbe({ [ASIA]: [90, 30, 32, 34] }) | ||
| await new RelayRegionPreferenceResolver({ | ||
| directorUrl: DIRECTOR, | ||
| userDataPath: userDataPath(), | ||
| fetch: catalogFetch([{ region: 'asia-east2', probeOrigins: [ASIA] }]), | ||
| probe: lone.probe, | ||
| now: () => 1_000 | ||
| }).resolve() |
There was a problem hiding this comment.
The second half of this test resolves a lone-region catalog against a fresh userDataPath() and never reads the resulting cache, so the "never a no-hint entry" promise in the test name is unasserted: it would still pass if writeCache ever leaked fullCatalog: true onto the region: null branch. Capture the second path and assert the no-hint cache omits fullCatalog.
| const lone = sampledProbe({ [ASIA]: [90, 30, 32, 34] }) | |
| await new RelayRegionPreferenceResolver({ | |
| directorUrl: DIRECTOR, | |
| userDataPath: userDataPath(), | |
| fetch: catalogFetch([{ region: 'asia-east2', probeOrigins: [ASIA] }]), | |
| probe: lone.probe, | |
| now: () => 1_000 | |
| }).resolve() | |
| const lonePath = userDataPath() | |
| const lone = sampledProbe({ [ASIA]: [90, 30, 32, 34] }) | |
| await new RelayRegionPreferenceResolver({ | |
| directorUrl: DIRECTOR, | |
| userDataPath: lonePath, | |
| fetch: catalogFetch([{ region: 'asia-east2', probeOrigins: [ASIA] }]), | |
| probe: lone.probe, | |
| now: () => 1_000 | |
| }).resolve() | |
| expect(JSON.parse(readFileSync(cachePath(lonePath), 'utf8'))).toEqual({ | |
| v: 1, | |
| directorUrl: DIRECTOR, | |
| region: null, | |
| expiresAt: 3_601_000 | |
| }) |
…read before a self-heal delete - a held incumbent is written without the fullCatalog marker, so the next expiry must re-earn it against a full catalog; holds cannot chain on partial evidence - the hold is logged as held-previous, not measured - self-heal rereads the cache before rmSync so a refresh that landed during its probes is not deleted on a stale verdict (new reason superseded-by-refresh)
There was a problem hiding this comment.
ℹ️ No new issues in this delta — one minor test-coverage item from the prior review remains open.
Reviewed changes — one commit (258705c) landed since the prior pullfrog review, tightening the incumbent-hold exception it approved.
- One hold per proven hint — a held incumbent is now written without the
fullCatalogmarker, so a roll wave can extend a proven hint by a day, but the next expiry re-entersselectRegionMeasurementagainst a full catalog instead of chaining holds on partial evidence. Thecannot chain holdstest pins the no-marker re-earn path. held-previouslogging for held incumbents —relayRegionRefreshEventtakes aheldflag and reportsheld-previouswhen the incumbent is kept through an incomplete catalog, preservingmeasuredfor a win against a live rival.- Self-heal reread before delete —
invalidateIfAssignedCellIsFarre-reads the cache beforermSyncand keeps it (loggingsuperseded-by-refresh) when a concurrent refresh wrote a different region during the probes, closing a pre-existing race.
The production logic is sound and the new tests fail without their fix. The one prior inline finding — the marks a hint earned against a full catalog, and never a no-hint entry test resolves a lone-region catalog against a discarded userDataPath() and never reads the written cache, so the "never a no-hint entry" half of its name is unasserted — is unchanged by this commit and remains open.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
|
Superseded by #19349, which keeps only the one-region rule. The rest of this PR was heuristics stacked on heuristics across six review rounds; each fix invited the next. Dropped rather than merged. |

Follow-up to #19233 from the post-merge adversarial review. Three findings on the desktop region probe, all reproduced against main.
Why
assignment-store.tsregionCatalog), so a roll wave or heartbeat stall shortens the catalog. The resolver only required every listed region to be measured, so a lone healthy region won against nothing and was written as a day-long hint. Two existing tests pinned that behaviour. An Asia desktop refreshing while the Asia cells drained would publishus-central1for a day; a US desktop refreshing while US cells were absent would publishasia-east2, the exact incident fix(relay): stop rejecting the near region on a cold first probe #19233 was written to end.What
refresh()withholds the hint (1 h no-hint TTL) whenreports.length < RELAY_REGIONS.length, logged with the new reasoncatalog-incomplete.WARMUP_TIMEOUT_MS = 3 × PROBE_TIMEOUT_MS;RelayProbetakes an optional'warmup' | 'sample'phase andcreateProbepicks the budget from it. An explicitrequestTimeoutMsoption still overrides both, as before.invalidateIfAssignedCellIsFarreturns early unless the cell origin passesisProbeOriginForDirector, now exported fromrelay-region-catalog-fetch.ts.measuredRegions/bestMeasurement/selectRegionMeasurementand the switch margins moved torelay-region-selection.tsto keep the resolver under the line budget. No behaviour change.Tests
catalog-incompletereason (fails without the fix).AbortSignal.timeout.pnpm vitest run src/main/runtime/relay159/159,pnpm tc:node,oxlintclean.Also
replayPendingConnectionslogged one warning per pending entry the cell stated without details. Against a cell that predates the capability that is every entry on every straddling rebind, up to the eight-connection cap. Now one aggregated line per ack.Review round 3 (Opus sweep)
all-unreachable/all-rejected;catalog-incompleteis reserved for a lone healthy region, so a support census of client-side breakage is not hidden by a roll wave.requestTimeoutMsoverride, and the aggregated unreplayable warning text and count.Cost and compatibility notes
resolve()grows from 7.5 s to 13.5 s (catalog 4.5 s, then warm-up 4.5 s, then three 1.5 s sample rounds, all sequential; regions run in parallel within each phase). The drain grace floor is 60 s, so a drain rotation still fits, and the no-hint case re-enters it hourly rather than daily. The drain-rotation path awaits it serially; if the roll-wave frequency makes that hourly cost visible, a wall-clock deadline aroundresolvePreferredRegionis the next step.RELAY_REGIONS.lengthis now load-bearing: a desktop on this build withholds the hint permanently (and re-probes hourly) in any environment that serves fewer regions than the constant lists. Retiring a region needs a desktop release that shrinks the constant first; adding one is safe (the catalog schema caps at the constant, so an unknown region fails the schema as before).Review round 4 (second Opus pass)
catalog-incomplete, notall-unreachable.Review round 5 (Codex)
fullCatalog: trueonly on a hint that won against every served region. Only a marked hint is held through an incomplete catalog, and the held entry is written without the marker, so one roll wave can extend a proven hint by a day but the next expiry must re-earn it. A legacy cache or a lone survivor is never renewed on partial evidence.held-previous, notmeasured.superseded-by-refresh). This race predates the PR.