fix(STRA-156): check indexed splits before metadata
Validate pinned index split summaries and tensor counts before parsing split metadata, then validate that metadata before profile and tokenizer parsing. Model-format tests, rustfmt, and strict Clippy pass.
This commit is contained in:
@@ -298,11 +298,12 @@ impl Qwen4ExpArtifact {
|
||||
|
||||
fn bind_after_identity(owners: [VerifiedGgufFile; 2]) -> Result<Self, BindingError> {
|
||||
let mut owners = owners;
|
||||
validate_owner_index_split(&owners)?;
|
||||
let split_metadata = [
|
||||
owners[0].split_snapshot().map_err(BindingError::Io)?,
|
||||
owners[1].split_snapshot().map_err(BindingError::Io)?,
|
||||
];
|
||||
validate_owner_split(&owners, &split_metadata)?;
|
||||
validate_owner_metadata_split(&split_metadata)?;
|
||||
let mut snapshots = [
|
||||
owners[0].profile_snapshot().map_err(BindingError::Io)?,
|
||||
owners[1].profile_snapshot().map_err(BindingError::Io)?,
|
||||
@@ -391,10 +392,7 @@ impl Qwen4ExpArtifact {
|
||||
}
|
||||
}
|
||||
|
||||
fn validate_owner_split(
|
||||
owners: &[VerifiedGgufFile; 2],
|
||||
metadata: &[MetadataSnapshot; 2],
|
||||
) -> Result<(), BindingError> {
|
||||
fn validate_owner_index_split(owners: &[VerifiedGgufFile; 2]) -> Result<(), BindingError> {
|
||||
for (number, owner) in owners.iter().enumerate() {
|
||||
let summary = &owner.index().summary;
|
||||
if summary.split_no != Some(number as u64) {
|
||||
@@ -407,6 +405,16 @@ fn validate_owner_split(
|
||||
return Err(BindingError::Split("split.tensors.count"));
|
||||
}
|
||||
}
|
||||
for (number, owner) in owners.iter().enumerate() {
|
||||
let expected = if number == 0 { 1223 } else { 1 };
|
||||
if owner.index().tensors.len() != expected {
|
||||
return Err(BindingError::Split("indexed_tensor_count"));
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn validate_owner_metadata_split(metadata: &[MetadataSnapshot; 2]) -> Result<(), BindingError> {
|
||||
for (number, snapshot) in metadata.iter().enumerate() {
|
||||
if snapshot.split_no != Some(number as u64) {
|
||||
return Err(BindingError::Split("split.no"));
|
||||
@@ -418,12 +426,6 @@ fn validate_owner_split(
|
||||
return Err(BindingError::Split("split.tensors.count"));
|
||||
}
|
||||
}
|
||||
for (number, owner) in owners.iter().enumerate() {
|
||||
let expected = if number == 0 { 1223 } else { 1 };
|
||||
if owner.index().tensors.len() != expected {
|
||||
return Err(BindingError::Split("indexed_tensor_count"));
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user