Skip to main content

SessionToolSet

Struct SessionToolSet 

Source
pub struct SessionToolSet { /* private fields */ }
Expand description

The small configured core set plus exact activated deferred tools for one session, pinned to the catalog generation it was built against. Core tools are pinned with the schema digest AND trust provenance of their catalog record at build time, so later drift is detectable per tool, not just per generation.

Implementations§

Source§

impl SessionToolSet

Source

pub fn new( session: SessionId, core: impl IntoIterator<Item = ToolId>, catalog: &ToolCatalog, ) -> Result<Self, SessionToolSetError>

Build a fresh set for one session. Every configured core id must exist in the catalog (typed failure otherwise) and its schema digest AND trust provenance are pinned from the catalog record; the set starts with zero activations — nothing is inherited from any other session.

Source

pub fn session(&self) -> &SessionId

Source

pub fn default_core_for_catalog( session: SessionId, catalog: &ToolCatalog, ) -> Self

Default per-stream-session set (Task 16 behavior preservation): the core set is EXACTLY every currently cataloged capability with verified provenance — builtins plus already-loaded trusted extension/MCP/plugin tools. Unverified capabilities are excluded (denied-by-default at the gate), and the set carries zero activations. Deterministic: ids come straight from the catalog in ToolId order, so rebuilding after a catalog mutation yields the same set for the same catalog state.

Source

pub fn progressive_core_for_catalog( session: SessionId, catalog: &ToolCatalog, ) -> Self

Deterministic minimal core for Task 18 progressive disclosure. Only essential local operations plus discovery/authorization gateways are eligible; missing/disabled gateways are skipped rather than invented. Specialized subagent lifecycle, extension, MCP, shell-session, and dynamically registered tools remain deferred until exact activation.

Source

pub fn rebuilt_for_catalog( &self, catalog: &ToolCatalog, progressive: bool, ) -> (Self, Vec<DroppedActivation>)

Round-top rebuild against a NEWER catalog (runtime/stream.rs): the core is re-derived exactly as a fresh build would derive it, and every prior exact activation whose CURRENT catalog record still matches its pinned (schema digest, trust provenance) is re-issued a grant at the new generation. Activations whose record is gone or drifted are dropped and reported.

This is NOT a gate change: a carried activation is exactly what a user re-activation of the same tool would produce against this catalog, and ExecutionGate::authorize still checks digest and provenance against the current record on every call.

Source

pub fn carry_activations_into( &self, next: SessionToolSet, catalog: &ToolCatalog, ) -> (Self, Vec<DroppedActivation>)

Carry this set’s exact activations into next — a freshly built core for the SAME session against catalog — with exactly the checks Self::rebuilt_for_catalog applies (pinned digest + provenance unchanged and source trust intact; promoted-to-core ids are not carried; drifted/removed ones are dropped and reported). Shared by the round-top rebuild and the turn-start reconciliation of a retained set, so the two paths can never drift.

A next built for a different session inherits nothing: grants never cross sessions.

Source

pub fn revoke_exact(&mut self, id: &ToolId) -> Result<(), ExactRevocationError>

Typed EXACT revocation (Task 19 grant invalidation): remove one non-core exact activation from this session’s set. The session schema generation advances by exactly one IFF an activation was removed; core tools and unknown/never-activated ids fail typed with zero mutation. Never touches the catalog or sibling activations.

Source

pub fn catalog_generation(&self) -> CatalogGeneration

The catalog generation this set snapshot was built against.

Source

pub fn is_stale(&self, catalog: &ToolCatalog) -> bool

True when the catalog has mutated since this set was built. A stale set must be rebuilt/revalidated, not silently used.

Source

pub fn core_ids(&self) -> impl Iterator<Item = &ToolId>

Deterministic projection of configured core ids (ToolId order).

Source

pub fn is_core(&self, id: &ToolId) -> bool

Source

pub fn core_schema_digest(&self, id: &ToolId) -> Option<&SchemaDigest>

The schema digest pinned for a configured core tool at build time, or None when the id is not in this session’s core set.

Source

pub fn core_pin(&self, id: &ToolId) -> Option<&CorePin>

The full (digest, provenance) pin for a configured core tool, or None when the id is not in this session’s core set.

Source

pub fn activated(&self) -> impl Iterator<Item = &ActivatedTool>

Deterministic projection of exact activations (ToolId order).

Source

pub fn activation(&self, id: &ToolId) -> Option<&ActivatedTool>

Source

pub fn schema_generation(&self) -> u64

Session schema-generation counter (spec §7.7): the number of successful nonempty activation batches applied to this set. A deterministic bulk activate_many advances it by exactly one.

Source

pub fn activate( &mut self, grant: SessionActivationGrant, catalog: &ToolCatalog, ) -> Result<(), ActivationError>

Record one exact activation. This is set/test/bootstrap plumbing, not a model-facing activation flow: the grant must already exist and must match this session, a cataloged tool, the CURRENT catalog generation, and the CURRENT schema digest exactly. Any drift — foreign session, unknown tool, stale generation, changed digest, stale set snapshot, duplicate activation, core-set membership — fails typed before any mutation, so a failed call leaves the set byte-for-byte unchanged. No implementation is constructed, no process started, no schema exposed. A successful call is a nonempty batch of one: the session schema-generation advances by exactly one.

Source

pub fn activate_many( &mut self, grants: Vec<SessionActivationGrant>, catalog: &ToolCatalog, ) -> Result<usize, BulkActivationError>

Deterministic atomic bulk activation (spec §7.7): validate EVERY requested grant first — duplicates within the batch, unknown ids, core-set ids, stale generations, digest mismatches, stale set snapshots, and untrusted/inconsistent source provenance all fail typed with ZERO partial mutation — then apply in stable ToolId order and advance the session schema-generation by exactly one. An empty batch is a no-op that advances nothing. Returns the number of activations applied.

Trait Implementations§

Source§

impl Clone for SessionToolSet

Source§

fn clone(&self) -> Self

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 Debug for SessionToolSet

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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

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 = !

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