Skip to main content

PlanningEngine

Struct PlanningEngine 

Source
pub struct PlanningEngine { /* private fields */ }

Implementations§

Source§

impl PlanningEngine

Source

pub fn open(path: impl AsRef<Path>) -> Result<Self>

Source

pub fn create(path: impl AsRef<Path>) -> Result<Self>

Source

pub fn load(path: impl AsRef<Path>) -> Result<Self>

Source

pub fn save(&mut self) -> Result<()>

Source§

impl PlanningEngine

Source

pub fn calculate_singularity_parallel(&self) -> IntentionSingularity

Compute the intention singularity with pre-filtered active goals.

Optimization over raw get_intention_singularity():

  • Pre-collects active goal references to avoid repeated status checks
  • Short-circuits the empty case (no active goals → empty singularity)
Source

pub fn scan_blockers_parallel(&self) -> Vec<BlockerProphecy>

Scan for blocker prophecies with pre-filtered active goals.

Optimization: pre-computes blocker type frequency histogram once, then runs prediction in a single pass with pre-allocated output.

Source

pub fn progress_echoes_parallel(&self) -> Vec<ProgressEcho>

Detect progress echoes with pre-filtered near-completion goals.

Optimization: only examines goals with progress > 0.5 and momentum > 0.2, skipping the bulk of low-progress goals. Uses the same logic as listen_progress_echoes but with an early-exit filter.

Source

pub fn create_goals_batch( &mut self, requests: Vec<CreateGoalRequest>, ) -> Result<Vec<Goal>>

Create multiple goals in a single batch operation.

Unlike calling create_goal() N times, this:

  1. Validates ALL requests upfront (fail-fast: no partial inserts on error)
  2. Pre-generates IDs and timestamps in one pass
  3. Inserts all goals into the store
  4. Wires parent/child and dependency links
  5. Rebuilds indexes ONCE at the end (not N incremental adds)

Performance: for N=10 goals, avoids 9 redundant index rebuilds. For N=100, the savings are substantial.

Source

pub fn batch_activate_goals(&mut self, ids: &[GoalId]) -> Result<Vec<Goal>>

Activate multiple Draft/Reborn goals in one pass.

Validates all IDs upfront (fail-fast), applies transitions, and calls mark_dirty once at the end.

Source

pub fn batch_progress_goals( &mut self, updates: Vec<(GoalId, f64, Option<String>)>, ) -> Result<Vec<Goal>>

Progress multiple goals at once with batched velocity/momentum recalc.

Each entry is (goal_id, new_percentage, optional_note). Validates all IDs upfront, records progress points, recalculates velocity/momentum/confidence for each, and marks dirty once.

Source

pub fn batch_create_decisions( &mut self, requests: Vec<CreateDecisionRequest>, ) -> Result<Vec<Decision>>

Create multiple decisions in a single batch.

Validates all requests upfront, generates IDs, wires goal links and causal chains, rebuilds indexes once.

Source

pub fn batch_create_commitments( &mut self, requests: Vec<CreateCommitmentRequest>, ) -> Result<Vec<Commitment>>

Create multiple commitments in a single batch.

Validates all requests, generates IDs, calculates weight/inertia/cost for each, wires to goals, and marks dirty once.

Source

pub fn batch_fulfill_commitments( &mut self, fulfillments: Vec<(CommitmentId, String)>, ) -> Result<Vec<Commitment>>

Fulfill multiple commitments in a single pass.

Validates all are Active upfront, calculates chain bonuses, applies fulfillments, and handles entanglement energy release.

Source

pub fn momentum_report_indexed(&self) -> MomentumReport

Momentum report with pre-filtered index-based active goals.

Optimization over get_momentum_report():

  • Uses indexes.goals_by_status to avoid full store scan
  • Same output shape, but skips inactive/completed goals entirely
Source

pub fn gravity_field_indexed(&self) -> GravityField

Gravity field with index-based pre-filtering.

Optimization over get_gravity_field():

  • Uses indexes.goals_by_status to skip inactive goals
  • Computes weighted center and gravity wells in a single pass
Source

pub fn at_risk_commitments_scan(&self) -> Vec<(CommitmentId, Vec<String>)>

Scan all active commitments for at-risk status in one pass.

Returns commitment IDs and their risk signals.

Source

pub fn metamorphosis_scan(&self) -> Vec<MetamorphosisSignal>

Scan all active/blocked goals for metamorphosis signals in one pass.

Returns only goals that should transform, skipping stable ones.

Source

pub fn progress_forecast_batch(&self, ids: &[GoalId]) -> Vec<ProgressForecast>

Progress forecasts for multiple goals at once.

Collects forecasts for all specified goals, returning partial results (skipping not-found goals rather than failing).

Source

pub fn progress_forecast_all_active(&self) -> Vec<ProgressForecast>

Progress forecasts for ALL active goals.

Uses index to identify active goals, then computes forecasts in a single pass. Useful for dashboard views.

Source

pub fn dream_goals_batch(&mut self, ids: &[GoalId]) -> Vec<Result<Dream>>

Dream multiple goals and collect all resulting dreams.

Unlike calling dream_goal N times, this batches the dirty marking. Note: each dream may create child goals if confidence > 0.7.

Source

pub fn federation_health_scan(&self) -> Vec<FederationHealthEntry>

Check health across all federations in one pass.

Returns federation ID, member count, sync freshness, and any issues.

Source

pub fn goal_health_scan(&self) -> GoalHealthReport

Comprehensive health scan across all active goals.

Single-pass check for: stalled goals, neglected goals, goals nearing deadline, blocked goals, and high-momentum goals (opportunities).

Source

pub fn start_consensus( &mut self, decision_id: DecisionId, participants: Vec<ConsensusParticipant>, ) -> Result<DecisionConsensus>

Start a consensus process for a decision with multiple stakeholders.

Validates the decision exists and is in Pending or Deliberating status. Creates a DecisionConsensus record and transitions the decision to Deliberating.

Source

pub fn add_deliberation_round( &mut self, decision_id: DecisionId, statements: Vec<ConsensusStatement>, common_ground: Vec<CommonGround>, ) -> Result<DecisionConsensus>

Add a deliberation round to an active consensus process.

Each round collects statements from stakeholders and identifies common ground. The alignment score is recalculated after each round.

Source

pub fn synthesize_consensus( &mut self, decision_id: DecisionId, proposal: String, incorporates_from: Vec<StakeholderId>, addresses_concerns: Vec<String>, ) -> Result<DecisionConsensus>

Propose a synthesis that attempts to reconcile stakeholder positions.

Source

pub fn record_consensus_vote( &mut self, decision_id: DecisionId, stakeholder_id: StakeholderId, vote: String, ) -> Result<DecisionConsensus>

Record a stakeholder’s vote on the current synthesis.

Source

pub fn get_consensus_status( &self, decision_id: DecisionId, ) -> Result<&DecisionConsensus>

Get the current status of a consensus process.

Source

pub fn crystallize_consensus( &mut self, decision_id: DecisionId, chosen_path: PathId, force: bool, ) -> Result<DecisionConsensus>

Crystallize a consensus decision once alignment is sufficient.

If alignment_score >= 0.5 (or force=true), crystallizes the decision and records the consensus outcome. Otherwise returns Deadlocked.

Source§

impl PlanningEngine

Source

pub fn get_goal(&self, id: GoalId) -> Option<&Goal>

Source

pub fn list_goals(&self, filter: GoalFilter) -> Vec<&Goal>

Source

pub fn get_root_goals(&self) -> Vec<&Goal>

Source

pub fn get_active_goals(&self) -> Vec<&Goal>

Source

pub fn get_blocked_goals(&self) -> Vec<&Goal>

Source

pub fn get_urgent_goals(&self, within_days: f64) -> Vec<&Goal>

Source

pub fn get_goal_tree(&self, root_id: GoalId) -> Option<GoalTree>

Source

pub fn search_goals(&self, query: &str) -> Vec<&Goal>

Source

pub fn get_intention_singularity(&self) -> IntentionSingularity

Source

pub fn get_decision(&self, id: DecisionId) -> Option<&Decision>

Source

pub fn get_decision_chain(&self, id: DecisionId) -> Option<DecisionChain>

Source

pub fn get_shadows(&self, id: DecisionId) -> Vec<&CrystalShadow>

Source

pub fn project_counterfactual( &self, decision_id: DecisionId, path_id: PathId, ) -> Option<CounterfactualProjection>

Source

pub fn decision_archaeology(&self, artifact: &str) -> DecisionArchaeology

Source

pub fn get_commitment(&self, id: CommitmentId) -> Option<&Commitment>

Source

pub fn get_dream(&self, id: DreamId) -> Option<&Dream>

Source

pub fn list_dreams(&self) -> Vec<&Dream>

Source

pub fn list_goal_dreams(&self, goal_id: GoalId) -> Vec<&Dream>

Source

pub fn list_decisions(&self) -> Vec<&Decision>

Source

pub fn list_commitments(&self) -> Vec<&Commitment>

Source

pub fn get_due_soon(&self, within_days: f64) -> Vec<&Commitment>

Source

pub fn get_commitment_inventory(&self) -> CommitmentInventory

Source

pub fn get_at_risk_commitments(&self) -> Vec<&Commitment>

Source

pub fn get_federation(&self, id: FederationId) -> Option<&Federation>

Source

pub fn list_federations(&self) -> Vec<&Federation>

Source

pub fn get_federation_members( &self, id: FederationId, ) -> Option<Vec<FederationMember>>

Source

pub fn scan_blocker_prophecy(&self) -> Vec<BlockerProphecy>

Source

pub fn listen_progress_echoes(&self) -> Vec<ProgressEcho>

Source

pub fn get_decision_prophecy( &self, question: &str, options: &[DecisionPath], ) -> DecisionProphecy

Source

pub fn search_decisions(&self, query: &str) -> Vec<Decision>

Source

pub fn get_progress_forecast(&self, id: GoalId) -> Result<ProgressForecast>

Source

pub fn get_momentum_report(&self) -> MomentumReport

Source

pub fn get_gravity_field(&self) -> GravityField

Source§

impl PlanningEngine

Source

pub fn validate_create_goal( &self, request: &CreateGoalRequest, ) -> ValidationResult<()>

Source

pub fn validate_status_transition( &self, current: GoalStatus, target: GoalStatus, ) -> ValidationResult<()>

Source

pub fn validate_create_decision( &self, request: &CreateDecisionRequest, ) -> ValidationResult<()>

Source

pub fn validate_crystallize(&self, decision: &Decision) -> ValidationResult<()>

Source

pub fn validate_no_self_dependency( &self, goal_id: GoalId, dependencies: &[GoalId], ) -> ValidationResult<()>

R4: Validate that a goal does not depend on itself

Source

pub fn validate_create_dream( &self, scenarios_count: usize, ) -> ValidationResult<()>

R4: Validate dream creation — at least 1 scenario required

Source

pub fn validate_create_federation( &self, member_count: usize, ) -> ValidationResult<()>

R4: Validate federation creation — at least 2 members required

Source

pub fn validate_create_commitment( &self, request: &CreateCommitmentRequest, ) -> ValidationResult<()>

Source§

impl PlanningEngine

Source

pub fn create_goal(&mut self, request: CreateGoalRequest) -> Result<Goal>

Source

pub fn activate_goal(&mut self, id: GoalId) -> Result<Goal>

Source

pub fn pause_goal(&mut self, id: GoalId, reason: Option<String>) -> Result<Goal>

Source

pub fn resume_goal(&mut self, id: GoalId) -> Result<Goal>

Source

pub fn progress_goal( &mut self, id: GoalId, percentage: f64, note: Option<String>, ) -> Result<Goal>

Source

pub fn complete_goal( &mut self, id: GoalId, note: Option<String>, ) -> Result<Goal>

Source

pub fn abandon_goal(&mut self, id: GoalId, reason: String) -> Result<Goal>

Source

pub fn reincarnate_goal( &mut self, original_id: GoalId, updates: ReincarnationUpdates, ) -> Result<Goal>

Source

pub fn decompose_goal( &mut self, id: GoalId, sub_goals: Vec<CreateGoalRequest>, ) -> Result<Vec<Goal>>

Source

pub fn block_goal(&mut self, id: GoalId, blocker: Blocker) -> Result<Goal>

Source

pub fn unblock_goal( &mut self, id: GoalId, blocker_id: Uuid, resolution: String, ) -> Result<Goal>

Source

pub fn create_decision( &mut self, request: CreateDecisionRequest, ) -> Result<Decision>

Source

pub fn add_option( &mut self, id: DecisionId, path: DecisionPath, ) -> Result<Decision>

Source

pub fn crystallize( &mut self, id: DecisionId, chosen_path_id: PathId, reasoning: DecisionReasoning, ) -> Result<Decision>

Source

pub fn record_consequence( &mut self, id: DecisionId, consequence: Consequence, ) -> Result<Decision>

Source

pub fn recrystallize( &mut self, id: DecisionId, new_path_id: PathId, reason: String, ) -> Result<Decision>

Source

pub fn create_commitment( &mut self, request: CreateCommitmentRequest, ) -> Result<Commitment>

Source

pub fn fulfill_commitment( &mut self, id: CommitmentId, how_delivered: String, ) -> Result<Commitment>

Source

pub fn break_commitment( &mut self, id: CommitmentId, reason: String, ) -> Result<Commitment>

Source

pub fn renegotiate_commitment( &mut self, id: CommitmentId, new_promise: Promise, reason: String, ) -> Result<Commitment>

Source

pub fn entangle_commitments( &mut self, a: CommitmentId, b: CommitmentId, entanglement_type: EntanglementType, strength: f64, ) -> Result<()>

Source

pub fn dream_goal(&mut self, id: GoalId) -> Result<Dream>

Source

pub fn create_federation( &mut self, goal_id: GoalId, agent_id: String, coordinator: Option<String>, ) -> Result<Federation>

Source

pub fn join_federation( &mut self, federation_id: FederationId, agent_id: String, ) -> Result<Federation>

Source

pub fn sync_federation( &mut self, federation_id: FederationId, ) -> Result<Federation>

Source

pub fn handoff_federation( &mut self, federation_id: FederationId, next_coordinator: String, ) -> Result<Federation>

Source

pub fn detect_metamorphosis( &self, goal_id: GoalId, ) -> Result<MetamorphosisSignal>

Source

pub fn approve_metamorphosis( &mut self, goal_id: GoalId, stage_title: String, stage_description: String, change: ScopeChange, ) -> Result<Goal>

Source

pub fn metamorphosis_history( &self, goal_id: GoalId, ) -> Result<Vec<MetamorphicStage>>

Source

pub fn predict_metamorphosis( &self, goal_id: GoalId, ) -> Result<MetamorphosisPrediction>

Source

pub fn metamorphosis_stage( &self, goal_id: GoalId, ) -> Result<Option<MetamorphicStage>>

Source

pub fn merge_from(&mut self, source: &PlanningEngine) -> MergeReport

Source

pub fn update_goal( &mut self, id: GoalId, updates: UpdateGoalRequest, ) -> Result<Goal>

Source

pub fn update_regret(&mut self, id: DecisionId) -> Result<Decision>

Source

pub fn record_insight( &mut self, dream_id: DreamId, insight: DreamInsight, ) -> Result<Dream>

Source

pub fn assess_accuracy( &mut self, dream_id: DreamId, accuracy: DreamAccuracy, ) -> Result<Dream>

Source

pub fn update_momentum(&mut self, id: GoalId) -> Result<Goal>

Source

pub fn update_gravity(&mut self, id: GoalId) -> Result<Goal>

Source

pub fn update_feelings(&mut self, id: GoalId) -> Result<Goal>

Source

pub fn update_commitment( &mut self, id: CommitmentId, updates: UpdateCommitmentRequest, ) -> Result<Commitment>

Source

pub fn validate(&self) -> Vec<String>

Source§

impl PlanningEngine

Source

pub fn in_memory() -> Self

Source

pub fn goal_count(&self) -> usize

Source

pub fn decision_count(&self) -> usize

Source

pub fn commitment_count(&self) -> usize

Source

pub fn session_id(&self) -> Uuid

Source

pub fn audit_log_mut(&mut self) -> &mut AuditLog

Source

pub fn goals(&self) -> impl Iterator<Item = &Goal>

Iterate over all goals (for ghost bridge context).

Source

pub fn decisions(&self) -> impl Iterator<Item = &Decision>

Iterate over all decisions (for ghost bridge context).

Source

pub fn commitments(&self) -> impl Iterator<Item = &Commitment>

Iterate over all commitments (for ghost bridge context).

Trait Implementations§

Source§

impl Clone for PlanningEngine

Source§

fn clone(&self) -> PlanningEngine

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for PlanningEngine

Source§

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

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.

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.

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.