Repository navigation
feat(hosting): turn the background service's remote access on through the installed CLI (#213, S-d) - #936
Merged
Conversation
4 tasks done
Collaborator
Author
|
net472 mutation replay on Windows at 2b61e55:
|
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.
📝 Description
What does this PR do?
The fourth slice of #213: turning the background service's remote access on, the way opencode's own CLI does it (
opencode service set remote true,packages/cli/src/services/service-config.tsandcommands/handlers/service/set.tsat the 2.3.0 pin). The read, the write path and every otherset/unsetare already on master (#926, #930); the canon, guides and CHANGELOG follow in the last #213 PR.OpenCodeServiceConfiguration.EnableRemoteAsync(options, cancellationToken)returns the route. Upstream's remote-on builds the tunnel itself, so the SDK runs the installed CLI rather than reimplementing it (the maintainer's decision): it resolves the command the wayStartAsyncresolves its command, runs<command...> service set remote truewith the given environment overlay, and only after the CLI reports success reads the route back. The SDK does no read, stop or write of its own before the run; the CLI owns the stop and the write.remote) throwsOpenCodeServerExceptionnaming the config file; the message never carries the route or a password.OpenCodeServiceConfigOptions:CliCommand(default["opencode"], the CLI's executable and any leading arguments, the counterpart of upstream'sselfCommand()) andEnvironment(entries layered over the process's environment for the CLI). The XML says onlyEnableRemoteAsyncreads them, and thatCliCommand,ChannelandEnvironmentmust name the same config the other operations read.EnsureAsyncvalidates its own), before any resolution or I/O.ServerChildStart.Passwordis now optional, and a null password neither injects nor removesOPENCODE_PASSWORD), stdout drained, stderr captured into a bounded tail (the 40-line / 8,192-character limits now live in one owner,BoundedLineBuffer.ForStderrTail, which the launcher uses unchanged) even when the host setsOPENCODE_PRINT_LOGS=1. Only an ordinary exit 0 succeeds; any other end names the executable, the exit and the stderr tail. Cancellation ends the child and propagates as the caller's cancellation; the child is released on every path.Related Issue(s):
🔄 Type of Change
🎯 Protocol & API Surface
tests/OpenCode.Sdk.Tests/Snapshots/PublicApi.verified.txtis updated in this PR (OpenCodeServiceConfigOptions.CliCommand,.Environment,OpenCodeServiceConfiguration.EnableRemoteAsync)dotnet run --file tools/opencode-tool.cs -- generate --verifypassesspec/) is untouchedexternal/was hand-edited🧪 Testing
How has this been tested?
Local check on
2b61e55c(macOS arm64, on mastercc86ec33), all green: the oraclebun tools/oracles/service-config.tsrun twice with no diff, slopwatch (0 issues),dotnet build -c Releaseand with-p:IncludeNet472Tests=true(0 warnings), both format passes,verify-clones(0 new clones), Tools tests (2861), SDK tests excluding ServiceElection and NativeAot (9714, net10.0 and net11.0), ServiceElection (22),--help,generate --verify.Tests: the remote-on sequence (CLI first, then the route read; exact executable, arguments, environment and token), entry validation with one invalid input per row, the shared-read outcomes for every config shape, the runner against scripted and real children (exit evaluation, stderr tail limits, stdout drain, cancellation ending the child), both platform strategies' optional credential and forced stderr, the cancellation table row (pre-cancelled,
bun --version, never a realopencode) under the extended session-isolation guard (proven red), and a live test that runs the pinned source CLI through a shim inside the managed fixture's run root (service set env, no tunnel, no installed CLI) and asserts the config change and the service's stop.Mutation proof, one mutant at a time under the full analyzer build, each killed on net10.0 and net11.0: 39 mutants across the entry validation, the run order and arguments, the route read, the runner's exit, tail, cancellation and release, the credential composition and both platforms' stderr routing, and the live row. Two test rows were tightened while proving (each invalid-input row now makes exactly one input invalid; the pre-cancelled runner test scripts the child's exit so a launch fails fast instead of hanging). The net472 replay is pending on the Windows gate host; this PR is enqueued only after it.
Review: a fresh cross-family read found one blocking issue (the runner's live tests cleaned up in
DisposeAsync, where TUnit only logs failures); it was fixed (cleanup in each test body, proven to fail a test when a step fails) together with a collapsed boolean assertion the repository gate rejected.📚 Documentation
CHANGELOG.md, the consumer guide and the full canon section: deliberately left to the last Background-service configuration administration: keep or drop #213 slice, which documents the whole configuration surface at onceKnown follow-ups
Non-blocking items from the read, left for a later change:
ServiceRemoteRequest.Snapshotrepeats the acceptance rules ofEnsureRequestinstead of sharing them; its single combinedCliCommandmessage differs from Ensure's three, and a malformed environment dictionary with duplicate keys throws withoutParamName = options.ServiceCliRunnerbuilds its own "Recent stderr" text instead of the launcher'sDescribeStderr, and appends the label even when the tail is empty.CliCommandthe resolver's message points atOpenCodeServerOptions.Command, the launcher's option.WindowsServerChildTestscovers only the no-credential, forced-stderr case; the host and caller password cases run through the POSIX strategy only (the composer is shared).EnableRemoteAsyncXML covers cancellation after the CLI's success but not cancellation mid-run, where upstream may already have stopped the service or left an issuance half done (upstream resumes it on the next run).ReadRouteAsyncresolves the paths a second time for its message; the store's message names remote-on options;ServiceRemoteRequestproperties lack XML; a missing blank line inChildEnvironmentComposer.Compose; aTask[]indirection in the runner tests; the remote-on store composition discards the stop (CreateStore(random, seams, out _)).