Metadata-Version: 2.4
Name: vayrm
Version: 0.1.3
Summary: Adaptive Compute Runtime
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: psutil>=5.9.0
Requires-Dist: cryptography>=41.0.0
Requires-Dist: PyYAML>=6.0.1
Requires-Dist: aiohttp>=3.9.0
Requires-Dist: qrcode>=7.4
Requires-Dist: pillow>=10.0.0
Requires-Dist: python-dotenv>=1.0.0
Requires-Dist: rich>=13.0.0
Provides-Extra: macos
Provides-Extra: windows
Provides-Extra: linux
Provides-Extra: dev
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
Requires-Dist: mypy>=1.0.0; extra == "dev"
Requires-Dist: ruff>=0.0.260; extra == "dev"

# Vayrm: Adaptive Compute Runtime

**Vayrm** is the public Python package and integration layer that orchestrates the **Adaptive Compute Runtime (ACR)** and the **PALADIN** communication substrate. It provides a clean, unified public API and CLI to run intelligent, decentralized workloads across heterogeneous machines.

## What Vayrm Is
Vayrm is the user-facing facade. It provides:
- A unified Python API (`import vayrm`)
- A unified CLI (`vayrm root`, `vayrm node`)
- Environment bootstrap logic (detecting Tailscale, Colab, Local modes)
- Safe, dynamic service port exposure.

## What Vayrm Is NOT
Vayrm is **not** a new runtime. It does not replace or duplicate ACR or PALADIN. All underlying capabilities (schedulers, protocols, mesh networks, workload execution) are physically handled by the existing ACR/PALADIN codebases. Vayrm merely exposes them cleanly.

---

## Installation

```bash
pip install vayrm
```

---

## The Public Python API

Vayrm guarantees that whether you use the Python API or the CLI, the exact same underlying bootstrap mechanisms are executed.

```python
import vayrm
from vayrm import Root, Node, SubRoot

# Subsystems are exposed cleanly:
import vayrm.scheduler
import vayrm.runtime
import vayrm.telemetry
import vayrm.network
```

### Root
The Root acts as the cluster brain, aggregating telemetry and making scheduling decisions.
```python
# Starts the root locally without Tailscale
vayrm.root.start(local=True)
```

### SubRoot
The SubRoot aggregates Node connections in large clusters and relays summaries to the Root.
```python
vayrm.subroot.start(root="100.x.y.z:49152")
```

### Node
The edge worker that characterizes its hardware and connects to the orchestration hierarchy.
```python
vayrm.node.start(root="100.x.y.z:49152", interval=1.0)
```

---

## Exposed Subsystems

Vayrm directly exports existing ACR functionality so that developers don't have to navigate internal package structures.

### Scheduler
`vayrm.scheduler` exposes all underlying ACR scheduling models (`AdaptiveScheduler`, `ResourceAwareScheduler`, etc.).
### Runtime
`vayrm.runtime` exposes runtime states (`RootState`, `ClusterState`, etc.).
### Network & Tailscale
`vayrm.network` exposes Tailscale queries (`get_tailscale_ip()`, `is_tailscale_available()`) and the `Endpoint` definitions.
### Telemetry
`vayrm.telemetry` exposes telemetry abstractions (`TelemetryProvider`, `TelemetryCollector`).

---

## CLI

The Vayrm CLI directly maps to the Python API:

```bash
vayrm root --local
vayrm node --root 100.x.y.z:49152
vayrm subroot --root 100.x.y.z:49152
vayrm diagnostics
vayrm doctor
```

---

## Environment & Networking Models

### Tailscale
Vayrm relies heavily on Tailscale for secure peer-to-peer discovery and data transport across firewalls. Vayrm automatically detects if Tailscale is installed, authenticated, and usable.

### Local Mode
For testing without a mesh network, you can bypass Tailscale detection entirely using `local=True` or the `--local` CLI flag. This binds all traffic to `127.0.0.1`.

### Google Colab
Vayrm explicitly detects Google Colab (`google.colab` / `COLAB_RELEASE_TAG`). A Colab VM is an independent cloud server and **does not** automatically share your laptop's Tailscale connection. Vayrm will warn you to run `!curl -fsSL https://tailscale.com/install.sh | sh` and `!sudo tailscale up` inside the notebook if you wish to join the mesh.

---

## Identity & Endpoint Model

Vayrm strictly separates **Identity** from **Endpoint**:
- **Identity**: `node_id` is a stable, persisted UUID (e.g., stored in `~/.acr/node_id` or `.paladin/node_identity.json`). It persists across restarts. The Root uses `explicit_node_id="root"`.
- **Endpoint**: The network socket (e.g., `100.x.y.z:49152`).

If a Node's IP changes, its Identity remains the same. Ports are bound dynamically (`port=0`) to prevent collisions, and the OS-assigned port is reported back by Vayrm.

---

## Security and Known Limitations

Vayrm orchestrates security primitives provided by PALADIN and Tailscale, but structural limitations exist:

1. **Root Rotation**: There is currently **no implemented cryptographic authority-transfer mechanism**. If a Root dies, Nodes must be restarted and explicitly pointed to the new Root endpoint.
2. **Application-Level Security**: Tailscale encrypts transport (WireGuard), but application-level messages over PALADIN are currently verified by structural cluster IDs rather than strict mTLS/signing from a centralized production trust anchor (a Dev CA is generated dynamically).
3. **Identity Dual-Management**: ACR and PALADIN generate persistent identity UUIDs slightly differently (`~/.acr/node_id` vs `.paladin/node_identity.json`). They refer to the same logical node but generate keys independently.

---

## Examples

**1. Starting a local cluster:**
```bash
# Terminal 1
vayrm root --local

# Terminal 2 (using the port printed by Terminal 1)
vayrm node --root 127.0.0.1:51302 --local
```

**2. Inspecting the Environment:**
```bash
vayrm doctor
vayrm diagnostics
```
`vayrm diagnostics` now actively queries and prints local identity and registry states for both `acr` and `paladin`.

---

## Troubleshooting

- **Node cannot connect to Root:**
  Ensure that you specify the dynamic port output by `vayrm root`. `vayrm root` uses dynamic port allocation to avoid collision, so its port changes each run. If you use `--local`, ensure the Root is also started with `--local` so it binds to `127.0.0.1` rather than its Tailscale mesh IP.
- **Workers=0 on Dashboard:**
  Ensure you are using `vayrm root` (which sets `USE_PALADIN="1"`) rather than manually bypassing the facade. The Vayrm facade is necessary to correctly boot the full PALADIN communication layer that the dashboard relies on.
