fix(extractors): store state in brain DB, not JSON files (closes #63)#91
Open
rajkripal wants to merge 1 commit into
Open
fix(extractors): store state in brain DB, not JSON files (closes #63)#91rajkripal wants to merge 1 commit into
rajkripal wants to merge 1 commit into
Conversation
Move extractor_state from <data_dir>/extractor_state/<name>.json into an extractor_state table in brain.db so that state lifecycle matches DB lifecycle. Wiping the DB now also resets extractor progress, eliminating silent skip-all-reprocessing on reingest. - ExtractorRegistry.__init__ accepts optional db_path; creates extractor_state table (name TEXT PK, state_json TEXT, updated_at TEXT) - _save_state / _load_state use DB when db_path is set, JSON otherwise - Backwards-compat shim: on first load, if DB row is missing, import from legacy JSON file and migrate into DB - CLI (cmd_ingest) passes db_path to registry - Four new tests: DB persistence, DB lifecycle matches DB wipe, JSON fallback, legacy shim import Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Extractor state files lived at
<data_dir>/extractor_state/<name>.json, independent ofgraph.db. Wiping the DB while keeping the state dir caused silent skip-all on reingest: 0 nodes, no error.Solution
Move extractor state into the brain DB as an
extractor_statetable:State lifecycle now matches DB lifecycle. Wipe the DB, state is gone, reingest works.
Changes
ExtractorRegistry.__init__accepts optionaldb_path; creates the table on init_save_state/_load_stateuse DB whendb_pathis set, JSON file otherwise_load_statemiss, checks for legacy JSON file and imports it into the DBcmd_ingestincashew_cli.pypassesdb_pathto registryTest results