pub struct PCPRuntime {
pub(crate) config: PCPConfig,
pub(crate) checkpoints: Vec<PCPCheckpoint>,
}Expand description
PCP Runtime - the main validation and checkpoint engine.
Fields§
§config: PCPConfigPCP configuration
checkpoints: Vec<PCPCheckpoint>Checkpoints stored in memory (in production, backed by storage)
Implementations§
Source§impl PCPRuntime
impl PCPRuntime
Source§impl PCPRuntime
impl PCPRuntime
Sourcepub fn validate_context_integrity(
&self,
scope: &Scope,
artifacts: &[Artifact],
current_tokens: i32,
) -> CellstateResult<ValidationResult>
pub fn validate_context_integrity( &self, scope: &Scope, artifacts: &[Artifact], current_tokens: i32, ) -> CellstateResult<ValidationResult>
Sourcepub(crate) fn check_dosage_limits(
&self,
result: &mut ValidationResult,
artifact_count: i32,
token_count: i32,
)
pub(crate) fn check_dosage_limits( &self, result: &mut ValidationResult, artifact_count: i32, token_count: i32, )
Check dosage limits.
Sourcepub(crate) fn check_stale_scope(
&self,
result: &mut ValidationResult,
scope: &Scope,
)
pub(crate) fn check_stale_scope( &self, result: &mut ValidationResult, scope: &Scope, )
Check if scope is stale.
Sourcepub(crate) fn check_artifact_integrity(
&self,
result: &mut ValidationResult,
artifact: &Artifact,
)
pub(crate) fn check_artifact_integrity( &self, result: &mut ValidationResult, artifact: &Artifact, )
Check artifact integrity.
Source§impl PCPRuntime
impl PCPRuntime
Sourcepub fn detect_contradictions(
&self,
artifacts: &[Artifact],
) -> CellstateResult<Vec<Contradiction>>
pub fn detect_contradictions( &self, artifacts: &[Artifact], ) -> CellstateResult<Vec<Contradiction>>
Detect contradictions between artifacts using embedding similarity. Two artifacts are considered potentially contradictory if:
- They have high embedding similarity (similar topic)
- Their content differs significantly
§Arguments
artifacts- Artifacts to check for contradictions
§Returns
Vector of detected contradictions
Source§impl PCPRuntime
impl PCPRuntime
Sourcepub fn apply_dosage_limits(
&self,
artifacts: &[Artifact],
current_tokens: i32,
) -> CellstateResult<DosageResult>
pub fn apply_dosage_limits( &self, artifacts: &[Artifact], current_tokens: i32, ) -> CellstateResult<DosageResult>
Source§impl PCPRuntime
impl PCPRuntime
Sourcepub fn lint_artifact(
&self,
artifact: &Artifact,
existing_artifacts: &[Artifact],
) -> CellstateResult<LintResult>
pub fn lint_artifact( &self, artifact: &Artifact, existing_artifacts: &[Artifact], ) -> CellstateResult<LintResult>
Sourcepub(crate) fn check_artifact_size(
&self,
result: &mut LintResult,
artifact: &Artifact,
)
pub(crate) fn check_artifact_size( &self, result: &mut LintResult, artifact: &Artifact, )
Check if artifact content is too large.
Sourcepub(crate) fn check_artifact_duplicates(
&self,
result: &mut LintResult,
artifact: &Artifact,
existing_artifacts: &[Artifact],
)
pub(crate) fn check_artifact_duplicates( &self, result: &mut LintResult, artifact: &Artifact, existing_artifacts: &[Artifact], )
Check for duplicate artifacts by content hash.
Sourcepub(crate) fn check_artifact_embedding(
&self,
result: &mut LintResult,
artifact: &Artifact,
)
pub(crate) fn check_artifact_embedding( &self, result: &mut LintResult, artifact: &Artifact, )
Check if artifact is missing embedding.
Sourcepub(crate) fn check_artifact_confidence(
&self,
result: &mut LintResult,
artifact: &Artifact,
)
pub(crate) fn check_artifact_confidence( &self, result: &mut LintResult, artifact: &Artifact, )
Check artifact confidence score.
Sourcepub(crate) fn check_artifact_semantics(
&self,
result: &mut LintResult,
artifact: &Artifact,
)
pub(crate) fn check_artifact_semantics( &self, result: &mut LintResult, artifact: &Artifact, )
Check semantic markdown/context hazards inside artifact content.
Sourcepub fn lint_artifacts(
&self,
artifacts: &[Artifact],
) -> CellstateResult<LintResult>
pub fn lint_artifacts( &self, artifacts: &[Artifact], ) -> CellstateResult<LintResult>
Source§impl PCPRuntime
impl PCPRuntime
Sourcepub fn create_checkpoint(
&mut self,
scope: &Scope,
artifacts: &[Artifact],
note_ids: &[NoteId],
) -> CellstateResult<PCPCheckpoint>
pub fn create_checkpoint( &mut self, scope: &Scope, artifacts: &[Artifact], note_ids: &[NoteId], ) -> CellstateResult<PCPCheckpoint>
Sourcepub(crate) fn enforce_checkpoint_limit(&mut self)
pub(crate) fn enforce_checkpoint_limit(&mut self)
Enforce the maximum checkpoint limit by removing oldest checkpoints.
Sourcepub fn recover_from_checkpoint(
&self,
checkpoint: &PCPCheckpoint,
) -> CellstateResult<RecoveryResult>
pub fn recover_from_checkpoint( &self, checkpoint: &PCPCheckpoint, ) -> CellstateResult<RecoveryResult>
Sourcepub fn get_latest_checkpoint(&self, scope_id: ScopeId) -> Option<&PCPCheckpoint>
pub fn get_latest_checkpoint(&self, scope_id: ScopeId) -> Option<&PCPCheckpoint>
Sourcepub fn get_checkpoints_for_scope(
&self,
scope_id: ScopeId,
) -> Vec<&PCPCheckpoint>
pub fn get_checkpoints_for_scope( &self, scope_id: ScopeId, ) -> Vec<&PCPCheckpoint>
Sourcepub fn delete_checkpoint(&mut self, checkpoint_id: Uuid) -> bool
pub fn delete_checkpoint(&mut self, checkpoint_id: Uuid) -> bool
Sourcepub fn clear_checkpoints_for_scope(&mut self, scope_id: ScopeId) -> usize
pub fn clear_checkpoints_for_scope(&mut self, scope_id: ScopeId) -> usize
Source§impl PCPRuntime
impl PCPRuntime
Sourcepub fn check_summarization_triggers(
&self,
scope: &Scope,
turn_count: i32,
artifact_count: i32,
policies: &[SummarizationPolicy],
) -> CellstateResult<Vec<(SummarizationPolicyId, SummarizationTrigger)>>
pub fn check_summarization_triggers( &self, scope: &Scope, turn_count: i32, artifact_count: i32, policies: &[SummarizationPolicy], ) -> CellstateResult<Vec<(SummarizationPolicyId, SummarizationTrigger)>>
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 forturn_count- Number of turns in the scopeartifact_count- Number of artifacts in the scopepolicies- 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
}Sourcepub fn get_abstraction_transition(
&self,
policy: &SummarizationPolicy,
) -> (AbstractionLevel, AbstractionLevel)
pub fn get_abstraction_transition( &self, policy: &SummarizationPolicy, ) -> (AbstractionLevel, AbstractionLevel)
Sourcepub fn validate_abstraction_transition(
&self,
source: AbstractionLevel,
target: AbstractionLevel,
) -> bool
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 leveltarget- Target abstraction level
§Returns
true if the transition is valid
Trait Implementations§
Source§impl Clone for PCPRuntime
impl Clone for PCPRuntime
Source§fn clone(&self) -> PCPRuntime
fn clone(&self) -> PCPRuntime
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more