pub struct RuntimeConfig { /* private fields */ }Expand description
Immutable runtime configuration shared by Rust and PyO3 callers.
Implementations§
Source§impl RuntimeConfig
impl RuntimeConfig
Sourcepub fn new(workspace_root: impl Into<PathBuf>) -> Self
pub fn new(workspace_root: impl Into<PathBuf>) -> Self
Construct a balanced runtime rooted at workspace_root.
Durable internal artifacts default to .vsh-runtime/data below the workspace;
that namespace is excluded from snapshots and denied to Monty.
Examples found in repository?
More examples
29fn main() -> Result<(), Box<dyn Error>> {
30 let workspace = Workspace::new()?;
31 fs::create_dir(workspace.0.join("templates"))?;
32 fs::write(
33 workspace.0.join("templates/service.toml"),
34 b"channel = \"dev\"\n",
35 )?;
36 let runtime = Runtime::open(RuntimeConfig::new(&workspace.0))?;
37 let code = include_str!("staged_release.monty");
38 let preview = runtime.preview(RunRequest::new(code).with_detail(ReceiptDetail::Full))?;
39 assert!(matches!(
40 preview.decision,
41 RuntimeDecision::PendingApproval(_)
42 ));
43 assert_eq!(preview.changed_paths, 3);
44 assert!(!workspace.0.join("release").exists());
45 assert_eq!(
46 preview
47 .changes
48 .iter()
49 .map(|entry| entry.path.as_str())
50 .collect::<Vec<_>>(),
51 ["release", "release/README.txt", "release/app.toml"]
52 );
53 let now = u64::try_from(SystemTime::now().duration_since(UNIX_EPOCH)?.as_millis())?;
54 // A rename is a semantic risk even if it only rearranges generated files.
55 // Production code must authenticate a reviewer before this trusted call.
56 runtime.approve(
57 preview.transaction,
58 PrincipalId::digest_label("fixture-reviewer"),
59 now,
60 now + 30_000,
61 )?;
62 let committed = runtime.commit(preview.transaction, now)?;
63 assert_eq!(committed.transaction, preview.transaction);
64 assert!(committed.commit.is_some());
65 assert_eq!(
66 fs::read_to_string(workspace.0.join("release/app.toml"))?,
67 "channel = \"stable\"\n"
68 );
69 assert_eq!(
70 fs::read_to_string(workspace.0.join("release/README.txt"))?,
71 "channel=stable\n"
72 );
73 assert!(!workspace.0.join("release/service.toml").exists());
74 println!(
75 "Committed {} reviewed paths: {}",
76 committed.changed_paths, committed.transaction
77 );
78 Ok(())
79}Sourcepub fn with_data_directory(self, data_directory: impl Into<PathBuf>) -> Self
pub fn with_data_directory(self, data_directory: impl Into<PathBuf>) -> Self
Place immutable blobs in an explicit trusted data directory.
Sourcepub fn with_worker_path(self, worker_path: impl Into<PathBuf>) -> Self
pub fn with_worker_path(self, worker_path: impl Into<PathBuf>) -> Self
Select the exact supervised Monty worker executable used for hostile code.
Sourcepub const fn with_max_idle_workers(self, max_idle_workers: usize) -> Self
pub const fn with_max_idle_workers(self, max_idle_workers: usize) -> Self
Bound clean workers retained for low-latency reuse. Zero disables pooling.
Sourcepub const fn with_result_compatibility(
self,
result_compatibility: ResultCompatibility,
) -> Self
pub const fn with_result_compatibility( self, result_compatibility: ResultCompatibility, ) -> Self
Require every result to be faithfully representable by one host surface.
Sourcepub fn with_in_process_execution(self) -> Self
pub fn with_in_process_execution(self) -> Self
Disable crash isolation for trusted embedding and deterministic test harnesses.
This mode must never execute hostile or unreviewed code. Production Rust and Python callers use the supervised worker by default.
Sourcepub fn with_virtual_root(self, virtual_root: VirtualRoot) -> Self
pub fn with_virtual_root(self, virtual_root: VirtualRoot) -> Self
Replace the synthetic absolute namespace exposed to Monty.
Sourcepub fn with_policy(self, policy: TransactionPolicy) -> Self
pub fn with_policy(self, policy: TransactionPolicy) -> Self
Replace deterministic transaction and pre-call policy.
Sourcepub fn with_policy_profile(self, profile: PolicyProfile) -> Self
pub fn with_policy_profile(self, profile: PolicyProfile) -> Self
Select a built-in deterministic policy profile.
Sourcepub const fn with_snapshot_limits(self, limits: SnapshotLimits) -> Self
pub const fn with_snapshot_limits(self, limits: SnapshotLimits) -> Self
Replace eager snapshot traversal bounds.
Sourcepub const fn with_commit_config(self, config: CommitConfig) -> Self
pub const fn with_commit_config(self, config: CommitConfig) -> Self
Replace trusted commit and recovery bounds.
Sourcepub const fn with_store_config(self, config: FileStoreConfig) -> Self
pub const fn with_store_config(self, config: FileStoreConfig) -> Self
Replace durable transaction-log bounds.
Sourcepub const fn with_artifact_limits(self, limits: ArtifactLimits) -> Self
pub const fn with_artifact_limits(self, limits: ArtifactLimits) -> Self
Replace durable pending-artifact allocation and cardinality bounds.
Sourcepub const fn with_commit_hook(self, hook: HookConfig) -> Self
pub const fn with_commit_hook(self, hook: HookConfig) -> Self
Require the native two-phase hook protocol for matching commit candidates.
Sourcepub fn workspace_root(&self) -> &Path
pub fn workspace_root(&self) -> &Path
Return the host workspace authority root.
Sourcepub fn data_directory(&self) -> &Path
pub fn data_directory(&self) -> &Path
Return the trusted immutable-artifact directory.
Sourcepub fn worker_path(&self) -> Option<&Path>
pub fn worker_path(&self) -> Option<&Path>
Return the supervised worker path, or None for explicit trusted in-process mode.
Sourcepub const fn policy(&self) -> &TransactionPolicy
pub const fn policy(&self) -> &TransactionPolicy
Return deterministic transaction policy.
Sourcepub const fn commit_hook(&self) -> Option<HookConfig>
pub const fn commit_hook(&self) -> Option<HookConfig>
Return the commit-hook configuration, when direct commits are guarded.
Trait Implementations§
Source§impl Clone for RuntimeConfig
impl Clone for RuntimeConfig
Source§fn clone(&self) -> RuntimeConfig
fn clone(&self) -> RuntimeConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for RuntimeConfig
impl RefUnwindSafe for RuntimeConfig
impl Send for RuntimeConfig
impl Sync for RuntimeConfig
impl Unpin for RuntimeConfig
impl UnsafeUnpin for RuntimeConfig
impl UnwindSafe for RuntimeConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.