#[non_exhaustive]pub struct KernelDef {
pub partitions: Vec<PartitionDef>,
pub coordinator: Option<PartitionId>,
pub drivers: Vec<DriverManifest>,
pub proactivity: Option<ProactivityPolicy>,
pub wake_sets: Vec<WakeSetDef>,
}Expand description
The kernel part of a hosted definition: partitions and their coordinator, drivers, the proactivity policy and wake sets (spec 3.2 §7.8, §7.13, §10 M1).
A KernelDef travels as JSON under KERNEL_DEF_METADATA_KEY in a
ManagedAgentDef’s metadata, beside the harness block, so the managed runtime stores
and rebuilds it like any other definition, and a KernelResolver
hosts the definition on its tenant’s kernel. The block is written in the kernel’s own
camelCase wire shape — its wakes, driver manifests and proactivity policy are the
kernel’s types — and an unknown key of the block, a partition or a wake set refuses it.
| Field | In the tenant’s kernel |
|---|---|
wakeSets | standing triggers: each wake starts a governed run of the definition’s agent |
proactivity | the tenant kernel’s ProactivityPolicy: open proposals, the daily proactive budget, quiet hours, how proposals are approved; the consolidation tick runs only when the block sets consolidation (§13 Q1) |
drivers | real DriverManifests, validated; with the tenant’s driver supervisor (TenantKernelBuilder::drivers), each one a declared partition mounts is proposed in the tenant’s approval inbox and mounted when a person approves it, then served to that partition’s harness (spec 3.2 §7.7) |
partitions, coordinator | as [[kernel.partitions]] and kernel.coordinator in harness.toml: each partition in the tenant’s partition table, its tenant the hosting tenant, with an agent of its own built by the tenant’s PartitionAgentResolver — one harness per partition — as the target <definition>@<partition>; the coordinator’s agent, else the first partition’s by id, also serves the definition’s own target. Without a partition resolver the partitions are recorded and the definition’s agent runs in the default partition |
A definition comes from a tenant, so the block cannot widen what the operator allows: a
driver is never unsandboxed and pins no declaration digest of its own, a credential
reaches a driver only as a secret:// reference, a wake set never runs on the
interactive queue a person’s turn holds nor watches the host’s files, and no field lets
an agenda item of origin Consolidation start without a person’s approval (K-I23).
§Example
use adk_kernel::Wake;
use adk_kernel::managed::{KernelDef, WakeSetDef};
use adk_managed::types::{ManagedAgentDef, ModelRef};
let kernel = KernelDef::new().with_wake_set(WakeSetDef::new(
"morning",
[WakeSetDef::cron("0 0 9 * * *")],
"Summarize what changed overnight.",
));
let def = kernel.apply_to(ManagedAgentDef::new("digest", ModelRef::Shorthand("gemini-3.5-flash-lite".into())));
// The definition crosses a store as JSON, as a session record does.
let def: ManagedAgentDef = serde_json::from_value(serde_json::to_value(&def)?)?;
assert_eq!(KernelDef::from_agent_def(&def)?, Some(kernel));Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.partitions: Vec<PartitionDef>The partitions the definition’s agents run in (spec 3.2 §7.8).
coordinator: Option<PartitionId>The partition whose agent is the coordinator, the one that may cross into another
partition under a non-waivable approval (spec 3.2 §7.8, K-I15); one of
partitions.
drivers: Vec<DriverManifest>The drivers the definition asks to mount (spec 3.2 §7.7).
proactivity: Option<ProactivityPolicy>The proactivity policy (spec 3.2 §7.5); None leaves the operator’s, with the
consolidation tick off.
wake_sets: Vec<WakeSetDef>The wake sets that start the definition’s agent (spec 3.2 §7.4).
Implementations§
Source§impl KernelDef
impl KernelDef
Sourcepub fn new() -> Self
pub fn new() -> Self
An empty block: no partitions, drivers or wake sets, no proactivity policy.
Sourcepub fn with_partition(self, partition: PartitionDef) -> Self
pub fn with_partition(self, partition: PartitionDef) -> Self
Adds a partition.
Sourcepub fn with_coordinator(self, partition: impl Into<PartitionId>) -> Self
pub fn with_coordinator(self, partition: impl Into<PartitionId>) -> Self
Makes partition’s agent the coordinator (spec 3.2 §7.8).
Sourcepub fn primary_partition(&self) -> Option<PartitionId>
pub fn primary_partition(&self) -> Option<PartitionId>
The partition whose agent serves the definition’s own target: the coordinator’s,
else the first partition’s by id; None without partitions (spec 3.2 §7.8).
Sourcepub fn with_driver(self, driver: DriverManifest) -> Self
pub fn with_driver(self, driver: DriverManifest) -> Self
Adds a driver manifest.
Sourcepub fn with_proactivity(self, proactivity: ProactivityPolicy) -> Self
pub fn with_proactivity(self, proactivity: ProactivityPolicy) -> Self
Sets the proactivity policy.
Sourcepub fn with_wake_set(self, wake_set: WakeSetDef) -> Self
pub fn with_wake_set(self, wake_set: WakeSetDef) -> Self
Adds a wake set.
Sourcepub fn from_agent_def(def: &ManagedAgentDef) -> Result<Option<Self>>
pub fn from_agent_def(def: &ManagedAgentDef) -> Result<Option<Self>>
The kernel block def carries, validated, or None when its metadata holds no
KERNEL_DEF_METADATA_KEY (spec 3.2 §7.13, §10 M1).
§Errors
Returns KernelError::Config when the block is not valid JSON, has an unknown key,
or fails validate; the message names the definition and the key.
Sourcepub fn apply_to(&self, def: ManagedAgentDef) -> ManagedAgentDef
pub fn apply_to(&self, def: ManagedAgentDef) -> ManagedAgentDef
def with this block in its metadata under KERNEL_DEF_METADATA_KEY, replacing
any block it carried; the caller’s other keys, adk.harness included, stay.
The block is not validated here; from_agent_def validates
it where it is read.
Sourcepub fn consolidation(&self) -> Option<&ConsolidationTick>
pub fn consolidation(&self) -> Option<&ConsolidationTick>
The consolidation tick the block turns on, or None: the tick is off in the managed
form unless the definition’s policy sets it (spec 3.2 §7.5, §13 Q1).
Sourcepub fn validate(&self) -> Result<()>
pub fn validate(&self) -> Result<()>
Checks every rule of the block (spec 3.2 §7.4, §7.5, §7.7, §7.8).
| Part | Refused when |
|---|---|
| partitions | an id or class is blank or repeated, an id has a character other than letters, digits, - and _, a mounted driver is not one of the block’s, crossPartition is unknown, a blocked crossing names the partition itself |
| coordinator | it names a partition the block does not declare |
| drivers | a manifest fails DriverManifest::validate, an id is repeated, a partition is not declared, the sandbox is unsandboxed, a declaration digest is pinned |
| proactivity | a share, score or fraction of the consolidation tick is outside its range, or its schedule is blank |
| wake sets | a name is blank, repeated or not an identifier, anyOf or input is empty, a wake is not a cron, webhook, queue or signal wake, a cron expression does not parse, a hook or source is blank, a signal kind is not an identifier, the partition — the set’s or a signal wake’s — is not declared, the queue is interactive, the user is blank |
§Errors
Returns KernelError::Config naming the first rule broken and how to fix it.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for KernelDef
impl<'de> Deserialize<'de> for KernelDef
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl StructuralPartialEq for KernelDef
Auto Trait Implementations§
impl Forget for KernelDef
impl Freeze for KernelDefwhere
*const u8 is !null: Freeze,
PhantomData<PartitionDef>: Freeze,
PhantomData<u8>: Freeze,
PhantomData<DriverManifest>: Freeze,
*const LeafNode<UsageUnit, u64> is !null: Freeze,
PhantomData<(Owned, LeafOrInternal)>: Freeze,
PhantomData<Box<(UsageUnit, u64)>>: Freeze,
PhantomData<WakeSetDef>: Freeze,
impl Move for KernelDef
impl RefUnwindSafe for KernelDef
impl Send for KernelDefwhere
RawVecInner: Send,
NodeRef<Owned, PartitionId, SetValZST, LeafOrInternal>: Send,
BoxRaw<(PartitionId, SetValZST)>: Send,
RawTable<(String, String)>: Send,
NodeRef<Owned, String, EffectClass, LeafOrInternal>: Send,
BoxRaw<(String, EffectClass)>: Send,
NodeRef<Owned, String, String, LeafOrInternal>: Send,
BoxRaw<(String, String)>: Send,
NodeRef<Owned, UsageUnit, u64, LeafOrInternal>: Send,
BoxRaw<(UsageUnit, u64)>: Send,
NonZero<i32>: Send,
Utc: Send,
impl Sync for KernelDefwhere
RawVecInner: Sync,
NodeRef<Owned, PartitionId, SetValZST, LeafOrInternal>: Sync,
BoxRaw<(PartitionId, SetValZST)>: Sync,
RawTable<(String, String)>: Sync,
NodeRef<Owned, String, EffectClass, LeafOrInternal>: Sync,
BoxRaw<(String, EffectClass)>: Sync,
NodeRef<Owned, String, String, LeafOrInternal>: Sync,
BoxRaw<(String, String)>: Sync,
NodeRef<Owned, UsageUnit, u64, LeafOrInternal>: Sync,
BoxRaw<(UsageUnit, u64)>: Sync,
NonZero<i32>: Sync,
Utc: Sync,
impl Unpin for KernelDefwhere
*const u8 is !null: Unpin,
*const LeafNode<PartitionId, SetValZST> is !null: Unpin,
Box<(PartitionId, SetValZST)>: Unpin,
*const LeafNode<String, EffectClass> is !null: Unpin,
Box<(String, EffectClass)>: Unpin,
*const LeafNode<String, String> is !null: Unpin,
Box<(String, String)>: Unpin,
*const LeafNode<UsageUnit, u64> is !null: Unpin,
Box<(UsageUnit, u64)>: Unpin,
NonZero<i32>: Unpin,
Utc: Unpin,
impl UnsafeUnpin for KernelDefwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<PartitionDef>: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<DriverManifest>: UnsafeUnpin,
*const LeafNode<UsageUnit, u64> is !null: UnsafeUnpin,
PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin,
PhantomData<Box<(UsageUnit, u64)>>: UnsafeUnpin,
PhantomData<WakeSetDef>: UnsafeUnpin,
impl UnwindSafe for KernelDefwhere
RawVecInner: UnwindSafe,
BTreeMap<PartitionId, SetValZST>: UnwindSafe,
HashMap<String, String>: UnwindSafe,
BTreeMap<String, EffectClass>: UnwindSafe,
BTreeMap<String, String>: UnwindSafe,
BTreeMap<UsageUnit, u64>: UnwindSafe,
NonZero<i32>: UnwindSafe,
Utc: UnwindSafe,
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§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.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
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.