feat(judgement,approvals,governance,ui): a class earns a raise after N approvals and drops on denial or failure; a freeze holds changing actions (#2004)
This commit is contained in:
17 files changed
+1185
-58
No files matched your search
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { onBeforeUnmount, ref, watch } from "vue";
|
||||
import { computed, onBeforeUnmount, ref, watch } from "vue";
|
||||
import { useRouter } from "vue-router";
|
||||
|
||||
import PageHeader from "@/base/PageHeader.vue";
|
||||
@@ -16,6 +16,7 @@ import {
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Empty, EmptyHeader, EmptyTitle } from "@/components/ui/empty";
|
||||
import { MetadataList } from "@/components/ui/metadata-list";
|
||||
import { ReadError } from "@/components/ui/read-error";
|
||||
import { Section } from "@/components/ui/section";
|
||||
import { Spinner } from "@/components/ui/spinner";
|
||||
@@ -24,6 +25,22 @@ import { Timestamp } from "@/components/ui/timestamp";
|
||||
import { type ClassDetail, classDetail, resetClass, Unauthorized } from "./api";
|
||||
import { className, levelLabel } from "./state";
|
||||
|
||||
const autonomyRows = computed(() => {
|
||||
const d = detail.value;
|
||||
if (!d) return [];
|
||||
const rows: { label: string; value?: string; at?: string }[] = [
|
||||
{ label: "Approvals in a row", value: String(d.count) },
|
||||
d.tightened_at
|
||||
? { label: "Last tightened", value: d.tightened_because, at: d.tightened_at }
|
||||
: { label: "Last tightened", value: "Never" },
|
||||
];
|
||||
const raise = d.raises.find((r) => r.state === "pending");
|
||||
if (raise) {
|
||||
rows.push({ label: "Raise waiting", value: `${levelLabel(raise.from)} to ${levelLabel(raise.to)}, answer by`, at: raise.deadline });
|
||||
}
|
||||
return rows;
|
||||
});
|
||||
|
||||
/** One action class: its level, and every decision made in it. */
|
||||
const props = defineProps<{ id: string }>();
|
||||
const emit = defineEmits<{ unauthorized: [] }>();
|
||||
@@ -87,7 +104,41 @@ onBeforeUnmount(() => controller.abort());
|
||||
</Button>
|
||||
</PageHeader>
|
||||
<ReadError v-if="error" :message="error" retry-label="Retry" @retry="load" />
|
||||
<Section title="History">
|
||||
<Section title="Autonomy">
|
||||
<MetadataList :rows="autonomyRows">
|
||||
<template #value="{ row }">
|
||||
<template v-if="row.at">
|
||||
<Timestamp :at="row.at" /><template v-if="row.value">, {{ row.value }}</template>
|
||||
</template>
|
||||
<template v-else>{{ row.value }}</template>
|
||||
</template>
|
||||
</MetadataList>
|
||||
</Section>
|
||||
<Section v-if="detail.raises.length > 0" title="Raises" class="mt-4">
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>From</TableHead>
|
||||
<TableHead>To</TableHead>
|
||||
<TableHead>State</TableHead>
|
||||
<TableHead>Answered by</TableHead>
|
||||
<TableHead>Approvals</TableHead>
|
||||
<TableHead>Proposed</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
<TableRow v-for="r in detail.raises" :key="r.id">
|
||||
<TableCell>{{ levelLabel(r.from) }}</TableCell>
|
||||
<TableCell>{{ levelLabel(r.to) }}</TableCell>
|
||||
<TableCell>{{ r.state }}</TableCell>
|
||||
<TableCell>{{ r.answered_by }}</TableCell>
|
||||
<TableCell>{{ r.evidence.map((e) => e.by).join(", ") }}</TableCell>
|
||||
<TableCell><Timestamp :at="r.proposed_at" /></TableCell>
|
||||
</TableRow>
|
||||
</TableBody>
|
||||
</Table>
|
||||
</Section>
|
||||
<Section title="History" class="mt-4">
|
||||
<Empty v-if="detail.history.length === 0">
|
||||
<EmptyHeader><EmptyTitle>No decisions yet</EmptyTitle></EmptyHeader>
|
||||
</Empty>
|
||||
|
||||
@@ -56,6 +56,7 @@ onBeforeUnmount(() => controller.abort());
|
||||
<TableHead>Environment</TableHead>
|
||||
<TableHead>Level</TableHead>
|
||||
<TableHead>Decisions</TableHead>
|
||||
<TableHead>Approvals in a row</TableHead>
|
||||
<TableHead>Last</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
@@ -66,6 +67,7 @@ onBeforeUnmount(() => controller.abort());
|
||||
<TableCell>{{ c.environment }}</TableCell>
|
||||
<TableCell><Badge variant="outline">{{ levelLabel(c.level) }}</Badge></TableCell>
|
||||
<TableCell>{{ c.decisions }}</TableCell>
|
||||
<TableCell>{{ c.count }}</TableCell>
|
||||
<TableCell><Timestamp v-if="c.last_decided_at" :at="c.last_decided_at" /></TableCell>
|
||||
</TableRow>
|
||||
</TableBody>
|
||||
|
||||
@@ -4,10 +4,12 @@ import { onBeforeUnmount, onMounted, ref } from "vue";
|
||||
import PageHeader from "@/base/PageHeader.vue";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { DurationInput } from "@/components/ui/duration-input";
|
||||
import { NumberField, NumberFieldContent, NumberFieldDecrement, NumberFieldIncrement, NumberFieldInput } from "@/components/ui/number-field";
|
||||
import { ReadError } from "@/components/ui/read-error";
|
||||
import { Section } from "@/components/ui/section";
|
||||
import { SettingRow } from "@/components/ui/setting-row";
|
||||
import { Spinner } from "@/components/ui/spinner";
|
||||
import { Switch } from "@/components/ui/switch";
|
||||
import { getSettings, saveSettings, Unauthorized } from "./api";
|
||||
|
||||
/**
|
||||
@@ -17,6 +19,8 @@ import { getSettings, saveSettings, Unauthorized } from "./api";
|
||||
const emit = defineEmits<{ unauthorized: [] }>();
|
||||
|
||||
const deadline = ref("24h");
|
||||
const raiseAfter = ref(3);
|
||||
const frozen = ref(false);
|
||||
const saved = ref("");
|
||||
const loading = ref(true);
|
||||
const saving = ref(false);
|
||||
@@ -29,6 +33,8 @@ async function load() {
|
||||
try {
|
||||
const set = await getSettings(controller.signal);
|
||||
deadline.value = set.approval_deadline;
|
||||
raiseAfter.value = set.raise_after;
|
||||
frozen.value = set.frozen;
|
||||
} catch (err) {
|
||||
fail(err);
|
||||
} finally {
|
||||
@@ -41,7 +47,7 @@ async function save() {
|
||||
error.value = "";
|
||||
saved.value = "";
|
||||
try {
|
||||
await saveSettings({ approval_deadline: deadline.value });
|
||||
await saveSettings({ approval_deadline: deadline.value, raise_after: raiseAfter.value, frozen: frozen.value });
|
||||
saved.value = "Saved.";
|
||||
} catch (err) {
|
||||
fail(err);
|
||||
@@ -72,6 +78,24 @@ onBeforeUnmount(() => controller.abort());
|
||||
<p class="text-caption text-muted-foreground">
|
||||
How long an approval request waits for an answer. Nothing runs when it expires.
|
||||
</p>
|
||||
<SettingRow label="Approvals to propose a raise" for="raise-after">
|
||||
<NumberField v-model="raiseAfter" :min="1" :max="100" class="w-32">
|
||||
<NumberFieldContent>
|
||||
<NumberFieldDecrement />
|
||||
<NumberFieldInput id="raise-after" class="font-mono" />
|
||||
<NumberFieldIncrement />
|
||||
</NumberFieldContent>
|
||||
</NumberField>
|
||||
</SettingRow>
|
||||
<p class="text-caption text-muted-foreground">
|
||||
Approvals in a row, since a class was last tightened, before Archie proposes raising it one level.
|
||||
</p>
|
||||
<SettingRow label="Freeze" for="frozen" tone="danger">
|
||||
<Switch id="frozen" v-model="frozen" aria-label="Freeze" />
|
||||
</SettingRow>
|
||||
<p class="text-caption text-muted-foreground">
|
||||
Every action that changes something waits for approval. Class levels stay as they are.
|
||||
</p>
|
||||
<div class="mt-3 flex items-center gap-3">
|
||||
<Button :disabled="saving" @click="save">Save</Button>
|
||||
<span v-if="saved" class="text-caption text-muted-foreground">{{ saved }}</span>
|
||||
|
||||
@@ -140,6 +140,10 @@ export interface Trail {
|
||||
export interface Settings {
|
||||
/** A Go duration, such as "24h". */
|
||||
approval_deadline: string;
|
||||
/** Approvals in a row, since a class was last tightened, that earn a proposal to raise it. */
|
||||
raise_after: number;
|
||||
/** Holds every action that changes something at propose and wait. */
|
||||
frozen: boolean;
|
||||
}
|
||||
|
||||
export const getSettings = (signal?: AbortSignal) => get<Settings>("/api/settings", signal);
|
||||
@@ -187,6 +191,10 @@ export interface ActionClass {
|
||||
decisions: number;
|
||||
last_decided_at?: string;
|
||||
reset_at?: string;
|
||||
/** Approvals in a row since the class was last tightened or raised. */
|
||||
count: number;
|
||||
tightened_at?: string;
|
||||
tightened_because?: "denied" | "failed";
|
||||
}
|
||||
|
||||
export interface HistoryEntry {
|
||||
@@ -200,7 +208,20 @@ export interface HistoryEntry {
|
||||
at: string;
|
||||
}
|
||||
|
||||
export interface Raise {
|
||||
id: string;
|
||||
from: Level;
|
||||
to: Level;
|
||||
state: "pending" | "approved" | "denied" | "expired" | "superseded";
|
||||
deadline: string;
|
||||
proposed_at: string;
|
||||
answered_by?: string;
|
||||
answered_at?: string;
|
||||
evidence: { decision_id: string; by: string; at: string }[];
|
||||
}
|
||||
|
||||
export interface ClassDetail extends ActionClass {
|
||||
raises: Raise[];
|
||||
history: HistoryEntry[];
|
||||
resets: { from: Level; to: Level; by: string; at: string }[];
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user