Architecture deepening: FieldRegistry-driven serialization + extractions#16
Merged
Conversation
Three architecture improvements from the codebase review:
1. Entity::Yaml drives from FieldRegistry (not a 50-line type switch)
- from_entity iterates FieldRegistry.fields_for, reads typed values
via the field DSL, sets YAML attrs by wire_name
- Eliminates the case entity.type switch, KNOWN_WIRE_IDS duplication
- Fixes MDC_P044 collision bug (code_list vs enumeration_code now
type-guarded in to_entity)
- Aligned field wire_names with YAML attr names via as: aliases
on Property, Unit, Relation, ViewControl fields
2. NameSynthesizer extracted from SheetSchema
- NAME_TO_PROPERTY_ID (45 entries) + synthesize() moved to
Entity::NameSynthesizer module
- SheetSchema delegates via synthesize_ids_from_names
- 13 specs covering name synthesis + SheetSchema integration
3. ImportPipeline extracted from CDDAL Builder
- process_import, check_cycle!, apply_import_scope,
register_qualified/selective_symbols moved to ImportPipeline
- Builder delegates apply_import_declarations to it
- 4 specs with in-memory resolver adapter (no doubles)
Candidate 4 (bidirectional field DSL) deferred: write paths are
already centralized through write_property!, and coercion already
happens at read time via FieldReader. Marginal benefit doesn't
justify the risk of touching core data flow.
Net: -72 lines across modified files. 4 new files (2 lib + 2 spec).
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
Three architecture improvements from the codebase review:
1. Entity::Yaml drives from FieldRegistry (Strong)
Replaced the 50-line
case entity.typeswitch with a FieldRegistry-driven approach.from_entitynow iteratesFieldRegistry.fields_for, reads typed values via the field DSL, and sets YAML attrs bywire_name. This mirrors howExporters::Json#entity_payloadalready works.as:aliases on Property, Unit, Relation, ViewControl2. NameSynthesizer extracted from SheetSchema (Worth exploring)
NAME_TO_PROPERTY_ID (45 entries) +
synthesize()moved toEntity::NameSynthesizermodule. SheetSchema delegates. Separate test surface.3. ImportPipeline extracted from CDDAL Builder (Worth exploring)
process_import, cycle detection, and symbol scoping moved toCddal::ImportPipeline. Builder delegates. Testable in isolation with in-memory resolver adapter. 4 specs including cycle detection + real import round-trip.Candidate 4 (bidirectional DSL): Deferred
Write paths already centralized through
write_property!; coercion at read time via FieldReader. Marginal benefit doesn't justify risk.Test plan