topologist 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.
@@ -0,0 +1,23 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ pull_request:
6
+
7
+ jobs:
8
+ test:
9
+ runs-on: ubuntu-latest
10
+ strategy:
11
+ matrix:
12
+ python-version: ["3.10", "3.11", "3.12"]
13
+
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+ - uses: actions/setup-python@v5
17
+ with:
18
+ python-version: ${{ matrix.python-version }}
19
+ - run: python -m pip install --upgrade pip
20
+ - run: pip install -e ".[dev]"
21
+ - run: ruff check .
22
+ - run: mypy topologist
23
+ - run: python -m pytest -q
@@ -0,0 +1,36 @@
1
+ name: Publish Python package
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'v*'
7
+
8
+ jobs:
9
+ build-and-publish:
10
+ name: Build and publish
11
+ runs-on: ubuntu-latest
12
+
13
+ steps:
14
+ - name: Checkout
15
+ uses: actions/checkout@v4
16
+
17
+ - name: Set up Python
18
+ uses: actions/setup-python@v4
19
+ with:
20
+ python-version: '3.10'
21
+
22
+ - name: Install build tools
23
+ run: |
24
+ python -m pip install --upgrade pip
25
+ python -m pip install --upgrade build twine
26
+
27
+ - name: Build distributions
28
+ run: python -m build
29
+
30
+ - name: Publish to PyPI
31
+ env:
32
+ TWINE_USERNAME: __token__
33
+ TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
34
+ run: |
35
+ python -m pip install --upgrade twine
36
+ python -m twine upload dist/*
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 JadeyGraham96
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,6 @@
1
+ include LICENSE
2
+ include README.md
3
+ include pyproject.toml
4
+ recursive-include examples *.py
5
+ recursive-include tests *.py
6
+ recursive-include .github/workflows *.yml
@@ -0,0 +1,301 @@
1
+ Metadata-Version: 2.4
2
+ Name: topologist
3
+ Version: 0.1.0
4
+ Summary: A production-hardened hyperdimensional neuro-symbolic topology system.
5
+ Author: Robert McMenemy
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/EasyTees/Topologist
8
+ Project-URL: Repository, https://github.com/EasyTees/Topologist
9
+ Project-URL: Documentation, https://github.com/EasyTees/Topologist#readme
10
+ Project-URL: Issues, https://github.com/EasyTees/Topologist/issues
11
+ Keywords: hyperdimensional-computing,neuro-symbolic,topology,reasoning,knowledge-graph
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Intended Audience :: Science/Research
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
21
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
+ Requires-Python: >=3.10
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Requires-Dist: numpy>=1.24
26
+ Requires-Dist: networkx>=3.1
27
+ Requires-Dist: pydantic>=2.5
28
+ Requires-Dist: typer>=0.9
29
+ Requires-Dist: rich>=13.0
30
+ Provides-Extra: dev
31
+ Requires-Dist: pytest>=7.4; extra == "dev"
32
+ Requires-Dist: pytest-cov>=4.1; extra == "dev"
33
+ Requires-Dist: ruff>=0.5; extra == "dev"
34
+ Requires-Dist: mypy>=1.8; extra == "dev"
35
+ Requires-Dist: build>=1.0; extra == "dev"
36
+ Requires-Dist: twine>=4.0; extra == "dev"
37
+ Dynamic: license-file
38
+
39
+ # Topologist
40
+
41
+ A production-hardened **hyperdimensional neuro-symbolic topology system** in Python.
42
+
43
+ Topologist combines:
44
+
45
+ - **Hyperdimensional Computing / Vector Symbolic Architecture** for robust distributed representations.
46
+ - **Neuro-symbolic graph topology** using NetworkX.
47
+ - **Rule-based inference** over symbolic relations.
48
+ - **Topology analytics** including PageRank centrality, communities, shortest paths, drift, and anomaly scoring.
49
+ - **Persistence and export** to JSON, GraphML, and Mermaid.
50
+ - **CLI tooling** for demos and inspection.
51
+
52
+ ---
53
+
54
+ ## Why this exists
55
+
56
+ Most symbolic graph systems are explainable but brittle. Most neural/vector systems are robust but opaque.
57
+
58
+ Topologist sits between the two:
59
+
60
+ ```text
61
+ Symbolic entities and relations
62
+
63
+ Hyperdimensional encoding
64
+
65
+ Topology graph
66
+
67
+ Reasoning + analytics + anomaly detection
68
+ ```
69
+
70
+ Each node and relation is stored symbolically, but also encoded into a high-dimensional bipolar hypervector. This gives you a graph that is queryable and explainable while also having a distributed topology-level memory state.
71
+
72
+ ---
73
+
74
+ ## Install
75
+
76
+ ```bash
77
+ cd topologist
78
+ python -m venv .venv
79
+ source .venv/bin/activate # Windows: .venv\Scripts\activate
80
+ pip install -e ".[dev]"
81
+ ```
82
+
83
+ For development without installing, ensure the package is in the Python path:
84
+
85
+ ```bash
86
+ pip install -e .
87
+ python examples/demo.py
88
+ ```
89
+
90
+ ---
91
+
92
+ ## Quick start
93
+
94
+ ```python
95
+ from topologist import Topologist
96
+ from topologist.models import ReasoningRule
97
+
98
+ system = Topologist()
99
+
100
+ system.add_edge("Neuron", "connects_to", "Synapse", confidence=0.95)
101
+ system.add_edge("Synapse", "supports", "Memory", confidence=0.90)
102
+ system.add_edge("HDC", "models", "Memory", confidence=0.85)
103
+
104
+ created = system.apply_rule(
105
+ ReasoningRule(
106
+ relation_a="connects_to",
107
+ relation_b="supports",
108
+ inferred_relation="indirectly_supports",
109
+ min_confidence=0.5,
110
+ )
111
+ )
112
+
113
+ system.update_global_state(take_snapshot=True)
114
+
115
+ print("Created inferred edges:", created)
116
+ print("Centrality:", system.centrality())
117
+ print("Communities:", system.communities())
118
+ print("Nearest nodes:", system.nearest_nodes("Memory"))
119
+ print("Path:", system.shortest_path("Neuron", "Memory"))
120
+
121
+ system.save("topology.json")
122
+ ```
123
+
124
+ Streaming example
125
+
126
+ ```bash
127
+ # Run the streaming demo which ingests events, applies inference,
128
+ # snapshots state, computes drift, and scores anomalies.
129
+ python examples/streaming_topology.py
130
+ ```
131
+
132
+ ---
133
+
134
+ ## CLI
135
+
136
+ Create a demo topology:
137
+
138
+ ```bash
139
+ topologist demo --output topology.json
140
+ ```
141
+
142
+ Inspect it:
143
+
144
+ ```bash
145
+ topologist inspect topology.json
146
+ ```
147
+
148
+ Export Mermaid:
149
+
150
+ ```bash
151
+ topologist mermaid topology.json --output topology.mmd
152
+ ```
153
+
154
+ ---
155
+
156
+ ## Main features
157
+
158
+ ### 1. Hyperdimensional item memory
159
+
160
+ Stable symbols are encoded into bipolar vectors:
161
+
162
+ ```text
163
+ symbol → {-1, +1}^D
164
+ ```
165
+
166
+ The engine supports:
167
+
168
+ - Binding: elementwise multiplication
169
+ - Bundling: majority superposition
170
+ - Permutation: cyclic shifts for order/role encoding
171
+ - Similarity: cosine similarity
172
+
173
+ ### 2. Symbolic topology graph
174
+
175
+ The graph is a `networkx.MultiDiGraph`, so it supports multiple relation types between the same source and target.
176
+
177
+ Example:
178
+
179
+ ```text
180
+ HDC --models--> Memory
181
+ HDC --enhances--> KnowledgeGraph
182
+ KnowledgeGraph --supports--> Reasoning
183
+ ```
184
+
185
+ ### 3. Rule-based inference
186
+
187
+ Rules operate over two-hop motifs:
188
+
189
+ ```text
190
+ A --relation_a--> B
191
+ B --relation_b--> C
192
+ ----------------------
193
+ A --inferred_relation--> C
194
+ ```
195
+
196
+ ### 4. Drift detection
197
+
198
+ The global graph state is bundled into a single hypervector snapshot.
199
+
200
+ ```python
201
+ system.update_global_state(take_snapshot=True)
202
+ drift = system.topology_drift()
203
+ ```
204
+
205
+ This lets you measure how much the topology has changed over time.
206
+
207
+ ### 5. Anomaly scoring
208
+
209
+ Candidate relations can be compared against the global topology state:
210
+
211
+ ```python
212
+ score = system.relation_anomaly_score("A", "unexpected_relation", "B")
213
+ ```
214
+
215
+ Higher scores mean the relation is less aligned with the current topology memory.
216
+
217
+ ### 6. Confidence decay
218
+
219
+ Knowledge that is not reinforced can gradually lose confidence:
220
+
221
+ ```python
222
+ system.decay_confidence()
223
+ ```
224
+
225
+ This is useful for agent memory, dynamic knowledge graphs, cybersecurity events, medical evidence tracking, and live topology streams.
226
+
227
+ ---
228
+
229
+ ## Project structure
230
+
231
+ ```text
232
+ topologist/
233
+ ├── topologist/
234
+ │ ├── __init__.py
235
+ │ ├── cli.py
236
+ │ ├── config.py
237
+ │ ├── engine.py
238
+ │ ├── exceptions.py
239
+ │ ├── hdc.py
240
+ │ ├── io.py
241
+ │ ├── models.py
242
+ │ └── visualization.py
243
+ ├── examples/
244
+ │ ├── demo.py
245
+ │ └── streaming_topology.py
246
+ ├── tests/
247
+ │ ├── test_engine.py
248
+ │ └── test_hdc.py
249
+ ├── pyproject.toml
250
+ └── README.md
251
+ ```
252
+
253
+ ---
254
+
255
+ ## Run tests
256
+
257
+ ```bash
258
+ pytest -q
259
+ ```
260
+
261
+ ---
262
+
263
+ ## Production hardening included
264
+
265
+ This package includes:
266
+
267
+ - Typed modules
268
+ - Pydantic validation
269
+ - Custom exceptions
270
+ - Save/load roundtrip support
271
+ - CLI entrypoint
272
+ - Config object
273
+ - Test suite
274
+ - Export helpers
275
+ - No notebook-only assumptions
276
+ - No hidden API dependency
277
+ - Deterministic seed support
278
+ - Dimension validation
279
+ - Confidence decay
280
+ - Snapshot capping
281
+
282
+ ---
283
+
284
+ ## Good next upgrades
285
+
286
+ Useful next layers would be:
287
+
288
+ 1. PyTorch Geometric bridge for GNN message passing.
289
+ 2. Streaming event ingestion from Kafka, Redis Streams, or WebSockets.
290
+ 3. Approximate nearest-neighbour search for large item memories.
291
+ 4. Rule DSL with richer multi-hop inference.
292
+ 5. OpenTelemetry tracing.
293
+ 6. FastAPI service wrapper.
294
+ 7. SQLite/Postgres persistence adapter.
295
+ 8. Agent memory adapter for Claude Code, OpenClaw, or local LLM agents.
296
+
297
+ ---
298
+
299
+ ## License
300
+
301
+ MIT
@@ -0,0 +1,263 @@
1
+ # Topologist
2
+
3
+ A production-hardened **hyperdimensional neuro-symbolic topology system** in Python.
4
+
5
+ Topologist combines:
6
+
7
+ - **Hyperdimensional Computing / Vector Symbolic Architecture** for robust distributed representations.
8
+ - **Neuro-symbolic graph topology** using NetworkX.
9
+ - **Rule-based inference** over symbolic relations.
10
+ - **Topology analytics** including PageRank centrality, communities, shortest paths, drift, and anomaly scoring.
11
+ - **Persistence and export** to JSON, GraphML, and Mermaid.
12
+ - **CLI tooling** for demos and inspection.
13
+
14
+ ---
15
+
16
+ ## Why this exists
17
+
18
+ Most symbolic graph systems are explainable but brittle. Most neural/vector systems are robust but opaque.
19
+
20
+ Topologist sits between the two:
21
+
22
+ ```text
23
+ Symbolic entities and relations
24
+
25
+ Hyperdimensional encoding
26
+
27
+ Topology graph
28
+
29
+ Reasoning + analytics + anomaly detection
30
+ ```
31
+
32
+ Each node and relation is stored symbolically, but also encoded into a high-dimensional bipolar hypervector. This gives you a graph that is queryable and explainable while also having a distributed topology-level memory state.
33
+
34
+ ---
35
+
36
+ ## Install
37
+
38
+ ```bash
39
+ cd topologist
40
+ python -m venv .venv
41
+ source .venv/bin/activate # Windows: .venv\Scripts\activate
42
+ pip install -e ".[dev]"
43
+ ```
44
+
45
+ For development without installing, ensure the package is in the Python path:
46
+
47
+ ```bash
48
+ pip install -e .
49
+ python examples/demo.py
50
+ ```
51
+
52
+ ---
53
+
54
+ ## Quick start
55
+
56
+ ```python
57
+ from topologist import Topologist
58
+ from topologist.models import ReasoningRule
59
+
60
+ system = Topologist()
61
+
62
+ system.add_edge("Neuron", "connects_to", "Synapse", confidence=0.95)
63
+ system.add_edge("Synapse", "supports", "Memory", confidence=0.90)
64
+ system.add_edge("HDC", "models", "Memory", confidence=0.85)
65
+
66
+ created = system.apply_rule(
67
+ ReasoningRule(
68
+ relation_a="connects_to",
69
+ relation_b="supports",
70
+ inferred_relation="indirectly_supports",
71
+ min_confidence=0.5,
72
+ )
73
+ )
74
+
75
+ system.update_global_state(take_snapshot=True)
76
+
77
+ print("Created inferred edges:", created)
78
+ print("Centrality:", system.centrality())
79
+ print("Communities:", system.communities())
80
+ print("Nearest nodes:", system.nearest_nodes("Memory"))
81
+ print("Path:", system.shortest_path("Neuron", "Memory"))
82
+
83
+ system.save("topology.json")
84
+ ```
85
+
86
+ Streaming example
87
+
88
+ ```bash
89
+ # Run the streaming demo which ingests events, applies inference,
90
+ # snapshots state, computes drift, and scores anomalies.
91
+ python examples/streaming_topology.py
92
+ ```
93
+
94
+ ---
95
+
96
+ ## CLI
97
+
98
+ Create a demo topology:
99
+
100
+ ```bash
101
+ topologist demo --output topology.json
102
+ ```
103
+
104
+ Inspect it:
105
+
106
+ ```bash
107
+ topologist inspect topology.json
108
+ ```
109
+
110
+ Export Mermaid:
111
+
112
+ ```bash
113
+ topologist mermaid topology.json --output topology.mmd
114
+ ```
115
+
116
+ ---
117
+
118
+ ## Main features
119
+
120
+ ### 1. Hyperdimensional item memory
121
+
122
+ Stable symbols are encoded into bipolar vectors:
123
+
124
+ ```text
125
+ symbol → {-1, +1}^D
126
+ ```
127
+
128
+ The engine supports:
129
+
130
+ - Binding: elementwise multiplication
131
+ - Bundling: majority superposition
132
+ - Permutation: cyclic shifts for order/role encoding
133
+ - Similarity: cosine similarity
134
+
135
+ ### 2. Symbolic topology graph
136
+
137
+ The graph is a `networkx.MultiDiGraph`, so it supports multiple relation types between the same source and target.
138
+
139
+ Example:
140
+
141
+ ```text
142
+ HDC --models--> Memory
143
+ HDC --enhances--> KnowledgeGraph
144
+ KnowledgeGraph --supports--> Reasoning
145
+ ```
146
+
147
+ ### 3. Rule-based inference
148
+
149
+ Rules operate over two-hop motifs:
150
+
151
+ ```text
152
+ A --relation_a--> B
153
+ B --relation_b--> C
154
+ ----------------------
155
+ A --inferred_relation--> C
156
+ ```
157
+
158
+ ### 4. Drift detection
159
+
160
+ The global graph state is bundled into a single hypervector snapshot.
161
+
162
+ ```python
163
+ system.update_global_state(take_snapshot=True)
164
+ drift = system.topology_drift()
165
+ ```
166
+
167
+ This lets you measure how much the topology has changed over time.
168
+
169
+ ### 5. Anomaly scoring
170
+
171
+ Candidate relations can be compared against the global topology state:
172
+
173
+ ```python
174
+ score = system.relation_anomaly_score("A", "unexpected_relation", "B")
175
+ ```
176
+
177
+ Higher scores mean the relation is less aligned with the current topology memory.
178
+
179
+ ### 6. Confidence decay
180
+
181
+ Knowledge that is not reinforced can gradually lose confidence:
182
+
183
+ ```python
184
+ system.decay_confidence()
185
+ ```
186
+
187
+ This is useful for agent memory, dynamic knowledge graphs, cybersecurity events, medical evidence tracking, and live topology streams.
188
+
189
+ ---
190
+
191
+ ## Project structure
192
+
193
+ ```text
194
+ topologist/
195
+ ├── topologist/
196
+ │ ├── __init__.py
197
+ │ ├── cli.py
198
+ │ ├── config.py
199
+ │ ├── engine.py
200
+ │ ├── exceptions.py
201
+ │ ├── hdc.py
202
+ │ ├── io.py
203
+ │ ├── models.py
204
+ │ └── visualization.py
205
+ ├── examples/
206
+ │ ├── demo.py
207
+ │ └── streaming_topology.py
208
+ ├── tests/
209
+ │ ├── test_engine.py
210
+ │ └── test_hdc.py
211
+ ├── pyproject.toml
212
+ └── README.md
213
+ ```
214
+
215
+ ---
216
+
217
+ ## Run tests
218
+
219
+ ```bash
220
+ pytest -q
221
+ ```
222
+
223
+ ---
224
+
225
+ ## Production hardening included
226
+
227
+ This package includes:
228
+
229
+ - Typed modules
230
+ - Pydantic validation
231
+ - Custom exceptions
232
+ - Save/load roundtrip support
233
+ - CLI entrypoint
234
+ - Config object
235
+ - Test suite
236
+ - Export helpers
237
+ - No notebook-only assumptions
238
+ - No hidden API dependency
239
+ - Deterministic seed support
240
+ - Dimension validation
241
+ - Confidence decay
242
+ - Snapshot capping
243
+
244
+ ---
245
+
246
+ ## Good next upgrades
247
+
248
+ Useful next layers would be:
249
+
250
+ 1. PyTorch Geometric bridge for GNN message passing.
251
+ 2. Streaming event ingestion from Kafka, Redis Streams, or WebSockets.
252
+ 3. Approximate nearest-neighbour search for large item memories.
253
+ 4. Rule DSL with richer multi-hop inference.
254
+ 5. OpenTelemetry tracing.
255
+ 6. FastAPI service wrapper.
256
+ 7. SQLite/Postgres persistence adapter.
257
+ 8. Agent memory adapter for Claude Code, OpenClaw, or local LLM agents.
258
+
259
+ ---
260
+
261
+ ## License
262
+
263
+ MIT
@@ -0,0 +1,45 @@
1
+ from topologist import Topologist
2
+ from topologist.models import ReasoningRule
3
+ from topologist.visualization import export_mermaid
4
+
5
+
6
+ def main() -> None:
7
+ topo = Topologist()
8
+
9
+ topo.add_node("Agent", "system")
10
+ topo.add_node("Memory", "cognitive_layer")
11
+ topo.add_node("KnowledgeGraph", "symbolic_layer")
12
+ topo.add_node("HypervectorSpace", "hdc_layer")
13
+ topo.add_node("AnomalyDetector", "reasoning_layer")
14
+
15
+ topo.add_edge("Agent", "uses", "Memory", confidence=0.95)
16
+ topo.add_edge("Memory", "encoded_by", "HypervectorSpace", confidence=0.90)
17
+ topo.add_edge("Memory", "structured_by", "KnowledgeGraph", confidence=0.88)
18
+ topo.add_edge("KnowledgeGraph", "feeds", "AnomalyDetector", confidence=0.82)
19
+
20
+ inferred = topo.apply_rule(
21
+ ReasoningRule(
22
+ relation_a="uses",
23
+ relation_b="encoded_by",
24
+ inferred_relation="indirectly_uses",
25
+ min_confidence=0.5,
26
+ )
27
+ )
28
+
29
+ topo.update_global_state(take_snapshot=True)
30
+
31
+ print(f"Inferred edges: {inferred}")
32
+ print("Centrality:", topo.centrality())
33
+ print("Communities:", topo.communities())
34
+ print("Nearest to Memory:", topo.nearest_nodes("Memory", top_k=3))
35
+ print(
36
+ "Anomaly score:",
37
+ topo.relation_anomaly_score("Agent", "ignores", "Memory"),
38
+ )
39
+
40
+ topo.save("example_topology.json")
41
+ export_mermaid(topo, "example_topology.mmd")
42
+
43
+
44
+ if __name__ == "__main__":
45
+ main()