[Core] Cleaner JSON token types, public usageId, and JSON Schema #339

Open
opened 2026-12-01 17:24:06 +01:00 by abiwab · 0 comments
Owner

While working on unit ratios in v1.5, I ran into a few rough edges in the compiled JSON output. I want to tidy those up in v1.7 without breaking anything for existing tools, so the format is solid heading into v2.0.

What I'm planning to change (all additive in v1.7, with old fields deprecated until v2.0):

  • Add an explicit type tag on every token. Right now simple ingredients and cookware don't have a type field (unlike timers, references, or alternatives), so anyone reading the JSON has to guess what an object is.
  • Expose a proper usageId / usageIds field on mentions and shopping list items, and deprecate the internal _usageId / _usageIds.
  • Separate kitchen's Usage type cleanly from the analyzer's enriched fields (normalizedMass, bakersPercentage, etc.), so kitchen doesn't declare fields it never fills.
  • Publish a JSON Schema for both compile() and analyze() outputs and check every conformance test against it in CI.

None of this changes .gram syntax or how recipes look. Existing outputs stay identical except for the added fields.

While working on unit ratios in `v1.5`, I ran into a few rough edges in the compiled JSON output. I want to tidy those up in `v1.7` without breaking anything for existing tools, so the format is solid heading into `v2.0`. What I'm planning to change (all additive in `v1.7`, with old fields deprecated until `v2.0`): - Add an explicit type tag on every token. Right now simple ingredients and cookware don't have a `type` field (unlike timers, references, or alternatives), so anyone reading the JSON has to guess what an object is. - Expose a proper `usageId` / `usageIds` field on mentions and shopping list items, and deprecate the internal `_usageId` / `_usageIds`. - Separate kitchen's `Usage` type cleanly from the analyzer's enriched fields (`normalizedMass`, `bakersPercentage`, etc.), so kitchen doesn't declare fields it never fills. - Publish a JSON Schema for both `compile()` and `analyze()` outputs and check every conformance test against it in CI. None of this changes `.gram` syntax or how recipes look. Existing outputs stay identical except for the added fields.
abiwab added this to the v1.7 milestone 2026-12-01 17:24:06 +01:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
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
gram-lang/gram#339
No description provided.