Repository navigation
test: a live service starts on the caller's config dir and serves the saved one after startup - #470
Merged
Merged
Conversation
… saved one after startup At the 2.0.32 pin the service re-applies its saved service-config env once it has started: the port comes from the caller's config directory, read at startup, while config discovery after startup uses the saved directory.
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.
What
This PR adds one live characterization test for the env precedence that the 2.0.32 refresh (#465) documented. When the caller and a background service's saved service config both set a key, the caller's value wins for anything the service reads at startup, and the saved value wins for anything it reads after startup.
Why the behaviour is what it is (upstream at the pin,
843a6c5)packages/cli/src/server-process.ts, in service mode:OPENCODE_CONFIG_DIRat:38, thenprocess.chdir(global.home),ServiceConfig.options()/read(), and the incumbent probe (:61-73).:75then runsObject.assign(process.env, config.env)on every service-mode start.:118, throughroutes.ts:124andconfig/discovery.ts:68-71).The test
OpenCodeServerEnsureLiveTests.EnsureAsync_Should_Start_On_The_Callers_Config_Dir_And_Serve_The_Saved_One_After_Startupuses a single key,OPENCODE_CONFIG_DIR.OpenCodeServerEnsureOptions.Environment. A's channel config holdsport = context.Portandenv = { OPENCODE_CONFIG_DIR: B }.context.Port: it read A's config before applying the saved env.GET /api/configreturnsConfigDirectoryentries that contain B and not A. Paths are normalized withGetFullPath, and membership is checked by element.Everything stays inside the context's run root, and the machine's real service is never touched. Cleanup is the existing per-test context teardown.
What this does not cover: the harness runs the ensure in direct-registration mode, where
ConfigFileis null, soServiceElection.OverlayAsyncreads no service config there. The SDK's own map merge stays covered byServiceEnsurerTests(lines 437-456). This test pins the upstream server behaviour that the merge feeds.Proof
There is no product mutant, because the behaviour belongs to upstream. Instead, two fixture controls each made a temporary edit to the new test's arrange, were run, and were restored:
envContains(GetFullPath(B)): "the item was not found in the collection"server.Endpoint.Port == context.Port: "Expected to be 62388 but found 62389"Checks:
OpenCodeServerEnsureLiveTests: 8 of 8 on net10.0 and on net472, 7 existing tests plus the new one.OpenCode.Sdk.Tools.Testsproject: 2072 of 2072.verify-clones: 0 new. Slopwatch: 0.OPENCODE_SDK_TESTS_BUN_MISMATCH=allow, so they are local evidence only. CI runs the exact pin, and its election pass covers Linux and macOS.88194dae(masterdf25ea59): all 8 steps, with 10,790 tests and 27 election tests, 0 failed. The first run failed the election step because the gate worktree's submodule was still checked out at v2.0.29 although its gitlink named v2.0.32. On that 2.0.29 server the new test is red, so it tells the two versions apart. After a submodule sync it passed. The prerequisite hole that let a stale submodule run is Pinned-server prerequisites accept a submodule checkout that differs from the recorded gitlink #469.Provenance
Sol Fast did a read-only research pass and then drafted the test from the coordinator's spec. The coordinator verified the evidence, read the change and ran the local check.
Need help on this PR? Tag
@codesmith-botwith what you need.