Add private complete mixed Project resolution with retained provenance

This commit is contained in:
2026-09-23 11:15:41 -07:00
parent a578ac98a0
commit 8f0d96ca63
8 changed files with 2135 additions and 32 deletions
+25 -5
View File
@@ -1664,17 +1664,25 @@ impl Parser<'_> {
}
}
pub(crate) fn resolve_declarations(
// The construction phase is shared with private mixed resolution. Migration and
// complete-model admission remain exclusively in each caller's finishing tail.
struct ConstructedDeclarations {
project: Project,
legacy_elements: serde_json::Map<String, Value>,
}
fn construct_declarations<'a>(
mut project: Project,
declarations: &[Declaration],
declarations: impl IntoIterator<Item = &'a Declaration>,
aliases: &BTreeMap<String, Id>,
limits: ParseLimits,
) -> Result<crate::persistence::DecodeResult, (usize, Error)> {
mut before_fields: impl FnMut(&Declaration) -> Result<(), Error>,
) -> Result<ConstructedDeclarations, (usize, Error)> {
let legacy = project.schema_version == 3;
let mut legacy_elements = serde_json::Map::new();
let mut nodes = Vec::new();
for (index, declaration) in declarations.iter().enumerate() {
for (index, declaration) in declarations.into_iter().enumerate() {
(|| -> Result<(), Error> {
before_fields(declaration)?;
let mut fields = declaration
.fields
.iter()
@@ -1899,6 +1907,18 @@ pub(crate) fn resolve_declarations(
.map_err(|error| (index, error))?;
target.nodes.insert(node.id, node);
}
Ok(ConstructedDeclarations { project, legacy_elements })
}
pub(crate) fn resolve_declarations(
project: Project,
declarations: &[Declaration],
aliases: &BTreeMap<String, Id>,
limits: ParseLimits,
) -> Result<crate::persistence::DecodeResult, (usize, Error)> {
let legacy = project.schema_version == 3;
let ConstructedDeclarations { project, legacy_elements } =
construct_declarations(project, declarations, aliases, |_| Ok(()))?;
if legacy {
let migrated = source3_bridge::from_scratch(project, legacy_elements)
.and_then(|old| crate::persistence::v3::migrate(old, limits))