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

Refusals are answered as the caller's, and failures as the host's

Merged
Merged chadtmiller.com asked to merge into main from chadtmiller.com/group-host:host/error-answers

What changes

A directory's refusal is the caller's, not a 500. Directory::publish now fails with a Refused carrying the directory's status and words, and plc::not_published answers a 4xx refusal as 400 InvalidOperation and anything else (a 5xx, no answer) as the host's 500. migrateComplete, addRecoveryKey, removeRecoveryKey and updateGroupHandle answer through it, as completeImport already answered such refusals; the three lexicons that list their errors list InvalidOperation. Fixes at://did:plc:bcgltzqazw5tb6k2g3ttenbj/space/dev.knotless.space/group-host/did:plc:bcgltzqazw5tb6k2g3ttenbj/dev.knotless.issue/3mzjdedoj46nl

Two changes to a group's DID at once both land. The directory holds a turn, taken from reading a DID's last operation until the next is published, by the recovery key methods, updateGroupHandle and migrateComplete. Two addRecoveryKey calls at once now both succeed one after the other, where the second was refused as a fork and answered 500. A refusal that still comes (a steward changing the document meanwhile) is InvalidOperation, as above. Fixes at://did:plc:bcgltzqazw5tb6k2g3ttenbj/space/dev.knotless.space/group-host/did:plc:bcgltzqazw5tb6k2g3ttenbj/dev.knotless.issue/3mzjdfi6ljoi5

A key change once the host holds no key is NotController, whatever the key. The check moved from signing to right after the keys are read, so TooManyKeys, AlreadyAdded, HostKey and UnknownKey no longer come first, as recovery.md says. Fixes at://did:plc:bcgltzqazw5tb6k2g3ttenbj/space/dev.knotless.space/group-host/did:plc:bcgltzqazw5tb6k2g3ttenbj/dev.knotless.issue/3mzjdfgoom6fu

migrateReceive says what the source's getRepo answered. getRepo goes through the same request as the export's parts (ask_source), so a 404 or 500 is SourceUnreadable "…getRepo answered 404 Not Found", not "a repo that is not the group's". Fixes at://did:plc:bcgltzqazw5tb6k2g3ttenbj/space/dev.knotless.space/group-host/did:plc:bcgltzqazw5tb6k2g3ttenbj/dev.knotless.issue/3mzjdef2valpv

listRepos gives a cursor only on a full page, as listRecords does. Fixes at://did:plc:bcgltzqazw5tb6k2g3ttenbj/space/dev.knotless.space/group-host/did:plc:bcgltzqazw5tb6k2g3ttenbj/dev.knotless.issue/3mzjdfjdmzskg

An MCP body that is not JSON is a parse error: HTTP 400 with JSON-RPC -32700 and a null id, as MCP's HTTP transport allows; JSON that is not a message is still -32600. Fixes at://did:plc:bcgltzqazw5tb6k2g3ttenbj/space/dev.knotless.space/group-host/did:plc:bcgltzqazw5tb6k2g3ttenbj/dev.knotless.issue/3mzjdftrwr6ol

Each report has its own id. Store::moderate returns the event's seq, and createReport answers it as id in place of the time. Fixes at://did:plc:bcgltzqazw5tb6k2g3ttenbj/space/dev.knotless.space/group-host/did:plc:bcgltzqazw5tb6k2g3ttenbj/dev.knotless.issue/3mzjdemxgwu5p

An unreadable describeServer keeps no handle. Bringing an account here fails closed: when its server cannot say which domains it gives out, the handle is not kept as the account's own, and it gets its address here. Fixes at://did:plc:bcgltzqazw5tb6k2g3ttenbj/space/dev.knotless.space/group-host/did:plc:bcgltzqazw5tb6k2g3ttenbj/dev.knotless.issue/3mzjdege732sc

move-host goes on past an account the directory fails on. Such an account is Moved::Failed(why), printed as "<handle>: not repointed: <why>", the rest are repointed, and the command exits with an error naming how many were not. move_host answers a Report of its lines and that count. Fixes at://did:plc:bcgltzqazw5tb6k2g3ttenbj/space/dev.knotless.space/group-host/did:plc:bcgltzqazw5tb6k2g3ttenbj/dev.knotless.issue/3mzjdeho4jvul

docs/design/recovery.md, docs/design/moving.md, docs/reference/mcp.md and docs/reference/cli.md say each of these.

How it was checked

New or extended tests, each failing before its fix:

  • migration::hands_over_only_what_names_the_destination: credentials with a key the directory cannot read are 400 InvalidOperation. The test directory now checks rotation keys as PLC does (at most five, each a key it can read).
  • recovery::makes_two_changes_at_once_one_after_the_other: two addRecoveryKey calls joined, with the test directory slowing reads of the last operation so both read before either writes; both answer 200 and both keys are on the document. Without the turn, the second is refused.
  • recovery::changes_nothing_once_the_host_holds_no_key: AlreadyAdded, HostKey, UnknownKey and TooManyKeys cases all answer NotController.
  • recovery::says_whose_trouble_an_operation_not_published_is: a 4xx refusal, a 5xx, and no answer at all.
  • migration::takes_in_nothing_it_cannot_check: a getRepo answering 404.
  • authority::keeps_the_writers_repo_hosts_tell_it_of: no cursor on a short page.
  • assistants::says_what_it_cannot_do_as_json_rpc_does: a body that does not parse.
  • moderation::takes_a_report_from_anyone: two reports, consecutive ids.
  • import::keeps_no_handle_of_a_server_that_cannot_say_whose_it_is.
  • move_host::moves_the_rest_past_an_account_the_directory_fails_on, through group_host::run too.

Ran locally: every test of group-host and group-host-mcp (interop with the reference PDS included), cargo fmt --check, clippy with warnings denied, node harness/lexicons.mjs, node harness/docs.mjs. The coverage gate is left to CI.

Shortcomings

  • The turn is one for the whole host, not one per DID. These changes are rare and short, so that is simpler than a lock per group. Tombstoning a deleted group and completeImport do not take it: they make the last change a DID has here.
  • A failed last_op read (the directory down) is still a 500 in these methods, as the issue's main point was the publish refusal.

🤖 Generated with Claude Code

Approved

This pull turns directory refusals into a 400 InvalidOperation. It adds a host-wide turn for DID changes, moves the NotController check to right after the keys are read, and makes the smaller fixes listed in the body. I read the plc, recovery and migration diffs and the MCP change. I did not read the rest of the diff (handle, listRepos, createReport, move-host, docs and tests), and I did not run the tests or look at the checks.

  • not_published: downcast_ref::<Refused>() still finds the error under .context(...), since anyhow downcasts through context wrappers. The 4xx and non-4xx split reads correctly.
  • The turn: each guard is taken before last_op/rotation_keys and held until publish, and early returns release it on drop. In add_recovery_key and remove_recovery_key the guard is declared before the early refused(...) returns, so it is held through them. That is harmless.
  • NotController: it now comes before the other checks, which matches what recovery.md says.

The shortcomings you list (one turn for the whole host, and last_op read failures still a 500) are reasonable for rare, short operations.

Merged as 8518915