Specify R6 data contracts and verify coupled REST migration

This commit is contained in:
2026-09-06 03:46:13 +03:00
parent 0b58107097
commit 959b83c78f
13 changed files with 1544 additions and 190 deletions
+13 -3
View File
@@ -128,9 +128,10 @@ impl PreparedProject {
fn from_compiled(compiled: CompiledSourceProject) -> ApiResult<Self> {
check_model_size(&compiled.decoded.project)?;
check_source_size(&compiled.bundle)?;
let migration = compiled.decoded.migration.clone();
Ok(Self {
compiled,
migration: None,
migration,
})
}
@@ -173,6 +174,10 @@ impl PreparedProject {
&self.compiled.bundle
}
pub(crate) fn migration(&self) -> Option<&MigrationReport> {
self.migration.as_ref()
}
pub(crate) fn source_issues(&self) -> Vec<crate::error::IssueDto> {
self.compiled
.diagnostics
@@ -329,7 +334,12 @@ impl Store {
let prepared = if let Some(bundle) = envelope.source_project {
let prepared = PreparedProject::from_bundle(bundle.clone())
.map_err(|error| corrupt(error.detail))?;
if prepared.bundle() != &bundle || prepared.model() != &decoded.project {
// Explicit source upgrades may change tokens and generate new
// records. They must still agree with independently migrated
// JSON. Current-format unstabilized/inconsistent pairs reject.
if (prepared.bundle() != &bundle && prepared.migration.is_none())
|| prepared.model() != &decoded.project
{
return Err(corrupt(
"Stored source and model disagree, or source lacks stable identities."
.into(),
@@ -347,7 +357,7 @@ impl Store {
revision: envelope.revision,
model: decoded.project,
source_project: prepared.compiled.bundle,
migration: decoded.migration,
migration: decoded.migration.or(prepared.migration),
};
if stored.resource_id != filename_id || stored.revision == 0 {
return Err(corrupt(