Skip to main content

ComposeBudget

Struct ComposeBudget 

Source
pub struct ComposeBudget {
    pub max_children: usize,
    pub max_bytes_per_child: usize,
    pub max_total_bytes: usize,
    pub max_depth: usize,
    pub max_total_nodes: usize,
    pub max_total_fb_bytes: usize,
    pub max_fb_bytes_per_child: usize,
}
Expand description

Resource caps for a composition — the security gate that stops an attacker-authored or runaway compose graph from exhausting the host (linear memory) or the sponsor (per-mount fees). The adversarial critique flagged ALL three frontier designs as leaving these uncapped (its #2 top risk: “sponsor-key drain… uncapped in all three designs”). Checked when a spawn is requested, BEFORE any fetch/instantiate/settle.

Fields§

§max_children: usize

Immediate children of ONE node.

§max_bytes_per_child: usize§max_total_bytes: usize

Wasm bytes across the WHOLE tree (every level), not per node.

§max_depth: usize

Deepest spawnable node. Root = depth 0; a node at this depth gets an inert compose api (its spawn_module returns -1) — the recursion stop.

§max_total_nodes: usize

Live nodes across the WHOLE tree — the fork-bomb backstop independent of the per-node child cap (a balanced tree could otherwise explode).

§max_total_fb_bytes: usize

Framebuffer bytes (w*h*4) across the WHOLE tree. The wasm-byte caps don’t bound this: a tiny (16 KB) cartridge can declare dims()=1024x1024 and allocate a 4 MB framebuffer, so 24 such nodes = 96 MB+ of host memory while staying inside every byte/node cap. This is the per-child FB ceiling AND the tree-wide aggregate that closes that hole.

§max_fb_bytes_per_child: usize

Per-child framebuffer bytes ceiling — a single composed panel can’t allocate a fullscreen-sized surface (the worker’s FB_MAX=1024 allows a 4 MB child standalone; composited, a child is far smaller).

Implementations§

Source§

impl ComposeBudget

Source

pub fn v1() -> Self

v1 caps. Composition is RECURSIVE (the fractal): a child gets its own table and may spawn grandchildren, bounded by depth + global node/byte caps. 16 children/node, 16 KB each, 256 KB total, depth 5, 24 nodes total, 1 MB framebuffer per child, 16 MB framebuffer across the whole tree. (16, not 8: a common 3×3 or 4×4 grid needs 9–16 immediate children — the old 8-cap silently refused the 9th, so a 9-cell grid’s last cell never spawned, read as “the bottom-right cartridge doesn’t work”, telemetry #87. The tree is still bounded by max_total_nodes + the total-FB cap.)

Source

pub fn admit( &self, count: usize, total_bytes: usize, child_bytes: usize, ) -> Result<(), String>

Whether a new child of child_bytes may be admitted given the count children and total_bytes already mounted. Err carries the reason so the host can log WHY a spawn was refused (silent caps read as “worked”).

Source

pub fn admit_fb( &self, total_fb_bytes: usize, child_fb_bytes: usize, ) -> Result<(), String>

Whether a child whose declared surface is child_fb_bytes (w*h*4) may be admitted given the total_fb_bytes of framebuffers already mounted across the tree. Checked AFTER instantiate (a child’s dims() needs a live instance), the same way the wasm-byte caps in [admit] are. Err carries the reason so a refused mount logs WHY (a silent cap reads as “worked”). This is the cap the wasm-byte budget can’t enforce: a 16 KB cartridge declaring dims()=1024x1024 wants a 4 MB framebuffer.

Source

pub fn may_spawn( &self, parent_depth: usize, total_nodes: usize, ) -> Result<(), String>

Whether a node at parent_depth may spawn another child given total_nodes already live across the tree — the recursion-specific gate (depth + global node count) checked at spawn time, before the byte caps in [admit]. Err says which cap stopped the fractal.

Trait Implementations§

Source§

impl Clone for ComposeBudget

Source§

fn clone(&self) -> ComposeBudget

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for ComposeBudget

Source§

impl Debug for ComposeBudget

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more