feat(render): model.render.json for display — camdlc render --format json + auto-archive#437
Merged
Conversation
Split latex.ml into a structured `rendered_model` and two projections: `to_document` (the existing standalone LaTeX, byte-identical) and `to_json` (a web/display shape). `camdlc render --format json` emits the JSON. The JSON is what a KaTeX consumer (camdl-watch) wants: every math string is a standalone renderable expression; transitions are split into reactants/products/rate (for a reaction table, not a pre-assembled arrow); dynamics are keyed by state; parameters carry a glossary (symbol + description) drawn from the `#'` doc comments; plus model name, mode, states, and dimension level sets. to_document is unchanged — the existing render tests stay green — and the JSON projection adds a well-formedness + shape test.
Add `camdl render` (passthrough to `camdlc render`, mirroring check/inspect) so the model renderer — LaTeX or `--format json` — is on the main CLI. Every fit segment now auto-archives `model.render.json` beside `model.ir.json`: the model's display JSON, captured via `util::render_model_json` (`camdlc render --format json`). Best-effort and identity-neutral like the IR archive — a render failure warns and skips, never aborts the fit. A viewer (camdl-watch) fetches it from the segment and renders the model's math with KaTeX, no recompile. Verified end-to-end: a fresh fit writes a valid model.render.json carrying the model name, states, parameter glossary, split transitions, and dynamics.
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.
Model render for display —
camdlc render --format json+ auto-archivedmodel.render.jsonMakes a model's math available to downstream viewers (camdl-watch) without
recompiling or DSL parsing.
camdlc render --format json(andcamdl render)latex.mlis split into a structuredrendered_modelwith two projections:to_document(the existing standalone LaTeX — byte-identical, all rendertests stay green) and
to_json(a web/display shape).camdl renderis apassthrough to
camdlc render, so both LaTeX and JSON are on the main CLI.The JSON is built for a KaTeX consumer: every math string is a standalone
renderable expression; transitions are split into
reactants/products/rate(for a reaction table, not a pre-assembled arrow); dynamics are keyedby
state; parameters carry a glossary (symbol+descriptionfrom the#'doc comments); plus model name, mode, states, and dimension level sets.Auto-archived
model.render.jsonEvery fit segment now writes
model.render.jsonbesidemodel.ir.json— thedisplay JSON, best-effort and identity-neutral (a render failure warns and
skips, never aborts the fit). A viewer fetches it from the run's segment and
renders the model, no recompile.
Verified end-to-end: a fresh fit writes a valid
model.render.jsonwith themodel name, states, parameter glossary, split transitions, and dynamics.
Follow-ups (not in this PR)
Sim/predict segments' archive (same helper), and an integration test asserting
the archive lands — batched with the output_schema v1.5 work.