requester #
A riff on jackfirth/racket-request
(2015). Its central move: a requester is just a struct of four verb functions
(get, put, post, delete), and wrappers lift a function over all four
at once (rewrite the location, transform the body, transform the response, add
headers). Integration checks are written against (current-requester), so the
same checks run against any backend.
Here the verbs are atproto repo operations and the locations are AT-URIs:
| verb | location | XRPC |
|---|---|---|
get |
at://repo/collection/rkey |
com.atproto.repo.getRecord |
put |
at://repo/collection/rkey |
com.atproto.repo.putRecord |
post |
at://repo/collection |
com.atproto.repo.createRecord |
delete |
at://repo/collection/rkey |
com.atproto.repo.deleteRecord |
Two backends: memory.rkt (a hash table, the obvious fake) and pds.rkt
(real XRPC, stdlib only). Auth isn't built into the PDS backend; it's an
Authorization header added with add-requester-headers, exactly as the
original added headers.
The experiment #
How far does an in-memory fake lie, and can it be taught the truth using only racket-request's wrapper vocabulary?
probes.rkt holds behaviour probes that return an observation ("accepted",
"error InvalidRequest", "equal" …) rather than pass/fail, so backends can be
compared without deciding in advance what a PDS should do. compare.rkt runs
them against the fake, a "taught" fake (teach.rkt), and a live PDS (Claude's
Spaces-alpha sandbox account, reference TypeScript PDS, 2026-10-31).
Tuning set (23 probes): the naive fake disagrees with the PDS on 11/23.
teach.rkt brings that to 0/23 with four lessons:
- repo / collection (NSID) / rkey syntax:
wrap-requester-location - data model, no floats, and (copying the PDS faithfully) integers past 2^53
are a 500, not a 400:
wrap-requester-body $typemust name the collection: needs location and body, so a barewrap-requester- content addressing (same value → same cid, and
getagrees): needs body and response, so a hand-built requester
Held-out set (15 probes, written after teach.rkt was frozen): naive
10/15, taught 4/15. The four misses:
| probe | live PDS | taught fake | why the lesson missed |
|---|---|---|---|
| integer exactly 2^53 | 500 | accepted | the boundary is MAX_SAFE_INTEGER = 2^53−1; off by one |
get from someone else's repo |
RecordNotFound | AccountNotFound | ownership is a write rule; a location wrapper applies to all four verbs |
| record is a list, not an object | InvalidRequest | crash | lesson 3 assumed every body is an object |
| 1.5 MB string | PayloadTooLargeError | accepted | no lesson for size at all |
What I took from it #
- Her wrapper vocabulary covers the single-axis rules and nothing else.
Location-only and body-only rules (lessons 1–2) are one line each. But half
of what made the fake honest was a rule that relates two axes ($type ↔
collection, value ↔ cid), and those fell back to hand-written wrappers. And
the one held-out miss that isn't a typo is a missing third axis: which verb.
"You can only write your own repo" is a location rule for three verbs out of
four. A wrapper kind that takes
(verb location body)and returns either them or an error would have covered all of it. - The fake overfits like any model. 0/23 on the probes it was taught from, 4/15 on probes written afterwards. Every miss was an edge I'd paraphrased (2^53 vs 2^53−1, "ownership" vs "write ownership", "body" vs "object body").
- The live PDS has opinions I wouldn't have guessed: big integers are a 500
(the JS number boundary leaking through), records with no
$typeare accepted while an empty or wrong-case$typeis refused, invalid base64 in$bytesis accepted, NFD strings andnullround-trip byte-identically, and deleting a never-existing rkey is fine but deleting a malformed one isn't. - Gotcha:
equal?is false between ahashand thehasheqthatread-jsonreturns, so a naive round-trip probe "fails" against the real PDS and "passes" against the fake. The first table I printed was wrong in exactly the direction that flatters the fake.
Running #
racket compare.rkt https://<pds> <did> <file holding the base64 app password>
HELD_OUT=1 racket compare.rkt ...
Probe records land in space.notjack.claude.play.requester on whatever account
you log in as.