fix(pds): include cid on applyWrites create/update results#181
Merged
Conversation
The lexicon marks `cid` as required on createResult and updateResult, but the PDS was reading it from the post-commit MST. A record that was created then deleted within the same batch leaves no MST entry, so the field was missing. Precompute via cidForRecord(op.record), matching reference PDS behaviour. Also relaxes pdscheck's commit-ops-have-prev check: a delete or update whose path was also created earlier in the same #commit has no prev (the record didn't exist before the commit), and reference PDS doesn't emit one. The check now exempts those ops instead of flagging them.
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
pdscheck | 191ef18 | May 24 2026, 08:32 PM |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
cirrusdocs | 191ef18 | Commit Preview URL Branch Preview URL |
May 24 2026, 08:32 PM |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
atproto-pds | 191ef18 | May 24 2026, 08:32 PM |
commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two related fixes surfaced by the latest pdscheck run against pds.mk.gg, both stemming from PR #176 (accept create+delete on the same rkey).
Bug 1 —
createResult.cidmissingThe lexicon (com.atproto.repo.applyWrites#createResult) marks
cidas required, but Cirrus was reading it fromupdatedRepo.data.get(dataKey)after applying the commit. For a record that was created then deleted within the same batch, the MST has no entry, sorecordCidwas undefined and the field was omitted from the response.Fix: precompute the create/update record's CID via
@atproto/repo'scidForRecord(op.record)before formatting the commit. The function encodes the record to DAG-CBOR and hashes deterministically — same algorithm the MST uses internally. This matches reference PDS behaviour (packages/pds/src/repo/prepare.ts:217:cid: await cidForCbor(encode(record))).Bug 2 — pdscheck flags delete ops with no prev
Sync 1.1 requires
prevon update/delete ops in the firehose. For a[create(K), delete(K)]batch, the delete has no prev because the record didn't exist pre-commit. Reference PDS readsprevfrom a pre-batch query (actor-store/repo/transactor.ts:125), so it also omits prev in this case.Fix: pdscheck's
firehose.commit-ops-have-prevcheck now exempts an update/delete op whose path was also created earlier in the same#commit. No change to Cirrus's firehose payload — its existing behaviour was already aligned with the reference.Test plan
pnpm --filter @getcirrus/pds test— 313 unit + 84 CLI passing, including a strengthened assertion in the existing create+delete-same-rkey test thatcidanduriare present oncreateResult.pnpm --filter @getcirrus/pds check— clean.apps/checktypechecks.repo-write.apply-writes.validatesandfirehose.commit-ops-have-prevto pass.