Skip to content

feat(resolution): a configurable resolution budget, and discoverPaths resolves once - #198

Merged
dweekly merged 3 commits into
mainfrom
feat/0.19-resolution-budget
Nov 28, 2026
Merged

dweekly merged 3 commits into
mainfrom
feat/0.19-resolution-budget

Conversation

@dweekly

@dweekly dweekly commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

Summary

PR #197 moved destination lookups off the tracer actor and gave them a fixed 20 s limit. This PR finishes that slice of docs/BLOCKING-IO.md (Resolution Off The Actor) in two ways.

  • A configurable limit. The limit becomes an option, SwiftFTRConfig.resolutionTimeout (decision 7). It is added through a further initializer, so existing code is unaffected.
  • discoverPaths resolves once. Before, each of its flows looked the name up on its own, so a name with rotating DNS records could send different flows to different hosts, and their paths were then compared as if they shared one destination. Now the run resolves the name once, before it asks for the public address, and every flow probes that one address.

Invariants

  1. One configurable budget. trace, traceClassified, traceStream, ping and the discoverPaths parent wait for resolution at most resolutionTimeout (default 20 s), under feat(resolution): resolve destinations off the actor, under one deadline #197's deadline rule. The value must be finite and in (0, Int32.max] seconds, the rule that PingConfig.timeout, StreamingTraceConfig.probeTimeout and the hybrid ASN fallbackTimeout follow (validatePositiveTimeout). Any other value throws invalidConfiguration from validateForOperation before anything is resolved, asked or sent. Ping now checks this one field of its tracer's configuration, and no other.
  2. One resolution per run. The discoverPaths parent resolves the target at most once, forced IPv4. It does this after input validation and before the public-IP question, inside its existing outcome and commit step, so cancelActiveTraces() during resolution still reports TracerouteError.cancelled and the caller's own cancellation reports CancellationError.
    • Every flow probes exactly that address, reports the caller's string as its destination, and resolves nothing.
    • A failed or timed-out lookup ends the run before any public-IP question, discovery packet or probe.
  3. Duration counts it. NetworkTopology.discoveryDuration starts before the lookup.

Caller-visible changes

  • New option: SwiftFTRConfig.resolutionTimeout and SwiftFTRConfig.defaultResolutionTimeout. The API check is clean.
  • One address per run: every path of a multipath run is probed at one address. Each path's destinationHost is still the name the caller passed.
  • Unresolvable names fail early: the run fails with resolutionFailed before the public-IP question. No STUN traffic is sent, no custom resolver is asked, and nothing is cached.
  • Duration: discoveryDuration includes the lookup.
  • One bound per run: a multipath run's lookup is bounded once, by the option. Before, each flow had its own 20 s.

Reproduce

swift format lint --strict -r Sources Tests
SKIP_NETWORK_TESTS=1 PTR_SKIP_STUN=1 swift test -c debug
SKIP_NETWORK_TESTS=1 PTR_SKIP_STUN=1 swift test -c release
SKIP_NETWORK_TESTS=1 PTR_SKIP_STUN=1 swift test -c debug --filter "ResolutionBudgetTests|MultipathWorkerConfigTests"
swift package diagnose-api-breaking-changes v0.18.1 --products SwiftFTR --breakage-allowlist-path "$PWD/api-breakage-allowlist.txt"

On main, where each flow resolves for itself, discoverPathsResolvesOnce fails (one call per flow, several addresses), and so do unresolvableTargetAsksNothing and cancelledDuringParentResolution (the custom resolver is asked). durationIncludesResolution passes on main, because the flows' own lookups fall inside the measured span there. It guards the lookup's new place ahead of the question, and fails if the duration's start moves after it. The option tests need the new API.

🤖 Generated with Claude Code

https://claude.ai/code/session_01A8mvWou2vH56zDnkZkqT2X

dweekly and others added 3 commits November 27, 2026 15:58
… resolves once

SwiftFTRConfig.resolutionTimeout (default 20 s), added through a further
initializer, bounds the resolution wait of trace, traceClassified,
traceStream, ping and discoverPaths. It must be finite and in (0, Int32.max]
seconds, the rule PingConfig.timeout and StreamingTraceConfig.probeTimeout
follow; validateForOperation rejects anything else, and ping now checks this
one field of its tracer's configuration.

discoverPaths resolves its target once, forced IPv4, inside its outcome and
commit path and before its public-IP question, and hands the address to every
flow, which keeps the caller's name for display. A name that does not resolve
ends the run before any question or probe; the reported duration includes the
lookup.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01A8mvWou2vH56zDnkZkqT2X
@dweekly
dweekly merged commit b38b07f into main Nov 28, 2026
8 checks passed
@dweekly
dweekly deleted the feat/0.19-resolution-budget branch November 28, 2026 00:28
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