use crate::check::{CheckKind, CheckLedger, CheckRecord, CheckState, Verdict, derive_state};
use crate::vcs::{Actor, ClientId};
use super::{Engine, error::EngineError};
impl Engine {
#[allow(clippy::too_many_arguments)] pub fn record_check(
&mut self,
mem_name: &str,
entity_id: &str,
verdict: Verdict,
kind: CheckKind,
method: Option<&str>,
actor: Actor,
client: Option<&ClientId>,
) -> Result<CheckRecord, EngineError> {
self.record_check_with(
mem_name,
entity_id,
verdict,
&crate::check::RecordKind::Engine(kind),
method,
None,
actor,
client,
)
}
#[allow(clippy::too_many_arguments)]
pub fn record_check_with(
&mut self,
mem_name: &str,
entity_id: &str,
verdict: Verdict,
kind: &crate::check::RecordKind,
method: Option<&str>,
finding: Option<crate::check::CheckFinding>,
actor: Actor,
client: Option<&ClientId>,
) -> Result<CheckRecord, EngineError> {
if let Some(f) = &finding {
f.validate()
.map_err(|reason| EngineError::InvalidCheckFinding { reason })?;
if crate::ops::strict::is_engine_code_shape(&f.code)
&& !crate::ops::strict::is_health_condition(&f.code)
{
return Err(EngineError::InvalidCheckFinding {
reason: format!(
"finding.code `{}` is spelled in the engine's UPPER_SNAKE namespace but \
names no health condition — an acknowledgement names one of: {}; a \
checker's own code takes another spelling (`hidden-premise`)",
f.code,
crate::ops::strict::HEALTH_CONDITIONS.join(", ")
),
});
}
if crate::ops::strict::is_health_condition(&f.code)
&& verdict == Verdict::Failed
&& method.is_none_or(|m| m.trim().is_empty())
{
return Err(EngineError::InvalidCheckFinding {
reason: format!(
"an acknowledgement of `{}` names its owner and the plan that closes it \
in `method`, and none was given",
f.code
),
});
}
}
let mount_idx = self
.mounts
.iter()
.position(|m| m.mount.mem == mem_name)
.ok_or_else(|| self.unknown_mem_error(mem_name))?;
if self.mounts[mount_idx].mount.capability != crate::workspace::MountCapability::Write {
return Err(EngineError::ReadOnlyMount(mem_name.to_string()));
}
let schema_ref = match kind.engine_kind() {
None | Some(CheckKind::Verification) => None,
Some(CheckKind::Conformance) => Some(
self.mounts[mount_idx]
.mount
.schema
.as_ref()
.map(|s| s.as_display())
.ok_or_else(|| {
EngineError::InvalidInput(format!(
"a conformance check binds to the mem's schema pin, and mem \
`{mem_name}` declares none"
))
})?,
),
};
let entity_hash = self
.store
.all_entities()
.find(|e| e.mem == mem_name && e.id.0 == entity_id)
.map(|e| e.content_hash.clone())
.ok_or_else(|| EngineError::NotFound {
id: entity_id.to_string(),
})?;
let Some(root) = self.workspace_root() else {
return Err(EngineError::CheckNotRecorded {
reason: "engine has no workspace root — no durable check store".to_string(),
});
};
let ledger = CheckLedger::for_workspace(root);
let record = CheckRecord {
ts: std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.map(|d| d.as_secs())
.unwrap_or(0),
entity: entity_id.to_string(),
verdict: verdict.as_str().to_string(),
method: method
.map(str::trim)
.filter(|m| !m.is_empty())
.map(str::to_string),
entity_hash,
actor: actor.as_trailer().to_string(),
client: client.map(|c| format!("{}@{}", c.name, c.version)),
role: self
.current_role()
.as_trailer()
.unwrap_or("unspecified")
.to_string(),
identity: self.current_identity().map(str::to_string),
kind: match kind {
crate::check::RecordKind::Engine(CheckKind::Verification) => None,
other => Some(other.as_wire().to_string()),
},
schema_ref,
finding,
renamed_from: None,
carried_from: None,
};
ledger
.record(&record)
.map_err(|e| EngineError::CheckNotRecorded {
reason: format!("ledger append failed: {e}"),
})?;
Ok(record)
}
pub(crate) fn carry_checks_across_rename(
&self,
old: &crate::entity::EntityId,
new: &crate::entity::EntityId,
) -> Result<usize, EngineError> {
let Some(root) = self.workspace_root() else {
return Ok(0);
};
CheckLedger::for_workspace(root)
.carry_rename(old.as_ref(), new.as_ref())
.map_err(|e| EngineError::CheckNotRecorded {
reason: format!("ledger carry across rename {old} → {new} failed: {e}"),
})
}
pub(crate) fn licensed_self_check_kinds(
&self,
next: &crate::entity::Entity,
type_def: &memstead_schema::TypeDefinition,
) -> Vec<String> {
let provider = self.check_standing_provider();
let mut kinds: Vec<String> = Vec::new();
for c in &type_def.constraints {
let memstead_schema::ConstraintDef::TransitionRequiresSelfCheck {
field,
to_value,
check_kind,
..
} = c
else {
continue;
};
let triggered = next
.metadata
.get(field.as_str())
.is_some_and(|v| v.to_frontmatter_string() == *to_value);
if triggered && !kinds.contains(check_kind) && provider(next, check_kind).confirms() {
kinds.push(check_kind.clone());
}
}
kinds
}
pub(crate) fn carry_checks_across_transition(
&self,
id: &crate::entity::EntityId,
kinds: &[String],
pre_hash: &str,
post_hash: &str,
) -> Result<usize, EngineError> {
if kinds.is_empty() || pre_hash == post_hash {
return Ok(0);
}
let Some(root) = self.workspace_root() else {
return Ok(0);
};
let ledger = CheckLedger::for_workspace(root);
let mut carried = 0;
for kind in kinds {
let moved = ledger
.carry_transition(id.as_ref(), kind, pre_hash, post_hash)
.map_err(|e| EngineError::CheckNotRecorded {
reason: format!(
"ledger carry of the `{kind}` record across the transition of {id} failed: {e}"
),
})?;
carried += usize::from(moved);
}
Ok(carried)
}
pub fn latest_check_record(
&self,
mem_name: &str,
entity_id: &str,
kind: &str,
) -> Option<CheckRecord> {
if self.is_archive_mount(mem_name) {
let path = crate::EntityId(entity_id.to_string());
return self
.archive_checks_for(mem_name)
.and_then(|sealed| sealed.latest(path.path(), kind))
.map(|sc| sc.to_record(entity_id, kind));
}
self.workspace_root()
.map(CheckLedger::for_workspace)
.and_then(|l| l.latest_for_wire_kind(entity_id, kind))
}
pub fn latest_foreign_checks(&self, mem_name: &str, entity_id: &str) -> Vec<CheckRecord> {
if self.is_archive_mount(mem_name) {
let path = crate::EntityId(entity_id.to_string());
return self
.archive_checks_for(mem_name)
.map(|sealed| {
sealed
.kinds_of(path.path())
.filter(|(k, _)| k.starts_with(crate::check::FOREIGN_KIND_PREFIX))
.map(|(k, sc)| sc.to_record(entity_id, k))
.collect()
})
.unwrap_or_default();
}
let Some(ledger) = self.workspace_root().map(CheckLedger::for_workspace) else {
return Vec::new();
};
let mut latest: std::collections::BTreeMap<String, CheckRecord> =
std::collections::BTreeMap::new();
for rec in ledger.all() {
if rec.entity != entity_id {
continue;
}
if let Some(k) = rec.foreign_kind() {
latest.insert(k.to_string(), rec.clone());
}
}
latest.into_values().collect()
}
pub fn entity_check_state(
&self,
mem_name: &str,
entity_id: &str,
) -> Result<(CheckState, Option<CheckRecord>), EngineError> {
self.find_mount(mem_name)?;
let current_hash = self
.store
.all_entities()
.find(|e| e.mem == mem_name && e.id.0 == entity_id)
.map(|e| e.content_hash.clone())
.ok_or_else(|| EngineError::NotFound {
id: entity_id.to_string(),
})?;
let latest =
self.latest_check_record(mem_name, entity_id, CheckKind::Verification.as_str());
Ok((derive_state(latest.as_ref(), ¤t_hash), latest))
}
pub fn entity_conformance_state(
&self,
mem_name: &str,
entity_id: &str,
) -> Result<(CheckState, Option<CheckRecord>), EngineError> {
let mount = self.find_mount(mem_name)?;
let current_pin = mount.mount.schema.as_ref().map(|s| s.as_display());
let current_hash = self
.store
.all_entities()
.find(|e| e.mem == mem_name && e.id.0 == entity_id)
.map(|e| e.content_hash.clone())
.ok_or_else(|| EngineError::NotFound {
id: entity_id.to_string(),
})?;
let latest = self.latest_check_record(mem_name, entity_id, CheckKind::Conformance.as_str());
Ok((
crate::check::derive_state_pinned(
latest.as_ref(),
¤t_hash,
current_pin.as_deref(),
),
latest,
))
}
}
#[cfg(test)]
mod tests {
use crate::check::{CheckKind, CheckLedger, CheckRecord, CheckState, Verdict};
use crate::vcs::Actor;
use crate::workspace::MountCapability;
#[test]
fn conformance_refuses_without_a_schema_pin() {
let tmp = tempfile::TempDir::new().unwrap();
std::fs::write(
tmp.path().join("anything.md"),
"---\nid: anything\ntitle: Anything\ntype: note\n---\n\nBody.\n",
)
.unwrap();
let mut mount = crate::engine::test_helpers::folder_mount("m", tmp.path().to_path_buf());
mount.schema = None;
let mut engine = crate::Engine::from_mounts(vec![(
mount,
Box::new(crate::storage::FilesystemBackend::new(
tmp.path().to_path_buf(),
)) as Box<dyn crate::backend::MemBackend>,
)])
.unwrap();
let err = engine
.record_check(
"m",
"m--anything",
Verdict::Ok,
CheckKind::Conformance,
None,
Actor::Cli,
None,
)
.unwrap_err();
assert_eq!(err.code(), "MEM_QUARANTINED");
}
fn self_check_gated_engine(tmp: &tempfile::TempDir, check_kind: &str) -> crate::Engine {
let schemas_dir = tmp.path().join(".memstead").join("schemas");
let pkg = schemas_dir.join("selfgate");
std::fs::create_dir_all(pkg.join("types")).unwrap();
std::fs::write(
pkg.join("schema.yaml"),
r#"name: selfgate
version: 0.1.0
description: self-check gate fixture
when_to_use: tests
types:
- plan
relationships:
mode: strict
definitions:
- name: PART_OF
description: hier
default_weight: 3.0
- name: _default
description: fallback
default_weight: 1.0
community:
resolution: 1.0
seed: 42
"#,
)
.unwrap();
std::fs::write(
pkg.join("types").join("plan.yaml"),
format!(
r#"name: plan
description: p
when_to_use: tests
sections:
- key: body
heading: Body
required: true
search_weight: 10.0
catch_all: true
write_rules: []
metadata_fields:
- key: status
description: s
field_type: string
default_value: draft
enum_values: [draft, complete]
title_weight: 100.0
text_fields:
- body
hierarchy_relationship: PART_OF
updatable_fields:
- title
- body
- status
health_required_fields: []
staleness_threshold_days: 90
constraints:
- kind: transition_requires_self_check
field: status
to_value: complete
check_kind: {check_kind}
severity: block
write_rules: []
"#
),
)
.unwrap();
let mem_dir = tmp.path().join("bundles");
std::fs::create_dir_all(mem_dir.join(".memstead")).unwrap();
std::fs::write(
mem_dir.join(".memstead").join("config.json"),
r#"{"format": 1, "schema": "selfgate@0.1.0", "version": "1.0.0"}"#,
)
.unwrap();
let writer = crate::storage::FilesystemBackend::new(mem_dir.clone());
let mount = crate::workspace::Mount {
mem: "bundles".to_string(),
schema: Some(memstead_schema::SchemaRef::new(
"selfgate",
semver::Version::new(0, 1, 0),
)),
storage: crate::workspace::MountStorage::Folder { path: mem_dir },
capability: crate::workspace::MountCapability::Write,
lifecycle: crate::workspace::MountLifecycle::Eager,
cross_linkable: true,
migration_target: None,
};
let mut engine = crate::Engine::from_mounts_with_schemas_dir(
vec![(
mount,
Box::new(writer) as Box<dyn crate::backend::MemBackend>,
)],
Some(&schemas_dir),
)
.unwrap();
engine.set_workspace_root(tmp.path().to_path_buf());
engine
}
fn create_plan(engine: &mut crate::Engine, title: &str) -> crate::entity::EntityId {
let (actor, client) = crate::engine::test_helpers::cli_actor();
let mut sections = indexmap::IndexMap::new();
sections.insert("body".to_string(), "the plan body.".to_string());
engine
.create_entity(
crate::engine::CreateEntityArgs {
anchors: Vec::new(),
mem: "bundles".to_string(),
title: title.to_string(),
entity_type: "plan".to_string(),
sections,
metadata: indexmap::IndexMap::new(),
relations: Vec::new(),
dry_run: false,
},
actor,
Some(&client),
None,
)
.unwrap()
.id
}
fn set_status(
engine: &mut crate::Engine,
id: &crate::entity::EntityId,
value: &str,
) -> Result<crate::engine::UpdateEntityOutcome, crate::engine::error::EngineError> {
let (actor, client) = crate::engine::test_helpers::cli_actor();
let current = engine.get_entity(id).unwrap().content_hash.clone();
let mut metadata = indexmap::IndexMap::new();
metadata.insert("status".to_string(), value.to_string());
engine.update_entity(
crate::engine::UpdateEntityArgs {
anchors: Vec::new(),
id: id.clone(),
expected_hash: Some(current),
sections: indexmap::IndexMap::new(),
append_sections: indexmap::IndexMap::new(),
patch_sections: indexmap::IndexMap::new(),
sections_unset: Vec::new(),
metadata,
metadata_unset: Vec::new(),
declare_relations: vec![],
dry_run: false,
relations_unset: Vec::new(),
anchors_unset: Vec::new(),
},
actor,
Some(&client),
None,
)
}
fn append_body(engine: &mut crate::Engine, id: &crate::entity::EntityId) {
let (actor, client) = crate::engine::test_helpers::cli_actor();
let current = engine.get_entity(id).unwrap().content_hash.clone();
let mut append = indexmap::IndexMap::new();
append.insert("body".to_string(), "more.".to_string());
engine
.update_entity(
crate::engine::UpdateEntityArgs {
anchors: Vec::new(),
id: id.clone(),
expected_hash: Some(current),
sections: indexmap::IndexMap::new(),
append_sections: append,
patch_sections: indexmap::IndexMap::new(),
sections_unset: Vec::new(),
metadata: indexmap::IndexMap::new(),
metadata_unset: Vec::new(),
declare_relations: vec![],
dry_run: false,
relations_unset: Vec::new(),
anchors_unset: Vec::new(),
},
actor,
Some(&client),
None,
)
.unwrap();
}
fn check_plan(
engine: &mut crate::Engine,
identity: &str,
id: &crate::entity::EntityId,
kind: &str,
) {
check_plan_as(engine, identity, crate::vcs::Role::Checker, id, kind);
}
fn check_plan_as(
engine: &mut crate::Engine,
identity: &str,
role: crate::vcs::Role,
id: &crate::entity::EntityId,
kind: &str,
) {
let (actor, client) = crate::engine::test_helpers::cli_actor();
engine.set_identity(Some(identity.to_string()));
engine.set_role(role);
engine
.record_check_with(
"bundles",
id.as_ref(),
Verdict::Ok,
&crate::check::RecordKind::from_wire(kind).unwrap(),
Some("projection walked"),
None,
actor,
Some(&client),
)
.unwrap();
engine.set_role(crate::vcs::Role::Unspecified);
}
#[test]
fn licensing_self_check_carries_across_the_transition_it_admitted() {
let tmp = tempfile::TempDir::new().unwrap();
let mut engine = self_check_gated_engine(&tmp, "x-projection");
engine.set_identity(Some("author-a".to_string()));
let id = create_plan(&mut engine, "The Bundle");
let hash_at_check = engine.get_entity(&id).unwrap().content_hash.clone();
check_plan(&mut engine, "checker-c", &id, "x-projection");
engine.set_identity(Some("author-a".to_string()));
let outcome = set_status(&mut engine, &id, "complete").expect("the gate admits the write");
assert_ne!(
outcome.content_hash, hash_at_check,
"the write moved the hash"
);
let findings = engine.constraint_findings(Some("bundles"));
assert!(findings.is_empty(), "{findings:?}");
let foreign = engine.latest_foreign_checks("bundles", id.as_ref());
assert_eq!(foreign.len(), 1);
let carried = &foreign[0];
assert_eq!(carried.entity_hash, outcome.content_hash);
assert_eq!(carried.identity.as_deref(), Some("checker-c"));
assert_eq!(carried.method.as_deref(), Some("projection walked"));
assert_eq!(
carried.carried_from,
Some(crate::check::CarriedFrom::transition(&hash_at_check))
);
let entity = engine.get_entity(&id).unwrap().clone();
let standing = (engine.check_standing_provider())(&entity, "x-projection");
assert!(standing.confirms(), "{standing:?}");
let ledger = CheckLedger::for_workspace(tmp.path());
let lines: Vec<CheckRecord> = ledger
.all()
.into_iter()
.filter(|r| r.entity == id.as_ref())
.collect();
assert_eq!(lines.len(), 2);
assert!(lines[0].carried_from.is_none());
assert_eq!(lines[0].entity_hash, hash_at_check);
engine.set_identity(Some("author-a".to_string()));
append_body(&mut engine, &id);
assert!(engine.constraint_findings(Some("bundles")).is_empty());
let onward = &engine.latest_foreign_checks("bundles", id.as_ref())[0];
assert_eq!(
onward.entity_hash,
engine.get_entity(&id).unwrap().content_hash
);
assert_eq!(
onward.carried_from.as_ref().unwrap().hash,
outcome.content_hash
);
set_status(&mut engine, &id, "draft").unwrap();
let before = ledger.all().len();
append_body(&mut engine, &id);
assert_eq!(
ledger.all().len(),
before,
"no gate passed, nothing carried"
);
}
#[test]
fn carried_verification_record_reads_checked_ok_and_independent() {
let tmp = tempfile::TempDir::new().unwrap();
let mut engine = self_check_gated_engine(&tmp, "verification");
engine.set_identity(Some("author-a".to_string()));
let id = create_plan(&mut engine, "The Bundle");
check_plan(&mut engine, "checker-c", &id, "verification");
engine.set_identity(Some("author-a".to_string()));
set_status(&mut engine, &id, "complete").expect("the gate admits the write");
let (state, latest) = engine.entity_check_state("bundles", id.as_ref()).unwrap();
assert_eq!(state, CheckState::CheckedOk);
let latest = latest.unwrap();
assert_eq!(latest.identity.as_deref(), Some("checker-c"));
assert!(latest.carried_from.is_some());
let axis = crate::ops::health::health_checks_axis(&engine, Some("bundles"));
let independence = &axis["bundles"]["independence"];
assert_eq!(
independence["confirmed_independent"]["items"],
serde_json::json!([id.as_ref()]),
"{axis}"
);
assert_eq!(
axis["bundles"]["checked_ok"],
serde_json::json!(1),
"{axis}"
);
assert!(engine.constraint_findings(Some("bundles")).is_empty());
}
#[test]
fn a_record_in_role_author_or_without_a_role_does_not_close_the_gate() {
let tmp = tempfile::TempDir::new().unwrap();
let mut engine = self_check_gated_engine(&tmp, "verification");
engine.set_identity(Some("author-a".to_string()));
let id = create_plan(&mut engine, "The Bundle");
check_plan_as(
&mut engine,
"checker-c",
crate::vcs::Role::Author,
&id,
"verification",
);
let standing =
(engine.check_standing_provider())(engine.get_entity(&id).unwrap(), "verification");
assert_eq!(standing.state, CheckState::CheckedOk);
assert_eq!(
standing.independence,
Some(crate::engine::independence::Independence::ConfirmedIndependent)
);
assert!(!standing.confirms(), "{standing:?}");
assert_eq!(standing.label(), "role_author");
engine.set_identity(Some("author-a".to_string()));
let err = set_status(&mut engine, &id, "complete").unwrap_err();
assert_eq!(err.code(), "CONSTRAINT_UNSATISFIED", "{err}");
assert!(err.to_string().contains("role_author"), "{err}");
let axis = crate::ops::health::health_checks_axis(&engine, Some("bundles"));
let row = axis["bundles"]["independence"]["readings"][id.as_ref()]
.as_array()
.unwrap()
.last()
.unwrap();
assert_eq!(row["reading"], "confirmed_independent", "{axis}");
assert_eq!(row["role"], "author", "{axis}");
assert_eq!(row["role_confirms"], false, "{axis}");
check_plan_as(
&mut engine,
"checker-c",
crate::vcs::Role::Unspecified,
&id,
"verification",
);
let standing =
(engine.check_standing_provider())(engine.get_entity(&id).unwrap(), "verification");
assert!(!standing.confirms(), "{standing:?}");
assert_eq!(standing.label(), "role_unspecified");
engine.set_identity(Some("author-a".to_string()));
let err = set_status(&mut engine, &id, "complete").unwrap_err();
assert!(err.to_string().contains("role_unspecified"), "{err}");
check_plan_as(
&mut engine,
"verifier-v",
crate::vcs::Role::Verifier,
&id,
"verification",
);
let standing =
(engine.check_standing_provider())(engine.get_entity(&id).unwrap(), "verification");
assert!(standing.confirms(), "{standing:?}");
engine.set_identity(Some("author-a".to_string()));
set_status(&mut engine, &id, "complete").expect("a verifier's record closes the gate");
let axis = crate::ops::health::health_checks_axis(&engine, Some("bundles"));
let row = axis["bundles"]["independence"]["readings"][id.as_ref()]
.as_array()
.unwrap()
.last()
.unwrap();
assert_eq!(row["role"], "verifier", "{axis}");
assert_eq!(row["role_confirms"], true, "{axis}");
}
#[test]
fn sealed_independence_holds_the_transition_gate_on_the_archive_mount() {
let tmp = tempfile::TempDir::new().unwrap();
let mut engine = self_check_gated_engine(&tmp, "verification");
engine.set_identity(Some("author-a".to_string()));
let id = create_plan(&mut engine, "The Bundle");
check_plan(&mut engine, "checker-c", &id, "verification");
engine.set_identity(Some("author-a".to_string()));
set_status(&mut engine, &id, "complete").expect("the gate admits the write");
assert!(engine.constraint_findings(Some("bundles")).is_empty());
let bytes = engine.export_mem_to_bytes("bundles").unwrap();
let mounted = crate::Engine::from_archive_bytes(bytes).unwrap();
assert!(mounted.is_archive_mount("bundles"));
let findings = mounted.constraint_findings(Some("bundles"));
assert!(findings.is_empty(), "{findings:?}");
let entity = mounted.get_entity(&id).unwrap();
let standing = (mounted.check_standing_provider())(entity, "verification");
assert!(standing.confirms(), "{standing:?}");
let axis = crate::ops::health::health_checks_axis(&mounted, Some("bundles"));
assert_eq!(
axis["bundles"]["independence"]["confirmed_independent"]["items"],
serde_json::json!([id.as_ref()]),
"{axis}"
);
assert_eq!(
axis["bundles"]["checked_ok"],
serde_json::json!(1),
"{axis}"
);
}
#[test]
fn stale_self_check_is_not_carried_and_the_write_refuses() {
let tmp = tempfile::TempDir::new().unwrap();
let mut engine = self_check_gated_engine(&tmp, "x-projection");
engine.set_identity(Some("author-a".to_string()));
let id = create_plan(&mut engine, "The Bundle");
check_plan(&mut engine, "checker-c", &id, "x-projection");
engine.set_identity(Some("author-a".to_string()));
append_body(&mut engine, &id);
let before = CheckLedger::for_workspace(tmp.path()).all().len();
let err = set_status(&mut engine, &id, "complete").unwrap_err();
assert_eq!(err.code(), "CONSTRAINT_UNSATISFIED");
assert!(err.to_string().contains("check_stale"), "{err}");
assert_eq!(CheckLedger::for_workspace(tmp.path()).all().len(), before);
assert_ne!(
engine
.get_entity(&id)
.unwrap()
.metadata
.get("status")
.map(|v| v.to_frontmatter_string())
.as_deref(),
Some("complete"),
"the refused write left the entity as it was"
);
}
#[test]
fn check_refuses_read_only_mounts_typed() {
let tmp = tempfile::TempDir::new().unwrap();
let mut mount = crate::engine::test_helpers::folder_mount("ro", tmp.path().to_path_buf());
mount.capability = MountCapability::ReadOnly;
let mut engine = crate::Engine::from_mounts(vec![(
mount,
Box::new(crate::storage::FilesystemBackend::new(
tmp.path().to_path_buf(),
)) as Box<dyn crate::backend::MemBackend>,
)])
.unwrap();
let err = engine
.record_check(
"ro",
"ro--anything",
Verdict::Ok,
crate::check::CheckKind::Verification,
None,
Actor::Cli,
None,
)
.unwrap_err();
assert_eq!(err.code(), "READ_ONLY_MOUNT");
}
}