feat(runs,approvals,ui): a run's trail joins each action's verdicts, approval and effect, and the run view shows them in order (archie #1996)
This commit is contained in:
7 files changed
+342
-18
No files matched your search
@@ -0,0 +1,97 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from "vue";
|
||||
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { CodeBlock, CodeBlockContent } from "@/components/ui/code-block";
|
||||
import { MetadataList } from "@/components/ui/metadata-list";
|
||||
import { Timestamp } from "@/components/ui/timestamp";
|
||||
import type { ActionTrail, ApprovalRequest, Effect, Verdict } from "./api";
|
||||
|
||||
/** One action from judgement to effect: verdicts, the approval it was put to, and what it did. */
|
||||
const props = defineProps<{ action: ActionTrail }>();
|
||||
|
||||
type Tone = "ok" | "warn" | "danger" | "info" | "secondary";
|
||||
|
||||
const decision = computed(() => props.action.decision);
|
||||
const target = computed(() => `${decision.value.action.target.Kind}:${decision.value.action.target.ID}`);
|
||||
|
||||
const approvalTone: Record<ApprovalRequest["state"], Tone> = {
|
||||
pending: "warn",
|
||||
approved: "ok",
|
||||
denied: "danger",
|
||||
expired: "secondary",
|
||||
};
|
||||
const effectTone: Record<Effect["state"], Tone> = { ran: "ok", failed: "danger", unknown: "warn" };
|
||||
const effectLabel: Record<Effect["state"], string> = { ran: "Ran", failed: "Failed", unknown: "Outcome unknown" };
|
||||
|
||||
const approvalRows = computed(() => {
|
||||
const a = props.action.approval;
|
||||
if (!a?.answered_by) return [];
|
||||
return [
|
||||
{ label: "Answered by", value: a.answered_by },
|
||||
{ label: "Via", value: a.answered_via ?? "" },
|
||||
];
|
||||
});
|
||||
|
||||
const json = (v: unknown) => JSON.stringify(v, null, 2);
|
||||
const ceilingTone = (v: Verdict): Tone => (v.failed ? "warn" : "secondary");
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex flex-col gap-3 rounded-md border p-3 text-label">
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<span class="font-medium">{{ decision.action.connector }} {{ decision.action.name }}</span>
|
||||
<span class="text-caption text-muted-foreground">{{ target }}</span>
|
||||
<Badge :variant="decision.reason ? 'danger' : 'secondary'">{{ decision.level }}</Badge>
|
||||
<Timestamp :at="decision.at" class="ml-auto text-caption" />
|
||||
</div>
|
||||
<p v-if="decision.action.effect.Summary" class="text-muted-foreground">{{ decision.action.effect.Summary }}</p>
|
||||
<CodeBlock size="sm">
|
||||
<CodeBlockContent wrap class="max-h-40">{{ json(decision.action.input) }}</CodeBlockContent>
|
||||
</CodeBlock>
|
||||
|
||||
<ul class="flex flex-col gap-1.5">
|
||||
<li v-for="v in decision.verdicts" :key="v.guard" class="flex flex-col gap-0.5">
|
||||
<span class="flex items-center gap-2">
|
||||
<span>{{ v.guard }}</span>
|
||||
<Badge :variant="ceilingTone(v)">{{ v.ceiling }}</Badge>
|
||||
<Badge v-if="v.advisory" variant="outline">advisory</Badge>
|
||||
</span>
|
||||
<span v-if="v.failed" class="text-caption text-destructive">{{ v.failed }}</span>
|
||||
<span v-for="f in v.findings" :key="f.text" class="text-caption text-muted-foreground">
|
||||
{{ f.text }}<template v-if="f.evidence">: {{ f.evidence }}</template>
|
||||
</span>
|
||||
<span v-for="b in v.blind_spots" :key="b" class="text-caption text-muted-foreground">Blind spot: {{ b }}</span>
|
||||
</li>
|
||||
</ul>
|
||||
<p v-if="decision.reason" class="text-destructive">{{ decision.reason }}</p>
|
||||
|
||||
<div v-if="action.approval" class="flex flex-col gap-2 border-t pt-3">
|
||||
<div class="flex items-center gap-2">
|
||||
<span class="font-medium">Approval</span>
|
||||
<Badge :variant="approvalTone[action.approval.state]">{{ action.approval.state }}</Badge>
|
||||
<Timestamp :at="action.approval.answered_at ?? action.approval.requested_at" class="ml-auto text-caption" />
|
||||
</div>
|
||||
<MetadataList v-if="approvalRows.length" :rows="approvalRows" />
|
||||
<p class="whitespace-pre-wrap text-muted-foreground">{{ action.approval.summary }}</p>
|
||||
</div>
|
||||
|
||||
<div v-if="action.rejudged" class="flex items-center gap-2 text-caption text-muted-foreground">
|
||||
<span>Judged again</span>
|
||||
<Badge variant="secondary">{{ action.rejudged.level }}</Badge>
|
||||
<span v-if="action.rejudged.reason">{{ action.rejudged.reason }}</span>
|
||||
</div>
|
||||
|
||||
<div v-if="action.effect" class="flex flex-col gap-2 border-t pt-3">
|
||||
<div class="flex items-center gap-2">
|
||||
<span class="font-medium">Effect</span>
|
||||
<Badge :variant="effectTone[action.effect.state]">{{ effectLabel[action.effect.state] }}</Badge>
|
||||
<Timestamp :at="action.effect.at" class="ml-auto text-caption" />
|
||||
</div>
|
||||
<p v-if="action.effect.error" class="text-destructive">{{ action.effect.error }}</p>
|
||||
<CodeBlock v-if="action.effect.output" size="sm">
|
||||
<CodeBlockContent wrap class="max-h-64">{{ action.effect.output }}</CodeBlockContent>
|
||||
</CodeBlock>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -18,6 +18,7 @@ import {
|
||||
TraceLine,
|
||||
TraceTitle,
|
||||
} from "@/components/ui/trace";
|
||||
import ActionTrailView from "./ActionTrailView.vue";
|
||||
import { runTrail, type Trail, type TrailEntry, Unauthorized } from "./api";
|
||||
import { runTone } from "./state";
|
||||
|
||||
@@ -103,6 +104,11 @@ const json = (v: unknown) => JSON.stringify(v, null, 2);
|
||||
<CodeBlockContent wrap class="max-h-64">{{ json(trail.origin.fields) }}</CodeBlockContent>
|
||||
</CodeBlock>
|
||||
</Section>
|
||||
<Section v-if="trail.actions.length" title="Actions">
|
||||
<div class="flex flex-col gap-3">
|
||||
<ActionTrailView v-for="a in trail.actions" :key="a.decision.id" :action="a" />
|
||||
</div>
|
||||
</Section>
|
||||
<Section title="Steps">
|
||||
<Trace>
|
||||
<TraceCollapsible v-for="e in trail.entries" :key="e.seq" :default-open="Boolean(e.error || e.unknown)">
|
||||
|
||||
@@ -78,9 +78,62 @@ export interface TrailEntry {
|
||||
unknown?: boolean;
|
||||
}
|
||||
|
||||
export interface Verdict {
|
||||
guard: string;
|
||||
ceiling: string;
|
||||
findings?: { text: string; evidence?: string }[];
|
||||
blind_spots?: string[];
|
||||
advisory?: boolean;
|
||||
failed?: string;
|
||||
}
|
||||
|
||||
export interface Decision {
|
||||
id: string;
|
||||
key: string;
|
||||
action: {
|
||||
connector: string;
|
||||
name: string;
|
||||
input: unknown;
|
||||
digest: string;
|
||||
target: { Kind: string; ID: string; Environment: string };
|
||||
effect: { Summary: string };
|
||||
};
|
||||
level: string;
|
||||
verdicts: Verdict[];
|
||||
refused_by?: string;
|
||||
reason?: string;
|
||||
at: string;
|
||||
}
|
||||
|
||||
export interface ApprovalRequest {
|
||||
id: string;
|
||||
summary: string;
|
||||
state: "pending" | "approved" | "denied" | "expired";
|
||||
deadline: string;
|
||||
requested_at: string;
|
||||
answered_by?: string;
|
||||
answered_via?: string;
|
||||
answered_at?: string;
|
||||
}
|
||||
|
||||
export interface Effect {
|
||||
state: "ran" | "failed" | "unknown";
|
||||
at: string;
|
||||
output?: string;
|
||||
error?: string;
|
||||
}
|
||||
|
||||
export interface ActionTrail {
|
||||
decision: Decision;
|
||||
rejudged?: Decision;
|
||||
approval?: ApprovalRequest;
|
||||
effect?: Effect;
|
||||
}
|
||||
|
||||
export interface Trail {
|
||||
run: Run;
|
||||
origin?: Origin;
|
||||
actions: ActionTrail[];
|
||||
entries: TrailEntry[];
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user