chorus-fabric 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,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Amin Parva
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,403 @@
1
+ Metadata-Version: 2.4
2
+ Name: chorus-fabric
3
+ Version: 0.1.0
4
+ Summary: High-dimensional tensor communication fabric for AI-to-AI signaling — Patent Pending US 64/096,156
5
+ Author-email: Amin Parva <parvaamin@gmail.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/aminparva84/chorus-fabric
8
+ Project-URL: Documentation, https://github.com/aminparva84/chorus-fabric#readme
9
+ Project-URL: Repository, https://github.com/aminparva84/chorus-fabric
10
+ Project-URL: Bug Tracker, https://github.com/aminparva84/chorus-fabric/issues
11
+ Keywords: AI,machine-to-machine,M2M,tensor,gRPC,embedding,LLM,protocol,cryptography,multiagent
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 :: System :: Networking
22
+ Requires-Python: >=3.10
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Requires-Dist: grpcio>=1.64.0
26
+ Requires-Dist: grpcio-tools>=1.64.0
27
+ Requires-Dist: protobuf>=5.26.0
28
+ Requires-Dist: numpy<2.0.0,>=1.24.0
29
+ Requires-Dist: torch>=2.0.0
30
+ Provides-Extra: server
31
+ Requires-Dist: chorus-fabric; extra == "server"
32
+ Provides-Extra: dev
33
+ Requires-Dist: pytest>=7.0; extra == "dev"
34
+ Requires-Dist: pytest-asyncio; extra == "dev"
35
+ Requires-Dist: black; extra == "dev"
36
+ Requires-Dist: ruff; extra == "dev"
37
+ Dynamic: license-file
38
+
39
+ # chorus-fabric
40
+
41
+ **High-dimensional tensor communication fabric for AI-to-AI signaling.**
42
+
43
+ [![PyPI version](https://img.shields.io/pypi/v/chorus-fabric.svg)](https://pypi.org/project/chorus-fabric/)
44
+ [![Python](https://img.shields.io/pypi/pyversions/chorus-fabric.svg)](https://pypi.org/project/chorus-fabric/)
45
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
46
+ [![Patent Pending](https://img.shields.io/badge/Patent-Pending%2064%2F096%2C156-blue.svg)]()
47
+
48
+ ---
49
+
50
+ Most AI agents talk to each other using HTTP and JSON — serializing embeddings to text, sending them over REST, and parsing them back. That process is slow, wasteful, and lossy.
51
+
52
+ **CHORUS Fabric** is a different approach: AI agents stream raw `float32` embedding vectors directly over bidirectional gRPC, with a built-in tensor multiplication cipher and per-message cryptographic watermark. No tokenization. No JSON. No overhead.
53
+
54
+ > Deployed transatlantic (US East → Germany West Central): **179 ms p50 RTT**, **4.45× less bandwidth than HTTP/REST**, **100% watermark verification** across 7,766 transmissions.
55
+
56
+ > *Patent Pending — US Provisional Application No. 64/096,156*
57
+
58
+ ---
59
+
60
+ ## Installation
61
+
62
+ ```bash
63
+ pip install chorus-fabric
64
+ ```
65
+
66
+ PyTorch is required. If you don't have it:
67
+
68
+ ```bash
69
+ pip install torch --index-url https://download.pytorch.org/whl/cpu
70
+ pip install chorus-fabric
71
+ ```
72
+
73
+ ---
74
+
75
+ ## Quick Start
76
+
77
+ ### 1. Start the services (Docker — easiest)
78
+
79
+ ```bash
80
+ git clone https://github.com/aminparva84/chorus-fabric
81
+ cd chorus-fabric
82
+ docker-compose up
83
+ ```
84
+
85
+ This starts the Control Plane (`:50051`), Relay Node (`:50052`), and Target Pod (`:50053`) locally.
86
+
87
+ ### 2. Send your first tensor
88
+
89
+ ```python
90
+ import torch
91
+ from chorus_fabric import ChorusClient
92
+
93
+ # Connect to the fabric
94
+ client = ChorusClient(
95
+ pod_id="my-agent",
96
+ control_plane="localhost:50051",
97
+ relay="localhost:50052",
98
+ )
99
+
100
+ # Get an ephemeral session key from the Control Plane
101
+ client.handshake()
102
+
103
+ # Send a 128-dimensional embedding vector
104
+ signal = torch.randn(128)
105
+ acks = client.send_direct(signal)
106
+
107
+ print(acks)
108
+ # [{'seq': 0, 'forwarded': True, 'status': 'ok'}]
109
+ ```
110
+
111
+ That's it. The tensor is encrypted with a session-specific matrix cipher, watermarked with a SHA-256-derived authentication vector, streamed over gRPC, and verified at the receiver — all in one call.
112
+
113
+ ---
114
+
115
+ ## Core Concepts
116
+
117
+ ### Tensor Multiplication Cipher
118
+
119
+ Every signal is encrypted by matrix multiplication before transmission:
120
+
121
+ ```
122
+ V_enc = V_raw @ K # at the sender
123
+ V_raw = V_enc @ K_inv # at the receiver
124
+ ```
125
+
126
+ Keys `K` and `K_inv` are generated via QR decomposition — mathematically guaranteed to invert. Both are ephemeral (TTL: 1 hour by default) and issued fresh per session by the Control Plane.
127
+
128
+ ### Rolling Neural Watermark
129
+
130
+ Every payload carries a deterministic authentication vector:
131
+
132
+ ```
133
+ watermark(n) = normalize( seeded_random( SHA-256(session_seed ‖ seq_num) ) )
134
+ ```
135
+
136
+ The receiver recomputes the expected watermark independently and checks cosine similarity ≥ 0.95. A replayed or tampered payload fails immediately — the watermark changes every sequence number.
137
+
138
+ ### Three Transmission Modes
139
+
140
+ | Mode | API call | Use case |
141
+ |------|----------|----------|
142
+ | **Direct** | `send_direct(tensor)` | Single agent → single target |
143
+ | **Isolation (Mode A)** | `send_isolation(tensor_a, tensor_b)` | Two agents share one channel, zero crosstalk |
144
+ | **Superposition (Mode B)** | `send_superposition(tensor_a, tensor_b)` | Consensus / ensemble blend |
145
+
146
+ ---
147
+
148
+ ## Use Cases
149
+
150
+ ### Use Case 1 — AI Agent-to-Agent Communication
151
+
152
+ Replace HTTP REST calls between LangChain / AutoGen agents with direct tensor streams.
153
+
154
+ ```python
155
+ # Agent 1 (source) — e.g. a retrieval agent
156
+ import torch
157
+ from chorus_fabric import ChorusClient
158
+
159
+ retrieval_agent = ChorusClient(pod_id="retrieval", control_plane="cp:50051", relay="relay:50052")
160
+ retrieval_agent.handshake()
161
+
162
+ # Tap the last hidden state from your LLM instead of generating random
163
+ hidden_state = torch.randn(128) # replace with model.last_hidden_state
164
+ acks = retrieval_agent.send_direct(hidden_state)
165
+ ```
166
+
167
+ ```python
168
+ # Agent 2 (target) — receives the embedding directly
169
+ # Run: python -m chorus_fabric.servers target
170
+ # The target pod decrypts, verifies, and processes the vector
171
+ ```
172
+
173
+ No JSON serialization. No tokenization round-trip. The embedding arrives at the receiving agent exactly as it left the sender.
174
+
175
+ ---
176
+
177
+ ### Use Case 2 — Dual-Agent Isolation (Mode A)
178
+
179
+ Two agents share a single encrypted channel. Each recovers only its own signal — measured crosstalk: **0.000006%**.
180
+
181
+ ```python
182
+ from chorus_fabric import ChorusClient
183
+ import torch
184
+
185
+ client = ChorusClient(pod_id="dual-agent", control_plane="cp:50051", relay="relay:50052")
186
+ client.handshake(isolation_mode=True) # fetches orthogonal projection matrices
187
+
188
+ agent_a_signal = torch.randn(128) # Agent A's embedding
189
+ agent_b_signal = torch.randn(128) # Agent B's embedding
190
+
191
+ # Both signals travel as a single encrypted payload
192
+ acks = client.send_isolation(agent_a_signal, agent_b_signal)
193
+ # At the receiver: W_A @ V_dec recovers A's signal, W_B @ V_dec recovers B's
194
+ ```
195
+
196
+ **When to use this:** Multi-agent pipelines where two agents need to coordinate over the same network channel without exposing each other's signals to the relay.
197
+
198
+ ---
199
+
200
+ ### Use Case 3 — Ensemble / Consensus Voting (Mode B)
201
+
202
+ Blend multiple agent signals into one collective transmission.
203
+
204
+ ```python
205
+ from chorus_fabric import ChorusClient
206
+ import torch
207
+
208
+ client = ChorusClient(pod_id="ensemble", control_plane="cp:50051", relay="relay:50052")
209
+ client.handshake()
210
+
211
+ # Three models vote on a decision — blend their hidden states
212
+ model_a_vote = torch.randn(128)
213
+ model_b_vote = torch.randn(128)
214
+
215
+ # Send the superposed collective state in a single payload
216
+ acks = client.send_superposition(model_a_vote, model_b_vote)
217
+ ```
218
+
219
+ **When to use this:** Ensemble inference, multi-model voting, distributed sensor fusion — any case where the aggregate state matters more than individual signals.
220
+
221
+ ---
222
+
223
+ ### Use Case 4 — Secure Relay (Confidential Multi-Hop)
224
+
225
+ A Relay Node amplifies and forwards signals without ever decrypting them. The relay logs a SHA-256 fingerprint of each ciphertext for audit — but the plaintext is invisible to it.
226
+
227
+ ```python
228
+ # Relay operates transparently — no code changes needed on the client
229
+ # The relay sits between source and target:
230
+ # source -> relay (amplify + audit log) -> target
231
+
232
+ # From the client's perspective it's identical to direct:
233
+ client = ChorusClient(pod_id="source", control_plane="cp:50051", relay="relay:50052")
234
+ client.handshake()
235
+ acks = client.send_direct(my_tensor)
236
+ # relay logs SHA-256(ciphertext) but never sees V_raw
237
+ ```
238
+
239
+ **When to use this:** Two companies running a joint AI pipeline — a neutral relay in the middle can audit traffic volume and timing without accessing the content.
240
+
241
+ ---
242
+
243
+ ### Use Case 5 — Crypto Primitives Standalone
244
+
245
+ Use just the crypto engine without the full gRPC stack:
246
+
247
+ ```python
248
+ from chorus_fabric import generate_key_pair, encrypt, decrypt, inject_watermark, verify_watermark
249
+ import torch
250
+
251
+ # Generate a session key pair
252
+ K, K_inv = generate_key_pair(dim=128)
253
+
254
+ # Encrypt a signal
255
+ signal = torch.randn(128)
256
+ ciphertext = encrypt(signal, K)
257
+
258
+ # Add a rolling watermark
259
+ seed = b'\x00' * 32
260
+ authenticated = inject_watermark(signal, seed=seed, seq_num=0)
261
+
262
+ # Decrypt and verify
263
+ recovered = decrypt(ciphertext, K_inv)
264
+ is_valid = verify_watermark(recovered, seed=seed, seq_num=0)
265
+ print(f"Verified: {is_valid}") # True
266
+ ```
267
+
268
+ ---
269
+
270
+ ## Architecture
271
+
272
+ ```
273
+ ┌─────────────┐ RegisterAndRequestKey ┌──────────────────┐
274
+ │ Your Agent │ ──────────────────────────────► │ Control Plane │
275
+ │ (Source) │ ◄────────────────────────────── │ :50051 │
276
+ │ │ SessionKeyBundle │ (key issuance) │
277
+ │ │ { K, K_inv, seed, TTL } └──────────────────┘
278
+ │ │
279
+ │ │ TensorPayload (V_enc) ┌──────────────────┐
280
+ │ │ ──────────────────────────────► │ Relay Node │
281
+ │ │ │ :50052 │
282
+ │ │ │ • amplify V_enc │
283
+ │ │ │ • log SHA-256 │
284
+ │ │ │ • no decryption │
285
+ │ │ └────────┬─────────┘
286
+ │ │ │ V_amp
287
+ │ │ ▼
288
+ │ │ RelayAck ┌──────────────────┐
289
+ │ │ ◄────────────────────────────── │ Target Pod │
290
+ └─────────────┘ │ :50053 │
291
+ │ • decrypt │
292
+ │ • verify wm │
293
+ │ • mode dispatch │
294
+ └──────────────────┘
295
+ ```
296
+
297
+ ---
298
+
299
+ ## Benchmark Results
300
+
301
+ Live transatlantic deployment — US East (Virginia) → Germany West Central (Frankfurt), ~8,000 km.
302
+
303
+ | Metric | Value |
304
+ |--------|-------|
305
+ | Direct mode p50 RTT | **179 ms** |
306
+ | Direct mode p95 RTT | 300 ms |
307
+ | Mode A (Isolation) p50 | 311 ms |
308
+ | Mode B (Superposition) p50 | 1,274 ms |
309
+ | Watermark verification | **7,766 / 7,766 (100%)** |
310
+ | Cipher overhead vs raw RTT | **0 ms** (matches physical minimum) |
311
+
312
+ ### Bandwidth comparison per 128-dim payload
313
+
314
+ | Protocol | Bytes/payload | vs CHORUS |
315
+ |----------|--------------|-----------|
316
+ | **CHORUS gRPC** | **548 B** | 1× |
317
+ | HTTP/REST JSON | 2,440 B | 4.45× more |
318
+ | LLM API call | 3,900 B | 7.1× more |
319
+
320
+ ---
321
+
322
+ ## Running Services Manually
323
+
324
+ ### Control Plane
325
+ ```bash
326
+ CHORUS_DIM=128 CONTROL_PLANE_PORT=50051 python -m chorus_fabric.servers control_plane
327
+ ```
328
+
329
+ ### Relay Node
330
+ ```bash
331
+ RELAY_PORT=50052 CONTROL_PLANE_HOST=localhost python -m chorus_fabric.servers relay
332
+ ```
333
+
334
+ ### Target Pod
335
+ ```bash
336
+ TARGET_PORT=50053 CONTROL_PLANE_HOST=localhost python -m chorus_fabric.servers target
337
+ ```
338
+
339
+ ### Environment Variables
340
+
341
+ | Variable | Default | Description |
342
+ |----------|---------|-------------|
343
+ | `CHORUS_DIM` | `128` | Embedding dimension |
344
+ | `CONTROL_PLANE_HOST` | `localhost` | Control plane hostname |
345
+ | `CONTROL_PLANE_PORT` | `50051` | Control plane port |
346
+ | `RELAY_HOST` | `localhost` | Relay node hostname |
347
+ | `RELAY_PORT` | `50052` | Relay node port |
348
+ | `CHORUS_TARGET_HOST` | `localhost` | Target pod hostname |
349
+ | `CHORUS_TARGET_PORT` | `50053` | Target pod port |
350
+ | `CHORUS_SESSION_TTL` | `3600` | Session key TTL in seconds |
351
+ | `CHORUS_AMPLIFY_FACTOR` | `1.0` | Relay amplification factor |
352
+
353
+ ---
354
+
355
+ ## Docker Compose (Full Stack)
356
+
357
+ ```yaml
358
+ # docker-compose.yml included in repo
359
+ services:
360
+ control-plane:
361
+ build: .
362
+ command: python -m chorus_fabric.servers control_plane
363
+ ports: ["50051:50051"]
364
+
365
+ relay-node:
366
+ build: .
367
+ command: python -m chorus_fabric.servers relay
368
+ ports: ["50052:50052"]
369
+
370
+ target-pod:
371
+ build: .
372
+ command: python -m chorus_fabric.servers target
373
+ ports: ["50053:50053"]
374
+ ```
375
+
376
+ ---
377
+
378
+ ## Patent Notice
379
+
380
+ The CHORUS Fabric protocol — including the tensor multiplication cipher, rolling neural watermark, orthogonal isolation mode, holographic superposition mode, relay confidentiality architecture, and control plane key management — is protected under:
381
+
382
+ **US Provisional Patent Application No. 64/096,156**
383
+ *The Chorus Fabric: High-Dimensional Signal Orchestration for Machine-to-Machine Communication*
384
+ Filed: June 22, 2026 — Inventor: Amin Parva
385
+
386
+ This library is released under the MIT License for use by developers. Commercial licensing for embedding the protocol into proprietary products is available — contact **parvaamin@gmail.com**.
387
+
388
+ ---
389
+
390
+ ## License
391
+
392
+ MIT License — Copyright (c) 2026 Amin Parva
393
+
394
+ See [LICENSE](LICENSE) for full text.
395
+
396
+ ---
397
+
398
+ ## Contact & Commercial Licensing
399
+
400
+ **Amin Parva**
401
+ parvaamin@gmail.com
402
+
403
+ For licensing inquiries, enterprise support, or research collaboration, please reach out directly.