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
impl SessionToolSet
Sourcepub fn new(
session: SessionId,
core: impl IntoIterator<Item = ToolId>,
catalog: &ToolCatalog,
) -> Result<SessionToolSet, SessionToolSetError>
pub fn new( session: SessionId, core: impl IntoIterator<Item = ToolId>, catalog: &ToolCatalog, ) -> Result<SessionToolSet, 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.
pub fn session(&self) -> &SessionId
Sourcepub fn default_core_for_catalog(
session: SessionId,
catalog: &ToolCatalog,
) -> SessionToolSet
pub fn default_core_for_catalog( session: SessionId, catalog: &ToolCatalog, ) -> SessionToolSet
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.
Sourcepub fn progressive_core_for_catalog(
session: SessionId,
catalog: &ToolCatalog,
) -> SessionToolSet
pub fn progressive_core_for_catalog( session: SessionId, catalog: &ToolCatalog, ) -> SessionToolSet
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.
Sourcepub fn rebuilt_for_catalog(
&self,
catalog: &ToolCatalog,
progressive: bool,
) -> (SessionToolSet, Vec<DroppedActivation>)
pub fn rebuilt_for_catalog( &self, catalog: &ToolCatalog, progressive: bool, ) -> (SessionToolSet, 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.
Sourcepub fn carry_activations_into(
&self,
next: SessionToolSet,
catalog: &ToolCatalog,
) -> (SessionToolSet, Vec<DroppedActivation>)
pub fn carry_activations_into( &self, next: SessionToolSet, catalog: &ToolCatalog, ) -> (SessionToolSet, 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.
Sourcepub fn revoke_exact(&mut self, id: &ToolId) -> Result<(), ExactRevocationError>
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.
Sourcepub fn catalog_generation(&self) -> CatalogGeneration
pub fn catalog_generation(&self) -> CatalogGeneration
The catalog generation this set snapshot was built against.
Sourcepub fn is_stale(&self, catalog: &ToolCatalog) -> bool
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.
Sourcepub fn core_ids(&self) -> impl Iterator<Item = &ToolId>
pub fn core_ids(&self) -> impl Iterator<Item = &ToolId>
Deterministic projection of configured core ids (ToolId order).
pub fn is_core(&self, id: &ToolId) -> bool
Sourcepub fn core_schema_digest(&self, id: &ToolId) -> Option<&SchemaDigest>
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.
Sourcepub fn core_pin(&self, id: &ToolId) -> Option<&CorePin>
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.
Sourcepub fn activated(&self) -> impl Iterator<Item = &ActivatedTool>
pub fn activated(&self) -> impl Iterator<Item = &ActivatedTool>
Deterministic projection of exact activations (ToolId order).
pub fn activation(&self, id: &ToolId) -> Option<&ActivatedTool>
Sourcepub fn schema_generation(&self) -> u64
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.
Sourcepub fn activate(
&mut self,
grant: SessionActivationGrant,
catalog: &ToolCatalog,
) -> Result<(), ActivationError>
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.
Sourcepub fn activate_many(
&mut self,
grants: Vec<SessionActivationGrant>,
catalog: &ToolCatalog,
) -> Result<usize, BulkActivationError>
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
impl Clone for SessionToolSet
Source§fn clone(&self) -> SessionToolSet
fn clone(&self) -> SessionToolSet
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 SessionToolSet
impl RefUnwindSafe for SessionToolSet
impl Send for SessionToolSet
impl Sync for SessionToolSet
impl Unpin for SessionToolSet
impl UnsafeUnpin for SessionToolSet
impl UnwindSafe for SessionToolSet
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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 more