TypeScript
Lead the dashboard with user-decision metrics (consistency, $/solved)
Claude687626d182d0
diff --git a/NOTES.md b/NOTES.mdindex 3bb4473..a001bc1 100644--- a/NOTES.md+++ b/NOTES.md@@ -2,6 +2,19 @@비전문 감시자용 기록. 용어 최소화, AS-IS → TO-BE.+## 2026-06-30 (2) — 사용자 관점 지표(일관성·해결당 비용)++**AS-IS**: 모든 지표를 동급으로 나열 — 서브에이전트·툴콜·토큰 같은 *진단* 지표가 헤드라인을 차지하고,+정작 사용자가 고를 때 보는 "매번 되는가(일관성)"와 "해결 하나당 실제 얼마(=비용÷성공률)"는 없었다.++**TO-BE**: 지표를 **결정(headline) vs 진단(drill-down)** 으로 분리.+- **신규 ① 일관성(k/n)** — 다수결 정확도가 가리는 플레이키니스. 런 단위 통과율 %. (예: 정확도 100% 인데+ 일관성 89% → 사실은 9번 중 1번 실패하는 조합.) 기존 per-run 데이터에서 파생(신규 수집 0).+- **신규 ② 해결당 기대비용 $/solved** = 실행당 비용 ÷ 실행당 통과율 — 재시도까지 감안한 정직한 단가.+- **관점에 tier 부여**: 결정(정확도·일관성·$/solved·시간·품질)만 **승자 스트립/평행좌표/순위막대**에 노출.+ 진단(원가·토큰·툴콜·서브에이전트)은 Detail 표로 강등. (정렬 불변키 `subagentCount→…` 는 보존.)+- Detail: 정확도 표에 일관성 열, 효율 표에 $/solved 열 추가.+## 2026-06-30 — report.html 전면 재설계(결정 대시보드)**AS-IS**: 리포트가 사실상 "표 8개 + 작은 산점도 1개"의 스크롤 더미였다 — 한눈에 답이 안 보이고,diff --git a/src/i18n.ts b/src/i18n.tsindex 45406a5..7436c3a 100644--- a/src/i18n.ts+++ b/src/i18n.ts@@ -70,6 +70,8 @@ export const STRINGS: Record<string, Entry> = {// perspectivespersp_accuracy: { en: "Highest accuracy", kr: "최고 정확도" },+ persp_consistency: { en: "Most consistent", kr: "최고 일관성" },+ persp_effcost: { en: "Lowest $/solved", kr: "최저 해결당 비용" },persp_cost: { en: "Lowest cost", kr: "최저 비용" },persp_tokens: { en: "Fewest tokens", kr: "최소 토큰" },persp_time: { en: "Fastest", kr: "최단 시간" },@@ -92,6 +94,12 @@ export const STRINGS: Record<string, Entry> = {// misc columnscol_combo: { en: "combo", kr: "조합" },col_acc: { en: "accuracy", kr: "정확도" },+ col_consistency: { en: "consistency", kr: "일관성" },+ col_effcost: { en: "$/solved", kr: "해결당 비용" },+ effcost_note: {+ en: "expected $ to land one passing result, accounting for retries (cost ÷ per-run pass rate)",+ kr: "통과 결과 1개를 얻기까지의 기대 비용 — 재시도 포함(실행당 비용 ÷ 실행당 통과율)",+ },col_subagents: { en: "subagents", kr: "서브에이전트" },col_tokens: { en: "total tok", kr: "총 토큰" },col_cost: { en: "cost", kr: "비용" },diff --git a/src/metrics.ts b/src/metrics.tsindex a9aa7c9..0327ef8 100644--- a/src/metrics.ts+++ b/src/metrics.ts@@ -26,6 +26,10 @@ export interface ComboMetrics {mcpCalls: number;numTurns: number;qualityScore: number | null;+ // ── 사용자 관점 파생 지표 ──+ runsPassed?: number; // resolved===true 인 run 수 (k of k/n)+ consistency?: number; // 런 단위 통과율 % = 100*runsPassed/runCount (일관성/플레이키니스)+ effectiveCostUsd?: number | null; // 해결당 기대비용 = costUsd / (accuracyAtK/100); 0% 면 nullperTask: Record<string, { passRate: number; resolved: boolean }>;}@@ -85,6 +89,12 @@ export function aggregateCombo(comboId: string, results: RunResult[]): ComboMetrconst acc = computeAccuracy(results);const cost = aggregateCost(results);const quals = results.map((r) => r.qualityScore).filter((q): q is number => q !== null);+ const runsPassed = results.filter((r) => r.resolved === true).length;+ // 해결당 기대비용 = 1회 실행 비용 / 1회 성공확률(=accuracyAtK). 재시도까지 감안한 정직한 단가.+ const effectiveCostUsd =+ cost.costUsd !== null && acc.accuracyAtK > 0+ ? round4(cost.costUsd / (acc.accuracyAtK / 100))+ : null;return {comboId,runCount: results.length,@@ -106,6 +116,9 @@ export function aggregateCombo(comboId: string, results: RunResult[]): ComboMetrmcpCalls: round4(mean(results.map((r) => r.mcpCalls))),numTurns: round4(mean(results.map((r) => r.numTurns))),qualityScore: quals.length ? round4(mean(quals)) : null,+ runsPassed,+ consistency: results.length ? round4((100 * runsPassed) / results.length) : 0,+ effectiveCostUsd,};}@@ -132,20 +145,31 @@ export function sortCombos(metrics: ComboMetrics[]): ComboMetrics[] {// ── 관점별 최적 ─────────────────────────────────────────type Dir = "max" | "min";+type Tier = "decision" | "diagnostic";interface Perspective {key: string; // i18n persp_*metric: keyof ComboMetrics;dir: Dir;+ tier: Tier;requiresQuality?: boolean;}+// decision = 사용자가 실제로 고르는 기준(헤드라인). diagnostic = "왜"를 설명(드릴다운).const PERSPECTIVES: Perspective[] = [- { key: "persp_accuracy", metric: "accuracy", dir: "max" },- { key: "persp_cost", metric: "costUsd", dir: "min" },- { key: "persp_tokens", metric: "totalTokens", dir: "min" },- { key: "persp_time", metric: "wallTimeMs", dir: "min" },- { key: "persp_toolcalls", metric: "toolCalls", dir: "min" },- { key: "persp_subagents", metric: "subagentCount", dir: "min" },- { key: "persp_quality", metric: "qualityScore", dir: "max", requiresQuality: true },+ { key: "persp_accuracy", metric: "accuracy", dir: "max", tier: "decision" },+ { key: "persp_consistency", metric: "consistency", dir: "max", tier: "decision" },+ { key: "persp_effcost", metric: "effectiveCostUsd", dir: "min", tier: "decision" },+ { key: "persp_time", metric: "wallTimeMs", dir: "min", tier: "decision" },+ {+ key: "persp_quality",+ metric: "qualityScore",+ dir: "max",+ tier: "decision",+ requiresQuality: true,+ },+ { key: "persp_cost", metric: "costUsd", dir: "min", tier: "diagnostic" },+ { key: "persp_tokens", metric: "totalTokens", dir: "min", tier: "diagnostic" },+ { key: "persp_toolcalls", metric: "toolCalls", dir: "min", tier: "diagnostic" },+ { key: "persp_subagents", metric: "subagentCount", dir: "min", tier: "diagnostic" },];export interface PerspectiveBest {@@ -159,10 +183,11 @@ export interface PerspectiveBest {export function bestByPerspectiveDetailed(metrics: ComboMetrics[],lang: Lang,- opts?: { judge?: boolean },+ opts?: { judge?: boolean; tier?: Tier },): PerspectiveBest[] {const out: PerspectiveBest[] = [];for (const p of PERSPECTIVES) {+ if (opts?.tier && p.tier !== opts.tier) continue; // 헤드라인은 decision 만if (p.requiresQuality && !opts?.judge) continue; // judge off → 품질 관점 숨김// 값 None/미수집 조합은 제외const candidates = metrics.filter((m) => {diff --git a/src/report.ts b/src/report.tsindex 20b9880..05125f3 100644--- a/src/report.ts+++ b/src/report.ts@@ -61,10 +61,14 @@ function fmtMetric(metric: keyof ComboMetrics, v: number): string {case "costUsd":case "estimatedCostUsd":return `$${v.toFixed(4)}`;+ case "effectiveCostUsd":+ return `$${v.toFixed(4)}`;case "wallTimeMs":return `${(v / 1000).toFixed(1)}s`;case "totalTokens":return v.toLocaleString("en-US");+ case "consistency":+ return `${v.toFixed(0)}%`;case "qualityScore":return `${v.toFixed(1)}/10`;default:@@ -95,12 +99,22 @@ interface Axis {nullable?: boolean;fmt: (v: number) => string;}+/**+ * 결정 축(사용자가 실제로 고르는 기준). 진단 지표(토큰·툴콜·서브에이전트)는 Detail 표로 강등.+ * 데이터가 없는 축(예: judge off → quality, 비용 미수집 → $/solved)은 호출부에서 자동 제외.+ */function axes(lang: Lang): Axis[] {return [{ key: "accuracy", label: tr(lang, "col_acc"), dir: "max", fmt: (v) => `${v.toFixed(0)}%` },{- key: "costUsd",- label: tr(lang, "col_cost"),+ key: "consistency",+ label: tr(lang, "col_consistency"),+ dir: "max",+ fmt: (v) => `${v.toFixed(0)}%`,+ },+ {+ key: "effectiveCostUsd",+ label: tr(lang, "col_effcost"),dir: "min",nullable: true,fmt: (v) => `$${v.toFixed(4)}`,@@ -112,19 +126,18 @@ function axes(lang: Lang): Axis[] {fmt: (v) => `${(v / 1000).toFixed(1)}s`,},{- key: "totalTokens",- label: tr(lang, "col_tokens"),- dir: "min",- fmt: (v) => `${Math.round(v / 1000)}k`,- },- {- key: "subagentCount",- label: tr(lang, "col_subagents"),- dir: "min",- fmt: (v) => v.toFixed(1),+ key: "qualityScore",+ label: tr(lang, "persp_quality"),+ dir: "max",+ nullable: true,+ fmt: (v) => `${v.toFixed(1)}/10`,},];}+/** 데이터가 있는(범위가 잡히는) 축만. quality(judge off)·$/solved(비용 미수집)는 자동 탈락. */+function liveAxes(metrics: ComboMetrics[], lang: Lang): Axis[] {+ return axes(lang).filter((a) => axisRange(metrics, a) !== null);+}/** 한 축의 유한값 범위. */function axisRange(metrics: ComboMetrics[], a: Axis): { min: number; max: number } | null {const vs = metrics@@ -143,7 +156,10 @@ function norm(v: number, r: { min: number; max: number }, dir: Dir): number {// ── 0. 관점별 승자 스트립 ─────────────────────────────────function verdictStrip(input: ReportInput, colors: Map<string, string>): string {const lang = input.language;- const best = bestByPerspectiveDetailed(input.metrics, lang, { judge: input.judge });+ const best = bestByPerspectiveDetailed(input.metrics, lang, {+ judge: input.judge,+ tier: "decision",+ });const cards = best.map((b) => {const c = colors.get(b.comboId) ?? THEME.mist;@@ -271,7 +287,7 @@ function renderScatter(metrics: ComboMetrics[], colors: Map<string, string>, lanfunction parallelCoords(metrics: ComboMetrics[], colors: Map<string, string>, lang: Lang): string {const sorted = sortCombos(metrics);if (sorted.length < 2) return `<p class="muted">—</p>`;- const ax = axes(lang);+ const ax = liveAxes(metrics, lang);const ranges = ax.map((a) => axisRange(metrics, a));const W = 720;const H = 320;@@ -348,7 +364,7 @@ function parallelCoords(metrics: ComboMetrics[], colors: Map<string, string>, la// ── 축별 순위막대(스몰 멀티플) ────────────────────────────function rankBars(metrics: ComboMetrics[], colors: Map<string, string>, lang: Lang): string {- const ax = axes(lang);+ const ax = liveAxes(metrics, lang);const blocks = ax.map((a) => {const r = axisRange(metrics, a);@@ -411,7 +427,7 @@ function tableBlocks(input: ReportInput): string[] {);}- // 1. 정확도+ // 1. 정확도 (+ 일관성 k/n — 다수결 정확도가 가리는 플레이키니스){const rows = sorted.map((m) =>@@ -419,13 +435,14 @@ function tableBlocks(input: ReportInput): string[] {`<code>${esc(m.comboId)}</code>`,`${m.accuracy.toFixed(1)}%`,`${m.accuracyAtK.toFixed(1)}%`,+ `${m.runsPassed ?? 0}/${m.runCount} (${(m.consistency ?? 0).toFixed(0)}%)`,]),).join("");blocks.push(section(tr(lang, "sec_accuracy"),- `<table>${th([tr(lang, "col_combo"), "accuracy", "accuracy@k"])}${rows}</table>`,+ `<table>${th([tr(lang, "col_combo"), "accuracy", "accuracy@k", tr(lang, "col_consistency")])}${rows}</table>`,),);}@@ -446,12 +463,17 @@ function tableBlocks(input: ReportInput): string[] {m.costUsd !== null && m.estimatedCostUsd !== null? `$${(m.costUsd - m.estimatedCostUsd).toFixed(4)}`: "—";+ const eff =+ m.effectiveCostUsd === null || m.effectiveCostUsd === undefined+ ? "—"+ : `$${m.effectiveCostUsd.toFixed(4)}`;return td([`<code>${esc(m.comboId)}</code>`,String(m.subagentCount),m.totalTokens.toLocaleString("en-US"),cost,+ eff,est,delta,`${(m.wallTimeMs / 1000).toFixed(1)}s`,@@ -461,7 +483,7 @@ function tableBlocks(input: ReportInput): string[] {(i) => {if (i === 1 && m.subagentCount === minSub) return "best";if (i === 2 && m.totalTokens === minTok) return "best";- if (i === 6 && m.wallTimeMs === minWall) return "best";+ if (i === 7 && m.wallTimeMs === minWall) return "best";return "";},);@@ -470,7 +492,8 @@ function tableBlocks(input: ReportInput): string[] {blocks.push(section(tr(lang, "sec_efficiency"),- `<table>${th(["combo-id", "subagents", "total tok", "cost", "est.cost", "Δcost", "wall", "turns", "tool calls"])}${rows}</table>`,+ `<table>${th(["combo-id", "subagents", "total tok", "cost", tr(lang, "col_effcost"), "est.cost", "Δcost", "wall", "turns", "tool calls"])}${rows}</table>`,+ tr(lang, "effcost_note"),),);}