provenance-engine 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- provenance_engine-0.1.0/LICENSE +21 -0
- provenance_engine-0.1.0/PKG-INFO +287 -0
- provenance_engine-0.1.0/README.md +246 -0
- provenance_engine-0.1.0/pyproject.toml +75 -0
- provenance_engine-0.1.0/setup.cfg +4 -0
- provenance_engine-0.1.0/src/provenance_engine/__init__.py +37 -0
- provenance_engine-0.1.0/src/provenance_engine/audio.py +261 -0
- provenance_engine-0.1.0/src/provenance_engine/chart.py +291 -0
- provenance_engine-0.1.0/src/provenance_engine/cli.py +401 -0
- provenance_engine-0.1.0/src/provenance_engine/gap.py +111 -0
- provenance_engine-0.1.0/src/provenance_engine/graph.py +222 -0
- provenance_engine-0.1.0/src/provenance_engine/llm.py +67 -0
- provenance_engine-0.1.0/src/provenance_engine/log.py +205 -0
- provenance_engine-0.1.0/src/provenance_engine/portal.py +115 -0
- provenance_engine-0.1.0/src/provenance_engine/probe.py +140 -0
- provenance_engine-0.1.0/src/provenance_engine/report.py +142 -0
- provenance_engine-0.1.0/src/provenance_engine/sounds/README.md +46 -0
- provenance_engine-0.1.0/src/provenance_engine/sweep.py +143 -0
- provenance_engine-0.1.0/src/provenance_engine.egg-info/PKG-INFO +287 -0
- provenance_engine-0.1.0/src/provenance_engine.egg-info/SOURCES.txt +25 -0
- provenance_engine-0.1.0/src/provenance_engine.egg-info/dependency_links.txt +1 -0
- provenance_engine-0.1.0/src/provenance_engine.egg-info/entry_points.txt +3 -0
- provenance_engine-0.1.0/src/provenance_engine.egg-info/requires.txt +22 -0
- provenance_engine-0.1.0/src/provenance_engine.egg-info/top_level.txt +1 -0
- provenance_engine-0.1.0/tests/test_audio.py +121 -0
- provenance_engine-0.1.0/tests/test_log.py +106 -0
- provenance_engine-0.1.0/tests/test_portal.py +198 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 PortalVision
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: provenance-engine
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Portal GC — attractor-based graph lifecycle management for persistent knowledge systems
|
|
5
|
+
Author-email: PortalVision <provenance@portalvision.dev>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/portalvision/provenance-engine
|
|
8
|
+
Project-URL: Repository, https://github.com/portalvision/provenance-engine
|
|
9
|
+
Project-URL: Documentation, https://github.com/portalvision/provenance-engine#readme
|
|
10
|
+
Keywords: graph,portal-gc,garbage-collection,knowledge-graph,llm,persistence,lorenz
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Topic :: Scientific/Engineering
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
20
|
+
Requires-Python: >=3.10
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Requires-Dist: click>=8.0
|
|
24
|
+
Provides-Extra: llm
|
|
25
|
+
Requires-Dist: openai>=1.0; extra == "llm"
|
|
26
|
+
Provides-Extra: chart
|
|
27
|
+
Requires-Dist: numpy>=1.24; extra == "chart"
|
|
28
|
+
Requires-Dist: sentence-transformers>=2.2; extra == "chart"
|
|
29
|
+
Provides-Extra: sim
|
|
30
|
+
Requires-Dist: pygame>=2.5; extra == "sim"
|
|
31
|
+
Provides-Extra: all
|
|
32
|
+
Requires-Dist: provenance-engine[chart,llm,sim]; extra == "all"
|
|
33
|
+
Provides-Extra: dev
|
|
34
|
+
Requires-Dist: provenance-engine[all]; extra == "dev"
|
|
35
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
36
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
37
|
+
Requires-Dist: ruff; extra == "dev"
|
|
38
|
+
Requires-Dist: build; extra == "dev"
|
|
39
|
+
Requires-Dist: twine; extra == "dev"
|
|
40
|
+
Dynamic: license-file
|
|
41
|
+
|
|
42
|
+
# ProvenanceEngine
|
|
43
|
+
|
|
44
|
+
Portal GC — attractor-based graph lifecycle management for persistent knowledge systems.
|
|
45
|
+
|
|
46
|
+
Three-phase architecture that uses the geometry of chaos (Lorenz equations) to decide what your graph remembers and what it forgets:
|
|
47
|
+
|
|
48
|
+
1. **Map** — graph nodes → Portal initial conditions (x₀, y₀, z₀) based on structural connectivity, association strength, and temporal vitality
|
|
49
|
+
2. **Integrate** — RK4 integration per node; classify KEEP / EVICT / REVIEW based on attractor wing residence
|
|
50
|
+
3. **Govern** — parameter sweep for stability, LLM probe + gap agents for semantic governance, reports + eviction notices
|
|
51
|
+
|
|
52
|
+
The attractor's two-wing structure maps to memory dynamics:
|
|
53
|
+
- **Left wing** (x < 0): consolidation / retention
|
|
54
|
+
- **Right wing** (x > 0): decay / eviction candidate
|
|
55
|
+
- **Chaotic boundary**: uncertain — requires review
|
|
56
|
+
|
|
57
|
+
## Install
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
pip install provenance-engine
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Or with all optional dependencies (LLM governance + semantic search):
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
pip install provenance-engine[all]
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### From source
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
git clone https://github.com/portalvision/provenance-engine.git
|
|
73
|
+
cd provenance-engine
|
|
74
|
+
./setup_venv.sh
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
This creates a `.ProvenanceEngine` venv with everything installed.
|
|
78
|
+
|
|
79
|
+
## Quick Start
|
|
80
|
+
|
|
81
|
+
### 1. Initialize
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
pe init
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Creates `.provenance/` with a sample graph.
|
|
88
|
+
|
|
89
|
+
### 2. Run a scan
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
pe scan --graph .provenance/sample_graph.jsonl
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Classifies every node as KEEP, EVICT, or REVIEW.
|
|
96
|
+
|
|
97
|
+
### 3. Parameter sweep
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
pe sweep --graph .provenance/sample_graph.jsonl
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Tests Portal ρ × τ grid, identifies the governance-stable band (eviction < 30%, zero load-bearing evictions).
|
|
104
|
+
|
|
105
|
+
### 4. Generate reports
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
pe report --classification classification_rho28.0_tau2.0.json
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Produces JSON scan, markdown report, and eviction notice.
|
|
112
|
+
|
|
113
|
+
### 5. LLM governance (optional)
|
|
114
|
+
|
|
115
|
+
Requires `OPENAI_API_KEY` in your environment:
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
pe probe --classification classification_rho28.0_tau2.0.json --graph your_graph.jsonl
|
|
119
|
+
pe gap --probe-report probe_report.json
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
The probe agent reviews each EVICT candidate for structural centrality and governance risk. The gap agent synthesizes into final evict / review / explore / keep buckets.
|
|
123
|
+
|
|
124
|
+
### 6. Semantic search (optional)
|
|
125
|
+
|
|
126
|
+
Build and query an embedding index over file metadata:
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
pe chart-build --source repo_vision.json
|
|
130
|
+
pe chart-search --index chart_index.jsonl --query "authentication flow"
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## Graph Format
|
|
134
|
+
|
|
135
|
+
Input is JSONL, one node per line:
|
|
136
|
+
|
|
137
|
+
```json
|
|
138
|
+
{
|
|
139
|
+
"id": "unique_node_id",
|
|
140
|
+
"edges": [
|
|
141
|
+
{"target": "other_id", "type": "STRUCTURAL", "strength": 0.8}
|
|
142
|
+
],
|
|
143
|
+
"importance": "high",
|
|
144
|
+
"load_bearing": true,
|
|
145
|
+
"created_at": "2026-01-01T00:00:00Z",
|
|
146
|
+
"metadata": {}
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
**Edge types** (with default connascence weights):
|
|
151
|
+
- `STRUCTURAL` (1.2) — direct structural dependency
|
|
152
|
+
- `CONCEPTUAL` (1.0) — conceptual relationship
|
|
153
|
+
- `CO_VARIANCE` (0.8) — co-varying properties
|
|
154
|
+
- `CO_OCCURRENCE` (0.6) — co-occurring references
|
|
155
|
+
- `TEMPORAL` (0.4) — temporal association
|
|
156
|
+
- `SUPPORTING` (0.8) — supporting evidence
|
|
157
|
+
- `SOURCE` (1.0) — source reference
|
|
158
|
+
|
|
159
|
+
**Importance levels**: `high` (1.0), `medium` (0.6), `low` (0.2)
|
|
160
|
+
|
|
161
|
+
**Load-bearing**: if `true`, node is escalated from EVICT → REVIEW (never auto-evicted).
|
|
162
|
+
|
|
163
|
+
## Python API
|
|
164
|
+
|
|
165
|
+
```python
|
|
166
|
+
from provenance_engine import build_graph, normalize_and_scale, integrate_portal, classify_node
|
|
167
|
+
|
|
168
|
+
nodes = [
|
|
169
|
+
{"id": "a", "edges": [{"target": "b", "strength": 0.9}], "importance": "high"},
|
|
170
|
+
{"id": "b", "edges": [], "importance": "low", "created_at": "2024-01-01T00:00:00Z"},
|
|
171
|
+
]
|
|
172
|
+
|
|
173
|
+
graph = build_graph(nodes)
|
|
174
|
+
scaled = normalize_and_scale(graph)
|
|
175
|
+
|
|
176
|
+
for node in scaled:
|
|
177
|
+
traj = integrate_portal(node["x0"], node["y0"], node["z0"])
|
|
178
|
+
result = classify_node(traj, tau=2.0, load_bearing=node.get("load_bearing", False))
|
|
179
|
+
print(f"{node['id']}: {result['classification']} (mean_x={result['mean_x']:.2f})")
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## Logging
|
|
183
|
+
|
|
184
|
+
Every CLI command writes dual-channel logs:
|
|
185
|
+
|
|
186
|
+
1. **Console** — timestamped, emoji-prefixed, color-coded, scannable
|
|
187
|
+
2. **File** — JSON lines at `.provenance/logs/`, machine-readable
|
|
188
|
+
|
|
189
|
+
```python
|
|
190
|
+
from provenance_engine import get_logger
|
|
191
|
+
|
|
192
|
+
log = get_logger("my_scan")
|
|
193
|
+
log.info("Classified 42 nodes", emoji="🔍", counts={"KEEP": 30, "EVICT": 5})
|
|
194
|
+
log.warn("High eviction rate", emoji="⚠️", evict_pct=0.35)
|
|
195
|
+
log.success("Sweep complete", emoji="✅")
|
|
196
|
+
log.section("PHASE 2", emoji="🌀")
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
Emojis are not decoration. They are pre-lexical navigation anchors — the same principle as RAG embeddings, applied to human scanning.
|
|
200
|
+
|
|
201
|
+
Disable color: `NO_COLOR=1` or `PE_COLOR=off`
|
|
202
|
+
|
|
203
|
+
## Sound Library
|
|
204
|
+
|
|
205
|
+
Optional audio feedback using Mario × Dark Souls design:
|
|
206
|
+
|
|
207
|
+
- **Mario-style**: light, affirming sounds for progress (scan complete, report generated)
|
|
208
|
+
- **Dark Souls-style**: deep, grave sounds for boundaries (eviction blocked, invariant violated)
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
pe audio-demo # hear all events
|
|
212
|
+
pe audio-demo --style mario # just the positive ones
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
**Accessibility (hard constraints):**
|
|
216
|
+
- Sounds are ALWAYS optional — text + emoji always displayed
|
|
217
|
+
- Disable: `PE_AUDIO=off`
|
|
218
|
+
- Volume capped, max 500ms, fails silently if audio unavailable
|
|
219
|
+
|
|
220
|
+
Drop `.wav` files into `provenance_engine/sounds/` to enable playback. See `sounds/README.md` for the event-to-file mapping.
|
|
221
|
+
|
|
222
|
+
```python
|
|
223
|
+
from provenance_engine import play, SoundEvent
|
|
224
|
+
|
|
225
|
+
play(SoundEvent.SCAN_COMPLETE) # Mario: affirming
|
|
226
|
+
play(SoundEvent.EVICTION_BLOCKED) # Dark Souls: grave
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
## Verification
|
|
230
|
+
|
|
231
|
+
```bash
|
|
232
|
+
pe verify
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
Runs the full verification suite: tests, sample scan, parameter sweep. Produces a timestamped JSONL log of every step.
|
|
236
|
+
|
|
237
|
+
## Optional Dependencies
|
|
238
|
+
|
|
239
|
+
| Extra | What it adds | Install |
|
|
240
|
+
|-------|-------------|---------|
|
|
241
|
+
| `llm` | LLM governance agents (probe + gap) | `pip install provenance-engine[llm]` |
|
|
242
|
+
| `chart` | Semantic search (sentence-transformers) | `pip install provenance-engine[chart]` |
|
|
243
|
+
| `all` | Everything | `pip install provenance-engine[all]` |
|
|
244
|
+
| `dev` | All + pytest, ruff, build tools | `pip install provenance-engine[dev]` |
|
|
245
|
+
|
|
246
|
+
## How It Works
|
|
247
|
+
|
|
248
|
+
### Portal Initial Conditions
|
|
249
|
+
|
|
250
|
+
Each node maps to (x₀, y₀, z₀):
|
|
251
|
+
- **x₀** — structural connectivity (normalized degree in the graph)
|
|
252
|
+
- **y₀** — connascence strength (weighted mean of edge associations)
|
|
253
|
+
- **z₀** — temporal vitality (inverse log decay from last update)
|
|
254
|
+
|
|
255
|
+
### RK4 Integration
|
|
256
|
+
|
|
257
|
+
The Lorenz equations are integrated using 4th-order Runge-Kutta (pure Python, zero dependencies):
|
|
258
|
+
|
|
259
|
+
```
|
|
260
|
+
dx/dt = σ(y - x) σ = 10
|
|
261
|
+
dy/dt = x(ρ - z) - y ρ = tunable (default 28)
|
|
262
|
+
dz/dt = xy - βz β = 8/3
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
### Classification
|
|
266
|
+
|
|
267
|
+
After integration, the mean x-coordinate over the last 200 steps determines fate:
|
|
268
|
+
- `mean_x < -τ` → **KEEP** (left wing: consolidated memory)
|
|
269
|
+
- `mean_x > τ` → **EVICT** (right wing: decayed, safe to remove)
|
|
270
|
+
- `|mean_x| ≤ τ` → **REVIEW** (chaotic boundary: operator inspection required)
|
|
271
|
+
|
|
272
|
+
### Parameter Sweep
|
|
273
|
+
|
|
274
|
+
The sweep tests combinations of ρ (eviction pressure) and τ (classification threshold) to find the governance-stable band:
|
|
275
|
+
- Total eviction rate < 30%
|
|
276
|
+
- High-importance eviction rate < 5%
|
|
277
|
+
- Zero load-bearing evictions
|
|
278
|
+
|
|
279
|
+
### LLM Governance
|
|
280
|
+
|
|
281
|
+
Two-layer LLM review of eviction candidates:
|
|
282
|
+
1. **Probe agent** — reviews each Portal EVICT node with graph context; recommends evict/review/explore/keep
|
|
283
|
+
2. **Gap agent** — synthesizes probe assessments into final governance decisions
|
|
284
|
+
|
|
285
|
+
## License
|
|
286
|
+
|
|
287
|
+
MIT
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
# ProvenanceEngine
|
|
2
|
+
|
|
3
|
+
Portal GC — attractor-based graph lifecycle management for persistent knowledge systems.
|
|
4
|
+
|
|
5
|
+
Three-phase architecture that uses the geometry of chaos (Lorenz equations) to decide what your graph remembers and what it forgets:
|
|
6
|
+
|
|
7
|
+
1. **Map** — graph nodes → Portal initial conditions (x₀, y₀, z₀) based on structural connectivity, association strength, and temporal vitality
|
|
8
|
+
2. **Integrate** — RK4 integration per node; classify KEEP / EVICT / REVIEW based on attractor wing residence
|
|
9
|
+
3. **Govern** — parameter sweep for stability, LLM probe + gap agents for semantic governance, reports + eviction notices
|
|
10
|
+
|
|
11
|
+
The attractor's two-wing structure maps to memory dynamics:
|
|
12
|
+
- **Left wing** (x < 0): consolidation / retention
|
|
13
|
+
- **Right wing** (x > 0): decay / eviction candidate
|
|
14
|
+
- **Chaotic boundary**: uncertain — requires review
|
|
15
|
+
|
|
16
|
+
## Install
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pip install provenance-engine
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Or with all optional dependencies (LLM governance + semantic search):
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pip install provenance-engine[all]
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### From source
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
git clone https://github.com/portalvision/provenance-engine.git
|
|
32
|
+
cd provenance-engine
|
|
33
|
+
./setup_venv.sh
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
This creates a `.ProvenanceEngine` venv with everything installed.
|
|
37
|
+
|
|
38
|
+
## Quick Start
|
|
39
|
+
|
|
40
|
+
### 1. Initialize
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
pe init
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Creates `.provenance/` with a sample graph.
|
|
47
|
+
|
|
48
|
+
### 2. Run a scan
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
pe scan --graph .provenance/sample_graph.jsonl
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Classifies every node as KEEP, EVICT, or REVIEW.
|
|
55
|
+
|
|
56
|
+
### 3. Parameter sweep
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
pe sweep --graph .provenance/sample_graph.jsonl
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Tests Portal ρ × τ grid, identifies the governance-stable band (eviction < 30%, zero load-bearing evictions).
|
|
63
|
+
|
|
64
|
+
### 4. Generate reports
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
pe report --classification classification_rho28.0_tau2.0.json
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Produces JSON scan, markdown report, and eviction notice.
|
|
71
|
+
|
|
72
|
+
### 5. LLM governance (optional)
|
|
73
|
+
|
|
74
|
+
Requires `OPENAI_API_KEY` in your environment:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
pe probe --classification classification_rho28.0_tau2.0.json --graph your_graph.jsonl
|
|
78
|
+
pe gap --probe-report probe_report.json
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
The probe agent reviews each EVICT candidate for structural centrality and governance risk. The gap agent synthesizes into final evict / review / explore / keep buckets.
|
|
82
|
+
|
|
83
|
+
### 6. Semantic search (optional)
|
|
84
|
+
|
|
85
|
+
Build and query an embedding index over file metadata:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
pe chart-build --source repo_vision.json
|
|
89
|
+
pe chart-search --index chart_index.jsonl --query "authentication flow"
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Graph Format
|
|
93
|
+
|
|
94
|
+
Input is JSONL, one node per line:
|
|
95
|
+
|
|
96
|
+
```json
|
|
97
|
+
{
|
|
98
|
+
"id": "unique_node_id",
|
|
99
|
+
"edges": [
|
|
100
|
+
{"target": "other_id", "type": "STRUCTURAL", "strength": 0.8}
|
|
101
|
+
],
|
|
102
|
+
"importance": "high",
|
|
103
|
+
"load_bearing": true,
|
|
104
|
+
"created_at": "2026-01-01T00:00:00Z",
|
|
105
|
+
"metadata": {}
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
**Edge types** (with default connascence weights):
|
|
110
|
+
- `STRUCTURAL` (1.2) — direct structural dependency
|
|
111
|
+
- `CONCEPTUAL` (1.0) — conceptual relationship
|
|
112
|
+
- `CO_VARIANCE` (0.8) — co-varying properties
|
|
113
|
+
- `CO_OCCURRENCE` (0.6) — co-occurring references
|
|
114
|
+
- `TEMPORAL` (0.4) — temporal association
|
|
115
|
+
- `SUPPORTING` (0.8) — supporting evidence
|
|
116
|
+
- `SOURCE` (1.0) — source reference
|
|
117
|
+
|
|
118
|
+
**Importance levels**: `high` (1.0), `medium` (0.6), `low` (0.2)
|
|
119
|
+
|
|
120
|
+
**Load-bearing**: if `true`, node is escalated from EVICT → REVIEW (never auto-evicted).
|
|
121
|
+
|
|
122
|
+
## Python API
|
|
123
|
+
|
|
124
|
+
```python
|
|
125
|
+
from provenance_engine import build_graph, normalize_and_scale, integrate_portal, classify_node
|
|
126
|
+
|
|
127
|
+
nodes = [
|
|
128
|
+
{"id": "a", "edges": [{"target": "b", "strength": 0.9}], "importance": "high"},
|
|
129
|
+
{"id": "b", "edges": [], "importance": "low", "created_at": "2024-01-01T00:00:00Z"},
|
|
130
|
+
]
|
|
131
|
+
|
|
132
|
+
graph = build_graph(nodes)
|
|
133
|
+
scaled = normalize_and_scale(graph)
|
|
134
|
+
|
|
135
|
+
for node in scaled:
|
|
136
|
+
traj = integrate_portal(node["x0"], node["y0"], node["z0"])
|
|
137
|
+
result = classify_node(traj, tau=2.0, load_bearing=node.get("load_bearing", False))
|
|
138
|
+
print(f"{node['id']}: {result['classification']} (mean_x={result['mean_x']:.2f})")
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Logging
|
|
142
|
+
|
|
143
|
+
Every CLI command writes dual-channel logs:
|
|
144
|
+
|
|
145
|
+
1. **Console** — timestamped, emoji-prefixed, color-coded, scannable
|
|
146
|
+
2. **File** — JSON lines at `.provenance/logs/`, machine-readable
|
|
147
|
+
|
|
148
|
+
```python
|
|
149
|
+
from provenance_engine import get_logger
|
|
150
|
+
|
|
151
|
+
log = get_logger("my_scan")
|
|
152
|
+
log.info("Classified 42 nodes", emoji="🔍", counts={"KEEP": 30, "EVICT": 5})
|
|
153
|
+
log.warn("High eviction rate", emoji="⚠️", evict_pct=0.35)
|
|
154
|
+
log.success("Sweep complete", emoji="✅")
|
|
155
|
+
log.section("PHASE 2", emoji="🌀")
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Emojis are not decoration. They are pre-lexical navigation anchors — the same principle as RAG embeddings, applied to human scanning.
|
|
159
|
+
|
|
160
|
+
Disable color: `NO_COLOR=1` or `PE_COLOR=off`
|
|
161
|
+
|
|
162
|
+
## Sound Library
|
|
163
|
+
|
|
164
|
+
Optional audio feedback using Mario × Dark Souls design:
|
|
165
|
+
|
|
166
|
+
- **Mario-style**: light, affirming sounds for progress (scan complete, report generated)
|
|
167
|
+
- **Dark Souls-style**: deep, grave sounds for boundaries (eviction blocked, invariant violated)
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
pe audio-demo # hear all events
|
|
171
|
+
pe audio-demo --style mario # just the positive ones
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
**Accessibility (hard constraints):**
|
|
175
|
+
- Sounds are ALWAYS optional — text + emoji always displayed
|
|
176
|
+
- Disable: `PE_AUDIO=off`
|
|
177
|
+
- Volume capped, max 500ms, fails silently if audio unavailable
|
|
178
|
+
|
|
179
|
+
Drop `.wav` files into `provenance_engine/sounds/` to enable playback. See `sounds/README.md` for the event-to-file mapping.
|
|
180
|
+
|
|
181
|
+
```python
|
|
182
|
+
from provenance_engine import play, SoundEvent
|
|
183
|
+
|
|
184
|
+
play(SoundEvent.SCAN_COMPLETE) # Mario: affirming
|
|
185
|
+
play(SoundEvent.EVICTION_BLOCKED) # Dark Souls: grave
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
## Verification
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
pe verify
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
Runs the full verification suite: tests, sample scan, parameter sweep. Produces a timestamped JSONL log of every step.
|
|
195
|
+
|
|
196
|
+
## Optional Dependencies
|
|
197
|
+
|
|
198
|
+
| Extra | What it adds | Install |
|
|
199
|
+
|-------|-------------|---------|
|
|
200
|
+
| `llm` | LLM governance agents (probe + gap) | `pip install provenance-engine[llm]` |
|
|
201
|
+
| `chart` | Semantic search (sentence-transformers) | `pip install provenance-engine[chart]` |
|
|
202
|
+
| `all` | Everything | `pip install provenance-engine[all]` |
|
|
203
|
+
| `dev` | All + pytest, ruff, build tools | `pip install provenance-engine[dev]` |
|
|
204
|
+
|
|
205
|
+
## How It Works
|
|
206
|
+
|
|
207
|
+
### Portal Initial Conditions
|
|
208
|
+
|
|
209
|
+
Each node maps to (x₀, y₀, z₀):
|
|
210
|
+
- **x₀** — structural connectivity (normalized degree in the graph)
|
|
211
|
+
- **y₀** — connascence strength (weighted mean of edge associations)
|
|
212
|
+
- **z₀** — temporal vitality (inverse log decay from last update)
|
|
213
|
+
|
|
214
|
+
### RK4 Integration
|
|
215
|
+
|
|
216
|
+
The Lorenz equations are integrated using 4th-order Runge-Kutta (pure Python, zero dependencies):
|
|
217
|
+
|
|
218
|
+
```
|
|
219
|
+
dx/dt = σ(y - x) σ = 10
|
|
220
|
+
dy/dt = x(ρ - z) - y ρ = tunable (default 28)
|
|
221
|
+
dz/dt = xy - βz β = 8/3
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
### Classification
|
|
225
|
+
|
|
226
|
+
After integration, the mean x-coordinate over the last 200 steps determines fate:
|
|
227
|
+
- `mean_x < -τ` → **KEEP** (left wing: consolidated memory)
|
|
228
|
+
- `mean_x > τ` → **EVICT** (right wing: decayed, safe to remove)
|
|
229
|
+
- `|mean_x| ≤ τ` → **REVIEW** (chaotic boundary: operator inspection required)
|
|
230
|
+
|
|
231
|
+
### Parameter Sweep
|
|
232
|
+
|
|
233
|
+
The sweep tests combinations of ρ (eviction pressure) and τ (classification threshold) to find the governance-stable band:
|
|
234
|
+
- Total eviction rate < 30%
|
|
235
|
+
- High-importance eviction rate < 5%
|
|
236
|
+
- Zero load-bearing evictions
|
|
237
|
+
|
|
238
|
+
### LLM Governance
|
|
239
|
+
|
|
240
|
+
Two-layer LLM review of eviction candidates:
|
|
241
|
+
1. **Probe agent** — reviews each Portal EVICT node with graph context; recommends evict/review/explore/keep
|
|
242
|
+
2. **Gap agent** — synthesizes probe assessments into final governance decisions
|
|
243
|
+
|
|
244
|
+
## License
|
|
245
|
+
|
|
246
|
+
MIT
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "provenance-engine"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Portal GC — attractor-based graph lifecycle management for persistent knowledge systems"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
requires-python = ">=3.10"
|
|
12
|
+
authors = [
|
|
13
|
+
{name = "PortalVision", email = "provenance@portalvision.dev"},
|
|
14
|
+
]
|
|
15
|
+
keywords = ["graph", "portal-gc", "garbage-collection", "knowledge-graph", "llm", "persistence", "lorenz"]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 4 - Beta",
|
|
18
|
+
"Intended Audience :: Developers",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"Programming Language :: Python :: 3.10",
|
|
21
|
+
"Programming Language :: Python :: 3.11",
|
|
22
|
+
"Programming Language :: Python :: 3.12",
|
|
23
|
+
"Programming Language :: Python :: 3.13",
|
|
24
|
+
"Topic :: Scientific/Engineering",
|
|
25
|
+
"Topic :: Software Development :: Libraries",
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
dependencies = [
|
|
29
|
+
"click>=8.0",
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
[project.optional-dependencies]
|
|
33
|
+
llm = [
|
|
34
|
+
"openai>=1.0",
|
|
35
|
+
]
|
|
36
|
+
chart = [
|
|
37
|
+
"numpy>=1.24",
|
|
38
|
+
"sentence-transformers>=2.2",
|
|
39
|
+
]
|
|
40
|
+
sim = [
|
|
41
|
+
"pygame>=2.5",
|
|
42
|
+
]
|
|
43
|
+
all = [
|
|
44
|
+
"provenance-engine[llm,chart,sim]",
|
|
45
|
+
]
|
|
46
|
+
dev = [
|
|
47
|
+
"provenance-engine[all]",
|
|
48
|
+
"pytest>=7.0",
|
|
49
|
+
"pytest-cov",
|
|
50
|
+
"ruff",
|
|
51
|
+
"build",
|
|
52
|
+
"twine",
|
|
53
|
+
]
|
|
54
|
+
|
|
55
|
+
[project.urls]
|
|
56
|
+
Homepage = "https://github.com/portalvision/provenance-engine"
|
|
57
|
+
Repository = "https://github.com/portalvision/provenance-engine"
|
|
58
|
+
Documentation = "https://github.com/portalvision/provenance-engine#readme"
|
|
59
|
+
|
|
60
|
+
[project.scripts]
|
|
61
|
+
provenance-engine = "provenance_engine.cli:cli"
|
|
62
|
+
pe = "provenance_engine.cli:cli"
|
|
63
|
+
|
|
64
|
+
[tool.setuptools.packages.find]
|
|
65
|
+
where = ["src"]
|
|
66
|
+
|
|
67
|
+
[tool.setuptools.package-data]
|
|
68
|
+
provenance_engine = ["sounds/*.wav", "sounds/README.md"]
|
|
69
|
+
|
|
70
|
+
[tool.ruff]
|
|
71
|
+
target-version = "py310"
|
|
72
|
+
line-length = 120
|
|
73
|
+
|
|
74
|
+
[tool.pytest.ini_options]
|
|
75
|
+
testpaths = ["tests", "examples/demo-weather/tests"]
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"""
|
|
2
|
+
ProvenanceEngine — Portal GC: attractor-based graph lifecycle management.
|
|
3
|
+
|
|
4
|
+
Three-phase architecture:
|
|
5
|
+
Phase 1: Map graph nodes to initial conditions (x₀, y₀, z₀)
|
|
6
|
+
Phase 2: Integrate Lorenz system per node, classify KEEP / EVICT / REVIEW
|
|
7
|
+
Phase 3: Generate reports, eviction notices, governance receipts
|
|
8
|
+
|
|
9
|
+
The Lorenz attractor's two-wing structure maps naturally to memory dynamics:
|
|
10
|
+
- Left wing (x < 0): consolidation / retention
|
|
11
|
+
- Right wing (x > 0): decay / eviction candidate
|
|
12
|
+
- Chaotic boundary: uncertain — requires review
|
|
13
|
+
|
|
14
|
+
Designed from first principles of human memory: structural connectivity,
|
|
15
|
+
association strength, and temporal vitality determine whether knowledge
|
|
16
|
+
persists or fades.
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
__version__ = "0.1.0"
|
|
20
|
+
|
|
21
|
+
from provenance_engine.portal import integrate_portal, classify_node
|
|
22
|
+
from provenance_engine.graph import build_graph, normalize_and_scale
|
|
23
|
+
from provenance_engine.log import get_logger
|
|
24
|
+
from provenance_engine.audio import play, SoundEvent, disable, enable
|
|
25
|
+
|
|
26
|
+
__all__ = [
|
|
27
|
+
"__version__",
|
|
28
|
+
"integrate_portal",
|
|
29
|
+
"classify_node",
|
|
30
|
+
"build_graph",
|
|
31
|
+
"normalize_and_scale",
|
|
32
|
+
"get_logger",
|
|
33
|
+
"play",
|
|
34
|
+
"SoundEvent",
|
|
35
|
+
"disable",
|
|
36
|
+
"enable",
|
|
37
|
+
]
|