Deduplicate node.schema.json with defs and refs #145

Merged
Claude merged 2 commits from chore/schema-defs into feat/yaml-nodes 2026-10-17 20:31:37 +00:00
Collaborator

YN-29. nodes/node.schema.json goes from 2,733 lines to 720. scripts/node_schema.py registers each shared fragment once under $defs and returns a $ref to it: index, label, pin, pins, rx, tx, every per-field spec, the three bind kinds (and the bind and measure-bind objects inside them), the literal-or-setting-label shapes, and each board's input, output and touch pin sets. A shared(name, spec) helper dedupes by content, so a new field or bind kind that reuses an existing shape picks up the same definition without any extra code; where a spec differs from the common one (the blower's frequency, each setting type's min, max and default) it gets an owner-prefixed name. Where a place only changes the description, the $ref carries it as a sibling keyword.

The output is also written by a small dump function, so a container that fits in 120 columns stays on one line. A $ref costs a line instead of three, and that accounts for most of the second half of the saving. It is plain JSON with two-space indent where it expands.

Validation is unchanged. test_node_schema.py is untouched and passes, and every fixture validates. I also compared the old and new schemas on 6,496 mutated copies of the fixtures (every field deleted or replaced with 24 odd values, and each fixture on each board) and they agree on every one. No change to the YAML format, the README or the generator's own checks. CI's stale check regenerates and diffs as before.

Sizes: nodes/node.schema.json 2,733 to 720 lines; scripts/node_schema.py 247 to 295.

Tested: Python 145, none skipped locally.

YN-29. `nodes/node.schema.json` goes from 2,733 lines to 720. `scripts/node_schema.py` registers each shared fragment once under `$defs` and returns a `$ref` to it: `index`, `label`, `pin`, `pins`, `rx`, `tx`, every per-field spec, the three bind kinds (and the bind and measure-bind objects inside them), the literal-or-setting-label shapes, and each board's input, output and touch pin sets. A `shared(name, spec)` helper dedupes by content, so a new field or bind kind that reuses an existing shape picks up the same definition without any extra code; where a spec differs from the common one (the blower's `frequency`, each setting type's `min`, `max` and `default`) it gets an owner-prefixed name. Where a place only changes the description, the `$ref` carries it as a sibling keyword. The output is also written by a small `dump` function, so a container that fits in 120 columns stays on one line. A `$ref` costs a line instead of three, and that accounts for most of the second half of the saving. It is plain JSON with two-space indent where it expands. Validation is unchanged. `test_node_schema.py` is untouched and passes, and every fixture validates. I also compared the old and new schemas on 6,496 mutated copies of the fixtures (every field deleted or replaced with 24 odd values, and each fixture on each board) and they agree on every one. No change to the YAML format, the README or the generator's own checks. CI's stale check regenerates and diffs as before. Sizes: `nodes/node.schema.json` 2,733 to 720 lines; `scripts/node_schema.py` 247 to 295. Tested: Python 145, none skipped locally.
Emit shared schema fragments once under defs
All checks were successful
Build and test / build (pull_request) Successful in 5m53s
Build and test / release (pull_request) Has been skipped
50662073a1
Name the schema defs after their contents and keep the registry local
All checks were successful
Build and test / build (pull_request) Successful in 2m10s
Build and test / release (pull_request) Has been skipped
d1142513bd
Claude merged commit aa4f37e37d into feat/yaml-nodes 2026-10-17 20:31:37 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
CamperCan/CampervanControlSystems!145
No description provided.