Repository navigation
feat(hosting): set and unset the background service's config, stopping it first as the CLI does (#213, S-c) - #930
Merged
Conversation
…g it first as the CLI does (#213)
Blind-Striker
force-pushed
the
feat/213-service-config-set
branch
from
November 16, 2026 17:46
8bf98e3 to
9244c65
Compare
Collaborator
Author
|
net472 mutation replay on Windows at 9244c65:
|
This was referenced Nov 16, 2026
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 third slice of #213: every
setandunsetof the background service's config, as opencode's own CLI does them (packages/cli/src/services/service-config.ts,commands/handlers/service/set.tsandunset.tsat the 2.3.0 pin). The read and the write path (S-a + S-b, #926) are already on master; remote access on, and the canon, guides and CHANGELOG, follow in later PRs for #213.OpenCodeServiceConfiguration:SetDisabledAsync,SetHostnameAsync,SetPortAsync,SetPasswordAsync,SetCorsOriginsAsync,SetEnvironmentVariableAsync,DisableRemoteAsync,UnsetAsync(OpenCodeServiceSetting)andUnsetEnvironmentVariableAsync, with the newOpenCodeServiceSettingenum (Disabled,Hostname,Port,Password,CorsOrigins).OpenCodeServerExceptionbefore anything stops), stop the running service, re-read, merge, write. Only enabling the service (SetDisabledAsync(false),UnsetAsync(Disabled)) does not stop it, as upstream. A stop that fails propagates as itself and leaves the change unmade.env;DisableRemoteAsyncmarksremoteAcceptedonly when a route was present; an empty password is stored as given; the port must be 1 to 65535.OpenCodeServer.StopAsync's composition through a new internalOpenCodeServer.SystemStopper, with the caller's token, channel and installed version;StopAsynckeeps its clock choice.ServiceConfigDocument's settings are now private-set properties set through its one internal constructor and changed only through named operations; the reader passes them as constructor arguments. Read semantics are unchanged (connection resolution in Hosting: a connection-mode resolver with reconnect and restart (upstream's ServerConnection.resolve) #850 reads through the same store).ServiceCancellationDoors.cswith its row in the cancellation table, under the session-isolation guard, which already covers every path the stop resolves.Related Issue(s):
🔄 Type of Change
🎯 Protocol & API Surface
tests/OpenCode.Sdk.Tests/Snapshots/PublicApi.verified.txtis updated in this PR (nineOpenCodeServiceConfigurationmethods andOpenCodeServiceSetting)dotnet run --file tools/opencode-tool.cs -- generate --verifypassesspec/) is untouchedexternal/was hand-edited🧪 Testing
How has this been tested?
Local check on
9244c65f(macOS arm64, on master81c1c057, after #921 merged), all green: the oraclebun tools/oracles/service-config.tsrun twice with no diff (100 config scenarios and 81 CORS verdicts from upstream's own code), 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 (9616, net10.0 and net11.0), ServiceElection (22),--help,generate --verify.Rebased onto #921 (#850): its parameterless
OpenCodeServer.SystemStopper()(used byStopAsyncandStopLocatedAsync) keeps its clock choice and pragma pair and now delegates to this PR's internalSystemStopper(environment, fileSystem, time); both sides' cancellation doors and compiler rows are kept. S-c reads the config only throughReadForWriteAsync, which #850 builds on its non-throwingServiceConfigStore.ReadAsync. A fresh read of the rebase found nothing blocking.Tests: the oracle parity rows for every operation (member order, legacy repair under a write, env order,
remoteAccepted, empty password), the stop table (which operations stop, the read-stop-read-write order, the stop's options and token), stop failure and refusal before stopping, argument guards before any collaborator, the CORS corpus, cancellation through every await and the new table row, and a live test that sets an environment variable on the pinned managed service and asserts it really stopped (process exited, registration gone) while the config kept its members and values.Mutation proof, one mutant at a time under the full analyzer build, each killed at its assertion on net10.0 and net11.0: 19 mutants (which operations stop, the stop's position and options, the re-read,
remoteAccepted, env order and removal, the empty password, a swallowed stop failure, the port guards, the CORS trim set, default ports and case). Not counted: three analyzer rejections (S1144 for a plainTrim(), re-spelled as a killed variant; S8949 twice for a token replaced bydefault). The net472 replay is pending on the Windows gate host; this PR is enqueued only after it.Review: a fresh cross-family read found nothing blocking under the review convergence rule.
📚 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:
SystemStopperoverloads differ only in their parameters; the parameterless one only chooses the clock, and a distinct name would read clearer.StopAsync(locate, then stop); Hosting: a connection-mode resolver with reconnect and restart (upstream's ServerConnection.resolve) #850 now offersStopLocatedAsync, which a later slice may weigh against the CLI's behaviour.CreateStore(random, out _)shares the stop through anoutparameter andReadAsyncbuilds a stop it discards;AssignRemoteAccepted(bool)is only called withtrue;RepairRemote(null)doubles as "disable remote";RemoveEnvironment()wrapsAssignEnvironment(null);["bad", null]reports the first item'sArgumentExceptionbefore the null; the editor tests namedServiceConfigEditor_Should_Refuse_*test the public door guards; the stop table indexes rows by number; the new cancellationMaparm matches by name only; XML on the internal editor methods is uneven.