Until now every receive path recorded the SENDER in `file_holders`, and
those rows went straight back out on the wire to third parties as
`cdn_redirect_peers`, as worm holder answers, and as HTTP 302 targets.
Exchanging bytes with a peer enrolled its node id -- and its addresses --
into a list we republished to anyone who asked.
Two things follow, and both matter. The concealment model the erasure
work depends on ("hold k shards quietly, announce exactly one slot") is
impossible on an inferred foundation: acquiring a shard registers you as
its holder whether you consented or not. And an enumerator never had to
hold anything -- it just asked holders who else holds.
`file_holders` rows now split two ways:
* local hint (`declared = 0`) -- "we exchanged bytes about this file
with that peer". Drives fetch retry, diff-propagation targets and
manifest refresh. Never published as a holder of a specific file.
* declaration (`declared = 1`) -- the peer told us "I hold this and you
may advertise me for it" (0xD3). The only holder list that may leave
the node.
All 12 inference sites were triaged into hints with a per-site reason
rather than deleted. 0xD3 became the declaration handler and is validated
hard, since it is now the only unauthenticated input reaching an outbound
holder surface: 16 KB read ceiling (was MAX_PAYLOAD, 64 MB), reject rather
than truncate oversized batches, a `tracks_file` gate so a stranger cannot
mint rows for arbitrary 32-byte ids, a per-peer token bucket and row
budget, and normalised publicly-routable addresses capped at 4. An
introducer nominee must be a known anchor -- otherwise a peer could make
us publish an arbitrary victim's address.
Declarations are soft state: a rotating per-peer sweep rides each
content-sync cycle and `DECLARATION_TTL_MS` (30d) ages out a holder that
goes quiet, so a peer that wipes its database re-learns them.
Durability decisions count EVIDENCE, never claims. A new `witnessed`
column records transport events we handled ourselves, independent of
`declared` because a peer can be both; keying the count on `declared = 0`
instead dropped every honest custodian that declared out of its author's
durability count, making the post look less durable and provoking
replication it did not need. Gating replication on claims would also let
five Sybil identities declare a post and silently stop its author
replicating it -- the data-availability attack the erasure study rules
against.
Alpha policy defaults are deliberately generous (both classes declare,
per-author cap off) because a tight cap makes content unfindable and
there is no spare holder population yet. Own-authored content is never
declared by default: it publishes device <-> posting identity, the
binding the manifest address strip exists to prevent. Non-public content
is never declared at all, at a single chokepoint. Policy changes are
retroactive, so the open alpha shape is transitional.
Known limit, documented in `holdings.rs` and design.html: this hides
WHICH and HOW MANY of an author's posts you hold, not THAT you hold some
of that author's content -- `build_own_uniques` still announces every
distinct author, deliberately interest-blind-but-complete so discovery
works. The one-shard-announcement property holds at file granularity
only; closing the author-level surface is a discovery trade Round 10 has
not ruled on.
Wire format (clean break, zero users): drops
`BlobRequestPayload.requester_addresses`, `BlobResponsePayload`'s
`cdn_registered`, and `CdnManifest.host` -- the last rode every blob
response and was relayed verbatim, so a third party learned "node A holds
this CID" with no declaration from A. ALPN is NOT bumped here; see the PR.
301 core tests (was 267), a3 23/23 (12 pre-existing + 11 new behavioural
assertions), c_topology 33/33 unchanged. Policy knobs reachable from the
desktop app, not CLI-only.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LGiPD2cF75mnvneSCjdDC5
285 lines
13 KiB
Bash
Executable file
285 lines
13 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# v0.8 A3 integration test — registry + greetings across 3 local nodes.
|
|
#
|
|
# Spec: A3-SPEC §6 multi-node scenario. Run from the repo root after
|
|
# `cargo build -p itsgoin-cli`. Uses FIFOs to drive the interactive REPL.
|
|
#
|
|
# 1. All nodes self-materialize the same registry post ID; node1 also
|
|
# runs the --publish-registry genesis one-shot (debug gate override).
|
|
# 2. node2 registers "Alice rust p2p" → node3 `search rust` finds her.
|
|
# node2 `unregister` → node3 re-search finds nothing.
|
|
# 3. node2's bio has a greeting slot; node3 greets it; node2 sees the
|
|
# unsealed text + real sender persona; node2 replies; node3 sees the
|
|
# reply. node1 (holder) stores only ciphertext.
|
|
# 5. Newest-wins: node2 re-registers; node3 sees exactly one entry.
|
|
# 6. Retention taxonomy (per-post policy x signing class): every comment
|
|
# on the registry post carries the post's FLAT 30d policy — including
|
|
# on holders that never registered — while greetings on a bio's open
|
|
# slot carry the randomized 30-365d stranger TTL. Asserted against
|
|
# each node's DB, so it also covers the debug ITSGOIN_TEST_TTL_SECS
|
|
# hook staying scoped to randomized windows (a flat policy must keep
|
|
# its exact 30 days, or the registry auto-renew loop never settles).
|
|
#
|
|
# Exit code 0 = all checks passed. Logs: /tmp/itsgoin-cli{1,2,3}.log
|
|
set -u
|
|
cd "$(dirname "$0")/.."
|
|
BIN=target/debug/itsgoin
|
|
[ -x "$BIN" ] || { echo "build first: cargo build -p itsgoin-cli"; exit 2; }
|
|
|
|
PASS=0; FAIL=0
|
|
check() { # check <desc> <cmd...>
|
|
local desc="$1"; shift
|
|
if "$@" >/dev/null 2>&1; then PASS=$((PASS+1)); echo "PASS: $desc";
|
|
else FAIL=$((FAIL+1)); echo "FAIL: $desc"; fi
|
|
}
|
|
strip_ansi() { sed 's/\x1b\[[0-9;]*m//g' "$1" | grep -v "WARN.*netlink\|WARN.*buffer_tool"; }
|
|
# Same noise filter for the tail-window checks below. The netlink/mDNS watcher
|
|
# logs in unpredictable bursts, and a burst landing between a REPL command and
|
|
# its assertion pushes the answer out of a raw `tail -N` window — a false
|
|
# failure with nothing wrong in the node.
|
|
quiet_tail() { grep -av "netlink\|buffer_tool\|iroh_quinn\|swarm_discovery" "$1" | tail -"$2"; }
|
|
export -f quiet_tail
|
|
sq() { sqlite3 "/tmp/itsgoin-test$1/itsgoin.db" "$2"; }
|
|
|
|
cleanup() {
|
|
{ exec 13>&- 14>&- 15>&-; } 2>/dev/null || true
|
|
kill $(pgrep -f 'itsgoin.*itsgoin-test') 2>/dev/null
|
|
rm -f /tmp/itsgoin-cmd{1,2,3}
|
|
}
|
|
trap cleanup EXIT
|
|
|
|
echo "== setup =="
|
|
kill $(pgrep -f 'itsgoin.*itsgoin-test') 2>/dev/null; sleep 1
|
|
for i in 1 2 3; do
|
|
rm -rf /tmp/itsgoin-test$i /tmp/itsgoin-cmd$i /tmp/itsgoin-cli$i.log
|
|
mkdir -p /tmp/itsgoin-test$i
|
|
mkfifo /tmp/itsgoin-cmd$i
|
|
done
|
|
|
|
export ITSGOIN_TEST_ALLOW_REGISTRY_GENESIS=1
|
|
|
|
# Genesis one-shot on node1's data dir (debug-gate override).
|
|
"$BIN" /tmp/itsgoin-test1 --bind 127.0.0.1:18411 --publish-registry > /tmp/itsgoin-genesis.log 2>&1
|
|
check "genesis prints registry post id matching shipped constant" \
|
|
bash -c 'g=$(grep registry_post_id /tmp/itsgoin-genesis.log | awk "{print \$2}");
|
|
c=$(grep shipped_constant /tmp/itsgoin-genesis.log | awk "{print \$2}");
|
|
[ -n "$g" ] && [ "$g" = "$c" ]'
|
|
|
|
# Start the three nodes with FIFO-driven stdin.
|
|
for i in 1 2 3; do
|
|
( exec "$BIN" /tmp/itsgoin-test$i --bind 127.0.0.1:1841$i \
|
|
< /tmp/itsgoin-cmd$i > /tmp/itsgoin-cli$i.log 2>&1 ) &
|
|
done
|
|
# Keep FIFO write ends open for the whole run.
|
|
exec 13>/tmp/itsgoin-cmd1 14>/tmp/itsgoin-cmd2 15>/tmp/itsgoin-cmd3
|
|
sleep 6
|
|
|
|
n1_id=$(strip_ansi /tmp/itsgoin-cli1.log | grep -m1 "Node ID:" | awk '{print $3}')
|
|
n2_id=$(strip_ansi /tmp/itsgoin-cli2.log | grep -m1 "Node ID:" | awk '{print $3}')
|
|
echo "node1=$n1_id node2=$n2_id"
|
|
check "all nodes self-materialized the registry post" \
|
|
bash -c 'for i in 1 2 3; do sqlite3 /tmp/itsgoin-test$i/itsgoin.db \
|
|
"SELECT count(*) FROM posts WHERE hex(id) = upper(\"'"$(grep shipped_constant /tmp/itsgoin-genesis.log | awk '{print $2}')"'\")" \
|
|
| grep -q 1 || exit 1; done'
|
|
|
|
echo "== mesh: 2,3 -> 1; 3 -> 2 =="
|
|
echo "connect $n1_id@127.0.0.1:18411" >&14
|
|
echo "connect $n1_id@127.0.0.1:18411" >&15
|
|
sleep 4
|
|
echo "connect $n2_id@127.0.0.1:18412" >&15
|
|
sleep 4
|
|
|
|
echo "== step 2: register / search / unregister =="
|
|
echo "name Alice" >&14
|
|
sleep 3
|
|
echo "register Alice rust p2p" >&14
|
|
sleep 3
|
|
echo "search rust" >&15
|
|
sleep 8
|
|
check "node3 search finds Alice" grep -q "Alice" /tmp/itsgoin-cli3.log
|
|
|
|
echo "unregister" >&14
|
|
sleep 3
|
|
echo "search rust" >&15
|
|
sleep 8
|
|
check "node3 re-search finds nothing after signed delete" \
|
|
bash -c 'quiet_tail /tmp/itsgoin-cli3.log 20 | grep -q "no registry matches"'
|
|
|
|
echo "== step 3: greeting roundtrip =="
|
|
# node2's bio post id (latest Profile post) from its DB.
|
|
bio2=$(sq 2 'SELECT lower(hex(id)) FROM posts WHERE visibility_intent = '"'"'"Profile"'"'"' ORDER BY timestamp_ms DESC LIMIT 1')
|
|
check "node2 has a bio post with a greeting slot" \
|
|
bash -c '[ -n "'"$bio2"'" ] && sqlite3 /tmp/itsgoin-test2/itsgoin.db \
|
|
"SELECT fof_gating_json FROM posts WHERE lower(hex(id))=\"'"$bio2"'\"" | grep -q Greeting'
|
|
|
|
echo "name Bob" >&15
|
|
sleep 3
|
|
echo "greet $bio2 hello alice from bob" >&15
|
|
sleep 6
|
|
echo "greetings" >&14
|
|
sleep 4
|
|
check "node2 unseals the greeting text" grep -q "hello alice from bob" /tmp/itsgoin-cli2.log
|
|
|
|
echo "reply 0 hello back bob" >&14
|
|
sleep 6
|
|
echo "greetings" >&15
|
|
sleep 4
|
|
check "node3 unseals the reply via its stored fresh reply key" \
|
|
grep -q "hello back bob" /tmp/itsgoin-cli3.log
|
|
|
|
# Holder-side opacity: node1 never sees plaintext greeting bodies.
|
|
check "node1 stores only ciphertext (no greeting plaintext in db)" \
|
|
bash -c '! sqlite3 /tmp/itsgoin-test1/itsgoin.db \
|
|
"SELECT content FROM comments" | grep -q "hello alice"'
|
|
|
|
echo "== step 5: newest-wins =="
|
|
echo "register Alice rust p2p" >&14
|
|
sleep 2
|
|
echo "register AliceV2 rust mesh" >&14
|
|
sleep 4
|
|
echo "search rust" >&15
|
|
sleep 8
|
|
check "node3 sees exactly one (newest) entry for node2's persona" \
|
|
bash -c 'quiet_tail /tmp/itsgoin-cli3.log 6 | grep -c "rust" | grep -q "^1$" &&
|
|
quiet_tail /tmp/itsgoin-cli3.log 6 | grep -q AliceV2'
|
|
|
|
echo "== step 6: retention taxonomy =="
|
|
# (parent post's comment-TTL policy) x (comment's signing class).
|
|
DAY_MS=86400000
|
|
FLAT30=$((30 * DAY_MS))
|
|
YEAR365=$((365 * DAY_MS))
|
|
reg_hex=$(grep shipped_constant /tmp/itsgoin-genesis.log | awk '{print $2}' | tr 'a-z' 'A-Z')
|
|
bio2_hex=$(echo "$bio2" | tr 'a-z' 'A-Z')
|
|
|
|
reg_total=0; reg_bad=0
|
|
for i in 1 2 3; do
|
|
reg_total=$((reg_total + $(sq $i "SELECT count(*) FROM comments WHERE hex(post_id)='$reg_hex'")))
|
|
reg_bad=$((reg_bad + $(sq $i "SELECT count(*) FROM comments WHERE hex(post_id)='$reg_hex'
|
|
AND (expires_at IS NULL OR expires_at - timestamp_ms != $FLAT30)")))
|
|
done
|
|
check "every registry-post comment carries the post's flat 30d policy" \
|
|
bash -c "[ $reg_total -gt 0 ] && [ $reg_bad -eq 0 ]"
|
|
|
|
greet_total=$(sq 2 "SELECT count(*) FROM comments WHERE hex(post_id)='$bio2_hex'")
|
|
greet_ok=$(sq 2 "SELECT count(*) FROM comments WHERE hex(post_id)='$bio2_hex'
|
|
AND expires_at IS NOT NULL
|
|
AND expires_at - timestamp_ms BETWEEN $FLAT30 AND $YEAR365")
|
|
check "greetings on the bio open slot carry the randomized 30-365d TTL" \
|
|
bash -c "[ $greet_total -gt 0 ] && [ $greet_ok -eq $greet_total ]"
|
|
|
|
over_cap=0
|
|
for i in 1 2 3; do
|
|
over_cap=$((over_cap + $(sq $i "SELECT count(*) FROM comments
|
|
WHERE expires_at IS NOT NULL AND expires_at - timestamp_ms > $((366 * DAY_MS))")))
|
|
done
|
|
check "no stored comment claims a TTL past the 366d holder ceiling" \
|
|
bash -c "[ $over_cap -eq 0 ]"
|
|
|
|
# v0.8.1 PHASE 2 — holdings are DECLARED, not inferred from transport.
|
|
#
|
|
# The scenario above is already a holder-discovery exercise: node2 and node3
|
|
# each pull the other's bio to greet it, and node1 serves the registry post to
|
|
# both. Declarations ride the content-sync cycle, so drive one explicitly
|
|
# rather than waiting for the 60s tick to land inside the run.
|
|
echo "== step 7: declared holdings =="
|
|
for fd in 13 14 15; do echo "sync" >&$fd; done
|
|
sleep 10
|
|
# Second pass: the first sweep teaches each peer our declarations; the second
|
|
# proves the sweep RECURS rather than firing only at acquisition.
|
|
for fd in 13 14 15; do echo "sync" >&$fd; done
|
|
sleep 10
|
|
|
|
# Transport events (serving posts, receiving diffs, greeting exchanges) still
|
|
# record LOCAL HINTS, which stay usable for fetch retry and diff propagation.
|
|
# Under the old inference rule every one of them wrote a PUBLISHABLE row
|
|
# instead. (node1 ends the run with publishable rows only, because serving
|
|
# content no longer writes a holder row for the requester at all - which is
|
|
# itself the property under test.)
|
|
hint_rows=0
|
|
for i in 1 2 3; do
|
|
hint_rows=$((hint_rows + $(sq $i "SELECT count(*) FROM file_holders WHERE declared=0")))
|
|
done
|
|
check "transport still records local hints (usable, never published)" \
|
|
bash -c "[ $hint_rows -gt 0 ]"
|
|
|
|
# The declaring side: nodes declare what they hold, through the policy.
|
|
d2=$(sq 2 "SELECT count(*) FROM declared_holdings")
|
|
d3=$(sq 3 "SELECT count(*) FROM declared_holdings")
|
|
check "node2 and node3 each declared a holding (explicit declaration works)" \
|
|
bash -c "[ $d2 -ge 1 ] && [ $d3 -ge 1 ]"
|
|
|
|
# Every publishable row must be attributable to a peer that actually sent us a
|
|
# 0xD3 - which, since a declaration only arrives over a live connection, means
|
|
# every declared row's peer is a peer we know.
|
|
orphan_declared=0
|
|
for i in 1 2 3; do
|
|
orphan_declared=$((orphan_declared + $(sq $i "SELECT count(*) FROM file_holders f
|
|
WHERE f.declared=1 AND f.peer_id NOT IN (SELECT node_id FROM peers)")))
|
|
done
|
|
check "every publishable holder row came from a peer that declared to us" \
|
|
bash -c "[ $orphan_declared -eq 0 ]"
|
|
|
|
# HUNT ITEM 3 - the point of the whole change: a node that wants content it
|
|
# does not hold must be able to find somebody who does. Every node declares the
|
|
# registry post (it is not its own authored content), the sweep carries that to
|
|
# its peers, so each node must be able to NAME a declared holder for it.
|
|
reg=$(grep shipped_constant /tmp/itsgoin-genesis.log | awk '{print $2}')
|
|
reg_declared=$(sq 1 "SELECT count(*) FROM file_holders WHERE declared=1 AND lower(hex(file_id))='$reg'")
|
|
check "a serving node can name a declared holder for the registry post" \
|
|
bash -c "[ $reg_declared -ge 1 ]"
|
|
|
|
# SELF-HEAL - the mechanism the migration ruling rests on. Clear a declaration
|
|
# from node1's view and show the sweep puts it back, so a peer that wipes its
|
|
# database (or evicts the row) re-learns our holdings.
|
|
victim=$(sq 1 "SELECT lower(hex(peer_id)) FROM file_holders WHERE declared=1 LIMIT 1")
|
|
sq 1 "DELETE FROM file_holders WHERE lower(hex(peer_id))='$victim' AND declared=1"
|
|
gone=$(sq 1 "SELECT count(*) FROM file_holders WHERE lower(hex(peer_id))='$victim' AND declared=1")
|
|
check "the deleted declarations are really gone before the sweep" \
|
|
bash -c "[ $gone -eq 0 ]"
|
|
for fd in 13 14 15; do echo "sync" >&$fd; done
|
|
sleep 12
|
|
healed=$(sq 1 "SELECT count(*) FROM file_holders WHERE lower(hex(peer_id))='$victim' AND declared=1")
|
|
check "a declaration self-heals after a sync cycle (re-declaration works)" \
|
|
bash -c "[ $healed -ge 1 ]"
|
|
|
|
# Round 10: addresses ride only for anchors. These are loopback test nodes with
|
|
# no anchor role, so every declaration must be a bare id.
|
|
addr_bearing=0
|
|
for i in 1 2 3; do
|
|
addr_bearing=$((addr_bearing + $(sq $i "SELECT count(*) FROM file_holders
|
|
WHERE declared=1 AND peer_addresses NOT IN ('"''"',\"[]\")")))
|
|
done
|
|
check "no non-anchor declaration carries an address (bare ids only)" \
|
|
bash -c "[ $addr_bearing -eq 0 ]"
|
|
|
|
# A declaration for a post we authored would publish device <-> persona, which
|
|
# is exactly what Iteration A's manifest address strip removed. Checked against
|
|
# the never-pruned ledger, so a rotated-out persona counts too.
|
|
own_authored=0
|
|
for i in 1 2 3; do
|
|
own_authored=$((own_authored + $(sq $i "SELECT count(*) FROM declared_holdings d
|
|
JOIN own_authored_identities p ON p.node_id = d.author")))
|
|
done
|
|
check "nobody declared content authored by one of its own personas" \
|
|
bash -c "[ $own_authored -eq 0 ]"
|
|
|
|
# Non-public content is never declared: a declaration announces audience
|
|
# membership. Greeting/DM traffic in this run gives the gate something to bite.
|
|
nonpublic=0
|
|
for i in 1 2 3; do
|
|
nonpublic=$((nonpublic + $(sq $i 'SELECT count(*) FROM declared_holdings d JOIN posts p ON p.id = d.post_id WHERE p.visibility != '\''"Public"'\''')))
|
|
done
|
|
check "no declaration covers non-public content" \
|
|
bash -c "[ $nonpublic -eq 0 ]"
|
|
|
|
# Standing assertions: the wire fields that reported/implied silent enrolment
|
|
# are gone. `cdn_registered` said "the host registered you"; `CdnManifest.host`
|
|
# said "node A holds this cid" and was relayed verbatim to third parties.
|
|
check "the cdn_registered silent-enrolment flag is gone from the tree" \
|
|
bash -c '! grep -rq "cdn_registered" --include=*.rs "$(dirname "$0")/../crates"'
|
|
check "CdnManifest no longer carries a serving-host id" \
|
|
bash -c '! grep -rq "pub host: NodeId" --include=*.rs "$(dirname "$0")/../crates"'
|
|
|
|
echo
|
|
echo "== results: $PASS passed, $FAIL failed =="
|
|
[ "$FAIL" -eq 0 ]
|