feat(frontend): v2 artifact viewers for cte_plan/cte_result/phase

Add CtePlanViewer, CteResultViewer, and PhaseSummaryViewer to render the
structured v2 payloads (schema_version: 2) the harness now emits for
artifact-gate widgets, per contracts.md. Extract PreviewGrid from
ResultsPanel as a reusable AG Grid component shared by CteResultViewer.
ArtifactView dispatches to the new viewers on a schema_version/shape
guard, falling back to the existing legacy renderers unchanged for
older sessions and replay fixtures.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-07 00:57:20 +02:00
co-authored by Claude Fable 5
parent 3ad93cd02f
commit 1c97289ed8
12 changed files with 937 additions and 26 deletions
+121
View File
@@ -0,0 +1,121 @@
// TypeScript mirrors of the v2 artifact payload contracts (see
// .superpowers/sdd/review-gates-v2/contracts.md). Detection everywhere is
// `data.schema_version === 2` + a shape-guard; anything else falls back to the
// legacy renderers in ArtifactView.
// --- A. cte_plan v2 ---------------------------------------------------------
export interface CtePlanTable {
name: string;
description?: string;
}
export interface CtePlanFilter {
column: string;
op: string;
value: string;
description?: string;
rationale?: string;
}
export interface CtePlanCte {
name: string;
index: number;
purpose?: string;
rationale?: string;
depends_on?: string[];
tables?: CtePlanTable[];
keys?: string[];
filters?: CtePlanFilter[];
output_columns?: string[];
}
export interface CtePlanV2 {
schema_version: 2;
question?: string;
strategy?: string;
ctes: CtePlanCte[];
}
// --- B. cte_result v2 --------------------------------------------------------
export interface CteResultColumn {
name: string;
description?: string;
}
export interface CteResultPreview {
columns: string[];
rows: unknown[][];
}
export interface CteResultV2 {
schema_version: 2;
name: string;
index: number;
total: number;
purpose?: string;
rationale?: string;
depends_on?: string[];
sql: string;
status: "ok" | "error" | string;
execution_ms?: number;
row_sample?: number;
warnings?: string[];
sql_hash?: string;
columns?: CteResultColumn[];
preview?: CteResultPreview;
note?: string;
}
// --- C. phase summary v2 -----------------------------------------------------
export interface PhaseMeta {
id: string;
num: number;
name: string;
}
export interface PhaseCheck {
label: string;
status: "ok" | "warn" | "fail" | string;
detail?: string;
}
export interface PhaseSectionItem {
label: string;
table?: string;
column?: string;
value?: string;
kind?: "table" | "column" | "filter" | "join" | "metric" | "note" | string;
description?: string;
rationale?: string;
}
export interface PhaseSection {
title: string;
items: PhaseSectionItem[];
}
export interface PhaseTableColumn {
name: string;
description?: string;
value_filter?: string;
}
export interface PhaseTable {
name: string;
role: "promoted" | "excluded" | string;
description?: string;
columns?: PhaseTableColumn[];
}
export interface PhaseSummaryV2 {
schema_version: 2;
phase: PhaseMeta;
summary?: string;
checks?: PhaseCheck[];
sections?: PhaseSection[];
tables?: PhaseTable[];
open_questions?: string[];
}