Repository navigation
feat(hosting): ask the registered owner of an address for its state, as the CLI does (#847) - #904
Merged
Merged
Conversation
Blind-Striker
marked this pull request as ready for review
November 15, 2026 18:29
Collaborator
Author
|
net472 mutation proof (Windows), at
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #847
What
OpenCodeServer.FindIncumbentAsync(Uri url, OpenCodeServerDiscoverOptions? options = null, CancellationToken cancellationToken = default)is upstream'sincumbent(url)(packages/client/src/effect/service.ts:33-43). It asks the registered background service that answers at a given address for its state, and returns anOpenCodeServerIncumbent { Server, State }withOpenCodeServerState { Ready, Waiting, Failed }, or null. The names are the maintainer's (2026-11-15).In upstream's order:
service.ts:37-38);mailto:) throwsArgumentException, as upstream'snew URL("/api/info", url)throws outside its catch (service-probe.ts:55-60); the base check (ServiceRegistrationReader.CanBeBase) follows the WHATWG rules: C0 and space trimmed at the ends, tab/LF/CR removed anywhere, the scheme grammar, the six special schemes, and a/after the colon otherwise;fetchrejects it and upstream's catch makes it no service;Endpoint) and probed once with the registration's credential;ExpectedVersionfilters on the version the probe reports (a null value accepts any version).The door guards only a null URL; a base check at the door would change upstream's observable order. It reuses
SystemDiscoveryProbe(), so it adds no clock site and no pragma. The caller's URL receives the registration's credential, as upstream's does; the guide says so. A URL carrying userinfo is probed (as the CLI's Bun runtime does), but the handle'sCreateClientrefuses it, as the client refuses userinfo.Also:
OpenCodeServer.EndpointandOpenCodeServerDiscoverOptions.ExpectedVersionXML now describe the caller-addressed handle; canon (client-runtime.md), the connection-modes and errors guides, and the CHANGELOG Added line are updated. No GLOSSARY edit: "Incumbent" already landed with the GLOSSARY rewrite (#894).Recorded divergence: host parsing
WHATWG's host parser refuses some hosts .NET's
Uriaccepts (for examplehttp://example.42/, whose numeric last label WHATWG reads as a failed IPv4 address). Upstream throws there; the SDK, which does not reimplement that parser, probes and answers null. The maintainer decided this stands as a recorded divergence (2026-11-15).docs/architecture/client-runtime.mdrecords it with its reason (parity would reimplement WHATWG's host, IPv4 and IDNA rules for hosts no loopback service uses) and its reversal trigger (a consumer needs the throw).Tests
OpenCodeServerFindIncumbentTests(onMockFileSystemwith substitute probes): every state with the caller's endpoint, pid, password and non-ownership; one probe at the caller's address with the caller's token; unspecified addresses as loopback; null without a probe when no registration reads (including for a non-base URL); null for no compatible answer; the version filter in all three states and for a versionless registration; a passwordless registration; non-HTTP and special-scheme rows (ws://,x-opencode://,http:\\,https:\\,wss:\\,ftp:\\,file:c:/x, tab/LF/CR, outer spaces, userinfo); validation before cancellation and before any file access; probe, registration-read and migration cancellation propagated as the same instance; the caller's token at the registration read and the channel migration; the null-URL guard. A live test over the pinned managed service reports Ready at a different spelling of the service's address and asserts the probe used it. A cancellation-identity row runs the public door end to end.Mutants, each run against one authorized member with the full analyzer build, all failing at an assertion on net10.0 and net11.0: 29 in the implementation round (2 more were analyzer-unreachable, IDE0060) and 3 in the two review rounds (the special-scheme list, LF/CR stripping, and
https/wss/ftp). The net472 replay of these mutants is pending on the Windows gate host (this macOS host builds net472 but does not run its tests); the PR is enqueued only after it.Version impact (ADR-0034)
Additive: one new public method and two new public types. No existing signature changes.
Local evidence (macOS arm64, head
9f883c76on03238e37)The full local check passed on the head:
dotnet build --configuration Release -p:IncludeNet472Tests=true,dotnet build --configuration Release, both format passes andverify-clones;OpenCode.Sdk.Tools.Tests[Category!=NativeAot]: 2823 of 2823 (including the file-size gate);OpenCode.Sdk.Tests[(Category!=ServiceElection)&(Category!=NativeAot)]: 8828 of 8828 on net10.0 and net11.0;OpenCode.Sdk.Tests[Category=ServiceElection]with--max-parallel-test-modules 1: 18 of 18;opencode-tool --helpandgenerate --verify: current.The run used the pinned ripgrep 15.1.0 on
PATH.The third commit moves the background-service cancellation doors (
AtStopPreCancelledAsync,AtServiceRequestAsync,InvokeServiceAsync,WriteServiceRegistrationAsyncand their constants) out ofCancellationIdentityTests.csinto a sealed, constructor-composedtests/OpenCode.Sdk.Tests/Support/ServiceCancellationDoors.cs. #902 grew that file to 793 lines, and this change's rows would have taken it to 801, over the 800-line test-file cap; after the move it is 655. Every assertion, row and variant is unchanged; the cancellation class runs the same 63 tests per framework before and after.One unrelated flake was seen once in a worker's run:
OpenCodeServerDescriptorTests.StartAsync_Should_Give_Each_Concurrent_Server_Only_Its_Own_Pipessaw six descriptors instead of 0, 1, 2 on net11; three reruns of that class passed 20 of 20, and this change touches no launcher code. It is recorded as a finding for the launcher's owner.Reviews
CanBeBaseagainst WHATWG and .NETUri,DiscoverAsyncunchanged); its test gaps and nits were fixed by a fix-up worker.