fractal-memory 0.3.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.
- fractal_memory-0.3.0/.gitignore +50 -0
- fractal_memory-0.3.0/CHANGELOG.md +50 -0
- fractal_memory-0.3.0/CONTRIBUTING.md +79 -0
- fractal_memory-0.3.0/LICENSE +21 -0
- fractal_memory-0.3.0/PKG-INFO +604 -0
- fractal_memory-0.3.0/README.md +556 -0
- fractal_memory-0.3.0/pyproject.toml +82 -0
- fractal_memory-0.3.0/src/fractal_memory/__init__.py +1175 -0
- fractal_memory-0.3.0/src/fractal_memory/apoptosis.py +310 -0
- fractal_memory-0.3.0/src/fractal_memory/associations.py +385 -0
- fractal_memory-0.3.0/src/fractal_memory/bandits.py +226 -0
- fractal_memory-0.3.0/src/fractal_memory/buffer.py +135 -0
- fractal_memory-0.3.0/src/fractal_memory/cli.py +885 -0
- fractal_memory-0.3.0/src/fractal_memory/config.py +348 -0
- fractal_memory-0.3.0/src/fractal_memory/consolidation.py +491 -0
- fractal_memory-0.3.0/src/fractal_memory/dashboard/__init__.py +1 -0
- fractal_memory-0.3.0/src/fractal_memory/dashboard/app.py +1581 -0
- fractal_memory-0.3.0/src/fractal_memory/dashboard/static/dashboard.js +45 -0
- fractal_memory-0.3.0/src/fractal_memory/dashboard/static/style.css +1075 -0
- fractal_memory-0.3.0/src/fractal_memory/dashboard/templates/apoptosis.html +314 -0
- fractal_memory-0.3.0/src/fractal_memory/dashboard/templates/bandits.html +439 -0
- fractal_memory-0.3.0/src/fractal_memory/dashboard/templates/base.html +373 -0
- fractal_memory-0.3.0/src/fractal_memory/dashboard/templates/brain.html +206 -0
- fractal_memory-0.3.0/src/fractal_memory/dashboard/templates/buffer.html +271 -0
- fractal_memory-0.3.0/src/fractal_memory/dashboard/templates/cascade.html +348 -0
- fractal_memory-0.3.0/src/fractal_memory/dashboard/templates/config.html +355 -0
- fractal_memory-0.3.0/src/fractal_memory/dashboard/templates/consolidation.html +380 -0
- fractal_memory-0.3.0/src/fractal_memory/dashboard/templates/domain_detail.html +41 -0
- fractal_memory-0.3.0/src/fractal_memory/dashboard/templates/dreaming.html +304 -0
- fractal_memory-0.3.0/src/fractal_memory/dashboard/templates/feedback.html +403 -0
- fractal_memory-0.3.0/src/fractal_memory/dashboard/templates/folding.html +307 -0
- fractal_memory-0.3.0/src/fractal_memory/dashboard/templates/guide.html +1033 -0
- fractal_memory-0.3.0/src/fractal_memory/dashboard/templates/index.html +122 -0
- fractal_memory-0.3.0/src/fractal_memory/dashboard/templates/lifecycle.html +102 -0
- fractal_memory-0.3.0/src/fractal_memory/dashboard/templates/maintenance.html +348 -0
- fractal_memory-0.3.0/src/fractal_memory/dashboard/templates/memory_detail.html +71 -0
- fractal_memory-0.3.0/src/fractal_memory/dashboard/templates/morphogens.html +373 -0
- fractal_memory-0.3.0/src/fractal_memory/dashboard/templates/niche.html +280 -0
- fractal_memory-0.3.0/src/fractal_memory/dashboard/templates/organism.html +327 -0
- fractal_memory-0.3.0/src/fractal_memory/dashboard/templates/pipeline.html +218 -0
- fractal_memory-0.3.0/src/fractal_memory/dashboard/templates/states.html +411 -0
- fractal_memory-0.3.0/src/fractal_memory/domains.py +168 -0
- fractal_memory-0.3.0/src/fractal_memory/dreaming.py +338 -0
- fractal_memory-0.3.0/src/fractal_memory/embeddings.py +62 -0
- fractal_memory-0.3.0/src/fractal_memory/feedback.py +661 -0
- fractal_memory-0.3.0/src/fractal_memory/folding.py +212 -0
- fractal_memory-0.3.0/src/fractal_memory/gate.py +144 -0
- fractal_memory-0.3.0/src/fractal_memory/kalman.py +81 -0
- fractal_memory-0.3.0/src/fractal_memory/lifecycle.py +108 -0
- fractal_memory-0.3.0/src/fractal_memory/llm.py +234 -0
- fractal_memory-0.3.0/src/fractal_memory/maintenance.py +389 -0
- fractal_memory-0.3.0/src/fractal_memory/mcp/__init__.py +1 -0
- fractal_memory-0.3.0/src/fractal_memory/mcp/server.py +625 -0
- fractal_memory-0.3.0/src/fractal_memory/models.py +141 -0
- fractal_memory-0.3.0/src/fractal_memory/morphogens.py +486 -0
- fractal_memory-0.3.0/src/fractal_memory/niche.py +259 -0
- fractal_memory-0.3.0/src/fractal_memory/py.typed +0 -0
- fractal_memory-0.3.0/src/fractal_memory/retrieval.py +327 -0
- fractal_memory-0.3.0/src/fractal_memory/scar.py +248 -0
- fractal_memory-0.3.0/src/fractal_memory/self_model.py +288 -0
- fractal_memory-0.3.0/src/fractal_memory/session.py +310 -0
- fractal_memory-0.3.0/src/fractal_memory/states.py +145 -0
- fractal_memory-0.3.0/src/fractal_memory/storage.py +1765 -0
- fractal_memory-0.3.0/src/fractal_memory/zoom.py +113 -0
- fractal_memory-0.3.0/tests/__init__.py +1 -0
- fractal_memory-0.3.0/tests/conftest.py +96 -0
- fractal_memory-0.3.0/tests/test_associations.py +270 -0
- fractal_memory-0.3.0/tests/test_benchmark.py +150 -0
- fractal_memory-0.3.0/tests/test_buffer.py +123 -0
- fractal_memory-0.3.0/tests/test_config.py +70 -0
- fractal_memory-0.3.0/tests/test_consolidation.py +297 -0
- fractal_memory-0.3.0/tests/test_dashboard.py +530 -0
- fractal_memory-0.3.0/tests/test_domains.py +174 -0
- fractal_memory-0.3.0/tests/test_embeddings.py +81 -0
- fractal_memory-0.3.0/tests/test_feedback.py +331 -0
- fractal_memory-0.3.0/tests/test_gate.py +196 -0
- fractal_memory-0.3.0/tests/test_habituation.py +91 -0
- fractal_memory-0.3.0/tests/test_integration.py +275 -0
- fractal_memory-0.3.0/tests/test_kill_gate_p3.py +383 -0
- fractal_memory-0.3.0/tests/test_lifecycle.py +171 -0
- fractal_memory-0.3.0/tests/test_mcp_dashboard_colaunch.py +275 -0
- fractal_memory-0.3.0/tests/test_models.py +166 -0
- fractal_memory-0.3.0/tests/test_phase2_benchmark.py +222 -0
- fractal_memory-0.3.0/tests/test_phase2_integration.py +256 -0
- fractal_memory-0.3.0/tests/test_phase3_apoptosis.py +298 -0
- fractal_memory-0.3.0/tests/test_phase3_bandits.py +323 -0
- fractal_memory-0.3.0/tests/test_phase3_cli.py +579 -0
- fractal_memory-0.3.0/tests/test_phase3_dreaming.py +556 -0
- fractal_memory-0.3.0/tests/test_phase3_folding.py +195 -0
- fractal_memory-0.3.0/tests/test_phase3_kalman.py +96 -0
- fractal_memory-0.3.0/tests/test_phase3_maintenance.py +306 -0
- fractal_memory-0.3.0/tests/test_phase3_morphogens.py +332 -0
- fractal_memory-0.3.0/tests/test_phase3_niche.py +633 -0
- fractal_memory-0.3.0/tests/test_phase3_self_model.py +323 -0
- fractal_memory-0.3.0/tests/test_phase3_states.py +211 -0
- fractal_memory-0.3.0/tests/test_property.py +197 -0
- fractal_memory-0.3.0/tests/test_real_embeddings.py +214 -0
- fractal_memory-0.3.0/tests/test_real_integration.py +321 -0
- fractal_memory-0.3.0/tests/test_real_phase3.py +508 -0
- fractal_memory-0.3.0/tests/test_retrieval.py +174 -0
- fractal_memory-0.3.0/tests/test_scar.py +215 -0
- fractal_memory-0.3.0/tests/test_security.py +121 -0
- fractal_memory-0.3.0/tests/test_session.py +183 -0
- fractal_memory-0.3.0/tests/test_session_summaries.py +423 -0
- fractal_memory-0.3.0/tests/test_storage.py +368 -0
- fractal_memory-0.3.0/tests/test_stress_concurrency.py +348 -0
- fractal_memory-0.3.0/tests/test_stress_scale.py +348 -0
- fractal_memory-0.3.0/tests/test_zoom.py +96 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*.egg-info/
|
|
5
|
+
*.egg
|
|
6
|
+
*.whl
|
|
7
|
+
.eggs/
|
|
8
|
+
dist/
|
|
9
|
+
build/
|
|
10
|
+
|
|
11
|
+
# Virtual environments
|
|
12
|
+
venv/
|
|
13
|
+
.venv/
|
|
14
|
+
|
|
15
|
+
# Databases (user data)
|
|
16
|
+
*.db
|
|
17
|
+
*.sqlite3
|
|
18
|
+
|
|
19
|
+
# Logs
|
|
20
|
+
*.log
|
|
21
|
+
|
|
22
|
+
# Environment files
|
|
23
|
+
.env
|
|
24
|
+
|
|
25
|
+
# macOS
|
|
26
|
+
.DS_Store
|
|
27
|
+
|
|
28
|
+
# Testing / Coverage
|
|
29
|
+
.hypothesis/
|
|
30
|
+
.pytest_cache/
|
|
31
|
+
_playwright/
|
|
32
|
+
.coverage
|
|
33
|
+
htmlcov/
|
|
34
|
+
coverage.xml
|
|
35
|
+
|
|
36
|
+
# Node
|
|
37
|
+
node_modules/
|
|
38
|
+
|
|
39
|
+
# IDE
|
|
40
|
+
.idea/
|
|
41
|
+
.vscode/
|
|
42
|
+
|
|
43
|
+
# MCP config (contains user-specific paths)
|
|
44
|
+
.mcp.json
|
|
45
|
+
|
|
46
|
+
# Internal docs and experiments (not for public repo)
|
|
47
|
+
internal/
|
|
48
|
+
|
|
49
|
+
# Claude Code settings (user-specific hooks and config)
|
|
50
|
+
.claude/
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [0.3.0] - 2026-04-07
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
**Phase 1 — Pioneer**
|
|
15
|
+
- `FractalMemory` core class with async `store()`, `retrieve()`, `session_start()`, `session_end()`
|
|
16
|
+
- 5-level zoom system (L0 tag → L1 label → L2 summary → L3 full → L4 raw)
|
|
17
|
+
- Token-budgeted retrieval: top 200 as labels, top 50 as summaries, top 10 as full context
|
|
18
|
+
- Memory lifecycle: probation → confirmed → permanent → safety-critical
|
|
19
|
+
- Intensity-weighted storage with automatic gating
|
|
20
|
+
- Session bootstrap with prior context injection
|
|
21
|
+
- Sentence-transformer embeddings with cosine similarity scoring
|
|
22
|
+
|
|
23
|
+
**Phase 2 — Shrub**
|
|
24
|
+
- Association graph: edges form between co-retrieved memories, weights decay over time
|
|
25
|
+
- Scar tissue: corrections leave permanent repair markers, penalize future retrieval
|
|
26
|
+
- Kintsugi: golden seams on corrected memories (visible in dashboard)
|
|
27
|
+
- Consolidation engine: merge similar memories, strengthen edges, expire scars
|
|
28
|
+
- Danger theory: feedback signals from user messages (surprise, contradiction, resolution)
|
|
29
|
+
- LLM judge: rates memory usefulness at session end
|
|
30
|
+
- Multi-domain support with domain isolation
|
|
31
|
+
- 19-page real-time dashboard (FastAPI + Chart.js + D3.js)
|
|
32
|
+
|
|
33
|
+
**Phase 3 — Forest**
|
|
34
|
+
- Morphogenetic self-calibration: adaptive sigmoid response curves per parameter
|
|
35
|
+
- System states: FLOW / STRESS / CURIOSITY state machine with parameter multipliers
|
|
36
|
+
- Contextual bandits: Thompson sampling for retrieval strategy selection
|
|
37
|
+
- Dreaming: slow-wave consolidation + REM recombination at session end
|
|
38
|
+
- Apoptosis: controlled pruning of low-vitality memories with fragment salvage
|
|
39
|
+
- Niche construction: Louvain clustering for domain reorganization proposals
|
|
40
|
+
- Cascade detector: Extended Kalman Filter for system health prediction
|
|
41
|
+
- Dimensional folding: operational regime detection (BOOTSTRAP → LEARNING → MATURE)
|
|
42
|
+
- Maintenance scheduler: tiered (intra-session, daily, weekly, monthly) background maintenance
|
|
43
|
+
- Self-model: organism health metrics, parameter drift detection
|
|
44
|
+
- MCP server with auto-session management and dashboard co-launch
|
|
45
|
+
- CLI (`fractal`) with store, retrieve, inspect, export, health, maintenance commands
|
|
46
|
+
|
|
47
|
+
### Security
|
|
48
|
+
- SQL injection protection via parameterized queries throughout
|
|
49
|
+
- Input validation on all public API boundaries
|
|
50
|
+
- Domain name sanitization (alphanumeric + hyphens/underscores/dots only)
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# Contributing to Fractal Memory
|
|
2
|
+
|
|
3
|
+
## Development Setup
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
# Clone
|
|
7
|
+
git clone https://github.com/entropyvector/fractal-memory.git
|
|
8
|
+
cd fractal-memory
|
|
9
|
+
|
|
10
|
+
# Create virtual environment
|
|
11
|
+
python3.11 -m venv .venv
|
|
12
|
+
source .venv/bin/activate
|
|
13
|
+
|
|
14
|
+
# Install with all extras
|
|
15
|
+
pip install -e ".[dev,dashboard]"
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Running Tests
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pytest
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Tests use `pytest-asyncio` with `asyncio_mode = "auto"` — async test functions are detected automatically.
|
|
25
|
+
|
|
26
|
+
## Code Style
|
|
27
|
+
|
|
28
|
+
- **Async-first** — all I/O must be async. No sync database drivers in async contexts.
|
|
29
|
+
- **Type annotations** on all public functions.
|
|
30
|
+
- **No hardcoding** — all configurable parameters go in `FractalConfig` (`src/fractal_memory/config.py`).
|
|
31
|
+
- **Extend, don't rewrite** — no phase may rewrite prior phase code. Use hooks, callbacks, or new modules.
|
|
32
|
+
- **Single source of truth** — `FractalConfig` is the only config object. No shadow configs.
|
|
33
|
+
|
|
34
|
+
See `internal/requirements/CODE_REQUIREMENTS.md` for the full specification.
|
|
35
|
+
|
|
36
|
+
## Project Structure
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
src/fractal_memory/
|
|
40
|
+
├── __init__.py # FractalMemory main class
|
|
41
|
+
├── config.py # FractalConfig — all parameters
|
|
42
|
+
├── storage.py # SQLite persistence (async via aiosqlite)
|
|
43
|
+
├── models.py # Data models (Memory, Session, etc.)
|
|
44
|
+
├── cli.py # Click CLI (fractal command)
|
|
45
|
+
├── mcp/
|
|
46
|
+
│ └── server.py # MCP server (fractal-memory-mcp)
|
|
47
|
+
└── dashboard/ # FastAPI dashboard
|
|
48
|
+
├── app.py
|
|
49
|
+
├── templates/
|
|
50
|
+
└── static/
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Architecture
|
|
54
|
+
|
|
55
|
+
The codebase is organized by evolutionary phases. Each phase builds on the previous:
|
|
56
|
+
|
|
57
|
+
- **Phase 1 (Pioneer):** Core store/retrieve, 5 zoom levels, lifecycle, gate
|
|
58
|
+
- **Phase 2 (Shrub):** Association network, danger theory, scar tissue, consolidation
|
|
59
|
+
- **Phase 3 (Forest):** Morphogenetic fields, niche construction, dreaming, maintenance
|
|
60
|
+
- **Phase 4 (Old Growth):** Aliveness diagnostic, memory packs, cross-domain (planned)
|
|
61
|
+
|
|
62
|
+
See `internal/plans/` for detailed phase plans.
|
|
63
|
+
|
|
64
|
+
## Pull Request Process
|
|
65
|
+
|
|
66
|
+
1. Fork the repository
|
|
67
|
+
2. Create a feature branch from `main`
|
|
68
|
+
3. Make your changes (follow the code style above)
|
|
69
|
+
4. Add tests for new functionality
|
|
70
|
+
5. Run `pytest` and ensure all tests pass
|
|
71
|
+
6. Submit a PR against `main`
|
|
72
|
+
|
|
73
|
+
## Reporting Issues
|
|
74
|
+
|
|
75
|
+
Open an issue at https://github.com/entropyvector/fractal-memory/issues with:
|
|
76
|
+
- What you expected to happen
|
|
77
|
+
- What actually happened
|
|
78
|
+
- Steps to reproduce
|
|
79
|
+
- Your Python version and OS
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-2026 Zaur Jafarov
|
|
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.
|