feat: Consolidate duplicate models into unified architecture #63
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