Files
state-hub/dashboard/src/todo.md
tegwick fc87e26b4b feat(gems): three-pass schema migration aligning state-hub with GEMS
Implements CUST-WP-0007. Resolves inconsistencies I-1, I-2, I-5, I-6
identified in the GEMS audit (GenericEntityModellingSystem.md).

Pass 1 (e1f2a3b4c5d6): domain_id FK on extension_points and
technical_debt (replaces raw string column); repo_id FK on contributions.
Fixes domain-filtering bugs in EP/TD dashboard pages.

Pass 2 (f2a3b4c5d6e7): repo_id nullable FK on workstreams, aligning
the GEMS primary attachment with ADR-001 (repo > topic). Dashboard
pages updated to prefer repo->domain over topic->domain.

Pass 3 (a3b4c5d6e7f8): SBOMSnapshot container entity (GEMS Complex
between Repository and SBOMEntry). Ingest is now additive — each call
creates a new snapshot; history is retained. List/report endpoints
filter to latest snapshot per repo via _latest_snapshot_ids_subquery().
New endpoints: GET /sbom/snapshots/, GET /sbom/snapshots/{id}/.
Dashboard gains a Snapshot History section.

Also adds GEMS analysis artefacts: wiki/GEMS-StateHub-TypeRegistry.md,
wiki/GEMS-StateHub-SWOT.md, workplans/CUST-WP-0006 (analysis),
workplans/CUST-WP-0007 (migration, now completed).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-02 23:39:17 +01:00

10 KiB

title
title
Todo
const API  = "http://127.0.0.1:8000";
const POLL = 15_000;
const THIS_REPO = "the-custodian";
// Live poll: tasks + workstreams + topics + contributions
const todoState = (async function*() {
  while (true) {
    let tasks = [], contribs = [], wsMap = {}, ok = false;
    try {
      const [rt, rw, rto, rr, rc] = await Promise.all([
        fetch(`${API}/tasks/?limit=500`),
        fetch(`${API}/workstreams/`),
        fetch(`${API}/topics/`),
        fetch(`${API}/repos/`),
        fetch(`${API}/contributions/`),
      ]);
      ok = rt.ok && rw.ok && rto.ok && rr.ok && rc.ok;
      if (ok) {
        const [taskList, wsList, topicList, repoList, contribList] = await Promise.all([
          rt.json(), rw.json(), rto.json(), rr.json(), rc.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,
          domain: repoMap[w.repo_id]?.domain_slug ?? topicMap[w.topic_id]?.domain_slug ?? "unknown",
        }]));
        tasks   = taskList.map(t => ({
          ...t,
          workstream_title: wsMap[t.workstream_id]?.title ?? "—",
          domain:           wsMap[t.workstream_id]?.domain ?? "unknown",
        }));
        contribs = contribList;
      }
    } catch {}
    yield {tasks, contribs, ok, ts: new Date()};
    await new Promise(res => setTimeout(res, POLL));
  }
})();
const tasks   = todoState.tasks   ?? [];
const contribs = todoState.contribs ?? [];
const _ok      = todoState.ok      ?? false;
const _ts      = todoState.ts;
// ── Classify tasks ────────────────────────────────────────────────────────────
const OPEN_STATUSES = new Set(["todo", "in_progress", "blocked"]);

// Internal: custodian domain, open, no [repo:] routing prefix
const internal = tasks.filter(t =>
  OPEN_STATUSES.has(t.status) &&
  t.domain === "custodian" &&
  !t.title.includes("[repo:")
);

// Ecosystem inbound: tasks routed to this repo from any domain
const ecosystem = tasks.filter(t =>
  OPEN_STATUSES.has(t.status) &&
  t.title.toLowerCase().includes(`[repo:${THIS_REPO}]`)
);

// Third-party: open contributions (outbound work for upstream repos)
const thirdParty = contribs.filter(c =>
  ["draft", "submitted", "acknowledged"].includes(c.status)
);

Todo

import {injectTocTop} from "./components/toc-sidebar.js";
import {withDocHelp}  from "./components/doc-overlay.js";

// ── KPI sidebar card ──────────────────────────────────────────────────────────
const _kpiBox = html`<div class="kpi-infobox">
  <div class="kpi-infobox-title">Todo Summary</div>
  <div class="kpi-row">
    <span class="kpi-row-label">internal</span>
    <div class="kpi-row-right">
      <div class="kpi-row-value">${internal.length}</div>
    </div>
  </div>
  <div class="kpi-row">
    <span class="kpi-row-label">ecosystem (inbound)</span>
    <div class="kpi-row-right">
      <div class="kpi-row-value">${ecosystem.length}</div>
    </div>
  </div>
  <div class="kpi-row">
    <span class="kpi-row-label">third-party (outbound)</span>
    <div class="kpi-row-right">
      <div class="kpi-row-value">${thirdParty.length}</div>
    </div>
  </div>
</div>`;

// ── Live indicator ────────────────────────────────────────────────────────────
const _liveEl = html`<div class="live-indicator">
  <span style="color:${_ok ? 'var(--theme-foreground-focus)' : 'red'}">●</span>
  ${_ok
    ? `Live · updated ${_ts?.toLocaleTimeString()}`
    : html`<span style="color:red">Offline — run: <code>make api</code></span>`}
</div>`;
withDocHelp(_liveEl, "/docs/live-data");

injectTocTop("todo-kpi-box", _kpiBox);
injectTocTop("live-indicator", _liveEl);

const _h1 = document.querySelector("#observablehq-main h1");
if (_h1) { _h1.style.position = "relative"; withDocHelp(_h1, "/docs/todo"); }

Internal

Work fully addressable within this repo. Open tasks in custodian workstreams without a cross-repo routing prefix.

const PRIORITY_ORDER = {critical: 0, high: 1, medium: 2, low: 3};
const STATUS_ORDER   = {blocked: 0, in_progress: 1, todo: 2};

function sortTasks(arr) {
  return [...arr].sort((a, b) => {
    const sd = (STATUS_ORDER[a.status] ?? 9) - (STATUS_ORDER[b.status] ?? 9);
    if (sd !== 0) return sd;
    return (PRIORITY_ORDER[a.priority] ?? 9) - (PRIORITY_ORDER[b.priority] ?? 9);
  });
}

function renderTaskList(arr) {
  if (arr.length === 0) return html`<p class="dim">No open todos in this category. ✓</p>`;
  return html`<div class="task-list">${sortTasks(arr).map(t => html`
    <div class="task-item status-${t.status}">
      <div class="task-item-header">
        <span class="task-badge task-priority-${t.priority}">${t.priority}</span>
        <span class="task-status-chip status-chip-${t.status}">${t.status.replace("_", " ")}</span>
        <span class="task-context task-ws-name">${t.workstream_title}</span>
        ${t.assignee ? html`<span class="task-assignee">@${t.assignee}</span>` : ""}
      </div>
      <div class="task-title">${t.title}</div>
      ${t.blocking_reason ? html`<div class="task-blocking-reason">⊘ ${t.blocking_reason}</div>` : ""}
    </div>
  `)}</div>`;
}

display(renderTaskList(internal));

Ecosystem

Inbound tasks routed to this repo by other agents via the [repo:${THIS_REPO}] prefix convention.

display(renderTaskList(ecosystem));

Third-Party

Outbound work for upstream repos — open contribution artifacts (bug reports, feature requests, extension points, upstream PRs).

const TYPE_LABEL = {br: "Bug Report", fr: "Feature Request", ep: "Extension Point", upr: "Upstream PR"};
const STATUS_COLOR_C = {draft: "#94a3b8", submitted: "#3b82f6", acknowledged: "#f59e0b"};

if (thirdParty.length === 0) {
  display(html`<p class="dim">No open outbound contributions. ✓</p>`);
} else {
  display(html`<div class="task-list">${thirdParty.map(c => html`
    <div class="task-item">
      <div class="task-item-header">
        <span class="task-badge" style="background:#f1f5f9;color:#475569">${TYPE_LABEL[c.type] ?? c.type}</span>
        <span class="task-status-chip" style="background:${STATUS_COLOR_C[c.status] ?? '#ccc'}20;color:${STATUS_COLOR_C[c.status] ?? '#666'}">${c.status}</span>
        ${c.target_org  ? html`<span class="task-context">${c.target_org}</span>` : ""}
        ${c.target_repo ? html`<span class="task-context task-ws-name">${c.target_repo}</span>` : ""}
      </div>
      <div class="task-title">${c.title}</div>
      ${c.body_path ? html`<div class="task-blocking-reason" style="background:#f0fdf4;color:#166534">↗ ${c.body_path}</div>` : ""}
    </div>
  `)}</div>`);
}
<style> /* ── Live indicator ───────────────────────────────────────────────────────── */ .live-indicator { font-size: 0.8rem; color: gray; position: relative; padding: 0.55rem 1.8rem 0.55rem 0.7rem; margin-bottom: 0.75rem; } /* ── KPI infobox ──────────────────────────────────────────────────────────── */ .kpi-infobox { background: var(--theme-background-alt, #f9f9f9); border: 1px solid var(--theme-foreground-faint, #e0e0e0); border-radius: 10px; padding: 0.75rem 1rem; position: relative; box-shadow: 0 1px 6px rgba(0,0,0,0.07); margin-bottom: 1.25rem; } .kpi-infobox-title { font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--theme-foreground-muted, #888); margin-bottom: 0.55rem; } .kpi-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 0.3rem 0; } .kpi-row + .kpi-row { border-top: 1px solid var(--theme-foreground-faint, #eee); } .kpi-row-label { font-size: 0.8rem; color: var(--theme-foreground-muted, #666); white-space: nowrap; } .kpi-row-right { text-align: right; } .kpi-row-value { font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; } /* ── Task list ────────────────────────────────────────────────────────────── */ .task-list { display: flex; flex-direction: column; gap: 0.5rem; } .task-item { border-left: 3px solid var(--theme-foreground-faint, #ccc); border-radius: 0 6px 6px 0; background: var(--theme-background-alt); padding: 0.65rem 0.9rem; } .task-item.status-blocked { border-left-color: #ef4444; } .task-item.status-in_progress { border-left-color: #3b82f6; } .task-item.status-todo { border-left-color: #94a3b8; } .task-item-header { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; margin-bottom: 0.3rem; font-size: 0.75rem; } .task-badge { display: inline-block; padding: 0.1rem 0.45rem; border-radius: 10px; font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; } .task-priority-critical { background: #fee2e2; color: #991b1b; } .task-priority-high { background: #ffedd5; color: #9a3412; } .task-priority-medium { background: #dbeafe; color: #1e40af; } .task-priority-low { background: #f1f5f9; color: #475569; } .task-status-chip { display: inline-block; padding: 0.1rem 0.45rem; border-radius: 10px; font-size: 0.7rem; font-weight: 500; } .status-chip-blocked { background: #fee2e2; color: #991b1b; } .status-chip-in_progress { background: #dbeafe; color: #1e40af; } .status-chip-todo { background: #f1f5f9; color: #475569; } .task-context { color: var(--theme-foreground-muted, #666); } .task-ws-name { font-style: italic; } .task-assignee { color: var(--theme-foreground-muted, #888); } .task-title { font-weight: 600; font-size: 0.95rem; margin-bottom: 0.15rem; } .task-blocking-reason { font-size: 0.8rem; color: #b45309; background: #fef3c7; border-radius: 4px; padding: 0.2rem 0.5rem; margin-top: 0.25rem; } .dim { color: gray; font-style: italic; } </style>