mfabric 0.3.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 (36) hide show
  1. mfabric-0.3.0/CHANGELOG.md +13 -0
  2. mfabric-0.3.0/CONTRIBUTING.md +30 -0
  3. mfabric-0.3.0/LICENSE +21 -0
  4. mfabric-0.3.0/MANIFEST.in +13 -0
  5. mfabric-0.3.0/NOTICE +19 -0
  6. mfabric-0.3.0/PKG-INFO +186 -0
  7. mfabric-0.3.0/README.md +126 -0
  8. mfabric-0.3.0/SECURITY.md +29 -0
  9. mfabric-0.3.0/mfabric/__init__.py +6 -0
  10. mfabric-0.3.0/mfabric/cli.py +712 -0
  11. mfabric-0.3.0/mfabric/crypto_ca.py +610 -0
  12. mfabric-0.3.0/mfabric/helper_node.py +569 -0
  13. mfabric-0.3.0/mfabric/host_server.py +1414 -0
  14. mfabric-0.3.0/mfabric/keystore.py +135 -0
  15. mfabric-0.3.0/mfabric/llama_installer.py +302 -0
  16. mfabric-0.3.0/mfabric/network.py +333 -0
  17. mfabric-0.3.0/mfabric/py.typed +0 -0
  18. mfabric-0.3.0/mfabric/receipts.py +286 -0
  19. mfabric-0.3.0/mfabric/router.py +164 -0
  20. mfabric-0.3.0/mfabric/runtimes.py +553 -0
  21. mfabric-0.3.0/mfabric/service_manager.py +112 -0
  22. mfabric-0.3.0/mfabric/telemetry.py +281 -0
  23. mfabric-0.3.0/mfabric/ui.py +164 -0
  24. mfabric-0.3.0/mfabric/wordlists/eff_large_wordlist.txt +7776 -0
  25. mfabric-0.3.0/mfabric.egg-info/PKG-INFO +186 -0
  26. mfabric-0.3.0/mfabric.egg-info/SOURCES.txt +34 -0
  27. mfabric-0.3.0/mfabric.egg-info/dependency_links.txt +1 -0
  28. mfabric-0.3.0/mfabric.egg-info/entry_points.txt +3 -0
  29. mfabric-0.3.0/mfabric.egg-info/requires.txt +6 -0
  30. mfabric-0.3.0/mfabric.egg-info/top_level.txt +1 -0
  31. mfabric-0.3.0/pyproject.toml +74 -0
  32. mfabric-0.3.0/setup.cfg +4 -0
  33. mfabric-0.3.0/tests/test_crypto_pairing.py +105 -0
  34. mfabric-0.3.0/tests/test_mesh_e2e.py +546 -0
  35. mfabric-0.3.0/tests/test_runtimes_router.py +168 -0
  36. mfabric-0.3.0/tests/test_security_and_packaging.py +366 -0
@@ -0,0 +1,13 @@
1
+ # Changelog
2
+
3
+ All notable changes to `mfabric` are documented in this file.
4
+
5
+ ## [0.3.0] - 2026-11-28
6
+
7
+ ### Added
8
+ - **Zero-Keyfile 6-Word SAS Pairing & Automatic Mutual TLS 1.3:** Built-in ECDSA P-256 Fabric Root CA, dual proof-of-possession pairing requests, pinned X.509 leaf certificates, and automatic DHCP endpoint healing verified by leaf certificate pinning.
9
+ - **OpenAI `/v1` Mesh Router (`127.0.0.1:8788/v1`):** Supports `/v1/models`, `/v1/chat/completions`, `/v1/completions`, and `/v1/embeddings` with multi-turn conversations, real-time SSE `stream: true`, `tools` / `tool_choice`, `reasoning_content`, and end-to-end TCP client-disconnect cancellation.
10
+ - **Universal Loopback Runtime Discovery:** Wraps local `127.0.0.1` Ollama, LM Studio, vLLM / OpenAI servers, and optional SHA-256-verified official `ggml-org/llama.cpp` (`llama-server`) releases without exposing unauthenticated model ports to the network.
11
+ - **Presence, Battery, VRAM & Speed-Aware Routing:** Virtual targets (`auto`, `fast`), model IDs, and pinned `@peer/model` selectors with automatic pre-first-token failover.
12
+ - **Dual-Signed Content-Free Execution Receipts (`mfabric.receipt.v3`):** Ed25519 helper attestations counter-signed by the host and verifiable offline via `mfab receipts verify`.
13
+ - **Cross-Platform CLI (`mfab` / `mfabric`) & Minimalist Web Console:** Commands for `up`, `join` (with mDNS discovery, multi-host selection, and `--no-discovery`), `pending`, `approve`, `revoke`, `peers`, `status`, `models`, `chat`, `receipts`, `install-llama`, `service`, `doctor`, and `down`.
@@ -0,0 +1,30 @@
1
+ # Contributing to MFabric
2
+
3
+ Thank you for your interest in contributing to MFabric!
4
+
5
+ ## Development Setup
6
+
7
+ ```bash
8
+ git clone https://github.com/sfiniti-ai/mfabric.git
9
+ cd mfabric
10
+ python -m venv .venv
11
+ # macOS / Linux:
12
+ source .venv/bin/activate
13
+ # Windows PowerShell:
14
+ # .venv\Scripts\Activate.ps1
15
+
16
+ python -m pip install -e ".[dev]"
17
+ pytest
18
+ ```
19
+
20
+ ## Design Principles
21
+
22
+ 1. **Zero Telemetry / Zero Cloud Dependency:** MFabric must never phone home, collect analytics, or require an external account.
23
+ 2. **Fail-Closed Security:** Never weaken TLS 1.3 mutual authentication, certificate fingerprint pinning, symlink checks, archive extraction bounds, or loopback CSRF/DNS-rebinding checks.
24
+ 3. **Cross-Platform Parity:** All features and tests should run cleanly on Linux, macOS, and Windows under Python 3.11+.
25
+
26
+ ## Pull Requests
27
+
28
+ - Add focused `pytest` coverage for new behavior or bug fixes.
29
+ - Ensure `pytest` passes with zero warnings or leftover background processes.
30
+ - By submitting a pull request, you agree that your contribution will be licensed under the repository's [MIT License](LICENSE).
mfabric-0.3.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Sfiniti AI Inc.
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,13 @@
1
+ include LICENSE
2
+ include NOTICE
3
+ include README.md
4
+ include CHANGELOG.md
5
+ include SECURITY.md
6
+ include CONTRIBUTING.md
7
+ recursive-include mfabric *.py py.typed *.txt
8
+ recursive-include tests *.py
9
+ global-exclude __pycache__ *.py[cod] *.sqlite *.secret *.log
10
+ prune .github
11
+ prune dist
12
+ prune build
13
+ prune .venv
mfabric-0.3.0/NOTICE ADDED
@@ -0,0 +1,19 @@
1
+ # Third-Party Notices
2
+
3
+ MFabric (`mfabric`) is licensed under the MIT License (`LICENSE`).
4
+
5
+ ## Bundled Data
6
+
7
+ ### EFF Large Wordlist (`mfabric/wordlists/eff_large_wordlist.txt`)
8
+ - **Author:** Joseph Bonneau / Electronic Frontier Foundation (EFF)
9
+ - **Source:** https://www.eff.org/deeplinks/2016/07/new-wordlists-random-passphrases (`https://www.eff.org/files/2016/07/18/eff_large_wordlist.txt`)
10
+ - **Grant & License:** Distributed unmodified (7,776 entries) under the Creative Commons Attribution 3.0 United States License (`CC BY 3.0 US`) granted by EFF in its 2016 wordlist release (`https://www.eff.org/files/2016/02/22/eff_letter_re_mail.pdf`).
11
+ - **License Text / Deed:** https://creativecommons.org/licenses/by/3.0/us/legalcode.en (summary: https://creativecommons.org/licenses/by/3.0/us/)
12
+ - **Usage:** Used unmodified to render human-verifiable 6-word Short Authentication Strings (SAS) during device pairing.
13
+
14
+ ## Runtime Dependencies (Installed via PyPI)
15
+
16
+ MFabric declares the following open-source Python packages as runtime dependencies (none are vendored into MFabric distributions):
17
+ - **`cryptography`** — Dual-licensed under Apache-2.0 or BSD-3-Clause.
18
+ - **`psutil`** — Licensed under BSD-3-Clause.
19
+ - **`zeroconf`** — Licensed under LGPL-2.1-or-later (imported dynamically at runtime for optional local mDNS service discovery).
mfabric-0.3.0/PKG-INFO ADDED
@@ -0,0 +1,186 @@
1
+ Metadata-Version: 2.4
2
+ Name: mfabric
3
+ Version: 0.3.0
4
+ Summary: Zero-config mutual-TLS 1.3 OpenAI mesh router for every computer you own.
5
+ Author: Sfiniti AI Inc.
6
+ License: MIT License
7
+
8
+ Copyright (c) 2026 Sfiniti AI Inc.
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Homepage, https://sfiniti.ai
29
+ Project-URL: Repository, https://github.com/sfiniti-ai/mfabric
30
+ Project-URL: Issues, https://github.com/sfiniti-ai/mfabric/issues
31
+ Project-URL: Changelog, https://github.com/sfiniti-ai/mfabric/blob/main/CHANGELOG.md
32
+ Project-URL: Security, https://github.com/sfiniti-ai/mfabric/blob/main/SECURITY.md
33
+ Keywords: openai,llm,router,mtls,ollama,vllm,lm-studio,llama-cpp,local-ai,mesh
34
+ Classifier: Development Status :: 4 - Beta
35
+ Classifier: Environment :: Console
36
+ Classifier: Intended Audience :: Developers
37
+ Classifier: Intended Audience :: Science/Research
38
+ Classifier: License :: OSI Approved :: MIT License
39
+ Classifier: Operating System :: MacOS
40
+ Classifier: Operating System :: Microsoft :: Windows
41
+ Classifier: Operating System :: POSIX :: Linux
42
+ Classifier: Programming Language :: Python :: 3
43
+ Classifier: Programming Language :: Python :: 3 :: Only
44
+ Classifier: Programming Language :: Python :: 3.11
45
+ Classifier: Programming Language :: Python :: 3.12
46
+ Classifier: Programming Language :: Python :: 3.13
47
+ Classifier: Topic :: Internet :: Proxy Servers
48
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
49
+ Classifier: Topic :: Security :: Cryptography
50
+ Requires-Python: >=3.11
51
+ Description-Content-Type: text/markdown
52
+ License-File: LICENSE
53
+ License-File: NOTICE
54
+ Requires-Dist: cryptography>=42.0
55
+ Requires-Dist: psutil>=5.9
56
+ Requires-Dist: zeroconf>=0.132
57
+ Provides-Extra: dev
58
+ Requires-Dist: pytest>=8.0; extra == "dev"
59
+ Dynamic: license-file
60
+
61
+ # MFabric
62
+
63
+ [![License: MIT](https://img.shields.io/badge/License-MIT-amber.svg)](LICENSE)
64
+ [![Python 3.11+](https://img.shields.io/badge/python-3.11%2B-blue.svg)](https://www.python.org/downloads/)
65
+
66
+ **Zero-config mutual-TLS 1.3 OpenAI mesh router for every computer you own.**
67
+
68
+ Expose one local OpenAI-compatible endpoint (`http://127.0.0.1:8788/v1`) on your laptop or workstation that securely routes across **Ollama**, **LM Studio**, **vLLM**, and **llama.cpp (`llama-server`)** running on your other macOS, Linux, and Windows machines—with **no cloud account, no mandatory VPN install, no static YAML, and no manual API key files**.
69
+
70
+ ---
71
+
72
+ ## Why MFabric?
73
+
74
+ - **60-Second Zero-Keyfile Pairing $\to$ Mutual TLS 1.3:** Compare a 6-word Short Authentication String (HKDF-bound to both the Fabric Root CA and the helper's ECDSA P-256 + Ed25519 public keys) and approve once. MFabric issues pinned X.509 leaf certificates automatically, encrypting every prompt and streamed token over Wi-Fi/LAN with TLS 1.3 mutual authentication.
75
+ - **Keep Model Servers Safely on `127.0.0.1`:** Leave Ollama (`:11434`), LM Studio (`:1234`), vLLM (`:8000`), and `llama-server` bound strictly to loopback so unauthenticated model ports are never exposed on `0.0.0.0`.
76
+ - **Drop-In OpenAI `/v1` Compatibility:** Works out of the box with **Cursor**, **Continue**, **Cline**, **Open WebUI**, and the official **`openai` Python/TypeScript SDKs**—including multi-turn `messages[]`, real-time SSE `stream: true`, `tools` / `tool_choice`, `reasoning_content`, `/v1/embeddings`, and instant TCP disconnect cancellation.
77
+ - **Presence, Battery & VRAM-Aware Routing:** Virtual models (`auto`, `fast`), canonical model names, and pinned `@peer/model` targets automatically steer away from unplugged laptops on battery or desktops under heavy foreground GPU load, with seamless pre-first-token failover.
78
+ - **Dual-Signed Content-Free Execution Receipts:** Every routed response records a `mfabric.receipt.v3` signed by **both** the executing helper's Ed25519 key and your host's Ed25519 key (with zero prompt or output text stored), verifiable offline via `mfab receipts verify`.
79
+
80
+ ---
81
+
82
+ ## Install (macOS, Linux, Windows)
83
+
84
+ Requires **Python 3.11 or newer**:
85
+
86
+ ```bash
87
+ pip install mfabric
88
+ mfab doctor
89
+ ```
90
+
91
+ *(Both `mfab` and `mfabric` CLI commands are installed; you can also isolate it with `pipx install mfabric` or `uv tool install mfabric`.)*
92
+
93
+ ---
94
+
95
+ ## Quickstart (Two Machines, Under 60 Seconds)
96
+
97
+ ### 1. Start the router on your primary computer (Host)
98
+
99
+ ```bash
100
+ mfab up -d
101
+ ```
102
+
103
+ This starts your local OpenAI `/v1` router and web dashboard on `http://127.0.0.1:8788` plus the LAN pairing listener on port `8935`.
104
+
105
+ ### 2. Join any GPU desktop, workstation, or Mac on your network (Helper)
106
+
107
+ If **Ollama**, **LM Studio**, or **vLLM** is already running on `127.0.0.1` on that machine, MFabric discovers its models automatically. Need a standalone GGUF runtime? Run `mfab install-llama` first to fetch an official SHA-256-verified `llama-server` build for CUDA, Metal, Vulkan, or CPU.
108
+
109
+ ```bash
110
+ # Auto-discovers your host over mDNS, or pass the Join URL explicitly:
111
+ mfab join -d
112
+ # Explicit URL fallback (or when mDNS is blocked / disabled):
113
+ # mfab join http://<host-lan-ip>:8935 --no-discovery -d
114
+ ```
115
+
116
+ Verify that the **6-word pairing phrase** shown on the helper matches `mfab pending` (or `http://127.0.0.1:8788`) on your host, then approve that exact phrase:
117
+
118
+ ```bash
119
+ mfab approve "<6-word-phrase>"
120
+ # (or bare `mfab approve` when only a single request is pending)
121
+ ```
122
+
123
+ ### 3. Point any OpenAI client at `http://127.0.0.1:8788/v1`
124
+
125
+ ```bash
126
+ mfab peers
127
+ mfab models
128
+ mfab chat "Write a lock-free ring buffer in C++20."
129
+ ```
130
+
131
+ #### Python (`openai` SDK)
132
+ ```python
133
+ from openai import OpenAI
134
+
135
+ client = OpenAI(base_url="http://127.0.0.1:8788/v1", api_key="local")
136
+ stream = client.chat.completions.create(
137
+ model="auto", # or "fast", "qwen2.5-coder:32b", or "@workstation/qwen2.5-coder:32b"
138
+ messages=[{"role": "user", "content": "Explain mutual TLS 1.3 in three sentences."}],
139
+ stream=True,
140
+ )
141
+ for chunk in stream:
142
+ print(chunk.choices[0].delta.content or "", end="", flush=True)
143
+ ```
144
+
145
+ #### Cursor / Continue / Cline / Open WebUI
146
+ - **OpenAI Base URL:** `http://127.0.0.1:8788/v1`
147
+ - **API Key:** `local` *(or set `MFABRIC_API_KEY` before `mfab up` to enforce a custom Bearer token)*
148
+ - **Model:** `auto`, `fast`, any discovered model ID, or `@<peer_id>/<model_id>` to pin a specific machine.
149
+
150
+ ---
151
+
152
+ ## What Can I Do Next?
153
+
154
+ | Goal | Command |
155
+ |---|---|
156
+ | Inspect live nodes, GPUs, battery state & models | `mfab status` or `mfab peers` |
157
+ | Pin a prompt to one exact machine (fail-closed, no failover) | `mfab chat -m "@studio-mac/qwen2.5-coder:32b" "Refactor this module"` |
158
+ | Serve a local `.gguf` file directly without Ollama/LM Studio | `mfab install-llama && mfab join --model ~/Models/qwen2.5-7b-instruct-q4_k_m.gguf -d` |
159
+ | Verify cryptographic proof of which machine ran a request | `mfab receipts list` $\to$ `mfab receipts verify <receipt_id>` |
160
+ | Revoke a helper immediately (pushes signed mTLS shutdown) | `mfab revoke <peer_id>` |
161
+ | Run automatically at login (LaunchAgent / systemd / Startup) | `mfab service install --role helper` (or `--role host`) |
162
+ | Require a Bearer API key on `/v1/*` and `/api/*` | Set `MFABRIC_API_KEY="<secret>"` in your environment before `mfab up` |
163
+ | Stop background host/helper processes | `mfab down` |
164
+
165
+ ---
166
+
167
+ ## Operating-System & Firewall Notes
168
+
169
+ - **macOS:** The first time you run `mfab up` or `mfab join`, allow your terminal or IDE under **System Settings $\to$ Privacy & Security $\to$ Local Network**. To keep a Mac helper awake while serving with the display off, run `caffeinate -dimsu` in a separate tab.
170
+ - **Windows:** Windows Defender Firewall prompts on first LAN bind (or blocks inbound connections on Public network profiles). Set your trusted home/office Wi-Fi or Ethernet to **Private network**, or run the exact `New-NetFirewallRule` command printed by `mfab join` if reachback fails.
171
+ - **Linux:** If `ufw` or `firewalld` is active, allow inbound TCP `8935` on the host (for pairing) and TCP `8789` on helpers from your private LAN subnet (e.g., `sudo ufw allow from 192.168.0.0/16 to any port 8789 proto tcp`).
172
+
173
+ ---
174
+
175
+ ## Security Model & Beta Caveats
176
+
177
+ - **Mutual TLS 1.3 Inference Transport:** All `/v1/*` model traffic and `/mesh/v1/*` health checks between Host and Helpers run over TLS 1.3 with mutual certificate verification (`CERT_REQUIRED`), SHA-256 leaf fingerprint pinning, and X.509 URI SAN role checks (`urn:mfabric:host:<id>` vs. `urn:mfabric:peer:<id>`). Compromising one helper certificate does **not** grant lateral access to other helpers.
178
+ - **Explicit Pairing Approval:** LAN mDNS discovery (`_mfabric-v3._tcp.local.`) only locates candidate host addresses and can be disabled with `--no-discovery`. No machine can join or receive a certificate until you verify the 6-word SAS phrase and approve on the host.
179
+ - **Loopback Protection:** The host console (`127.0.0.1:8788`) enforces `Host`-header allowlisting (blocking DNS rebinding), `Origin` validation, and `Content-Type: application/json` checks against cross-origin browser CSRF.
180
+ - **What MFabric v0.3 Does *Not* Do:** MFabric v0.3 routes whole OpenAI requests across independent runtimes and fails over *before* the first output token; it does not shard a single model's weights across multiple machines over Wi-Fi, and revoking a peer blocks new MFabric dispatches without altering your local Ollama/vLLM installation. Do **not** port-forward `:8788` or `:8935` to the public Internet.
181
+
182
+ ---
183
+
184
+ ## License
185
+
186
+ MIT License. Copyright (c) 2026 Sfiniti AI Inc. See [LICENSE](LICENSE) and [NOTICE](NOTICE).
@@ -0,0 +1,126 @@
1
+ # MFabric
2
+
3
+ [![License: MIT](https://img.shields.io/badge/License-MIT-amber.svg)](LICENSE)
4
+ [![Python 3.11+](https://img.shields.io/badge/python-3.11%2B-blue.svg)](https://www.python.org/downloads/)
5
+
6
+ **Zero-config mutual-TLS 1.3 OpenAI mesh router for every computer you own.**
7
+
8
+ Expose one local OpenAI-compatible endpoint (`http://127.0.0.1:8788/v1`) on your laptop or workstation that securely routes across **Ollama**, **LM Studio**, **vLLM**, and **llama.cpp (`llama-server`)** running on your other macOS, Linux, and Windows machines—with **no cloud account, no mandatory VPN install, no static YAML, and no manual API key files**.
9
+
10
+ ---
11
+
12
+ ## Why MFabric?
13
+
14
+ - **60-Second Zero-Keyfile Pairing $\to$ Mutual TLS 1.3:** Compare a 6-word Short Authentication String (HKDF-bound to both the Fabric Root CA and the helper's ECDSA P-256 + Ed25519 public keys) and approve once. MFabric issues pinned X.509 leaf certificates automatically, encrypting every prompt and streamed token over Wi-Fi/LAN with TLS 1.3 mutual authentication.
15
+ - **Keep Model Servers Safely on `127.0.0.1`:** Leave Ollama (`:11434`), LM Studio (`:1234`), vLLM (`:8000`), and `llama-server` bound strictly to loopback so unauthenticated model ports are never exposed on `0.0.0.0`.
16
+ - **Drop-In OpenAI `/v1` Compatibility:** Works out of the box with **Cursor**, **Continue**, **Cline**, **Open WebUI**, and the official **`openai` Python/TypeScript SDKs**—including multi-turn `messages[]`, real-time SSE `stream: true`, `tools` / `tool_choice`, `reasoning_content`, `/v1/embeddings`, and instant TCP disconnect cancellation.
17
+ - **Presence, Battery & VRAM-Aware Routing:** Virtual models (`auto`, `fast`), canonical model names, and pinned `@peer/model` targets automatically steer away from unplugged laptops on battery or desktops under heavy foreground GPU load, with seamless pre-first-token failover.
18
+ - **Dual-Signed Content-Free Execution Receipts:** Every routed response records a `mfabric.receipt.v3` signed by **both** the executing helper's Ed25519 key and your host's Ed25519 key (with zero prompt or output text stored), verifiable offline via `mfab receipts verify`.
19
+
20
+ ---
21
+
22
+ ## Install (macOS, Linux, Windows)
23
+
24
+ Requires **Python 3.11 or newer**:
25
+
26
+ ```bash
27
+ pip install mfabric
28
+ mfab doctor
29
+ ```
30
+
31
+ *(Both `mfab` and `mfabric` CLI commands are installed; you can also isolate it with `pipx install mfabric` or `uv tool install mfabric`.)*
32
+
33
+ ---
34
+
35
+ ## Quickstart (Two Machines, Under 60 Seconds)
36
+
37
+ ### 1. Start the router on your primary computer (Host)
38
+
39
+ ```bash
40
+ mfab up -d
41
+ ```
42
+
43
+ This starts your local OpenAI `/v1` router and web dashboard on `http://127.0.0.1:8788` plus the LAN pairing listener on port `8935`.
44
+
45
+ ### 2. Join any GPU desktop, workstation, or Mac on your network (Helper)
46
+
47
+ If **Ollama**, **LM Studio**, or **vLLM** is already running on `127.0.0.1` on that machine, MFabric discovers its models automatically. Need a standalone GGUF runtime? Run `mfab install-llama` first to fetch an official SHA-256-verified `llama-server` build for CUDA, Metal, Vulkan, or CPU.
48
+
49
+ ```bash
50
+ # Auto-discovers your host over mDNS, or pass the Join URL explicitly:
51
+ mfab join -d
52
+ # Explicit URL fallback (or when mDNS is blocked / disabled):
53
+ # mfab join http://<host-lan-ip>:8935 --no-discovery -d
54
+ ```
55
+
56
+ Verify that the **6-word pairing phrase** shown on the helper matches `mfab pending` (or `http://127.0.0.1:8788`) on your host, then approve that exact phrase:
57
+
58
+ ```bash
59
+ mfab approve "<6-word-phrase>"
60
+ # (or bare `mfab approve` when only a single request is pending)
61
+ ```
62
+
63
+ ### 3. Point any OpenAI client at `http://127.0.0.1:8788/v1`
64
+
65
+ ```bash
66
+ mfab peers
67
+ mfab models
68
+ mfab chat "Write a lock-free ring buffer in C++20."
69
+ ```
70
+
71
+ #### Python (`openai` SDK)
72
+ ```python
73
+ from openai import OpenAI
74
+
75
+ client = OpenAI(base_url="http://127.0.0.1:8788/v1", api_key="local")
76
+ stream = client.chat.completions.create(
77
+ model="auto", # or "fast", "qwen2.5-coder:32b", or "@workstation/qwen2.5-coder:32b"
78
+ messages=[{"role": "user", "content": "Explain mutual TLS 1.3 in three sentences."}],
79
+ stream=True,
80
+ )
81
+ for chunk in stream:
82
+ print(chunk.choices[0].delta.content or "", end="", flush=True)
83
+ ```
84
+
85
+ #### Cursor / Continue / Cline / Open WebUI
86
+ - **OpenAI Base URL:** `http://127.0.0.1:8788/v1`
87
+ - **API Key:** `local` *(or set `MFABRIC_API_KEY` before `mfab up` to enforce a custom Bearer token)*
88
+ - **Model:** `auto`, `fast`, any discovered model ID, or `@<peer_id>/<model_id>` to pin a specific machine.
89
+
90
+ ---
91
+
92
+ ## What Can I Do Next?
93
+
94
+ | Goal | Command |
95
+ |---|---|
96
+ | Inspect live nodes, GPUs, battery state & models | `mfab status` or `mfab peers` |
97
+ | Pin a prompt to one exact machine (fail-closed, no failover) | `mfab chat -m "@studio-mac/qwen2.5-coder:32b" "Refactor this module"` |
98
+ | Serve a local `.gguf` file directly without Ollama/LM Studio | `mfab install-llama && mfab join --model ~/Models/qwen2.5-7b-instruct-q4_k_m.gguf -d` |
99
+ | Verify cryptographic proof of which machine ran a request | `mfab receipts list` $\to$ `mfab receipts verify <receipt_id>` |
100
+ | Revoke a helper immediately (pushes signed mTLS shutdown) | `mfab revoke <peer_id>` |
101
+ | Run automatically at login (LaunchAgent / systemd / Startup) | `mfab service install --role helper` (or `--role host`) |
102
+ | Require a Bearer API key on `/v1/*` and `/api/*` | Set `MFABRIC_API_KEY="<secret>"` in your environment before `mfab up` |
103
+ | Stop background host/helper processes | `mfab down` |
104
+
105
+ ---
106
+
107
+ ## Operating-System & Firewall Notes
108
+
109
+ - **macOS:** The first time you run `mfab up` or `mfab join`, allow your terminal or IDE under **System Settings $\to$ Privacy & Security $\to$ Local Network**. To keep a Mac helper awake while serving with the display off, run `caffeinate -dimsu` in a separate tab.
110
+ - **Windows:** Windows Defender Firewall prompts on first LAN bind (or blocks inbound connections on Public network profiles). Set your trusted home/office Wi-Fi or Ethernet to **Private network**, or run the exact `New-NetFirewallRule` command printed by `mfab join` if reachback fails.
111
+ - **Linux:** If `ufw` or `firewalld` is active, allow inbound TCP `8935` on the host (for pairing) and TCP `8789` on helpers from your private LAN subnet (e.g., `sudo ufw allow from 192.168.0.0/16 to any port 8789 proto tcp`).
112
+
113
+ ---
114
+
115
+ ## Security Model & Beta Caveats
116
+
117
+ - **Mutual TLS 1.3 Inference Transport:** All `/v1/*` model traffic and `/mesh/v1/*` health checks between Host and Helpers run over TLS 1.3 with mutual certificate verification (`CERT_REQUIRED`), SHA-256 leaf fingerprint pinning, and X.509 URI SAN role checks (`urn:mfabric:host:<id>` vs. `urn:mfabric:peer:<id>`). Compromising one helper certificate does **not** grant lateral access to other helpers.
118
+ - **Explicit Pairing Approval:** LAN mDNS discovery (`_mfabric-v3._tcp.local.`) only locates candidate host addresses and can be disabled with `--no-discovery`. No machine can join or receive a certificate until you verify the 6-word SAS phrase and approve on the host.
119
+ - **Loopback Protection:** The host console (`127.0.0.1:8788`) enforces `Host`-header allowlisting (blocking DNS rebinding), `Origin` validation, and `Content-Type: application/json` checks against cross-origin browser CSRF.
120
+ - **What MFabric v0.3 Does *Not* Do:** MFabric v0.3 routes whole OpenAI requests across independent runtimes and fails over *before* the first output token; it does not shard a single model's weights across multiple machines over Wi-Fi, and revoking a peer blocks new MFabric dispatches without altering your local Ollama/vLLM installation. Do **not** port-forward `:8788` or `:8935` to the public Internet.
121
+
122
+ ---
123
+
124
+ ## License
125
+
126
+ MIT License. Copyright (c) 2026 Sfiniti AI Inc. See [LICENSE](LICENSE) and [NOTICE](NOTICE).
@@ -0,0 +1,29 @@
1
+ # Security Policy
2
+
3
+ ## Supported Versions
4
+
5
+ | Version | Supported |
6
+ |---|---|
7
+ | `0.3.x` | Yes |
8
+ | `< 0.3.0` | No |
9
+
10
+ ## Security Architecture Summary
11
+
12
+ 1. **Zero-Keyfile SAS Pairing (`mfabric.pairing_request.v3`):**
13
+ - Helpers generate fresh ECDSA `SECP256R1` (TLS) and `Ed25519` (attestation) keypairs locally; private keys never leave the device.
14
+ - A 6-word Short Authentication String (SAS) is derived via `HKDF-SHA256` over the Fabric ID, Host Root CA certificate SHA-256, Helper TLS public key SHA-256, Helper Ed25519 public key, and a single-use challenge nonce.
15
+ - Pairing requests carry dual proof-of-possession signatures (Ed25519 + ECDSA P-256) and require explicit human approval on the Host before an X.509 leaf certificate is issued.
16
+ 2. **Mutual TLS 1.3 (`mTLS`) Transport & Lateral-Movement Prevention:**
17
+ - Helper servers enforce `TLSv1.3` minimum, `ssl.CERT_REQUIRED`, CA signature verification, and require the client certificate to carry `urn:mfabric:host:<fabric_id>` in its X.509 URI SAN—blocking sibling peer certificates from querying other helpers.
18
+ - The Host client pins every approved helper's exact X.509 SHA-256 fingerprint and `urn:mfabric:peer:<peer_id>` URI SAN on every connection.
19
+ 3. **Loopback Control & `/v1` Surface Hardening:**
20
+ - Loopback endpoints validate `Host` headers (mitigating DNS rebinding), reject foreign/null browser `Origin` headers (mitigating cross-origin CSRF), and require `Content-Type: application/json` on `POST`.
21
+ - Local secret storage (`~/.mfabric/v3/secrets` or `%LOCALAPPDATA%\mfabric\v3\secrets`) rejects symlinks, writes atomically with `0600` permissions, and never passes API keys on child process command lines (`--api-key-file`).
22
+
23
+ ## Deployment Boundaries
24
+
25
+ - MFabric is designed for **private LANs (`10.0.0.0/8`, `172.16.0.0/12`, `192.168.0.0/16`) and private mesh interfaces (`100.64.0.0/10`)**. Never expose ports `8788`, `8789`, or `8935` directly to the public Internet.
26
+
27
+ ## Reporting a Vulnerability
28
+
29
+ Please **do not** open a public GitHub issue for security vulnerabilities. Report suspected vulnerabilities privately to **security@sfiniti.ai** (or **mani@sfiniti.ai**) with reproduction steps and affected version details. We aim to acknowledge reports within 48 hours.
@@ -0,0 +1,6 @@
1
+ """MFabric v0.3 - Zero-config mTLS OpenAI mesh router for owned computers."""
2
+
3
+ from __future__ import annotations
4
+
5
+ __version__ = "0.3.0"
6
+ __all__ = ["__version__"]