The town: a fake community across the pasture, checked for coherence
tools/pasture/town/ (run through tools/pasture/town.sh) seeds a fake community across every running peer and checks that all of them, and PrivaPub, agree on what happened: - drivers per platform on four dialect bases (Mastodon API, Misskey API, Lemmy API, PrivaPub with /clientapi), each with a selftest against its own server; what a server holds is read from its database, never by making it fetch; - a deterministic generator (specs/village.json: 23 accounts on seven servers, roots with several personas, circles and communities, a cross-server follow graph, posts of every kind and visibility, reply rounds, likes, boosts, reactions, votes, edits, deletes, blocks, mutes and a report) and a seeder that keeps a ledger of what happened; - a sweep that expects delivery and confinement per server, what each account sees, counts, threads, edits, deletes, follows and privacy rows (sibling keys, published days, canary root credentials in every peer's database, located posts that never leave), with what the peers do on purpose modelled (Misskey drops orphan replies, Lemmy keeps only community content, edits go to the post's own audience); - known gaps (gaps.json) turn failures into xfail and passes into xpass; a self-contained report.html, and docs/INTEROP-BACKLOG.md. The pasture moves to a public-looking subnet (peers with no private address switch can join), takes PASTURE_PORT when 6971 is in use, adds peers to a running pasture (run.sh add, Caddy recreated with its CA kept), removes its volumes on down, writes every scenario check to out/scenarios.jsonl, serves decePub as decepub.test for its e2e tests, lifts GoToSocial's and Lemmy's own rate limits, trusts Caddy in Mastodon (TRUSTED_PROXY_IP) and gains Hollo (Fedify), whose one login owning several accounts is the nearest peer to PrivaPub's personas. The first village found the four PrivaPub bugs fixed in the commits before this one; the second run, on the fixed server, passes 2319 checks with 11 failures left, all between peers or from Lemmy's send worker, which the seeder now warms up first. ROADMAP records the owner's decisions of 2026-10-04 (the town, and P9 back from the cut list). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LsXgEaXee4GCU1hwYgPJXw
This commit is contained in:
1 parent
d6131af289
commit
2873344690
46 files changed
+4400
-24
No files matched your search
@@ -0,0 +1,93 @@
|
||||
"""A seeded random generator that is the same on every Python: xoshiro256** seeded through splitmix64 from a SHA-256
|
||||
of the seed and a name. `sub(name)` gives an independent stream, so changing how many posts are drawn never reshuffles
|
||||
the follow graph."""
|
||||
import hashlib
|
||||
|
||||
MASK = (1 << 64) - 1
|
||||
|
||||
|
||||
def _rotl(x, k):
|
||||
return ((x << k) | (x >> (64 - k))) & MASK
|
||||
|
||||
|
||||
def _splitmix(state):
|
||||
while True:
|
||||
state = (state + 0x9E3779B97F4A7C15) & MASK
|
||||
z = state
|
||||
z = ((z ^ (z >> 30)) * 0xBF58476D1CE4E5B9) & MASK
|
||||
z = ((z ^ (z >> 27)) * 0x94D049BB133111EB) & MASK
|
||||
yield z ^ (z >> 31)
|
||||
|
||||
|
||||
class Rng:
|
||||
def __init__(self, seed, name="root"):
|
||||
self.seed = seed
|
||||
self.name = name
|
||||
digest = hashlib.sha256(f"{seed}/{name}".encode()).digest()
|
||||
mix = _splitmix(int.from_bytes(digest[:8], "little"))
|
||||
self.s = [next(mix) for _ in range(4)]
|
||||
|
||||
def sub(self, name):
|
||||
return Rng(self.seed, f"{self.name}/{name}")
|
||||
|
||||
def next64(self):
|
||||
s = self.s
|
||||
result = (_rotl((s[1] * 5) & MASK, 7) * 9) & MASK
|
||||
t = (s[1] << 17) & MASK
|
||||
s[2] ^= s[0]
|
||||
s[3] ^= s[1]
|
||||
s[1] ^= s[2]
|
||||
s[0] ^= s[3]
|
||||
s[2] ^= t
|
||||
s[3] = _rotl(s[3], 45)
|
||||
return result
|
||||
|
||||
def random(self):
|
||||
return (self.next64() >> 11) / float(1 << 53)
|
||||
|
||||
def below(self, n):
|
||||
"""An integer in [0, n)."""
|
||||
if n <= 0:
|
||||
raise ValueError("below() needs n > 0")
|
||||
limit = MASK - (MASK % n)
|
||||
while True:
|
||||
x = self.next64()
|
||||
if x < limit:
|
||||
return x % n
|
||||
|
||||
def between(self, lo, hi):
|
||||
"""An integer in [lo, hi]."""
|
||||
return lo + self.below(hi - lo + 1)
|
||||
|
||||
def chance(self, p):
|
||||
return self.random() < p
|
||||
|
||||
def choice(self, seq):
|
||||
return seq[self.below(len(seq))]
|
||||
|
||||
def weighted(self, weights):
|
||||
"""A key of {key: weight}, keys taken in sorted order so the draw does not depend on dict order."""
|
||||
keys = sorted(k for k, w in weights.items() if w > 0)
|
||||
total = sum(weights[k] for k in keys)
|
||||
x = self.random() * total
|
||||
for k in keys:
|
||||
x -= weights[k]
|
||||
if x < 0:
|
||||
return k
|
||||
return keys[-1]
|
||||
|
||||
def shuffle(self, items):
|
||||
items = list(items)
|
||||
for i in range(len(items) - 1, 0, -1):
|
||||
j = self.below(i + 1)
|
||||
items[i], items[j] = items[j], items[i]
|
||||
return items
|
||||
|
||||
def sample(self, seq, k):
|
||||
return self.shuffle(seq)[:max(0, min(k, len(seq)))]
|
||||
|
||||
def span(self, pair):
|
||||
"""A value drawn from [lo, hi] given as a two-item list, or the value itself."""
|
||||
if isinstance(pair, (list, tuple)):
|
||||
return self.between(pair[0], pair[1])
|
||||
return pair
|
||||
Reference in new issue
Block a user