chain: the INTERPLANE ledger, a record anyone can check
A hash chain for what agents and people did: hand-offs, verdicts, merges, messages. Each record
commits to its payload and to the record before it, so the ledger's last digest fixes its whole
history. Checking it needs no trust in this program, its author or any model vendor: the format is
one text line per record and the only arithmetic is SHA-256, which sha256sum already does.
Status: IMPLEMENTED and EXERCISED on the Spark host (gate below). No ledger is published yet.
Format
One line per record, seven tab-separated fields, ended by a line feed:
seq utc kind actor subject payload prev
| Field | Rule |
|---|---|
seq | counts from 1, no gaps, no leading zero |
utc | YYYY-MM-DDTHH:MM:SSZ, a real date and time, never earlier than the record before |
kind | A-Z, 0-9, _; 1 to 24 bytes |
actor, subject | printable ASCII; 1 to 64 and 1 to 128 bytes |
payload | SHA-256 of the payload bytes, 64 lowercase hex digits |
prev | SHA-256 of the previous record's line (without its line feed); GENESIS in record 1 |
The head of a ledger is the SHA-256 of its last line.
Use
OMV=$HOME/work/flux/omega-mv # sha2.om sha256 5cf0f981…fdb33, omc 3ad9f10f…93194
{ printf 'om2\n'; cat $OMV/om/tls/sha2.om chain/chain.om; } | $OMV/seed/out/omc > chain-bin
./chain-bin add LEDGER KIND ACTOR SUBJECT < payload # prints: OK <seq> <head>
./chain-bin verify LEDGER # prints: OK <count> <head>, or BAD line N code
./chain-bin check LEDGER SEQ < payload # exit 0 only if this is the payload record SEQ committed to
./chain-bin feed LEDGER FILE KIND ACTOR [PAGE] # one record per new complete line of FILE; then PAGE
./chain-bin page LEDGER OUT # the head as a page with the check by hand
add takes an exclusive lock, verifies the whole ledger and refuses to append to one that does not
verify. verify enforces every rule in the table above, not only the chain. Commands are matched as
whole words (add, verify, check, feed, page). Exit 0 done; 1 usage or a bad argument; 2 the ledger
does not verify; 3 read or write failed; 4 check: no such record, or the payload is not the one
committed; 5 feed: the file has fewer complete lines than were already recorded from it. BAD
codes: 1 not seven fields, or a byte that is not a tab or printable ASCII; 2 seq; 3 utc; 4 payload
digest; 5 prev; 6 line longer than 1,023 bytes; 7 last line has no line feed; 8 kind, actor or
subject breaks its rule.
page verifies the ledger and writes one HTML file: the record count, the time of the last
record, the head, and the commands from "Checking it without this program" with the public
address of the ledger. It writes nothing for a ledger that does not verify. The file has no script
and no inline style; it links /assets/tokens.css and /assets/proof.css (chain/proof.css).
It is written as OUT.tmp and renamed. feed with a fifth argument writes the same page after
its last record, so one service keeps ledger and page together. A page name, or its .tmp, that is
the ledger or (in feed) the fed file is refused with exit 1 before anything is written. A stale
OUT.tmp is removed first (the name, never what a link points to), the new one is created
exclusively, and it is removed again when writing or renaming fails.
feed is how a running log becomes a chain. It records line N of FILE with the subject
<file name> line N and the SHA-256 of the line's bytes, without its line feed, as the payload.
It resumes after the highest N already recorded for that KIND and file name, so running it again
adds only new lines; a last line with no line feed yet is left for the next run. Only the digest
enters the ledger, so a private log can be chained in public: whoever holds a line can prove it was
recorded (printf %s "$(sed -n 'Np' FILE)" | chain check LEDGER SEQ, with the line number for N,
so the line needs no quoting), and nobody can read it from the ledger.
The file name is at most 100 bytes of printable ASCII. Two files with one base name share a resume
point under one KIND, so give each its own KIND. A record another writer adds with the same kind and
a subject of the same form moves the resume point; one ledger per trusted set of writers. FILE may
not be the ledger itself, by any name: that feed would never end, so it is refused (exit 1).
add syncs its record to disk before it answers. feed syncs once, after its last record, so a
first run over a long file costs one sync, not one per line; the gate counts the syncs with
strace and fails without it.
Checking it without this program
# every record's prev is the digest of the line above it
awk 'NR>1' ledger.tsv | cut -f7 > claimed
sed '$d' ledger.tsv | while IFS= read -r line; do printf %s "$line" | sha256sum | cut -d' ' -f1; done > computed
cmp claimed computed && echo chain intact
# a payload is the one a record committed to
sha256sum < payload # equals field 6 of that record
What it proves, and what it does not
- Proved (
Ledger.lean, Lean 4, no axioms,lean chain/Ledger.lean): two valid ledgers with the same head are the same ledger, provided SHA-256 never gives one digest for two different lines. So an edit, removal, insertion or reordering anywhere changes the head. - Assumed, not proved: that nobody can find such a SHA-256 collision.
- Not proved by the chain alone: when a record was written, and who wrote the payload. A ledger kept only on one machine can be rebuilt from scratch by whoever holds it. Time and authorship come from outside: publish each new head where the publisher cannot take it back (for example a signed commit copied to machines other people run), and the record existed no later than that. A model vendor does not sign what its model says, so "this model wrote this text" needs a witness of the vendor connection; that is a later unit, not claimed here.
Service (after merge)
infra/spark/interplane-chain.service chains the hive's message board, ~/handoffs/BOARD.md,
one record per line, into ~/forge-data/proof/board.tsv, and rewrites the page
~/forge-data/proof/index.html after each run. It runs when the folder changes (inotify through
aien-onchange, at most once a minute), not on a clock. Only digests enter the ledger.
mkdir -p ~/.local/share/interplane-chain ~/forge-data/proof
{ printf 'om2\n'; cat $OMV/om/tls/sha2.om chain/chain.om; } | $OMV/seed/out/omc > ~/.local/share/interplane-chain/chain
chmod 755 ~/.local/share/interplane-chain/chain
cp chain/proof.css ~/forge-data/proof/
cp infra/spark/interplane-chain.service ~/.config/systemd/user/
systemctl --user daemon-reload && systemctl --user enable --now interplane-chain.service
Undo: systemctl --user disable --now interplane-chain.service. The ledger file stays; it is
append-only by intent. On a copy of the board of 2026-11-09 (3,294 lines) the first feed took
0.04 s and wrote 3,294 records that verify accepts; a second run added none.
Gate
sh chain/tests/run.sh # prints RESULT pass=<count> fail=0 when every case holds
The oracle is sha256sum, never the program under test: every prev, every payload digest
(text, empty, 5 MiB of random bytes) and the head are recomputed with it. Seven kinds of damage are
each refused with the expected line and code (an edited record, a removed one, two swapped, a
forged one with a stale prev, a cut-off last line, record 1 not on GENESIS, a non-hex digest); a
damaged ledger cannot be appended to; twenty writers at once leave one valid chain. Nineteen
hand-made ledgers, relinked with sha256sum, each break one field rule (seq with a leading zero,
an earlier time, an impossible date or time such as 2100-02-29, April 31, month 00, day 00, hour 24,
minute or second 60, a bad kind, an over-long actor or subject, a DEL, carriage return or non-ASCII
byte) and are refused with the expected code; two leap days (2024, 2400) and the longest allowed
fields are accepted. add on a ledger whose last record is later than the clock is refused and
writes nothing. A command that only starts like add or verify, or has a byte after add,
verify or check, is refused and writes nothing. feed is checked against sha256sum line by
line (an empty line, a line with a tab, a 200,000-byte line of arbitrary bytes), for leaving an
unfinished line, for adding nothing when run again, for resuming only on its own kind and exact file
name, for exit 5 with nothing written when the file lost lines, for refusing the ledger itself as
the file (by its name and through a link), and for its argument rules. page is checked on a
ledger of 1,234 records: its head and count against sha256sum and wc, and then the commands
are taken out of the page itself, entity-decoded and run: the head command gives the page's head,
the link check prints chain intact, and on a copy with one edited record it does not; the
"prove one message" command, run on a board line holding a quote, an apostrophe, parentheses and a
dollar sign, gives that line's SHA-256; the page ends with </html> and its line feed. (A page
that would pass the 16,383-byte page buffer is refused with exit 3, never cut short; today's page
is under 3,000 bytes, so the gate does not reach that case.) A damaged
ledger gets exit 2 and no page; an empty one says so. A page named as the ledger, as the ledger's
name plus .tmp, or (in feed) as the fed file is refused and leaves both unchanged; a stale
OUT.tmp link is not written through; a failed rename leaves no OUT.tmp.
Negative controls: a mutant that skips the prev check accepts the edited ledger; a mutant that
forgets what was recorded records lines twice; a mutant without the lost-lines rule exits 0; a
mutant without the verify rule writes a page for a damaged ledger; a mutant without the name guard
replaces its own ledger with the page. The
gate refuses any compiler or sha2.om other than the pins (exit 2).
Not done
- The ledger and its page are not served from interplane.io yet: the files exist under
~/forge-data/proof/, the forged routes (/proof,/proof/board.tsv,/assets/proof.css) do not. - No outside time anchor yet: publishing each head where it cannot be taken back is a later unit.
- A ledger line is at most 1,023 bytes.