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_conformance;
9#[cfg(test)]
10mod a2a_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 artifact_supply;
18pub mod bindings;
19pub(crate) mod cancel;
20pub(crate) mod cgroup;
21pub mod child_launch;
22pub(crate) mod compiled_forms;
23pub mod containment;
24pub(crate) mod control_plane;
25pub(crate) mod conversation;
26pub(crate) mod conversation_import;
27pub mod delegation;
28pub mod delegation_plane;
29pub mod detached;
30pub(crate) mod detached_reconcile;
31pub mod door_auth;
32pub(crate) mod driver_choice;
33// Public so the `runtime_out!` / `runtime_err!` macros resolve `$crate::diagnostic` from outside
34// this crate, and so `mur run`'s launch path writes its lines the same way the runtime does.
35pub(crate) mod credential_gateway;
36pub mod diagnostic;
37pub(crate) mod dns_resolver;
38pub(crate) mod egress_proxy;
39pub mod errors;
40pub(crate) mod fence;
41pub mod formation;
42pub mod formation_credentials;
43pub mod formation_launch;
44pub(crate) mod gateway_credential;
45pub(crate) mod harness_session;
46pub(crate) mod hooks;
47pub mod host_warnings;
48pub(crate) mod http_client;
49pub(crate) mod identity;
50pub(crate) mod inference_import;
51pub(crate) mod install_grant;
52pub mod lanes;
53pub mod lifeline;
54pub mod limits;
55pub mod mac_token;
56pub(crate) mod member_call;
57pub mod murmur_home;
58pub(crate) mod murmur_md;
59pub mod network_namespace;
60pub(crate) mod network_policy;
61pub mod origin;
62pub(crate) mod otel;
63pub(crate) mod outgoing;
64pub mod peer_handoff;
65pub(crate) mod peer_tasks;
66#[cfg(test)]
67mod pinned_port;
68pub mod plan;
69pub mod precompile;
70pub mod process_driver;
71pub(crate) mod protected_paths;
72pub(crate) mod reachability;
73pub(crate) mod recipes;
74pub mod records_dir;
75pub mod registration;
76pub(crate) mod required_fields;
77pub mod resource_plane;
78pub mod resources;
79pub mod retention;
80pub mod roster;
81pub mod running;
82pub mod runtime;
83pub mod runtime_dir;
84pub(crate) mod sandbox;
85pub mod sealed;
86pub mod security;
87pub(crate) mod shell;
88#[cfg(test)]
89mod source_scan;
90pub mod spawn_credential;
91pub mod spawn_envelope;
92pub(crate) mod spend;
93pub mod staged_runtime;
94pub mod state_store;
95pub(crate) mod stream_events;
96pub(crate) mod streaming;
97pub(crate) mod task_io_import;
98pub(crate) mod tokens_import;
99pub(crate) mod tool_annotations;
100pub(crate) mod tool_call_progress;
101pub mod tool_names;
102pub(crate) mod trace;
103pub(crate) mod trace_blobs;
104pub mod types;
105pub(crate) mod wit_versions;
106pub mod workdir_fs;
107pub mod workdir_writes;
108
109pub use artifact_config::{
110    configured_artifact_names, lower_artifact_config, ARTIFACT_CONFIG_ENV,
111    MAX_ARTIFACT_CONFIG_BYTES,
112};
113pub use artifact_supply::{SourceSupply, SourcedArtifact};
114pub use containment::{
115    applied_mechanism, check_containment_floor, containment_shortfall_reason,
116    detect_achieved_containment, detect_sealed_blocker, detect_userns_grant, doctor_runtime_dir,
117    explain_scope, install_from_places, read_only_advisory_for, render_install, render_read_only,
118    render_records_dir, render_runtime_dir, resolve_runtime_dir_reach, resolve_runtime_dir_reaches,
119    DoctorDirReports, ExportsFilesReport, FilesystemBoundaryReport, FilesystemRestriction,
120    PreopenReport, PreopenSurface, RuntimeDirReach, RuntimeDirReport, ScopeReport, ShortfallCause,
121    StateStoreReport,
122};
123pub use diagnostic::{diagnostic_workdir, set_diagnostic_workdir, Emitted};
124pub use murmur_home::{usable_murmur_home, HomeUnusable, HOME_UNUSABLE_HINT};
125pub use network_namespace::{
126    check_egress_namespace, detect_egress_namespace_blocker, skip_without_egress_namespace,
127    EgressNamespaceBlocker,
128};
129pub use records_dir::{
130    records_dir_root, records_group, records_group_under, RecordsDir, HOOKS_SUBDIR,
131    RECORDS_DIR_ENV, RECORDS_DIR_NAME,
132};
133pub use runtime_dir::{
134    runtime_dir_inside_warning, runtime_dir_placement, RuntimeDirPlacement, RUNTIME_DIR_ENV,
135    RUNTIME_DIR_GUEST_PATH,
136};
137// `network_policy` is a private module; `preopen_reports` is re-exported because `mur run
138// --explain-scope` and `mur doctor` both resolve the preopen set the same way `stage_session`
139// does, and one resolver shared by all three is what keeps the report a description of the launch.
140pub use network_policy::preopen_reports;
141// `sandbox` is a private module; `HostProbe` is re-exported because the freshness of a session's
142// host reading is asserted from integration tests outside this crate. `find_on_path` is re-exported
143// so a caller outside this crate resolves a binary name the way the shell allowlist and the
144// invoked-binary report already resolve one, rather than open-coding the `PATH` walk again.
145pub use sandbox::{detect_landlock_abi, find_on_path, landlock_doctor_lines, HostProbe};
146pub use sealed::{
147    classify_installed_profile, classify_profile_attachment, inspect_installed_profile,
148    inspect_profile_attachment, InstalledProfileState, ProfileAttachment, SealedBlocker,
149    UsernsGrant, SEALED_APPARMOR_ATTACHMENT_PATHS, SEALED_APPARMOR_PROFILE_PATH,
150    SEALED_APPARMOR_PROFILE_SHA256,
151};
152pub use streaming::STREAM_EXTENSION_URI;
153// `cgroup` is a private module, but the entry points below are consumed from `murmur-cli` — the
154// three test-support probes from its integration tests, the `io.max` reporting from
155// `mur run --explain-scope` and the swap-bound reporting from `mur doctor`, each of which has to
156// answer the question a launch does without staging a session. Re-exported here rather than
157// duplicating a probe once per crate that needs it.
158pub use cgroup::{
159    active_swap_areas, cgroup_delegation_available, io_max_device_available, probe_io_max,
160    probe_swap_control, requires_process_bounding, skip_without_host_support, IoMaxReport,
161    IoMaxStatus, SwapControl, SCOPE_SWAP_MAX,
162};
163// The door's protocol version and error tables: every client of a door sends the header pair,
164// and names the error it is answered with through `A2aError::from_code`.
165pub use a2a::{
166    murmur_state_name, A2aError, MurmurError, A2A_EXTENSIONS_HEADER, A2A_PROTOCOL_VERSION,
167    A2A_VERSION_HEADER,
168};
169pub use child_launch::{
170    child_workdir_for, format_workdir_identity, launch_child_capsule, parse_workdir_identity,
171    ChildLaunchRequest, LaunchedChild, MUR_BINARY_ENV, READINESS_TOKENS_FLAG,
172    WORKDIR_IDENTITY_FLAG,
173};
174// The delegation types and constants stay module-qualified beyond these: `Spawner` and
175// `SpawnerHandle` are what a caller of `launch_child_capsule` composes, and the rest of the
176// module — the outcome, the file, the two headers — is read by name from `delegation::`.
177pub use delegation::{CompletionAddress, Spawner, SpawnerHandle};
178// The delegating side's own types. `DelegationPlane` is built by `launch_session` and reached
179// only through the `delegate-task` dispatch branch, so what leaves this crate is the vocabulary a
180// reader of a trace or a tool result needs, plus the bound and its override.
181pub use delegation_plane::{
182    DelegationLaunch, DelegationOrigin, DelegationPlane, DelegationRequest, DelegationResult,
183    StartedDelegation, DELEGATION_RESULT_TIMEOUT, DELEGATION_TIMEOUT_ENV,
184};
185// `reachability` is a private module, but both of its entry points are consumed from
186// `murmur-cli`'s `mur doctor` as well as from `stage_session`, so they are re-exported here — the
187// same facade shape `check_staged_runtime_floor` has, without making the module's internals
188// (`shebang_interpreter_name`, the probe, the prefix helpers) part of any crate's API.
189pub use door_auth::{
190    bearer_header, door_posture, is_loopback_bind, public_door_bind_warning, public_door_warning,
191    render_public_door_warning, AuthRefusal, DoorAuth, DoorExposure, DoorGrant, DoorToken,
192    PublicDoorDisclosure, DOOR_TOKEN_ENV,
193};
194pub use errors::{RuntimeError, UnreachableEntrypoint};
195pub use formation::{FormationId, FormationPeer, FormationPeers};
196pub use formation_credentials::{
197    FormationAuthority, FormationBundle, FormationMember, FormationToken, FormationVerifier,
198    FormationVerifyKey, FORMATION_CALL_SCOPES, FORMATION_CHANNEL_ENV,
199};
200pub use host_warnings::{
201    host_warnings_reported, host_warnings_reported_in, HOST_WARNINGS_REPORTED_ENV,
202};
203pub use lanes::TaskLane;
204#[cfg(unix)]
205pub use lifeline::{ChildLifeline, FormationLifeline, MemberLifeline, SpawnerLifeline};
206pub use lifeline::{FORMATION_LIFELINE_ENV, SPAWNER_LIFELINE_ENV};
207pub use limits::ExecutionLimits;
208pub use murmur_artifact::{AfterTask, LifecycleConfig, LifecycleOverride, TaskAcceptance};
209// The types and header names are flat; `origin::from_wire` and `origin::stamp_for_peer` stay
210// module-qualified, because their bare names say nothing about tasks.
211pub use origin::{TaskOrigin, TaskProvenance, TrustClass, PEER_ORIGIN_HEADER, PEER_TRUST_HEADER};
212pub use peer_handoff::{
213    audience_from_card, handle_id, handle_peer_request, is_peer_path, mint, stored_path_for,
214    verify, HandleError, HandlePayload, MintedHandle, PeerError, PeerMintKey, PeerPlane,
215    AUDIENCE_HEADER, HANDLE_ID_HEADER, PEER_INBOX_DIR, PEER_PATH_PREFIX,
216};
217pub use reachability::{
218    check_interpreted_entrypoints_reachable, warn_on_unreachable_toolchain_helpers,
219    ToolchainHelperReport, ToolchainHelperWarning, UnprobedToolchainDriver,
220};
221pub use registration::{check_roost_health, deregister_session, register_session, SessionOutcome};
222pub use resource_plane::{
223    check_export_root, check_peer_files_root, handle_resource_request, reason_phrase,
224    symlink_policy, DeclaredExport, ListEntry, ListResponse, ReadResponse, ResourceError,
225    ResourcePlane, ResourceResponse, SymlinkPolicy, RESOURCE_PATH_PREFIX,
226};
227pub use resources::HostResourceLimits;
228// `retention` is its own public module rather than a set of flat re-exports: `mur conversation`
229// consumes six of its entry points and four of its types, and a facade that wide is a second
230// place for the names to drift.
231pub use retention::{
232    list_records, locate_message, prune_records, prune_sessions, remove_record, truncate_record,
233    MessageLocation, MessageStatus, PrunedRecord, PrunedSession, RecordHeader, RecordSummary,
234    RemovedRecord, TruncationMarker, TruncationOutcome,
235};
236pub use roster::{
237    admit_roster, admit_roster_file, caller_overflow_fix, caller_overflow_warning, AdmittedMember,
238    AdmittedRoster, CallerOverflow, RosterEdge, RosterRefusal,
239};
240// The running-capsule vocabulary a reader of a record needs. The verbs stay module-qualified —
241// `running::list`, `running::verify`, `running::prune`, `running::running_dir` — on the same terms
242// as `origin::from_wire`: their bare names say nothing about capsules.
243pub use running::{Liveness, ProcessState, RunningGuard, RunningRecord, SignalOutcome};
244pub use runtime::{
245    check_env_allow_reaches_guests, check_no_reserved_tool_names, has_subprocess_route_at_staging,
246    launch_session, launch_session_handling_sigterm, secret_shaped_env_grants, stage_session,
247    stripped_env_allow_entries, undeclarable_runtime_pin_role,
248    warn_on_gateway_endpoint_in_network_allow, warn_on_interpreter_runtime_grants,
249    warn_on_launch_only_gateway_credential, warn_on_secret_shaped_env_grants,
250    warn_on_unmetered_gateways, warn_on_userns_restriction_disabled_host_wide,
251    warn_on_workdir_exec, SecretShapedEnvGrant, StrippedEnvAllowEntry,
252};
253// The one question about a variable name a caller outside the runtime needs answered: would the
254// credential backstop drop it, and by which pattern. `shell` is otherwise crate-private, and these
255// are what `secret_shaped_env_grants` and `check_env_allow_reaches_guests` judge a
256// `capabilities.env.allow` entry with.
257pub use shell::{
258    credential_backstop_drops, credential_backstop_match, BackstopMatch, BackstopPatternSource,
259};
260pub use spawn_credential::{
261    SpawnApproval, SpawnCredential, SPAWN_APPROVAL_HEADER, SPAWN_CREDENTIAL_HEADER,
262};
263pub use spawn_envelope::{EnvelopeAxis, EnvelopeViolation, SpawnEnvelope};
264pub use staged_runtime::check_staged_runtime_floor;
265pub use state_store::{
266    ensure_state_store, state_store_reports, validate_store_name, STATE_PREOPEN_NAME,
267};
268pub use trace::{PlanTraceAppender, ResourceTraceAppender};
269pub use types::{
270    capability_policy_from_runtime_manifest, ArtifactRequest, CapabilityPolicy,
271    InstalledArtifactSummary, LaunchEnding, LaunchResult, LockExpectation, ResolvedLockArtifact,
272    ResumeMode, ResumeRequest, StageRequest, StagedSession,
273};
274// The one way the runtime touches a path inside a capsule's workdir, and what it reports when a
275// link there is refused.
276pub use workdir_fs::{
277    EntryKind, RefusalReason, WorkdirError, WorkdirOperation, WorkdirRefusal, WorkdirRoot,
278};
279// The declaration `--explain-scope` prints and `trace.jsonl` carries as
280// `session_start.effective_grants.runtime_writes`. Flat, on the same terms as the other report
281// types: a consumer of a scope report reads these names off it.
282pub use workdir_writes::{
283    render_runtime_writes, RuntimeWriteCondition, RuntimeWriteKind, RuntimeWriteReport,
284    RuntimeWriteScope, SESSION_ID_PLACEHOLDER,
285};
286// The served version of each `murmur:*` package, and the WIT levels: the committed, numbered sets
287// of those versions, the newest of which is the one this host serves.
288pub use wit_versions::{served_wit_level, wit_levels, SERVED_WIT_PACKAGES, WIT_LEVELS_FILE};