eidetic-engine 0.15.1

Durable, local-first, explainable memory for coding agents.
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
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
//! Agent-safe install and update planning contracts (EE-DIST-003).
//!
//! These contracts describe what an installer or updater would inspect or
//! mutate. Planning remains data-only; update apply consumes the verified plan
//! through the guarded side-path artifact flow.

use std::cmp::Ordering;
use std::fmt;
use std::path::Path;

use serde::{Deserialize, Serialize};

/// Schema for `ee install check --json`.
pub const INSTALL_CHECK_SCHEMA_V1: &str = "ee.install.check.v1";

/// Schema for the source-vs-installed freshness block in `ee install check`.
pub const INSTALL_FRESHNESS_SCHEMA_V1: &str = "ee.install.freshness.v1";

/// Schema for `ee install plan --json`.
pub const INSTALL_PLAN_SCHEMA_V1: &str = "ee.install.plan.v1";

/// Schema for `ee update --dry-run --json`.
pub const UPDATE_PLAN_SCHEMA_V1: &str = "ee.update.plan.v1";

/// Stable finding codes for install/update diagnostics.
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum InstallFindingCode {
    ArtifactChecksumMismatch,
    ArtifactMissing,
    BinaryNotOnPath,
    ChecksumVerificationPending,
    CurrentBinaryShadowed,
    DuplicatePathBinary,
    ExistingUnknownFile,
    InstalledBinaryStale,
    InstalledVersionUnknown,
    PathBinaryVersionMismatch,
    RequiredSurfaceMissing,
    InstallDirMissing,
    InstallDirNotWritable,
    DuplicateTarget,
    ManifestInvalid,
    ManifestMissing,
    NoArtifacts,
    NoUpdateSourceConfigured,
    OfflineNoManifest,
    SignatureMissing,
    SourceVersionUnknown,
    TargetMismatch,
    UnsupportedTarget,
    UnsafeArtifact,
    UnsafeTargetPath,
    UpdateApplyUnsupported,
    WouldDowngrade,
}

impl InstallFindingCode {
    #[must_use]
    pub const fn as_str(self) -> &'static str {
        match self {
            Self::ArtifactChecksumMismatch => "artifact_checksum_mismatch",
            Self::ArtifactMissing => "artifact_missing",
            Self::BinaryNotOnPath => "binary_not_on_path",
            Self::ChecksumVerificationPending => "checksum_verification_pending",
            Self::CurrentBinaryShadowed => "current_binary_shadowed",
            Self::DuplicatePathBinary => "duplicate_path_binary",
            Self::ExistingUnknownFile => "existing_unknown_file",
            Self::InstalledBinaryStale => "installed_binary_stale",
            Self::InstalledVersionUnknown => "installed_version_unknown",
            Self::PathBinaryVersionMismatch => "path_binary_version_mismatch",
            Self::RequiredSurfaceMissing => "required_surface_missing",
            Self::InstallDirMissing => "install_dir_missing",
            Self::InstallDirNotWritable => "install_dir_not_writable",
            Self::DuplicateTarget => "duplicate_target",
            Self::ManifestInvalid => "manifest_invalid",
            Self::ManifestMissing => "manifest_missing",
            Self::NoArtifacts => "no_artifacts",
            Self::NoUpdateSourceConfigured => "no_update_source_configured",
            Self::OfflineNoManifest => "offline_no_manifest",
            Self::SignatureMissing => "signature_missing",
            Self::SourceVersionUnknown => "source_version_unknown",
            Self::TargetMismatch => "target_mismatch",
            Self::UnsupportedTarget => "unsupported_target",
            Self::UnsafeArtifact => "unsafe_artifact",
            Self::UnsafeTargetPath => "unsafe_target_path",
            Self::UpdateApplyUnsupported => "update_apply_unsupported",
            Self::WouldDowngrade => "would_downgrade",
        }
    }
}

impl fmt::Display for InstallFindingCode {
    fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
        formatter.write_str(self.as_str())
    }
}

/// Severity of an install/update finding.
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum InstallFindingSeverity {
    Info,
    Warning,
    Error,
}

impl InstallFindingSeverity {
    #[must_use]
    pub const fn as_str(self) -> &'static str {
        match self {
            Self::Info => "info",
            Self::Warning => "warning",
            Self::Error => "error",
        }
    }
}

/// One actionable diagnostic emitted by install/update planning.
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct InstallFinding {
    pub code: InstallFindingCode,
    pub severity: InstallFindingSeverity,
    pub message: String,
    pub next_action: String,
}

impl InstallFinding {
    #[must_use]
    pub fn info(
        code: InstallFindingCode,
        message: impl Into<String>,
        next_action: impl Into<String>,
    ) -> Self {
        Self {
            code,
            severity: InstallFindingSeverity::Info,
            message: message.into(),
            next_action: next_action.into(),
        }
    }

    #[must_use]
    pub fn warning(
        code: InstallFindingCode,
        message: impl Into<String>,
        next_action: impl Into<String>,
    ) -> Self {
        Self {
            code,
            severity: InstallFindingSeverity::Warning,
            message: message.into(),
            next_action: next_action.into(),
        }
    }

    #[must_use]
    pub fn error(
        code: InstallFindingCode,
        message: impl Into<String>,
        next_action: impl Into<String>,
    ) -> Self {
        Self {
            code,
            severity: InstallFindingSeverity::Error,
            message: message.into(),
            next_action: next_action.into(),
        }
    }
}

/// PATH posture for the `ee` binary.
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum InstallPathStatus {
    Ok,
    Missing,
    Duplicate,
    Shadowed,
}

impl InstallPathStatus {
    #[must_use]
    pub const fn as_str(self) -> &'static str {
        match self {
            Self::Ok => "ok",
            Self::Missing => "missing",
            Self::Duplicate => "duplicate",
            Self::Shadowed => "shadowed",
        }
    }
}

/// Conservative writability posture for the configured install target.
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum InstallPermissionStatus {
    Writable,
    MissingParentWritable,
    MissingParentUnknown,
    NotWritable,
}

impl InstallPermissionStatus {
    #[must_use]
    pub const fn as_str(self) -> &'static str {
        match self {
            Self::Writable => "writable",
            Self::MissingParentWritable => "missing_parent_writable",
            Self::MissingParentUnknown => "missing_parent_unknown",
            Self::NotWritable => "not_writable",
        }
    }
}

/// High-level decision for an install or update plan.
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum InstallPlanStatus {
    Ready,
    Blocked,
    Degraded,
    Idempotent,
}

impl InstallPlanStatus {
    #[must_use]
    pub const fn as_str(self) -> &'static str {
        match self {
            Self::Ready => "ready",
            Self::Blocked => "blocked",
            Self::Degraded => "degraded",
            Self::Idempotent => "idempotent",
        }
    }
}

/// Type of install/update operation being planned.
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum InstallOperation {
    Install,
    Update,
}

impl InstallOperation {
    #[must_use]
    pub const fn as_str(self) -> &'static str {
        match self {
            Self::Install => "install",
            Self::Update => "update",
        }
    }
}

/// One observed `ee` binary in PATH.
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PathBinary {
    pub path: String,
    pub ordinal: usize,
    pub is_current_binary: bool,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub version: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub version_status: Option<String>,
}

/// PATH analysis for an install check.
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct InstallPathAnalysis {
    pub status: InstallPathStatus,
    pub path_entries: Vec<String>,
    pub binaries: Vec<PathBinary>,
    pub first_binary: Option<String>,
    pub current_binary_on_path: bool,
    pub duplicate_count: usize,
}

/// Permission check for the intended install directory.
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct InstallPermissionCheck {
    pub status: InstallPermissionStatus,
    pub install_dir: String,
    pub target_path: String,
    pub exists: bool,
    pub writable: bool,
}

/// Target platform selected for a plan.
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct InstallTarget {
    pub target_triple: String,
    pub supported: bool,
    pub binary_name: String,
    pub executable_name: String,
    pub install_dir: String,
    pub install_path: String,
}

/// Current binary observation for `install check`.
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct CurrentBinary {
    pub path: Option<String>,
    pub version: String,
    pub source: String,
}

/// Update-source posture for read-only install checks.
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct UpdateSourcePosture {
    pub configured: bool,
    pub offline: bool,
    pub source: Option<String>,
    pub status: String,
}

/// Freshness verdict for deciding whether a running `ee` can authoritatively
/// represent the current source checkout for agent automation.
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum InstallFreshnessVerdict {
    Fresh,
    Stale,
    UnknownSourceVersion,
    UnknownInstalledVersion,
    MissingRequiredSurface,
    PathBinaryMissing,
    ShadowedBinary,
}

impl InstallFreshnessVerdict {
    #[must_use]
    pub const fn as_str(self) -> &'static str {
        match self {
            Self::Fresh => "fresh",
            Self::Stale => "stale",
            Self::UnknownSourceVersion => "unknown_source_version",
            Self::UnknownInstalledVersion => "unknown_installed_version",
            Self::MissingRequiredSurface => "missing_required_surface",
            Self::PathBinaryMissing => "path_binary_missing",
            Self::ShadowedBinary => "shadowed_binary",
        }
    }
}

/// One version input used by the freshness authority model.
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct InstallVersionEvidence {
    pub version: Option<String>,
    pub source: String,
    pub status: String,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub path: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub path_class: Option<String>,
}

/// Derived source-vs-installed freshness report.
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct InstallFreshnessReport {
    pub schema: String,
    pub verdict: InstallFreshnessVerdict,
    pub authoritative: bool,
    pub comparison: String,
    pub source_version: InstallVersionEvidence,
    pub installed_version: InstallVersionEvidence,
    pub path_status: InstallPathStatus,
    pub required_surfaces: Vec<String>,
    pub missing_required_surfaces: Vec<String>,
    pub blocking_findings: Vec<InstallFindingCode>,
    pub repair: String,
}

/// Report emitted by `ee install check`.
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct InstallCheckReport {
    pub command: String,
    pub schema: String,
    pub version: String,
    pub current_binary: CurrentBinary,
    pub target: InstallTarget,
    pub path: InstallPathAnalysis,
    pub permissions: InstallPermissionCheck,
    pub update_source: UpdateSourcePosture,
    pub freshness: InstallFreshnessReport,
    pub findings: Vec<InstallFinding>,
}

impl InstallCheckReport {
    #[must_use]
    pub fn status(&self) -> InstallPlanStatus {
        findings_status(&self.findings)
    }
}

/// Selected release artifact for a dry-run plan.
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct InstallArtifactSelection {
    pub artifact_id: String,
    pub release_version: String,
    pub file_name: String,
    pub target_triple: String,
    pub archive_format: String,
    pub checksum_algorithm: String,
    pub checksum: String,
    pub signature: String,
}

/// One planned file operation. Planning commands never execute these.
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PlannedInstallOperation {
    pub action: String,
    pub path: String,
    pub mode: String,
    pub requires_verification: bool,
}

/// Verification posture for the selected artifact and target path.
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct InstallVerificationPlan {
    pub manifest_status: String,
    pub checksum_status: String,
    pub signature_status: String,
    pub target_status: String,
    pub overwrite_status: String,
}

/// Dry-run report emitted by install planning and update planning.
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct InstallPlanReport {
    pub command: String,
    pub schema: String,
    pub version: String,
    pub operation: InstallOperation,
    pub dry_run: bool,
    pub status: InstallPlanStatus,
    pub current_version: String,
    pub target_version: Option<String>,
    pub pinned_version: Option<String>,
    pub target: InstallTarget,
    pub artifact: Option<InstallArtifactSelection>,
    pub verification: InstallVerificationPlan,
    pub planned_operations: Vec<PlannedInstallOperation>,
    pub idempotency_key: String,
    pub rollback: String,
    pub findings: Vec<InstallFinding>,
}

/// Compare package versions conservatively without pulling in a semver parser.
#[must_use]
pub fn compare_versions(current: &str, target: &str) -> Ordering {
    let current_version = ParsedVersion::parse(current);
    let target_version = ParsedVersion::parse(target);
    let width = current_version.core.len().max(target_version.core.len());
    for index in 0..width {
        let left = current_version.core.get(index).copied().unwrap_or(0);
        let right = target_version.core.get(index).copied().unwrap_or(0);
        match left.cmp(&right) {
            Ordering::Equal => {}
            ordering => return ordering,
        }
    }
    compare_prerelease(
        current_version.prerelease.as_deref(),
        target_version.prerelease.as_deref(),
    )
}

#[must_use]
pub fn is_safe_install_path(path: &Path) -> bool {
    path.is_absolute()
        && path.components().all(|component| {
            !matches!(
                component,
                std::path::Component::ParentDir | std::path::Component::CurDir
            )
        })
}

#[must_use]
pub fn findings_status(findings: &[InstallFinding]) -> InstallPlanStatus {
    if findings
        .iter()
        .any(|finding| finding.severity == InstallFindingSeverity::Error)
    {
        InstallPlanStatus::Blocked
    } else if findings
        .iter()
        .any(|finding| finding.severity == InstallFindingSeverity::Warning)
    {
        InstallPlanStatus::Degraded
    } else {
        InstallPlanStatus::Ready
    }
}

#[derive(Debug, Eq, PartialEq)]
struct ParsedVersion {
    core: Vec<u64>,
    prerelease: Option<Vec<PrereleaseIdentifier>>,
}

impl ParsedVersion {
    fn parse(version: &str) -> Self {
        let trimmed = version.trim().trim_start_matches('v');
        let without_build = trimmed.split_once('+').map_or(trimmed, |(core, _)| core);
        let (core, prerelease) = without_build
            .split_once('-')
            .map_or((without_build, None), |(core, prerelease)| {
                (core, Some(prerelease))
            });

        Self {
            core: version_parts(core),
            prerelease: prerelease.and_then(parse_prerelease_identifiers),
        }
    }
}

#[derive(Debug, Eq, PartialEq)]
enum PrereleaseIdentifier {
    Numeric(u64),
    Text(String),
}

fn parse_prerelease_identifiers(prerelease: &str) -> Option<Vec<PrereleaseIdentifier>> {
    let identifiers = prerelease
        .split('.')
        .filter(|part| !part.is_empty())
        .map(|part| {
            if part.chars().all(|ch| ch.is_ascii_digit()) {
                part.parse::<u64>()
                    .map(PrereleaseIdentifier::Numeric)
                    .unwrap_or_else(|_| PrereleaseIdentifier::Text(part.to_owned()))
            } else {
                PrereleaseIdentifier::Text(part.to_owned())
            }
        })
        .collect::<Vec<_>>();

    if identifiers.is_empty() {
        None
    } else {
        Some(identifiers)
    }
}

fn compare_prerelease(
    current: Option<&[PrereleaseIdentifier]>,
    target: Option<&[PrereleaseIdentifier]>,
) -> Ordering {
    match (current, target) {
        (None, None) => Ordering::Equal,
        (None, Some(_)) => Ordering::Greater,
        (Some(_), None) => Ordering::Less,
        (Some(current), Some(target)) => compare_prerelease_identifiers(current, target),
    }
}

fn compare_prerelease_identifiers(
    current: &[PrereleaseIdentifier],
    target: &[PrereleaseIdentifier],
) -> Ordering {
    let width = current.len().max(target.len());
    for index in 0..width {
        let Some(left) = current.get(index) else {
            return Ordering::Less;
        };
        let Some(right) = target.get(index) else {
            return Ordering::Greater;
        };
        let ordering = match (left, right) {
            (PrereleaseIdentifier::Numeric(left), PrereleaseIdentifier::Numeric(right)) => {
                left.cmp(right)
            }
            (PrereleaseIdentifier::Numeric(_), PrereleaseIdentifier::Text(_)) => Ordering::Less,
            (PrereleaseIdentifier::Text(_), PrereleaseIdentifier::Numeric(_)) => Ordering::Greater,
            (PrereleaseIdentifier::Text(left), PrereleaseIdentifier::Text(right)) => {
                left.cmp(right)
            }
        };
        if ordering != Ordering::Equal {
            return ordering;
        }
    }
    Ordering::Equal
}

fn version_parts(version: &str) -> Vec<u64> {
    version
        .trim()
        .trim_start_matches('v')
        .split('.')
        .map(|part| {
            part.chars()
                .take_while(|ch| ch.is_ascii_digit())
                .collect::<String>()
        })
        .take_while(|part| !part.is_empty())
        .filter_map(|part| part.parse::<u64>().ok())
        .collect()
}

#[cfg(test)]
mod tests {
    use super::*;

    type TestResult = Result<(), String>;

    fn ensure(condition: bool, context: &str) -> TestResult {
        if condition {
            Ok(())
        } else {
            Err(context.to_owned())
        }
    }

    fn ensure_equal<T: std::fmt::Debug + PartialEq>(
        actual: T,
        expected: T,
        context: &str,
    ) -> TestResult {
        if actual == expected {
            Ok(())
        } else {
            Err(format!("{context}: expected {expected:?}, got {actual:?}"))
        }
    }

    #[test]
    fn version_comparison_orders_patch_releases() -> TestResult {
        ensure_equal(
            compare_versions("0.1.9", "0.1.10"),
            Ordering::Less,
            "patch ordering",
        )?;
        ensure_equal(
            compare_versions("v0.2.0", "0.1.10"),
            Ordering::Greater,
            "v prefix ordering",
        )?;
        ensure_equal(
            compare_versions("0.2.0", "0.2.0+build"),
            Ordering::Equal,
            "build metadata ignored",
        )?;
        ensure_equal(
            compare_versions("0.2.0-alpha", "0.2.0"),
            Ordering::Less,
            "prerelease sorts before stable",
        )?;
        ensure_equal(
            compare_versions("0.2.0", "0.2.0-rc.1"),
            Ordering::Greater,
            "stable sorts after prerelease",
        )?;
        ensure_equal(
            compare_versions("0.2.0-alpha.2", "0.2.0-alpha.10"),
            Ordering::Less,
            "numeric prerelease identifiers sort numerically",
        )?;
        ensure_equal(
            compare_versions("0.2.0-alpha", "0.2.0-alpha+build"),
            Ordering::Equal,
            "build metadata ignored after prerelease",
        )
    }

    #[test]
    fn findings_status_is_conservative() -> TestResult {
        ensure_equal(findings_status(&[]), InstallPlanStatus::Ready, "empty")?;
        ensure_equal(
            findings_status(&[InstallFinding::warning(
                InstallFindingCode::SignatureMissing,
                "missing",
                "attach signature",
            )]),
            InstallPlanStatus::Degraded,
            "warning",
        )?;
        ensure_equal(
            findings_status(&[InstallFinding::error(
                InstallFindingCode::UnsupportedTarget,
                "unsupported",
                "pick supported target",
            )]),
            InstallPlanStatus::Blocked,
            "error",
        )
    }

    #[test]
    fn safe_install_path_rejects_relative_traversal() -> TestResult {
        ensure(is_safe_install_path(Path::new("/tmp/ee")), "absolute path")?;
        ensure(!is_safe_install_path(Path::new("bin/ee")), "relative path")?;
        ensure(
            !is_safe_install_path(Path::new("/tmp/../ee")),
            "parent traversal",
        )
    }
}