rxon 1.0.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.
Files changed (41) hide show
  1. rxon-1.0.0/LICENSE +348 -0
  2. rxon-1.0.0/PKG-INFO +153 -0
  3. rxon-1.0.0/README.md +120 -0
  4. rxon-1.0.0/pyproject.toml +90 -0
  5. rxon-1.0.0/setup.cfg +4 -0
  6. rxon-1.0.0/src/rxon/__init__.py +202 -0
  7. rxon-1.0.0/src/rxon/blob.py +92 -0
  8. rxon-1.0.0/src/rxon/constants.py +136 -0
  9. rxon-1.0.0/src/rxon/exceptions.py +74 -0
  10. rxon-1.0.0/src/rxon/models.py +388 -0
  11. rxon-1.0.0/src/rxon/py.typed +0 -0
  12. rxon-1.0.0/src/rxon/schema.py +568 -0
  13. rxon-1.0.0/src/rxon/security.py +242 -0
  14. rxon-1.0.0/src/rxon/testing.py +95 -0
  15. rxon-1.0.0/src/rxon/transports/__init__.py +4 -0
  16. rxon-1.0.0/src/rxon/transports/base.py +99 -0
  17. rxon-1.0.0/src/rxon/transports/factory.py +31 -0
  18. rxon-1.0.0/src/rxon/transports/http.py +322 -0
  19. rxon-1.0.0/src/rxon/transports/http_server.py +283 -0
  20. rxon-1.0.0/src/rxon/utils.py +103 -0
  21. rxon-1.0.0/src/rxon/validators.py +33 -0
  22. rxon-1.0.0/src/rxon.egg-info/PKG-INFO +153 -0
  23. rxon-1.0.0/src/rxon.egg-info/SOURCES.txt +39 -0
  24. rxon-1.0.0/src/rxon.egg-info/dependency_links.txt +1 -0
  25. rxon-1.0.0/src/rxon.egg-info/requires.txt +13 -0
  26. rxon-1.0.0/src/rxon.egg-info/top_level.txt +1 -0
  27. rxon-1.0.0/tests/test_audit_fixes.py +207 -0
  28. rxon-1.0.0/tests/test_blob.py +104 -0
  29. rxon-1.0.0/tests/test_caching_edge_cases.py +245 -0
  30. rxon-1.0.0/tests/test_factory.py +27 -0
  31. rxon-1.0.0/tests/test_integration.py +742 -0
  32. rxon-1.0.0/tests/test_matching.py +202 -0
  33. rxon-1.0.0/tests/test_models.py +258 -0
  34. rxon-1.0.0/tests/test_new_features.py +259 -0
  35. rxon-1.0.0/tests/test_policy_models.py +235 -0
  36. rxon-1.0.0/tests/test_schema.py +191 -0
  37. rxon-1.0.0/tests/test_schema_ux.py +423 -0
  38. rxon-1.0.0/tests/test_testing.py +51 -0
  39. rxon-1.0.0/tests/test_utils.py +311 -0
  40. rxon-1.0.0/tests/test_validators.py +31 -0
  41. rxon-1.0.0/tests/test_zero_trust_security.py +170 -0
rxon-1.0.0/LICENSE ADDED
@@ -0,0 +1,348 @@
1
+ Copyright (c) 2025-2026 Dmitrii Gagarin
2
+
3
+ Mozilla Public License Version 2.0
4
+ ==================================
5
+
6
+ 1. Definitions
7
+ --------------
8
+
9
+ 1.1. "Contributor"
10
+ means each individual or legal entity that creates, contributes to
11
+ the creation of, or owns Covered Software.
12
+
13
+ 1.2. "Contributor Version"
14
+ means the combination of the Contributions of others (if any) used
15
+ by a Contributor and that particular Contributor's Contribution.
16
+
17
+ 1.3. "Contribution"
18
+ means Covered Software of a particular Contributor.
19
+
20
+ 1.4. "Covered Software"
21
+ means the Source Code Form to which the initial Contributor has
22
+ attached the notice in Exhibit A, the Executable Form of such Source
23
+ Code Form, and Modifications of such Source Code Form, in each case
24
+ including portions thereof.
25
+
26
+ 1.5. "Incompatible With Secondary Licenses"
27
+ means
28
+ (a) that the initial Contributor has otherwise conditioned
29
+ disbursement of the Covered Software on this representation; or
30
+ (b) that the Covered Software was made available under the Mozilla
31
+ Public License, version 1.1, or a third party archive of such
32
+ software contains a relevant notice.
33
+
34
+ 1.6. "Executable Form"
35
+ means any form of the work other than Source Code Form.
36
+
37
+ 1.7. "Larger Work"
38
+ means a work that combines Covered Software with other material, in
39
+ a separate file or files, that is not Covered Software.
40
+
41
+ 1.8. "License"
42
+ means this document.
43
+
44
+ 1.9. "Licensable"
45
+ means having the right to grant, to the maximum extent possible,
46
+ whether at the time of the initial grant or subsequently, any and
47
+ all of the rights conveyed by this License.
48
+
49
+ 1.10. "Modifications"
50
+ means any of the following:
51
+ (a) any file in Source Code Form that results from an addition to,
52
+ deletion from, or modification of the contents of Covered
53
+ Software; or
54
+ (b) any new file in Source Code Form that contains any Covered
55
+ Software.
56
+
57
+ 1.11. "Source Code Form"
58
+ means the form of the work preferred for making modifications.
59
+
60
+ 1.12. "You" (or "Your")
61
+ means an individual or a legal entity exercising rights under this
62
+ License. For legal entities, "You" includes any entity that
63
+ controls, is controlled by, or is under common control with You. For
64
+ purposes of this definition, "control" means (a) the power, direct
65
+ or indirect, to cause the direction or management of such entity,
66
+ whether by contract or otherwise, or (b) ownership of more than
67
+ fifty percent (50%) of the outstanding shares or beneficial
68
+ ownership of such entity.
69
+
70
+ 2. License Grants and Conditions
71
+ --------------------------------
72
+
73
+ 2.1. Grants
74
+
75
+ Each Contributor hereby grants You a world-wide, royalty-free,
76
+ non-exclusive license:
77
+
78
+ (a) under intellectual property rights (other than patent or trademark)
79
+ Licensable by such Contributor to use, reproduce, make available,
80
+ modify, display, perform, distribute, and otherwise exploit its
81
+ Contributions, either on an unmodified basis, with Modifications, or
82
+ as part of a Larger Work; and
83
+
84
+ (b) under Patent Claims of such Contributor to make, use, sell, offer
85
+ for sale, have made, import, and otherwise transfer either its
86
+ Contributions or its Contributions as combined with any
87
+ Modifications of the Contributor Version.
88
+
89
+ 2.2. Effective Date
90
+
91
+ The licenses granted in Section 2.1 with respect to any Contribution
92
+ become effective for each Contribution on the date the Contributor first
93
+ distributes such Contribution.
94
+
95
+ 2.3. Limitations on Grant Scope
96
+
97
+ The licenses granted in this Section 2 are the only rights granted under
98
+ this License. No additional rights or licenses will be implied from the
99
+ distribution or licensing of Covered Software under this License.
100
+ Notwithstanding Section 2.1(b) above, no patent license is granted by a
101
+ Contributor:
102
+
103
+ (a) for any code that a Contributor has removed from Covered Software;
104
+ or
105
+
106
+ (b) for infringements caused by: (i) Your and any other third party's
107
+ modifications of Covered Software, or (ii) the combination of its
108
+ Contributions with other software (except as part of its Contributor
109
+ Version); or
110
+
111
+ (c) under Patent Claims infringed by Covered Software in the absence of
112
+ its Contributions.
113
+
114
+ This License does not grant any rights in the trademarks, service marks,
115
+ or logos of any Contributor (except as may be necessary to comply with
116
+ the notice requirements in Section 3.4).
117
+
118
+ 2.4. Subsequent Licenses
119
+
120
+ No Contributor makes additional grants as a result of Your receiving
121
+ Covered Software under a subsequent version of this License (see
122
+ Section 10.2) or under the terms of a Secondary License (see
123
+ Section 3.3).
124
+
125
+ 2.5. Representation
126
+
127
+ Each Contributor represents that the Contributor believes its
128
+ Contributions are its original creation(s) or it has sufficient rights
129
+ to grant the rights conveyed by this License.
130
+
131
+ 2.6. Fair Use
132
+
133
+ This License is not intended to limit any rights You have under
134
+ applicable copyright doctrines of fair use, fair dealing, or other
135
+ equivalents.
136
+
137
+ 2.7. Conditions
138
+
139
+ Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
140
+ in Section 2.1.
141
+
142
+ 3. Responsibilities
143
+ -------------------
144
+
145
+ 3.1. Distribution of Source Form
146
+
147
+ All distribution of Covered Software in Source Code Form, including any
148
+ Modifications that You create or to which You contribute, must be under
149
+ the terms of this License in accordance with Section 3.4. You must
150
+ inform recipients that the Source Code Form of the Covered Software is
151
+ governed by the terms of this License, and how they can obtain a copy of
152
+ this License. You may not attempt to alter or restrict the recipients'
153
+ rights in the Source Code Form.
154
+
155
+ 3.2. Distribution of Executable Form
156
+
157
+ If You distribute Covered Software in Executable Form then:
158
+
159
+ (a) such Covered Software must also be available in Source Code Form,
160
+ as described in Section 3.1, and You must inform recipients of the
161
+ Executable Form how they can obtain a copy of such Source Code
162
+ Form by reasonable means in a timely manner, at a charge no more
163
+ than the cost of distribution to the recipient; and
164
+
165
+ (b) You may distribute such Executable Form under the terms of this
166
+ License, or sublicense it under different terms, provided that the
167
+ license for the Executable Form does not attempt to limit or alter
168
+ the recipients' rights in the Source Code Form under this License.
169
+
170
+ 3.3. Distribution of a Larger Work
171
+
172
+ You may create and distribute a Larger Work under terms of Your choice,
173
+ provided that You also comply with the requirements of this License for
174
+ the Covered Software. If the Larger Work is a combination of Covered
175
+ Software with a work governed by one or more Secondary Licenses, and the
176
+ Covered Software is not Incompatible With Secondary Licenses, this
177
+ License permits You to additionally distribute such Covered Software
178
+ under the terms of such Secondary License(s), so that the recipient of
179
+ the Larger Work may, at their option, further distribute the Covered
180
+ Software under the terms of either this License or such Secondary
181
+ License(s).
182
+
183
+ 3.4. Notices
184
+
185
+ You may not remove or alter the substance of any license notices
186
+ (including copyright notices, patent notices, disclaimers of warranty,
187
+ or limitations of liability) contained within the Source Code Form of
188
+ the Covered Software, except that You may alter any license notices to
189
+ the extent required to remedy inadvertent errors in existing notices.
190
+
191
+ 3.5. Application of Additional Terms
192
+
193
+ You may choose to offer, and to charge a fee for, warranty, support,
194
+ indemnity or liability obligations to one or more recipients of Covered
195
+ Software. However, You may do so only on Your own behalf, and not on
196
+ behalf of any Contributor. You must make it absolutely clear that any
197
+ such warranty, support, indemnity, or liability obligation is offered by
198
+ You alone, and You hereby agree to indemnify every Contributor for any
199
+ liability incurred by such Contributor as a result of warranty,
200
+ support, indemnity or liability terms You offer. You may include
201
+ additional disclaimers of warranty and limitations of liability
202
+ specific to any jurisdiction.
203
+
204
+ 4. Inability to Comply Due to Statute or Regulation
205
+ ---------------------------------------------------
206
+
207
+ If it is impossible for You to comply with any of the terms of this
208
+ License with respect to some or all of the Covered Software due to
209
+ statute, judicial order, or regulation then You must: (a) comply with
210
+ the terms of this License to the maximum extent possible; and (b)
211
+ describe the limitations and the code they affect. Such description must
212
+ be placed in a text file included with all distributions of the Covered
213
+ Software under this License. Except to the extent prohibited by statute
214
+ or regulation, such description must be sufficiently detailed for a
215
+ recipient of ordinary skill to be able to understand it.
216
+
217
+ 5. Termination
218
+ --------------
219
+
220
+ 5.1. The rights granted under this License will terminate automatically
221
+ if You fail to comply with any of its terms. However, if You become
222
+ compliant, then the rights granted under this License from a particular
223
+ Contributor are reinstated (a) provisionally, unless and until such
224
+ Contributor explicitly and finally terminates Your grants, and (b) on an
225
+ ongoing basis, if such Contributor fails to notify You of the
226
+ non-compliance by some reasonable means prior to 60 days after You have
227
+ come back into compliance. Moreover, Your grants from a particular
228
+ Contributor are reinstated on an ongoing basis if such Contributor
229
+ notifies You of the non-compliance by some reasonable means, this is the
230
+ first time You have received notice of non-compliance with this License
231
+ from such Contributor, and You become compliant prior to 30 days after
232
+ Your receipt of the notice.
233
+
234
+ 5.2. If You initiate litigation against any entity by asserting a patent
235
+ infringement claim (excluding declaratory judgment actions,
236
+ counter-claims, and cross-claims) alleging that a Contributor Version
237
+ directly or indirectly infringes any patent, then the rights granted to
238
+ You by any and all Contributors for the Covered Software under Section
239
+ 2.1 of this License shall terminate.
240
+
241
+ 5.3. In the event of termination under Sections 5.1 or 5.2 above, all
242
+ end user license agreements (excluding distributors and resellers) which
243
+ have been validly granted by You or Your distributors under this License
244
+ prior to termination shall survive termination.
245
+
246
+ 6. Disclaimer of Warranty
247
+ -------------------------
248
+
249
+ Covered Software is provided under this License on an "as is" basis,
250
+ without warranty of any kind, either expressed, implied, or statutory,
251
+ including, without limitation, warranties that the Covered Software is
252
+ free of defects, merchantable, fit for a particular purpose or
253
+ non-infringing. The entire risk as to the quality and performance of the
254
+ Covered Software is with You. Should any Covered Software prove
255
+ defective in any respect, You (not any Contributor) assume the cost of
256
+ any necessary servicing, repair, or correction. This disclaimer of
257
+ warranty constitutes an essential part of this License. No use of any
258
+ Covered Software is authorized under this License except under this
259
+ disclaimer.
260
+
261
+ 7. Limitation of Liability
262
+ --------------------------
263
+
264
+ Under no circumstances and under no legal theory, whether tort
265
+ (including negligence), contract, or otherwise, shall any Contributor,
266
+ or anyone who distributes Covered Software as permitted above, be liable
267
+ to You for any direct, indirect, special, incidental, or consequential
268
+ damages of any character including, without limitation, damages for lost
269
+ profits, loss of goodwill, work stoppage, computer failure or
270
+ malfunction, or any and all other commercial damages or losses, even if
271
+ such party shall have been informed of the possibility of such damages.
272
+ This limitation of liability shall not apply to liability for death or
273
+ personal injury resulting from such party's negligence to the extent
274
+ applicable law prohibits such limitation. Some jurisdictions do not
275
+ allow the exclusion or limitation of incidental or consequential
276
+ damages, so this exclusion and limitation may not apply to You.
277
+
278
+ 8. Litigation
279
+ -------------
280
+
281
+ Any litigation relating to this License may be brought only in the
282
+ courts of a jurisdiction where the defendant maintains its principal
283
+ place of business and such litigation shall be governed by laws of that
284
+ jurisdiction, without reference to its conflict-of-law provisions.
285
+ Nothing in this Section shall prevent a party's ability to bring
286
+ cross-claims or counter-claims.
287
+
288
+ 9. Miscellaneous
289
+ ----------------
290
+
291
+ This License represents the complete agreement concerning the subject
292
+ matter hereof. If any provision of this License is held to be
293
+ unenforceable, such provision shall be reformed only to the extent
294
+ necessary to make it enforceable. Any law or regulation which provides
295
+ that the language of a contract shall be construed against the drafter
296
+ shall not be used to construe this License against a Contributor.
297
+
298
+ 10. Versions of the License
299
+ ---------------------------
300
+
301
+ 10.1. New Versions
302
+
303
+ Mozilla Foundation is the license steward. Except as provided in
304
+ Section 10.3, no one other than the license steward has the right to
305
+ modify or publish new versions of this License. Each version will be
306
+ given a distinguishing version number.
307
+
308
+ 10.2. Effect of New Versions
309
+
310
+ You may distribute the Covered Software under the terms of the version
311
+ of the License under which You originally received the Covered Software,
312
+ or under the terms of any subsequent version published by the license
313
+ steward.
314
+
315
+ 10.3. Modified Versions
316
+
317
+ If you create software not governed by this License, and you want to
318
+ create a new license for such software, you may create and use a
319
+ modified version of this License if you rename the license and remove
320
+ any references to the name of the license steward (except to note that
321
+ such modified license differs from this License).
322
+
323
+ 10.4. Distributing Source Code Form that is Incompatible With Secondary
324
+ Licenses (as defined in Section 1.5)
325
+
326
+ If You choose to distribute Source Code Form that is Incompatible With
327
+ Secondary Licenses under the terms of this version of the License, the
328
+ notice described in Exhibit B of this License must be attached.
329
+
330
+ Exhibit A - Source Code Form License Notice
331
+ -------------------------------------------
332
+
333
+ This Source Code Form is subject to the terms of the Mozilla Public
334
+ License, v. 2.0. If a copy of the MPL was not distributed with this
335
+ file, You can obtain one at http://mozilla.org/MPL/2.0/.
336
+
337
+ If it is not possible or desirable to put the notice in a particular
338
+ file, then You may include the notice in a location (such as a LICENSE
339
+ file in a relevant directory) where a recipient would be likely to look
340
+ for such a notice.
341
+
342
+ You may add additional accurate notices of copyright ownership.
343
+
344
+ Exhibit B - "Incompatible With Secondary Licenses" Notice
345
+ ---------------------------------------------------------
346
+
347
+ This Source Code Form is "Incompatible With Secondary Licenses", as
348
+ defined by the Mozilla Public License, v. 2.0.
rxon-1.0.0/PKG-INFO ADDED
@@ -0,0 +1,153 @@
1
+ Metadata-Version: 2.4
2
+ Name: rxon
3
+ Version: 1.0.0
4
+ Summary: RXON (Reverse Axon) - Lightweight Inter-node Reverse Communication Protocol
5
+ Author-email: Dmitrii Gagarin <madgagarin@gmail.com>
6
+ License-Expression: MPL-2.0
7
+ Project-URL: Homepage, https://github.com/madgagarin/rxon
8
+ Project-URL: Repository, https://github.com/madgagarin/rxon
9
+ Classifier: Development Status :: 5 - Production/Stable
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Programming Language :: Python :: 3.11
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: Programming Language :: Python :: 3.13
14
+ Classifier: Programming Language :: Python :: 3.14
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Typing :: Typed
17
+ Requires-Python: >=3.11
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Requires-Dist: aiohttp>=3.14.0
21
+ Requires-Dist: orjson>=3.11.0
22
+ Requires-Dist: msgspec>=0.18.0
23
+ Requires-Dist: fastjsonschema>=2.21.0
24
+ Requires-Dist: cryptography>=42.0.0
25
+ Provides-Extra: dev
26
+ Requires-Dist: mypy~=2.3.0; extra == "dev"
27
+ Requires-Dist: pytest~=9.1.0; extra == "dev"
28
+ Requires-Dist: pytest-asyncio~=1.4.0; extra == "dev"
29
+ Requires-Dist: pytest-cov~=7.1.0; extra == "dev"
30
+ Requires-Dist: ruff; extra == "dev"
31
+ Requires-Dist: mutmut>=3.8.0; extra == "dev"
32
+ Dynamic: license-file
33
+
34
+ # RXON (Reverse Axon) Protocol
35
+
36
+ **EN** | [ES](https://github.com/madgagarin/rxon/blob/main/docs/es/README.md) | [RU](https://github.com/madgagarin/rxon/blob/main/docs/ru/README.md)
37
+
38
+ [![License: MPL 2.0](https://img.shields.io/badge/License-MPL%202.0-brightgreen.svg)](https://opensource.org/licenses/MPL-2.0)
39
+ [![Python 3.11+](https://img.shields.io/badge/python-3.11+-blue.svg)](https://www.python.org/downloads/release/python-3110/)
40
+ [![PyPI version](https://img.shields.io/pypi/v/rxon.svg)](https://pypi.org/project/rxon/)
41
+
42
+ **RXON** (Reverse Axon) is a lightweight protocol for reverse connections, task distribution, and typed inter-service communication within **[HLN (Holarchical Logic Network)](https://github.com/madgagarin/hln)** systems.
43
+
44
+ It provides a strictly typed message foundation and Zero Trust payload verification for distributed agent runtimes.
45
+
46
+ ## Concept
47
+
48
+ In conventional client-server architectures, control planes push requests down to worker nodes. In **RXON**, worker nodes (shells) initiate outbound connections to the orchestrator to pull tasks. This reverse-connection pattern allows workers to operate behind firewalls and NAT without inbound port forwarding, while establishing a bidirectional communication channel.
49
+
50
+ ## Key Features
51
+
52
+ - **Reverse connection (pull model)**: Worker nodes initiate outbound connections to orchestrators to receive tasks, simplifying deployment behind NAT and firewalls.
53
+ - **Zero Trust payload verification**: Message signing with HMAC-SHA256 (symmetric) and Ed25519 (asymmetric), constant-time signature comparison, call-chain tracking (`bubbling_chain`), and task authorization signatures (`sig`).
54
+ - **Policy and telemetry tracking**: Built-in support for execution constraints (`policy`), holarchy call depth (`depth`), execution step counters (`step`), event hash linking (`parent_hash`), execution cost reporting (`costs`), risk levels (`risk`), and required permissions (`permissions`).
55
+ - **Execution receipts**: `ExecutionReceipt` schema for recording advisory routing decisions, candidate evaluations, fallback triggers, and decision latency.
56
+ - **Schema inference and validation**: Generates JSON Schemas from Python handler signatures (`msgspec.Struct`, `dataclass`, models implementing `model_json_schema`, primitives). Caches compiled validators with a thread-safe bounded LRU cache (up to 2048 entries).
57
+ - **Deterministic serialization**: `to_dict` normalizes floating-point values (e.g., `1.0` -> `1`), strips `None` values, and sorts keys via `orjson` to ensure reproducible cryptographic hashes.
58
+ - **Model conversion**: `from_dict` utility based on `msgspec` to convert dictionaries into typed structures (`Struct`, `dataclass`, `Enum`, `UUID`, `datetime`).
59
+ - **Resource matching**: Matches hardware devices and worker resources against task requirements using greater-than-or-equal (numeric) and set intersection/inclusion rules.
60
+ - **Transport resilience**: WebSocket and HTTP polling transports with token refresh, exponential backoff, and HTTP 429 (`Retry-After`) handling.
61
+
62
+ ## Ecosystem
63
+
64
+ RXON is the foundational protocol powering the distributed multi-agent automation stack:
65
+
66
+ - **[HLN (Holarchical Logic Network)](https://github.com/madgagarin/hln)**: Architecture and specification for self-similar holarchies.
67
+ - **[Shellspirit](https://github.com/madgagarin/shellspirit)**: State-machine based orchestrator for long-running AI workflows and distributed execution.
68
+ - **[Shellnode](https://github.com/madgagarin/shellnode)**: Python SDK for building workers (holons) that connect to orchestrators via RXON.
69
+
70
+ ## Architecture & Logic
71
+
72
+ ### Data Integrity & Validation
73
+
74
+ 1. **Serialization stability**: RXON uses `orjson` to produce canonical JSON: floating-point whole numbers are normalized (`10.0` -> `10`), dictionary keys are sorted, and non-string keys are converted to strings. This ensures identical cryptographic hashes for equivalent payloads.
75
+ 2. **Type support**: First-class support for `msgspec.Struct`, standard library `dataclass`, `datetime`, `UUID`, `Enum`, and models exposing `model_json_schema()` or `schema()`.
76
+ 3. **Recursion depth limit**: Recursive traversal in serialization helpers is bounded to 30 levels to prevent stack exhaustion on deeply nested or cyclic payloads.
77
+ 4. **Schema enforcement**: JSON Schemas are compiled and cached in memory. Before task execution, parameters can be validated against the skill's input schema to reject missing required fields or type mismatches early.
78
+
79
+ ### Resource Matching
80
+
81
+ RXON defines declarative matching rules between worker resources and task requirements:
82
+
83
+ 1. **Hardware devices**: Evaluates `HardwareDevice` properties. Numeric requirements use greater-than-or-equal matching (e.g. `vram_gb: 16` requires `vram_gb >= 16`).
84
+ 2. **Generic properties**: Scalar attributes in `properties` follow the same greater-than-or-equal comparison.
85
+ 3. **Capability sets**: When requirements specify a collection of acceptable values (e.g. `["linux", "darwin"]`), matching checks for membership or non-empty set intersection.
86
+
87
+ ### Execution Context & Governance
88
+
89
+ - **Policy constraints (`policy`)**: Dict containing execution constraints (e.g. allowed skills, token limits, budget caps).
90
+ - **Call hierarchy (`depth`, `step`, `parent_hash`)**: Tracks call nesting depth (`depth`), workflow step sequence (`step`), and parent event hash (`parent_hash`).
91
+ - **Task signature (`sig`)**: HMAC-SHA256 signature generated by the orchestrator using `ORCHESTRATOR_SECRET_KEY` and verified by the worker prior to execution.
92
+ - **Timestamp (`timestamp`)**: Integer Unix timestamp in seconds (`int`) to avoid floating-point rounding discrepancies across systems.
93
+ - **Cost reporting (`costs`)**: `TaskResult.costs` field for metrics such as consumed tokens, duration, or currency amounts (e.g. `{"tokens": 1500, "usd": 0.02}`).
94
+
95
+ ## Standard Error Codes
96
+
97
+ - `CONTRACT_VIOLATION_ERROR`: Payload does not conform to the expected schema.
98
+ - `SECURITY_ERROR`: Authentication failure, token expiration, or signature mismatch.
99
+ - `RESOURCE_EXHAUSTED_ERROR`: Worker has insufficient memory, GPU, or compute capacity.
100
+ - `DEPENDENCY_ERROR`: Required upstream service, worker, or artifact is unavailable.
101
+
102
+ ## Quick Start
103
+
104
+ ### Worker Side (Pull)
105
+
106
+ ```python
107
+ from rxon import create_transport
108
+ from rxon.models import HardwareDevice, Resources
109
+
110
+ # 1. Initialize transport (supports http, https, ws, wss)
111
+ transport = create_transport("ws://api.hln.local", "worker-01", "secret-token")
112
+
113
+ # 2. Define worker resources
114
+ my_res = Resources(
115
+ properties={"ram_gb": 64, "cpu_cores": 16},
116
+ devices=[HardwareDevice(type="gpu", model="RTX 4090", properties={"vram_gb": 24})],
117
+ )
118
+
119
+ # 3. Match against task requirements (e.g., GPU with at least 16GB VRAM)
120
+ req = Resources(devices=[HardwareDevice(type="gpu", properties={"vram_gb": 16})])
121
+ if my_res.matches(req):
122
+ print("Worker meets requirements")
123
+ ```
124
+
125
+ ### Orchestrator Side (Server)
126
+
127
+ ```python
128
+ from aiohttp import web
129
+ from rxon import HttpListener
130
+
131
+ app = web.Application()
132
+ listener = HttpListener(app)
133
+
134
+ # Register RXON routes before startup
135
+ listener.setup_routes()
136
+
137
+
138
+ async def my_handler(action, payload, context):
139
+ if action == "poll":
140
+ return {"job_id": "j-1", "task_id": "t-1", "type": "echo"}
141
+ return {"status": "ok"}
142
+
143
+
144
+ await listener.start(handler=my_handler)
145
+ ```
146
+
147
+ ## License
148
+
149
+ This project is licensed under the Mozilla Public License 2.0 (MPL 2.0).
150
+
151
+ ---
152
+
153
+ _Mantra: "The RXON is the medium for the Ghost."_
rxon-1.0.0/README.md ADDED
@@ -0,0 +1,120 @@
1
+ # RXON (Reverse Axon) Protocol
2
+
3
+ **EN** | [ES](https://github.com/madgagarin/rxon/blob/main/docs/es/README.md) | [RU](https://github.com/madgagarin/rxon/blob/main/docs/ru/README.md)
4
+
5
+ [![License: MPL 2.0](https://img.shields.io/badge/License-MPL%202.0-brightgreen.svg)](https://opensource.org/licenses/MPL-2.0)
6
+ [![Python 3.11+](https://img.shields.io/badge/python-3.11+-blue.svg)](https://www.python.org/downloads/release/python-3110/)
7
+ [![PyPI version](https://img.shields.io/pypi/v/rxon.svg)](https://pypi.org/project/rxon/)
8
+
9
+ **RXON** (Reverse Axon) is a lightweight protocol for reverse connections, task distribution, and typed inter-service communication within **[HLN (Holarchical Logic Network)](https://github.com/madgagarin/hln)** systems.
10
+
11
+ It provides a strictly typed message foundation and Zero Trust payload verification for distributed agent runtimes.
12
+
13
+ ## Concept
14
+
15
+ In conventional client-server architectures, control planes push requests down to worker nodes. In **RXON**, worker nodes (shells) initiate outbound connections to the orchestrator to pull tasks. This reverse-connection pattern allows workers to operate behind firewalls and NAT without inbound port forwarding, while establishing a bidirectional communication channel.
16
+
17
+ ## Key Features
18
+
19
+ - **Reverse connection (pull model)**: Worker nodes initiate outbound connections to orchestrators to receive tasks, simplifying deployment behind NAT and firewalls.
20
+ - **Zero Trust payload verification**: Message signing with HMAC-SHA256 (symmetric) and Ed25519 (asymmetric), constant-time signature comparison, call-chain tracking (`bubbling_chain`), and task authorization signatures (`sig`).
21
+ - **Policy and telemetry tracking**: Built-in support for execution constraints (`policy`), holarchy call depth (`depth`), execution step counters (`step`), event hash linking (`parent_hash`), execution cost reporting (`costs`), risk levels (`risk`), and required permissions (`permissions`).
22
+ - **Execution receipts**: `ExecutionReceipt` schema for recording advisory routing decisions, candidate evaluations, fallback triggers, and decision latency.
23
+ - **Schema inference and validation**: Generates JSON Schemas from Python handler signatures (`msgspec.Struct`, `dataclass`, models implementing `model_json_schema`, primitives). Caches compiled validators with a thread-safe bounded LRU cache (up to 2048 entries).
24
+ - **Deterministic serialization**: `to_dict` normalizes floating-point values (e.g., `1.0` -> `1`), strips `None` values, and sorts keys via `orjson` to ensure reproducible cryptographic hashes.
25
+ - **Model conversion**: `from_dict` utility based on `msgspec` to convert dictionaries into typed structures (`Struct`, `dataclass`, `Enum`, `UUID`, `datetime`).
26
+ - **Resource matching**: Matches hardware devices and worker resources against task requirements using greater-than-or-equal (numeric) and set intersection/inclusion rules.
27
+ - **Transport resilience**: WebSocket and HTTP polling transports with token refresh, exponential backoff, and HTTP 429 (`Retry-After`) handling.
28
+
29
+ ## Ecosystem
30
+
31
+ RXON is the foundational protocol powering the distributed multi-agent automation stack:
32
+
33
+ - **[HLN (Holarchical Logic Network)](https://github.com/madgagarin/hln)**: Architecture and specification for self-similar holarchies.
34
+ - **[Shellspirit](https://github.com/madgagarin/shellspirit)**: State-machine based orchestrator for long-running AI workflows and distributed execution.
35
+ - **[Shellnode](https://github.com/madgagarin/shellnode)**: Python SDK for building workers (holons) that connect to orchestrators via RXON.
36
+
37
+ ## Architecture & Logic
38
+
39
+ ### Data Integrity & Validation
40
+
41
+ 1. **Serialization stability**: RXON uses `orjson` to produce canonical JSON: floating-point whole numbers are normalized (`10.0` -> `10`), dictionary keys are sorted, and non-string keys are converted to strings. This ensures identical cryptographic hashes for equivalent payloads.
42
+ 2. **Type support**: First-class support for `msgspec.Struct`, standard library `dataclass`, `datetime`, `UUID`, `Enum`, and models exposing `model_json_schema()` or `schema()`.
43
+ 3. **Recursion depth limit**: Recursive traversal in serialization helpers is bounded to 30 levels to prevent stack exhaustion on deeply nested or cyclic payloads.
44
+ 4. **Schema enforcement**: JSON Schemas are compiled and cached in memory. Before task execution, parameters can be validated against the skill's input schema to reject missing required fields or type mismatches early.
45
+
46
+ ### Resource Matching
47
+
48
+ RXON defines declarative matching rules between worker resources and task requirements:
49
+
50
+ 1. **Hardware devices**: Evaluates `HardwareDevice` properties. Numeric requirements use greater-than-or-equal matching (e.g. `vram_gb: 16` requires `vram_gb >= 16`).
51
+ 2. **Generic properties**: Scalar attributes in `properties` follow the same greater-than-or-equal comparison.
52
+ 3. **Capability sets**: When requirements specify a collection of acceptable values (e.g. `["linux", "darwin"]`), matching checks for membership or non-empty set intersection.
53
+
54
+ ### Execution Context & Governance
55
+
56
+ - **Policy constraints (`policy`)**: Dict containing execution constraints (e.g. allowed skills, token limits, budget caps).
57
+ - **Call hierarchy (`depth`, `step`, `parent_hash`)**: Tracks call nesting depth (`depth`), workflow step sequence (`step`), and parent event hash (`parent_hash`).
58
+ - **Task signature (`sig`)**: HMAC-SHA256 signature generated by the orchestrator using `ORCHESTRATOR_SECRET_KEY` and verified by the worker prior to execution.
59
+ - **Timestamp (`timestamp`)**: Integer Unix timestamp in seconds (`int`) to avoid floating-point rounding discrepancies across systems.
60
+ - **Cost reporting (`costs`)**: `TaskResult.costs` field for metrics such as consumed tokens, duration, or currency amounts (e.g. `{"tokens": 1500, "usd": 0.02}`).
61
+
62
+ ## Standard Error Codes
63
+
64
+ - `CONTRACT_VIOLATION_ERROR`: Payload does not conform to the expected schema.
65
+ - `SECURITY_ERROR`: Authentication failure, token expiration, or signature mismatch.
66
+ - `RESOURCE_EXHAUSTED_ERROR`: Worker has insufficient memory, GPU, or compute capacity.
67
+ - `DEPENDENCY_ERROR`: Required upstream service, worker, or artifact is unavailable.
68
+
69
+ ## Quick Start
70
+
71
+ ### Worker Side (Pull)
72
+
73
+ ```python
74
+ from rxon import create_transport
75
+ from rxon.models import HardwareDevice, Resources
76
+
77
+ # 1. Initialize transport (supports http, https, ws, wss)
78
+ transport = create_transport("ws://api.hln.local", "worker-01", "secret-token")
79
+
80
+ # 2. Define worker resources
81
+ my_res = Resources(
82
+ properties={"ram_gb": 64, "cpu_cores": 16},
83
+ devices=[HardwareDevice(type="gpu", model="RTX 4090", properties={"vram_gb": 24})],
84
+ )
85
+
86
+ # 3. Match against task requirements (e.g., GPU with at least 16GB VRAM)
87
+ req = Resources(devices=[HardwareDevice(type="gpu", properties={"vram_gb": 16})])
88
+ if my_res.matches(req):
89
+ print("Worker meets requirements")
90
+ ```
91
+
92
+ ### Orchestrator Side (Server)
93
+
94
+ ```python
95
+ from aiohttp import web
96
+ from rxon import HttpListener
97
+
98
+ app = web.Application()
99
+ listener = HttpListener(app)
100
+
101
+ # Register RXON routes before startup
102
+ listener.setup_routes()
103
+
104
+
105
+ async def my_handler(action, payload, context):
106
+ if action == "poll":
107
+ return {"job_id": "j-1", "task_id": "t-1", "type": "echo"}
108
+ return {"status": "ok"}
109
+
110
+
111
+ await listener.start(handler=my_handler)
112
+ ```
113
+
114
+ ## License
115
+
116
+ This project is licensed under the Mozilla Public License 2.0 (MPL 2.0).
117
+
118
+ ---
119
+
120
+ _Mantra: "The RXON is the medium for the Ghost."_