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