Skip to content

feat(hosting): resolve explicit, standalone and service connections as the CLI does (#850) - #921

Merged
Blind-Striker merged 15 commits into
masterfrom
feat/850-connection-resolver
Nov 16, 2026
Merged

Blind-Striker merged 15 commits into
masterfrom
feat/850-connection-resolver

Conversation

@Blind-Striker

Copy link
Copy Markdown
Collaborator

Closes #850

Summary

OpenCodeServer.ResolveAsync resolves a connection the way opencode's CLI does: an explicit endpoint, an owned standalone server, or the shared background service. It follows the CLI's precedence, including the saved disabled flag.

  • Explicit endpoints are probed with a pipeline-clock deadline. A version mismatch exposes its context and can invoke OnServerVersionMismatch.
  • Probe failures are classified as upstream classifies them. A null or undecodable health body, and an undeclared success status such as 204, report the compatible-V2 message. Only network failures report "Could not reach server".
  • Every connection exposes the resolve-time ServerVersion.
  • Managed connections get ServiceOperations. Reconnect and restart use the resolve-time snapshot, with a best-effort handoff of persistent terminals.
  • Shared located cores. The located Ensure and Discover paths share their cores with the existing service operations, and registrations carry their version.

Background-service and resolved-connection cancellation doors live in Support/ServiceCancellationDoors.cs; CancellationIdentityTests.cs retains their table rows, classifier mappings and enumerating guard, alongside the other cancellation cases.

The public API adds 43 lines and removes none. All of it is the approved surface.

Review

Three independent reviews covered the whole diff, lifetime and disposal, and a fresh read. The production code matched the plan and upstream, and the reviews found these gaps, all fixed in this PR:

  • Proof gaps. New tests cover:
    • the probe deadline's lower edge, and that its timer is released;
    • the caller's token reaching every door and file read, with a pre-cancelled row per arm;
    • a live leg that runs the shipped located Ensure and Discover paths.
  • One parity gap: the undeclared-2xx probe classification.
  • Minor items:
    • argument and pre-cancellation exceptions surface through the returned task, as the existing doors do;
    • the mock connection disposes quietly;
    • the canon's token-identity list;
    • name-policy ordering;
    • XML docs;
    • the errors-guide wording.

One suggestion was kept as it is: the CreateClient refusal text, because an existing test pins it and that text is shared with OpenCodeServer.CreateClient.

Verification

Suite net10.0 net11.0
SDK 4,642 4,642
Election 11 11
Extensions 21 21
Tools (except NativeAot) — 2,833
  • Tests: no failures or skips.
  • Build: the Release build has 0 warnings.
  • Static checks: generation verification, both format passes, the CLI help check and the clone gate pass. Slopwatch: "Scan complete: 0 issue(s) found."
  • Mutation: every new mutant (the deadline bound, token propagation at each door, the located twins and probe classification) compiled under the full analyzer build. Each was killed at its oracle on both TFMs.
  • No new suppressions, baseline entries or clones.

@Blind-Striker
Blind-Striker force-pushed the feat/850-connection-resolver branch 2 times, most recently from 43ad725 to deb7788 Compare November 16, 2026 11:49
…her's helper (#850)

The live standalone test awaited the public Exited task through the connection's Server property, which VSTHRD003 rejects on net472. It now waits on the owned child's exit through ChildExitObservation, as the launcher lifecycle proofs do, and still asserts the process has ended.
…ry runtime (#850)

net472 formats an ArgumentException message with its parameter on a new line, so the refusal tests compare against the runtime's own rendering and pin ParamName separately. Directory enumeration has no defined order, so the migration test compares the config directory's files as a set.
…ck (#850)

RouteRefusal already checks the exact type, the parameter name and the runtime's own message rendering; the three refusal tests use it instead of repeating those assertions.
@Blind-Striker
Blind-Striker force-pushed the feat/850-connection-resolver branch from deb7788 to fedc3de Compare November 16, 2026 13:48
@Blind-Striker

Copy link
Copy Markdown
Collaborator Author

net472 mutation replay on Windows: 76 of 76 killed at head fedc3de4 (upstream pin a6b15d33), on .NET SDK 11.0.100, Windows build 26300, Bun 1.4.4.

  • Baseline (net472): 47 filters, 84 tests, all passed.
  • Mutants: every mutant had been compiled on net10.0 and net472 before the run. During the run each one built clean, failed at its named oracle test, and was restored clean.
  • Final restored tree (net472): the same 47 filters and 84 tests, all passed.
  • Hygiene: each test command ran with --framework net472 and kept its TRX evidence, and no build-weakening switch was used.

@Blind-Striker
Blind-Striker added this pull request to the merge queue Nov 16, 2026
Merged via the queue into master with commit 81c1c05 Nov 16, 2026
17 checks passed
@Blind-Striker
Blind-Striker deleted the feat/850-connection-resolver branch November 16, 2026 17:31
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.

Hosting: a connection-mode resolver with reconnect and restart (upstream's ServerConnection.resolve)

1 participant