@luhtech/site-template 0.22.0 → 0.23.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -3,8 +3,15 @@
3
3
  One Astro component library renders every LuhTech venture marketing site from
4
4
  its own `content/page.schema.json` + `content/site.schema.json` instances.
5
5
  Copy is a derived surface -- the instances are the authored source, this
6
- package is the renderer, and it validates on every build so an invalid
7
- instance fails the build instead of shipping.
6
+ package is the renderer. Since 0.18.0 the package fetches and carries no
7
+ schema: each site repo validates its instances in its own CI against
8
+ schema-registry (the reusable `content-validate.yml` workflow), so an invalid
9
+ instance fails that site's CI instead of shipping.
10
+
11
+ Current release: **0.23.1** on npmjs.com. Every release is a
12
+ `site-template-v*` tag, published by `.github/workflows/publish.yml`; CI
13
+ (`.github/workflows/ci.yml`) runs `npm install` + `npm test` on every PR and
14
+ push to `main`.
8
15
 
9
16
  ```
10
17
  npm install @luhtech/site-template
@@ -45,6 +52,8 @@ site with no way to supply one (GTM-L3 G1.4-R, 2026-09-08).
45
52
  on `hero`/`proof` sections were silently invisible before this).
46
53
  - **`<SplashHero {...} />`** (`@luhtech/site-template/components/SplashHero.astro`)
47
54
  -- a trigger-flow hero: full-bleed photo, a one-time splash intro on load
55
+ (optional since 0.20.0: `intro: 'wordmark'` is the default, `intro: 'none'`
56
+ renders the hero with no splash -- Ectropy-Business's `apps/marketing-site` home page uses `'none'`)
48
57
  (wireframe wordmark -> white-fill wave -> fly-out into the real nav logo's
49
58
  on-screen position, measured at play time), then never repeats for that
50
59
  session (`sessionStorage`, keyed by your own `sessionKey` so two on one
@@ -63,9 +72,9 @@ site with no way to supply one (GTM-L3 G1.4-R, 2026-09-08).
63
72
  as usual. See `~/dev/luhtech/Ectropy-Business/apps/marketing-site/src/pages/index.astro`
64
73
  for the reference consumer.
65
74
  - **`loadBrand(path)`** (`@luhtech/site-template/content`) reads a
66
- `content/brand/<venture>.json` file and ajv-validates it against the live,
67
- version-pinned `portfolio/brand-identity.schema.json`. Mirrors
68
- `loadPage`/`loadSite`.
75
+ `content/brand/<venture>.json` (`portfolio/brand-identity.schema.json`)
76
+ instance. Like `loadPage`/`loadSite`, it does not validate (0.18.0); the
77
+ site's CI does.
69
78
  - **`applyBrandDefaults(page, brand)`** (`@luhtech/site-template/content`) --
70
79
  GTM-L3 G1.1/G1.2: on the page whose `route` is `/`, returns a copy of
71
80
  `page` with `sections[hero].heading` replaced by `brand.identity.tagline`,
@@ -216,9 +225,10 @@ design undershot; the bespoke clickable-diagram/inspector/scenario-ledger
216
225
  layer those examples also use is deliberately out of scope -- genuinely
217
226
  bespoke per-tool illustration work, not schema-parametrizable regardless.
218
227
 
219
- `loadTool()` (new, `@luhtech/site-template/content`) reads and ajv-validates
220
- a `content/tool.schema.json` instance from disk, same convention and error
221
- handling as `loadPage`/`loadSite`. `ToolCalculator.astro` renders it: real
228
+ `loadTool()` (new, `@luhtech/site-template/content`) reads a
229
+ `content/tool.schema.json` instance from disk, same convention as
230
+ `loadPage`/`loadSite` (it validated with ajv until 0.18.0; the site's CI
231
+ validates it now). `ToolCalculator.astro` renders it: real
222
232
  inputs, a live-computed result gated behind a contact-capture form, and
223
233
  (when the instance's `presentation` block is present) the hero KPI/chart/
224
234
  method-notes/sources described above. `<Section>`/`<Article>` gained
@@ -290,7 +300,8 @@ this same section's own `diagrams[]` -- the block is a position, `diagrams[]`
290
300
  stays the data) and `image` (required `src`+`alt`, optional `caption` --
291
301
  the first real mechanism for a photo to appear inline in an article body
292
302
  at all). Existing instances validate unchanged; `PAGE_PIN` bumped to
293
- `1.3.0`.
303
+ `1.3.0` (the pin itself was removed in 0.18.0, when validation moved to
304
+ each site's CI).
294
305
 
295
306
  **`Block.astro`** renders both: `diagram` dispatches to `Diagram.astro`
296
307
  after resolving `diagramId` against a new `diagrams` prop -- a dangling
@@ -327,6 +338,47 @@ A `tsconfig.json` was added (this repo had none) extending
327
338
  diagnostics across `ToolCalculator.astro` and the diagram components that
328
339
  the repo's prior no-tsconfig default resolution wasn't catching.
329
340
 
341
+ ## Marks, the venture directory, forms, papers and figures (0.8.0 - 0.20.1)
342
+
343
+ What landed between 0.7.0 and 0.15.0, and after it, that the sections above
344
+ and below do not cover (versions from this repo's commit history):
345
+
346
+ - **Venture marks.** `VentureMark.astro` renders a venture's mark on a sibling
347
+ site, preferring its animated mark from the generated
348
+ `src/lib/venture-marks.generated.ts` and falling back to the static one.
349
+ Each animated mark is self-contained (its own scoped `<style>` and prefixed
350
+ keyframes) so several can sit on one page (0.8.0, 0.9.0; Ectropy's mark is
351
+ its brand pack's reverse reveal at small format since 0.20.0/0.20.1).
352
+ - **Venture cards.** `VentureCard.astro` renders a `crossLinks[]` entry as a
353
+ card: mark, the venture's display name and one-liner from the generated
354
+ `src/lib/venture-directory.generated.ts`, and the authored
355
+ `relationshipLine` (0.10.0; the holding company shows its name, not its id,
356
+ since 0.18.1).
357
+ - **Sync bins (local, not CI).** `luhtech-sync-marks`,
358
+ `luhtech-sync-animated-marks` and `luhtech-sync-venture-directory` read the
359
+ venture repos as sibling checkouts on disk (`~/dev/luhtech/<Repo>`, listed in
360
+ `bin/lib/ventures.mjs`) and regenerate the files above. They cannot run in
361
+ CI; run them by hand when a venture's mark or brand record changes.
362
+ `bin/lib/ventures.mjs` lists ten entries: Ectropy, Qullqa, Siltana,
363
+ JobsiteControl, Viiva, Ohjaus, Raizal, Replique, Hilja and LuhTech.
364
+ - **Shared layout pieces.** `FullBleedHeroImage.astro` (0.10.2, promoted from
365
+ LuhTech-Business), `SectionHeading.astro` (shared heading standard), a `bio` block
366
+ type (0.11.0), a nav that collapses behind a menu button below `md` (0.13.0),
367
+ and `LoginCard.astro` plus a sign-in nav button (0.14.0).
368
+ - **Gated asset request.** `AssetRequestForm.astro` renders a `cta` section
369
+ that carries `assetRequest`: name, work email, company, role and an unticked
370
+ opt-in, posted to `site.leadCapture.assetRequestEndpoint`. The page only
371
+ shows a confirmation; the capture service emails the link
372
+ (d-2026-10-01-st-asset-request-form).
373
+ - **Paper landing.** `PaperLanding.astro` (`@luhtech/site-template/lib/paperLanding`
374
+ for its helpers) is a paper's one page: its open summary and figures, then
375
+ Download, Feedback and Share, read from the whitepaper record (0.17.0,
376
+ d-2026-10-02-st-paper-landing-three-actions).
377
+ - **Figure records.** A `diagrams[]` entry that names a `figureRef` is drawn by
378
+ `@luhtech/figures` (published from `luh-tech/site-visuals`) in the site's
379
+ brand theme; an entry with `diagramType` + `data` still draws inline (0.19.0).
380
+ `ConnectionGraph.astro` renders the `connection-graph` diagram type.
381
+
330
382
  ## Browser icons, canonical URLs and search metadata (0.15.0)
331
383
 
332
384
  `SiteLayout` now emits, beyond `page.seo`'s title/description/ogImage:
@@ -373,6 +425,29 @@ Two bins go with it:
373
425
  install chromium`. `SiteLayout` emits the web-app meta for an installable
374
426
  site.
375
427
 
428
+ ## A connection graph with a cycle lays out at its true width (0.23.1)
429
+
430
+ `ConnectionGraph` layered by longest-path relaxation, which on a cycle
431
+ (design -> ... -> operate -> design) pushed the cycle's nodes one column
432
+ right on every pass: desconops.org's five-node three-loops figure came out
433
+ 13000 units wide. `layerGraph` (`src/lib/graphLayout.ts`) now breaks each
434
+ cycle first -- a depth-first search in node order marks the edge that closes
435
+ it -- and layers the rest in one topological pass; both are linear in nodes
436
+ plus edges and give the same layout for the same record. A cycle-closing
437
+ edge draws as a dashed return path under the graph, its label beneath. An
438
+ acyclic graph lays out exactly as before (`test/graphLayout.test.mjs` checks
439
+ 300 random ones against the old layering).
440
+
441
+ ## A figure renders its label (0.23.0)
442
+
443
+ content/page 2.9.0 and whitepaper 1.4.0 give a figure a `label` (what the
444
+ value is) and a `measure` (the value as money, a quantity, a fraction or a
445
+ date, by reference to the open standard's units definitions), and deprecate
446
+ `unit`, which carried both. `Figure` and the `sources` section render
447
+ `label`, and fall back to `unit` for a record not yet moved;
448
+ `paperSections` carries `label` and `measure` onto the proof section.
449
+ `figureLabel` (`@luhtech/site-template/lib/figureLabel`) is the one rule.
450
+
376
451
  ## An animated mark replays when clicked (0.22.0)
377
452
 
378
453
  Every animated mark ran once on load and then sat on its last frame;
@@ -444,4 +519,12 @@ in `predev`/`prebuild` as before. Run both check bins in CI against every
444
519
 
445
520
  ## Peer dependencies
446
521
 
447
- `astro ^7.2`, `tailwindcss ^4`.
522
+ `astro ^7.2`, `tailwindcss ^4`, and `playwright >=1.40` as an optional peer
523
+ (only `luhtech-device-smoke` needs it).
524
+
525
+ Dependencies: `@lucide/astro` (icons), `@resvg/resvg-js` (`luhtech-sync-icons`)
526
+ and `@luhtech/figures` (figure records).
527
+
528
+ Deliverable records for this package's changes (`d-<date>-st-<slug>`) live in
529
+ `luh-tech/Ectropy-Business` `.dlp/deliverables/`; this repo carries no `.roadmap/`
530
+ or `.dlp/`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luhtech/site-template",
3
- "version": "0.22.0",
3
+ "version": "0.23.1",
4
4
  "description": "Shared Astro component library + content-instance contract for LuhTech venture marketing sites -- one template renders every site from content/page.schema.json + content/site.schema.json instances.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -23,6 +23,7 @@
23
23
  "exports": {
24
24
  "./content": "./src/content/index.ts",
25
25
  "./lib/paperLanding": "./src/lib/paperLanding.ts",
26
+ "./lib/figureLabel": "./src/lib/figureLabel.ts",
26
27
  "./layouts/SiteLayout.astro": "./src/layouts/SiteLayout.astro",
27
28
  "./components/*": "./src/components/*",
28
29
  "./components/sections/*": "./src/components/sections/*"
@@ -12,16 +12,21 @@ export interface Props {
12
12
  figure: {
13
13
  figureId: string;
14
14
  value: string;
15
+ label?: string;
16
+ measure?: Record<string, unknown>;
17
+ /** Deprecated by content/page 2.9.0; read only when label is absent. */
15
18
  unit?: string;
16
19
  provenance: { sourceRef: string; observedAt?: string };
17
20
  };
18
21
  }
22
+ import { figureLabel } from '../lib/figureLabel';
19
23
  const { figure } = Astro.props;
24
+ const label = figureLabel(figure);
20
25
  ---
21
26
  <div class="relative rounded-md border border-ink/15 bg-canvas p-5 overflow-hidden" id={figure.figureId}>
22
27
  <span class="absolute top-0 left-0 right-0 h-1 bg-accent-primary" aria-hidden="true"></span>
23
28
  <span class="font-display text-4xl font-bold leading-none block">{figure.value}</span>
24
- {figure.unit && <span class="text-sm text-ink/70 font-medium mt-2 block">{figure.unit}</span>}
29
+ {label && <span class="text-sm text-ink/70 font-medium mt-2 block">{label}</span>}
25
30
  <span class="text-xs text-ink/50 mt-4 pt-3 border-t border-ink/10 block">
26
31
  {figure.provenance.sourceRef}
27
32
  {figure.provenance.observedAt && ` (${figure.provenance.observedAt})`}
@@ -10,6 +10,9 @@
10
10
  // any real nodes[]/edges[] input -- not hand-tuned to one graph. Self-loops
11
11
  // (a node citing itself, e.g. "a decision supersedes a decision") are
12
12
  // excluded from layering and drawn as a small loop above the node instead.
13
+ // An edge that closes a longer cycle (operate -> design in a three-loop
14
+ // record) is found by src/lib/graphLayout.ts, kept out of layering, and drawn
15
+ // as a dashed return path under the graph -- see layerGraph's own note.
13
16
  export interface Node {
14
17
  id: string;
15
18
  label: string;
@@ -22,6 +25,7 @@ export interface Edge {
22
25
  to: string;
23
26
  label?: string;
24
27
  }
28
+ import { layerGraph } from '../../lib/graphLayout';
25
29
  export interface Props {
26
30
  diagramId: string;
27
31
  nodes: Node[];
@@ -31,27 +35,16 @@ export interface Props {
31
35
  const { diagramId, nodes, edges, class: className = 'w-full h-auto' } = Astro.props;
32
36
 
33
37
  const selfLoops = edges.filter((e) => e.from === e.to);
34
- const crossEdges = edges.filter((e) => e.from !== e.to);
35
38
 
36
- // Longest-path layering: layer(n) = 0 if no incoming cross-edge, else
37
- // 1 + max(layer(source)) over incoming edges. Iterative relaxation with a
38
- // bounded pass count (nodes.length) makes this safe even if the real data
39
- // ever contains a longer cycle than a self-loop -- it converges to a stable
40
- // (if imperfect) layering rather than looping forever.
41
- const layer = new Map<string, number>(nodes.map((n) => [n.id, 0]));
42
- for (let pass = 0; pass < nodes.length + 1; pass++) {
43
- let changed = false;
44
- for (const e of crossEdges) {
45
- const want = (layer.get(e.from) ?? 0) + 1;
46
- if (want > (layer.get(e.to) ?? 0)) {
47
- layer.set(e.to, want);
48
- changed = true;
49
- }
50
- }
51
- if (!changed) break;
52
- }
53
-
54
- const maxLayer = Math.max(...Array.from(layer.values()), 0);
39
+ // Layering and cycle-breaking: src/lib/graphLayout.ts (O(nodes + edges),
40
+ // deterministic). Forward edges are drawn left to right; an edge that closes a
41
+ // cycle is a return edge, drawn under the graph.
42
+ const { layer, maxLayer, backEdges } = layerGraph(
43
+ nodes.map((n) => n.id),
44
+ edges,
45
+ );
46
+ const crossEdges = edges.filter((e, i) => e.from !== e.to && !backEdges.has(i));
47
+ const returnEdges = edges.filter((_, i) => backEdges.has(i));
55
48
  const columns: Node[][] = Array.from({ length: maxLayer + 1 }, () => []);
56
49
  for (const n of nodes) columns[layer.get(n.id) ?? 0].push(n);
57
50
 
@@ -107,8 +100,19 @@ columns.forEach((col, ci) => {
107
100
  });
108
101
  });
109
102
 
110
- const width = PAD_X * 2 + (maxLayer + 1) * NODE_W + maxLayer * COL_GAP;
111
- const height = topPad + PAD + colHeight;
103
+ // A return edge's label runs under the whole graph, so the canvas is at least
104
+ // as wide as the longest one (same ~5.4px/char estimate as COL_GAP).
105
+ const longestReturnLabel = Math.max(0, ...returnEdges.filter((e) => e.label).map((e) => e.label!.length));
106
+ const width = Math.max(
107
+ PAD_X * 2 + (maxLayer + 1) * NODE_W + maxLayer * COL_GAP,
108
+ longestReturnLabel * 5.4 + PAD * 2,
109
+ );
110
+ // Each return edge runs along its own track under the nodes, its label just
111
+ // below the track; reserved only when the graph has one, so every acyclic
112
+ // diagram's canvas stays exactly as tight as before.
113
+ const RETURN_TRACK = 26;
114
+ const RETURN_ROOM = returnEdges.length > 0 ? returnEdges.length * RETURN_TRACK + 14 : 0;
115
+ const height = topPad + PAD + colHeight + RETURN_ROOM;
112
116
 
113
117
  // Cubic bezier from the right edge of `from` to the left edge of `to`
114
118
  // (forward, cross-column edges), or a vertical bow between two nodes in
@@ -141,6 +145,23 @@ const drawnCrossEdges = crossEdges
141
145
  })
142
146
  .filter((e): e is NonNullable<typeof e> => e !== null);
143
147
 
148
+ // A return edge leaves the bottom of its source, runs along its track and
149
+ // rises into the bottom of its target, with rounded corners.
150
+ const drawnReturnEdges = returnEdges
151
+ .map((e, ti) => {
152
+ const from = positions.get(e.from);
153
+ const to = positions.get(e.to);
154
+ if (!from || !to) return null;
155
+ const yRun = topPad + colHeight + 18 + ti * RETURN_TRACK;
156
+ const r = 8;
157
+ const dir = to.cx < from.cx ? -1 : 1;
158
+ const fb = from.y + NODE_H;
159
+ const tb = to.y + NODE_H;
160
+ const path = `M ${from.cx} ${fb} L ${from.cx} ${yRun - r} Q ${from.cx} ${yRun} ${from.cx + dir * r} ${yRun} L ${to.cx - dir * r} ${yRun} Q ${to.cx} ${yRun} ${to.cx} ${yRun - r} L ${to.cx} ${tb + 2}`;
161
+ return { ...e, path, lx: (from.cx + to.cx) / 2, ly: yRun + 12 };
162
+ })
163
+ .filter((e): e is NonNullable<typeof e> => e !== null);
164
+
144
165
  const drawnSelfLoops = selfLoops
145
166
  .map((e) => {
146
167
  const at = positions.get(e.from);
@@ -188,6 +209,15 @@ const ariaLabel = `Connection graph: ${nodes.length} nodes -- ${nodes.map((n) =>
188
209
  </g>
189
210
  ))}
190
211
 
212
+ {drawnReturnEdges.map((e) => (
213
+ <g class="text-ink/50">
214
+ <path d={e.path} fill="none" stroke="currentColor" stroke-width="1.25" stroke-opacity="0.4" stroke-dasharray="4 3" marker-end={`url(#${markerId})`} />
215
+ {e.label && (
216
+ <text x={e.lx} y={e.ly} text-anchor="middle" font-family="JetBrains Mono, monospace" font-size="9" fill="currentColor" fill-opacity="0.65">{e.label}</text>
217
+ )}
218
+ </g>
219
+ ))}
220
+
191
221
  {drawnSelfLoops.map((e) => (
192
222
  <g class="text-ink/50">
193
223
  <path d={e.path} fill="none" stroke="currentColor" stroke-width="1.25" stroke-opacity="0.4" marker-end={`url(#${markerId})`} />
@@ -2,6 +2,7 @@
2
2
  // sectionKind: sources -- citations for every figure used on the page,
3
3
  // each figure's provenance.sourceRef rendered as a full citation.
4
4
  import SectionHeading from '../SectionHeading.astro';
5
+ import { figureLabel } from '../../lib/figureLabel';
5
6
 
6
7
  export interface Props { section: any }
7
8
  const { section } = Astro.props;
@@ -11,7 +12,7 @@ const { section } = Astro.props;
11
12
  <ol class="space-y-2 text-sm text-ink/70">
12
13
  {section.figures?.map((f: any) => (
13
14
  <li>
14
- <strong>{f.value}{f.unit ? ` ${f.unit}` : ''}</strong> — {f.provenance.sourceRef}
15
+ <strong>{f.value}{figureLabel(f) ? ` ${figureLabel(f)}` : ''}</strong> — {f.provenance.sourceRef}
15
16
  {f.provenance.observedAt && ` (observed ${f.provenance.observedAt})`}
16
17
  </li>
17
18
  ))}
@@ -0,0 +1,13 @@
1
+ // A figure's caption under its value: content/page 2.9.0 and whitepaper 1.4.0
2
+ // give a figure a `label` (what the value is) and a structured `measure`
3
+ // (money, quantity, fraction or date by reference to the open standard's
4
+ // units definitions), and deprecate `unit`, a free-text label that carried
5
+ // both meanings. A record that still carries only `unit` renders as before.
6
+ export interface LabelledFigure {
7
+ label?: string;
8
+ unit?: string;
9
+ }
10
+
11
+ export function figureLabel(figure: LabelledFigure): string | undefined {
12
+ return figure.label ?? figure.unit;
13
+ }
@@ -0,0 +1,96 @@
1
+ // Layering for ConnectionGraph: which column each node sits in, and which
2
+ // edges close a cycle.
3
+ //
4
+ // A layered (Sugiyama-style) layout needs an acyclic graph. Real records are
5
+ // not always one: a loop such as design -> release -> construct -> operate ->
6
+ // design closes back on its start. Layering such a graph by longest-path
7
+ // relaxation pushes every node in the cycle one column further right on each
8
+ // pass, so the canvas grows with the pass count (found live: desconops.org's
9
+ // three-loops figure, 5 nodes, laid out 13000 units wide).
10
+ //
11
+ // So the cycle is broken first, the standard way: a depth-first search in node
12
+ // order marks each edge that reaches a node still on the search stack as a back
13
+ // edge. The remaining forward edges form a DAG, layered by longest path in one
14
+ // topological pass. Back edges are not lost: the component draws each one as a
15
+ // return path under the graph. Both passes are O(nodes + edges), and the result
16
+ // depends only on node and edge order, so the same record always draws the same.
17
+ // A graph with no cycle has no back edges and lays out exactly as before.
18
+
19
+ export interface LayoutEdge {
20
+ from: string;
21
+ to: string;
22
+ }
23
+
24
+ export interface GraphLayering {
25
+ /** column index per node id, 0 for a node with no forward incoming edge */
26
+ layer: Map<string, number>;
27
+ /** the highest column index */
28
+ maxLayer: number;
29
+ /** indexes into the edges array of the edges that close a cycle */
30
+ backEdges: Set<number>;
31
+ }
32
+
33
+ export function layerGraph(nodeIds: readonly string[], edges: readonly LayoutEdge[]): GraphLayering {
34
+ const known = new Set(nodeIds);
35
+ const out = new Map<string, number[]>(nodeIds.map((id) => [id, []]));
36
+ edges.forEach((e, i) => {
37
+ if (e.from !== e.to && known.has(e.from) && known.has(e.to)) out.get(e.from)!.push(i);
38
+ });
39
+
40
+ // Depth-first search, iterative so a long chain cannot overflow the stack.
41
+ // Roots are taken in node order: nodes with no incoming edge first, so a
42
+ // graph's natural start stays in column 0, then any node not yet reached.
43
+ const hasIncoming = new Set<string>();
44
+ for (const e of edges) if (e.from !== e.to && known.has(e.from)) hasIncoming.add(e.to);
45
+ const roots = [...nodeIds.filter((id) => !hasIncoming.has(id)), ...nodeIds];
46
+
47
+ const state = new Map<string, 0 | 1 | 2>(); // 0 unseen, 1 on stack, 2 done
48
+ const backEdges = new Set<number>();
49
+ for (const root of roots) {
50
+ if (state.get(root)) continue;
51
+ const stack: Array<{ id: string; next: number }> = [{ id: root, next: 0 }];
52
+ state.set(root, 1);
53
+ while (stack.length) {
54
+ const top = stack[stack.length - 1];
55
+ const outs = out.get(top.id)!;
56
+ if (top.next < outs.length) {
57
+ const ei = outs[top.next++];
58
+ const to = edges[ei].to;
59
+ const s = state.get(to) ?? 0;
60
+ if (s === 1) backEdges.add(ei);
61
+ else if (s === 0) {
62
+ state.set(to, 1);
63
+ stack.push({ id: to, next: 0 });
64
+ }
65
+ } else {
66
+ state.set(top.id, 2);
67
+ stack.pop();
68
+ }
69
+ }
70
+ }
71
+
72
+ // Longest-path layering over the forward edges, in topological order (Kahn).
73
+ const indeg = new Map<string, number>(nodeIds.map((id) => [id, 0]));
74
+ const fwd = new Map<string, string[]>(nodeIds.map((id) => [id, []]));
75
+ out.forEach((list, from) => {
76
+ for (const ei of list) {
77
+ if (backEdges.has(ei)) continue;
78
+ fwd.get(from)!.push(edges[ei].to);
79
+ indeg.set(edges[ei].to, indeg.get(edges[ei].to)! + 1);
80
+ }
81
+ });
82
+ const layer = new Map<string, number>(nodeIds.map((id) => [id, 0]));
83
+ const queue = nodeIds.filter((id) => indeg.get(id) === 0);
84
+ for (let qi = 0; qi < queue.length; qi++) {
85
+ const id = queue[qi];
86
+ for (const to of fwd.get(id)!) {
87
+ layer.set(to, Math.max(layer.get(to)!, layer.get(id)! + 1));
88
+ indeg.set(to, indeg.get(to)! - 1);
89
+ if (indeg.get(to) === 0) queue.push(to);
90
+ }
91
+ }
92
+
93
+ let maxLayer = 0;
94
+ for (const l of layer.values()) if (l > maxLayer) maxLayer = l;
95
+ return { layer, maxLayer, backEdges };
96
+ }
@@ -111,6 +111,9 @@ export function feedbackMessage(status: number, error?: string): string {
111
111
  interface PaperFigure {
112
112
  figureId: string;
113
113
  value: string;
114
+ label?: string;
115
+ measure?: Record<string, unknown>;
116
+ /** Deprecated by whitepaper 1.4.0; read only when label is absent. */
114
117
  unit?: string;
115
118
  caption?: string;
116
119
  estimate?: boolean;
@@ -173,6 +176,8 @@ export function paperSections(paper: PaperRecord, slug: string) {
173
176
  figures: open.map((f) => ({
174
177
  figureId: f.figureId,
175
178
  value: f.estimate && !/estimate/i.test(f.value) ? `${f.value} (estimate)` : f.value,
179
+ ...(f.label ? { label: f.label } : {}),
180
+ ...(f.measure ? { measure: f.measure } : {}),
176
181
  ...(f.unit ? { unit: f.unit } : {}),
177
182
  provenance: f.provenance,
178
183
  })),