Fix enforced connection fields overridden by user env vars#19
Merged
Conversation
Connection env vars (ANTHROPIC_BASE_URL, AWS_REGION, etc.) were applied as a post-merge overlay above the enforced layer, so a user's shell variable could override an admin-pinned value from POSIT_AI_PROVIDERS_ENFORCED. Convert the env vars into a resolver-owned config source ranked below enforced (rank 1) but above user/host/default (ranks 2-4). The single deepMerge now handles all precedence — enforced is merged last and always wins. The bespoke applyEnvOverlay in build-catalog.ts is removed. New module connection-env.ts owns CONNECTION_ENV_MAPPINGS and the reader; build-catalog.ts is left responsible only for turning merged config into catalog entries. Fixes #10
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.
Connection env vars (
ANTHROPIC_BASE_URL,AWS_REGION,POSITAI_AUTH_HOST, etc.) were applied as a post-merge overlay that landed above thePOSIT_AI_PROVIDERS_ENFORCEDlayer. This meant a user's shell variable could silently override an admin-pinned connection value, defeating the enforced control.The fix converts env vars from a post-resolution overlay into a resolver-owned config source ranked below
enforcedbut aboveuser/host/default. All precedence now flows through the singledeepMergeinresolveProviderCatalog— enforced is merged last and always wins. The bespokeapplyEnvOverlayfunction inbuild-catalog.tsis removed.Fixes #10
Changes
src/connection-env.ts(new) — ownsCONNECTION_ENV_MAPPINGSandreadEnvConnectionConfig(), extracted frombuild-catalog.ts.src/resolve-catalog.ts— privateConnectionEnvSource/RankedConfigSourcetypes;RANKmap withenvat rank 1; env source synthesized fromenvVars, excluded from enablement layers.src/build-catalog.ts— removedapplyEnvOverlay,readEnvSection,CONNECTION_ENV_MAPPINGS, and theoptions.envVarsparameter frombuildCatalog().build-catalog-custom.test.tsto the new three-argument signature.aiConfig.md, and JSDoc updated to describe precedence asenforced > connection env > user > host > default.Verification