pub struct ContextOffloader<'a> { /* private fields */ }Expand description
Substrate-level engine for offload+deref. Composed from the
caller’s keypair, the existing SQLite connection, and the
OffloadConfig defaults.
Implementations§
Source§impl<'a> ContextOffloader<'a>
impl<'a> ContextOffloader<'a>
Sourcepub fn new(
conn: &'a Connection,
signer: Option<&'a AgentKeypair>,
config: OffloadConfig,
) -> Self
pub fn new( conn: &'a Connection, signer: Option<&'a AgentKeypair>, config: OffloadConfig, ) -> Self
Construct a new offloader. Pass signer = None for read-only
deref workflows.
Sourcepub fn offload(
&self,
content: &str,
namespace: &str,
ttl_seconds: Option<u64>,
agent_id: &str,
) -> Result<OffloadResult>
pub fn offload( &self, content: &str, namespace: &str, ttl_seconds: Option<u64>, agent_id: &str, ) -> Result<OffloadResult>
Offload content and return the ref_id callers persist in
place of the full payload.
§Errors
OffloadError::SizeLimitExceededwhencontentis larger than the configured per-blob ceiling.anyhow::Errorfor zstd / SQLite / signing failures.
Sourcepub fn deref(
&self,
ref_id: &str,
caller_agent_id: Option<&str>,
) -> Result<DerefResult>
pub fn deref( &self, ref_id: &str, caller_agent_id: Option<&str>, ) -> Result<DerefResult>
Dereference a ref_id and return the original content.
§IDOR (SEC-4, Cluster D, issue #767)
caller_agent_id is the authenticated identity of the
caller (resolved via crate::identity::resolve_agent_id
upstream). The stored row’s agent_id is consulted as the
owner of the blob; when the caller is not the owner, this
function returns OffloadError::NotFound (leak-resistant
— does NOT reveal the blob exists). A future K9 cross-agent
grant check can layer on top of this; pass None to BYPASS
the ownership gate (substrate-internal sweepers, integrity
audits, operator dump tools — none of which originate from
an authenticated agent context).
§Errors
OffloadError::NotFoundwhenref_idhas no row OR when the caller is not the stored owner (leak-resistant).OffloadError::IntegrityFailedwhen the decompressed content’s SHA-256 disagrees with the stored hash (tamper).OffloadError::SignatureFailedwhen a signer was provided and the stored Ed25519 signature fails to verify.
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for ContextOffloader<'a>
impl<'a> !Send for ContextOffloader<'a>
impl<'a> !Sync for ContextOffloader<'a>
impl<'a> !UnwindSafe for ContextOffloader<'a>
impl<'a> Freeze for ContextOffloader<'a>
impl<'a> Unpin for ContextOffloader<'a>
impl<'a> UnsafeUnpin for ContextOffloader<'a>
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<T> ErasedDestructor for Twhere
T: 'static,
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