Repository navigation
refactor: shared config layer resolution in uteke-core - #1354
Merged
Merged
Conversation
Add uteke_core::config_layers: per-key deep merge of the global and project uteke.toml, one untrusted-project-key policy (stripped before merging) and per-layer validation, generic over the schema type. The CLI (Config::load) and the server (load_uteke_toml) both use it, replacing ~290 lines of hand-listed merge_from_file, restore_sensitive_from and the server's overlay_project_config. A new config key now needs only a struct field. Server behaviour: project [recall]/[lifecycle]/... now merge per key instead of replacing the whole section; parse errors are logged instead of silent; UTEKE_TRUST_PROJECT_CONFIG=1 works for the server too. Refs #1342 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-code · BYOK · MIT |
This was referenced Oct 7, 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.
What
Step 1 of the Config module (#1342, tracked in #1345): a shared layer resolution module in core, used by both adapters.
uteke_core::config_layers(resolve::<T>(&Layers),deep_merge,strip_untrusted,UNTRUSTED_PROJECT_KEYS): global file then project-local file; tables merge per key, other values (arrays included) from the higher layer replace; untrusted project keys (embedding.{backend,api_key,base_url,endpoint_path},embed_fallback.*/extraction.*credentials+endpoints, the whole[server]section) are stripped from the project file before merging unlessUTEKE_TRUST_PROJECT_CONFIG=1; each layer must validate against the schema on its own, otherwise it is skipped with a warning.Config::load→Config::from_layers(+ env overrides as before). Deletedmerge_from_file(~290 lines, 56 hand-listedcontains_key) andrestore_sensitive_from.config.rs2256 → 1936 lines.load_uteke_tomlcalls the same resolver; deletedoverlay_project_config/read_server_toml.docs/configuration.mdper-project section now states what a project file may not set (the old example set[server], which has been ignored since security: untrusted project config, CORS off by default, list limit caps #1321).Why
The same
uteke.tomlwas merged by two different hand-written implementations and the untrusted-project rule existed twice. That caused real bugs: whole sections silently ignored by the CLI (#1334), a project file wiping the global[server]auth in the server (#1321). Adding a key needed a struct field and a merge line and a trust entry. Now a key needs a struct field only.Behaviour changes
[recall]/[lifecycle]/[maintenance]/[dream]now merges per key instead of replacing the global section (the CLI already did). Project[extraction]model/mode now apply; only itsapi_key/base_url/endpoint_pathare stripped (before, the whole section was ignored). Config parse errors are logged instead of silently dropped.UTEKE_TRUST_PROJECT_CONFIG=1is honoured by the server too.tomlinuteke-core(already used by CLI and server).Testing
[server]keeps global, invalid TOML / wrong-type layers skipped without leaking, missing files).load-style resolution incl. the new per-key[recall]merge (fixed a flaky temp-file name along the way).cargo fmt --check,cargo clippy --workspace --all-targetsclean;cargo test --workspacegreen (core 615, cli 87, server 52); vecq-only core build green (613).Configvs serverServerFileConfigstill mirror each other) — optional step 2 in refactor: one Config module in core; CLI and server as adapters #1342; env override tests unchanged.Refs #1342
🤖 Generated with Claude Code