mobhub
Decentralized model and agent weights distribution network
Brought by drakestapleton
mobhub / README.md
| 1 | # MobHub |
| 2 | |
| 3 | Ultra-high-performance native Rust and Mojo rewrite of the MobHub faction operations engine for Torn City. |
| 4 | |
| 5 | Replaces the legacy Node.js/Next.js implementation with compiled native binaries, embedded SQLite persistence, and sub-millisecond execution. |
| 6 | |
| 7 | ## Architectural Highlights |
| 8 | |
| 9 | - **Pure Native Execution**: Built with native Rust (Axum, Tokio, SQLite) and Modular Mojo. Zero Node.js or Python daemons required. |
| 10 | - **MobPay Payout Engine**: Deterministic calculation engine supporting flat-rate respect-based and pool-share hit-based models. Bit-for-bit validated against GanjaWarriors ranked war #40711 ground truth data. Zero rounding drift reconciliation. |
| 11 | - **Disbursement & Money-Log Reconciliation**: Parses Torn depositFunds money-log news entries (with automatic OC-cut exclusion) and matches them against payout register rows to record and confirm paid status. |
| 12 | - **MobWorth Valuation**: Instant faction net worth calculations parsing spendable vault funds and armory holdings. |
| 13 | - **MobGym Mojo Kernel**: High-speed numerical calculations implementing Vladar Training Formula V2.0 for single-train and multi-train sessions with happy decay. |
| 14 | - **Hardware TPM Key Vault**: Dynamic in-memory credential resolution (atlas-vault get TORN_API_KEY). Zero plaintext credentials stored on disk. |
| 15 | - **Embedded Web Dashboard**: Self-contained web UI served directly from Axum with zero external CDN or npm package dependencies. |
| 16 | |
| 17 | ## Installation and Build |
| 18 | |
| 19 | ### Prerequisites |
| 20 | - Rust toolchain (1.80+) |
| 21 | - Modular Mojo (for gym trajectory compilation) |
| 22 | - SQLite3 |
| 23 | |
| 24 | ### Compilation |
| 25 | ```bash |
| 26 | cargo build --release |
| 27 | ``` |
| 28 | |
| 29 | Compiled binary will be available at `target/release/mobhub`. |
| 30 | |
| 31 | ## CLI Usage |
| 32 | |
| 33 | ### System Diagnostics |
| 34 | ```bash |
| 35 | ./target/release/mobhub doctor |
| 36 | ``` |
| 37 | |
| 38 | ### TPM Vault Verification |
| 39 | ```bash |
| 40 | ./target/release/mobhub test-vault |
| 41 | ``` |
| 42 | |
| 43 | ### Calculate War Payout |
| 44 | ```bash |
| 45 | ./target/release/mobhub payout --cache 349499999 --model flat_rate |
| 46 | ``` |
| 47 | |
| 48 | ### Calculate Faction Valuation |
| 49 | ```bash |
| 50 | ./target/release/mobhub valuation --respect 100000 --rate 180284 --armory 50000000 --cash 25000000 |
| 51 | ``` |
| 52 | |
| 53 | ### Simulate Gym Training Session |
| 54 | ```bash |
| 55 | ./target/release/mobhub gym --stat strength --start-stat 1000000 --happy 5000 --energy 1000 --dots 7.3 |
| 56 | ``` |
| 57 | |
| 58 | ### Reconcile Money Log Disbursements |
| 59 | ```bash |
| 60 | ./target/release/mobhub reconcile --news-file news.json --register-file register.json |
| 61 | ``` |
| 62 | |
| 63 | ### Run HTTP Service & Embedded Dashboard |
| 64 | ```bash |
| 65 | ./target/release/mobhub serve --port 3000 --db-path mobhub.db --faction-id 50645 |
| 66 | ``` |
| 67 | |
| 68 | ## API Endpoints |
| 69 | |
| 70 | | Method | Path | Description | |
| 71 | |---|---|---| |
| 72 | | `GET` | `/health` | System health check | |
| 73 | | `GET` | `/status` | TPM vault status and runtime telemetry | |
| 74 | | `POST` | `/api/payout/compute` | Run deterministic war payout calculation | |
| 75 | | `POST` | `/api/payout/export-csv` | Export payout register as CSV | |
| 76 | | `POST` | `/api/valuation/compute` | Calculate faction valuation breakdown | |
| 77 | | `POST` | `/api/gym/simulate` | Simulate gym session via Mojo/Rust engine | |
| 78 | | `POST` | `/api/reconcile/parse` | Parse raw Torn news to disbursements | |
| 79 | | `POST` | `/api/reconcile/match` | Match disbursements to payout register rows | |
| 80 | | `GET` | `/api/disbursements` | List stored disbursements | |
| 81 | | `POST` | `/api/disbursements` | Store disbursements into SQLite | |
| 82 | | `GET` | `/api/wars` | List archived wars from SQLite | |
| 83 | | `POST` | `/api/wars` | Record or import war | |
| 84 | | `GET` | `/api/balances` | List member vault balances | |
| 85 | | `GET` | `/` | Embedded web management dashboard | |
| 86 | |
| 87 | ## Test Verification |
| 88 | |
| 89 | Run all unit and integration tests: |
| 90 | ```bash |
| 91 | cargo test --verbose |
| 92 | ``` |
| 93 | |
| 94 | All calculations are tested against real faction ground truth data and reference gym formula values. |
| 95 | |
| 96 | ## License |
| 97 | |
| 98 | MIT OR Apache-2.0 |