operations capa

operations-device-safety

Shared privileged-device-access substrate: stable device identity (never /dev/sdX), per-device locks, TOCTOU revalidation immediately before destructive ops, policy-gated actuation

Shared privileged-device-access substrate: stable device identity (never /dev/sdX), per-device locks, TOCTOU revalidation immediately before destructive ops, policy-gated actuation

Tieroperations
Roleunclassified (baselined)
Pathcrates/operations/device-safety
Edition2021
Targetsoperations_device_safety
Public items30 across 0 modules
Tests24

What it is for

operations-device-safety — shared privileged-device-access substrate.

The hardware, block-imaging, drive-sanitize, and boot-media library crates all compose this so none of them re-implements device identity, locking, TOCTOU safety, or destructive-op policy. Its central invariant (Gate-1.5 consensus) is wrong-device rejection: a destructive operation bound to a DeviceId must re-check that the device at its path STILL matches that identity immediately before execution, or the operation is refused — defeating the TOCTOU window where a /dev/sdX name re-points to a different disk.

Testability

Device identity is resolved through the DeviceResolver seam; unit tests drive it with a fixture so the safety logic is proven without touching real hardware.

Capabilities

crate root

operations-device-safety — shared privileged-device-access substrate.

Item
fn carries_critical_mount(device : & str, proc_mounts : & str) -> bool
fn usb_attached(udev_properties : & str) -> bool
fn permit_destructive_target(path : & str, udev_properties : & str, proc_mounts : & str, allowlist : & TargetAllowlist,) -> Result <(), DeviceSafetyError>
fn revalidate <R : DeviceResolver>(expected : & DeviceId, path : & str, resolver : & R,) -> Result <(), DeviceSafetyError>
fn actuate <A : Actuator>(policy : & WritePolicy, path : & str, value : & u8, actuator : & mut A,) -> Result <(), DeviceSafetyError>

Actuator

operations-device-safety — shared privileged-device-access substrate.

Item
pub trait Actuator

CommandEvidence

operations-device-safety — shared privileged-device-access substrate.

Item
pub struct CommandEvidence
fn evidence_for(path : & str, value : & u8, sensitive : bool) -> CommandEvidence

DeviceId

operations-device-safety — shared privileged-device-access substrate.

Item
pub struct DeviceId
DeviceId :: fn from_wwn(wwn : impl Into <String>) -> Self
DeviceId :: fn from_usb_serial(serial : impl Into <String>) -> Self
DeviceId :: fn kind(& self) -> IdentityKind
DeviceId :: fn value(& self) -> & str
DeviceId :: fn wwn(& self) -> Option <& str>
DeviceId :: fn from_udev_properties(properties : & str) -> Result <Self, DeviceSafetyError>

DeviceLockGuard

operations-device-safety — shared privileged-device-access substrate.

Item
pub struct DeviceLockGuard<'a>

DeviceLockGuard<'_>

operations-device-safety — shared privileged-device-access substrate.

Item
DeviceLockGuard<'_> :: fn drop(& mut self)

DeviceLocks

operations-device-safety — shared privileged-device-access substrate.

Item
pub struct DeviceLocks
DeviceLocks :: fn new() -> Self
DeviceLocks :: fn acquire(& self, id : & DeviceId) -> Result <DeviceLockGuard <'_>, DeviceSafetyError>

DeviceResolver

operations-device-safety — shared privileged-device-access substrate.

Item
pub trait DeviceResolver

DeviceSafetyError

operations-device-safety — shared privileged-device-access substrate.

Item
pub enum DeviceSafetyError

IdentityKind

operations-device-safety — shared privileged-device-access substrate.

Item
pub enum IdentityKind

TargetAllowlist

operations-device-safety — shared privileged-device-access substrate.

Item
pub struct TargetAllowlist
TargetAllowlist :: fn for_case(devices : impl IntoIterator <Item = DeviceId>) -> Self
TargetAllowlist :: fn permits(& self, device : & DeviceId) -> bool

WritePolicy

operations-device-safety — shared privileged-device-access substrate.

Item
pub struct WritePolicy
WritePolicy :: fn deny_all() -> Self
WritePolicy :: fn allow_prefix(mut self, prefix : impl Into <String>) -> Self
WritePolicy :: fn permits(& self, path : & str) -> bool

How to use it

No examples/ target and no doctest in this crate's rustdoc. The tests listed under Verification are the closest executable usage.

Module structure

No public modules: the crate root is its whole surface.

Public surface

`crate root`

ItemWhat it is
pub enum IdentityKindWhich namespace a DeviceId's value was drawn from
pub struct DeviceIdA stable device identity — bound to the physical device, NOT a racy /dev/sdX name
DeviceId :: fn from_wwn(wwn : impl Into <String>) -> SelfConstruct from a World Wide Name (the stable storage identifier).
DeviceId :: fn from_usb_serial(serial : impl Into <String>) -> SelfConstruct from a USB bridge's reported serial, for devices that expose no WWN.
DeviceId :: fn kind(& self) -> IdentityKindWhich namespace this identity came from.
DeviceId :: fn value(& self) -> & strThe identifying value, without its namespace
DeviceId :: fn wwn(& self) -> Option <& str>The underlying WWN, when this identity is one.
DeviceId :: fn from_udev_properties(properties : & str) -> Result <Self, DeviceSafetyError>Resolve an identity from udevadm info --query=property output
pub trait DeviceResolverResolves the CURRENT identity of the device at a path — the seam a caller uses to re-check identity immediately before a destructive op
pub enum DeviceSafetyErrorErrors from the device-safety substrate.
fn carries_critical_mount(device : & str, proc_mounts : & str) -> boolWhether device (a disk or one of its partitions) carries a mount the running system depends on, given the contents of /proc/mounts
fn usb_attached(udev_properties : & str) -> boolWhether udev reports this device as USB-attached
pub struct TargetAllowlistThe devices an engagement is allowed to write to, named one by one
TargetAllowlist :: fn for_case(devices : impl IntoIterator <Item = DeviceId>) -> SelfThe devices this engagement may write to
TargetAllowlist :: fn permits(& self, device : & DeviceId) -> boolWhether device was named for this engagement.
fn permit_destructive_target(path : & str, udev_properties : & str, proc_mounts : & str, allowlist : & TargetAllowlist,) -> Result <(), DeviceSafetyError>The gate every destructive target passes, or does not
fn revalidate <R : DeviceResolver>(expected : & DeviceId, path : & str, resolver : & R,) -> Result <(), DeviceSafetyError>Re-check that the device at path STILL matches expected, immediately before a destructive operation
pub struct WritePolicyGoverns what the Actuator may write
WritePolicy :: fn deny_all() -> SelfA policy that permits nothing — the safe default.
WritePolicy :: fn allow_prefix(mut self, prefix : impl Into <String>) -> SelfPermit writes whose path starts with prefix.
WritePolicy :: fn permits(& self, path : & str) -> boolWhether path is permitted by this policy.
pub trait ActuatorSeam that performs the actual privileged write
fn actuate <A : Actuator>(policy : & WritePolicy, path : & str, value : & u8, actuator : & mut A,) -> Result <(), DeviceSafetyError>Perform a policy-gated write
pub struct DeviceLocksPer-device exclusive locks
DeviceLocks :: fn new() -> SelfA new, empty lock registry.
DeviceLocks :: fn acquire(& self, id : & DeviceId) -> Result <DeviceLockGuard <'_>, DeviceSafetyError>Acquire an exclusive lock on id
pub struct DeviceLockGuard<'a>Releases its device lock when dropped.
DeviceLockGuard<'_> :: fn drop(& mut self)
pub struct CommandEvidenceStructured, audit-safe record of a device operation
fn evidence_for(path : & str, value : & u8, sensitive : bool) -> CommandEvidenceBuild audit evidence for a write

No pub use re-exports: every item above is declared in this crate.

Boundary

Depends on no other workspace tier.

Shares tier operations with 40 other crates: operations-approval-workflow, operations-assessments, operations-block-imaging, operations-boot-media, operations-browser-agent-worker, operations-camera-discovery, operations-camera-liveview, operations-camera-registry, … (40 total).

_What this crate deliberately does NOT own is a judgment. No committed registry records one for it, so none is stated here._

Where it sits

Tier (ontology)operations
Architectural role (taxonomy)unclassified (baselined)
Locationcrates/operations/device-safety
Vocabulary in force (lexicon)current

Dependencies

Runtime, from outside the workspace.

CrateRequirementFeaturesOptionalOnly on
serde^1derivenoalways
thiserror^2noalways

Development. None.

Build. None.

Depended on by. 3 workspace crates.

Signal flow — what reaches this crate, and what it reaches.

flowchart LR
  n_operations_block_imaging["operations-block-imaging"] -->|uses| SELF
  n_operations_boot_media["operations-boot-media"] -->|uses| SELF
  n_tools_ir_triage["tools-ir-triage"] -->|uses| SELF
  SELF["operations-device-safety"]
  classDef self fill:#1f883d,stroke:#1f883d,color:#fff;
  class SELF self;

Feature flags

No Cargo features are defined: every capability is unconditional, so no consumer can receive a half-wired crate.

Targets

KindNameSource
liboperations_device_safety`src/lib.rs`

Error model

Error typeNamed by
DeviceSafetyErroractuate, permit_destructive_target, revalidate

Operational characteristics

PropertyEvidence
async public surfacenone detected
async runtimenone detected
database accessnone detected
network I/Onone detected
unsafe codenone detected
environment variablesnone detected

No unsafe block, unsafe fn, unsafe impl or unsafe trait was found by the parser anywhere in this crate's source.

Configuration

No environment variable is read with a literal name anywhere in this crate. A variable whose key is computed at run time cannot be listed here, and is not claimed to be absent.

3 workspace crates depend on this one: operations-block-imaging, operations-boot-media, tools-ir-triage.

Verification

KindCount
Unit tests24
Integration tests0
Examples0
Doctests0

Evidence by module. How often each public module is named by something executable.

ModuleTestsExamplesConsumers
crate root1608

What the tests establish, by name:

Documentation coverage

MeasureDocumentedTotal
Public items with rustdoc2930
Public modules with a //! block00
pie showData
    title Public items with rustdoc
    "Documented" : 29
    "No rustdoc detected" : 1

Metrics

MetricValue
Rust source files1
Source lines890
Code lines577
Public API items30
Public modules0
Tests24
Examples0
Cargo features0
Direct runtime dependencies2
Workspace reverse dependencies3
pie showData
    title Public API by kind
    "enum" : 2
    "function" : 6
    "method" : 14
    "struct" : 6
    "trait" : 2
pie showData
    title Rust source composition
    "Code" : 577
    "Blank or comment" : 313

Generation

Rendered by tools-corpus corpus readme from repository evidence alone, renderer schema 2, lexicon current. No model, network service or database was consulted. Regenerate with tools-corpus corpus readme --write; verify with --check.

Todas las operations · Manual