Refactor classification terminology to traits across taxonomy system#641
Refactor classification terminology to traits across taxonomy system#641
Conversation
- Renamed classification-related variables and methods to use "trait" terminology for consistency. - Updated database schema references from classifications to traits, including relevant SQL queries. - Adjusted test cases to reflect the new trait terminology, ensuring all references to classifications are replaced with traits. - Enhanced the CopyStats class to include traits and element_traits counts. - Ensured all relevant documentation and comments are updated to reflect the changes in terminology.
|
@claude please review this PR |
|
Claude finished @jfrench9's task in 2m 56s —— View job PR Review: Refactor classification terminology to traits
SummaryThis is a well-structured, large-scale terminology refactor that cleanly separates the semantics of "traits" (element-level FASB metamodel vocabulary) from "classifications" (association-level structural patterns). The architecture is sound. I found one confirmed bug, two correctness issues, several stale docstrings, and one incomplete feature worth calling out. 🐛 Bug:
|
| Location | Issue |
|---|---|
library_creator.py:126-128 |
Docstring says "Classifications per package" — now Traits. |
library_creator.py:355 |
Docstring says "Insert Associations + ClassificationAssignments" — now TraitAssignments. |
0002_taxonomy_library.py:797-800 |
Comment says "element_classifications junction rows" — should be "element_traits". |
✅ What looks good
- Model design is clean.
Trait(element-side, 25 categories) andClassification(association-side, 3 categories) are clearly documented and have correct CHECK constraints that mirror each other. ElementTraitcomposite PK with a partial index on(element_id, is_primary) WHERE is_primary=trueis the right index for EFS lookups.efs_trait_by_elementis the single source of truth for EFS lookups (elements.py:94) — this is the right abstraction and eliminates the N+1 pattern._bulk_resolve_element_idsavoids the O(N) round-trip problem for large packages — good performance hygiene.- Deterministic UUID5 key derivation ensures idempotent re-seeding.
- Immutability triggers cover
element_traitsandtraitsin addition to structural tables — library-seeded trait data is correctly protected. - Migration
downgrade()correctly handles public schema — FK-safe delete order (rules → junction → vocabulary → elements), then table drops. - Test coverage is updated across all affected files; the
test_classifications_migration_shape.pystatic shape tests are a good pattern for this kind of plumbing.
…oject dependencies
Summary
This PR introduces a fundamental terminology refactor across the taxonomy and classification system, renaming the concept of "classifications" to "traits" when associated with elements. This aligns the domain model more accurately with the intended semantics — elements possess traits rather than being assigned to classifications — and introduces a new
Traitmodel as a first-class entity distinct from the legacyClassificationmodel.Key Changes
New Models & Renamed Entities
robosystems/models/extensions/trait.py— NewTraitmodel replacing the classification concept for element-level attributesrobosystems/models/extensions/element_trait.py— New junction model replacingElementClassificationto associate elements with traitsrobosystems/models/extensions/element_classification.py— Superseded byelement_trait.pyrobosystems/models/extensions/classification.py— Refactored to coexist with the newTraitmodel; likely scoped to non-element contexts (e.g., association classifications)Database Migration
0002_taxonomy_library.pymigration with significant schema changes (~214 lines changed) to reflect the new trait-based table structures and relationshipsAPI Layer Updates
extensions/(accounts, reports, taxonomies, trial_balance, account_rollups) to use trait terminologyinformation_block.py,library.py, andtaxonomy_block.pyAPI modelsOperations & Business Logic
chart_of_accounts,library_creator,cascade,custom_ontology,reporting_extension,reporting_standard,update_apply,update_validator,validatorsextensions/materialize.pyTaxonomy Seeds & Loaders
jsonld_loader.pyandtaxonomy/model.pyto parse and represent traitstenant_writer.pyfor trait-aware persistenceSchema & Infrastructure
robosystems/schemas/base.pywith trait-related schema definitionsBreaking Changes
element_classificationtables must be migrated to the newelement_traitstructure.trait/traitsinstead ofclassification/classificationsfor element-level attributes. All API consumers must be updated.Testing Notes
Infrastructure Considerations
🤖 Generated with Claude Code
Branch Info:
feature/element-trait-breakoutmainCo-Authored-By: Claude noreply@anthropic.com