Class: ClaudeMemory::Infrastructure::SchemaValidator
- Inherits:
-
Object
- Object
- ClaudeMemory::Infrastructure::SchemaValidator
- Defined in:
- lib/claude_memory/infrastructure/schema_validator.rb
Overview
Validates database schema integrity and data consistency Records validation results in schema_health table
Constant Summary collapse
- EXPECTED_TABLES =
%i[ meta content_items delta_cursors entities entity_aliases facts provenance fact_links conflicts tool_calls operation_progress schema_health ].freeze
- OPTIONAL_TABLES =
FTS table is created lazily, so it’s optional
%i[content_fts].freeze
- CRITICAL_COLUMNS =
{ facts: %i[id subject_entity_id predicate status scope project_path embedding_json], content_items: %i[id source session_id text_hash ingested_at source_mtime], entities: %i[id type canonical_name slug], operation_progress: %i[id operation_type scope status started_at] }.freeze
- VEC_TABLE_PREFIX =
sqlite-vec virtual table prefix; all internal tables (chunks, rowids, etc.) share this
"facts_vec"- CRITICAL_INDEXES =
%i[ idx_facts_predicate idx_facts_subject idx_facts_status idx_facts_scope idx_facts_project idx_provenance_fact idx_content_items_session idx_operation_progress_type idx_operation_progress_status ].freeze
Instance Method Summary collapse
-
#initialize(store) ⇒ SchemaValidator
constructor
A new instance of SchemaValidator.
- #validate ⇒ Object
Constructor Details
#initialize(store) ⇒ SchemaValidator
Returns a new instance of SchemaValidator.
33 34 35 |
# File 'lib/claude_memory/infrastructure/schema_validator.rb', line 33 def initialize(store) @store = store end |
Instance Method Details
#validate ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/claude_memory/infrastructure/schema_validator.rb', line 37 def validate issues = [] tables = @store.db.tables check_tables(tables, issues) check_columns(tables, issues) check_indexes(issues) check_orphaned_records(issues) check_enum_values(issues) (issues) record_health_check(issues) { valid: issues.none? { |i| i[:severity] == "error" }, issues: issues } end |