Skip to content

fix: render metric embeds on a div carrier with a readable sentence fallback#13

Merged
EiffL merged 1 commit into
mainfrom
fix/metric-carrier-contract
Jul 5, 2026
Merged

fix: render metric embeds on a div carrier with a readable sentence fallback#13
EiffL merged 1 commit into
mainfrom
fix/metric-carrier-contract

Conversation

@EiffL

@EiffL EiffL commented Jul 5, 2026

Copy link
Copy Markdown
Member

Closes the metric leftover from #10 (also tracked in LightconeResearch/astra-theme#2's ecosystem notes).

Problem

The resolved store already materializes metrics (metric: readMetric(absPath) since v0.0.6), but the embed rendering didn't hold up its end of the contract:

  • A produced metric (:::{astra} outputs.<id>) rendered as a collapsible key/value table on a details carrier — a poor neutral fallback, and a node type rich themes can't sensibly key on, so astra-theme's big-stat rendering (MetricStat) could never trigger.
  • An unproduced output embed (any type) emitted the "Pending Output" admonition with no identifier at alltagComponent's carrierOf fell back to nodes[0] for the class, but cross-references and store joins had nothing to land on, even though the store entry (label, description, full provenance) exists before the artifact does.

(Side note from testing: the DESI prototype's analyses/reconstruction/results is a broken symlink to NERSC scratch, which is why metrics appeared unexercisable there — worth knowing when testing locally.)

Change

  • A produced metric renders as one div carrier (the fix: nest the decision/finding fallback inside the carrier node #11 contract) bearing output-<id>, with a readable sentence nested as the neutral fallback: <label>: <value> ± <uncertainty> <unit>, built via readMetric. A JSON that isn't metric-shaped keeps the existing tabular fallback, wrapped in the same carrier.
  • An unproduced output embed wraps its Pending admonition in the identifier-bearing carrier div: anchors resolve, and rich themes can join and decorate (astra-theme now shows the provenance drawer on pending outputs).
  • data / report types keep their current inline rendering.

Testing

  • Carrier tests updated/added: produced metric pins div + sentence + no details; new unproduced-embed test pins the identifier + nested admonition. vitest 101/101, tsc clean.
  • Verified end-to-end with astra-theme against a minimal ASTRA project on this branch: the produced metric renders as the big stat (6.42 ±0.31 Mpc/h + label + provenance drawer) — the first time that component has rendered from real plugin output — and the pending embed keeps its admonition and gains the drawer. Theme-side support (a div[class*="astra-output"] renderer bucket, inert on older plugins) is already on astra-theme main (c56c74a).

🤖 Generated with Claude Code

https://claude.ai/code/session_013EE6NiwH2UhVAUT6cdAQJ4

…allback

Closes the metric leftover from #10 (see also
LightconeResearch/astra-theme#2, ecosystem notes).

A produced metric embed (:::{astra} outputs.<id>) rendered as a
collapsible key/value table on a 'details' carrier — a poor neutral
fallback, and a node type rich themes can't sensibly key on, so the
big-stat rendering never triggered even though the resolved store
already carries the parsed metric. An unproduced output embed was worse:
the pending admonition carried no identifier at all, so cross-references
and store joins had nothing to land on.

- A produced metric now renders as one div carrier (the #11 contract)
  bearing output-<id>, with a readable sentence fallback nested inside:
  "**<label>:** <value> ± <uncertainty> <unit>", built via readMetric.
  A JSON that isn't metric-shaped keeps the tabular fallback (wrapped in
  the same carrier).
- An unproduced output embed (any type) wraps its Pending Output
  admonition in the identifier-bearing carrier div: anchors resolve and
  rich themes can join the store entry (label, description, provenance)
  before the artifact exists.
- data / report types keep their current inline rendering.

Tests: metric carrier test now pins the div + sentence + no-details
shape; new unproduced-embed test pins the identifier + nested admonition
(101/101 pass, tsc clean).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013EE6NiwH2UhVAUT6cdAQJ4

@EiffL EiffL left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@EiffL
EiffL merged commit 1ac016c into main Jul 5, 2026
3 of 4 checks passed
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