Build the schema's data object directly (implement ADR 0010)#9
Merged
Conversation
Implements ADR 0010: drop the intermediate CalculationResult domain hierarchy and populate the schema-generated Platform/Sector/... objects directly. - acoustics/: now just the pure seam functions (band_centre_hz, ...) plus load_input; the *Result dataclasses and the calculate() orchestration are gone. - mapping.py -> build.py: one builder that computes values via the seams and constructs the schema objects directly, applying float->Decimal conversion, fixed quantisation, and range-checks (MappingError) at construction. Public API: build_platform(data) / build_platform_from_file(path). - cli/schema_docs: use build.build_platform_from_file; the worked-example snippet and the committed schema reference are regenerated. - tests: seam maths stay in test_acoustics; new test_build asserts the builder produces the expected Platform; the out-of-band guard now feeds a bad input dict. The golden file is unchanged — the refactor is behaviour-preserving. - docs: typed-data and pipeline-data-flow pages updated to the direct-build story; ADR 0002 marked refined-by-0010; ADR 0010 accepted.
|
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.
What this does
Implements ADR 0010 (merged in #8): the acoustic calculation now builds the schema's data object directly. The intermediate
CalculationResulthierarchy — built only to be converted onto the generated classes — is gone. The process is now the one we can defend to stakeholders: compute the values, populate one data object that meets the schema, and prove it does.Changes
acoustics/— slimmed to the pure seam functions (band_centre_hz,spectral_rolloff_db,active_max_range_m, …) plusload_input. The*Resultdataclasses and thecalculate()orchestration are removed.mapping.py→build.py— one builder that computes the values via the seams and constructs the generatedPlatform/RadiatedBand/Sector/… directly, applyingfloat → Decimalconversion, fixed quantisation, and range-checks (MappingError) at the point of construction. Public API:build_platform(data)/build_platform_from_file(path).cli/schema_docs— usebuild.build_platform_from_file; the worked-example snippet and the committed schema-reference page are regenerated.test_acoustics; a newtest_buildasserts the builder produces the expectedPlatform; the out-of-band guard now feeds a bad input dict (noCalculationResultto mutate).What's preserved (the proof the object meets the schema)
The
float → Decimalconversion, fixed quantisation, range-checks, and both verification gates are intact — they moved to construction, they didn't disappear. Crucially:Verification
pytest— 48 passedruff check— cleanmkdocs build --strict— cleanacoustic pipeline→ golden matchTrade-off (per ADR 0010)
The builder now imports the generated schema classes, so a schema change can ripple into it (previously contained to the mapping). It's kept to the single
build.pymodule to bound that blast radius, and model regeneration + the validation gate surface any mismatch.🤖 Generated with Claude Code
Generated by Claude Code