@@ -18,6 +18,7 @@ pub const DEFAULT_MAX_MANIFEST_BYTES: u64 = 1024 * 1024;
1818pub const DEFAULT_MAX_ROW_IDENTITY_JSONL_LINE_BYTES : usize = 64 * 1024 ;
1919pub const DEFAULT_MAX_ROW_IDENTITY_ROWS : usize = 10_000_000 ;
2020pub const DEFAULT_MAX_ROW_IDENTITY_TRACKED_DB_ID_BYTES : usize = 64 * 1024 * 1024 ;
21+ pub const DEFAULT_MAX_AUXILIARY_ARTIFACTS : usize = 1024 ;
2122pub const DEFAULT_MAX_REPORT_ISSUES : usize = 1024 ;
2223pub const DEFAULT_MAX_CACHED_REPORT_BYTES : u64 = 4 * 1024 * 1024 ;
2324
@@ -157,7 +158,7 @@ pub fn verify_index_manifest(
157158
158159pub fn verify_manifest ( document : & ManifestDocument , options : VerifyOptions ) -> VerificationReport {
159160 let mut report = VerificationReport :: new ( Some ( document. manifest . manifest_id . clone ( ) ) ) ;
160- validate_manifest_shape ( & document. manifest , & mut report) ;
161+ validate_manifest_shape ( & document. manifest , & options . limits , & mut report) ;
161162
162163 let artifact_display_path = document. manifest . artifact . path . clone ( ) ;
163164 report. artifact . manifest_path = Some ( artifact_display_path. clone ( ) ) ;
@@ -228,7 +229,11 @@ pub fn verify_manifest(document: &ManifestDocument, options: VerifyOptions) -> V
228229 report
229230}
230231
231- fn validate_manifest_shape ( manifest : & IndexManifest , report : & mut VerificationReport ) {
232+ fn validate_manifest_shape (
233+ manifest : & IndexManifest ,
234+ limits : & ResourceLimits ,
235+ report : & mut VerificationReport ,
236+ ) {
232237 if manifest. schema_version != SCHEMA_VERSION {
233238 report. error (
234239 "schema_version_unsupported" ,
@@ -321,7 +326,7 @@ fn validate_manifest_shape(manifest: &IndexManifest, report: &mut VerificationRe
321326 }
322327 }
323328
324- validate_auxiliary_artifact_shape ( manifest, report) ;
329+ validate_auxiliary_artifact_shape ( manifest, limits , report) ;
325330
326331 validate_optional_non_empty (
327332 "embedding_model_revision_empty" ,
@@ -401,7 +406,14 @@ fn validate_manifest_shape(manifest: &IndexManifest, report: &mut VerificationRe
401406 }
402407}
403408
404- fn validate_auxiliary_artifact_shape ( manifest : & IndexManifest , report : & mut VerificationReport ) {
409+ fn validate_auxiliary_artifact_shape (
410+ manifest : & IndexManifest ,
411+ limits : & ResourceLimits ,
412+ report : & mut VerificationReport ,
413+ ) {
414+ if !check_auxiliary_artifact_count ( manifest, limits, report) {
415+ return ;
416+ }
405417 let mut names = HashSet :: new ( ) ;
406418 for artifact in & manifest. auxiliary_artifacts {
407419 let name = artifact. name . trim ( ) ;
@@ -1176,6 +1188,9 @@ fn verify_auxiliary_artifacts(
11761188 options : & VerifyOptions ,
11771189 report : & mut VerificationReport ,
11781190) {
1191+ if !check_auxiliary_artifact_count ( & document. manifest , & options. limits , report) {
1192+ return ;
1193+ }
11791194 for artifact in auxiliary_artifacts_in_report_order ( & document. manifest ) {
11801195 let mut entry = AuxiliaryArtifactReport {
11811196 name : artifact. name . clone ( ) ,
@@ -1264,6 +1279,33 @@ fn verify_auxiliary_artifacts(
12641279 }
12651280}
12661281
1282+ fn check_auxiliary_artifact_count (
1283+ manifest : & IndexManifest ,
1284+ limits : & ResourceLimits ,
1285+ report : & mut VerificationReport ,
1286+ ) -> bool {
1287+ let count = manifest. auxiliary_artifacts . len ( ) ;
1288+ if count <= limits. max_auxiliary_artifacts {
1289+ return true ;
1290+ }
1291+ if !report
1292+ . errors
1293+ . iter ( )
1294+ . any ( |issue| issue. code == "auxiliary_artifact_count_limit_exceeded" )
1295+ {
1296+ push_report_issue_bounded (
1297+ & mut report. errors ,
1298+ limits,
1299+ "auxiliary_artifact_count_limit_exceeded" ,
1300+ format ! (
1301+ "auxiliary_artifacts has {count} entries, exceeding max_auxiliary_artifacts={}" ,
1302+ limits. max_auxiliary_artifacts
1303+ ) ,
1304+ ) ;
1305+ }
1306+ false
1307+ }
1308+
12671309fn auxiliary_artifacts_in_report_order ( manifest : & IndexManifest ) -> Vec < & AuxiliaryArtifact > {
12681310 let mut artifacts: Vec < _ > = manifest. auxiliary_artifacts . iter ( ) . collect ( ) ;
12691311 artifacts. sort_by ( |left, right| {
@@ -1473,6 +1515,7 @@ pub struct ResourceLimits {
14731515 pub max_row_identity_jsonl_line_bytes : usize ,
14741516 pub max_row_identity_rows : usize ,
14751517 pub max_row_identity_tracked_db_id_bytes : usize ,
1518+ pub max_auxiliary_artifacts : usize ,
14761519 pub max_report_issues : usize ,
14771520 pub max_cached_report_bytes : u64 ,
14781521}
@@ -1484,6 +1527,7 @@ impl Default for ResourceLimits {
14841527 max_row_identity_jsonl_line_bytes : DEFAULT_MAX_ROW_IDENTITY_JSONL_LINE_BYTES ,
14851528 max_row_identity_rows : DEFAULT_MAX_ROW_IDENTITY_ROWS ,
14861529 max_row_identity_tracked_db_id_bytes : DEFAULT_MAX_ROW_IDENTITY_TRACKED_DB_ID_BYTES ,
1530+ max_auxiliary_artifacts : DEFAULT_MAX_AUXILIARY_ARTIFACTS ,
14871531 max_report_issues : DEFAULT_MAX_REPORT_ISSUES ,
14881532 max_cached_report_bytes : DEFAULT_MAX_CACHED_REPORT_BYTES ,
14891533 }
@@ -1863,6 +1907,7 @@ pub struct VerificationReport {
18631907 pub checked_at : String ,
18641908 pub manifest_id : Option < String > ,
18651909 pub artifact : ArtifactReport ,
1910+ #[ serde( default ) ]
18661911 pub auxiliary_artifacts : Vec < AuxiliaryArtifactReport > ,
18671912 pub row_identity : RowIdentityReport ,
18681913 pub calibration : CalibrationReport ,
0 commit comments