arachnite 0.10.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 (61) hide show
  1. arachnite-0.10.1/.github/workflows/ci.yml +74 -0
  2. arachnite-0.10.1/.gitignore +75 -0
  3. arachnite-0.10.1/LICENSE +21 -0
  4. arachnite-0.10.1/PKG-INFO +308 -0
  5. arachnite-0.10.1/README.md +245 -0
  6. arachnite-0.10.1/arachnite/__init__.py +219 -0
  7. arachnite-0.10.1/arachnite/builder.py +179 -0
  8. arachnite-0.10.1/arachnite/bus.py +130 -0
  9. arachnite-0.10.1/arachnite/codec.py +236 -0
  10. arachnite-0.10.1/arachnite/config.py +162 -0
  11. arachnite-0.10.1/arachnite/context.py +299 -0
  12. arachnite-0.10.1/arachnite/distributed/__init__.py +16 -0
  13. arachnite-0.10.1/arachnite/distributed/agent_node.py +193 -0
  14. arachnite-0.10.1/arachnite/distributed/colocation.py +82 -0
  15. arachnite-0.10.1/arachnite/distributed/manifest.py +388 -0
  16. arachnite-0.10.1/arachnite/distributed/mesh.py +125 -0
  17. arachnite-0.10.1/arachnite/distributed/permissions.py +52 -0
  18. arachnite-0.10.1/arachnite/exceptions.py +260 -0
  19. arachnite-0.10.1/arachnite/framework_config.py +305 -0
  20. arachnite-0.10.1/arachnite/health.py +93 -0
  21. arachnite-0.10.1/arachnite/llm_provider.py +541 -0
  22. arachnite-0.10.1/arachnite/logging.py +274 -0
  23. arachnite-0.10.1/arachnite/media.py +196 -0
  24. arachnite-0.10.1/arachnite/models.py +428 -0
  25. arachnite-0.10.1/arachnite/nodes/__init__.py +34 -0
  26. arachnite-0.10.1/arachnite/nodes/action.py +629 -0
  27. arachnite-0.10.1/arachnite/nodes/active_inference.py +144 -0
  28. arachnite-0.10.1/arachnite/nodes/base.py +170 -0
  29. arachnite-0.10.1/arachnite/nodes/decision.py +353 -0
  30. arachnite-0.10.1/arachnite/nodes/instinct.py +340 -0
  31. arachnite-0.10.1/arachnite/nodes/llm.py +341 -0
  32. arachnite-0.10.1/arachnite/nodes/sense.py +412 -0
  33. arachnite-0.10.1/arachnite/py.typed +0 -0
  34. arachnite-0.10.1/arachnite/runtime.py +727 -0
  35. arachnite-0.10.1/arachnite/safety_monitor.py +306 -0
  36. arachnite-0.10.1/arachnite/shutdown.py +165 -0
  37. arachnite-0.10.1/arachnite/supervisor.py +224 -0
  38. arachnite-0.10.1/arachnite/testing.py +137 -0
  39. arachnite-0.10.1/arachnite/transport/__init__.py +25 -0
  40. arachnite-0.10.1/arachnite/transport/base.py +132 -0
  41. arachnite-0.10.1/arachnite/transport/local.py +64 -0
  42. arachnite-0.10.1/arachnite/transport/mqtt.py +217 -0
  43. arachnite-0.10.1/arachnite/transport/nats.py +164 -0
  44. arachnite-0.10.1/arachnite/transport/redis.py +217 -0
  45. arachnite-0.10.1/arachnite/web.py +642 -0
  46. arachnite-0.10.1/arachnite.toml +91 -0
  47. arachnite-0.10.1/benchmarks/__init__.py +1 -0
  48. arachnite-0.10.1/benchmarks/active_inference_comparison.py +495 -0
  49. arachnite-0.10.1/benchmarks/memory_footprint.py +435 -0
  50. arachnite-0.10.1/benchmarks/multistep_action_latency.py +570 -0
  51. arachnite-0.10.1/benchmarks/reflex_latency.py +177 -0
  52. arachnite-0.10.1/benchmarks/scalability_extended.py +306 -0
  53. arachnite-0.10.1/benchmarks/scalability_sweep.py +159 -0
  54. arachnite-0.10.1/benchmarks/soak_test.py +494 -0
  55. arachnite-0.10.1/benchmarks/stage_breakdown.py +286 -0
  56. arachnite-0.10.1/benchmarks/stats.py +413 -0
  57. arachnite-0.10.1/benchmarks/suite.py +1126 -0
  58. arachnite-0.10.1/benchmarks/tick_latency.py +166 -0
  59. arachnite-0.10.1/benchmarks/transport_latency.py +653 -0
  60. arachnite-0.10.1/main.py +16 -0
  61. arachnite-0.10.1/pyproject.toml +95 -0
@@ -0,0 +1,74 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: ['**']
6
+ pull_request:
7
+ workflow_dispatch:
8
+
9
+ concurrency:
10
+ group: ci-${{ github.ref }}
11
+ cancel-in-progress: true
12
+
13
+ jobs:
14
+ test:
15
+ name: test (py${{ matrix.python }})
16
+ runs-on: ubuntu-latest
17
+ strategy:
18
+ fail-fast: false
19
+ matrix:
20
+ python: ['3.10', '3.11', '3.12', '3.13', '3.14']
21
+ steps:
22
+ - uses: actions/checkout@v4
23
+ - uses: actions/setup-python@v5
24
+ with:
25
+ python-version: ${{ matrix.python }}
26
+ cache: pip
27
+ cache-dependency-path: pyproject.toml
28
+ - name: Install
29
+ run: |
30
+ python -m pip install --upgrade pip
31
+ pip install -e ".[all,dev,benchmarks]"
32
+ - name: Run tests
33
+ run: pytest
34
+
35
+ static:
36
+ name: static
37
+ runs-on: ubuntu-latest
38
+ steps:
39
+ - uses: actions/checkout@v4
40
+ - uses: actions/setup-python@v5
41
+ with:
42
+ python-version: '3.12'
43
+ cache: pip
44
+ cache-dependency-path: pyproject.toml
45
+ - name: Install
46
+ run: |
47
+ python -m pip install --upgrade pip
48
+ pip install -e ".[dev]"
49
+ - name: Ruff
50
+ run: ruff check arachnite tests benchmarks
51
+ - name: Mypy
52
+ run: mypy arachnite
53
+
54
+ coverage:
55
+ name: coverage
56
+ runs-on: ubuntu-latest
57
+ steps:
58
+ - uses: actions/checkout@v4
59
+ - uses: actions/setup-python@v5
60
+ with:
61
+ python-version: '3.12'
62
+ cache: pip
63
+ cache-dependency-path: pyproject.toml
64
+ - name: Install
65
+ run: |
66
+ python -m pip install --upgrade pip
67
+ pip install -e ".[all,dev,benchmarks]"
68
+ - name: Run tests with coverage
69
+ run: pytest --cov=arachnite --cov-report=xml --cov-report=term-missing --cov-fail-under=85
70
+ - uses: actions/upload-artifact@v4
71
+ if: always()
72
+ with:
73
+ name: coverage-xml
74
+ path: coverage.xml
@@ -0,0 +1,75 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ .Python
7
+ build/
8
+ develop-eggs/
9
+ dist/
10
+ downloads/
11
+ eggs/
12
+ .eggs/
13
+ lib/
14
+ lib64/
15
+ parts/
16
+ sdist/
17
+ var/
18
+ wheels/
19
+ share/python-wheels/
20
+ *.egg-info/
21
+ .installed.cfg
22
+ *.egg
23
+ MANIFEST
24
+
25
+ # Virtual environments
26
+ .env
27
+ .venv
28
+ env/
29
+ venv/
30
+ ENV/
31
+
32
+ # Testing
33
+ .tox/
34
+ .nox/
35
+ .coverage
36
+ .coverage.*
37
+ .cache
38
+ nosetests.xml
39
+ coverage.xml
40
+ *.cover
41
+ *.py,cover
42
+ .hypothesis/
43
+ .pytest_cache/
44
+ htmlcov/
45
+
46
+ # Type checking
47
+ .mypy_cache/
48
+ .dmypy.json
49
+ dmypy.json
50
+ .pytype/
51
+
52
+ # IDE
53
+ .idea/
54
+ .vscode/
55
+ *.swp
56
+ *.swo
57
+ *~
58
+
59
+ # OS
60
+ .DS_Store
61
+ Thumbs.db
62
+
63
+ # Secrets — never commit these
64
+ .env.local
65
+ .env.*.local
66
+ secrets.yaml
67
+ *.pem
68
+ *.key
69
+
70
+ # Distribution
71
+ *.tar.gz
72
+ *.whl
73
+
74
+ # Quick-launch script
75
+ arachnite.bat
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 memrecolak
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,308 @@
1
+ Metadata-Version: 2.4
2
+ Name: arachnite
3
+ Version: 0.10.1
4
+ Summary: A biologically-inspired reactive agent framework for Python
5
+ Project-URL: Homepage, https://github.com/memrecolak/arachnite-oss
6
+ Project-URL: Repository, https://github.com/memrecolak/arachnite-oss
7
+ Project-URL: Issues, https://github.com/memrecolak/arachnite-oss/issues
8
+ Project-URL: Documentation, https://github.com/memrecolak/arachnite-oss/tree/main/spec
9
+ License: MIT
10
+ License-File: LICENSE
11
+ Keywords: agent,ai,framework,iot,reactive,robotics
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
20
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
21
+ Classifier: Typing :: Typed
22
+ Requires-Python: >=3.10
23
+ Requires-Dist: msgpack>=1.0
24
+ Requires-Dist: tomli>=2.0; python_version < '3.11'
25
+ Requires-Dist: typing-extensions>=4.5; python_version < '3.12'
26
+ Provides-Extra: all
27
+ Requires-Dist: aiomqtt>=2.0; extra == 'all'
28
+ Requires-Dist: anthropic>=0.25; extra == 'all'
29
+ Requires-Dist: fastapi>=0.110; extra == 'all'
30
+ Requires-Dist: llama-cpp-python>=0.2; extra == 'all'
31
+ Requires-Dist: nats-py>=2.7; extra == 'all'
32
+ Requires-Dist: numpy>=1.26; extra == 'all'
33
+ Requires-Dist: openai>=1.0; extra == 'all'
34
+ Requires-Dist: psutil>=5.9; extra == 'all'
35
+ Requires-Dist: redis<7,>=5.0; extra == 'all'
36
+ Requires-Dist: uvicorn>=0.27; extra == 'all'
37
+ Provides-Extra: benchmarks
38
+ Requires-Dist: psutil>=5.9; extra == 'benchmarks'
39
+ Provides-Extra: dev
40
+ Requires-Dist: mypy>=1.9; extra == 'dev'
41
+ Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
42
+ Requires-Dist: pytest-cov>=5.0; extra == 'dev'
43
+ Requires-Dist: pytest>=8.0; extra == 'dev'
44
+ Requires-Dist: ruff>=0.4; extra == 'dev'
45
+ Provides-Extra: llm
46
+ Requires-Dist: anthropic>=0.25; extra == 'llm'
47
+ Provides-Extra: local-llm
48
+ Requires-Dist: llama-cpp-python>=0.2; extra == 'local-llm'
49
+ Provides-Extra: mqtt
50
+ Requires-Dist: aiomqtt>=2.0; extra == 'mqtt'
51
+ Provides-Extra: nats
52
+ Requires-Dist: nats-py>=2.7; extra == 'nats'
53
+ Provides-Extra: numpy
54
+ Requires-Dist: numpy>=1.26; extra == 'numpy'
55
+ Provides-Extra: ollama
56
+ Requires-Dist: openai>=1.0; extra == 'ollama'
57
+ Provides-Extra: redis
58
+ Requires-Dist: redis<7,>=5.0; extra == 'redis'
59
+ Provides-Extra: web
60
+ Requires-Dist: fastapi>=0.110; extra == 'web'
61
+ Requires-Dist: uvicorn>=0.27; extra == 'web'
62
+ Description-Content-Type: text/markdown
63
+
64
+ # Arachnite
65
+
66
+ A biologically-inspired reactive agent framework for Python.
67
+
68
+ The architecture models the nervous system of arachnids — `sense → context →
69
+ reflex → instinct → decide → act`. Developers extend abstract base classes
70
+ to build agents that run on edge devices (Raspberry Pi, Jetson Nano), laptops,
71
+ or cloud servers, all connected by a pluggable transport layer.
72
+
73
+ - **Async-first**: every node interface is `asyncio`-native
74
+ - **Typed**: strict type annotations throughout (mypy strict)
75
+ - **Pluggable transports**: in-process, MQTT, NATS, Redis
76
+ - **Distributed by manifest**: declarative multi-device deployment
77
+ - **Reflex co-location**: safety-critical reflexes are validated at deploy time
78
+ - **Python 3.10+**
79
+
80
+ ## Install
81
+
82
+ ```bash
83
+ pip install arachnite
84
+ ```
85
+
86
+ With optional extras:
87
+
88
+ ```bash
89
+ pip install "arachnite[all]" # every optional dependency
90
+ pip install "arachnite[mqtt]" # MQTT transport
91
+ pip install "arachnite[nats]" # NATS transport
92
+ pip install "arachnite[redis]" # Redis transport
93
+ pip install "arachnite[web]" # bundled signal dashboard
94
+ pip install "arachnite[llm]" # Anthropic LLM provider
95
+ pip install "arachnite[benchmarks]" # psutil for RSS measurement
96
+ ```
97
+
98
+ Development install from source:
99
+
100
+ ```bash
101
+ git clone https://github.com/memrecolak/arachnite-oss.git arachnite
102
+ cd arachnite
103
+ pip install -e ".[all,dev]"
104
+ ```
105
+
106
+ ## Quick start
107
+
108
+ A minimal agent: a sensor that reads temperature, an instinct that fires
109
+ when it gets hot, and an action that cools things down.
110
+
111
+ ```python
112
+ import asyncio
113
+ import time
114
+
115
+ from arachnite import (
116
+ BaseActionNode,
117
+ BaseInstinctNode,
118
+ BaseSenseNode,
119
+ Proposal,
120
+ Result,
121
+ RuntimeBuilder,
122
+ Signal,
123
+ )
124
+
125
+
126
+ class TempSense(BaseSenseNode):
127
+ node_id = "TempSense"
128
+ signal_kind = "temperature"
129
+
130
+ async def read(self) -> Signal:
131
+ return Signal(
132
+ source=self.node_id,
133
+ kind=self.signal_kind,
134
+ value=42.0,
135
+ confidence=1.0,
136
+ timestamp=time.monotonic(),
137
+ )
138
+
139
+
140
+ class HotInstinct(BaseInstinctNode):
141
+ node_id = "HotInstinct"
142
+ priority = 80
143
+
144
+ async def evaluate(self, ctx) -> Proposal | None:
145
+ hot = [s for s in ctx.signals if s.kind == "temperature" and s.value > 40.0]
146
+ if hot:
147
+ return Proposal(
148
+ instinct_id=self.node_id,
149
+ action_id="CoolDown",
150
+ priority=self.priority,
151
+ urgency=0.9,
152
+ )
153
+ return None
154
+
155
+
156
+ class CoolDown(BaseActionNode):
157
+ node_id = "CoolDown"
158
+
159
+ async def execute(self, proposal) -> Result:
160
+ print(f"Cooling down! params={proposal.parameters}")
161
+ return Result(action_id=self.node_id, success=True)
162
+
163
+
164
+ async def main() -> None:
165
+ rt = (
166
+ RuntimeBuilder()
167
+ .sense(TempSense)
168
+ .instinct(HotInstinct)
169
+ .action(CoolDown)
170
+ .tick_rate(5.0)
171
+ .build()
172
+ )
173
+ await rt.start()
174
+ await asyncio.sleep(5.0)
175
+ await rt.stop()
176
+
177
+
178
+ asyncio.run(main())
179
+ ```
180
+
181
+ See the [`examples/`](examples) directory for more complete programs:
182
+ reflex nodes, multi-step actions, supervisor restart policies, and a
183
+ web dashboard.
184
+
185
+ ## Documentation
186
+
187
+ - [`tutorials/`](tutorials) — step-by-step lessons starting at
188
+ [tutorials/01_welcome.md](tutorials/01_welcome.md). Advanced topics
189
+ (multi-step actions, supervisors, distributed deployment, LLM instincts,
190
+ active inference, safety monitors) live under
191
+ [`tutorials/advanced/`](tutorials/advanced).
192
+ - [`spec/`](spec) — the formal framework specification, eight numbered
193
+ sections covering architecture, nodes, runtime, distributed deployment,
194
+ infrastructure, and the benchmark suite.
195
+
196
+ ## Core concepts
197
+
198
+ ### Nodes
199
+
200
+ Five node families, each with an abstract base and a master that owns the
201
+ registered instances:
202
+
203
+ | Node | Returns | When to use |
204
+ | ------------- | ------------ | ------------------------------------------- |
205
+ | `BaseSenseNode` | `Signal` | Read hardware/state, emit one signal per tick |
206
+ | `BaseInstinctNode` | `Proposal` or `None` | Evaluate context, propose an action |
207
+ | `BaseReflexInstinctNode` | `Proposal` or `None` | Same as instinct, but bypasses the decision layer (priority ≥ 200, co-located with target action) |
208
+ | `BaseDecisionNode` | `Decision` | Pick which proposal to execute (Greedy / Weighted / Random / ActiveInference built-ins, or your own) |
209
+ | `BaseActionNode` | `Result` | Carry out the work — must always return, never raise |
210
+ | `MultiStepActionNode` | `Result` | Long-running actions with interrupt/rollback policies |
211
+
212
+ ### Priority convention
213
+
214
+ - **200+** — reflex instincts only
215
+ - **100–199** — safety / survival
216
+ - **50–99** — goal-directed
217
+ - **1–49** — exploratory / maintenance
218
+ - **0** — reserved (inactive)
219
+
220
+ ### Architectural rules
221
+
222
+ 1. Nodes never hold references to each other; communication goes through `SignalBus`.
223
+ 2. `ReflexInstinctNode` and its target `ActionNode` must be on the same `AgentNode`.
224
+ 3. `MultiStepActionNode` mandatory blocks cannot be interrupted (except `emergency_stop`).
225
+ 4. `execute()` on any `ActionNode` must always return a `Result` — never raise.
226
+ 5. `evaluate()` on any `InstinctNode` must return `None` when not applicable — never raise.
227
+ 6. All node I/O must be async — wrap blocking hardware calls in `asyncio.to_thread()`.
228
+
229
+ ## Distributed deployments
230
+
231
+ A `DeploymentManifest` declares which nodes run on which `AgentNode`. The
232
+ manifest validator enforces co-location rules and fails loudly on missing
233
+ environment variables.
234
+
235
+ ```yaml
236
+ agents:
237
+ vision:
238
+ transport: nats
239
+ transport_url: ${NATS_URL}
240
+ nodes:
241
+ - ProximitySense
242
+ - ObjectDetectionSense
243
+ control:
244
+ transport: nats
245
+ transport_url: ${NATS_URL}
246
+ nodes:
247
+ - JointPositionSense
248
+ - CollisionReflex # priority 250, reflex
249
+ - EmergencyRetract # co-located target
250
+ - GraspInstinct
251
+ - PickAndPlace
252
+ ```
253
+
254
+ See [`examples/robot_arm/`](examples/robot_arm) for a runnable two-agent
255
+ case study.
256
+
257
+ ## Benchmarks
258
+
259
+ A reproducible benchmark suite ships under [`benchmarks/`](benchmarks):
260
+
261
+ ```bash
262
+ # Full suite (30 runs, JSON output)
263
+ python benchmarks/suite.py
264
+
265
+ # Quick run (5 runs)
266
+ python benchmarks/suite.py --runs 5
267
+
268
+ # Individual benchmarks
269
+ python benchmarks/tick_latency.py
270
+ python benchmarks/reflex_latency.py
271
+ python benchmarks/scalability_sweep.py
272
+ python benchmarks/transport_latency.py
273
+ ```
274
+
275
+ Benchmarks include tick latency, per-stage breakdown, reflex arc timing,
276
+ memory footprint, scalability sweeps, multi-step action interrupt latency,
277
+ long-horizon stability soak, and transport publish-to-deliver latency.
278
+ All emit JSON with bootstrap CIs for median / P95 / P99.
279
+
280
+ ### Cross-framework comparison (optional)
281
+
282
+ [`baselines/`](baselines) holds comparison harnesses against
283
+ [py_trees](https://github.com/splintered-reality/py_trees),
284
+ [ROS 2](https://docs.ros.org/), and the [Jason](https://jason-lang.github.io/)
285
+ AgentSpeak BDI engine. **These are not part of the framework** — they are
286
+ not installed by `pip install arachnite` and are excluded from the wheel.
287
+ They require external toolchains (JVM, ROS 2) to run. See
288
+ [`baselines/README.md`](baselines/README.md) for setup.
289
+
290
+ ## Development
291
+
292
+ ```bash
293
+ # Run all tests
294
+ pytest
295
+
296
+ # With coverage
297
+ pytest --cov=arachnite --cov-report=term-missing
298
+
299
+ # Type check
300
+ mypy arachnite
301
+
302
+ # Lint
303
+ ruff check arachnite tests benchmarks
304
+ ```
305
+
306
+ ## License
307
+
308
+ MIT — see [LICENSE](LICENSE).