Build reliable ownership and defensible evidence across every autonomous decision, so teams don't lose track of responsibility.
Use risk-tiered gates so low-risk actions flow automatically and high-impact actions pause for reviewer approval. Always enforce explicit deny-by-default behavior when approval is missing or times out.
type DecisionLog = {
decisionId: string;
timestamp: string;
agentId: string;
actorId: string;
action: string;
riskLevel: "low" | "medium" | "high";
rationale: string;
confidence: number;
policyChecks: { ruleId: string; passed: boolean }[];
escalationRequired: boolean;
};
export async function logDecision(entry: DecisionLog) {
await auditStore.append({
...entry,
timestamp: new Date().toISOString(),
});
if (entry.riskLevel === "high" || entry.escalationRequired) {
await notifyHumanReviewer({
decisionId: entry.decisionId,
summary: entry.rationale,
actorId: entry.actorId,
});
}
}export async function runWithHumanGate(input: TaskInput) {
const risk = assessRisk(input);
if (risk.level !== "high") {
return executeTask(input);
}
const approval = await requestApproval({
requestedBy: input.actorId,
summary: input.summary,
timeoutMinutes: 30,
});
if (!approval.granted) {
return { status: "blocked", reason: "human_approval_required" };
}
return executeTask(input);
}