Skip to content

fix(extract): restore soft-deleted document on extraction accept#777

Merged
cpcloud merged 2 commits intomainfrom
worktree-logical-churning-swing
Mar 14, 2026
Merged

fix(extract): restore soft-deleted document on extraction accept#777
cpcloud merged 2 commits intomainfrom
worktree-logical-churning-swing

Conversation

@cpcloud
Copy link
Owner

@cpcloud cpcloud commented Mar 14, 2026

Summary

  • acceptExistingExtraction now calls EnsureDocumentAlive before persisting extraction data, restoring soft-deleted documents automatically
  • UpdateDocumentExtraction uses Unscoped so the update reaches soft-deleted rows as a safety net
  • Added store-level tests for EnsureDocumentAlive (alive/deleted/nonexistent) and UpdateDocumentExtraction on soft-deleted docs
  • Added app-level tests for accepting extraction on soft-deleted documents with and without shadow operations

closes #769

cpcloud and others added 2 commits March 14, 2026 10:23
acceptExistingExtraction now calls EnsureDocumentAlive before persisting
extraction data, so a document that was soft-deleted between extraction
start and accept is restored automatically. UpdateDocumentExtraction
uses Unscoped so the update reaches soft-deleted rows as a safety net.

closes #769

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…reDocumentAlive

EnsureDocumentAlive now checks for gorm.ErrRecordNotFound explicitly
before falling through to RestoreDocument. Transient DB errors (e.g.
connection issues) are surfaced immediately instead of being masked by
a confusing restore error.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@cpcloud cpcloud merged commit 8351a5a into main Mar 14, 2026
23 checks passed
@cpcloud cpcloud deleted the worktree-logical-churning-swing branch March 14, 2026 14:43
@codecov
Copy link

codecov bot commented Mar 14, 2026

Codecov Report

❌ Patch coverage is 57.14286% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.20%. Comparing base (f9f0968) to head (0c13465).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
internal/app/extraction.go 40.00% 2 Missing and 1 partial ⚠️
internal/data/store.go 66.66% 2 Missing and 1 partial ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
internal/app/extraction.go 76.57% <40.00%> (-0.13%) ⬇️
internal/data/store.go 72.52% <66.66%> (+0.44%) ⬆️

... and 4 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

cpcloud added a commit that referenced this pull request Mar 19, 2026
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
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.

fix(extract): reextraction of soft-deleted document produces FK/unique constraint errors

1 participant