Skip to content

Ponder a native JSON serialization - #62

Open
timj wants to merge 6 commits into
masterfrom
u/timj/jsonchan-design
Open

Ponder a native JSON serialization#62
timj wants to merge 6 commits into
masterfrom
u/timj/jsonchan-design

Conversation

@timj

@timj timj commented Jun 28, 2026

Copy link
Copy Markdown
Member

This would also make native YAML pretty straightforward.

This is purely a spec at the moment. No implementation to look at.

@codecov

codecov Bot commented Jun 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.13%. Comparing base (3a3c3e5) to head (cc874d4).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #62      +/-   ##
==========================================
- Coverage   61.13%   61.13%   -0.01%     
==========================================
  Files          83       83              
  Lines       96370    96370              
  Branches    30543    30543              
==========================================
- Hits        58913    58912       -1     
  Misses      21411    21411              
- Partials    16046    16047       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@dsberry

dsberry commented Jun 28, 2026

Copy link
Copy Markdown
Member

Odd that the design doc never mentions FitsChan, only XmlChan and YamlChan. FitsChan does include a native encoding.

None of the native encodings have ever been used to the best of my knowledge (except obviously for the basic Channel class). I suppose the reason is that the only bit of software that understands the semantics of an AST object is the AST library itself, which already has the Channel class.

timj and others added 6 commits July 3, 2026 11:11
Design for a new JsonChan Channel subclass providing lossless JSON
serialization of AST objects (JSON syntax, AST semantics), with
generated per-class JSON Schemas and a shared object/KeyMap converter
reusable for a future native YamlChan encoding.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
$minReadVersion gates the envelope grammar, not the class vocabulary, so
adding a new class is a MINOR bump that leaves $minReadVersion at 1.
Unknown $type is always a hard error (like native astGetLoader), distinct
from unknown attributes which Strict governs.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Define a dedicated AST__FORMAT_VERSION constant (separate from the
library version) as the single source of truth for the serialization
vocabulary, enforced by a CI schema-regen version-bump guard. Record the
native-format version comment as deferred future work.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The versioned thing is the Frame/Mapping object-model schema, not a file
format, so the constant becomes AST__SCHEMA_VERSION. Versioning starts at
1.0.0 with no historical archaeology; major is expected to stay 1. Patch
covers description/comment-only changes, minor covers new classes,
attributes, or type changes; the CI check distinguishes structural from
description-only schema diffs to choose the level.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add a JsonEncoding attribute (default NATIVE) mirroring XmlChan.XmlFormat
and YamlChan.YamlEncoding, as the extension point for future foreign JSON
encodings such as OME-NGFF coordinate transforms (RFC 5). Only NATIVE is
implemented; selecting another encoding errors. Plan Task 1 keeps and
renames the YamlEncoding machinery rather than deleting it.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@timj
timj force-pushed the u/timj/jsonchan-design branch from 3029557 to cc874d4 Compare July 3, 2026 10:11
@timj

timj commented Jul 3, 2026

Copy link
Copy Markdown
Member Author

We did use FITS Native form in ndf2fits in the past because we knew that GAIA could read it. I think we had ongoing debates with the DS9 people about it since I think you mentioned that they are not using AST in a way that lets AST discover the FITS WCS encoding and so it can't work with native.

We are using the native string form internally in Rubin data but if we could put both the FITS-WCS approximation and the full Native form in the same FITS header and have DS9 pick out the native form in preference, that might be an interesting approach for some users.

The JSON form proposed here is me wondering whether it would be more straightforward for us to write JSON into our JSON models directly instead of a blob, and then have schema validation for the entire model.

cc/ @TallJimbo

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