--- title: Dependencies --- ```js import {API, POLL} from "./components/config.js"; ``` ```js // Fetch workstreams + topics + summary (summary carries dep edges on open_workstreams) const depState = (async function*() { while (true) { let wsMap = {}, edges = [], ok = false; try { const [rw, rto, rr, rs] = await Promise.all([ fetch(`${API}/workstreams/`), fetch(`${API}/topics/`), fetch(`${API}/repos/`), fetch(`${API}/state/summary`), ]); ok = rw.ok && rto.ok && rr.ok && rs.ok; if (ok) { const [wsList, topicList, repoList, summary] = await Promise.all([ rw.json(), rto.json(), rr.json(), rs.json(), ]); const topicMap = Object.fromEntries(topicList.map(t => [t.id, t])); const repoMap = Object.fromEntries(repoList.map(r => [r.id, r])); wsMap = Object.fromEntries(wsList.map(w => [w.id, { ...w, // Prefer repo→domain (GEMS primary); fall back to topic→domain domain: repoMap[w.repo_id]?.domain_slug ?? topicMap[w.topic_id]?.domain_slug ?? "unknown", }])); // Build directed edge list from open_workstreams depends_on arrays for (const ow of (summary.open_workstreams ?? [])) { for (const depId of (ow.depends_on ?? [])) { edges.push({from_id: ow.id, to_id: depId}); } } } } catch {} yield {wsMap, edges, ok, ts: new Date()}; await new Promise(res => setTimeout(res, POLL)); } })(); ``` ```js const wsMap = depState.wsMap ?? {}; const edges = depState.edges ?? []; const _ok = depState.ok ?? false; const _ts = depState.ts; ``` # Dependencies ```js import {injectTocTop} from "./components/toc-sidebar.js"; import {withDocHelp} from "./components/doc-overlay.js"; // ── KPI sidebar card ────────────────────────────────────────────────────────── const _wsWithDeps = new Set([...edges.map(e => e.from_id), ...edges.map(e => e.to_id)]); const _kpiBox = html`
Dependencies
edges
${edges.length}
workstreams involved
${_wsWithDeps.size}
`; const _liveEl = html`
${_ok ? `Live · updated ${_ts?.toLocaleTimeString()}` : html`Offline — run: make api`}
`; const _h1 = document.querySelector("#observablehq-main h1"); if (_h1) { _h1.style.position = "relative"; withDocHelp(_h1, "/docs/dependencies"); } injectTocTop("dep-kpi-box", _kpiBox); injectTocTop("live-indicator", _liveEl); ``` Directed edges between active workstreams. An edge **A → B** means A cannot fully proceed until B reaches a satisfactory state. ```js if (edges.length === 0) { display(html`

No dependency edges registered.

`); } else { const rows = edges.map(e => { const from = wsMap[e.from_id]; const to = wsMap[e.to_id]; return { from_domain: from?.domain ?? "—", from_title: from?.title ?? e.from_id, from_status: from?.status ?? "—", to_domain: to?.domain ?? "—", to_title: to?.title ?? e.to_id, to_status: to?.status ?? "—", }; }); display(html`${rows.map(r => html` `)}
Depends-on domain Depends-on workstream Blocked-by domain Blocked-by workstream Status
${r.from_domain} ${r.from_title} ${r.to_domain} ${r.to_title} ${r.to_status}
`); } ```