Skip to content

feat(relay): log the region probe and name the assigned cell - #19240

Closed
Jinwoo-H wants to merge 3 commits into
relay/region-probe-warm-upfrom
relay/region-probe-logging
Closed

Jinwoo-H wants to merge 3 commits into
relay/region-probe-warm-upfrom
relay/region-probe-logging

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​482 $\color{#cf222e}{\Huge{\mathbf{−}}}$​6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​476
Prod 16 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​440 $\color{#cf222e}{\Huge{\mathbf{−}}}$​121 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​319

Stacked on #19233

Base is relay/region-probe-warm-up. Retarget to main after #19233 merges.

Why

A desktop silently picked a far relay region for a day and every phone connect paid ~10 s. Nothing in the desktop logs said which regions were probed, what the samples were, why a region was rejected, or which cell the host ended up on. Diagnosing it took a bench harness.

What

  • One-line [relay-region] JSON events in the main process:
    • relay_region_probe per refresh: per region the origins, discarded warm-up sample, kept samples, min, spread, verdict (measured / rejected-spread / unreachable), then the chosen region or no hint with a reason (measured, held-previous, sole-survivor-forbidden, all-rejected, all-unreachable, catalog-unavailable, override, cached), whether the outcome was cached, and its TTL.
    • relay_region_self_heal per check: cached region, best measured region and latency, assigned cell URL and latency, decision, reason.
  • MobileRelayStatusDetail.cellUrl (optional) on the relay status IPC, rendered in the pairing panel as a muted line. A shared rule keeps the cell only for registered and draining, applied in the broker and the auth coordinator so an offline or reconnecting status never shows a stale cell.
  • Catalog fetching moved into relay-region-catalog-fetch.ts (max-lines).

No secrets reach either log line: fields are hostnames, catalog-validated origins, region names, latencies, enums, booleans. The status payload travels only over Electron IPC (main, preload, renderer ship together); the event shape changed from a bare string to an object, so do not cherry-pick one half.

Verification

  • pnpm tc (node, cli, web), relay + mobile IPC + panel tests (18 files, 199 tests), check:code-quality:changed 0 across 21 files, react-doctor 0 new, oxlint clean, no max-lines disables.
  • Independent adversarial review: lane A selection, cache, and self-heal behaviour byte-equivalent by replay; log cardinality one event per refresh / per check; the nit round found and fixed a second publisher that would have blanked the cell in the real flow.

Not for merge until the owner gives the go.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ Minor suggestions only — one localization-catalog entry plus two nitpicks. No behavioral issues found; the cell-derivation and log-structure design is sound.

Reviewed changes

  • Region-probe logging — new [relay-region] one-line JSON events (relay_region_probe / relay_region_self_heal) emitted from RelayRegionPreferenceResolver via a logEvent sink, with refreshReason() deriving the choice reason and constructors for override / cache-hit / catalog-failure / refresh outcomes.
  • Cell naming — MobileRelayStatusDetail threads an optional cellUrl from broker → coordinator → IPC → preload → pairing panel; relayStatusCellUrl() keeps the cell only for registered/draining, and the coordinator re-derives it from broker.endpoint.cellUrl so a republish never blanks what the broker set.
  • Catalog-fetch extraction — fetchRelayRegionCatalog + relayDirectorHost moved to relay-region-catalog-fetch.ts; measureRegion now returns a RelayRegionProbeReport (warmup/kept/min/spread/verdict).

ℹ️ Nitpicks

  • refreshReason (src/main/runtime/relay/relay-region-probe-log.ts) labels an empty catalog (regions: [], which RelayRegionCatalogSchema permits) as all-unreachable, since reports.every(...) is vacuously true on an empty array. The behavior (withhold hint, 1h TTL) is still correct; only the log label is off.
  • The self-heal early-return path where the best measured region equals the cached region (best-matches-cache) and the no-region-measured outcome (all regions unreachable during self-heal) are reachable but untested, as is refreshReason's all-rejected branch.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@Jinwoo-H
Jinwoo-H force-pushed the relay/region-probe-warm-up branch from 63d18cc to 28529cd Compare September 7, 2026 08:35
A desktop silently pinned itself to a far relay region for a day and every
phone connect paid the round trip. Nothing in the desktop logs said which
regions were probed, what they measured, why one was rejected, or which cell
the host landed on, so the only way to diagnose it was a bench harness.

The resolver now emits one line per outcome. A refresh carries every region's
probe origins, the discarded warm-up, the kept samples, the minimum, the
spread, and a verdict, then the chosen region or no-hint with the reason it
withheld one. Cache hits, diagnostic overrides, and a director that cannot
list its regions each get their own line so a quiet run is never ambiguous.
Self-heal logs the cached region, the best measured region, the assigned
cell's round trip, and whether it kept or deleted the cache. Only a refresh
reports a catalog failure; a self-heal never chose a region, so a line saying
it withheld a hint would be a lie.

Relay status now carries the assigned cell so the pairing panel can name it.
The field is optional because an offline host holds no assignment and the web
client answers from a stub that never has one.

Splitting catalog fetching out of the preference module keeps both files
inside the line budget without a lint disable.
The origin pool publishes offline while it still holds the assignment it is
about to rotate, so the panel kept naming a cell nothing was served from. The
same class of bug hid a second instance: the coordinator republishes
registered right after the broker announces its cell, and that republish
carried no cell, blanking the value moments after it was set. The cell would
never have reached the panel in the real flow.

Deriving the cell from the status at each publisher removes both. The rule
lives beside the status type because it defines when the optional field is
populated, and the coordinator reads the owned broker's endpoint rather than
trusting a call site to remember to pass it.
@Jinwoo-H
Jinwoo-H force-pushed the relay/region-probe-logging branch from 09af1b9 to 41a1254 Compare September 7, 2026 08:36

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Localization-catalog fix — added the missing relayCell key to src/renderer/src/i18n/locales/en.json, resolving the prior verify:localization-catalog failure on MobilePairingConnectionOptions' translate() call.

The remaining prior-review nitpicks (the empty-catalog refreshReason label and the untested self-heal/all-rejected branches) are unchanged and non-blocking; no new behavioral surface was introduced by the rebase onto the updated base.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@Jinwoo-H
Jinwoo-H deleted the branch relay/region-probe-warm-up September 7, 2026 17:11
@Jinwoo-H Jinwoo-H closed this Sep 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant