interplane.Get Omega
Read in your language

interplane-forge

INTERPLANE Forge

Brought by drakestapleton

branch main Branches Tags History

interplane-forge / docs / SALVAGE.md

148 lines · 14607 bytes Raw Blame History Rendered
1# Interplane salvage release candidate
2
3This candidate turns the welcome page into a bounded, working journey: a builder signs in with a Radicle key, shares unfinished source, derives a native Omega part, verifies a declared example, explicitly publishes it, and downloads a reproduction bundle. It is isolated from the live Interplane service.
4
5## Supported public surface
6
7- `/salvage/`: public source and passing published parts, with bounded pagination.
8- `/salvage/new`: authenticated, permission-confirmed source submission.
9- `/salvage/<SHA256>`: exact immutable revision, attribution, source, example and verification status.
10- `/source.om`, `/record`, `/stdin`, `/expected`, `/receipt`, `/bundle.tar` below that revision: authorized downloads. Unknown and private revisions are 404.
11- POST actions on a revision: derive, verify, publish and withdraw. Ownership is the authenticated DID, not its display name. The hub's existing node DID can withdraw public content.
12- A source's withdrawal hides its derived parts. Duplicate submission cannot reverse withdrawal. Withdrawal cannot recall copies already downloaded.
13
14Intake is UTF-8 text, at most 16 KiB per source, with explicit original source, attribution, description and one of four supported permissive licenses. The author affirms permission; the hub does not establish legal ownership. CRLF and CR form newlines become LF before hashing. The existing HTTP layer also caps the complete encoded request body at 64 KiB. No URL is fetched. No archive is unpacked. Source is inert until a builder explicitly derives and verifies a self-contained Omega program.
15
16Parts have one declared stdin/expected-stdout example, at most 4 KiB each. Repair is human-assisted. Model-assisted conversion, arbitrary project builds, weights, hardware orchestration and universal correctness are outside this release. Existing model/agent/system repositories remain linked from the hub. The existing aien-train weight-patching tool is not duplicated.
17
18## Implementation and trust boundary
19
20All new application behavior, storage, collector, replay and behavioral tests are native `.om`. HTML/CSS are emitted presentation data. The existing `run.sh` build glue composes the modules and invokes native tests; it is not a replacement runtime. The explicitly requested formal predicate proof is Lean 4.
21
22The application requires the existing seeded compiler pin:
23
24- Omega source revision: `f4df82394e35893dcf1354dda69a2fe028d94bc1`
25- Compiler SHA-256: `3ad9f10f64309e7acf8a725082b28e23a2a4aeb07e98322fb4dc0fcd8fc93194`
26- Compiler source SHA-256: `0effe37afc4ddd0507151c9f2afa34b3e6774eae7006cbecd8c59f11bc386db7`
27- Rung-zero hex SHA-256: `baaf081fe6055a768485c5d25d7435681ce00b04cfa80b26c48169f78944e14d`
28
29The compiler was independently rebuilt through `seed/omega-from-seed.sh`. The rebuilt and pinned compilers produce identical application bytes for identical composed source. This is a reproducibility check, not a formal proof of the entire compiler.
30
31The collector copies and hashes the compiler into private scratch space. It compiles in an empty `bwrap --unshare-all` namespace with only the pinned compiler mounted read-only. `prlimit` bounds address space, CPU and file output. The completed compiler output is copied into a separate sealed inode before execution, because Linux was observed refusing the original output with ETXTBSY, meaning an outstanding writer still held that inode. The exact natural writer was not identified; the new inode removes that lifetime dependency. A native held-writer control reproduces ETXTBSY on the original output and verifies the separate inode executes while that writer remains open. Generated programs run exclusively through Omega's existing `execpure`: Landlock ABI 3, seccomp, strict stdio, no network/files/process creation, fixed resource limits. Missing isolation refuses verification; there is no weaker fallback. External Linux isolation tools remain dependencies.
32
33Each compile and execution has a three-second wall deadline, plus bounded kill/reap handling. The run must exit zero and produce exactly the declared bytes. The negative control changes the expected bytes and must be rejected by the same comparator. This is a comparator negative control, not a second proof of arbitrary program behavior. The sandbox tests separately exercise wrong output, invalid source, denied file access, CPU exhaustion and a nonzero exit.
34
35One collector holds an independent kernel lock through verification, receipt creation and cleanup. A new server instance cannot run a conflicting collector while an old one survives. There are no cron jobs, timers for work discovery, directory scans or background model calls. A verification POST starts the bounded child directly. If the server stops before accepting a job, the saved draft can be retried.
36
37The root must be a private 0700 directory at an absolute configured path ending in slash. Files are 0600, final path opens refuse symlinks, writes loop for partial output, fsync precedes atomic rename, and affected directories are synced. An exclusive writer lock prevents multiple web processes sharing a store. Startup rebuilds owner quotas from hash-checked indexed records. A corrupt record, missing key in a nonempty store, or failed required initialization disables the store.
38
39There are at most 4096 immutable records and 64 per DID, including drafts and withdrawals. Per-IP and per-DID request limits use the existing forge gate; salvage charges its own accepted write attempts to the DID counter. The short-window counter is process state, while the per-author storage allocation survives restart. This is a small public release, not an unbounded storage service. A hostile population with many identities can still consume the total allocation. Operators must monitor capacity and moderate public submissions.
40
41Trusted boundaries remain the host operator, kernel, pinned compiler and signed-session authentication. The implementation does not defend against the host owner modifying code or keys.
42
43## Record and receipt format
44
45`record.ip` is exactly:
46
471. ASCII `IPSLV001` (8 bytes).
482. Kind byte (1 source, 2 part), then seven zero bytes.
493. Twelve unsigned 32-bit little-endian field lengths.
504. The twelve field payloads, in order, with no trailing data.
51
52Fields: author DID, title, original source, license, description, source bytes, parent source ID, stdin, expected stdout, attribution, language, schema marker. The record's SHA-256 is its revision ID. It binds both the program and its declared example.
53
54The collector receipt is 353 bytes: record ID (64 lowercase hex), result byte (1 pass, 2 refusal), binary SHA-256 (64), stdout SHA-256 (64), compiler SHA-256 (64), policy SHA-256 (64), then HMAC-SHA256 over the first 321 bytes. For refusal receipts, bytes 65..67 carry phase, exit status and signal status; artifact hash slots otherwise remain zero. Publication accepts only an authenticated passing receipt for the exact record and current compiler/policy.
55
56The HMAC authenticates the collector to this hub. It is **not a publicly verifiable digital signature**. Public verification is independent replay, including comparison of the rebuilt binary and output hashes. A receipt by itself proves neither authorship nor safety.
57
58`state/<ID>` contains ID (64), action (1 published, 2 withdrawn), then HMAC-SHA256 (32). A missing state is private; a malformed state is refused.
59
60## Reproduce without trusting the hub
61
62Use Linux AArch64 with the compiler pin above, `bwrap`, `prlimit`, Landlock ABI 3 and seccomp. Acquire and verify the pinned Omega source through the existing harness/seed workflow. In this checkout:
63
64```sh
65OMV="$HOME/work/flux/omega-mv"
66{ printf 'om2\n'; cat "$OMV/om/tls/sha2.om" salvage/00core.om salvage/10verify.om salvage/replay.om; } > /tmp/interplane-replay.om
67"$OMV/seed/out/omc" < /tmp/interplane-replay.om > /tmp/interplane-replay
68chmod 700 /tmp/interplane-replay
69scratch=$(mktemp -d /tmp/interplane-replay.XXXXXX)
70OMEGA_COMPILER="$OMV/seed/out/omc" /tmp/interplane-replay /absolute/path/record.ip EXPECTED_RECORD_SHA256 "$scratch/" /absolute/path/receipt.ip
71```
72
73Obtain EXPECTED_RECORD_SHA256 independently from the revision you intend to reproduce, rather than trusting an unverified bundle's label. The compiler location is supplied privately through `OMEGA_COMPILER`, an absolute path to the actual verified file. The application, tests and replay retain the same mandatory compiler hash; an absent, symlinked or wrong compiler is refused.
74
75The deterministic tar contains only fixed regular filenames: `record.ip`, `receipt.ip`, `source.om`, `stdin`, `expected`, `README.txt`. No executable flags, links or paths are emitted. `docs/salvage/example.tar` is the synthetic public test bundle.
76
77The replay tool checks the record ID and receipt policy/compiler/record fields, recompiles in the sandbox, replays the example, checks the negative control, and compares the rebuilt binary/output hashes. A modified record or binary digest is refused. Replay does not know or need the hub's HMAC secret.
78
79## Verification and operational boundary
80
81Run the targeted native checks on the runner or Spark, not a heavy suite on the interactive Mac:
82
83```sh
84FORGED_CPUS=6 ./run.sh check-salvage
85lean docs/salvage/Visibility.lean
86```
87
88The checks cover immutable records and tampering, durable owner quotas, writer exclusion, sandbox refusal paths, real asynchronous collection, draft/public ownership, withdrawal, malformed form escapes, the visibility truth table, and existing Observatory routes.
89
90`Visibility.lean` proves four properties of the exact three-Boolean publication predicate: a public part requires a passing receipt; withdrawing the parent hides a part; a draft is not public; all requirements suffice. Lean 4.35.0 reports no axioms for these theorems. This is a predicate proof, not end-to-end formal verification. Native tests exercise all eight truth assignments and the real route transitions.
91
92The isolated browser/HTTP qualification uses disposable signed identities. See `EVIDENCE.md` for hashes, replay results and scope. Test keys, cookies, collector keys and private host data are not in the repository.
93
94The candidate is opt-in through `INTERPLANE_SALVAGE_DIR`, with `OMEGA_COMPILER` required for verification. Without it, salvage routes return 503 with an explicit configuration message. Configure a dedicated private store only for the intended candidate instance. Do not point the isolated candidate at live social or salvage data.
95
96Production deployment, DNS, proxy settings, service restarts and migrations are not performed by this source release. Keep the existing HTTPS and trusted-proxy boundary: the server listens on loopback, authentication cookies are Secure/HttpOnly, and POST Origin is checked against the configured public origins. The development browser fixture changes the allowed origin only in its disposable composed source.
97
98## Running it beside the sandboxed server
99
100The live forged runs in a namespace with no network, no compiler, no `bwrap` and nested namespaces
101disabled (`infra/spark/forged-sandbox.sh`). A verifier inside that process could never compile or
102run a submission, so verification is its own program:
103
104| Part | Where it runs | What it does |
105|---|---|---|
106| forged, `salvage/` slice | inside the forged sandbox | pages, sign-in checks, drafts, records, publication state; on "verify" it creates the one job file `<store>job` holding the record id |
107| `salvage/collector.om` (`./run.sh collector`) | its own service, outside that sandbox | polls the job file about three times a second, verifies in its own empty namespace with the pinned compiler, writes `<store>receipts/<id>`, removes the job |
108
109They share only the store. One job at a time: while the job file exists, another "verify" answers
110503 "The verifier is busy". If the collector is not running the job stays queued and the page keeps
111saying that verification is in progress; nothing is published without a receipt.
112
113The collector's scratch folder (`INTERPLANE_SALVAGE_WORK`) must be outside the store, and the
114program refuses to start otherwise. The sandboxed server can write everything in the store, and
115scratch files are compiled and executed, so a scratch folder in the store would let a compromised
116server swap a file between its check and its use. The collector treats the store as input from a
117less trusted process: fixed names, the job must be a record id, the record must hash to that id,
118every read is bounded and refuses a symlink as the file. Known limit: the server holds the receipt
119key (it checks receipts with it), so a compromised server could write a passing receipt itself.
120That was already true when the verifier was a child of the server. Outside verification stays
121independent replay, as above. The store's folders themselves are not re-checked for symlinks on
122every pass; the worst a swapped folder gives is a 353-byte receipt file, named by a record id,
123written to another folder of the owner.
124
125Install on the Spark (after review; nothing here is done by the source release):
126
127```sh
128C=$(git rev-parse --short=8 HEAD); D=$HOME/.local/lib/interplane-salvage/$C
129mkdir -p "$D" "$HOME/forge-salvage-work" && chmod 700 "$HOME/forge-salvage-work"
130COLLECTOR_OUT="$D/salvage-collector" ./run.sh collector
131cp "$HOME/work/flux/omega-mv/seed/out/omc" "$D/omc" # the collector refuses any digest but the pin
132ln -sfn "$D" "$HOME/.local/lib/interplane-salvage/current"
133cp infra/spark/interplane-salvage.service ~/.config/systemd/user/
134systemctl --user daemon-reload && systemctl --user enable --now interplane-salvage.service
135# then switch the server on: add FORGED_SALVAGE=on to the env list of interplane-forged.service
136# (ExecStart) and restart it. The server creates <data>/salvage/ (0700) and its key on first use.
137```
138
139Check: `curl -s -o /dev/null -w '%{http_code}\n' https://interplane.io/salvage/` answers 200 (503
140"not configured" while the switch is off, 404 on a build without the slice).
141Undo: remove `FORGED_SALVAGE=on` and restart forged; `systemctl --user disable --now
142interplane-salvage.service`. The store stays where it is; nothing is deleted.
143
144Gate: `./run.sh check-salvage` ends with `SALVAGE_COLLECTOR PASS 10`. It runs the collector
145program against the store the journey test left: no store, no scratch folder, a scratch folder
146inside the store (refused), a store without a key (waits, creates none), nothing queued, a damaged
147job file (removed), a wrong compiler (refusal receipt, never a pass), a queued job (receipt, job
148removed), and the scratch folder left empty.