Skip to content

feat: preserve child tombstones#120

Merged
steipete merged 2 commits into
mainfrom
feat/m-tier-tombstones
Jul 18, 2026
Merged

feat: preserve child tombstones#120
steipete merged 2 commits into
mainfrom
feat/m-tier-tombstones

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Gitcrawl child hydration could not distinguish an explicitly deleted comment or pull-request child from an item that happened not to appear in one response. Replacing child snapshots also discarded rows and edit history that a lossless maintainer archive needs to retain.

Why This Change Was Made

Schema v13 applies the existing family tombstone contract to comments, pull-request reviews and review threads, and commit references: stable identities merge by default, absence is neutral, and only a sourced deletion record sets deleted_at plus deletion_reason. Editable comments and review threads record revisions, including delete and restore transitions. The migration rebuilds legacy family tables transactionally so upgraded databases receive the same strict tombstone constraints as fresh stores without losing payloads or foreign-key relationships.

Portable archives retain the new revision/tombstone tables while applying the existing body truncation and raw-JSON stripping policy to both current and historical review content.

User Impact

Maintainer archives keep child records and edit history across partial responses, explicit deletion, and later restoration. A missing child is no longer interpreted as deleted, and tombstoned rows stay out of active lists, documents, and search until a later live observation restores them.

Evidence

  • GOWORK=off go test ./...
  • GOWORK=off go vet ./...
  • AutoReview completed with no accepted actionable findings.
  • Migration coverage starts from legacy v12 family tables, verifies lossless payload and revision backfill, enforces fresh-schema CHECK constraints after upgrade, and passes foreign_key_check.
  • Merge/import tests cover not-seen neutrality, sparse explicit tombstones, payload preservation, revisions, and live restoration for comments, review threads, reviews, and PR commit references.
  • A real compiled tombstone-proof-final binary opened and converged a scratch archive to schema v13. After a live comment sync followed by an empty child response, SQLite still reported one active comment, one baseline comment revision, one retained FTS hit, strict tombstone constraints, quick_check=ok, and no foreign-key violations; doctor reported current schema with no pending migration.

@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: 1572fb3b9f

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

or (deleted_at is not null and deletion_reason is not null and trim(deletion_reason) <> '')),
unique(thread_id, comment_type, github_id)
)`,
columns: "id, thread_id, github_id, comment_type, author_login, author_type, body, is_bot, raw_json, raw_json_blob_id, created_at_gh, updated_at_gh, deleted_at, deletion_reason",

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 portable comment metadata during the rebuild

When upgrading an existing pruned portable database, comments already contains body_excerpt and body_length (added by ensurePortableExcerptColumns), but this fixed rebuild copies only the canonical columns and then drops the original table. The migration therefore permanently discards the stored original body length and excerpt columns while portable_metadata still advertises comment_excerpts; include these optional portable columns when present, as the thread migration does.

Useful? React with 👍 / 👎.

@steipete
steipete merged commit a88d729 into main Jul 18, 2026
10 checks passed
@steipete
steipete deleted the feat/m-tier-tombstones branch July 18, 2026 22:42
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