Repository navigation
refactor(config): compile config patterns once, type settings secrets, trim cache checks - #358
Merged
Merged
Conversation
plain() rejected + so no new key could look like the retired per-build keys migration 014 deletes. That migration runs once, before any write, on caches older than 14, so a + written later is never deleted.
Only call() recovers the store, and it clears readers_valid before it does, so the writer loop's per-job connection path check never fired.
Registry::Url and Registry::Unusable were told apart on read-back by the same check producers apply, and the one reader (the datasource lookup) treats both alike, re-checking the value itself. They become Registry::Named; the URL check moves to the manager, its only user, and Ord drops the kind tiebreak, which the indexes already cover.
load_files puts the bundled schema beside the entry when the files leave it out, so the evaluator serves its map and nothing else for repository configs and local settings alike; the local flag and its /repo check go. A path outside the map was already unreadable: the evaluator never touches the host filesystem.
The hand copy of PatchulaSettings.pkl's defaults goes; a settings-less CLI run evaluates the schema once instead.
A registry entry and its secret are read through try_from into enums: basic carries its username and secret, bearer only a secret, and a secret is either an environment variable or a file. Exactly one secret source and a username only for basic can no longer be represented, so Secret::source, read_bytes_with and the engine's credentials stop handling the shapes the settings check refused. A shape problem now reads as the registry's path and what is wrong with it.
Settings diagnostics mask quoted values, the registry key among them.
Config fields holding patterns, version filters and extractor regexes deserialize straight into compiled Pattern, Patterns, Filter and ConfigRegex values that keep their text, which is how they serialize. A bad one is reported at its field path (rules[0].select.packages[1]) as the config is read, so validation stops compiling each one only to throw it away, and the lookup evaluator, the scanner, custom extractors and the report stop compiling them again: lookup's CompiledRule goes, and the extractor path check that silently skipped an invalid pattern is gone with the compile it guarded. The serialized config, which keys the extraction cache, is byte-for-byte what it was; a test pins it for every example against bytes recorded from the previous build.
Pattern compares and orders by its text alone, so the regex's internal cache never affects a quietImages key; clippy.toml says so.
Since map entries are checked as they deserialize, serde's error path split a map key at its dots, so a registry or quietImages problem highlighted whatever the key's last dotted part spelled (a host ending in .tools pointed at another entry's tools) and the settings masking hid which registry it was. Paths are now built from the error's segments: a registries key reads registries["https://host/path"] (its scheme, host, port and path; [redacted] when it carries a user or does not parse), a quietImages key reads security.quietImages[key], and the property to highlight is the last name outside any bracketed key. A registry's username or secret problem names that property again.
sweepies
force-pushed
the
refactor/simplify-config
branch
from
November 22, 2026 20:50
7e4aebf to
be34fa3
Compare
Merged
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.
Simplification pass over
crates/config(settings included) andcrates/cache. The items come from the review of cache, config, report, process and testkit (items 2–6, 11 and 12).Done
Pattern/Patterns,FilterandConfigRegexdeserialize straight from the config text and keep it. Serializing writes that text back, so the serialized config (which the engine hashes for its extraction cache) stays byte-for-byte the same.serialized_configs_keep_their_byteschecks this for every example and for a config that sets each compiled field, againstcrates/config/tests/config-serialized.txt. That file was recorded from the previous build. Errors keep their field paths, such asrules[0].select.packages[1]: invalid regex: …, andcompile_errors_name_the_field_pathchecks this. Validation no longer compiles each pattern just to throw it away. Lookup'sCompiledRuleand itsEvaluatorfields are gone, the scanner readsfiles/excludestraight from the config, custom extractors use the compiled regexes, and the report readsquietImagesdirectly instead of calling.ok(). Theis_ok_andpath incustom.rsis gone. It skipped an extractor whose paths did not compile. Validation already rejected that case, and now the type cannot hold it at all.Registry.authisOption<RegistryAuth>, whereBasic { username, secret }orBearer { secret }.SecretisEnv(name)orFile(path). Both are built throughtry_fromfrom the Pkl shape. "Exactly one secret source" and "username only for basic" can no longer be represented, soSecret::source,read_bytes_with, the engine'scredentials(and its "secret is missing" case) and the CLI server's secret helper stop handling shapes that were already refused. Security: the same entries are refused as before. The rules now hold by construction, which is strictly stronger. Wording change: a shape problem is now reported at the registry's path, for exampleregistries.<key>: username is required for basic registries, …, instead ofregistries["<key>"].username …. The settings diagnostic still masks the quoted key.Registryvariant for a named registry (item 4).Registry::UrlandRegistry::Unusablewere told apart on read-back by the same check producers apply. The one reader, the datasource lookup, treated both alike and checks the value itself, so they merge intoRegistry::Named. Serialization is unchanged (the recorded string). The URL check moves into the manager'sregistry_url, its only user.Ordloses the kind tiebreak, because the indexes tiebreak already keeps it consistent withEq.load_filesputs the bundled schema beside the entry when the supplied files leave it out. The evaluator then serves its map and nothing else, for repository configs and local settings alike. Thelocalflag and its/repoprefix check go. Security: unchanged. The evaluator never reads the host filesystem, so a path outside the map was already unreadable. Imports are still confined byimport_files.Settings::default()evaluates the bundledPatchulaSettings.pkl(item 6) instead of keeping a hand-written copy of its defaults. A CLI run without a settings file now does one Pkl evaluation.conn.path()check is dropped. Onlycall()recovers the store, and it clearsreaders_validbefore it does.plain()accepts+(item 12). Migration 014 runs once, before any write, on caches older than version 14, so a+written later is never deleted.The code-versioned states whose hashed sources this touches are bumped in
tests/state-versions.tsvandtests/derived-versions.tsv.Dropped
crates/datasource/src/github.rsusesmerge_release_pageandreleases.Follow-ups
Evaluator::newandScanner::newcan no longer fail but still returnResult. Changing that touches about 280 call sites in crates other open PRs are editing, so it is left for after they land.Notes
clippy.toml: it tellsmutable_key_typeto ignorePattern.Patterncompares and orders by its text alone, so the regex's internal cache never affects aquietImageskey.cargo test --workspacepasses,cargo clippy --workspace --all-targets -D warningsis clean, and the state/derived parity checks pass.After review
An adversarial review confirmed every security property but found two diagnostic regressions. Both came from moving map-entry checks into serde:
serde_path_to_errorsplits a map key at its dots, and the diagnostic highlights the path's last dotted part.registries.https://npm.acme.dev. Nothing was highlighted, or for a host ending in.toolsthe caret landed on another entry'stools = true. The settings masking also hid which registry was meant. Field paths are now built from the error's segments, so a registry key readsregistries["https://npm.acme.dev/"]: its scheme, host, port and path when it parses as an http(s) URL without a user or password, and[redacted]otherwise. The diagnostic leaves only http(s) URLs with no user, password, query or fragment unmasked; everything else is still masked. Ausernameorsecretproblem names that property again (registries["…"].username is required …), as before this PR. Tests:a_registry_problem_names_and_points_at_its_registrycovers the.toolshost, naming the registry, and a key with a user and password staying redacted.security.quietImageskey errors. The path becamesecurity.quietImages.<pattern>, and[unclosed.imageshighlightedimages = true. Map keys now format assecurity.quietImages[<key>]. The property to highlight is the last name outside any bracketed key, so this case highlightsquietImages. Test:a_bad_quiet_image_key_points_at_quiet_images.The parity hashes are updated for the changed
crates/config/src; versions were already bumped in this PR. Tested on the VM: config, engine, cli and server tests pass, workspace clippy with-D warningsis clean, and parity passes.