Skip to content

Build the schema's data object directly (implement ADR 0010)#9

Merged
IanMayo merged 1 commit into
mainfrom
claude/build-schema-object-directly
Jun 17, 2026
Merged

Build the schema's data object directly (implement ADR 0010)#9
IanMayo merged 1 commit into
mainfrom
claude/build-schema-object-directly

Conversation

@IanMayo

@IanMayo IanMayo commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

What this does

Implements ADR 0010 (merged in #8): the acoustic calculation now builds the schema's data object directly. The intermediate CalculationResult hierarchy — 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, …) plus load_input. The *Result dataclasses and the calculate() orchestration are removed.
  • mapping.pybuild.py — one builder that computes the values via the seams and constructs the generated Platform/RadiatedBand/Sector/… directly, applying float → Decimal conversion, fixed quantisation, and range-checks (MappingError) at the point of 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 page are regenerated.
  • Tests — seam maths stay in test_acoustics; a new test_build asserts the builder produces the expected Platform; the out-of-band guard now feeds a bad input dict (no CalculationResult to mutate).
  • Docs — the typed-data and pipeline-data-flow pages now tell the direct-build story; ADR 0002 is marked refined by ADR 0010; ADR 0010 flipped to Accepted.

What's preserved (the proof the object meets the schema)

The float → Decimal conversion, fixed quantisation, range-checks, and both verification gates are intact — they moved to construction, they didn't disappear. Crucially:

The golden file is unchangedmake pipeline output is byte-identical to tests/golden/acoustic_dataset.xml. The refactor is behaviour-preserving.

Verification

  • pytest — 48 passed
  • ruff check — clean
  • mkdocs build --strict — clean
  • end-to-end acoustic pipelinegolden match

Trade-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.py module to bound that blast radius, and model regeneration + the validation gate surface any mismatch.

🤖 Generated with Claude Code


Generated by Claude Code

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.
@github-actions

github-actions Bot commented Jun 16, 2026

Copy link
Copy Markdown
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-06-17 05:33 UTC

@IanMayo IanMayo merged commit aff76c7 into main Jun 17, 2026
3 checks passed
@IanMayo IanMayo deleted the claude/build-schema-object-directly branch June 17, 2026 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants