Skip to content

Ship record version history to production (staging port of #135) - #136

Merged
daviddao merged 1 commit into
stagingfrom
record-version-history-staging
Sep 23, 2026
Merged

daviddao merged 1 commit into
stagingfrom
record-version-history-staging

Conversation

@daviddao

Copy link
Copy Markdown
Member

Ports #135 (opt-in record version history, merged to main) onto staging so it reaches production without the unreleased main work (#123 record validation gate, #133).

  • Same files as Opt-in record version history (recordHistory query) #135: migration 015 record_version, RecordVersionsRepository, RECORD_HISTORY_COLLECTIONS, recordHistory(uri, first, after), baseline seeding at startup, and docs.
  • The Tap handler edits are adapted to staging's records.Insert / records.Delete path. The version is written before the insert; the tombstone is written before the delete.
  • The migration keeps number 015 so both branches agree. The runner applies any migration not yet in schema_migrations, so 012–014 still apply at the next main → staging promotion. Expect a small conflict in internal/tap/handler.go then: keep main's version, which already contains this feature.

Rollout: set RECORD_HISTORY_COLLECTIONS=app.gainforest.dwc.occurrence on the production hyperindex service. The first boot seeds about 34.5k baseline rows.

Verified on this branch: go build, golangci-lint (0 issues), go test -race ./... on SQLite and PostgreSQL 17, and integration tests. A new migration test covers 015 up/down; the Postgres rollback test now rolls back 015 before 011.

Ports the opt-in record version history from main (#135) onto staging
without the unreleased record validation gate: migration 015 record_version,
RecordVersionsRepository, the RECORD_HISTORY_COLLECTIONS config, Tap handler
writes (version before the current-state insert, tombstone before delete),
baseline seeding at startup, and the recordHistory GraphQL query.

The migration keeps number 015 so main and staging agree; the runner applies
any unapplied migration, so 012-014 still apply when main is promoted.
@vercel

vercel Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
hyperindex-atproto-client Ready Ready Preview Sep 23, 2026 7:04am UTC
hyperindex-client Error Error Sep 23, 2026 7:04am UTC

Request Review

@coderabbitai

coderabbitai Bot commented Sep 23, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository: GainForest/hyperindex/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: a87c6136-afb1-4e02-82c9-f35de544be9f

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@daviddao
daviddao merged commit 0aba588 into staging Sep 23, 2026
8 of 9 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a06ec1b511

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +5 to +8
CREATE TABLE IF NOT EXISTS record_version (
id BIGSERIAL PRIMARY KEY,
uri TEXT NOT NULL,
cid TEXT NOT NULL,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Remove version rows when purging an actor

When an admin invokes PurgeActor or Tap receives a deleted, deactivated, suspended, or taken-down identity, RecordsRepository.PurgeActorData deletes only record and actor; this independent table has no cascade and neither purge path removes its rows. Because the new public recordHistory resolver reads this table directly, tracked record bodies remain publicly retrievable after an operation documented as removing all indexed data for the DID. Include these rows in the same purge transaction.

Useful? React with 👍 / 👎.

Comment on lines +20 to +22
-- A version is recorded once, however often Tap redelivers or resyncs it.
CREATE UNIQUE INDEX IF NOT EXISTS idx_record_version_uri_key
ON record_version(uri, version_key);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve recreated versions after a deletion

When a URI is deleted and later recreated with the same content, ATProto produces the same content-addressed CID, but this URI/CID uniqueness constraint discards both the later create and its subsequent delete:<cid> tombstone. CID-less records have the same problem because identical bodies and all empty-CID tombstones reuse their keys. The resulting history ends at the first delete even while the record exists again, so deduplication needs an event or lifecycle identity that distinguishes redelivery from a legitimate recreate.

AGENTS.md reference: AGENTS.md:L94-L94

Useful? React with 👍 / 👎.

This branch had an error being deployed

1 failed and 1 active deployments
Preview – hyperindex-client — a06ec1b5 Deployed Sep 23, 2026 by vercel[bot]
Preview – hyperindex-atproto-client — a06ec1b5 Deployed Sep 23, 2026 by vercel[bot]
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.

1 participant