alef-component-runtime 0.127.3

Verified downloader and dynamic loader for Alef native components
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
use super::*;
use crate::{ComponentIdentity, ComponentLibrary};
use ed25519_dalek::{Signer as _, SigningKey};
use std::io::Cursor;
use std::sync::atomic::AtomicBool;
use std::time::Duration;

fn package(signing: Option<(&SigningKey, &str)>) -> (Vec<u8>, ComponentLockEntry) {
    let library = b"native";
    let identity = ComponentIdentity {
        crate_name: "demo-core".into(),
        component: "fast".into(),
        version: "1.0.0".into(),
        target: "test-target".into(),
        feature_hash: hex::encode([1; 32]),
        contract_hash: hex::encode([2; 32]),
    };
    let manifest = ComponentManifest {
        schema_version: COMPONENT_MANIFEST_SCHEMA,
        abi_version: 1,
        identity: identity.clone(),
        provides: vec![crate::ComponentProvidedContract {
            contract: "engine".into(),
            interface_version: 1,
            contract_hash: hex::encode([2; 32]),
            implementation: "demo::Fast".into(),
        }],
        features: vec!["fast".into()],
        default_features: false,
        library: ComponentLibrary {
            file: "libdemo.so".into(),
            sha256: hex::encode(sha256(library)),
            size: library.len() as u64,
        },
    };
    let manifest_bytes = manifest.canonical_bytes().unwrap();
    let signature = signing.map(|(key, id)| ComponentSignature {
        algorithm: "ed25519".into(),
        key_id: id.into(),
        signature: base64::engine::general_purpose::STANDARD.encode(key.sign(&manifest_bytes).to_bytes()),
    });
    let mut compressed = Vec::new();
    {
        let encoder = flate2::write::GzEncoder::new(&mut compressed, flate2::Compression::default());
        let mut builder = tar::Builder::new(encoder);
        append(&mut builder, "component.json", &manifest_bytes);
        if let Some(signature) = &signature {
            append(
                &mut builder,
                "component.sig",
                &crate::canonical_json(signature).unwrap(),
            );
        }
        append(&mut builder, "libdemo.so", library);
        builder.into_inner().unwrap().finish().unwrap();
    }
    let entry = ComponentLockEntry {
        identity,
        provides: manifest.provides.clone(),
        mode: crate::ComponentDeliveryMode::Download,
        url: "unused".into(),
        sha256: hex::encode(sha256(&compressed)),
        size: compressed.len() as u64,
        manifest_sha256: hex::encode(sha256(&manifest_bytes)),
        key_id: signature.map(|value| value.key_id).unwrap_or_default(),
        input_hash: None,
    };
    (compressed, entry)
}

fn append(builder: &mut tar::Builder<flate2::write::GzEncoder<&mut Vec<u8>>>, path: &str, content: &[u8]) {
    let mut header = tar::Header::new_gnu();
    header.set_size(content.len() as u64);
    header.set_mode(0o644);
    header.set_cksum();
    builder.append_data(&mut header, path, Cursor::new(content)).unwrap();
}

#[test]
fn installs_and_verifies_full_trust_chain() {
    let signing = SigningKey::from_bytes(&[7; 32]);
    let (bytes, entry) = package(Some((&signing, "release")));
    let keys = BTreeMap::from([(
        "release".into(),
        base64::engine::general_purpose::STANDARD.encode(signing.verifying_key().to_bytes()),
    )]);
    let dir = tempfile::tempdir().unwrap();
    let cache = ArtifactCache::new(dir.path(), TrustPolicy::EmbeddedKeys(keys));
    let installed = cache.install_from_reader(&entry, Cursor::new(bytes)).unwrap();
    assert_eq!(fs::read(installed.library).unwrap(), b"native");
    assert_eq!(installed.manifest.identity, entry.identity);
}

/// Regression for the padding disagreement between this loader, `alef`'s config
/// validation, and `alef`'s artifact verification: config accepted unpadded base64
/// keys while the loader accepted only standard-padded base64, so a key that passed
/// config validation and was baked into the lock would fail every load here.
#[test]
fn installs_and_verifies_full_trust_chain_with_unpadded_base64_key() {
    let signing = SigningKey::from_bytes(&[7; 32]);
    let (bytes, entry) = package(Some((&signing, "release")));
    let keys = BTreeMap::from([(
        "release".into(),
        base64::engine::general_purpose::STANDARD_NO_PAD.encode(signing.verifying_key().to_bytes()),
    )]);
    let dir = tempfile::tempdir().unwrap();
    let cache = ArtifactCache::new(dir.path(), TrustPolicy::EmbeddedKeys(keys));
    let installed = cache.install_from_reader(&entry, Cursor::new(bytes)).unwrap();
    assert_eq!(fs::read(installed.library).unwrap(), b"native");
    assert_eq!(installed.manifest.identity, entry.identity);
}

#[test]
fn reuses_verified_cache_when_source_is_unavailable() {
    let (bytes, mut entry) = package(None);
    let dir = tempfile::tempdir().unwrap();
    let cache = ArtifactCache::new(dir.path(), TrustPolicy::DigestOnly);
    let installed = cache.install_from_reader(&entry, Cursor::new(bytes)).unwrap();
    entry.url = "file:///source/does/not/exist".into();

    let reused = cache.install(&entry).unwrap();
    assert_eq!(reused, installed);
}

#[test]
fn rejects_unsigned_archive_when_lock_names_a_key() {
    let (bytes, mut entry) = package(None);
    entry.key_id = "release".into();
    let keys = BTreeMap::from([(
        "release".into(),
        base64::engine::general_purpose::STANDARD.encode(SigningKey::from_bytes(&[7; 32]).verifying_key().to_bytes()),
    )]);
    let dir = tempfile::tempdir().unwrap();
    let cache = ArtifactCache::new(dir.path(), TrustPolicy::EmbeddedKeys(keys));
    assert!(matches!(
        cache.install_from_reader(&entry, Cursor::new(bytes)),
        Err(ComponentError::SignatureRequired)
    ));
}

#[test]
fn rejects_archive_digest_mismatch() {
    let (bytes, mut entry) = package(None);
    entry.sha256 = "00".repeat(32);
    let dir = tempfile::tempdir().unwrap();
    let cache = ArtifactCache::new(dir.path(), TrustPolicy::DigestOnly);
    assert!(matches!(
        cache.install_from_reader(&entry, Cursor::new(bytes)),
        Err(ComponentError::DigestMismatch { .. })
    ));
}

#[test]
fn stops_when_download_exceeds_pinned_size() {
    let (bytes, mut entry) = package(None);
    entry.size = 1;
    let dir = tempfile::tempdir().unwrap();
    let cache = ArtifactCache::new(dir.path(), TrustPolicy::DigestOnly);
    assert!(matches!(
        cache.install_from_reader(&entry, Cursor::new(bytes)),
        Err(ComponentError::SizeMismatch { expected: 1, .. })
    ));
}

#[test]
fn rejects_invalid_signature_without_installing() {
    let signing = SigningKey::from_bytes(&[7; 32]);
    let wrong_key = SigningKey::from_bytes(&[8; 32]);
    let (bytes, entry) = package(Some((&signing, "release")));
    let keys = BTreeMap::from([(
        "release".into(),
        base64::engine::general_purpose::STANDARD.encode(wrong_key.verifying_key().to_bytes()),
    )]);
    let dir = tempfile::tempdir().unwrap();
    let cache = ArtifactCache::new(dir.path(), TrustPolicy::EmbeddedKeys(keys));
    let destination = cache.object_path(&entry).unwrap();

    assert!(matches!(
        cache.install_from_reader(&entry, Cursor::new(bytes)),
        Err(ComponentError::SignatureVerification)
    ));
    assert!(!destination.exists());
}

#[test]
fn offline_mode_rejects_a_missing_artifact_without_a_network_attempt() {
    let (_bytes, mut entry) = package(None);
    entry.url = "https://example.invalid/component.tar.gz".into();
    let dir = tempfile::tempdir().unwrap();
    let cache = ArtifactCache::new(dir.path(), TrustPolicy::DigestOnly).offline(true);

    let error = cache.install(&entry).unwrap_err();

    assert!(matches!(
        error,
        ComponentError::Offline { ref component, ref url }
            if component == "fast" && url == "https://example.invalid/component.tar.gz"
    ));
}

#[test]
fn offline_mode_still_reuses_an_already_verified_cache_entry() {
    let (bytes, entry) = package(None);
    let dir = tempfile::tempdir().unwrap();
    let cache = ArtifactCache::new(dir.path(), TrustPolicy::DigestOnly);
    let installed = cache.install_from_reader(&entry, Cursor::new(bytes)).unwrap();

    let offline_cache = ArtifactCache::new(dir.path(), TrustPolicy::DigestOnly).offline(true);
    let reused = offline_cache.install(&entry).unwrap();

    assert_eq!(reused, installed);
}

#[test]
fn offline_mode_does_not_block_a_file_url() {
    let (bytes, mut entry) = package(None);
    let dir = tempfile::tempdir().unwrap();
    let source = dir.path().join("source.tar.gz");
    fs::write(&source, &bytes).unwrap();
    entry.url = format!("file://{}", source.display());

    let cache_root = tempfile::tempdir().unwrap();
    let cache = ArtifactCache::new(cache_root.path(), TrustPolicy::DigestOnly).offline(true);

    assert!(cache.install(&entry).is_ok());
}

#[test]
fn rejects_parent_traversal_archive_entry() {
    let mut tar_bytes = Vec::new();
    {
        let mut builder = tar::Builder::new(&mut tar_bytes);
        let mut header = tar::Header::new_gnu();
        header.set_size(1);
        header.set_mode(0o644);
        header.as_mut_bytes()[..7].copy_from_slice(b"../evil");
        header.set_cksum();
        builder.append(&header, Cursor::new(b"x")).unwrap();
        builder.finish().unwrap();
    }
    let mut compressed = Vec::new();
    {
        let mut encoder = flate2::write::GzEncoder::new(&mut compressed, flate2::Compression::default());
        encoder.write_all(&tar_bytes).unwrap();
        encoder.finish().unwrap();
    }
    let dir = tempfile::tempdir().unwrap();
    assert!(matches!(
        extract_safely(Cursor::new(compressed), dir.path()),
        Err(ComponentError::UnsafeArchiveEntry(path)) if path == "../evil"
    ));
    assert!(!dir.path().parent().unwrap().join("evil").exists());
}

/// Yields at most `chunk` bytes per read so progress is reported several times.
struct ChunkedReader {
    data: Vec<u8>,
    position: usize,
    chunk: usize,
}

impl Read for ChunkedReader {
    fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> {
        let end = (self.position + self.chunk)
            .min(self.data.len())
            .min(self.position + buf.len());
        let slice = &self.data[self.position..end];
        buf[..slice.len()].copy_from_slice(slice);
        self.position = end;
        Ok(slice.len())
    }
}

#[test]
fn progress_reports_cumulative_bytes_against_the_pinned_total() {
    let (bytes, entry) = package(None);
    let seen = Arc::new(std::sync::Mutex::new(Vec::new()));
    let sink = Arc::clone(&seen);
    let options = DownloadOptions::default().with_progress(move |done, total| sink.lock().unwrap().push((done, total)));
    let dir = tempfile::tempdir().unwrap();
    let cache = ArtifactCache::new(dir.path(), TrustPolicy::DigestOnly).with_download_options(options);
    let reader = ChunkedReader {
        data: bytes,
        position: 0,
        chunk: 16,
    };

    cache.install_from_reader(&entry, reader).unwrap();

    let seen = seen.lock().unwrap();
    assert!(seen.len() > 1, "expected several progress calls, got {}", seen.len());
    assert!(seen.windows(2).all(|pair| pair[0].0 < pair[1].0));
    assert!(seen.iter().all(|&(_, total)| total == entry.size));
    assert_eq!(seen.last().copied(), Some((entry.size, entry.size)));
}

#[test]
fn cancel_flag_aborts_between_chunks_without_installing() {
    let (bytes, entry) = package(None);
    let cancel = Arc::new(AtomicBool::new(false));
    let trigger = Arc::clone(&cancel);
    let options = DownloadOptions::default()
        .with_cancel(Arc::clone(&cancel))
        .with_progress(move |_, _| trigger.store(true, std::sync::atomic::Ordering::Relaxed));
    let dir = tempfile::tempdir().unwrap();
    let cache = ArtifactCache::new(dir.path(), TrustPolicy::DigestOnly).with_download_options(options);
    let destination = cache.object_path(&entry).unwrap();
    let reader = ChunkedReader {
        data: bytes,
        position: 0,
        chunk: 16,
    };

    let error = cache.install_from_reader(&entry, reader).unwrap_err();

    assert!(matches!(error, ComponentError::Cancelled));
    assert_eq!(error.code(), "cancelled");
    assert!(!destination.exists());
}

#[test]
fn already_cancelled_install_fails_before_any_network_attempt() {
    let (_bytes, mut entry) = package(None);
    entry.url = "https://example.invalid/component.tar.gz".into();
    let cancel = Arc::new(AtomicBool::new(true));
    let dir = tempfile::tempdir().unwrap();
    let cache = ArtifactCache::new(dir.path(), TrustPolicy::DigestOnly)
        .with_download_options(DownloadOptions::default().with_cancel(cancel));

    assert!(matches!(cache.install(&entry), Err(ComponentError::Cancelled)));
}

#[test]
fn url_override_replaces_the_lock_url_and_integrity_still_applies() {
    let (bytes, mut entry) = package(None);
    entry.url = "https://origin.invalid/component.tar.gz".into();
    let source = tempfile::tempdir().unwrap();
    let mirror = source.path().join("mirror.tar.gz");
    fs::write(&mirror, &bytes).unwrap();
    let target = format!("file://{}", mirror.display());

    let dir = tempfile::tempdir().unwrap();
    let cache = ArtifactCache::new(dir.path(), TrustPolicy::DigestOnly).with_url_override(move |_| target.clone());
    assert!(cache.install(&entry).is_ok());

    fs::write(&mirror, b"substituted content").unwrap();
    let other = tempfile::tempdir().unwrap();
    let target = format!("file://{}", mirror.display());
    let cache = ArtifactCache::new(other.path(), TrustPolicy::DigestOnly).with_url_override(move |_| target.clone());
    assert!(matches!(
        cache.install(&entry),
        Err(ComponentError::SizeMismatch { .. } | ComponentError::DigestMismatch { .. })
    ));
}

#[test]
fn install_stamps_last_use() {
    let (bytes, entry) = package(None);
    let dir = tempfile::tempdir().unwrap();
    let cache = ArtifactCache::new(dir.path(), TrustPolicy::DigestOnly);
    cache.install_from_reader(&entry, Cursor::new(bytes)).unwrap();

    let objects = cache.list_objects().unwrap();
    assert_eq!(objects.len(), 1);
    assert!(
        dir.path()
            .join("sha256")
            .join(format!("{}.used", entry.sha256))
            .is_file()
    );
}

fn set_mtime(path: &Path, offset_secs: u64) {
    let later = std::time::SystemTime::now() + Duration::from_secs(offset_secs);
    File::options()
        .write(true)
        .open(path)
        .unwrap()
        .set_modified(later)
        .unwrap();
}

#[test]
fn verified_stamp_is_off_by_default() {
    let (bytes, entry) = package(None);
    let dir = tempfile::tempdir().unwrap();
    let cache = ArtifactCache::new(dir.path(), TrustPolicy::DigestOnly);
    cache.install_from_reader(&entry, Cursor::new(bytes)).unwrap();
    assert!(!cache.stamp_path(&entry.sha256).exists());
}

#[test]
fn verified_stamp_lets_a_matching_library_skip_rehashing() {
    let (bytes, entry) = package(None);
    let dir = tempfile::tempdir().unwrap();
    let cache = ArtifactCache::new(dir.path(), TrustPolicy::DigestOnly).with_verified_stamp(true);
    let installed = cache.install_from_reader(&entry, Cursor::new(bytes)).unwrap();
    assert!(cache.stamp_path(&entry.sha256).is_file());

    // A same-size edit that is re-stamped (what a local attacker with cache write access
    // could do) is trusted: documents the limit of the threat model.
    fs::write(&installed.library, b"nativf").unwrap();
    let stamp = stamp::capture(&entry.sha256, &installed.library).unwrap();
    stamp::write(&cache.stamp_path(&entry.sha256), &stamp);

    let reused = cache.install(&entry).unwrap();
    assert_eq!(fs::read(reused.library).unwrap(), b"nativf");
}

#[test]
fn verified_stamp_mismatch_forces_full_verification_and_repair() {
    let (bytes, mut entry) = package(None);
    let source = tempfile::tempdir().unwrap();
    let archive = source.path().join("component.tar.gz");
    fs::write(&archive, &bytes).unwrap();
    entry.url = format!("file://{}", archive.display());
    let dir = tempfile::tempdir().unwrap();
    let cache = ArtifactCache::new(dir.path(), TrustPolicy::DigestOnly).with_verified_stamp(true);
    let installed = cache.install_from_reader(&entry, Cursor::new(bytes)).unwrap();

    fs::write(&installed.library, b"nativf").unwrap();
    set_mtime(&installed.library, 5);

    let repaired = cache.install(&entry).unwrap();
    assert_eq!(fs::read(repaired.library).unwrap(), b"native");
}

#[test]
fn full_verification_writes_the_stamp_for_a_pre_existing_install() {
    let (bytes, entry) = package(None);
    let dir = tempfile::tempdir().unwrap();
    ArtifactCache::new(dir.path(), TrustPolicy::DigestOnly)
        .install_from_reader(&entry, Cursor::new(bytes))
        .unwrap();
    let stamping = ArtifactCache::new(dir.path(), TrustPolicy::DigestOnly).with_verified_stamp(true);
    assert!(!stamping.stamp_path(&entry.sha256).exists());

    stamping.install(&entry).unwrap();

    assert!(stamping.stamp_path(&entry.sha256).is_file());
}

fn manifest_declaring_library_size(size: u64) -> ComponentManifest {
    ComponentManifest {
        schema_version: COMPONENT_MANIFEST_SCHEMA,
        abi_version: 1,
        identity: ComponentIdentity {
            crate_name: "demo-core".into(),
            component: "fast".into(),
            version: "1.0.0".into(),
            target: "test-target".into(),
            feature_hash: hex::encode([1; 32]),
            contract_hash: hex::encode([2; 32]),
        },
        provides: vec![crate::ComponentProvidedContract {
            contract: "engine".into(),
            interface_version: 1,
            contract_hash: hex::encode([2; 32]),
            implementation: "demo::Fast".into(),
        }],
        features: vec!["fast".into()],
        default_features: false,
        library: ComponentLibrary {
            file: "libdemo.so".into(),
            sha256: hex::encode(sha256(b"native")),
            size,
        },
    }
}

/// A component archive can only ever grow to the size the manifest itself declares (plus
/// a small fixed headroom): a library entry that decompresses to far more than that is
/// rejected before the whole thing is buffered or written to disk, bounding how much a
/// crafted or corrupted archive can force this loader to decompress.
#[test]
fn rejects_library_entry_exceeding_the_manifest_declared_size() {
    let manifest = manifest_declaring_library_size(6);
    let manifest_bytes = manifest.canonical_bytes().unwrap();
    let oversized_library = vec![b'x'; (LIBRARY_SIZE_HEADROOM + 4096) as usize];

    let mut compressed = Vec::new();
    {
        let encoder = flate2::write::GzEncoder::new(&mut compressed, flate2::Compression::default());
        let mut builder = tar::Builder::new(encoder);
        append(&mut builder, "component.json", &manifest_bytes);
        append(&mut builder, "libdemo.so", &oversized_library);
        builder.into_inner().unwrap().finish().unwrap();
    }

    let dir = tempfile::tempdir().unwrap();
    assert!(matches!(
        extract_safely(Cursor::new(compressed), dir.path()),
        Err(ComponentError::ExtractedSizeExceeded { .. })
    ));
    assert!(!dir.path().join("libdemo.so").exists());
}

/// The library entry must be a regular file: a symlink (which could point anywhere on
/// the filesystem once `dlopen`ed) is rejected outright, never followed or written.
#[test]
fn rejects_symlink_library_entry() {
    let manifest = manifest_declaring_library_size(6);
    let manifest_bytes = manifest.canonical_bytes().unwrap();

    let mut compressed = Vec::new();
    {
        let encoder = flate2::write::GzEncoder::new(&mut compressed, flate2::Compression::default());
        let mut builder = tar::Builder::new(encoder);
        append(&mut builder, "component.json", &manifest_bytes);
        let mut header = tar::Header::new_gnu();
        header.set_size(0);
        header.set_mode(0o777);
        header.set_entry_type(tar::EntryType::Symlink);
        header.set_link_name("/etc/passwd").unwrap();
        header.set_path("libdemo.so").unwrap();
        header.set_cksum();
        builder.append(&header, Cursor::new(&[][..])).unwrap();
        builder.into_inner().unwrap().finish().unwrap();
    }

    let dir = tempfile::tempdir().unwrap();
    assert!(matches!(
        extract_safely(Cursor::new(compressed), dir.path()),
        Err(ComponentError::UnsafeArchiveEntry(path)) if path == "libdemo.so"
    ));
    assert!(!dir.path().join("libdemo.so").exists());
}

/// A packaged component archive never has more than three entries (manifest, optional
/// signature, library); a fourth is not an archive this loader made.
#[test]
fn rejects_archive_with_too_many_entries() {
    let manifest = manifest_declaring_library_size(6);
    let manifest_bytes = manifest.canonical_bytes().unwrap();

    let mut compressed = Vec::new();
    {
        let encoder = flate2::write::GzEncoder::new(&mut compressed, flate2::Compression::default());
        let mut builder = tar::Builder::new(encoder);
        append(&mut builder, "component.json", &manifest_bytes);
        append(&mut builder, "component.sig", b"{}");
        append(&mut builder, "libdemo.so", b"native");
        append(&mut builder, "unexpected.txt", b"extra");
        builder.into_inner().unwrap().finish().unwrap();
    }

    let dir = tempfile::tempdir().unwrap();
    assert!(matches!(
        extract_safely(Cursor::new(compressed), dir.path()),
        Err(ComponentError::TooManyArchiveEntries {
            max: MAX_ARCHIVE_ENTRIES,
            ..
        })
    ));
}