Skip to main content

ScopeKernel

Struct ScopeKernel 

Source
pub struct ScopeKernel<M> { /* private fields */ }
Expand description

Typed wrapper around an Arc<PolydatKernel>.

Construction via this type goes through the SRD-67 protocol (subcontext_builderfinalizespawn); direct construction from a PolydatKernel is pub(crate) for the Phase 1 internal bridge.

Implementations§

Source§

impl<M> ScopeKernel<M>

Source

pub fn shared_cells_in_scope(&self) -> Vec<SharedCellInScope>

Enumerate every shared cell visible at this scope. Delegates to PolydatKernel::shared_cells_in_scope — the carrier lives at the kernel layer so it survives any wrap/unwrap dance the activity layer does. The SharedCellInScope re-export is kept for callers in the SRD-67 builder; it’s a thin alias over the kernel layer’s SharedCellEntry.

Source

pub fn name(&self) -> &ChildName

The structured name this kernel was spawned under (for child kernels) or its self-label (for root kernels).

Source

pub fn site(&self) -> &SourceContext

Diagnostic site for this kernel’s construction.

Source

pub fn lock_inner(&self) -> MutexGuard<'_, PolydatKernel>

Borrow the underlying PolydatKernel for read-only operations. The lock is released when the returned guard is dropped. Exposed for callers that drive the kernel directly (the builder’s finalize does, as do tests).

Source

pub fn consumers(&self) -> Vec<RegisteredPullConsumer>

The pull consumers registered with this kernel. Used by the activity-side fixture adapter at seal time.

Source

pub fn has_child(&self, name: &ChildName) -> bool

Whether name is recorded in this kernel’s named-child registry. Diagnostic; Phase 1 tests assert against this.

Source

pub fn release_child(&self, name: &ChildName)

Drop the named child from this kernel’s registry. The child kernel itself is unaffected — only the registry entry. After release, the same name may be spawned again (typical for comprehension scopes that re-traverse per iteration). See SRD-67 §“Release semantics”.

Source

pub fn subcontext_builder(self: Arc<Self>) -> SubcontextBuilder<M>

Begin construction of a child sub-context. Per SRD-67 §“Step 1 — Parent yields a builder”: the builder borrows an Arc of the parent, accumulates module matter, and produces a closed ScopeModule artifact at finalize.

Source

pub fn spawn( self: &Arc<Self>, name: ChildName, artifact: ScopeModule<Child<M>>, ) -> Result<ScopeKernel<Child<M>>, ContractViolation>

Spawn a child kernel from a closed ScopeModule artifact. Per SRD-67 §“Step 4 — Parent spawns the child kernel”: this is the single chokepoint where every cross- binding is resolved.

The artifact arrives with Rule 1 (name closure) and Rule 2 (the shared write-through rewrite) already applied by SubcontextBuilder::finalize. Spawn materializes the closed program under this parent via PolydatKernel::materialize_subscope, whose materialize_wiring_from_outer (kernel/state.rs) does the live binding: attaches every parent-visible SharedCell to a matching child slot and forwards the rest as transit (Rule 2’s cell attach, SC8), value-copies or cell-attaches parent outputs into child externs (Rules 4 and 5), pulls every const output once after wiring so scope-init values see post-bind inputs (Rule 3), and freezes the scope coordinates. Per-cycle publication to the cells is Self::commit_write_throughs.

Source

pub fn write_throughs(&self) -> &[WriteThroughBinding]

The Rule 2 write-through bindings carried by this kernel. Empty for the vast majority of kernels; populated only when the artifact’s finalize rewrote a child export to a parent shared cell write.

Source

pub fn commit_write_throughs(&self) -> Result<(), String>

Per-cycle Rule 2 commit: pulls every write-through’s synthetic source output (__write_<X>) and stores its value through the corresponding child input slot for <X>. Because materialize_wiring_from_outer attached the parent’s SharedCell to that slot, the write propagates to the cell, where it becomes visible to the parent and to any sibling that shares the same cell.

No-op for kernels with no write-throughs.

TYPE-STABLE (scope_model.md §“Type stability”): each pending value passes the same boundary as crate::kernel::PolydatKernel::commit_write_throughs — matching types pass, catalog adapters heal (widening), and an unhealable mismatch is an Err at the write site.

Trait Implementations§

Source§

impl<M> Debug for ScopeKernel<M>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<M> !Freeze for ScopeKernel<M>

§

impl<M> RefUnwindSafe for ScopeKernel<M>
where PhantomData<fn() -> M>: RefUnwindSafe,

§

impl<M> Send for ScopeKernel<M>
where PhantomData<fn() -> M>: Send,

§

impl<M> Sync for ScopeKernel<M>
where PhantomData<fn() -> M>: Sync,

§

impl<M> Unpin for ScopeKernel<M>
where PhantomData<fn() -> M>: Unpin,

§

impl<M> UnsafeUnpin for ScopeKernel<M>
where PhantomData<fn() -> M>: UnsafeUnpin,

§

impl<M> UnwindSafe for ScopeKernel<M>
where PhantomData<fn() -> M>: UnwindSafe,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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