Skip to content

feat(input): XML calculation-input schema + extracted dataclasses#11

Merged
IanMayo merged 1 commit into
mainfrom
feature/xml-input-schema
Jun 19, 2026
Merged

feat(input): XML calculation-input schema + extracted dataclasses#11
IanMayo merged 1 commit into
mainfrom
feature/xml-input-schema

Conversation

@IanMayo

@IanMayo IanMayo commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Summary

Makes the input side of the pipeline symmetric with the output. The calculation input was an unvalidated JSON dict (json.loadsdict, 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 how Platform is 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:all of 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 generate does both; --schema <xsd> still does one); import-checks each module.
  • build.pyload_input() runs the input XSD gate before parsing into a typed CalculationInput; the _build_* helpers read typed attributes instead of dict keys. acoustics.load_input removed so acoustics stays pure.
  • examples/calculation_input.xml replaces the .json (same values).
  • .gitattributes — pins LF so the schema-docs drift gate (a raw read_bytes() byte-compare) passes on Windows checkouts with core.autocrlf=true, not only on LF-based CI.
  • CLI, pyproject.toml (ruff/mypy excludes for input_models/), tests, docs, and the CLI-commands contract updated to match.

Verification

  • Pipeline output is byte-identical to the golden file — the input format changed without changing behaviour.
  • ruff, mypy, and all 41 tests pass (including the schema-docs drift gate, which previously failed locally on the CRLF artifact).
  • Output models show no drift after regeneration.

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

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

github-actions Bot commented Jun 19, 2026

Copy link
Copy Markdown
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-06-19 12:03 UTC

@IanMayo IanMayo merged commit 77bbe5b into main Jun 19, 2026
3 checks passed
@IanMayo IanMayo deleted the feature/xml-input-schema branch June 19, 2026 12:03
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.

1 participant