tasks
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
Status: ready-for-agent
|
||||
|
||||
# 01 — Monorepo scaffold + single-node smoke test
|
||||
|
||||
## What to build
|
||||
|
||||
Stand up the monorepo package layout and prove that a client HTTP request can travel end-to-end through the stack — gateway → one node serving all layers → valid response — before any real model or distributed logic is wired in.
|
||||
|
||||
The six top-level packages should exist with minimal stubs:
|
||||
- `packages/node` — node client CLI (`meshnet-node`)
|
||||
- `packages/gateway` — HTTP gateway + route orchestration
|
||||
- `packages/tracker` — node registry and route selection
|
||||
- `packages/sdk` — `meshnet` Python SDK
|
||||
- `packages/contracts` — Solana smart contract wrappers
|
||||
- `packages/p2p` — gossip and shard swarm
|
||||
|
||||
The smoke test uses a tiny in-process stub model (not a real LLM) so the test is fast and has no external dependencies. The node runs in the same process as the test. The gateway is a real HTTP server. The client sends a real `POST /v1/chat/completions` request and receives a valid OpenAI-format response.
|
||||
|
||||
## Acceptance criteria
|
||||
|
||||
- [ ] `pip install -e packages/node packages/gateway packages/tracker` works from repo root
|
||||
- [ ] `meshnet-node`, `meshnet-gateway`, and `meshnet-tracker` CLI entry points exist
|
||||
- [ ] A single integration test starts a gateway and one stub node in-process, sends a `POST /v1/chat/completions` request, and asserts a valid OpenAI-format response is returned
|
||||
- [ ] The test passes with `pytest` from repo root with no external services running
|
||||
- [ ] All six package directories exist with `pyproject.toml` and an importable top-level module
|
||||
|
||||
## Blocked by
|
||||
|
||||
None — can start immediately.
|
||||
@@ -0,0 +1,23 @@
|
||||
Status: ready-for-agent
|
||||
|
||||
# 02 — Two-node shard pipeline
|
||||
|
||||
## What to build
|
||||
|
||||
Extend the single-node smoke test so that inference is routed through exactly two nodes, each serving half of a stub model's layers. Activation tensors must travel from the gateway to node A, then from node A to node B, and the final output returns to the gateway. This proves the distributed shard pipeline works end-to-end before real models or a real tracker are introduced.
|
||||
|
||||
The two nodes run in the same process as the test (no real network required). The gateway hardcodes the two-node route for now — dynamic route selection comes in issue 03. The activation tensor protocol (shape, dtype, serialisation format) must be established here, as all later issues depend on it.
|
||||
|
||||
Use the domain vocabulary from `CONTEXT.md`: the ordered list of nodes is an **inference route**; each node's layer range is a **shard**; the tensors passed between nodes are activations (not "data" or "chunks").
|
||||
|
||||
## Acceptance criteria
|
||||
|
||||
- [ ] The integration test spins up two stub nodes, each configured with a non-overlapping shard range
|
||||
- [ ] A `POST /v1/chat/completions` request results in activation tensors flowing node-A → node-B (verifiable via test assertions or logs)
|
||||
- [ ] The gateway assembles the final response correctly from node-B's output
|
||||
- [ ] The test passes with no external services running
|
||||
- [ ] The activation tensor serialisation format is documented in a short inline comment (shape, dtype, wire format) — this becomes the contract all future nodes implement
|
||||
|
||||
## Blocked by
|
||||
|
||||
- `01-monorepo-scaffold.md`
|
||||
@@ -0,0 +1,24 @@
|
||||
Status: ready-for-agent
|
||||
|
||||
# 03 — Tracker: node registration + route selection
|
||||
|
||||
## What to build
|
||||
|
||||
Replace the hardcoded two-node route from issue 02 with a real tracker. Nodes register themselves with the tracker on startup (endpoint, shard range, hardware profile, node score). The gateway queries the tracker for an inference route for a given model preset instead of using a static list. The tracker returns an ordered list of node endpoints whose shards collectively cover all layers.
|
||||
|
||||
The tracker runs as a lightweight HTTP service. Node score is initially a simple placeholder (e.g. fixed value or random) — real throughput/latency scoring comes later. The tracker must correctly reject route requests when no registered nodes cover a required shard range and return an appropriate error.
|
||||
|
||||
This issue establishes the tracker's registration and routing API contract, which issues 04 (node startup) and 05 (OpenAI gateway) both depend on.
|
||||
|
||||
## Acceptance criteria
|
||||
|
||||
- [ ] A node can register with the tracker via HTTP, providing its endpoint, shard range, and a hardware profile
|
||||
- [ ] The gateway queries the tracker with a model preset name and receives an ordered list of node endpoints forming a complete inference route
|
||||
- [ ] The end-to-end integration test from issue 02 still passes with the tracker now in the loop (no hardcoded routes)
|
||||
- [ ] The tracker returns a clear error response when no route is available for a requested model preset
|
||||
- [ ] Nodes that fail to heartbeat within a configurable window are removed from the registry
|
||||
- [ ] The tracker's registration and route-selection HTTP API is defined (paths, request/response shapes) in the tracker package
|
||||
|
||||
## Blocked by
|
||||
|
||||
- `02-two-node-shard-pipeline.md`
|
||||
@@ -0,0 +1,32 @@
|
||||
Status: ready-for-agent
|
||||
|
||||
# 04 — Node client startup flow (`meshnet-node start`)
|
||||
|
||||
## What to build
|
||||
|
||||
Make `meshnet-node start` self-configuring from scratch on a machine with a CUDA-capable GPU (or CPU fallback). The full startup sequence must complete without any manual configuration:
|
||||
|
||||
1. Detect GPU model and available VRAM
|
||||
2. Load an existing Solana wallet from disk, or generate and save a new one
|
||||
3. Query the tracker for the optimal shard assignment given the hardware profile
|
||||
4. Download the assigned shard from HuggingFace (`huggingface_hub`)
|
||||
5. Register with the tracker (wallet address, endpoint, shard range, hardware profile)
|
||||
6. Begin accepting inference connections
|
||||
|
||||
The node prints a short status summary on startup: wallet address, assigned shard, model preset, and download progress. No interactive prompts — the entire flow is non-interactive.
|
||||
|
||||
This is the primary viral growth vector. Every second of friction in this flow costs node operators. The startup sequence must work on Linux with CUDA, and degrade gracefully to CPU on machines without a GPU.
|
||||
|
||||
## Acceptance criteria
|
||||
|
||||
- [ ] `meshnet-node start --tracker http://localhost:8080` completes startup without prompts on a machine with a CUDA GPU
|
||||
- [ ] A Solana wallet keypair is generated and saved to `~/.config/meshnet/wallet.json` if none exists
|
||||
- [ ] The assigned shard is downloaded from HuggingFace and cached to `~/.cache/meshnet/shards/`
|
||||
- [ ] The node registers with the tracker and appears in the tracker's node registry
|
||||
- [ ] The node accepts a live inference connection and processes activation tensors correctly after startup
|
||||
- [ ] On a CPU-only machine, the node starts with a warning and serves a CPU-appropriate shard
|
||||
- [ ] An integration test covers the full startup sequence against a local tracker stub
|
||||
|
||||
## Blocked by
|
||||
|
||||
- `03-tracker-registration-and-routing.md`
|
||||
@@ -0,0 +1,29 @@
|
||||
Status: ready-for-agent
|
||||
|
||||
# 05 — OpenAI-compatible gateway
|
||||
|
||||
## What to build
|
||||
|
||||
Expose a production-shape HTTP API from the gateway so that any client using the OpenAI Python SDK (or any OpenAI-compatible tool) works by changing only the `base_url`. The gateway translates OpenAI-format requests into inference route execution and streams responses back in OpenAI-format.
|
||||
|
||||
Endpoints to implement:
|
||||
- `POST /v1/chat/completions` — streaming (`text/event-stream`) and non-streaming
|
||||
- `GET /v1/models` — returns the list of model presets currently routable on the network
|
||||
- `GET /v1/health` — liveness check
|
||||
|
||||
The gateway selects an inference route from the tracker, executes the shard pipeline, and assembles the streamed response. If the tracker returns no route for the requested model, the gateway responds with a standard OpenAI-format error (`model_not_available`).
|
||||
|
||||
Authentication (API key → SOL/USDC balance) is a stub in this issue — return 200 for any non-empty `Authorization` header. Real payment gating comes in issue 06.
|
||||
|
||||
## Acceptance criteria
|
||||
|
||||
- [ ] `openai.OpenAI(base_url="http://localhost:8080/v1", api_key="test").chat.completions.create(model="stub-model", messages=[...])` returns a valid response
|
||||
- [ ] Streaming works: `stream=True` returns `text/event-stream` chunks in OpenAI SSE format
|
||||
- [ ] `GET /v1/models` returns a JSON array of available model preset names
|
||||
- [ ] A request for an unavailable model returns an OpenAI-format error response with HTTP 503
|
||||
- [ ] LangChain `ChatOpenAI(base_url=..., api_key=...)` works against the gateway
|
||||
- [ ] An integration test covers streaming and non-streaming paths end-to-end through a real tracker and two stub nodes
|
||||
|
||||
## Blocked by
|
||||
|
||||
- `03-tracker-registration-and-routing.md`
|
||||
@@ -0,0 +1,32 @@
|
||||
Status: ready-for-agent
|
||||
|
||||
# 06 — Solana stake + settlement contracts
|
||||
|
||||
## What to build
|
||||
|
||||
Deploy and integrate the Solana smart contracts that make node staking, client payment, and token reward settlement trustless. All development and testing targets **Solana testnet** — never devnet or mainnet during development, to avoid real costs.
|
||||
|
||||
Three contracts are needed:
|
||||
|
||||
**Registry contract**: records stake balances, strike counts, and ban status per wallet. The gateway and tracker read from this contract to exclude banned wallets from route selection.
|
||||
|
||||
**Payment contract**: clients pre-fund an API key account with SOL or USDC. The gateway records per-request compute attribution (which node served which layer range, for how many tokens).
|
||||
|
||||
**Settlement contract**: called once per epoch. Debits client accounts proportional to compute consumed. Credits node operator wallets with our native token proportional to layers served. Distributes a validator reward share.
|
||||
|
||||
The `packages/contracts` package provides Python wrappers for reading and writing to all three contracts. The gateway uses these wrappers to check stake before routing to a node and to record attribution after each request.
|
||||
|
||||
## Acceptance criteria
|
||||
|
||||
- [ ] All contracts deploy successfully to Solana testnet
|
||||
- [ ] A node can submit a stake transaction and have its balance reflected in the registry contract
|
||||
- [ ] A client can fund an API key account with testnet SOL
|
||||
- [ ] After a completed inference session, compute attribution is recorded on-chain with correct node/layer attribution
|
||||
- [ ] The epoch settlement transaction correctly distributes token rewards to node operators and deducts client balances
|
||||
- [ ] The gateway refuses to route to a node whose stake balance is below the minimum threshold
|
||||
- [ ] All contract interactions in tests run against a local Solana test validator (via `solana-test-validator`) — no live testnet required for CI
|
||||
- [ ] A `.env.testnet` config points to Solana testnet RPC for manual end-to-end testing
|
||||
|
||||
## Blocked by
|
||||
|
||||
- `03-tracker-registration-and-routing.md`
|
||||
@@ -0,0 +1,28 @@
|
||||
Status: ready-for-agent
|
||||
|
||||
# 07 — Fraud detection: validator + on-chain slash
|
||||
|
||||
## What to build
|
||||
|
||||
Implement the optimistic fraud detection loop. After each inference request completes, the validator process independently decides whether to re-run the request on a reference node (~5% sample rate). If the reference output diverges from the node's output beyond a configurable floating-point tolerance, the validator submits a slash transaction on-chain.
|
||||
|
||||
The validator is a separate process (not the gateway or tracker). It subscribes to completed inference events, selects a random sample, re-runs those requests against a trusted reference node, compares outputs, and submits slash proofs when fraud is detected.
|
||||
|
||||
On slash: the offending node's stake balance decreases by the configured slash amount; its strike count increments. The gateway reads strike state from the registry contract on each route selection and excludes nodes that exceed the strike threshold.
|
||||
|
||||
Node operators receive a push notification (logged to stdout and, if configured, a webhook) when their node is slashed.
|
||||
|
||||
## Acceptance criteria
|
||||
|
||||
- [ ] The validator process samples ~5% of completed inference requests (configurable)
|
||||
- [ ] A node returning a deliberately wrong output is detected and slashed within one validation cycle
|
||||
- [ ] The on-chain stake balance of the slashed node decreases by the correct slash amount
|
||||
- [ ] The strike count for the slashed node increments on-chain
|
||||
- [ ] A node that reaches the strike threshold is excluded from route selection on the next gateway request
|
||||
- [ ] A slashed node logs a clear warning to stdout
|
||||
- [ ] An integration test: run a deliberately-bad node, send 20 requests, assert at least one slash transaction is submitted and the node is eventually excluded from routes
|
||||
|
||||
## Blocked by
|
||||
|
||||
- `05-openai-compatible-gateway.md`
|
||||
- `06-solana-stake-and-settlement.md`
|
||||
@@ -0,0 +1,27 @@
|
||||
Status: ready-for-agent
|
||||
|
||||
# 08 — Node probationary period + ban enforcement
|
||||
|
||||
## What to build
|
||||
|
||||
Implement the two anti-sybil mechanisms that make re-entering the network after a ban economically costly.
|
||||
|
||||
**Probationary period**: a new wallet's first N completed inference jobs earn no token rewards. N is a configurable on-chain parameter (default: 50 jobs). The settlement contract reads the wallet's job count and skips reward distribution until the threshold is met. The node client displays the remaining probationary job count on startup.
|
||||
|
||||
**Ban enforcement**: when a wallet's strike count reaches the configured threshold, the registry contract marks it as banned. The tracker and gateway must check ban status on every route selection and exclude banned wallets. Ban status is read exclusively from the Solana registry contract — the tracker cannot set or unset bans.
|
||||
|
||||
Both mechanisms together mean a banned node operator must: create a new wallet, fund a new stake, and complete N free jobs before earning again — a meaningful economic barrier.
|
||||
|
||||
## Acceptance criteria
|
||||
|
||||
- [ ] A node with a new wallet receives no token rewards for its first N jobs (verified via settlement contract state)
|
||||
- [ ] The node client prints remaining probationary jobs on startup (e.g. "Probationary period: 38 jobs remaining before earning")
|
||||
- [ ] After N jobs, the next epoch settlement correctly credits the node with token rewards
|
||||
- [ ] A wallet with strike count at the threshold is marked banned in the registry contract
|
||||
- [ ] The tracker excludes banned wallets from route selection
|
||||
- [ ] A banned wallet that attempts to register with the tracker is rejected
|
||||
- [ ] An integration test covers: new wallet → N jobs → earning begins; and: strike threshold reached → banned → excluded from routes
|
||||
|
||||
## Blocked by
|
||||
|
||||
- `07-fraud-detection-slash.md`
|
||||
@@ -0,0 +1,24 @@
|
||||
Status: ready-for-agent
|
||||
|
||||
# 09 — P2P shard swarm
|
||||
|
||||
## What to build
|
||||
|
||||
Once a node has downloaded a shard, it seeds that shard to other nodes that are assigned the same shard. New nodes with the same shard assignment should download from the swarm (peer nodes) rather than HuggingFace when peers are available, reducing HuggingFace load and speeding up propagation of popular shards.
|
||||
|
||||
The shard swarm is keyed by `(model_preset, shard_index)`. Nodes announce their shard availability to the tracker on registration. When a new node requests a shard download, the tracker returns a list of peer endpoints that hold the shard alongside the HuggingFace fallback URL. The node tries peers first; falls back to HuggingFace if no peers respond within a timeout.
|
||||
|
||||
Peers serve shard data over a simple chunked HTTP endpoint — no custom P2P protocol needed in v1. The node client displays download source (peer or HuggingFace) during shard download.
|
||||
|
||||
## Acceptance criteria
|
||||
|
||||
- [ ] A node that has downloaded a shard is listed as a peer for that shard in the tracker
|
||||
- [ ] A second node assigned the same shard downloads it from the first node (peer) rather than HuggingFace (verified by asserting no HuggingFace HTTP calls are made in the test)
|
||||
- [ ] If no peers are available, the node falls back to HuggingFace without error
|
||||
- [ ] The node client logs whether the shard was downloaded from a peer or HuggingFace
|
||||
- [ ] Shard chunks are verified against a checksum before being marked complete
|
||||
- [ ] An integration test: node A downloads shard from HuggingFace stub; node B with same assignment downloads from node A
|
||||
|
||||
## Blocked by
|
||||
|
||||
- `04-node-client-startup.md`
|
||||
@@ -0,0 +1,44 @@
|
||||
Status: ready-for-agent
|
||||
|
||||
# 10 — `meshnet` Python SDK
|
||||
|
||||
## What to build
|
||||
|
||||
A Python SDK (`packages/sdk`) that wraps the OpenAI-compatible gateway and exposes network-specific controls that the raw OpenAI SDK cannot express. The SDK is the recommended interface for developers who want more than basic inference.
|
||||
|
||||
The SDK surface:
|
||||
|
||||
```python
|
||||
from meshnet import Client
|
||||
|
||||
client = Client(api_key="...", base_url="https://api.meshnet.ai")
|
||||
|
||||
# Basic inference (identical to OpenAI SDK)
|
||||
response = client.chat.completions.create(model="llama-3-70b", messages=[...])
|
||||
|
||||
# Network-specific features
|
||||
client.wallet.balance() # SOL/USDC balance remaining
|
||||
client.wallet.top_up(amount_sol=1.0) # returns a Solana payment address + QR
|
||||
client.models.available() # list of routable model presets with shard coverage %
|
||||
client.request(redundancy=2) # route through 2 independent chains, return majority
|
||||
client.estimate_cost(model="llama-3-70b", tokens=1000) # cost in SOL before sending
|
||||
```
|
||||
|
||||
The SDK must not require clients to hold or know about our native token. All wallet operations are in SOL or USDC.
|
||||
|
||||
## Acceptance criteria
|
||||
|
||||
- [ ] `pip install meshnet` installs the SDK
|
||||
- [ ] `Client.chat.completions.create(...)` works identically to the OpenAI SDK (same parameters, same response shape)
|
||||
- [ ] `client.wallet.balance()` returns the current SOL/USDC balance for the API key
|
||||
- [ ] `client.wallet.top_up()` returns a valid Solana payment address
|
||||
- [ ] `client.models.available()` returns model presets with shard coverage percentage
|
||||
- [ ] `client.estimate_cost(model, tokens)` returns a cost estimate in SOL before the request is sent
|
||||
- [ ] `client.request(redundancy=2)` sends the same prompt to two independent inference routes and returns the majority response
|
||||
- [ ] The SDK is typed (py.typed, full type stubs)
|
||||
- [ ] An integration test covers each SDK method against a local gateway + tracker + stub nodes
|
||||
|
||||
## Blocked by
|
||||
|
||||
- `05-openai-compatible-gateway.md`
|
||||
- `06-solana-stake-and-settlement.md`
|
||||
Reference in New Issue
Block a user