Skip to content

Full Loop

kyuchan edited this page Apr 4, 2026 · 1 revision

Full Loop (Phase B-F)

Phase A (principle extraction via the Autonomic Engine) produces initial principles. The Full Loop validates, evolves, and stress-tests them.

Overview

Phase A: Extract principles from data
         │
Phase B: Validate against new data
         │
Phase C: Evolve (strengthen / weaken / refine / drop)
         │
Phase D: Generate predictions
         │
Phase E: Compare predictions to actual outcomes
         │
Phase F: Auto-loop (repeat B→E on new data batches)

Usage

# After Phase A: you have output/results.md
sparks loop \
    --principles output/results.md \
    --data ./new-data/ \
    --cycles 3 \
    --budget 10.0

# With predictions
sparks loop \
    --principles output/results.md \
    --predict "What happens if interest rates rise?" \
    --outcomes "Rates rose 25bp, tech stocks fell 3%"

Phase B: Validate

Tests each principle against new data:

For each principle:
  1. Search new data for supporting evidence
  2. Search for contradicting evidence
  3. Score accuracy (0-1)
  4. Flag if refinement needed

Output: ValidationResult per principle — supported/unsupported, evidence, accuracy.

Phase C: Evolve

Based on validation results:

Validation Action
Strongly supported Strengthen confidence (+0.1, cap 0.95)
Weakly supported Refine statement to match evidence
Unsupported Weaken confidence (-0.15)
Confidence < 0.25 Drop principle

Phase D: Predict

Uses validated principles to generate predictions:

Given these principles + a situation:
  → What should happen next?
  → What is the probability?
  → Which principle supports this prediction?

Output: Prediction objects with principle attribution.

Phase E: Feedback

Compares predictions to actual outcomes:

For each prediction:
  1. Compare to actual outcome (LLM judgment)
  2. Was direction correct? Magnitude?
  3. Update the source principle's confidence

Accurate predictions → strengthen source principle. Wrong predictions → weaken source principle.

PrincipleStore

Principles persist across sessions in ~/.sparks/loop/:

~/.sparks/loop/
  └── {store_name}/
      ├── principles.json
      └── history.json

Each principle tracks:

  • Statement, confidence, supporting patterns
  • Validation history (when tested, result)
  • Prediction accuracy over time

Example

$ sparks loop --principles output/results.md --data ./week2/

⚡ Sparks — Full Loop (B→F)

📊 Loading 12 principles from output/results.md
📊 New data: 8 files (~15K tokens)

Phase B: Validate ━━━━━━━━━━━━━━━━━━━━ 100%
  12/12 principles tested
  10 supported, 2 need refinement

Phase C: Evolve
  ↑ "Information asymmetry drives price" 0.85 → 0.92
  ↑ "Physical constraints create bottleneck" 0.78 → 0.86
  ~ "Market cycles follow cognitive bias" (refined)
  ↓ "Regulatory capture dominates" 0.62 → 0.47

💰 Cost: $1.85
📋 12 principles (avg confidence: 84%)

Clone this wiki locally