Repository navigation
feat(hosting): read and write the background service's config the CLI's way (#213, S-a + S-b) - #926
Merged
Merged
Conversation
… searched, as upstream's read does (#213)
…n, and the existence contract says what it returns (#213)
…d create its password (#213)
…or is judged by the text it would copy, and the config cancellation doors join the shared table (#213)
…the config cancellation doors stay in isolated roots, and the runtime canon says the config operations write (#213)
…oded text as the config store, and the config cancellation doors rely on the session's isolated roots (#213)
…, the migration's refusal of colliding names is pinned, and the isolation guard is proven on its path checks (#213)
… the duplicate refusal alone, and the config doors run after their isolation guard (#213)
Collaborator
Author
|
net472 mutation replay on Windows: 59 of 59 killed at head
|
This was referenced Nov 16, 2026
Closed
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 first two slices of #213: typed read of the background service's config, and its write path, as opencode's own CLI reads and writes it (
packages/cli/src/services/service-config.ts,commands/handlers/service/get.tsat the 2.3.0 pin). Everyset/unset, remote access, and the canon, guides and CHANGELOG follow in later PRs for #213.OpenCodeServiceConfiguration.ReadAsync(options, cancellationToken)returnsOpenCodeServiceConfig, the safe view upstream'sservice getprints: disabled, remote enabled/accepted, hostname, port, CORS origins in order, environment entries. The password and the route are never exposed.OpenCodeServiceConfigOptionsselects the channel and installed version, as the CLI resolves them.ReadAsyncreads the CLI's way: when the config file is missing it copies a current-shape legacy donor (migrateConfig), and it repairs a legacy booleanremotein place. It stops nothing, asgetstops nothing.OpenCodeServiceConfiguration.GetOrCreatePasswordAsync(options, cancellationToken)returns the stored password, creating and storing one when none exists. The config is written as the CLI writes it: its JSON form, an owner-only file, its directory created, and a rename retried on a transient failure.OpenCodeServerExceptionnaming the file, before any copy or write; a document neither can read is replaced as upstream replaces it. This covers the config file and the legacy donor.ServiceMigration, for both the config and the registration donor; invalid UTF-8 inside a string is copied as upstream's decode writes it.RandomCredential, unchanged in output, so the launcher and the config share it.ServiceCancellationDoors.cswith their rows in the cancellation table, beside the other background-service doors, and a guard asserts every config door resolves under the test session's isolated roots, so no test reaches the developer's real OpenCode files.client-runtime.md): the smallest correction thatOpenCodeServiceConfiguration's operations read and repair the config the CLI's way and write it; Discovery, Ensure and Stop still read the document as it is. The full canon, guides and CHANGELOG entry come with the last Background-service configuration administration: keep or drop #213 slice.Related Issue(s):
🔄 Type of Change
🎯 Protocol & API Surface
tests/OpenCode.Sdk.Tests/Snapshots/PublicApi.verified.txtis updated in this PR (OpenCodeServiceConfigurationwithReadAsyncandGetOrCreatePasswordAsync,OpenCodeServiceConfig,OpenCodeServiceConfigOptions)dotnet run --file tools/opencode-tool.cs -- generate --verifypassesspec/) is untouchedexternal/was hand-edited🧪 Testing
How has this been tested?
Local check on
09cff076(macOS arm64, rebased onto master837ae9a2), all green: the oraclebun tools/oracles/service-config.tsrun twice with no diff (it runs upstream's ownservice-config.tsover the corpus and writes the expected fixtures), slopwatch (0 issues),dotnet build -c Releaseand with-p:IncludeNet472Tests=true(0 warnings), both format passes,verify-clones, Tools tests (2841), SDK tests excluding ServiceElection and NativeAot (9250, net10.0 and net11.0), ServiceElection (18),--help,generate --verify.Tests: the oracle corpus (read, repair, donor copy, write shapes, CORS), the store, writer, editor, retry, cancellation and write tests, the door tests through
OpenCodeServiceConfiguration's seams,ServiceConfigReaderandServiceMigrationadditions,RandomCredential, the file-system and environment seams, a live test that reads the pinned managed service's password through the password door without writing, and the cancellation table rows.Mutation proof, one mutant at a time under the full analyzer build, each killed at its assertion on net10.0 and net11.0: more than sixty mutants across the implementation and its five fix-up rounds (the read, the repair, the donor rule, the refusal, the writer, the password door, the shared decode step, the duplicate-member refusal and the doors' seams); the net472 replay re-targets the ones still meaningful at this head as 59 rows. Not counted: four analyzer controls (three S8949, one IDE0060). Token-dropping mutants on the config doors ran only after the isolation guard was in, and wrote only under the session roots. The net472 replay is pending on the Windows gate host; this PR is enqueued only after it.
Reviews: fresh cross-family reads of S-a, its fix-up, S-b and each of its five fix-up rounds; every blocking finding was fixed and re-proven. The isolation guard is proven red on both of its path checks (the registration path with
XDG_STATE_HOMEwithheld, the config path withOPENCODE_CONFIG_DIRandXDG_CONFIG_HOMEwithheld; the guard alone ran under those mutants), and the method that runs the config doors depends on it, so a failed guard skips the doors.📚 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 once; this PR corrects only the canon sentence S-b made untrueKnown follow-ups
Non-blocking items from the last read, left for a later change:
[DependsOn]sits on the cancellation table's public-door method, so a failed isolation guard also skips that method's non-config rows (HTTP, events, PTY); only the two config rows need it.ServiceConfigWriteData.CollidingDonorNamesis now the config-only colliding donor besideCollidingRegistrationNames; its name could say so.