Portal GC — attractor-based graph lifecycle management for persistent knowledge systems
Project description
ProvenanceEngine
Portal GC — attractor-based graph lifecycle management for persistent knowledge systems.
Three-phase architecture that uses the geometry of chaos (Lorenz equations) to decide what your graph remembers and what it forgets:
- Map — graph nodes → Portal initial conditions (x₀, y₀, z₀) based on structural connectivity, association strength, and temporal vitality
- Integrate — RK4 integration per node; classify KEEP / EVICT / REVIEW based on attractor wing residence
- Govern — parameter sweep for stability, LLM probe + gap agents for semantic governance, reports + eviction notices
The attractor's two-wing structure maps to memory dynamics:
- Left wing (x < 0): consolidation / retention
- Right wing (x > 0): decay / eviction candidate
- Chaotic boundary: uncertain — requires review
Install
pip install provenance-engine[all]
The full stack runs locally — no API keys, no network after initial setup.
LLM governance (free, local)
Install Ollama and pull a model:
ollama pull llama3.2
That's it. ProvenanceEngine defaults to Ollama at localhost:11434. No OPENAI_API_KEY needed.
To use a paid provider instead, set OPENAI_API_KEY and install the extra:
pip install provenance-engine[llm]
export OPENAI_API_KEY=sk-...
From source
git clone https://github.com/portalvision/provenance-engine.git
cd provenance-engine
./setup_venv.sh
This creates a .ProvenanceEngine venv with everything installed.
Quick Start
1. Initialize
pe init
Creates .provenance/ with a sample graph.
2. Run a scan
pe scan --graph .provenance/sample_graph.jsonl
Classifies every node as KEEP, EVICT, or REVIEW.
3. Parameter sweep
pe sweep --graph .provenance/sample_graph.jsonl
Tests Portal ρ × τ grid, identifies the governance-stable band (eviction < 30%, zero load-bearing evictions).
4. Generate reports
pe report --classification classification_rho28.0_tau2.0.json
Produces JSON scan, markdown report, and eviction notice.
5. LLM governance
Runs locally via Ollama by default (no API key needed):
pe probe --classification classification_rho28.0_tau2.0.json --graph your_graph.jsonl
pe gap --probe-report probe_report.json
The probe agent reviews each EVICT candidate for structural centrality and governance risk. The gap agent synthesizes into final evict / review / explore / keep buckets.
Override the model: PE_MODEL=llama3.1:8b pe probe ...
6. Semantic search (optional)
Build and query an embedding index over file metadata:
pe chart-build --source repo_vision.json
pe chart-search --index chart_index.jsonl --query "authentication flow"
Graph Format
Input is JSONL, one node per line:
{
"id": "unique_node_id",
"edges": [
{"target": "other_id", "type": "STRUCTURAL", "strength": 0.8}
],
"importance": "high",
"load_bearing": true,
"created_at": "2026-01-01T00:00:00Z",
"metadata": {}
}
Edge types (with default connascence weights):
STRUCTURAL(1.2) — direct structural dependencyCONCEPTUAL(1.0) — conceptual relationshipCO_VARIANCE(0.8) — co-varying propertiesCO_OCCURRENCE(0.6) — co-occurring referencesTEMPORAL(0.4) — temporal associationSUPPORTING(0.8) — supporting evidenceSOURCE(1.0) — source reference
Importance levels: high (1.0), medium (0.6), low (0.2)
Load-bearing: if true, node is escalated from EVICT → REVIEW (never auto-evicted).
Python API
from provenance_engine import build_graph, normalize_and_scale, integrate_portal, classify_node
nodes = [
{"id": "a", "edges": [{"target": "b", "strength": 0.9}], "importance": "high"},
{"id": "b", "edges": [], "importance": "low", "created_at": "2024-01-01T00:00:00Z"},
]
graph = build_graph(nodes)
scaled = normalize_and_scale(graph)
for node in scaled:
traj = integrate_portal(node["x0"], node["y0"], node["z0"])
result = classify_node(traj, tau=2.0, load_bearing=node.get("load_bearing", False))
print(f"{node['id']}: {result['classification']} (mean_x={result['mean_x']:.2f})")
Logging
Every CLI command writes dual-channel logs:
- Console — timestamped, emoji-prefixed, color-coded, scannable
- File — JSON lines at
.provenance/logs/, machine-readable
from provenance_engine import get_logger
log = get_logger("my_scan")
log.info("Classified 42 nodes", emoji="🔍", counts={"KEEP": 30, "EVICT": 5})
log.warn("High eviction rate", emoji="⚠️", evict_pct=0.35)
log.success("Sweep complete", emoji="✅")
log.section("PHASE 2", emoji="🌀")
Emojis are not decoration. They are pre-lexical navigation anchors — the same principle as RAG embeddings, applied to human scanning.
Disable color: NO_COLOR=1 or PE_COLOR=off
Sound Library
Optional audio feedback using Mario × Dark Souls design:
- Mario-style: light, affirming sounds for progress (scan complete, report generated)
- Dark Souls-style: deep, grave sounds for boundaries (eviction blocked, invariant violated)
pe audio-demo # hear all events
pe audio-demo --style mario # just the positive ones
Accessibility (hard constraints):
- Sounds are ALWAYS optional — text + emoji always displayed
- Disable:
PE_AUDIO=off - Volume capped, max 500ms, fails silently if audio unavailable
Drop .wav files into provenance_engine/sounds/ to enable playback. See sounds/README.md for the event-to-file mapping.
from provenance_engine import play, SoundEvent
play(SoundEvent.SCAN_COMPLETE) # Mario: affirming
play(SoundEvent.EVICTION_BLOCKED) # Dark Souls: grave
Verification
pe verify
Runs the full verification suite: tests, sample scan, parameter sweep. Produces a timestamped JSONL log of every step.
Optional Dependencies
| Extra | What it adds | Install |
|---|---|---|
llm |
OpenAI client (for paid LLM providers) | pip install provenance-engine[llm] |
chart |
Semantic search (sentence-transformers) | pip install provenance-engine[chart] |
sim |
Pygame simulation | pip install provenance-engine[sim] |
all |
Everything | pip install provenance-engine[all] |
dev |
All + pytest, ruff, build tools | pip install provenance-engine[dev] |
Note: LLM governance works out of the box with Ollama (free, local) — the llm extra is only needed for paid providers like OpenAI.
How It Works
Portal Initial Conditions
Each node maps to (x₀, y₀, z₀):
- x₀ — structural connectivity (normalized degree in the graph)
- y₀ — connascence strength (weighted mean of edge associations)
- z₀ — temporal vitality (inverse log decay from last update)
RK4 Integration
The Lorenz equations are integrated using 4th-order Runge-Kutta (pure Python, zero dependencies):
dx/dt = σ(y - x) σ = 10
dy/dt = x(ρ - z) - y ρ = tunable (default 28)
dz/dt = xy - βz β = 8/3
Classification
After integration, the mean x-coordinate over the last 200 steps determines fate:
mean_x < -τ→ KEEP (left wing: consolidated memory)mean_x > τ→ EVICT (right wing: decayed, safe to remove)|mean_x| ≤ τ→ REVIEW (chaotic boundary: operator inspection required)
Parameter Sweep
The sweep tests combinations of ρ (eviction pressure) and τ (classification threshold) to find the governance-stable band:
- Total eviction rate < 30%
- High-importance eviction rate < 5%
- Zero load-bearing evictions
LLM Governance
Two-layer LLM review of eviction candidates:
- Probe agent — reviews each Portal EVICT node with graph context; recommends evict/review/explore/keep
- Gap agent — synthesizes probe assessments into final governance decisions
Default: Ollama at localhost:11434 (free, local). Set OPENAI_API_KEY for paid providers.
| Environment Variable | Purpose | Default |
|---|---|---|
PE_MODEL |
Model name | llama3.2 (Ollama) / gpt-4.1 (OpenAI) |
PE_OLLAMA_URL |
Ollama server URL | http://localhost:11434 |
OPENAI_API_KEY |
Switches to OpenAI client | unset |
OPENAI_BASE_URL |
Custom OpenAI-compatible endpoint | unset |
Demo & Simulation
The package includes a demo weather pipeline with a Pygame simulation:
./run_sim.sh
Or manually:
pip install provenance-engine[sim]
python examples/demo-weather/sim/portal_gc_sim.py
14 knowledge graph nodes trace through the Lorenz attractor in real time, classified as KEEP (green), EVICT (red), or REVIEW (amber).
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file provenance_engine-0.2.0.tar.gz.
File metadata
- Download URL: provenance_engine-0.2.0.tar.gz
- Upload date:
- Size: 38.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8bab8b04bd0453186a331ac6f3d15468eb55271f2b607269d8088357d6c64e71
|
|
| MD5 |
f85763848517ebf0e7778c794e9533e6
|
|
| BLAKE2b-256 |
4398a06b15c7a1ac47f89eb0ddf3e53d53efc130cc90f78cce0f76049e78ec3e
|
File details
Details for the file provenance_engine-0.2.0-py3-none-any.whl.
File metadata
- Download URL: provenance_engine-0.2.0-py3-none-any.whl
- Upload date:
- Size: 36.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6b229a984e9889da5f46c2398fe15e0ca6909e5073cb9d857c1015aa758e11e6
|
|
| MD5 |
54b231e7370a44a7248b4430d25eb8d1
|
|
| BLAKE2b-256 |
8387ee7fc8e79b28f88feeff10486cf10ab6f4faa3bf353068924db041ffa8e7
|