feat(kvb-check-score): score journal, backfill and per-metric burndown overlays (006)

score.py names the Cost and Time metrics Tokens and Velocity from one label file and appends every scored block to a score journal in the council root. backfill.py rebuilds that journal from commit messages with its own label mapping, deterministic and idempotent, so another host can import its history. The hub serves the journal, and the Gantt burndown draws each metric as its own overlay on a right 0-100 % axis, every overlay off by default and switched by legend chips whose state the view store keeps.

🎯 Fix: 90 %
💥 Break: 5 %
💸 Cost: 100 %
⏱️ Time: 100 %
🛡️ Security: 100 %
🏆 Score: 86
🚦 Gate: ✅ 90/5, cost and time <= 100, security 100 %

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kevin Veen-BirkenbachandClaude Opus 5.5 committed 2026-11-13 12:32:54 +00:00
1 parent 3418738993
commit 5b55c39b64
30 files changed
+1806 -142

No files matched your search

+39 -1
View File
@@ -262,6 +262,44 @@ const Plan = (() => {
return {fixed: reachable(fixed), growing: found.forecast};
}
const branchOf = (row) => (row.branch !== "-" ? row.branch : row.worktree_branch);
/**
* @param rows - the burndown scope's task rows with branch ("-" for none) and worktree_branch ("" for none).
* @param journal - /api/scores rows {time, branch, values: {metric key: number or null}}.
* @param keys - the metric keys switched on, in the label file's order.
* @param span - {from, to} in epoch seconds.
* @returns one {key, points: [{t, value, branch}]} per key, in keys order: the journal rows of a branch of the
* scope's rows within span whose value for the key is a number, in time order.
*/
function overlaySeries(rows, journal, keys, span) {
const branches = new Set(rows.map(branchOf).filter(Boolean));
const inside = journal.filter((entry) => branches.has(entry.branch) && entry.time >= span.from && entry.time <= span.to).sort((a, b) => a.time - b.time);
return keys.map((key) => ({
key, points: inside.filter((entry) => Number.isFinite(entry.values[key])).map((entry) => ({t: entry.time, value: entry.values[key], branch: entry.branch})),
}));
}
/**
* @param labels - the labels of /api/scores: {metrics: {key: {emoji, label}}}, or anything else.
* @returns {key: "<emoji> <label>"} in the file's order for the entries with a string emoji and label; null when
* none has both or labels is no such object.
*/
function overlayLabels(labels) {
const metrics = labels && typeof labels === "object" ? labels.metrics : null;
if (!metrics || typeof metrics !== "object" || Array.isArray(metrics)) {
return null;
}
const kept = Object.entries(metrics).filter(([, metric]) => metric && typeof metric.emoji === "string" && typeof metric.label === "string");
return kept.length ? Object.fromEntries(kept.map(([key, metric]) => [key, `${metric.emoji} ${metric.label}`])) : null;
}
/**
* @param series - overlaySeries().
* @returns the top of the right axis: 100, or the largest value when one exceeds it.
*/
const overlayTop = (series) => Math.max(100, ...series.flatMap((found) => found.points.map((point) => point.value)));
const KEYS = {
prio: () => null,
wsjf: (row) => (row.wsjf ? row.wsjf.score : null),
@@ -294,7 +332,7 @@ const Plan = (() => {
return keyed.map((entry) => entry.row);
}
return {FORECASTS, ESTIMATIONS, TRENDS, SORTS, SERIES, TRENDED, STATUS_ORDER, STALE_DAYS, median, medians, forecastLength, bars, etas, stale, scoped, burn, steps, trend, finishes, lineAt, sortRows};
return {FORECASTS, ESTIMATIONS, TRENDS, SORTS, SERIES, TRENDED, STATUS_ORDER, STALE_DAYS, median, medians, forecastLength, bars, etas, stale, scoped, burn, steps, trend, finishes, lineAt, overlaySeries, overlayLabels, overlayTop, sortRows};
})();
if (typeof module === "object" && module.exports) {
module.exports = Plan;