PCPRuntime

Struct PCPRuntime 

Source
pub struct PCPRuntime {
    pub(crate) config: PCPConfig,
    pub(crate) checkpoints: Vec<PCPCheckpoint>,
}
Expand description

PCP Runtime - the main validation and checkpoint engine.

Fields§

§config: PCPConfig§checkpoints: Vec<PCPCheckpoint>

Implementations§

Source§

impl PCPRuntime

Source

pub fn new(config: PCPConfig) -> Result<PCPRuntime, CellstateError>

Create a new PCP runtime with the given configuration.

Source

pub fn config(&self) -> &PCPConfig

Get the configuration.

Source§

impl PCPRuntime

Source

pub fn validate_context_integrity( &self, scope: &Scope, artifacts: &[Artifact], current_tokens: i32, ) -> Result<ValidationResult, CellstateError>

Validate context integrity. Checks for stale data, missing references, and dosage limits.

§Arguments
  • scope - The scope to validate
  • artifacts - Artifacts in the scope
  • current_tokens - Current token count in the scope
§Returns

ValidationResult with any issues found

Source§

impl PCPRuntime

Source

pub fn detect_contradictions( &self, artifacts: &[Artifact], ) -> Result<Vec<Contradiction>, CellstateError>

Detect contradictions between artifacts using embedding similarity. Two artifacts are considered potentially contradictory if:

  1. They have high embedding similarity (similar topic)
  2. Their content differs significantly
§Arguments
  • artifacts - Artifacts to check for contradictions
§Returns

Vector of detected contradictions

Source§

impl PCPRuntime

Source

pub fn apply_dosage_limits( &self, artifacts: &[Artifact], current_tokens: i32, ) -> Result<DosageResult, CellstateError>

Apply dosage limits to artifacts and tokens. Returns which artifacts should be pruned to stay within limits.

§Arguments
  • artifacts - Current artifacts (sorted by priority/recency)
  • current_tokens - Current token count
§Returns

DosageResult indicating what needs to be pruned

Source

pub fn would_exceed_limits( &self, current_artifacts: i32, current_tokens: i32, additional_artifacts: i32, additional_tokens: i32, ) -> bool

Check if adding more content would exceed dosage limits.

§Arguments
  • current_artifacts - Current artifact count
  • current_tokens - Current token count
  • additional_artifacts - Artifacts to add
  • additional_tokens - Tokens to add
§Returns

true if adding would exceed limits

Source§

impl PCPRuntime

Source

pub fn lint_artifact( &self, artifact: &Artifact, existing_artifacts: &[Artifact], ) -> Result<LintResult, CellstateError>

Lint an artifact for quality issues. Checks for size, duplicates, missing embeddings, and low confidence.

§Arguments
  • artifact - The artifact to lint
  • existing_artifacts - Existing artifacts to check for duplicates
§Returns

LintResult with any issues found

Source

pub fn lint_artifacts( &self, artifacts: &[Artifact], ) -> Result<LintResult, CellstateError>

Lint multiple artifacts at once.

§Arguments
  • artifacts - Artifacts to lint
§Returns

Combined LintResult for all artifacts

Source§

impl PCPRuntime

Source

pub fn create_checkpoint( &mut self, scope: &Scope, artifacts: &[Artifact], note_ids: &[NoteId], ) -> Result<PCPCheckpoint, CellstateError>

Create a checkpoint for a scope. Captures the current state for potential recovery.

§Arguments
  • scope - The scope to checkpoint
  • artifacts - Current artifacts in the scope
  • note_ids - Current note IDs referenced by the scope
§Returns

The created checkpoint

Source

pub fn recover_from_checkpoint( &self, checkpoint: &PCPCheckpoint, ) -> Result<RecoveryResult, CellstateError>

Recover a scope from a checkpoint.

§Arguments
  • checkpoint - The checkpoint to recover from
§Returns

RecoveryResult with the recovered scope

Source

pub fn get_latest_checkpoint(&self, scope_id: ScopeId) -> Option<&PCPCheckpoint>

Get the latest checkpoint for a scope.

§Arguments
  • scope_id - The scope to get checkpoint for
§Returns

The latest checkpoint if found

Source

pub fn get_checkpoints_for_scope( &self, scope_id: ScopeId, ) -> Vec<&PCPCheckpoint>

Get all checkpoints for a scope.

§Arguments
  • scope_id - The scope to get checkpoints for
§Returns

Vector of checkpoints for the scope

Source

pub fn delete_checkpoint(&mut self, checkpoint_id: Uuid) -> bool

Delete a checkpoint.

§Arguments
  • checkpoint_id - The checkpoint to delete
§Returns

true if checkpoint was deleted

Source

pub fn clear_checkpoints_for_scope(&mut self, scope_id: ScopeId) -> usize

Clear all checkpoints for a scope.

§Arguments
  • scope_id - The scope to clear checkpoints for
§Returns

Number of checkpoints deleted

Source§

impl PCPRuntime

Source

pub fn check_summarization_triggers( &self, scope: &Scope, turn_count: i32, artifact_count: i32, policies: &[SummarizationPolicy], ) -> Result<Vec<(SummarizationPolicyId, SummarizationTrigger)>, CellstateError>

Check which summarization triggers should fire based on current scope state.

This method evaluates all provided summarization policies against the current state of a scope and returns which triggers should activate. Inspired by EVOLVE-MEM’s self-improvement engine.

§Arguments
  • scope - The scope to evaluate triggers for
  • turn_count - Number of turns in the scope
  • artifact_count - Number of artifacts in the scope
  • policies - Summarization policies to check
§Returns

Vector of (summarization_policy_id, triggered_trigger) pairs for policies that should fire

§Example
let triggered = runtime.check_summarization_triggers(
    &scope,
    turns.len() as i32,
    artifacts.len() as i32,
    &policies,
)?;

for (summarization_policy_id, trigger) in triggered {
    // Execute summarization for this policy
}
Source

pub fn get_abstraction_transition( &self, policy: &SummarizationPolicy, ) -> (AbstractionLevel, AbstractionLevel)

Calculate what abstraction level transition should occur for a policy.

§Arguments
  • policy - The policy defining source->target transition
§Returns

Tuple of (source_level, target_level) for the summarization operation

Source

pub fn validate_abstraction_transition( &self, source: AbstractionLevel, target: AbstractionLevel, ) -> bool

Validate an abstraction level transition.

Valid transitions are:

  • Raw -> Summary (L0 -> L1)
  • Summary -> Principle (L1 -> L2)
  • Raw -> Principle (L0 -> L2, skipping L1)

Invalid transitions:

  • Summary -> Raw (downgrade)
  • Principle -> Summary/Raw (downgrade)
  • Same level to same level
§Arguments
  • source - Source abstraction level
  • target - Target abstraction level
§Returns

true if the transition is valid

Trait Implementations§

Source§

impl Clone for PCPRuntime

Source§

fn clone(&self) -> PCPRuntime

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PCPRuntime

Source§

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

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

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.

§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: 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
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more