Skip to content

fix: store_enrichment commits internally so external callers don't lose data#5

Open
gnujoow wants to merge 1 commit into
mainfrom
fix/issue-3-store-enrichment-commit
Open

fix: store_enrichment commits internally so external callers don't lose data#5
gnujoow wants to merge 1 commit into
mainfrom
fix/issue-3-store-enrichment-commit

Conversation

@gnujoow

@gnujoow gnujoow commented Jul 13, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes #3.

Database.store_enrichment() wrote the enrichment row (and the status update) but never committed — enrich_pending commits in its own loop, so the CLI path was safe, but any external caller (e.g. a script looping db.store_enrichment(...)) silently lost everything on close. Since every enrichment result costs a request against FreqBlog's monthly quota (~1,000/month), a rollback here is unrecoverable data loss.

Changes

  • store_enrichment now commits before returning (both finalize=True and finalize=False paths), with a docstring note explaining why.
  • enrich_pending is unchanged: its COMMIT_EVERY / finally commits still cover the bump_enrich_attempt / mark_enrichment_failed paths, and become harmless no-ops for the store path. WAL + synchronous=NORMAL keeps per-row commits cheap.

Tests

Two regression tests using a file-backed DB: call store_enrichment with no explicit commit, close (which rolls back any open transaction), reopen, and assert the enrichment row and track status survived — for both the finalized and finalize=False (partial) paths.

147 passed (baseline 145).

🤖 Generated with Claude Code

…lose data

Each enrichment result costs a request against FreqBlog's monthly quota,
so silently rolling it back when a caller forgets db.conn.commit() is
data loss (observed: 146 stored via an external script, only 2 survived).

store_enrichment now commits before returning. enrich_pending's batched
COMMIT_EVERY/finally commits still cover the bump/mark paths and become
harmless no-ops for the store path (WAL + synchronous=NORMAL keeps
per-row commits cheap).

Fixes #3

Co-Authored-By: Claude Fable 5 <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.

enrich: store_enrichment data is silently lost (no commit on external callers)

1 participant