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
58 lines
2.7 KiB
Python
58 lines
2.7 KiB
Python
"""Mastodon 4.7: accounts and tokens made in one `rails runner` (it has no password grant, and tootctl boots Rails once
|
|
per account), objects read from its Postgres database (`mastodon`)."""
|
|
import json
|
|
|
|
from core import podman
|
|
from dialects.base import Stored
|
|
from dialects.mastodon_api import MastodonApi
|
|
|
|
VIS = {0: "public", 1: "unlisted", 2: "followers", 3: "direct", 4: "limited"}
|
|
|
|
PROVISION = r'''
|
|
app = Doorkeeper::Application.find_or_create_by!(name: "pasture-town") { |a| a.redirect_uri = "urn:ietf:wg:oauth:2.0:oob"; a.scopes = "read write follow" }
|
|
out = {}
|
|
JSON.parse(STDIN.read).each do |u|
|
|
account = Account.find_local(u["username"])
|
|
if account.nil?
|
|
account = Account.new(username: u["username"])
|
|
user = User.new(email: "#{u["username"]}@mastodon.test", password: u["password"], agreement: true, approved: true,
|
|
confirmed_at: Time.now.utc, account: account)
|
|
user.save!
|
|
account.reload
|
|
end
|
|
account.user.approve! unless account.user.approved?
|
|
account.user.confirm unless account.user.confirmed?
|
|
token = Doorkeeper::AccessToken.find_or_create_for(application: app, resource_owner: account.user, scopes: Doorkeeper::OAuth::Scopes.from_string("read write follow"), expires_in: nil, use_refresh_token: false)
|
|
out[u["username"]] = token.token
|
|
end
|
|
puts "TOWN" + out.to_json
|
|
'''
|
|
|
|
|
|
class Mastodon(MastodonApi):
|
|
platform = "mastodon"
|
|
caps = MastodonApi.caps | {"quote"}
|
|
|
|
def provision(self, accounts):
|
|
payload = json.dumps([{"username": a.username, "password": a.password} for a in accounts])
|
|
out = podman.exec_("pasture-mastodon", "bin/rails", "runner", PROVISION, input=payload, timeout=600)
|
|
tokens = json.loads(next(line[4:] for line in out.splitlines() if line.startswith("TOWN")))
|
|
return [self.session_from_token(a, tokens[a.username]) for a in accounts]
|
|
|
|
def _rows(self, uris):
|
|
if not uris:
|
|
return {}
|
|
rows = podman.psql("mastodon", """
|
|
select s.id::text as local_id, s.uri, s.deleted_at is not null as deleted, s.visibility, s.text,
|
|
s.spoiler_text as cw, s.edited_at is not null as edited, p.uri as parent_uri,
|
|
coalesce(st.favourites_count, 0) as likes, coalesce(st.reblogs_count, 0) as boosts,
|
|
coalesce(st.replies_count, 0) as replies, pl.cached_tallies as votes
|
|
from statuses s
|
|
left join statuses p on p.id = s.in_reply_to_id
|
|
left join status_stats st on st.status_id = s.id
|
|
left join polls pl on pl.status_id = s.id
|
|
where s.reblog_of_id is null and s.uri = any(string_to_array(:'p1', ' '))""", " ".join(uris))
|
|
return {r["uri"]: Stored(True, r["deleted"], r["local_id"], VIS.get(r["visibility"]), r["text"], r["cw"] or None,
|
|
r["edited"], r["parent_uri"], r["likes"], r["boosts"], r["replies"], r["votes"], None, r)
|
|
for r in rows}
|