Skip to content

fix(pds): include prevData in firehose #commit events#170

Closed
simnaut wants to merge 2 commits into
ascorbic:mainfrom
simnaut:feat/firehose-prevdata
Closed

fix(pds): include prevData in firehose #commit events#170
simnaut wants to merge 2 commits into
ascorbic:mainfrom
simnaut:feat/firehose-prevdata

Conversation

@simnaut
Copy link
Copy Markdown
Contributor

@simnaut simnaut commented May 23, 2026

Closes #169

Problem

Cirrus's firehose #commit events omit the prevData field — the MST root CID of the previous commit (the data field at the since rev), which is "effectively required for the 'inductive' version of firehose" per the lexicon. Relays running strict commit validation (indigo with LenientSyncValidation off) fail verification with "missing prevData field" and reject every commit after the first, freezing the repo on that relay.

Demonstrated on two independent repos: a strict relay (relay.feeds.blue) and a lenient relay (bsky.network) read the firehose to the same cursor, yet the strict relay is frozen ~106 days while the lenient one is at head — the divergence is purely strict-vs-lenient validation of the missing field. The relay.feeds.blue operator confirmed they run standard indigo with LenientSyncValidation off.

Change

The previous commit's MST root is already in scope at every write path in account-do.ts (the repo object captured before applyWrites, alongside the existing prevRev). Populate prevData = repo.commit.data:

  • sequencer.ts: add prevData: CID to CommitData and CommitEvent; set it in sequenceCommit's payload (flows through the existing CBOR encoder).
  • account-do.ts: set prevData: repo.commit.data in the CommitData at rpcCreateRecord, rpcDeleteRecord, rpcPutRecord, rpcApplyWrites.
  • test/firehose.test.ts: new test asserting prevData is present and equals the prior commit's data CID.
  • scripts/verify-firehose.ts: add prevData to its CommitEvent interface.

Verification

  • pnpm --filter @getcirrus/pds build
  • pnpm --filter @getcirrus/pds test:unit ✅ (280 passed, incl. new prevData test)
  • pnpm knip

Related: #167 / #168 (getLatestCommit) is a separate conformance gap, not the indexing fix.

🤖 Generated with Claude Code

prevData is the MST root CID of the previous commit (the data field at the
since rev) and is effectively required for the inductive firehose. Without
it, relays running strict commit validation (indigo with LenientSyncValidation
off) fail with "missing prevData field" and reject every commit after the
first, freezing the repo. Populated from the pre-write repo's commit.data at
each write path (create/delete/put/applyWrites).

Closes ascorbic#169

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 23, 2026 23:41
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR adds prevData to firehose #commit events so relays can verify commits inductively (avoiding “missing prevData field” failures).

Changes:

  • Add prevData (previous commit MST root CID) to sequencer commit event types and emitted events.
  • Populate prevData from the pre-write repo state across account write paths.
  • Add a regression test and update the firehose verification script/types.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/pds/test/firehose.test.ts Adds a test asserting prevData matches the previous commit’s MST root.
packages/pds/src/sequencer.ts Extends commit event/data types and forwards prevData into emitted events.
packages/pds/src/account-do.ts Populates prevData on commit data objects built during repo writes.
packages/pds/scripts/verify-firehose.ts Updates verification script’s commit event shape to include prevData.
.changeset/firehose-prevdata.md Documents the patch change and rationale for relays/verification.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/pds/src/sequencer.ts Outdated
Comment thread packages/pds/scripts/verify-firehose.ts Outdated
Comment thread packages/pds/test/firehose.test.ts
Address review feedback: type prevData as CID | null in the sequencer
(consistent with the nullable since field) and optional in the
verify-firehose script (tolerates legacy pre-prevData / since=null streams).
No behavior change — every write path still has a prior commit and sets it.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@ascorbic
Copy link
Copy Markdown
Owner

Aah! I missed that you'd jumped on this. I just merged #171 that does the same thing and a few more compliance things that I found. I'll close this but thanks for your help. I'll merge the other one

@ascorbic ascorbic closed this May 24, 2026
@simnaut simnaut deleted the feat/firehose-prevdata branch May 24, 2026 07:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Firehose #commit omits prevData, breaking inductive verification on strict relays

3 participants