feat(input): XML calculation-input schema + extracted dataclasses#11
Merged
Conversation
Make the input side symmetric with the output: the calculation input is now an XML document held to its own contract, parsed into typed dataclasses generated from that schema — instead of an unvalidated JSON dict. - schema/calculation_input.xsd: small XSD in the same salami-slice idiom, modelling the parameter vocabulary (incl. input-only fields like the active sonar's detection threshold that the output derives from but never emits). - input_models/: dataclasses generated from it via xsdata. Separate package because input/output schemas share element names (Characteristics, Sensors). - generate.py: regenerate both schemas (make generate does both; --schema does one); import-check each. - build.load_input(): runs the input XSD gate, then parses into a typed CalculationInput; the builders read typed attributes. acoustics.load_input removed (keeps acoustics pure). - examples/calculation_input.xml replaces the .json (same values -> output is byte-identical to the golden file). - .gitattributes: pin LF so the byte-compared schema-docs drift gate passes on Windows checkouts (core.autocrlf=true), not just on LF-based CI. - cli, pyproject (ruff/mypy excludes), tests, docs and the CLI contract updated. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
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
Makes the input side of the pipeline symmetric with the output. The calculation input was an unvalidated JSON dict (
json.loads→dict, shape enforced only implicitly by the builder). It's now an XML document held to its own contract, parsed into typed dataclasses generated from that schema — mirroring howPlatformis generated from the output schema.One file format (XML) throughout: mock input schema → extracted dataclasses → typed, validated parse → compute → validated output XML.
What changed
schema/calculation_input.xsd— small XSD in the same salami-slice idiom (no-namespace, XSD 1.1, global elements,xs:allof refs, docs on declarations). Models the parameter vocabulary, which is deliberately a different shape from the output: a handful of parameters (base frequency, band ratio/count, bearing step, roll-off, directivity lobe) are expanded by the acoustic seams into the output's bands/sectors, and some inputs (e.g. the active sonar's detection threshold) are consumed to derive an output figure and never appear verbatim.src/acoustic_dataset/input_models/— dataclasses generated from the input schema via xsdata. A separate package because the input and output schemas share element names (Characteristics,Sensors,RadiatedNoise, …), which would collide in a shared package's__init__.generate.py— regenerates both schemas (make generatedoes both;--schema <xsd>still does one); import-checks each module.build.py—load_input()runs the input XSD gate before parsing into a typedCalculationInput; the_build_*helpers read typed attributes instead of dict keys.acoustics.load_inputremoved soacousticsstays pure.examples/calculation_input.xmlreplaces the.json(same values)..gitattributes— pins LF so the schema-docs drift gate (a rawread_bytes()byte-compare) passes on Windows checkouts withcore.autocrlf=true, not only on LF-based CI.pyproject.toml(ruff/mypy excludes forinput_models/), tests, docs, and the CLI-commands contract updated to match.Verification
ruff,mypy, and all 41 tests pass (including the schema-docs drift gate, which previously failed locally on the CRLF artifact).Note
Historical planning artifacts under
specs/(data-model.md,research.md,plan.md,tasks.md) still reference the old.json— left as point-in-time records. Happy to update if preferred.🤖 Generated with Claude Code