Skip to main content

agent_profile/adapter/
fake.rs

1// Copyright (c) 2026 Costas Kirgoussios
2//
3// This software is licensed under the PolyForm Noncommercial License 1.0.0.
4// You may obtain a copy of the License at:
5// https://polyformproject.org/licenses/noncommercial/1.0.0/
6
7//! The debug-only test agent: `FAKE_AGENT_HOME` per profile (SP1 design D1, SP2 design ยง5.4).
8
9use std::path::PathBuf;
10
11use super::{
12    Adapter, AdapterEvidence, AdapterMetadata, Capability, CapabilityClaim, CapabilityState,
13    ConflictOption, EnvOverride, Mechanism, PathKind, PlanContext, PlannedLaunch, SupportLevel,
14    profile_dir,
15};
16use crate::config::AppRoot;
17use crate::error::Result;
18use crate::name::ProfileName;
19
20const VAR: &str = "FAKE_AGENT_HOME";
21
22static METADATA: AdapterMetadata = AdapterMetadata {
23    id: "fake",
24    executable: "fake-agent",
25    mechanism: Mechanism::Env(VAR),
26    support: SupportLevel::Experimental,
27    evidence: AdapterEvidence {
28        mechanism_id: "fake-home-v1",
29        verified_at: "2026-09-15",
30        upstream_version: "0.0.0",
31        source_url: "measured",
32        notes: "test fixture",
33    },
34    capabilities: &[
35        CapabilityClaim {
36            capability: Capability::ConfigIsolation,
37            state: CapabilityState::Unknown,
38            basis: "unmeasured: a fixture has nothing to isolate",
39        },
40        CapabilityClaim {
41            capability: Capability::CredentialIsolation,
42            state: CapabilityState::Unknown,
43            basis: "unmeasured: a fixture has nothing to isolate",
44        },
45        CapabilityClaim {
46            capability: Capability::StateIsolation,
47            state: CapabilityState::Unknown,
48            basis: "unmeasured: a fixture has nothing to isolate",
49        },
50    ],
51    env: &[EnvOverride { name: VAR, sensitive: false }],
52    conflicts: &[ConflictOption { long: &["--fake-profile"], short: None }],
53    credential_env: &[],
54};
55
56/// The test agent, launched through the `fake-agent` fixture.
57#[derive(Debug, Clone, Copy)]
58pub struct Fake;
59
60impl Adapter for Fake {
61    fn metadata(&self) -> &'static AdapterMetadata {
62        &METADATA
63    }
64
65    fn paths(&self, root: &AppRoot, profile: &ProfileName) -> Vec<(PathBuf, PathKind)> {
66        vec![(profile_dir(root, profile, METADATA.id), PathKind::Dir)]
67    }
68
69    fn plan(&self, ctx: &PlanContext<'_>) -> Result<PlannedLaunch> {
70        METADATA.mechanism.plan(self, ctx)
71    }
72}