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 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
- A runner key is an ECDSA key on NIST P-256. The public key travels as 130 lowercase hex characters: the 65-byte SEC1 uncompressed point `04 || X || Y`.
- The key id is the lowercase hex SHA-256 of those 65 bytes (64 characters).
- A signature is ECDSA over P-256 with SHA-256: the digest is SHA-256 of the signed bytes, and the signature travels as 128 lowercase hex characters, `r || s`, each 32 bytes big-endian. The hub verifies with `ecdsa_verify_raw` from omega-mv `om/tls/ec.om`; the runner signs with `runner/20key.om` and checks its own signature with the same verifier before it sends anything.
## 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
rate
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
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
time
sig <128 hex>
```
`` is one of: a decimal exit status `0`..`255` of the program; `signal` (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` when the compiler exited with status K, `omcsignal` or `omctimeout` (in those three cases `binary` is 64 zeros and `stdout` is the SHA-256 of no bytes); `cell` 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
sig <128 hex>
```
## Replies (hub to runner)
Every reply is `text/plain`. The first line is `ipcc1 ok ` or `ipcc1 refused `, where `` 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 `/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 `/salvage//record`.
No work: `ipcc1 ok none` then `retry `. 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 `; every refusal and every accepted message is public: `/community/refused`, `/community/ledger`, `/community/msg/`, `/community/key/`.
reason when
`malformed` the body does not have the exact form above
`size` the body is longer than 4096 bytes
`clock` `time` is more than 300 s from the hub clock
`signature` the signature does not verify for the key
`unregistered` the key id is not registered, or it has left
`denied` the key or the part is on the hub deny list
`job` the job id was not issued to this key, or it expired (3600 s)
`mismatch` `part` or `compiler` differ from what the job named
`duplicate` this key already has a counted result for this part (stored, not counted)
`off` the community service is switched off on this hub
`store` the 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.` and `refused.` 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:
- 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;
- 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;
- compiles the source with that compiler inside the cell, then runs the binary inside the cell with the declared stdin;
- 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)
- Only results that passed every check above count. Each key counts at most once per part revision: the first accepted result of that key for that revision; later ones are stored as `duplicate` and never counted.
- N is the number of keys counted for the revision. Results agree when `binary`, `stdout` and `exit` are all equal. K is the size of the largest agreeing group; the rest disagree. When two groups tie for largest, K is reported for each and no group is called the agreement.
- The page says "ran again by N community runners: K agree" and, when any disagree, "D disagree" and that the part is not shown as reproduced.
- Keys are free, so N unknown keys agreeing is not called verified and never changes what the hub's own tick means.