Let a remote loader read a flag the local layer carries - #44
Merged
Conversation
When the URL a remote config is fetched from is itself a flag — one the bundled local config sets — the loader has to resolve it through the pole after the local layer is applied. The pole does not exist when the configuration is constructed (it is built from the configuration's own sources), so a loader passed to init cannot reach it. Add EnvironmentConfiguration.fetchRemote(_:) to set the loader once the pole exists, capturing it. load(_:) already applies the local layer in full before running the loader, so the flag resolves through the whole stack — a by-hand override of the URL wins over the bundled value. The init remote: parameter is now optional (a nil loader leaves the remote layer absent), so existing call sites are unaffected. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NnwCqKNm8rZ63Au6bpYdaD
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
Adds
EnvironmentConfiguration.fetchRemote(_:), so the remote layer can be fetched from a URL that itself lives in a flag the local config sets.Why
Some apps store the remote config's endpoint in their bundled local config: the app only knows where to fetch from after the local layer is applied.
load(_:)already applies the local layer in full before running the remote loader, so the timing was never the problem — the pole was. It doesn't exist when the configuration is built (the pole is constructed fromconfig.sources), so a loader passed toinithas nothing to resolve a flag against.fetchRemote(_:)closes that construction-order knot: set the loader after the pole exists, capturing it.Because the loader resolves through the whole pole, a by-hand override of the URL beats the bundled value — so a staging build can be pointed at a different config server from the companion without a rebuild.
API
EnvironmentConfiguration.fetchRemote(_:).remote:init parameter is now optional (defaults to a nil-returning loader). A nil loader leaves the remote layer.absent. Non-breaking — existingremote:-at-init call sites still compile.Notes
lockinload(_:), alongsideepoch;remotemoved fromlettovar..superseded— a wasted fetch, never a wrong apply. Same guarantee as before.fetchRemotethere would be an artificial example.Tests
Three added to
EnvironmentConfigurationTests(TDD, red first):.absent.Full suite: 774 pass, 0 failures. DocC builds clean under
--warnings-as-errors(new subsection inSourcesAndPrecedence.md).🤖 Generated with Claude Code
https://claude.ai/code/session_01NnwCqKNm8rZ63Au6bpYdaD