~ knotless Search/
↑↓ move↵ open⇧↵ all results
0
0

Spec and check what a build from scratch found the spec left open

Merged
Merged chadtmiller.com asked to merge into main from chadtmiller.com/monolith:spec-gaps

An agent rebuilt the whole server from spec/ alone, from an empty crates/ with no history, and passed just gates in 25 minutes. Its list of where the spec was silent is now spec, each answer taken from the reference PDS, and each one is a harness check against the reference.

Spec (SLICE.md). What the reference does, now written down:

  • A write checks its token, then its input, then its repo, then the record's $type. No token is 401 AuthMissing (SLICE said AuthenticationRequired, which was wrong). A token never given out is 400 InvalidToken, whatever the input. A repo that isn't the account is 403 AccountNotFound.
  • describeRepo, getRepo and getLatestCommit of a DID the server doesn't hold are 400 RepoNotFound.
  • The other HTTP method, a query by POST or a procedure by GET, is 400 InvalidRequest.
  • validate: true is 400 InvalidRequest, since the server has no lexicon for any record type. validate: false writes, with no validationStatus in the answer.
  • getRepo since: the latest commit, plus the blocks of the current tree written since that rev. A record replaced or deleted since is not included, which a first wording got wrong. A since that isn't a TID is 400.
  • A firehose cursor that isn't an integer gets an InvalidRequest frame, then the stream closes.
  • A no-op putRecord also answers validationStatus.
  • The firehose blocks are defined by what is checked: every op proved against the commit, and the ops undone back to prevData.
  • DIDs and handles are as atproto/did.md and atproto/handle.md define them; both are newly vendored.

COMMANDS.md: a nullable argument's schema type is [type, "null"].

Harness.

  • A new oddRequests step covers every case above against the reference: writes with no token or a bogus one, with good or bad input; a write to another repo; unknown DIDs; the other HTTP method; validate.
  • getRepo since is checked in the repository check: the root, the record blocks, and no blocks at the head.
  • The firehose check now tries a non-integer cursor.
  • Tool schemas are checked for nullable types.
  • AccountNotFound is mapped for tool errors.

The checks bite. Two independent servers fail them:

  • The server before this pull fails at seed 1 step 19 (AuthenticationRequired).
  • The regenerated server fails on all five seeds, one for each new case, including since returning a replaced record.

Three of my own guesses were wrong and got caught here: since at first, the place of the repo check, and the place of the $type check. Each came from a random run on the reference.

Server:

  • check order in dispatch, check_account, typed;
  • validate;
  • car_since, with the rev that added each block, logged so it survives restarts;
  • nullable schemas in pds-lexicon.

Docs:

  • README: where the byte-cut tests live.
  • AGENTS.md: how a from-scratch build is run, and how its gaps become spec.

Checked: just gates: all 15 harness runs and the crates' tests pass, in 223s.

🤖 Generated with Claude Code

Approved

This pull writes down what the reference does where the spec was silent. It reorders the write checks (token, then input, then repo, then $type), adds RepoNotFound, wrong-HTTP-method, validate and getRepo since, and makes nullable tool schemas [type, "null"]. Each change is in SLICE.md or COMMANDS.md and has a harness check against the reference (oddRequests, checkSince, the cursor abc case, the nullable schema comparison). I read all ten files. The server code matches the spec text, and the held bookkeeping in pds-repo is logged as added, so it survives a restart (the new since_survives_restart test covers that). The harness changes only add or tighten checks, and nothing in the pull touches conformance.yaml. It adds no crates, and I saw no use of reference or SDK source. I did not run the gates.

One gap that does not block the merge: SLICE.md says getRepo since holds "the records and MST nodes of the current tree written since", but checkSince compares only the records (blocks with a $type) and the root. It checks the node count only for the latest rev, where it must be 0. A server that left out the changed MST nodes would pass. Compare the non-record block count against the reference, or narrow the spec sentence to what is checked.

harness/compare.mjsline 1191
if (oursSince.root !== ourRoot) await differ('com.atproto.sync.getRepo', request, `the latest commit, ${ourRoot}, as root`, oursSince.root)
if (theirsSince.root !== theirRoot) throw new Error(`the reference's getRepo since has root ${theirsSince.root}, not ${theirRoot}`)
if (which === 'latest' && oursSince.blocks !== 0) await differ('com.atproto.sync.getRepo', request, 'no blocks', `${oursSince.blocks} blocks`)
if (!isDeepStrictEqual(theirsSince.records, oursSince.records)) await differ('com.atproto.sync.getRepo', request, { records: theirsSince.records }, { records: oursSince.records }, 'the records written since')
review.knotless.dev

Only records are compared. The spec also puts the MST nodes written since in this CAR, and nothing here checks them. Compare the count of non-record blocks too, or say in SLICE.md that the nodes are the server's choice, as is done for the firehose.

Merged as ff17bf3