fix: align Profile authoring with compaction and reasoning contracts (T-710)
Resolve MR seq9 supported-compaction-fields and numeric-extraction-reasoning findings. Cover all canonical CompactionConfigPartial settings, token aliases and ratio helpers; accept string effort and signed integer extraction budgets without materializing editor defaults. Audit the remaining Profile field groups against their real serde contracts.
Share an actual-provider value corpus across native, generated WASM, and shared save/projection/verified Runtime archive consumption. Prove inline/import/patch exact values and effective Manifest settings; gate canonical compaction field coverage against serialization of the actual partial type. Keep prior scope union and worker/feature diagnostics fixes intact.
Validation: root cargo check; config-source40; unfiltered server644+11; Runtime340+17+17; API typescript77; Deno39; deno task check0/0; wasm32 release regeneration byte-identical with wasm-bindgen0.2.117/Binaryen132; cargo fmt/diff checks. Logs target/t710-contract-{check,config-source,server,api,runtime}.log. Reviewer seq9 independently confirmed seq3/5/7 resolution and correct main/relative-cwd routing. No target integration/ref mutations.
This commit is contained in:
@@ -303,6 +303,141 @@ async fn value_profiles_scalar_and_table_scopes_analyze_save_and_resolve_equally
|
||||
assert_eq!(scopes[1], scopes[2]);
|
||||
}
|
||||
|
||||
fn profile_fixture_decodal(value: &serde_json::Value) -> String {
|
||||
match value {
|
||||
serde_json::Value::Object(fields) => format!(
|
||||
"{{ {} }}",
|
||||
fields
|
||||
.iter()
|
||||
.map(|(key, value)| format!("{key} = {};", profile_fixture_decodal(value)))
|
||||
.collect::<Vec<_>>()
|
||||
.join(" ")
|
||||
),
|
||||
serde_json::Value::Array(values) => format!(
|
||||
"[{}]",
|
||||
values
|
||||
.iter()
|
||||
.map(profile_fixture_decodal)
|
||||
.collect::<Vec<_>>()
|
||||
.join(", ")
|
||||
),
|
||||
serde_json::Value::Null => panic!("fixture omission must not be represented as null"),
|
||||
value => value.to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn value_profiles_authoring_corpus_preserves_effective_runtime_settings() {
|
||||
let cases: Vec<serde_json::Value> = serde_json::from_str(include_str!(
|
||||
"../../../../../resources/config-schema/profile-authoring-values.json"
|
||||
))
|
||||
.unwrap();
|
||||
// The canonical token fixture must exercise every serializable setting,
|
||||
// so adding a field to CompactionConfigPartial cannot silently outgrow the
|
||||
// editor-shape coverage. Aliases/ratio helpers have separate corpus cases.
|
||||
let default = serde_json::to_value(manifest::CompactionConfigPartial::default()).unwrap();
|
||||
let canonical = cases
|
||||
.iter()
|
||||
.find(|case| case["name"] == "canonical_compaction_tokens")
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
default
|
||||
.as_object()
|
||||
.unwrap()
|
||||
.keys()
|
||||
.collect::<std::collections::BTreeSet<_>>(),
|
||||
canonical["profile"]["compaction"]
|
||||
.as_object()
|
||||
.unwrap()
|
||||
.keys()
|
||||
.filter(|name| name.as_str() != "kind")
|
||||
.collect()
|
||||
);
|
||||
for case in cases {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let api = test_api(dir.path()).await;
|
||||
let recipe = profile_fixture_decodal(&case["profile"]);
|
||||
for (index, (form, patched)) in [
|
||||
(recipe.clone(), false),
|
||||
(r#"import "./recipe.dcdl""#.into(), false),
|
||||
(
|
||||
r#"(import "./recipe.dcdl") // { description = "patched"; }"#.into(),
|
||||
true,
|
||||
),
|
||||
]
|
||||
.iter()
|
||||
.enumerate()
|
||||
{
|
||||
let extra = if index == 0 {
|
||||
vec![config_source::ConfigTreeChange::Create {
|
||||
path: config_source::VirtualPath::parse("recipe.dcdl").unwrap(),
|
||||
content_type: config_source::ConfigContentType::Decodal,
|
||||
content: recipe.clone(),
|
||||
}]
|
||||
} else {
|
||||
vec![]
|
||||
};
|
||||
let authored = format!("{} as WorkspaceConfigSchema", source(form));
|
||||
let state = commit_workspace_config_tree(
|
||||
&api,
|
||||
TEST_WORKSPACE_ID,
|
||||
&request(&api, &authored, extra),
|
||||
)
|
||||
.unwrap();
|
||||
let environment = config_source::SnapshotEnvironment::new(state.snapshot.clone())
|
||||
.with_schema_bundle(state.contract.schema_bundle.clone());
|
||||
let diagnostics = environment.analyze(
|
||||
&config_source::VirtualPath::parse("main.dcdl").unwrap(),
|
||||
None,
|
||||
);
|
||||
assert!(diagnostics.is_empty(), "{}: {diagnostics:?}", case["name"]);
|
||||
let mut expected = case["profile"].clone();
|
||||
if *patched {
|
||||
expected["description"] = serde_json::json!("patched");
|
||||
}
|
||||
let evaluated = environment.evaluate_contract(&state.contract).unwrap();
|
||||
assert_eq!(
|
||||
evaluated.projections[0]
|
||||
.data_json
|
||||
.pointer("/profile/entries/0/profile"),
|
||||
Some(&expected)
|
||||
);
|
||||
let projection =
|
||||
project_profiles_from_workspace_config(TEST_WORKSPACE_ID, &state).unwrap();
|
||||
let bundle = build_virtual_profile_config_bundle(
|
||||
&projection,
|
||||
&state,
|
||||
TEST_WORKSPACE_ID,
|
||||
"created",
|
||||
"project:alpha",
|
||||
)
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
let resolved = bundle
|
||||
.profile_source_archive
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.verify()
|
||||
.unwrap()
|
||||
.resolve_profile(
|
||||
"project:alpha",
|
||||
Path::new("/runtime-worker"),
|
||||
"corpus-worker",
|
||||
)
|
||||
.unwrap();
|
||||
let manifest = serde_json::to_value(resolved).unwrap();
|
||||
for (pointer, value) in case["manifest_expect"].as_object().unwrap() {
|
||||
assert_eq!(
|
||||
manifest.pointer(pointer),
|
||||
Some(value),
|
||||
"{}: {pointer}",
|
||||
case["name"]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn value_profiles_invalid_saves_preserve_the_active_config() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
|
||||
Reference in New Issue
Block a user