v0.1.3-pre.011

This commit is contained in:
2026-08-16 04:35:23 +02:00
parent 695068acea
commit 274428bd2f
13 changed files with 1005 additions and 91 deletions

View File

@@ -1,5 +1,5 @@
// file: crates/ksp-config-lib/src/profile.rs
// version: 3
// version: 4
/// Origin of one top-level value in a resolved standard Config profile.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
@@ -83,9 +83,31 @@ impl ResolvedConfigProfile {
return self.origins.get(key).copied();
}
/// Resolves environment placeholders in the effective view while preserving this source profile and its Global/Profile provenance unchanged.
/// Resolves environment placeholders in the effective view and returns only the real runtime map.
///
/// Use [`Self::resolve_effective_environment_detailed`] when safe value, sensitivity and environment provenance are required. Global/Profile provenance on
/// this source profile remains unchanged in both cases.
pub fn resolve_effective_environment(&self, environment: &crate::ConfigEnvironment) -> ksp_core_lib::Result<serde_json::Map<String, serde_json::Value>> {
return environment.resolve_map(&self.effective);
let resolved = self.resolve_effective_environment_detailed(environment);
let resolved = match resolved {
std::result::Result::Ok(value) => value,
std::result::Result::Err(error) => return std::result::Result::Err(error),
};
return match resolved.value() {
serde_json::Value::Object(value) => std::result::Result::Ok(value.clone()),
_ => std::result::Result::Err(ksp_core_lib::Error::new(
crate::ERROR_CODE_DOCUMENT_SEMANTIC_INVALID,
"resolved Config profile effective view changed JSON shape",
)),
};
}
/// Resolves environment placeholders while preserving real/safe JSON trees, strongest sensitivity and JSON-Pointer environment provenance.
///
/// Top-level Global/Profile provenance remains available through [`Self::origin`]; the returned value adds literal/process/`.env`/fallback provenance for
/// the environment-resolution stage.
pub fn resolve_effective_environment_detailed(&self, environment: &crate::ConfigEnvironment) -> ksp_core_lib::Result<crate::ResolvedConfigJson> {
return environment.resolve_json_detailed(&serde_json::Value::Object(self.effective.clone()));
}
}
@@ -93,8 +115,8 @@ impl crate::ConfigDocumentEngine {
/// Loads, validates and resolves one standard Config document to its default or explicitly requested profile.
///
/// Passing `None` selects the autonomous `default_profile` declared by the document. Passing `Some(profile_id)` selects that profile explicitly.
/// Environment interpolation is intentionally not applied implicitly by profile selection. Call `ResolvedConfigProfile::resolve_effective_environment` with
/// a Config-owned environment snapshot when an effective runtime view is required.
/// Environment interpolation is intentionally not applied implicitly by profile selection. Call `ResolvedConfigProfile::resolve_effective_environment` for
/// a real runtime map or `ResolvedConfigProfile::resolve_effective_environment_detailed` when safe value, sensitivity and provenance are also required.
pub fn load_resolved_profile(
&self,
file_id: &crate::ConfigFileId,