-
-
Notifications
You must be signed in to change notification settings - Fork 101
Description
Background
The Relationship model currently has two separate fields for tracking analysis relationships:
analysis(ForeignKey) - Organizational/filtering field (which mode relationship appears in)created_by_analysis(ForeignKey) - Privacy/permissions field (who can see it)
This dual-field design mirrors the same architectural pattern found in the Annotation model (see #495), introducing the same complexity and potential security concerns.
Current State (Option 1 - Implemented)
We've implemented validation to enforce consistency between these fields as a temporary mitigation. See opencontractserver/annotations/models.py:275-305.
Additionally, relationships can now be private to extracts via created_by_extract field with mutual exclusivity enforced.
Proposed Solution (Option 2)
Remove the analysis field entirely and use only created_by_analysis for both purposes:
- Simpler mental model
- Reduced validation complexity
- Better performance (one less field to index)
- Clearer semantics
- Consistency with Annotation model refactoring
Documentation
Full architectural analysis and migration strategy documented in:
docs/architecture/TODO_unify_relationship_analysis_fields.md
Related Work
- Refactor: Unify analysis and created_by_analysis fields in Annotation model #495 - Parallel refactoring effort for Annotation model
- Should be coordinated with annotation unification (do both together)
Priority
Medium - This is a refactoring to improve architecture, not a critical bug.
Effort
Medium - Requires data migration, code updates across multiple files, and thorough testing.