Commit Graph

236 Commits

Author SHA1 Message Date
Dobromir Popov
080d49b2c2 feat(us-016): auto-detect shard range from model config
Layer count is now fetched from the curated catalog (zero network calls
for known models) or via AutoConfig.from_pretrained() (~1 KB config.json
only) when model_id is given without --shard-start/--shard-end.

- model_catalog: add detect_num_layers(), two small Qwen models at top
- startup: _detect_num_layers() helper; shard range auto-derived
- wizard: show detected layer count for custom HF repos
- tests: 3 new tests for auto-shard; fix catalog-order assumptions

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-29 18:27:50 +03:00
Dobromir Popov
a2258d3df4 feat(us-017): P2P gossip, NAT-traversal relay node, and TLS
- packages/p2p: identity (peer_id from sha256 of RSA pubkey), TLS cert
  generation with SHA-256 fingerprint, GossipClient (WSS PubSub with
  per-topic handlers, dedup by msg_id, auto-reconnect), MdnsDiscovery
  (zeroconf optional dependency, graceful no-op fallback)
- packages/relay: new meshnet-relay package — RelayServer (asyncio +
  websockets) with gossip fanout hub, circuit relay proxy for NAT traversal,
  peer registry; meshnet-relay CLI
- packages/p2p/relay_bootstrap.json: team relay bootstrap list
- Tracker: _NodeEntry gains relay_addr, cert_fingerprint, peer_id; both
  register and heartbeat handlers read and store these optional fields
- docs/adr/0010 already written (previous commit)
- conftest.py: packages/relay added to sys.path
- 18 new tests; 115 passed total, 1 skipped (no regressions)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-29 17:58:16 +03:00
Dobromir Popov
65f3ee6a85 feat(us-016): mining-style node startup CLI + live dashboard
- `meshnet-node` with no args runs interactive setup wizard on first run,
  then starts directly on subsequent runs using saved config
- Wizard auto-detects all GPUs/VRAM, shows curated model list with per-quant
  VRAM requirements, marks models that exceed available VRAM as incompatible,
  offers HuggingFace Hub browse as escape hatch
- Persistent config saved to ~/.config/meshnet/config.json (0o600)
- Live rich dashboard (tokens/sec EMA, VRAM, requests, peers, uptime) with
  automatic plain-text fallback when stdout is not a TTY (WSL2/SSH/CI)
- All wizard values overridable via CLI flags; --reset-config re-runs wizard
- `meshnet-node models` lists curated models; `--browse` fetches HF Hub top-20
- `meshnet-node config` prints saved config
- `meshnet-node start ...` preserved for backward compatibility
- 19 new tests; 97 passed, 1 skipped (no regressions)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-29 17:45:38 +03:00
Dobromir Popov
65dee3d6d1 feat: tracker-as-first-layer-node inference entry point (US-014)
Tracker: GET /v1/tracker-nodes/<model> returns head-shard nodes registered
with tracker_mode=true. tracker_mode stored per node in registry.

Node (stub + torch): head nodes (shard_start==0 or --tracker-mode flag)
expose /v1/chat/completions alongside /forward. Pipeline: tokenize →
embed → own layers → GET /v1/route (skip self) → binary forward through
remaining hops → decode → SSE back to client.

Gateway: proxies round-robin to tracker-nodes when found, falls back to
existing direct pipeline when none registered. All US-005 tests still pass.

CLI: --tracker-mode and --tracker-url flags on meshnet-node start.

Tests: 4 new integration tests — valid responses on 10 requests, both
tracker-nodes receive load, exact 5/5 round-robin split. 78 pass, 1 skipped.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-29 17:00:52 +03:00
Dobromir Popov
dbf856f497 feat: tracker-as-first-layer-node inference entry point (US-014)
- Tracker: add GET /v1/tracker-nodes/<model> returning nodes registered
  with tracker_mode=true whose shard_start matches the model's first layer
- Node: StubNodeServer and TorchNodeServer accept tracker_mode/tracker_url;
  when tracker_mode=True (or auto-detected via shard_start==0 for Torch),
  /v1/chat/completions is served alongside /forward
- TorchNodeServer: full pipeline implementation — encode_prompt → route
  selection via tracker → binary forward through remaining hops → decode
- Gateway: _handle_chat_completions checks _get_tracker_nodes() first and
  proxies round-robin to tracker-nodes; falls back to existing direct
  pipeline when none found (preserves all US-005 backward compat)
- CLI: --tracker-mode and --tracker-url flags added to meshnet-node start
- Test: two stub tracker-nodes + two mid-shard nodes for gpt2; 10 requests;
  round-robin 5/5 split verified; all OpenAI-format responses validated
- All 78 tests pass

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-29 16:59:32 +03:00
Dobromir Popov
753f553766 feat: coverage-first tracker shard assignment (US-013)
Recovered from interrupted Codex session (ended 13:02, changes uncommitted).
All 74 tests pass.

- Tracker accepts vram_bytes, ram_bytes, quantizations[], benchmark_tokens_per_sec
  in node registration payload
- GET /v1/coverage/<model_preset> returns [{start_layer, end_layer, node_count}]
- Coverage-first bin-packing: fills gaps before adding redundancy
- Speed-weighted assignment: faster nodes get wider shard ranges
- LOAD_SHARD/DROP_SHARD rebalance directives delivered via heartbeat responses
- Model is unroutable when any layer range has node_count=0
- model_presets.json config for bytes_per_layer at each quantization level

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-29 16:37:48 +03:00
Dobromir Popov
85c13e4e82 feat: add per-story metadata line to Ralph dashboard
Each story shows an optional second line with agent · worktree · summary:
- _active_worktrees(): parses git worktree list --porcelain, maps feat/<id> branches
- _story_meta(): joins agent name, worktree path, completionNotes/last commit subject
- print_dashboard: renders metadata line indented below story title
- --compact flag on show/watch suppresses metadata for tight one-line-per-story view

Also wires worktree-by-default groundwork: _active_worktrees called once per
render, worktree paths shown relative to repo root.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-29 16:32:35 +03:00
Dobromir Popov
0152d5ed99 feat(us-015): Ralph status-aware dashboard, agent-agnostic runner
Part 1 — status-field awareness:
- _is_done/_needs_attention/_is_active/_is_in_design helpers with passes fallback
- _story_sets returns 6-tuple: done/attention/active/in_design/ready/blocked
- Dashboard shows ⚠ Attention Required section with status_reason
- auto skips to-revise/needs-review; --include-revise overrides
- _review_report includes Attention Required section

Part 2 — agent-agnostic runner:
- --agent codex|claude|openrouter|custom on run-next/auto/review
- set-agent subcommand persists choice to .ralph-tui/agent-config.json
- _run_openrouter stub (needs OPENROUTER_API_KEY)
- _run_custom_agent: --agent-cmd script receives prompt file as $1
- list-parallel: shows ready stories safe to run concurrently

Part 3 (parallel opt-in): auto --parallel N flag available but not default

Missing (follow-up patch): worktree-by-default for single runs,
per-story metadata line in dashboard (_active_worktrees/_story_meta)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-29 16:30:22 +03:00
Dobromir Popov
7bd663d9b8 feat: Ralph status-aware dashboard, agent-agnostic runner, worktree parallelism
- Add _is_done/_needs_attention/_is_active/_is_in_design status helpers with
  passes-field backward compatibility for old prd.json files
- Rewrite _story_sets to return 6 buckets: done, attention, active, in_design,
  ready, blocked
- Dashboard shows ⚠ Attention required section with status_reason for
  to-revise/needs-review stories; progress bar counts attention as complete
- _review_report includes dedicated Attention Required section
- auto skips attention stories by default; --include-revise flag overrides
- _status_symbol updated to handle all status values (⚠ ?  ✎ • →)
- Agent-agnostic runner: --agent codex|claude|openrouter|custom on run-next,
  auto, review; default agent loaded from .ralph-tui/agent-config.json
- set-agent subcommand writes agent-config.json (agent + optional model)
- _run_openrouter stub with clear error when OPENROUTER_API_KEY not set
- Custom agent support: --agent custom --agent-cmd ./script.sh runs script
  with prompt file as $1
- list-parallel subcommand prints ready stories with no shared dep chain
- auto --parallel N creates git worktrees, runs N agents concurrently,
  merges on success, preserves on failure for manual resolution
- Mark US-015 done in prd.json

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-29 16:27:41 +03:00
Dobromir Popov
8ea70ff6a0 docs(us-015): add Part 4 — per-story agent/worktree/summary in dashboard
Each story shows an optional second line:
  agent · status · worktree path (if not main) · last output summary

Sources: git worktree list, agent-config.json, session.json,
completionNotes, git log on feat/<id> branch, iteration logs.
--compact flag suppresses metadata lines.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-29 16:21:57 +03:00
Dobromir Popov
dac81a66b4 chore(prd): expand US-015 scope with worktree parallelism
auto --parallel N: creates one worktree per ready task, runs N agents
concurrently, merges on success, preserves worktree on conflict.
list-parallel: shows stories safe to run concurrently.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-29 16:14:33 +03:00
Dobromir Popov
d3bb50a894 feat(prd): add US-015 — Ralph agent-agnostic runner + status-field dashboard
Status-field awareness:
- Replace passes:bool with status field in ralph_progress.py
- Six buckets: done, attention, active, in-design, ready, blocked
- Dashboard shows ⚠ Attention Required section for to-revise/needs-review
- auto skips attention stories by default; --include-revise overrides

Agent agnosticism:
- --agent codex|claude|openrouter|custom on all run commands
- Persistent config in .ralph-tui/agent-config.json via set-agent subcommand
- OpenRouter adapter: calls API directly when ralph-tui lacks native plugin
- custom: --agent-cmd <script> receives prompt file as $1

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-29 16:10:28 +03:00
Dobromir Popov
bf5055e6e0 chore(prd): replace passes boolean with rich status field
Status vocabulary: open | in-design | in-progress | needs-review | to-revise | done | blocked
Vocabulary definition stored in metadata.statusVocabulary for tooling.

US-002 → to-revise (base64 wire format replaced by binary in US-011)
US-005 → to-revise (gateway orchestration role superseded by US-014 tracker-as-node)
US-014 → open
All others → done

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-29 16:07:48 +03:00
Dobromir Popov
2690d9b9ba feat: add real PyTorch model backend 2026-06-29 15:54:40 +03:00
Dobromir Popov
c358798627 chore: harden Ralph session controls 2026-06-29 15:54:00 +03:00
Dobromir Popov
8895e5e8f1 chore: add Ralph session controls 2026-06-29 15:36:47 +03:00
Dobromir Popov
cd9e3686a5 docs(adr-0002): lock TAI tokenomics — 1B supply, revenue-backed, 90% floor
Locked decisions:
- 1 billion TAI hard cap, no minting, halving-style emission decay
- No transfer tax; spread-only revenue, decreases with volume
- Buyback floor = 90% of current organic backing price (ratcheting up)
- Wind-down guarantee: 90% floor always funded by protocol spread
- Post-listing speculative risk acknowledged and accepted
- Node bootstrap: probationary period = stake-free entry (no loan/grant)
- Listing threshold (provisional): $50k volume AND 25 nodes / 15+ operators

Open parameters noted: halving schedule, dynamic spread curve, listing %, legal.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-29 15:34:15 +03:00
Dobromir Popov
202b579bd1 docs(adr-0002): rewrite TAI tokenomics with revenue-backed model
- Token named TAI, fixed supply (BTC-inspired), no open market during bootstrap
- Price anchored to inference revenue: team holds ~100% → 36% over ~5 years
- 95% soft buyback floor; ~10% protocol spread funds wind-down reserve
- Wind-down guarantee: protocol can always buy back all issued TAI at issue price
- Open questions section captures unresolved parameters for token launch

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-29 15:15:15 +03:00
Dobromir Popov
2a4383e353 feat: add binary activation wire format 2026-06-29 14:58:55 +03:00
Dobromir Popov
b17deb4d0e chore: add Ralph progress dashboard 2026-06-29 14:58:19 +03:00
Dobromir Popov
b02e07d308 docs: add ADRs and user stories for real model inference stack (US-011–014)
ADR-0008: binary activation wire format — raw bfloat16 over HTTP, zstd compression,
128-token chunked prefill; replaces base64 JSON (~33% overhead removed).

ADR-0009: coverage-first shard assignment and tracker-as-first-layer-node —
any node serving layers[0..k] becomes the inference entry point for that model;
bin-packing fills all coverage gaps before adding redundancy; tracker issues
LOAD_SHARD/DROP_SHARD rebalance directives; nodes declare VRAM + quantization.

US-011: binary wire format migration
US-012: real PyTorch layer execution (transformers + bitsandbytes, test on GPT-2)
US-013: coverage-first tracker bin-packing with VRAM-aware shard assignment
US-014: tracker-as-node (tracker node serves first layers + handles client requests)

CONTEXT.md: Tracker Node, Coverage Map, Rebalance Directive terms added.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-29 14:43:54 +03:00
Dobromir Popov
3286f77e27 feat: add meshnet python sdk 2026-06-29 10:29:19 +03:00
Dobromir Popov
e9c9bf63bc feat: add p2p shard swarm 2026-06-29 10:15:01 +03:00
Dobromir Popov
792a9fd97f feat: add probation and ban enforcement 2026-06-29 09:58:32 +03:00
Dobromir Popov
39f6f23c83 feat: add fraud detection validator 2026-06-29 09:46:22 +03:00
Dobromir Popov
a2aa22fc08 docs: clarify validation slash model 2026-06-29 02:47:36 +03:00
Dobromir Popov
e24c2e3cea feat: add settlement contract boundary 2026-06-29 02:46:25 +03:00
Dobromir Popov
8900990193 docs: clarify contract boundary 2026-06-29 02:31:23 +03:00
Dobromir Popov
3b7ef2743d feat: add OpenAI-compatible gateway
- GET /v1/health, GET /v1/models, POST /v1/chat/completions (streaming + non-streaming)
- OpenAI SDK, LangChain ChatOpenAI, and SSE streaming integration tests
- Tracker-backed GET /v1/models endpoint
- OpenAI-format errors for unavailable model (503) and pipeline failures
- Malformed JSON body handled with 400 instead of crash
- Test deps (openai, langchain-openai) declared in root pyproject dev extras

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-29 01:52:45 +03:00
Dobromir Popov
0199c99f6b feat: add node startup flow 2026-06-29 01:30:12 +03:00
Dobromir Popov
15897d5c95 feat: add tracker registration routing 2026-06-29 01:16:48 +03:00
Dobromir Popov
7c8e85c571 feat: add two-node shard pipeline 2026-06-29 00:34:57 +03:00
Dobromir Popov
1141b51286 feat: scaffold meshnet monorepo 2026-06-29 00:28:29 +03:00
Dobromir Popov
84614a36a4 chore: add Ralph task tracker 2026-06-29 00:16:13 +03:00
Dobromir Popov
2f1f9717be tasks 2026-06-29 00:10:21 +03:00
Dobromir Popov
0f24a1d4f9 iinit 2026-06-28 23:49:11 +03:00