diff --git a/ui/src/lib/api.ts b/ui/src/lib/api.ts index 72214b3ca..ecd7b1b96 100644 --- a/ui/src/lib/api.ts +++ b/ui/src/lib/api.ts @@ -192,6 +192,22 @@ export const api = { request(`/api/runs/${encodeURIComponent(id)}/retry`, { method: "POST", body: from ? { from } : {} }), /** Asks a run that has not ended to stop, along with the runs it called. */ cancelRun: (id: string) => request(`/api/runs/${encodeURIComponent(id)}/cancel`, { method: "POST", body: {} }), + proposals: (state?: ProposalState) => request("/api/proposals" + qs({ state })), + proposal: (id: string) => request(`/api/proposals/${encodeURIComponent(id)}`), + /** Approves a proposal and the actions it lists; the server applies it. */ + approveProposal: (id: string, assertion?: ApprovalAssertion) => + request(`/api/proposals/${encodeURIComponent(id)}/approve`, { method: "POST", body: { assertion } }), + rejectProposal: (id: string, reason: string) => + request(`/api/proposals/${encodeURIComponent(id)}/reject`, { method: "POST", body: { reason } }), + /** Starts the passkey confirmation that approving an irreversible action needs. */ + beginProposalConfirmation: (id: string) => + request(`/api/proposals/${encodeURIComponent(id)}/confirmation`, { method: "POST", body: {} }), + /** Replays a stored event, the newest by default, against a trigger proposal. */ + dryRunProposal: (id: string, eventId?: string) => + request(`/api/proposals/${encodeURIComponent(id)}/dry-run`, { method: "POST", body: eventId ? { event_id: eventId } : {} }), + /** Proposes a trigger and workflow for a group of unmatched events. */ + proposeForGroup: (groupId: string) => + request(`/api/groups/${encodeURIComponent(groupId)}/proposal`, { method: "POST", body: {} }), approvals: () => request("/api/approvals"), answerApproval: (id: string, approved: boolean, assertion?: ApprovalAssertion) => request(`/api/approvals/${encodeURIComponent(id)}/answer`, { method: "POST", body: { approved, assertion } }), @@ -846,6 +862,64 @@ export interface Bootstrap { sealing_identity_set: boolean; } +export type ProposalState = "pending" | "approved" | "rejected" | "published" | "superseded" | "withdrawn"; + +export interface ProposalAction { + seq: number; + connector: string; + action: string; + target_kind: string; + target_id: string; + input: unknown; + decision_id: string; + /** How far judgement lets the action run, as shown when it was proposed. */ + level?: string; + reason?: string; + refused_by?: string; + verdicts?: { guard: string; ceiling: string; findings?: { text: string }[]; failed?: string }[]; + state: "pending" | "ran" | "failed" | "unknown" | "refused" | "skipped"; + outcome?: string; + settled_at?: string; +} + +export interface ProposalTrigger { + group_id: string; + name: string; + source_id: string; + event_type: string; + filter: Record; + workflow: string; + policy_kind: "hard_rules" | "change_request"; + policy: string; + dry_run?: { run_id: string; state: string; error?: string; findings?: string; actions: { action: string; target: string; level: string; outcome: string; why?: string }[] }; + dry_event_id?: string; + installed_version?: number; +} + +export interface Proposal { + id: string; + kind: "root_cause_fix" | "trigger" | "workflow_change" | "ceiling_raise" | "policy_change"; + state: ProposalState; + /** Who must approve: the owner, or a person with authority over policies. */ + needs: "owner" | "authority"; + title: string; + summary: string; + evidence: unknown; + change?: unknown; + trigger?: ProposalTrigger; + target_kind: string; + target_id?: string; + actions: ProposalAction[]; + prompted_by: string[]; + run_id?: string; + proposed_by_id: string; + created_at: string; + answered_by_id?: string; + answered_at?: string; + answer_reason?: string; + published_at?: string; +} + export interface ApprovalConfirmation { token: string; options: { publicKey: Record }; diff --git a/ui/src/proposals/ProposalPage.vue b/ui/src/proposals/ProposalPage.vue new file mode 100644 index 000000000..92aa74eda --- /dev/null +++ b/ui/src/proposals/ProposalPage.vue @@ -0,0 +1,167 @@ + + +