Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/spark-connector/blob/main/docs/PROTOCOL.md # spark-connector aien-dev/spark-connector Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `spark-connector / docs / PROTOCOL.md` 158 lines ยท 7778 bytes Raw Blame History Rendered 1 # Interplane community runner protocol, version 1 (ipcc1) 2 3 This is the wire contract between the runner (`runner/`, this repository) and the hub (the 4 `community/` slice of interplane-forge, served at https://interplane.io/community/). Both sides 5 are seeded Omega. Every message is plain ASCII text. There is no JSON, no cookie and no account. 6 7 ## Keys and signatures 8 9 - A runner key is an ECDSA key on NIST P-256. The public key travels as 130 lowercase hex 10 characters: the 65-byte SEC1 uncompressed point `04 || X || Y`. 11 - The key id is the lowercase hex SHA-256 of those 65 bytes (64 characters). 12 - A signature is ECDSA over P-256 with SHA-256: the digest is SHA-256 of the signed bytes, and the 13 signature travels as 128 lowercase hex characters, `r || s`, each 32 bytes big-endian. 14 The hub verifies with `ecdsa_verify_raw` from omega-mv `om/tls/ec.om`; the runner signs with 15 `runner/20key.om` and checks its own signature with the same verifier before it sends anything. 16 17 ## Message form (runner to hub) 18 19 Each message is the body of one `POST` to `https://interplane.io/community/api`, at most 4096 20 bytes, `Content-Type: text/plain`. It is a sequence of lines, each `name SP value LF`, in the 21 fixed order shown, with no other bytes: no carriage return, no trailing space, no blank line, 22 no repeated or extra field. The first line names the protocol and the kind. The last line is 23 `sig <128 hex>`. The signed bytes are every byte before `sig `. 24 25 `time` is Unix seconds in decimal without leading zeros. The hub refuses a message whose time is 26 more than 300 seconds away from its own clock. 27 28 ### register 29 30 ``` 31 ipcc1 register 32 pub <130 hex> 33 time 34 rate 35 sig <128 hex> 36 ``` 37 38 The signature proves the sender holds the private key. The hub stores the registration. A key 39 that registers again updates its `rate`; a key that left may register again. 40 41 ### next (ask for work) 42 43 ``` 44 ipcc1 next 45 key <64 hex key id> 46 time 47 nonce <32 hex> 48 sig <128 hex> 49 ``` 50 51 ### result 52 53 ``` 54 ipcc1 result 55 key <64 hex key id> 56 job <32 hex> 57 part <64 hex revision: the salvage record id> 58 compiler <64 hex sha256 of the compiler that built the part> 59 binary <64 hex sha256 of the compiled binary, 64 zeros when the compiler refused> 60 stdout <64 hex sha256 of the bytes the declared example wrote to stdout> 61 exit 62 time 63 sig <128 hex> 64 ``` 65 66 `` is one of: a decimal exit status `0`..`255` of the program; `signal` (N 1..127) when 67 a signal ended it (the cell's CPU limit is `signal24`); `timeout` when the runner's 3 s wall clock 68 ended it; for the compile stage, `omc` when the compiler exited with status K, `omcsignal` 69 or `omctimeout` (in those three cases `binary` is 64 zeros and `stdout` is the SHA-256 of no 70 bytes); `cell` when the cell itself could not start (E the errno), so the machine cannot run 71 jobs. A `cell` result is stored and listed in the ledger but never counted. 72 73 ### leave 74 75 ``` 76 ipcc1 leave 77 key <64 hex key id> 78 time 79 sig <128 hex> 80 ``` 81 82 ## Replies (hub to runner) 83 84 Every reply is `text/plain`. The first line is `ipcc1 ok ` or `ipcc1 refused `, 85 where `` is one lowercase word from the table below. The HTTP status is 200 for ok, 86 400 for a malformed message, 403 for a refusal by rule, 409 for a duplicate, 413 for size and 503 when the 87 community service is off. The hub refuses nothing for volume: it counts signed messages (after the signature and replay checks) per key 88 and in all, and refusals, per hour, and writes one line to `/community/alarms` naming the key (or 89 "all", "refused") and the count when a count first passes its threshold (150 per key, 3600 in all, 90 3600 refusals). The public edge limits request rate per address (HTTP 429 from nginx); the runner 91 backs off on any error. 92 93 A job reply to `next`: 94 95 ``` 96 ipcc1 ok job 97 job <32 hex> 98 part <64 hex> 99 compiler <64 hex> 100 ``` 101 102 The runner fetches the record from `/salvage//record`. 103 104 No work: `ipcc1 ok none` then `retry `. Other replies: `ipcc1 ok registered`, 105 `ipcc1 ok counted` (a result that counts), `ipcc1 ok stored` (a `cell` result), `ipcc1 ok left`. 106 A refused body is answered with `ipcc1 refused `; every refusal and every accepted 107 message is public: `/community/refused`, `/community/ledger`, 108 `/community/msg/`, `/community/key/`. 109 110 | reason | when | 111 |---|---| 112 | `malformed` | the body does not have the exact form above | 113 | `size` | the body is longer than 4096 bytes | 114 | `clock` | `time` is more than 300 s from the hub clock | 115 | `signature` | the signature does not verify for the key | 116 | `unregistered` | the key id is not registered, or it has left | 117 | `denied` | the key or the part is on the hub deny list | 118 | `job` | the job id was not issued to this key, or it expired (3600 s) | 119 | `mismatch` | `part` or `compiler` differ from what the job named | 120 | `duplicate` | this key already has a counted result for this part (stored, not counted) | 121 | `off` | the community service is switched off on this hub | 122 | `store` | the hub could not write its store (try again later) | 123 124 Every refusal is appended to the hub's refusal log with its reason and, when known, the key id and the message id. The message id is the SHA-256 of the signed bytes (everything before the `sig` line): it names the stored message and is the replay key, so the other valid encoding of the same signature ((r, n - s)) is a replay too. The ledger and the refusal log are set aside as `ledger.` and `refused.` when they reach 4 MiB; all parts stay public. 125 126 ## The job class in version 1 127 128 A job names a published salvage part (a record id, which is the SHA-256 of the record bytes) and 129 the compiler SHA-256 the hub's own check used. The runner: 130 131 1. refuses the job unless `compiler` equals the one compiler it carries 132 (omc ``3ad9f10f64309e7acf8a725082b28e23a2a4aeb07e98322fb4dc0fcd8fc93194``, omega-mv `f4df8239`, 133 the salvage pin), whose file it hashes again before every job; 134 2. fetches the record over HTTPS, refuses it unless its SHA-256 equals `part` and it parses as a 135 part record (`IPSLV001`, kind 2), and takes the source and the declared stdin from it; 136 3. compiles the source with that compiler inside the cell, then runs the binary inside the cell 137 with the declared stdin; 138 4. hashes the binary and the stdout bytes, signs the result and posts it. 139 140 The cell is omega-mv `execpure` for both stages (the compiler too): Landlock allows only reading 141 and executing the one program, `PR_SET_NO_NEW_PRIVS`, seccomp allows only `read` on descriptor 0, 142 `write` on descriptors 1 and 2, `exit` and `execveat` of that program, and prlimit sets CPU 1 s 143 soft / 2 s hard, file size 1 MiB, stack 8 MiB, no core, no new processes, 4 descriptors and 144 128 MiB address space, with an empty environment. The runner adds a 3 s wall clock per stage. 145 Brought code never runs outside the cell. There is no GPU work in version 1. 146 147 ## Counting rule (the hub page) 148 149 - Only results that passed every check above count. Each key counts at most once per part 150 revision: the first accepted result of that key for that revision; later ones are stored as 151 `duplicate` and never counted. 152 - N is the number of keys counted for the revision. Results agree when `binary`, `stdout` and 153 `exit` are all equal. K is the size of the largest agreeing group; the rest disagree. 154 When two groups tie for largest, K is reported for each and no group is called the agreement. 155 - The page says "ran again by N community runners: K agree" and, when any disagree, 156 "D disagree" and that the part is not shown as reproduced. 157 - Keys are free, so N unknown keys agreeing is not called verified and never changes what the 158 hub's own tick means.