Skip to main content

Crate phi_cap

Crate phi_cap 

Source
Expand description

§phi-cap

Capability vocabulary for the phi family: one declaration language, one decision vocabulary.

Two layers, one refinement point:

CapabilitySpec (scoped declaration)  --class_of-->  Capability (coarse decision)
  fs:read{paths}            read_fs
  net:http{hosts}           net
  process:spawn{programs}   process
  device:input{targets}     device
  device:capture{targets}   device
  • Declaration layer — what a plugin manifest or capability pack writes. Scopes are mandatory; undeclared = not granted (fail-closed).
  • Decision layer — what Policy matches on. Coarse action-surface classes; never data semantics (a remote DB query is net, the same query on a local file is read_fs).

The only translation is class_of. New dimensions extend CapabilitySpec variants — never a third enum (iron rule 2).

Zero hard dependencies; enable serde for wire formats (plugin manifests). Wire tags keep the dotted face:scope names ("fs:read", "net:http", …).

O7 cross-class rule: a method carrying several capabilities resolves to the highest-risk class (`device > process > net > write_fs > read_fs

pure) — see [class_of_all`].

Structs§

DeviceCaptureSpec
Device capture face (device:capture): screenshots and friends.
DeviceInputSpec
Device input face (device:input): pointer / keyboard / touch injection.
FsReadSpec
Readable directories/files (resolved to absolute paths and pinned by the registry at install time — “whoever declares, pins”).
NetHttpSpec
Outbound HTTP host allow-list (normalized and pinned at install time).
ProcessSpawnSpec
Process spawn face (process:spawn).

Enums§

Capability
Coarse capability class — the decision key handed to Policy::allow.
CapabilitySpec
Capability allow-list entry — the declaration form (fail-closed: undeclared = not granted).
ResolvedCapability
A declaration with its scope resolved/pinned — the registry’s view.
ScopeKind
What kind of scope a declaration carries. The registry pins exactly this (“whoever declares, pins”): paths become absolute, hosts normalized, targets/programs kept as declared.

Functions§

class_of
The refinement: declaration → decision class (sdk-assembly §4.1).
class_of_all
Collapse a multi-capability method to one policy key (O7): take the highest-risk class — a method that both reads files and spawns processes is decided as process.
device_capture
device:capture{targets} — helper for declarations.
device_input
device:input{targets} — helper for declarations.
fs_read
fs:read{paths} — helper for declarations.
net_http
net:http{hosts} — helper for declarations.
process_spawn
process:spawn{} (unrestricted) — helper for declarations.
process_spawn_programs
process:spawn{programs} — helper for declarations.
resolve
Resolve a declaration into its pinned form — scope is preserved verbatim here; path/host pinning is the installer’s job (see agent-works resolve_capabilities, which this type set sinks from).
scope_kind
The scope kind a declaration carries.