Skip to main content

capsule_runtime/
lib.rs

1// `security::harden_process_dumpable` needs one `unsafe { libc::prctl(...) }` call on Linux;
2// `#[allow(unsafe_code)]` on that item overrides this crate-level default of `deny` rather
3// than `forbid`, since `forbid` cannot be overridden by a narrower `allow` anywhere in the crate.
4#![deny(unsafe_code)]
5
6pub(crate) mod a2a;
7#[cfg(test)]
8mod a2a_card_conformance;
9#[cfg(test)]
10mod a2a_card_conformance_tests;
11pub(crate) mod agent;
12#[cfg(feature = "alloc-bench")]
13pub mod alloc_bench;
14pub mod artifact;
15pub mod artifact_config;
16pub(crate) mod artifact_removal;
17pub mod bindings;
18pub(crate) mod cancel;
19pub(crate) mod cgroup;
20pub mod child_launch;
21pub(crate) mod compiled_forms;
22pub mod containment;
23pub(crate) mod control_plane;
24pub(crate) mod conversation;
25pub(crate) mod conversation_import;
26pub mod delegation;
27pub mod delegation_plane;
28pub mod detached;
29pub(crate) mod detached_reconcile;
30pub mod door_auth;
31pub(crate) mod driver_choice;
32// Public so the `runtime_out!` / `runtime_err!` macros resolve `$crate::diagnostic` from outside
33// this crate, and so `mur run`'s launch path writes its lines the same way the runtime does.
34pub(crate) mod credential_gateway;
35pub mod diagnostic;
36pub(crate) mod dns_resolver;
37pub(crate) mod egress_proxy;
38pub mod errors;
39pub(crate) mod fence;
40pub(crate) mod gateway_credential;
41pub(crate) mod harness_session;
42pub(crate) mod hooks;
43pub(crate) mod http_client;
44pub(crate) mod identity;
45pub(crate) mod inference_import;
46pub(crate) mod install_grant;
47pub mod lanes;
48pub mod limits;
49pub mod mac_token;
50pub mod murmur_home;
51pub(crate) mod murmur_md;
52pub mod network_namespace;
53pub(crate) mod network_policy;
54pub mod origin;
55pub(crate) mod otel;
56pub(crate) mod outgoing;
57pub mod peer_handoff;
58pub mod plan;
59pub mod precompile;
60pub mod process_driver;
61pub(crate) mod protected_paths;
62pub(crate) mod reachability;
63pub(crate) mod recipes;
64pub mod registration;
65pub mod resource_plane;
66pub mod resources;
67pub mod retention;
68pub mod running;
69pub mod runtime;
70pub(crate) mod sandbox;
71pub mod sealed;
72pub mod security;
73pub(crate) mod shell;
74pub mod spawn_credential;
75pub mod spawn_envelope;
76pub(crate) mod spend;
77pub mod staged_runtime;
78pub mod state_store;
79pub(crate) mod streaming;
80pub(crate) mod task_io_import;
81pub(crate) mod tokens_import;
82pub(crate) mod tool_annotations;
83pub(crate) mod trace;
84pub(crate) mod trace_blobs;
85pub mod types;
86pub mod workdir_writes;
87
88pub use artifact_config::{
89    configured_artifact_names, lower_artifact_config, ARTIFACT_CONFIG_ENV,
90    MAX_ARTIFACT_CONFIG_BYTES,
91};
92pub use containment::{
93    check_containment_floor, containment_shortfall_reason, detect_achieved_containment,
94    detect_sealed_blocker, detect_userns_grant, explain_scope, read_only_advisory_for,
95    render_install, render_read_only, ExportsFilesReport, FilesystemBoundaryReport,
96    FilesystemRestriction, PreopenReport, PreopenSurface, ScopeReport, StateStoreReport,
97};
98pub use diagnostic::{diagnostic_workdir, set_diagnostic_workdir, Emitted};
99pub use network_namespace::{
100    check_egress_namespace, detect_egress_namespace_blocker, skip_without_egress_namespace,
101    EgressNamespaceBlocker,
102};
103// `network_policy` is a private module; `preopen_reports` is re-exported because `mur run
104// --explain-scope` and `mur doctor` both resolve the preopen set the same way `stage_session`
105// does, and one resolver shared by all three is what keeps the report a description of the launch.
106pub use network_policy::preopen_reports;
107// `sandbox` is a private module; `HostProbe` is re-exported because the freshness of a session's
108// host reading is asserted from integration tests outside this crate. `find_on_path` is re-exported
109// so a caller outside this crate resolves a binary name the way the shell allowlist and the
110// invoked-binary report already resolve one, rather than open-coding the `PATH` walk again.
111pub use sandbox::{find_on_path, HostProbe};
112pub use sealed::{
113    classify_installed_profile, classify_profile_attachment, inspect_installed_profile,
114    inspect_profile_attachment, InstalledProfileState, ProfileAttachment, SealedBlocker,
115    UsernsGrant, SEALED_APPARMOR_ATTACHMENT_PATHS, SEALED_APPARMOR_PROFILE_PATH,
116    SEALED_APPARMOR_PROFILE_SHA256,
117};
118// `cgroup` is a private module, but the entry points below are consumed from `murmur-cli` — the
119// three test-support probes from its integration tests, and the `io.max` reporting from
120// `mur run --explain-scope`, which has to answer the same question a launch does without staging
121// a session. Re-exported here rather than duplicating either probe once per crate that needs it.
122pub use cgroup::{
123    cgroup_delegation_available, io_max_device_available, probe_io_max, requires_process_bounding,
124    skip_without_host_support, IoMaxReport, IoMaxStatus,
125};
126pub use child_launch::{
127    child_workdir_for, launch_child_capsule, ChildLaunchRequest, LaunchedChild, MUR_BINARY_ENV,
128};
129// The delegation types and constants stay module-qualified beyond these: `Spawner` and
130// `SpawnerHandle` are what a caller of `launch_child_capsule` composes, and the rest of the
131// module — the outcome, the file, the two headers — is read by name from `delegation::`.
132pub use delegation::{CompletionAddress, Spawner, SpawnerHandle};
133// The delegating side's own types. `DelegationPlane` is built by `launch_session` and reached
134// only through the `delegate-task` dispatch branch, so what leaves this crate is the vocabulary a
135// reader of a trace or a tool result needs, plus the bound and its override.
136pub use delegation_plane::{
137    DelegationLaunch, DelegationOrigin, DelegationPlane, DelegationRequest, DelegationResult,
138    DELEGATION_RESULT_TIMEOUT, DELEGATION_TIMEOUT_ENV,
139};
140// `reachability` is a private module, but both of its entry points are consumed from
141// `murmur-cli`'s `mur doctor` as well as from `stage_session`, so they are re-exported here — the
142// same facade shape `check_staged_runtime_floor` has, without making the module's internals
143// (`shebang_interpreter_name`, the probe, the prefix helpers) part of any crate's API.
144pub use door_auth::{
145    bearer_header, door_posture, is_loopback_bind, public_door_bind_warning, public_door_warning,
146    render_public_door_warning, AuthRefusal, DoorAuth, DoorExposure, DoorGrant, DoorToken,
147    PublicDoorDisclosure, DOOR_TOKEN_ENV,
148};
149pub use errors::{RuntimeError, UnreachableEntrypoint};
150pub use lanes::TaskLane;
151pub use limits::ExecutionLimits;
152pub use murmur_artifact::{AfterTask, LifecycleConfig, LifecycleOverride, TaskAcceptance};
153// The types and header names are flat; `origin::from_wire` and `origin::stamp_for_peer` stay
154// module-qualified, because their bare names say nothing about tasks.
155pub use origin::{TaskOrigin, TaskProvenance, TrustClass, PEER_ORIGIN_HEADER, PEER_TRUST_HEADER};
156pub use peer_handoff::{
157    audience_from_card, handle_id, handle_peer_request, is_peer_path, mint, stored_path_for,
158    verify, HandleError, HandlePayload, MintedHandle, PeerError, PeerMintKey, PeerPlane,
159    AUDIENCE_HEADER, HANDLE_ID_HEADER, PEER_INBOX_DIR, PEER_PATH_PREFIX,
160};
161pub use reachability::{
162    check_interpreted_entrypoints_reachable, warn_on_unreachable_toolchain_helpers,
163    ToolchainHelperReport, ToolchainHelperWarning, UnprobedToolchainDriver,
164};
165pub use registration::{check_roost_health, deregister_session, register_session, SessionOutcome};
166pub use resource_plane::{
167    check_export_root, check_peer_files_root, handle_resource_request, reason_phrase,
168    symlink_policy, DeclaredExport, ListEntry, ListResponse, ReadResponse, ResourceError,
169    ResourcePlane, ResourceResponse, SymlinkPolicy, RESOURCE_PATH_PREFIX,
170};
171pub use resources::HostResourceLimits;
172// `retention` is its own public module rather than a set of flat re-exports: `mur conversation`
173// consumes six of its entry points and four of its types, and a facade that wide is a second
174// place for the names to drift.
175pub use retention::{
176    list_records, locate_message, prune_records, prune_sessions, remove_record, truncate_record,
177    MessageLocation, MessageStatus, PrunedRecord, PrunedSession, RecordHeader, RecordSummary,
178    RemovedRecord, TruncationMarker, TruncationOutcome,
179};
180// The running-capsule vocabulary a reader of a record needs. The verbs stay module-qualified —
181// `running::list`, `running::verify`, `running::prune`, `running::running_dir` — on the same terms
182// as `origin::from_wire`: their bare names say nothing about capsules.
183pub use running::{Liveness, ProcessState, RunningGuard, RunningRecord, SignalOutcome};
184pub use runtime::{
185    check_env_allow_reaches_guests, check_no_reserved_tool_names, launch_session,
186    launch_session_handling_sigterm, secret_shaped_env_grants, stage_session,
187    stripped_env_allow_entries, undeclarable_runtime_pin_role,
188    warn_on_gateway_endpoint_in_network_allow, warn_on_interpreter_runtime_grants,
189    warn_on_launch_only_gateway_credential, warn_on_secret_shaped_env_grants,
190    warn_on_unmetered_gateways, warn_on_userns_restriction_disabled_host_wide,
191    warn_on_workdir_exec, SecretShapedEnvGrant, StrippedEnvAllowEntry,
192};
193// The one question about a variable name a caller outside the runtime needs answered: would the
194// credential backstop drop it, and by which pattern. `shell` is otherwise crate-private, and these
195// are what `secret_shaped_env_grants` and `check_env_allow_reaches_guests` judge a
196// `capabilities.env.allow` entry with.
197pub use shell::{
198    credential_backstop_drops, credential_backstop_match, BackstopMatch, BackstopPatternSource,
199};
200pub use spawn_credential::{
201    SpawnApproval, SpawnCredential, SPAWN_APPROVAL_HEADER, SPAWN_CREDENTIAL_HEADER,
202};
203pub use spawn_envelope::{EnvelopeAxis, EnvelopeViolation, SpawnEnvelope};
204pub use staged_runtime::check_staged_runtime_floor;
205pub use state_store::{
206    ensure_state_store, state_store_reports, validate_store_name, STATE_PREOPEN_NAME,
207};
208pub use trace::{PlanTraceAppender, ResourceTraceAppender};
209pub use types::{
210    capability_policy_from_runtime_manifest, ArtifactRequest, CapabilityPolicy,
211    InstalledArtifactSummary, LaunchResult, LockExpectation, ResolvedLockArtifact, ResumeMode,
212    ResumeRequest, StageRequest, StagedSession,
213};
214// The declaration `--explain-scope` prints and `trace.jsonl` carries as
215// `session_start.effective_grants.runtime_writes`. Flat, on the same terms as the other report
216// types: a consumer of a scope report reads these names off it.
217pub use workdir_writes::{
218    render_runtime_writes, RuntimeWriteCondition, RuntimeWriteKind, RuntimeWriteReport,
219    RuntimeWriteScope, SESSION_ID_PLACEHOLDER,
220};