Skip to main content

run_democritus_loop

Function run_democritus_loop 

Source
pub async fn run_democritus_loop(
    tick: Arc<CognitiveTick>,
    causal: Arc<CausalGraph>,
    hnsw: Arc<HnswService>,
    eml: Arc<Mutex<EmlCoherenceModel>>,
)
Expand description

Run the DEMOCRITUS two-tier coherence loop.

This is spawned as a background tokio task during kernel boot. On every cognitive tick it performs:

  1. SENSE – gather cheap graph metadata (node/edge counts).
  2. THINK (fast) – O(1) EML coherence prediction.
  3. DETECT DRIFT – compare prediction against last exact value.
  4. THINK (exact) – O(k*m) Lanczos spectral analysis (only when drift exceeds threshold, or periodically to maintain calibration).
  5. LOG – drain EML events and append to ExoChain.
  6. COMMIT – record timing in the adaptive tick system.

The EML model is retrained periodically from accumulated exact samples so the fast path becomes more accurate over time.