Skip to content

feat(render): model.render.json for display — camdlc render --format json + auto-archive#437

Merged
vsbuffalo merged 2 commits into
mainfrom
feature/render-json
Jul 15, 2026
Merged

feat(render): model.render.json for display — camdlc render --format json + auto-archive#437
vsbuffalo merged 2 commits into
mainfrom
feature/render-json

Conversation

@vsbuffalo

Copy link
Copy Markdown
Owner

Model render for display — camdlc render --format json + auto-archived model.render.json

Makes a model's math available to downstream viewers (camdl-watch) without
recompiling or DSL parsing.

camdlc render --format json (and camdl render)

latex.ml is split into a structured rendered_model with two projections:
to_document (the existing standalone LaTeX — byte-identical, all render
tests stay green) and to_json (a web/display shape). camdl render is a
passthrough 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 keyed
by state; parameters carry a glossary (symbol + description from the
#' doc comments); plus model name, mode, states, and dimension level sets.

Auto-archived model.render.json

Every fit segment now writes model.render.json beside model.ir.json — the
display 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.json with the
model 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.

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.
@vsbuffalo
vsbuffalo merged commit 56424d2 into main Jul 15, 2026
5 checks passed
@vsbuffalo
vsbuffalo deleted the feature/render-json branch July 15, 2026 19: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