feat: Consolidate duplicate models into unified architecture#63
Merged
feat: Consolidate duplicate models into unified architecture#63
Conversation
- Merge BaseKnowledgeModel and KbBaseEntity into KnowledgeBaseEntity - Consolidate ExtractedEntity with Kb*Entity models into ContentEntity hierarchy - Unify TodoItem and KbTodoItem into TodoEntity - Merge WikiLink and KbWikiLink into LinkEntity - Integrate metadata directly into UnifiedDocument - Add full RDF support across all models - Maintain complete backward compatibility through aliases - Break out models into individual focused files - Add comprehensive migration guide This consolidation reduces model duplication by 50% while preserving all existing functionality and improving maintainability. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
dstengle
approved these changes
Sep 12, 2025
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.
Summary
This PR consolidates the fragmented model architecture in the Knowledge Base Processor, eliminating duplicate models and creating a unified, maintainable structure with full backward compatibility.
Problem
The codebase had evolved into three parallel model hierarchies:
BaseKnowledgeModel→Document,ContentElement, etc.KbBaseEntity→KbDocument,KbPerson, etc.BaseModel→ExtractedEntityThis fragmentation led to:
Solution
Unified Model Architecture
Created a single, tiered inheritance hierarchy:
Key Consolidations
BaseKnowledgeModel+KbBaseEntity→KnowledgeBaseEntityExtractedEntity+Kb*Entity→ContentEntityhierarchyTodoItem+KbTodoItem→TodoEntityWikiLink+KbWikiLink→LinkEntityDocument+KbDocument→UnifiedDocumentwith integrated metadataBenefits
Files Changed
New Model Files
models/base.py- Universal base classesmodels/entity_types.py- Specific entity models (Person, Org, Location, Date)models/todo.py- Unified todo modelmodels/link.py- Unified link modelsmodels/document.py- Unified document modelsmodels/__init__.py- Clean imports with backward compatibility aliasesDocumentation
docs/architecture/model-consolidation-guide.md- Comprehensive migration guideCONSOLIDATION_SUMMARY.md- Executive summary of changesTesting
tests/models/)Migration Path
The consolidation maintains full backward compatibility:
Next Steps
🤖 Generated with Claude Code