NWcortex 1.0.1__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.
Files changed (198) hide show
  1. nwcortex-1.0.1/LICENSE +21 -0
  2. nwcortex-1.0.1/MANIFEST.in +10 -0
  3. nwcortex-1.0.1/NWcortex.egg-info/PKG-INFO +317 -0
  4. nwcortex-1.0.1/NWcortex.egg-info/SOURCES.txt +196 -0
  5. nwcortex-1.0.1/NWcortex.egg-info/dependency_links.txt +1 -0
  6. nwcortex-1.0.1/NWcortex.egg-info/entry_points.txt +5 -0
  7. nwcortex-1.0.1/NWcortex.egg-info/requires.txt +6 -0
  8. nwcortex-1.0.1/NWcortex.egg-info/top_level.txt +1 -0
  9. nwcortex-1.0.1/PKG-INFO +317 -0
  10. nwcortex-1.0.1/README.md +289 -0
  11. nwcortex-1.0.1/examples/ablation_benchmark.py +391 -0
  12. nwcortex-1.0.1/examples/emergence_demo.py +230 -0
  13. nwcortex-1.0.1/examples/locomo_eval.py +504 -0
  14. nwcortex-1.0.1/examples/locomo_llm_eval.py +600 -0
  15. nwcortex-1.0.1/examples/locomo_test.py +597 -0
  16. nwcortex-1.0.1/examples/memory_basic.py +164 -0
  17. nwcortex-1.0.1/examples/memory_benchmark.py +1126 -0
  18. nwcortex-1.0.1/pyproject.toml +61 -0
  19. nwcortex-1.0.1/setup.cfg +4 -0
  20. nwcortex-1.0.1/star_graph/__init__.py +398 -0
  21. nwcortex-1.0.1/star_graph/__main__.py +20 -0
  22. nwcortex-1.0.1/star_graph/abstraction.py +518 -0
  23. nwcortex-1.0.1/star_graph/anchor.py +869 -0
  24. nwcortex-1.0.1/star_graph/async_manager.py +463 -0
  25. nwcortex-1.0.1/star_graph/atom_facts.py +541 -0
  26. nwcortex-1.0.1/star_graph/autobiography.py +4 -0
  27. nwcortex-1.0.1/star_graph/benchmark.py +10 -0
  28. nwcortex-1.0.1/star_graph/bm25.py +129 -0
  29. nwcortex-1.0.1/star_graph/brain_sphere.py +247 -0
  30. nwcortex-1.0.1/star_graph/cascade.py +264 -0
  31. nwcortex-1.0.1/star_graph/causal_edges.py +217 -0
  32. nwcortex-1.0.1/star_graph/cli.py +210 -0
  33. nwcortex-1.0.1/star_graph/cluster_memory.py +200 -0
  34. nwcortex-1.0.1/star_graph/cognitive_cache.py +625 -0
  35. nwcortex-1.0.1/star_graph/community.py +642 -0
  36. nwcortex-1.0.1/star_graph/competition.py +242 -0
  37. nwcortex-1.0.1/star_graph/compiler.py +524 -0
  38. nwcortex-1.0.1/star_graph/compression.py +959 -0
  39. nwcortex-1.0.1/star_graph/config.py +486 -0
  40. nwcortex-1.0.1/star_graph/consolidation/__init__.py +37 -0
  41. nwcortex-1.0.1/star_graph/contrib/__init__.py +33 -0
  42. nwcortex-1.0.1/star_graph/contrib/benchmark.py +820 -0
  43. nwcortex-1.0.1/star_graph/contrib/mcp_server.py +416 -0
  44. nwcortex-1.0.1/star_graph/contrib/snapshot.py +567 -0
  45. nwcortex-1.0.1/star_graph/contrib/streaming.py +399 -0
  46. nwcortex-1.0.1/star_graph/contrib/symbolic_filter.py +182 -0
  47. nwcortex-1.0.1/star_graph/cortex.py +534 -0
  48. nwcortex-1.0.1/star_graph/cortex_api/__init__.py +31 -0
  49. nwcortex-1.0.1/star_graph/cost_estimator.py +325 -0
  50. nwcortex-1.0.1/star_graph/defaults.yaml +543 -0
  51. nwcortex-1.0.1/star_graph/domain_router.py +401 -0
  52. nwcortex-1.0.1/star_graph/dual_channel.py +691 -0
  53. nwcortex-1.0.1/star_graph/edge_budget.py +4 -0
  54. nwcortex-1.0.1/star_graph/edge_decay.py +4 -0
  55. nwcortex-1.0.1/star_graph/edge_management.py +264 -0
  56. nwcortex-1.0.1/star_graph/embedding.py +225 -0
  57. nwcortex-1.0.1/star_graph/embedding_provider/__init__.py +43 -0
  58. nwcortex-1.0.1/star_graph/embedding_provider/providers.py +404 -0
  59. nwcortex-1.0.1/star_graph/episodic_memory.py +264 -0
  60. nwcortex-1.0.1/star_graph/evolution.py +548 -0
  61. nwcortex-1.0.1/star_graph/exact_cache.py +4 -0
  62. nwcortex-1.0.1/star_graph/extras/__init__.py +41 -0
  63. nwcortex-1.0.1/star_graph/extras/autobiography.py +329 -0
  64. nwcortex-1.0.1/star_graph/extras/resonance.py +214 -0
  65. nwcortex-1.0.1/star_graph/four_layer.py +624 -0
  66. nwcortex-1.0.1/star_graph/gate.py +218 -0
  67. nwcortex-1.0.1/star_graph/ghost.py +536 -0
  68. nwcortex-1.0.1/star_graph/goal_tree.py +365 -0
  69. nwcortex-1.0.1/star_graph/graph.py +1244 -0
  70. nwcortex-1.0.1/star_graph/hippocampus.py +262 -0
  71. nwcortex-1.0.1/star_graph/hub.py +847 -0
  72. nwcortex-1.0.1/star_graph/index.py +98 -0
  73. nwcortex-1.0.1/star_graph/layers.py +143 -0
  74. nwcortex-1.0.1/star_graph/logger.py +118 -0
  75. nwcortex-1.0.1/star_graph/manager.py +128 -0
  76. nwcortex-1.0.1/star_graph/manager_stats.py +49 -0
  77. nwcortex-1.0.1/star_graph/math_utils.py +43 -0
  78. nwcortex-1.0.1/star_graph/mcp_server.py +4 -0
  79. nwcortex-1.0.1/star_graph/memory_core/__init__.py +43 -0
  80. nwcortex-1.0.1/star_graph/metrics.py +181 -0
  81. nwcortex-1.0.1/star_graph/micro_sleep.py +295 -0
  82. nwcortex-1.0.1/star_graph/multimodal.py +561 -0
  83. nwcortex-1.0.1/star_graph/online.py +116 -0
  84. nwcortex-1.0.1/star_graph/personality.py +299 -0
  85. nwcortex-1.0.1/star_graph/raw_buffer.py +275 -0
  86. nwcortex-1.0.1/star_graph/reflection_loop.py +426 -0
  87. nwcortex-1.0.1/star_graph/resonance.py +4 -0
  88. nwcortex-1.0.1/star_graph/retrieval_budget.py +125 -0
  89. nwcortex-1.0.1/star_graph/retrieval_core.py +1029 -0
  90. nwcortex-1.0.1/star_graph/retrieval_engine/__init__.py +36 -0
  91. nwcortex-1.0.1/star_graph/retrieval_pipeline.py +37 -0
  92. nwcortex-1.0.1/star_graph/retriever.py +879 -0
  93. nwcortex-1.0.1/star_graph/router.py +304 -0
  94. nwcortex-1.0.1/star_graph/runtime.py +1045 -0
  95. nwcortex-1.0.1/star_graph/runtime_core.py +440 -0
  96. nwcortex-1.0.1/star_graph/runtime_lifecycle.py +407 -0
  97. nwcortex-1.0.1/star_graph/runtime_stats.py +2 -0
  98. nwcortex-1.0.1/star_graph/scheduler.py +881 -0
  99. nwcortex-1.0.1/star_graph/seed.py +34 -0
  100. nwcortex-1.0.1/star_graph/self_org.py +302 -0
  101. nwcortex-1.0.1/star_graph/server.py +166 -0
  102. nwcortex-1.0.1/star_graph/shard.py +231 -0
  103. nwcortex-1.0.1/star_graph/sleep.py +563 -0
  104. nwcortex-1.0.1/star_graph/sleep_consolidate.py +943 -0
  105. nwcortex-1.0.1/star_graph/sleep_nrem.py +206 -0
  106. nwcortex-1.0.1/star_graph/sleep_rem.py +148 -0
  107. nwcortex-1.0.1/star_graph/sleep_report.py +125 -0
  108. nwcortex-1.0.1/star_graph/snapshot.py +4 -0
  109. nwcortex-1.0.1/star_graph/spreading.py +211 -0
  110. nwcortex-1.0.1/star_graph/sqlite_storage.py +371 -0
  111. nwcortex-1.0.1/star_graph/storage.py +176 -0
  112. nwcortex-1.0.1/star_graph/storage_backend.py +66 -0
  113. nwcortex-1.0.1/star_graph/streaming.py +4 -0
  114. nwcortex-1.0.1/star_graph/survival.py +294 -0
  115. nwcortex-1.0.1/star_graph/symbolic_filter.py +4 -0
  116. nwcortex-1.0.1/star_graph/thermal_store.py +260 -0
  117. nwcortex-1.0.1/star_graph/tier.py +960 -0
  118. nwcortex-1.0.1/star_graph/tiered.py +4 -0
  119. nwcortex-1.0.1/star_graph/timespine.py +296 -0
  120. nwcortex-1.0.1/star_graph/topology.py +332 -0
  121. nwcortex-1.0.1/star_graph/tracing.py +366 -0
  122. nwcortex-1.0.1/star_graph/versioned_memory.py +217 -0
  123. nwcortex-1.0.1/star_graph/working_memory.py +267 -0
  124. nwcortex-1.0.1/star_graph/write_gate.py +326 -0
  125. nwcortex-1.0.1/tests/test_abstraction.py +379 -0
  126. nwcortex-1.0.1/tests/test_abstractive_memory.py +177 -0
  127. nwcortex-1.0.1/tests/test_anchor.py +503 -0
  128. nwcortex-1.0.1/tests/test_atom_facts.py +51 -0
  129. nwcortex-1.0.1/tests/test_autobiography.py +344 -0
  130. nwcortex-1.0.1/tests/test_bm25.py +148 -0
  131. nwcortex-1.0.1/tests/test_brain_sphere.py +244 -0
  132. nwcortex-1.0.1/tests/test_cascade.py +86 -0
  133. nwcortex-1.0.1/tests/test_causal_edges.py +85 -0
  134. nwcortex-1.0.1/tests/test_cluster_memory.py +111 -0
  135. nwcortex-1.0.1/tests/test_cognitive_cache.py +223 -0
  136. nwcortex-1.0.1/tests/test_cognitive_compiler.py +220 -0
  137. nwcortex-1.0.1/tests/test_community.py +487 -0
  138. nwcortex-1.0.1/tests/test_competition.py +228 -0
  139. nwcortex-1.0.1/tests/test_compiler.py +626 -0
  140. nwcortex-1.0.1/tests/test_compression.py +623 -0
  141. nwcortex-1.0.1/tests/test_config_schema.py +125 -0
  142. nwcortex-1.0.1/tests/test_cortex_hierarchy.py +336 -0
  143. nwcortex-1.0.1/tests/test_cost_estimator.py +240 -0
  144. nwcortex-1.0.1/tests/test_domain_router.py +186 -0
  145. nwcortex-1.0.1/tests/test_edge_budget.py +154 -0
  146. nwcortex-1.0.1/tests/test_edge_decay.py +157 -0
  147. nwcortex-1.0.1/tests/test_edge_management.py +235 -0
  148. nwcortex-1.0.1/tests/test_embedding.py +116 -0
  149. nwcortex-1.0.1/tests/test_episodic_memory.py +159 -0
  150. nwcortex-1.0.1/tests/test_evolution.py +396 -0
  151. nwcortex-1.0.1/tests/test_four_layer.py +418 -0
  152. nwcortex-1.0.1/tests/test_gate.py +225 -0
  153. nwcortex-1.0.1/tests/test_ghost.py +243 -0
  154. nwcortex-1.0.1/tests/test_ghost_intensity.py +442 -0
  155. nwcortex-1.0.1/tests/test_goal_tree.py +324 -0
  156. nwcortex-1.0.1/tests/test_graph.py +675 -0
  157. nwcortex-1.0.1/tests/test_hippocampus.py +173 -0
  158. nwcortex-1.0.1/tests/test_index.py +92 -0
  159. nwcortex-1.0.1/tests/test_layers.py +92 -0
  160. nwcortex-1.0.1/tests/test_logger.py +87 -0
  161. nwcortex-1.0.1/tests/test_manager_stats.py +45 -0
  162. nwcortex-1.0.1/tests/test_math_utils.py +88 -0
  163. nwcortex-1.0.1/tests/test_memory_tier.py +233 -0
  164. nwcortex-1.0.1/tests/test_metrics.py +229 -0
  165. nwcortex-1.0.1/tests/test_micro_sleep.py +292 -0
  166. nwcortex-1.0.1/tests/test_multimodal.py +451 -0
  167. nwcortex-1.0.1/tests/test_online.py +135 -0
  168. nwcortex-1.0.1/tests/test_oscillation_match.py +178 -0
  169. nwcortex-1.0.1/tests/test_personality.py +209 -0
  170. nwcortex-1.0.1/tests/test_raw_buffer.py +170 -0
  171. nwcortex-1.0.1/tests/test_readme_doctest.py +90 -0
  172. nwcortex-1.0.1/tests/test_reflection_loop.py +332 -0
  173. nwcortex-1.0.1/tests/test_resonance.py +131 -0
  174. nwcortex-1.0.1/tests/test_retrieval_budget.py +103 -0
  175. nwcortex-1.0.1/tests/test_retrieval_trace.py +131 -0
  176. nwcortex-1.0.1/tests/test_retriever.py +526 -0
  177. nwcortex-1.0.1/tests/test_router.py +281 -0
  178. nwcortex-1.0.1/tests/test_scheduler.py +646 -0
  179. nwcortex-1.0.1/tests/test_seed.py +62 -0
  180. nwcortex-1.0.1/tests/test_self_org.py +232 -0
  181. nwcortex-1.0.1/tests/test_shard.py +413 -0
  182. nwcortex-1.0.1/tests/test_sleep_consolidation.py +604 -0
  183. nwcortex-1.0.1/tests/test_sleep_report.py +109 -0
  184. nwcortex-1.0.1/tests/test_spreading.py +149 -0
  185. nwcortex-1.0.1/tests/test_sqlite_storage.py +257 -0
  186. nwcortex-1.0.1/tests/test_storage.py +136 -0
  187. nwcortex-1.0.1/tests/test_storage_backend.py +54 -0
  188. nwcortex-1.0.1/tests/test_streaming.py +433 -0
  189. nwcortex-1.0.1/tests/test_survival.py +583 -0
  190. nwcortex-1.0.1/tests/test_thermal_store.py +310 -0
  191. nwcortex-1.0.1/tests/test_tier.py +423 -0
  192. nwcortex-1.0.1/tests/test_timespine.py +187 -0
  193. nwcortex-1.0.1/tests/test_topology.py +169 -0
  194. nwcortex-1.0.1/tests/test_tracing.py +437 -0
  195. nwcortex-1.0.1/tests/test_v08_modules.py +558 -0
  196. nwcortex-1.0.1/tests/test_versioned_memory.py +112 -0
  197. nwcortex-1.0.1/tests/test_working_memory.py +195 -0
  198. nwcortex-1.0.1/tests/test_write_gate.py +439 -0
nwcortex-1.0.1/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Thatgfsj
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,10 @@
1
+ include README.md
2
+ include LICENSE
3
+ include star_graph/defaults.yaml
4
+ recursive-include examples *.py
5
+ prune venv
6
+ prune dist
7
+ prune build
8
+ prune .git
9
+ prune __pycache__
10
+ global-exclude *.pyc
@@ -0,0 +1,317 @@
1
+ Metadata-Version: 2.4
2
+ Name: NWcortex
3
+ Version: 1.0.1
4
+ Summary: NeuroWeave Cortex (NWC) — Graph-first cognitive memory runtime for AI agents. Hippocampal-inspired architecture with domain routing, spreading activation, edge budget management, 4-layer compression, thermal storage, personality modeling, and 8-phase sleep consolidation.
5
+ Author-email: Thatgfsj <thatgfsj@users.noreply.github.com>
6
+ License: MIT
7
+ Project-URL: repository, https://github.com/Thatgfsj/neuroweave-cortex
8
+ Classifier: Development Status :: 4 - Beta
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Intended Audience :: Science/Research
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
18
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
19
+ Requires-Python: >=3.11
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Requires-Dist: numpy>=1.24.0
23
+ Requires-Dist: PyYAML>=6.0
24
+ Requires-Dist: scikit-learn>=1.3.0
25
+ Provides-Extra: embeddings
26
+ Requires-Dist: sentence-transformers>=2.2.0; extra == "embeddings"
27
+ Dynamic: license-file
28
+
29
+ # NeuroWeave Cortex (NWC) — Cognitive Memory Runtime
30
+
31
+ An infrastructure-grade memory system for AI agents. Not a vector database. Not a graph database. A **memory runtime** — it remembers, forgets, strengthens, connects, abstracts, and evolves, the way biological memory does.
32
+
33
+ ```
34
+ Anchors: 131 Edges: 211 Ghosts: 0 Schemas: 9 Abstracts: 1
35
+ Memory Stability: 0.72 Recall Plasticity: 0.58 Compression: 1.6x
36
+ ```
37
+
38
+ ## What makes it different
39
+
40
+ Vector databases retrieve. Graph databases traverse. NeuroWeave Cortex runs a **cognitive lifecycle**:
41
+
42
+ | Capability | Vector DB | Graph DB | NeuroWeave Cortex |
43
+ |---|---|---|---|
44
+ | Semantic retrieval | yes | no | yes |
45
+ | Graph traversal | no | yes | yes |
46
+ | Automatic forgetting (survival decay) | no | no | yes |
47
+ | Memory strengthening (rehearsal) | no | no | yes |
48
+ | Conflict detection (contradiction edges) | no | no | yes |
49
+ | Fuzzy recall ("I think I remember...") | no | no | yes |
50
+ | Emergent abstraction (pattern discovery) | no | no | yes |
51
+ | Temporal context (TimeSpine-indexed) | no | no | yes |
52
+ | 8-phase sleep consolidation | no | no | yes |
53
+ | Ghost revival (savings effect) | no | no | yes |
54
+ | Autobiographical self-model | no | no | yes |
55
+
56
+ ## Quick Start
57
+
58
+ ```python
59
+ from star_graph import MemoryManager
60
+ from star_graph.scheduler import AgentContext
61
+
62
+ # One-line setup
63
+ mgr = MemoryManager()
64
+
65
+ # Remember things
66
+ mgr.remember("User debugs Redis connection timeout — pool was 10, fixed to 20",
67
+ tags=["redis", "debug", "timeout"])
68
+ mgr.remember("User knows Python async programming with asyncio",
69
+ tags=["python", "knowledge"])
70
+ mgr.remember("User prefers type hints and concise code",
71
+ tags=["preference", "style"])
72
+
73
+ # Working memory — fast, ephemeral buffer for active context
74
+ mgr.remember_working("Currently debugging auth middleware timeout",
75
+ tags=["debug", "auth"])
76
+
77
+ # Context-aware recall — working memory gets retrieval priority
78
+ ctx = AgentContext(task_type="debugging", active_goals=["fix Redis connection"])
79
+ memories = mgr.recall("Redis connection pool config", context=ctx)
80
+ print(memories.memory_summary)
81
+
82
+ # System-2 deep recall for exhaustive or low-confidence queries
83
+ memories = mgr.dual_recall("list all Redis-related issues", context=ctx)
84
+
85
+ # Micro-consolidation — incremental, non-blocking
86
+ mgr.micro_consolidate()
87
+
88
+ # Let the system sleep — 8-phase consolidation
89
+ report = mgr.sleep()
90
+ print(report)
91
+
92
+ # Persist
93
+ mgr.save("agent_memory.json")
94
+ mgr.load("agent_memory.json")
95
+ ```
96
+
97
+ ## Architecture
98
+
99
+ Three-layer design. Each layer depends only on the one below.
100
+
101
+ ```
102
+ Layer 3: Behavior │ Cortex routing, memory gating, working memory,
103
+ (cortex.py, │ dual-channel retrieval, adaptive replay, autobiographical memory
104
+ router.py, │ "What should I recall right now, at what detail level?"
105
+ gate.py, │
106
+ working_memory.py,│
107
+ scheduler.py, │
108
+ autobiography.py)│
109
+
110
+ Layer 2: Cognitive │ Hub abstraction, cascade recall, TimeSpine temporal index,
111
+ (retriever.py, │ sleep consolidation, evolution, ghost revival,
112
+ sleep.py, │ abstraction, community detection, competition
113
+ evolution.py, │ "How do memories connect, strengthen, and fade?"
114
+ ghost.py, │
115
+ abstraction.py, │
116
+ community.py, │
117
+ competition.py, │
118
+ timespine.py, │
119
+ cascade.py, │
120
+ hub.py) │
121
+
122
+ Layer 1: Storage │ CRUD, persistence, ANN indexing, tiered storage,
123
+ (graph.py, │ BM25 keyword index, multi-level caching
124
+ anchor.py, │ "Where is this memory stored?"
125
+ storage.py, │
126
+ sqlite_storage.py,│
127
+ index.py, │
128
+ bm25.py, │
129
+ cognitive_cache.py,│
130
+ tier.py) │
131
+ ```
132
+
133
+ ### Core modules
134
+
135
+ | Module | Role |
136
+ |---|---|
137
+ | `manager.py` | High-level facade — `remember()`, `recall()`, `sleep()`, `save()` |
138
+ | `runtime.py` | Dependency container — manages all subsystem lifecycles |
139
+ | `retrieval_pipeline.py` | 5-layer dimensional descent (L0→L4) with automatic degradation |
140
+ | `scheduler.py` | Context-aware retrieval with memory type selection |
141
+ | `working_memory.py` | Short-term buffer (15-item, 1h TTL) — auto-promotes to long-term |
142
+ | `sleep.py` | 8-phase sleep: N1_Replay → N2_Merge → N3_Compression → N3b_AtomFacts → REM_Emotion → N4_Prune → N5_HubConnect → N6_IndexRebuild |
143
+ | `evolution.py` | Survival-based decay (Ebbinghaus/Power-law/Exponential), belief transitions, interference |
144
+ | `retriever.py` | HybridFusion + OscillationResonance + VectorSimilarity + Personalized PageRank + explainable scores |
145
+ | `dual_channel.py` | System-1 (fast) + System-2 (deep) dual-channel retrieval with auto-trigger |
146
+ | `bm25.py` | Sparse keyword retrieval (BM25) with reciprocal rank fusion for hybrid search |
147
+ | `ghost.py` | Latent memory traces with fuzzy recall and contradiction tracking (NegativeGhost) |
148
+ | `abstraction.py` | Emergent category discovery from anchor clusters |
149
+ | `community.py` | Louvain community detection with centroid routing |
150
+ | `anchor.py` | Memory unit with 6-state lifecycle, 10-dim AnchorVector, multiplicative retention |
151
+ | `graph.py` | Star graph with RichEdge (temporal, causal, state-transition), Schema, ReflectionNode |
152
+ | `timespine.py` | Temporal index for O(days×buckets) time-scoped retrieval |
153
+ | `cascade.py` | Causal chain traversal across connected memory sequences |
154
+ | `hub.py` | Hierarchical hub-and-spoke abstraction (leaf→domain→global) |
155
+ | `cortex.py` | Partitioned memory cortices with independent sleep and retrieval |
156
+ | `cognitive_cache.py` | Multi-level cache (query/session/topic/activation) + exact-match entity lookup |
157
+ | `tier.py` | STM/MTM/LTM/Core cognitive tiering + HOT/WARM/COLD storage tiers |
158
+ | `autobiography.py` | Self-narrative formation and autobiographical memory |
159
+ | `atom_facts.py` | LLM-powered atomic fact extraction from memory clusters |
160
+ | `survival.py` | Pluggable survival functions (Ebbinghaus, Power-law, Exponential, Custom) |
161
+ | `compression.py` | Multi-level session compression (episodic/strategic/meta) |
162
+ | `resonance.py` | Phase-locked oscillation resonance for temporal-coherent retrieval |
163
+ | `streaming.py` | Streaming memory buffer with backpressure |
164
+ | `benchmark.py` | Built-in benchmark suite (5 categories) |
165
+ | `config.py` | Centralized YAML config with schema validation, dot-path access, overrides |
166
+
167
+ ## Retrieval Benchmarks
168
+
169
+ ### LoCoMo Benchmark (real-world conversations)
170
+
171
+ Evaluated on the [LoCoMo-10 dataset](https://github.com/snap-research/LoCoMo): 10 conversations, 5,882 turns across 272 sessions, 1,986 QA pairs across 5 categories. Pure retrieval (no LLM generation).
172
+
173
+ | Method | has_answer | F1 | Latency |
174
+ |---|---|---|---|
175
+ | VectorSimilarity | 13.1% | 0.026 | 122.2ms |
176
+ | OscillationResonance | 11.9% | 0.026 | 110.4ms |
177
+ | **HybridFusion + BM25** | **15.3%** | **0.025** | <200ms |
178
+
179
+ Per-category has_answer:
180
+
181
+ | Category | #QA | VecSim | OscRes | HybFus |
182
+ |---|---|---|---|---|
183
+ | Temporal (1) | 282 | 3.5% | 2.8% | 4.3% |
184
+ | Short Memory (2) | 321 | 1.9% | 2.2% | 1.9% |
185
+ | Long Memory (3) | 96 | 2.1% | 2.1% | 3.1% |
186
+ | Composite (4) | 841 | 18.0% | 16.4% | 21.0% |
187
+ | Adversarial (5) | 446 | 20.4% | 18.4% | 23.5% |
188
+
189
+ ### Internal Benchmark (synthetic multi-session)
190
+
191
+ 6 sessions × 80 turns, 5 categories. 1.7x compression (6,708 → 3,982 tokens) with maintained or improved recall.
192
+
193
+ | Method | C-R@3 | C-R@5 | Interf |
194
+ |---|---|---|---|
195
+ | VectorSimilarity | 0.933 | 0.933 | N/A |
196
+ | **OscillationResonance** | **0.967** | **0.967** | 0.667 |
197
+ | HybridFusion | 0.900 | 0.900 | 0.667 |
198
+
199
+ ## Memory Lifecycle
200
+
201
+ Every anchor moves through 6 states:
202
+
203
+ ```
204
+ ACTIVE → REHEARSING → CONSOLIDATING → DORMANT → GHOST → REACTIVATED
205
+ ```
206
+
207
+ - **Active**: Just created or recently accessed — fully plastic, easy to update
208
+ - **Rehearsing**: Being replayed during sleep — temporarily elevated importance
209
+ - **Consolidating**: Transferring from hippocampal to cortical — increasing stability
210
+ - **Dormant**: Stable, low-activity — read-only, cortical retrieval
211
+ - **Ghost**: Pruned but with residual trace — can partially recall or fully revive
212
+ - **Reactivated**: Ghost revived by new relevant experience — reduced stability, high plasticity
213
+
214
+ Paired with **ThermalState** (HOT → WARM → COLD → DEAD) for storage tier switching:
215
+ - HOT: in-memory, fully accessible
216
+ - WARM: in-memory, periodically flushed to disk
217
+ - COLD: disk-only, transparent thaw on access
218
+
219
+ ## Sleep Consolidation
220
+
221
+ Sleep is not cleanup. Sleep **changes the graph**:
222
+
223
+ 1. **N1_Replay** — prioritizes surprising and emotional memories for replay via SWR scoring
224
+ 2. **N2_Merge** — fuses near-duplicate anchors (ANN-accelerated, O(n×k)), bridges constellations
225
+ 3. **N3_Compression** — transfers memories from hippocampal to cortical, forms schemas
226
+ 4. **N3b_AtomFacts** — LLM extraction of atomic facts from compressed clusters
227
+ 5. **REM_Emotion** — strips emotional charge from consolidated memories
228
+ 6. **N4_Prune** — removes weak anchors/edges, creates ghost traces for savings effect
229
+ 7. **N5_HubConnect** — cross-cortex hub bridge formation
230
+ 8. **N6_IndexRebuild** — refreshes ANN, BM25, and community indices
231
+
232
+ ## Dual-Channel Retrieval
233
+
234
+ System-1 (fast, embedding + BM25 hybrid) and System-2 (deep, hierarchical traversal) with automatic triggering:
235
+
236
+ - Low-confidence System-1 results (<0.35) automatically trigger System-2
237
+ - Structural keywords ("all", "every", "list", "which", "before", "last") trigger exhaustive search
238
+ - Results merged via weighted reciprocal rank fusion
239
+
240
+ ## Configuration
241
+
242
+ ```python
243
+ from star_graph.config import config, override, load_config
244
+
245
+ # Dot-path access
246
+ threshold = config.sleep.merge.default_threshold # 0.85
247
+
248
+ # Programmatic override
249
+ override('sleep.merge.default_threshold', 0.75)
250
+ override('gate.k', 30)
251
+
252
+ # Schema validation
253
+ warnings = config.validate() # type, range, and cross-section checks
254
+
255
+ # Load custom YAML
256
+ cfg = load_config("my_params.yaml")
257
+ ```
258
+
259
+ See `star_graph/defaults.yaml` for all 300+ tunable parameters.
260
+
261
+ ## Installation
262
+
263
+ ```bash
264
+ # From PyPI (package name: NWcortex, import as: star_graph)
265
+ pip install NWcortex
266
+
267
+ # With sentence-transformers for semantic embeddings (~2GB model download on first use)
268
+ pip install "NWcortex[embeddings]"
269
+
270
+ # Optional: for SQLite storage backend
271
+ pip install aiosqlite
272
+
273
+ # Run demo
274
+ python examples/emergence_demo.py
275
+ ```
276
+
277
+ **Note:** Without `[embeddings]`, the system uses a lightweight TF-IDF fallback for text encoding. Install `sentence-transformers` only if you need semantic-quality embeddings.
278
+
279
+ ## Interactive Demo
280
+
281
+ ```bash
282
+ python examples/emergence_demo.py
283
+
284
+ # Or use the CLI:
285
+ # sg-add "Discussed microservices deployment patterns" --tags architecture --emotional 0.6
286
+ # sg-query "database connection pooling best practices"
287
+ # sg-query --trace "When did Alice visit Hawaii?"
288
+ # sg-stats --schemas --ghosts
289
+ # sg-sleep --retention 0.15 --edge-prune 0.1
290
+ ```
291
+
292
+ ## Benchmarks
293
+
294
+ ```bash
295
+ python examples/memory_benchmark.py --quick # 4 sessions, ~200 turns
296
+ python examples/memory_benchmark.py --full # 12 sessions, ~5000 turns
297
+ ```
298
+
299
+ ## Running Tests
300
+
301
+ ```bash
302
+ pip install pytest pytest-cov
303
+ pytest tests/ -v
304
+
305
+ # With coverage report
306
+ pytest tests/ --cov=star_graph --cov-report=term
307
+ ```
308
+
309
+ **Status:** 1,989 tests passing, 80% coverage (v1.0.0).
310
+
311
+ ## Roadmap
312
+
313
+ See [ROADMAP.md](ROADMAP.md) for planned work.
314
+
315
+ ## License
316
+
317
+ MIT
@@ -0,0 +1,196 @@
1
+ LICENSE
2
+ MANIFEST.in
3
+ README.md
4
+ pyproject.toml
5
+ NWcortex.egg-info/PKG-INFO
6
+ NWcortex.egg-info/SOURCES.txt
7
+ NWcortex.egg-info/dependency_links.txt
8
+ NWcortex.egg-info/entry_points.txt
9
+ NWcortex.egg-info/requires.txt
10
+ NWcortex.egg-info/top_level.txt
11
+ examples/ablation_benchmark.py
12
+ examples/emergence_demo.py
13
+ examples/locomo_eval.py
14
+ examples/locomo_llm_eval.py
15
+ examples/locomo_test.py
16
+ examples/memory_basic.py
17
+ examples/memory_benchmark.py
18
+ star_graph/__init__.py
19
+ star_graph/__main__.py
20
+ star_graph/abstraction.py
21
+ star_graph/anchor.py
22
+ star_graph/async_manager.py
23
+ star_graph/atom_facts.py
24
+ star_graph/autobiography.py
25
+ star_graph/benchmark.py
26
+ star_graph/bm25.py
27
+ star_graph/brain_sphere.py
28
+ star_graph/cascade.py
29
+ star_graph/causal_edges.py
30
+ star_graph/cli.py
31
+ star_graph/cluster_memory.py
32
+ star_graph/cognitive_cache.py
33
+ star_graph/community.py
34
+ star_graph/competition.py
35
+ star_graph/compiler.py
36
+ star_graph/compression.py
37
+ star_graph/config.py
38
+ star_graph/cortex.py
39
+ star_graph/cost_estimator.py
40
+ star_graph/defaults.yaml
41
+ star_graph/domain_router.py
42
+ star_graph/dual_channel.py
43
+ star_graph/edge_budget.py
44
+ star_graph/edge_decay.py
45
+ star_graph/edge_management.py
46
+ star_graph/embedding.py
47
+ star_graph/episodic_memory.py
48
+ star_graph/evolution.py
49
+ star_graph/exact_cache.py
50
+ star_graph/four_layer.py
51
+ star_graph/gate.py
52
+ star_graph/ghost.py
53
+ star_graph/goal_tree.py
54
+ star_graph/graph.py
55
+ star_graph/hippocampus.py
56
+ star_graph/hub.py
57
+ star_graph/index.py
58
+ star_graph/layers.py
59
+ star_graph/logger.py
60
+ star_graph/manager.py
61
+ star_graph/manager_stats.py
62
+ star_graph/math_utils.py
63
+ star_graph/mcp_server.py
64
+ star_graph/metrics.py
65
+ star_graph/micro_sleep.py
66
+ star_graph/multimodal.py
67
+ star_graph/online.py
68
+ star_graph/personality.py
69
+ star_graph/raw_buffer.py
70
+ star_graph/reflection_loop.py
71
+ star_graph/resonance.py
72
+ star_graph/retrieval_budget.py
73
+ star_graph/retrieval_core.py
74
+ star_graph/retrieval_pipeline.py
75
+ star_graph/retriever.py
76
+ star_graph/router.py
77
+ star_graph/runtime.py
78
+ star_graph/runtime_core.py
79
+ star_graph/runtime_lifecycle.py
80
+ star_graph/runtime_stats.py
81
+ star_graph/scheduler.py
82
+ star_graph/seed.py
83
+ star_graph/self_org.py
84
+ star_graph/server.py
85
+ star_graph/shard.py
86
+ star_graph/sleep.py
87
+ star_graph/sleep_consolidate.py
88
+ star_graph/sleep_nrem.py
89
+ star_graph/sleep_rem.py
90
+ star_graph/sleep_report.py
91
+ star_graph/snapshot.py
92
+ star_graph/spreading.py
93
+ star_graph/sqlite_storage.py
94
+ star_graph/storage.py
95
+ star_graph/storage_backend.py
96
+ star_graph/streaming.py
97
+ star_graph/survival.py
98
+ star_graph/symbolic_filter.py
99
+ star_graph/thermal_store.py
100
+ star_graph/tier.py
101
+ star_graph/tiered.py
102
+ star_graph/timespine.py
103
+ star_graph/topology.py
104
+ star_graph/tracing.py
105
+ star_graph/versioned_memory.py
106
+ star_graph/working_memory.py
107
+ star_graph/write_gate.py
108
+ star_graph/consolidation/__init__.py
109
+ star_graph/contrib/__init__.py
110
+ star_graph/contrib/benchmark.py
111
+ star_graph/contrib/mcp_server.py
112
+ star_graph/contrib/snapshot.py
113
+ star_graph/contrib/streaming.py
114
+ star_graph/contrib/symbolic_filter.py
115
+ star_graph/cortex_api/__init__.py
116
+ star_graph/embedding_provider/__init__.py
117
+ star_graph/embedding_provider/providers.py
118
+ star_graph/extras/__init__.py
119
+ star_graph/extras/autobiography.py
120
+ star_graph/extras/resonance.py
121
+ star_graph/memory_core/__init__.py
122
+ star_graph/retrieval_engine/__init__.py
123
+ tests/test_abstraction.py
124
+ tests/test_abstractive_memory.py
125
+ tests/test_anchor.py
126
+ tests/test_atom_facts.py
127
+ tests/test_autobiography.py
128
+ tests/test_bm25.py
129
+ tests/test_brain_sphere.py
130
+ tests/test_cascade.py
131
+ tests/test_causal_edges.py
132
+ tests/test_cluster_memory.py
133
+ tests/test_cognitive_cache.py
134
+ tests/test_cognitive_compiler.py
135
+ tests/test_community.py
136
+ tests/test_competition.py
137
+ tests/test_compiler.py
138
+ tests/test_compression.py
139
+ tests/test_config_schema.py
140
+ tests/test_cortex_hierarchy.py
141
+ tests/test_cost_estimator.py
142
+ tests/test_domain_router.py
143
+ tests/test_edge_budget.py
144
+ tests/test_edge_decay.py
145
+ tests/test_edge_management.py
146
+ tests/test_embedding.py
147
+ tests/test_episodic_memory.py
148
+ tests/test_evolution.py
149
+ tests/test_four_layer.py
150
+ tests/test_gate.py
151
+ tests/test_ghost.py
152
+ tests/test_ghost_intensity.py
153
+ tests/test_goal_tree.py
154
+ tests/test_graph.py
155
+ tests/test_hippocampus.py
156
+ tests/test_index.py
157
+ tests/test_layers.py
158
+ tests/test_logger.py
159
+ tests/test_manager_stats.py
160
+ tests/test_math_utils.py
161
+ tests/test_memory_tier.py
162
+ tests/test_metrics.py
163
+ tests/test_micro_sleep.py
164
+ tests/test_multimodal.py
165
+ tests/test_online.py
166
+ tests/test_oscillation_match.py
167
+ tests/test_personality.py
168
+ tests/test_raw_buffer.py
169
+ tests/test_readme_doctest.py
170
+ tests/test_reflection_loop.py
171
+ tests/test_resonance.py
172
+ tests/test_retrieval_budget.py
173
+ tests/test_retrieval_trace.py
174
+ tests/test_retriever.py
175
+ tests/test_router.py
176
+ tests/test_scheduler.py
177
+ tests/test_seed.py
178
+ tests/test_self_org.py
179
+ tests/test_shard.py
180
+ tests/test_sleep_consolidation.py
181
+ tests/test_sleep_report.py
182
+ tests/test_spreading.py
183
+ tests/test_sqlite_storage.py
184
+ tests/test_storage.py
185
+ tests/test_storage_backend.py
186
+ tests/test_streaming.py
187
+ tests/test_survival.py
188
+ tests/test_thermal_store.py
189
+ tests/test_tier.py
190
+ tests/test_timespine.py
191
+ tests/test_topology.py
192
+ tests/test_tracing.py
193
+ tests/test_v08_modules.py
194
+ tests/test_versioned_memory.py
195
+ tests/test_working_memory.py
196
+ tests/test_write_gate.py
@@ -0,0 +1,5 @@
1
+ [console_scripts]
2
+ sg-add = star_graph.cli:add
3
+ sg-query = star_graph.cli:query
4
+ sg-sleep = star_graph.cli:sleep_cmd
5
+ sg-stats = star_graph.cli:stats_cmd
@@ -0,0 +1,6 @@
1
+ numpy>=1.24.0
2
+ PyYAML>=6.0
3
+ scikit-learn>=1.3.0
4
+
5
+ [embeddings]
6
+ sentence-transformers>=2.2.0
@@ -0,0 +1 @@
1
+ star_graph