interplane.Get Omega
Read in your language

spark-connector

aien-dev/spark-connector

Brought by drakestapleton

branch main Branches Tags History

spark-connector / docs / PROTOCOL.md

158 lines · 7778 bytes Raw Blame History Source

Interplane community runner protocol, version 1 (ipcc1)

This is the wire contract between the runner (runner/, this repository) and the hub (the community/ slice of interplane-forge, served at https://interplane.io/community/). Both sides are seeded Omega. Every message is plain ASCII text. There is no JSON, no cookie and no account.

Keys and signatures

Message form (runner to hub)

Each message is the body of one POST to https://interplane.io/community/api, at most 4096 bytes, Content-Type: text/plain. It is a sequence of lines, each name SP value LF, in the fixed order shown, with no other bytes: no carriage return, no trailing space, no blank line, no repeated or extra field. The first line names the protocol and the kind. The last line is sig <128 hex>. The signed bytes are every byte before sig .

time is Unix seconds in decimal without leading zeros. The hub refuses a message whose time is more than 300 seconds away from its own clock.

register

ipcc1 register
pub <130 hex>
time <decimal>
rate <decimal: checks per hour, the volunteer's own setting (0 = paused)>
sig <128 hex>

The signature proves the sender holds the private key. The hub stores the registration. A key that registers again updates its rate; a key that left may register again.

next (ask for work)

ipcc1 next
key <64 hex key id>
time <decimal>
nonce <32 hex>
sig <128 hex>

result

ipcc1 result
key <64 hex key id>
job <32 hex>
part <64 hex revision: the salvage record id>
compiler <64 hex sha256 of the compiler that built the part>
binary <64 hex sha256 of the compiled binary, 64 zeros when the compiler refused>
stdout <64 hex sha256 of the bytes the declared example wrote to stdout>
exit <outcome>
time <decimal>
sig <128 hex>

<outcome> is one of: a decimal exit status 0..255 of the program; signal<N> (N 1..127) when a signal ended it (the cell's CPU limit is signal24); timeout when the runner's 3 s wall clock ended it; for the compile stage, omc<K> when the compiler exited with status K, omcsignal<N> or omctimeout (in those three cases binary is 64 zeros and stdout is the SHA-256 of no bytes); cell<E> when the cell itself could not start (E the errno), so the machine cannot run jobs. A cell result is stored and listed in the ledger but never counted.

leave

ipcc1 leave
key <64 hex key id>
time <decimal>
sig <128 hex>

Replies (hub to runner)

Every reply is text/plain. The first line is ipcc1 ok <kind> or ipcc1 refused <reason>, where <reason> is one lowercase word from the table below. The HTTP status is 200 for ok, 400 for a malformed message, 403 for a refusal by rule, 409 for a duplicate, 413 for size and 503 when the community service is off. The hub refuses nothing for volume: it counts signed messages (after the signature and replay checks) per key and in all, and refusals, per hour, and writes one line to <hub>/community/alarms naming the key (or "all", "refused") and the count when a count first passes its threshold (150 per key, 3600 in all, 3600 refusals). The public edge limits request rate per address (HTTP 429 from nginx); the runner backs off on any error.

A job reply to next:

ipcc1 ok job
job <32 hex>
part <64 hex>
compiler <64 hex>

The runner fetches the record from <hub>/salvage/<part>/record.

No work: ipcc1 ok none then retry <seconds>. Other replies: ipcc1 ok registered, ipcc1 ok counted (a result that counts), ipcc1 ok stored (a cell result), ipcc1 ok left. A refused body is answered with ipcc1 refused <reason>; every refusal and every accepted message is public: <hub>/community/refused, <hub>/community/ledger, <hub>/community/msg/<message id>, <hub>/community/key/<key id>.

reasonwhen
malformedthe body does not have the exact form above
sizethe body is longer than 4096 bytes
clocktime is more than 300 s from the hub clock
signaturethe signature does not verify for the key
unregisteredthe key id is not registered, or it has left
deniedthe key or the part is on the hub deny list
jobthe job id was not issued to this key, or it expired (3600 s)
mismatchpart or compiler differ from what the job named
duplicatethis key already has a counted result for this part (stored, not counted)
offthe community service is switched off on this hub
storethe hub could not write its store (try again later)

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.<seconds> and refused.<seconds> when they reach 4 MiB; all parts stay public.

The job class in version 1

A job names a published salvage part (a record id, which is the SHA-256 of the record bytes) and the compiler SHA-256 the hub's own check used. The runner:

  1. refuses the job unless compiler equals the one compiler it carries (omc 3ad9f10f64309e7acf8a725082b28e23a2a4aeb07e98322fb4dc0fcd8fc93194, omega-mv f4df8239, the salvage pin), whose file it hashes again before every job;
  2. fetches the record over HTTPS, refuses it unless its SHA-256 equals part and it parses as a part record (IPSLV001, kind 2), and takes the source and the declared stdin from it;
  3. compiles the source with that compiler inside the cell, then runs the binary inside the cell with the declared stdin;
  4. hashes the binary and the stdout bytes, signs the result and posts it.

The cell is omega-mv execpure for both stages (the compiler too): Landlock allows only reading and executing the one program, PR_SET_NO_NEW_PRIVS, seccomp allows only read on descriptor 0, write on descriptors 1 and 2, exit and execveat of that program, and prlimit sets CPU 1 s soft / 2 s hard, file size 1 MiB, stack 8 MiB, no core, no new processes, 4 descriptors and 128 MiB address space, with an empty environment. The runner adds a 3 s wall clock per stage. Brought code never runs outside the cell. There is no GPU work in version 1.

Counting rule (the hub page)