Decision Audit
Once you delegate routine choices to AI agents, your inbox gets blissfully quiet. The danger is that a quiet inbox looks identical whether your delegation policy is working beautifully or your agents are quietly making calls you never meant to hand over. One surprise mistake three weeks later can shatter trust and send you right back to approving everything yourself.
Decision Audit closes the trust loop on delegated authority. The hub logs every decision agents make without you, automatically flags exceptions, and draws a small, unpredictable random sample for your regular check-ins — paired with independent outcomes. Your verdicts tell you when to fix a root cause, tighten sampling to 100%, or safely widen what agents may handle on their own. Reach for it whenever agents act under standing policies too often for you to review every single call.
Decision
Why a quiet inbox isn't proof of good delegation
Across support credits, vendor approvals, content publishing, and code merges, standing policies can slash human interruptions from dozens per week to a handful. Everything looks smooth — until a customer or stakeholder reports a failure caused by an autonomous decision that should never have slipped past you.
Without structured sampling, you have no way to tell whether that miss was a rare fluke or one of ten silent errors. Unable to judge how trustworthy the policy really is, the rational human response is to revoke the policy completely and go back to approving every routine call by hand.
Decision Audit replaces blind trust and panic revocations with four hub-enforced mechanics:
-
Every autonomous act writes a
Decisionatomically alongside itsPolicy use, capturing the chosen path, options weighed, rationale, how to undo it, and later the hub-observed outcome — so later agents and returning humans do not re-litigate settled calls. - The hub marks exceptions automatically and draws the sample blindly. Missing policies, non-undoable acts, rollbacks, and objections are always surfaced; all other decisions enter a random draw no agent can predict or influence.
-
Verdicts judge authority, not just luck, and drive adaptive sampling.
Each reviewed item gets
rightorshould_have_asked. A miss snaps sampling back to 100% until ten consecutive sampled calls pass again; sampling never drops to zero. - Investigate root causes before rewriting policies. A verdict never edits a policy automatically; the lead agent first diagnoses whether the miss came from policy wording, policy scope, agent misreading, or missing facts.
Why must the hub draw the random sample at write time — hidden from the agents? Because if agents choose which decisions to log or can predict which calls will be sampled, the sample proves nothing. Blind hub-side selection means every autonomous choice faces the same chance of inspection.
Architecture and participants
The Hub stores one immutable Decision
record for every autonomous act — written in the same transaction as its
Policy use. Two working views — the
Review list and the Track record — are computed on read
directly from decisions and never stored separately, so
they can never drift out of sync with verdicts.
Policy use pairs 1-to-1 with a
Decision. The hub derives the requester's Review list
(exceptions first, then sampled items) and each decision kind's Track record (sampled
verdicts only) directly from stored decisions.
right or should_have_asked)
with an optional note, and decides whether to widen, narrow, or revoke policies.
Decision atomically with its
Policy use, marks exceptions, runs the blind random
draw, fills in independent outcomes from its own records, and computes both derived views.
should_have_asked, the lead agent
investigates and records the cause and
fix.
kind
(excluding non-random exceptions) and drives the adaptive
sample_one_in rate.
Execution flow
Toggle between the normal path — where clean sampled verdicts maintain a light 1-in-5
review rate and build evidence to widen a policy — and the miss path — where a single
should_have_asked verdict snaps sampling to 100% and
triggers a root-cause fix without discarding the policy.
The hub logs the decision and draws the sample at write time, enriches it with an
independent outcome before Friday's check-in, and counts the requester's
right verdict toward the kind's track record — giving
concrete evidence before proposing a broader policy later.
Begins at Friday's check-in when the Review list surfaces a sampled merge that quietly
added a column to the invoices table.
Marking the merge should_have_asked immediately resets
sample_one_in to 1
(100% review). The lead agent discovers missing_information
in the checker's finding, fixes the reporting gap, and keeps the underlying policy intact.
Skipped reviews never relax sampling: sample_one_in
counts only reviewed sampled decisions toward the ten-clean run, so unreviewed
items awaiting check-in can never lower the rate from 1-in-1 to 1-in-5 — while decisions
recorded under an already-earned 1-in-5 rate continue sampling at 1-in-5 until a
should_have_asked verdict tightens it back to 1-in-1.
Concrete examples
Decision Audit applies to any recurring delegated workflow — customer support, vendor operations, editorial publishing, or software delivery — where mistakes can be caught and repaired after the fact.
Example 1 — Customer support credit authorizations
No code or unit tests- Context
- Support agents authorized 28 account credits under a standing policy for amounts below $50. Reviewing all 28 every week would undo the savings of delegating them.
- Check-in list
-
The hub shows 6 decisions: 1 exception (an instant card refund with
undo: null→cannot_undo) plus 5 random samples, each paired with the hub's billing outcome. - Verdict & fix
-
Five items are marked
right. One sampled $45 credit was applied to an account with an open legal dispute, so the manager marks itshould_have_asked. Sampling snaps to 1-in-1; the lead agent logsmissing_information(the billing lookup omitted dispute status), updates the lookup, and preserves the $50 credit policy.
Example 2 — Weekly bug-fix merges (API service)
Software engineering- Context
- Over one week, the lead agent merges 23 approved bug fixes under a standing policy that excludes database schema changes.
- Check-in list
-
Friday at 4:10 p.m., Decision Audit shows 5 decisions: 1 exception
(a retry-timeout fix rolled back in staging on Wednesday — marked
rightbecause it was still inside the agent's scope to handle) plus 4 random samples. - Verdict & fix
-
Three sampled fixes have run cleanly in production (
right). The fourth (invoice export totals) quietly added a column toinvoicesand is markedshould_have_asked. Sampling resets to 100%, the lead agent traces the cause tomissing_informationin the checker's report, updates the checker to list every touched table, and keeps the merge policy running safely.
What this pattern is NOT — Preventing irreversible harm upfront
Negative example- Situation
- Allowing agents to wire funds or purge customer records and relying on Friday's 1-in-5 spot check to catch a mistake — or turning on logging when nobody opens the Review list.
- Why skip it
- Decision Audit runs after the act. When a single wrong call costs too much to undo, place a Policy Gate before the action so it never runs without explicit verification. And never treat an unreviewed audit log as real oversight.
When to use and when to skip
Use Decision Audit when
- Agents make recurring autonomous decisions under a Delegation Policy too often for the requester to review 100% forever.
- An occasional bad decision can be detected afterward and undone or repaired at acceptable cost.
- The requester expects to widen or narrow agent authority over time as real evidence accumulates.
- The requester has a real check-in cadence to actually read and judge the sampled Review list.
Skip it when
- A single mistake is irreversible and severe (financial payouts, deleting customer data) — use Policy Gate before acting instead.
- Nobody will read the sampled Review list — unreviewed logs create a dangerous illusion of safety.
- Delegated actions happen only once or twice a month; reviewing every single one directly is simpler.
- The hub has no independent way to observe outcomes, leaving the requester only the agent's own self-report.
Data model and hub invariants
Decision Audit defines one durable table — decisions —
linking to Request and Party
(Orchestrator-Workers),
Job (Durable Job),
Policy use (Delegation Policy),
and Question (Self-Contained Question).
Both the Review list and Track record are derived purely from queries over
decisions.
Policy use pairs with exactly one
Decision (1? to
1). A decision always belongs to one
Request and one deciding Party,
and optionally links a Job, settled
Question, and reviewing requester.
Table: decisions
| Column | Postgres type | Nullability | Notes |
|---|---|---|---|
| id | uuid | NOT NULL, PK | Unique decision identifier. |
| request_id | uuid | NOT NULL, FK | References requests(id). |
| job_id | uuid | NULLABLE, FK | References jobs(id); NULL when request-wide. |
| policy_use_id | uuid | NULLABLE, FK | References policy_uses(id); unique when non-null; NULL triggers no_policy exception. |
| question_id | uuid | NULLABLE, FK | References questions(id) when settling an open question. |
| decided_by_id | uuid | NOT NULL, FK | References parties(id); agent or hub, never the requester. |
| kind | text | NOT NULL | Category sampled and tracked together (e.g. merge_bug_fix). |
| summary | text | NOT NULL | Self-contained one-sentence summary of the chosen path, readable without chat history. |
| options_considered | jsonb | NULLABLE | JSON array of alternatives weighed when choosing among options, preventing future agents from re-litigating settled calls. |
| rationale | text | NOT NULL | Concise explanation of why the deciding party chose this path under the active policy, giving reviewers concrete context for their verdict. |
| undo | text | NULLABLE | Concrete reversal instructions; NULL triggers cannot_undo exception. |
| decided_at | timestamptz | NOT NULL | Timestamp when the autonomous action occurred. |
| outcome | text | NULLABLE | Independent hub-observed outcome (e.g. "Live since Tuesday with no errors"). |
| exception | text | NULLABLE | CHECK (exception IN ('no_policy', 'cannot_undo', 'undone', 'objection')); sticky once set. |
| sampled | boolean | NOT NULL | Set blindly by hub at insert time; immutable thereafter. |
| verdict | text | NULLABLE | CHECK (verdict IN ('right', 'should_have_asked')); written at most once. |
| verdict_note | text | NULLABLE | Requester's note explaining why a decision was right or should have asked. |
| reviewed_by_id | uuid | NULLABLE, FK | References parties(id); the reviewing requester. |
| reviewed_at | timestamptz | NULLABLE | Timestamp when the verdict was recorded. |
| cause | text | NULLABLE | CHECK (cause IN ('policy_wording', 'policy_scope', 'agent_reading', 'missing_information')). |
| fix | text | NULLABLE | One-sentence description of what changed so the miss does not repeat. |
Six hub invariants
-
01One-to-one atomic link between Policy use and Decision Database constraint
A partial unique index
UNIQUE (policy_use_id) WHERE policy_use_id IS NOT NULLpaired with atomic hub writes guarantees everyPolicy useproduces exactly oneDecisionrow. -
02Missing policy or undo path forces a sticky exception Database constraint
CHECK ((policy_use_id IS NOT NULL AND undo IS NOT NULL) OR exception IS NOT NULL)guarantees any uncovered or irreversible act is always flagged asno_policyorcannot_undo, and hub transitions never clear an existing exception. -
03Root cause and fix exist only on missed decisions Database constraint
CHECK ((cause IS NULL AND fix IS NULL) OR verdict = 'should_have_asked')backs the hub'scause_requires_should_have_asked,invalid_cause, andfix_requiredguards; misses stay open with the lead agent until both fields are recorded. -
04Append-only record and one-time verdict Hub guard
Decisions are never deleted and
samplednever changes.reviewaccepts only valid verdicts (invalid_verdict) on unreviewed rows (already_reviewed). -
05Track record and sampling rate follow reviewed history only Hub guard
track_recordignores non-random exceptions so the statistical pass rate stays unbiased.sample_one_inrelaxes to5only after ten consecutive reviewed sampled decisions earnright(unreviewed items never count toward the run), and resets to1on anyshould_have_askedverdict (even on an exception). -
06Verdicts never mutate policies directly Hub guard
Recording a verdict updates only the
Decisionrow. Widening, narrowing, or revoking a rule always happens explicitly through Delegation Policy by the requester.
Reference implementation
The same pure sampling, review-list derivation, track-record calculation, and verdict/cause guards in Lean, TypeScript, Python, and Elixir. Notice how injecting the random draw function makes adaptive sampling deterministic to test.
-- Pure DecisionAudit sampling, review list, track record, and guards
inductive ExceptionKind where
| noPolicy | cannotUndo | undone | objection
deriving Repr, BEq, DecidableEq
inductive Verdict where
| right | shouldHaveAsked
deriving Repr, BEq, DecidableEq
inductive CauseKind where
| policyWording | policyScope | agentReading | missingInformation
deriving Repr, BEq, DecidableEq
inductive HubError where
-- invalidVerdict and invalidCause are kept for parity: the Verdict and CauseKind
-- types already rule out any other value, so no guard here can raise them.
| invalidVerdict | unknownDecision | alreadyReviewed
| causeRequiresShouldHaveAsked | invalidCause | fixRequired
deriving Repr, BEq
-- Timestamps are Unix seconds, passed in by the caller.
structure Decision where
id : String
requestId : String
policyUseId : Option String := none
decidedById : String
kind : String
summary : String
optionsConsidered : Option (List String) := none
rationale : String
undo : Option String := none
decidedAt : Nat
outcome : Option String := none
exception : Option ExceptionKind := none
sampled : Bool := false
verdict : Option Verdict := none
verdictNote : Option String := none
reviewedById : Option String := none
reviewedAt : Option Nat := none
cause : Option CauseKind := none
fix : Option String := none
deriving Repr
def cleanRun : Nat := 10
def relaxedOneIn : Nat := 5
namespace DecisionAudit
-- Reviewed decisions of one kind, most recently reviewed first.
def reviewed (decisions : List Decision) (kind : String) : List Decision :=
(decisions.filter fun d => d.kind == kind && d.verdict.isSome).mergeSort fun a b =>
a.reviewedAt.getD a.decidedAt >= b.reviewedAt.getD b.decidedAt
def sampleOneIn (decisions : List Decision) (kind : String) : Nat :=
-- Rate follows reviewed history only: unreviewed items awaiting the next check-in
-- never count toward the 10-clean run, and any should_have_asked verdict resets to 1.
let run := (reviewed decisions kind
|>.takeWhile (fun d => d.verdict == some .right)
|>.countP (·.sampled))
if run >= cleanRun then relaxedOneIn else 1
-- `draw n` returns a number from 1 to n; it stands in for a random number generator.
def record (decisions : List Decision) (d : Decision) (draw : Nat → Nat) : List Decision :=
let exception :=
match d.exception, d.policyUseId, d.undo with
| some e, _, _ => some e
| none, none, _ => some .noPolicy
| none, some _, none => some .cannotUndo
| none, some _, some _ => none
let sampled := draw (sampleOneIn decisions d.kind) == 1
{ d with exception, sampled } :: decisions
-- Open items oldest first, exceptions ahead of plain samples.
def reviewList (decisions : List Decision) : List Decision :=
let openItems := (decisions.filter fun d =>
d.verdict.isNone && (d.exception.isSome || d.sampled)).mergeSort fun a b =>
a.decidedAt <= b.decidedAt
let (exceptions, sample) := openItems.partition (·.exception.isSome)
exceptions ++ sample
def review (decisions : List Decision) (id : String) (verdict : Verdict)
(note : Option String) (reviewerId : String) (reviewedAt : Nat) :
Except HubError (List Decision) := do
let some target := decisions.find? (·.id == id) | throw .unknownDecision
if target.verdict.isSome then throw .alreadyReviewed
return decisions.map fun d =>
if d.id == id then
{ d with verdict := some verdict, verdictNote := note,
reviewedById := some reviewerId, reviewedAt := some reviewedAt }
else d
def recordCause (decisions : List Decision) (id : String) (cause : CauseKind) (fix : String) :
Except HubError (List Decision) := do
let some target := decisions.find? (·.id == id) | throw .unknownDecision
unless target.verdict == some .shouldHaveAsked do throw .causeRequiresShouldHaveAsked
if fix.all Char.isWhitespace then throw .fixRequired
return decisions.map fun d =>
if d.id == id then { d with cause := some cause, fix := some fix } else d
structure TrackRecord where
sampled : Nat
right : Nat
shouldHaveAsked : Nat
deriving Repr
def trackRecord (decisions : List Decision) (kind : String) : TrackRecord :=
let verdicts := (reviewed decisions kind).filter (·.sampled) |>.map (·.verdict)
{ sampled := verdicts.length,
right := verdicts.countP (· == some .right),
shouldHaveAsked := verdicts.countP (· == some .shouldHaveAsked) }
end DecisionAudit
-- With no reviewed history, every decision of a kind is sampled one in one.
theorem sampleOneIn_empty (kind : String) : DecisionAudit.sampleOneIn [] kind = 1 := by
simp [DecisionAudit.sampleOneIn, DecisionAudit.reviewed, cleanRun]
// Pure DecisionAudit sampling, review list, track record, and guards
type ExceptionKind = "no_policy" | "cannot_undo" | "undone" | "objection";
type Verdict = "right" | "should_have_asked";
type CauseKind = "policy_wording" | "policy_scope" | "agent_reading" | "missing_information";
interface Decision {
id: string;
requestId: string;
policyUseId: string | null;
decidedById: string;
kind: string;
summary: string;
optionsConsidered: string[] | null;
rationale: string;
undo: string | null;
decidedAt: Date;
outcome: string | null;
exception: ExceptionKind | null;
sampled: boolean;
verdict: Verdict | null;
verdictNote: string | null;
reviewedById: string | null;
reviewedAt: Date | null;
cause: CauseKind | null;
fix: string | null;
}
const CLEAN_RUN = 10;
const RELAXED_ONE_IN = 5;
const VALID_CAUSES: CauseKind[] = [
"policy_wording",
"policy_scope",
"agent_reading",
"missing_information",
];
class DecisionAudit {
record(
decisions: Decision[],
input: Decision,
draw: (n: number) => number = (n) => Math.floor(Math.random() * n) + 1
): Decision[] {
const exception: ExceptionKind | null =
input.exception ??
(input.policyUseId === null
? "no_policy"
: input.undo === null
? "cannot_undo"
: null);
const sampled = draw(this.sampleOneIn(decisions, input.kind)) === 1;
return [{ ...input, exception, sampled }, ...decisions];
}
reviewList(decisions: Decision[]): Decision[] {
const open = decisions
.filter((d) => d.verdict === null && (d.exception !== null || d.sampled))
.sort((a, b) => a.decidedAt.getTime() - b.decidedAt.getTime());
return [
...open.filter((d) => d.exception !== null),
...open.filter((d) => d.exception === null),
];
}
review(
decisions: Decision[],
id: string,
verdict: Verdict,
note: string | null,
reviewerId: string,
at: Date
): Decision[] {
if (verdict !== "right" && verdict !== "should_have_asked") {
throw new Error("invalid_verdict");
}
const target = decisions.find((d) => d.id === id);
if (!target) throw new Error("unknown_decision");
if (target.verdict !== null) throw new Error("already_reviewed");
return decisions.map((d) =>
d.id === id
? { ...d, verdict, verdictNote: note, reviewedById: reviewerId, reviewedAt: at }
: d
);
}
recordCause(decisions: Decision[], id: string, cause: CauseKind, fix: string): Decision[] {
const target = decisions.find((d) => d.id === id);
if (!target) throw new Error("unknown_decision");
if (target.verdict !== "should_have_asked") {
throw new Error("cause_requires_should_have_asked");
}
if (!VALID_CAUSES.includes(cause)) throw new Error("invalid_cause");
if (!fix.trim()) throw new Error("fix_required");
return decisions.map((d) => (d.id === id ? { ...d, cause, fix } : d));
}
trackRecord(decisions: Decision[], kind: string) {
const sampledVerdicts = this.reviewed(decisions, kind)
.filter((d) => d.sampled)
.map((d) => d.verdict);
return {
sampled: sampledVerdicts.length,
right: sampledVerdicts.filter((v) => v === "right").length,
shouldHaveAsked: sampledVerdicts.filter((v) => v === "should_have_asked").length,
};
}
sampleOneIn(decisions: Decision[], kind: string): number {
// Rate follows reviewed history only: unreviewed items awaiting the next check-in
// never count toward the 10-clean run, and any should_have_asked verdict resets to 1.
let cleanSampled = 0;
for (const d of this.reviewed(decisions, kind)) {
if (d.verdict !== "right") break;
if (d.sampled) cleanSampled += 1;
}
return cleanSampled >= CLEAN_RUN ? RELAXED_ONE_IN : 1;
}
private reviewed(decisions: Decision[], kind: string): Decision[] {
return decisions
.filter((d) => d.kind === kind && d.verdict !== null)
.sort(
(a, b) =>
(b.reviewedAt ?? b.decidedAt).getTime() - (a.reviewedAt ?? a.decidedAt).getTime()
);
}
}
# Pure DecisionAudit sampling, review list, track record, and guards
from dataclasses import dataclass, replace
from datetime import datetime
import random
from typing import Callable, Literal, Optional
ExceptionKind = Literal["no_policy", "cannot_undo", "undone", "objection"]
Verdict = Literal["right", "should_have_asked"]
CauseKind = Literal["policy_wording", "policy_scope", "agent_reading", "missing_information"]
CLEAN_RUN = 10
RELAXED_ONE_IN = 5
VALID_CAUSES = {"policy_wording", "policy_scope", "agent_reading", "missing_information"}
@dataclass(frozen=True)
class Decision:
id: str
request_id: str
decided_by_id: str
kind: str
summary: str
rationale: str
decided_at: datetime
options_considered: Optional[list[str]] = None
policy_use_id: Optional[str] = None
undo: Optional[str] = None
outcome: Optional[str] = None
exception: Optional[ExceptionKind] = None
sampled: bool = False
verdict: Optional[Verdict] = None
verdict_note: Optional[str] = None
reviewed_by_id: Optional[str] = None
reviewed_at: Optional[datetime] = None
cause: Optional[CauseKind] = None
fix: Optional[str] = None
class AuditError(Exception):
pass
class DecisionAudit:
def record(
self,
decisions: list[Decision],
decision: Decision,
draw: Callable[[int], int] = lambda n: random.randint(1, n),
) -> list[Decision]:
exception = decision.exception
if exception is None:
if decision.policy_use_id is None:
exception = "no_policy"
elif decision.undo is None:
exception = "cannot_undo"
sampled = draw(self.sample_one_in(decisions, decision.kind)) == 1
return [replace(decision, exception=exception, sampled=sampled), *decisions]
def review_list(self, decisions: list[Decision]) -> list[Decision]:
open_items = sorted(
(d for d in decisions if d.verdict is None and (d.exception is not None or d.sampled)),
key=lambda d: d.decided_at,
)
exceptions = [d for d in open_items if d.exception is not None]
samples = [d for d in open_items if d.exception is None]
return exceptions + samples
def review(
self,
decisions: list[Decision],
decision_id: str,
verdict: Verdict,
note: Optional[str],
reviewer_id: str,
at: datetime,
) -> list[Decision]:
if verdict not in ("right", "should_have_asked"):
raise AuditError("invalid_verdict")
target = next((d for d in decisions if d.id == decision_id), None)
if target is None:
raise AuditError("unknown_decision")
if target.verdict is not None:
raise AuditError("already_reviewed")
return [
replace(d, verdict=verdict, verdict_note=note, reviewed_by_id=reviewer_id, reviewed_at=at)
if d.id == decision_id
else d
for d in decisions
]
def record_cause(
self, decisions: list[Decision], decision_id: str, cause: CauseKind, fix: str
) -> list[Decision]:
target = next((d for d in decisions if d.id == decision_id), None)
if target is None:
raise AuditError("unknown_decision")
if target.verdict != "should_have_asked":
raise AuditError("cause_requires_should_have_asked")
if cause not in VALID_CAUSES:
raise AuditError("invalid_cause")
if not fix.strip():
raise AuditError("fix_required")
return [replace(d, cause=cause, fix=fix) if d.id == decision_id else d for d in decisions]
def track_record(self, decisions: list[Decision], kind: str) -> dict[str, int]:
verdicts = [d.verdict for d in self._reviewed(decisions, kind) if d.sampled]
return {
"sampled": len(verdicts),
"right": sum(1 for v in verdicts if v == "right"),
"should_have_asked": sum(1 for v in verdicts if v == "should_have_asked"),
}
def sample_one_in(self, decisions: list[Decision], kind: str) -> int:
# Rate follows reviewed history only: unreviewed items awaiting the next check-in
# never count toward the 10-clean run, and any should_have_asked verdict resets to 1.
clean_sampled = 0
for d in self._reviewed(decisions, kind):
if d.verdict != "right":
break
if d.sampled:
clean_sampled += 1
return RELAXED_ONE_IN if clean_sampled >= CLEAN_RUN else 1
def _reviewed(self, decisions: list[Decision], kind: str) -> list[Decision]:
return sorted(
(d for d in decisions if d.kind == kind and d.verdict is not None),
key=lambda d: d.reviewed_at or d.decided_at,
reverse=True,
)
# Pure DecisionAudit sampling, review list, track record, and guards
defmodule Decision do
@enforce_keys [:id, :request_id, :decided_by_id, :kind, :summary, :rationale, :decided_at]
defstruct [:id, :request_id, :job_id, :policy_use_id, :question_id, :decided_by_id, :kind,
:summary, :options_considered, :rationale, :undo, :decided_at, :outcome,
:exception, :verdict, :verdict_note, :reviewed_by_id, :reviewed_at, :cause, :fix,
sampled: false]
end
defmodule DecisionAudit do
@clean_run 10
@relaxed 5
@valid_causes [:policy_wording, :policy_scope, :agent_reading, :missing_information]
def record(decisions, %Decision{} = d, draw \\ &:rand.uniform/1) do
exception =
cond do
d.exception != nil -> d.exception
d.policy_use_id == nil -> :no_policy
d.undo == nil -> :cannot_undo
true -> nil
end
sampled = draw.(sample_one_in(decisions, d.kind)) == 1
[%{d | exception: exception, sampled: sampled} | decisions]
end
def review_list(decisions) do
{exceptions, sample} =
decisions
|> Enum.filter(&(&1.verdict == nil and (&1.exception != nil or &1.sampled)))
|> Enum.sort_by(& &1.decided_at, DateTime)
|> Enum.split_with(&(&1.exception != nil))
exceptions ++ sample
end
def review(_decisions, _id, verdict, _note, _reviewer_id, _at)
when verdict not in [:right, :should_have_asked],
do: {:error, :invalid_verdict}
def review(decisions, id, verdict, note, reviewer_id, at) do
case Enum.find(decisions, &(&1.id == id)) do
nil ->
{:error, :unknown_decision}
%Decision{verdict: existing} when not is_nil(existing) ->
{:error, :already_reviewed}
_target ->
updated =
Enum.map(decisions, fn
%Decision{id: ^id} = d ->
%{d | verdict: verdict, verdict_note: note, reviewed_by_id: reviewer_id, reviewed_at: at}
d ->
d
end)
{:ok, updated}
end
end
def record_cause(decisions, id, cause, fix) do
with %Decision{} = d <- Enum.find(decisions, &(&1.id == id)) || {:error, :unknown_decision},
true <- d.verdict == :should_have_asked || {:error, :cause_requires_should_have_asked},
true <- cause in @valid_causes || {:error, :invalid_cause},
true <- is_binary(fix) and String.trim(fix) != "" || {:error, :fix_required} do
updated =
Enum.map(decisions, fn
%Decision{id: ^id} = row -> %{row | cause: cause, fix: fix}
row -> row
end)
{:ok, updated}
end
end
def track_record(decisions, kind) do
verdicts = decisions |> reviewed(kind) |> Enum.filter(& &1.sampled) |> Enum.map(& &1.verdict)
%{
sampled: length(verdicts),
right: Enum.count(verdicts, &(&1 == :right)),
should_have_asked: Enum.count(verdicts, &(&1 == :should_have_asked))
}
end
def sample_one_in(decisions, kind) do
# Rate follows reviewed history only: unreviewed items awaiting the next check-in
# never count toward the 10-clean run, and any should_have_asked verdict resets to 1.
run =
decisions
|> reviewed(kind)
|> Enum.take_while(&(&1.verdict == :right))
|> Enum.count(& &1.sampled)
if run >= @clean_run, do: @relaxed, else: 1
end
defp reviewed(decisions, kind) do
decisions
|> Enum.filter(&(&1.kind == kind and &1.verdict != nil))
|> Enum.sort_by(&(&1.reviewed_at || &1.decided_at), {:desc, DateTime})
end
end
Execution trace
Walking Example 2 (weekly bug-fix merges) through these guards shows
exception-first ordering, a should_have_asked verdict
snapping sample_one_in back to 1,
rejection of repeat reviews and misplaced causes, and recording a root-cause fix:
1. # Prior history has 10 clean reviewed samples -> sampleOneIn("merge_bug_fix") == 5.
# On Wednesday dec_retry_rollback is logged as an exception (pending Friday check-in).
# Because sampling reads reviewed history, later merges still draw 1-in-5 until Friday.
# Merge dec_invoice_export (with optionsConsidered + rationale) is drawn into the sample:
decisions = audit.record(decisions, dec_invoice_export, draw: () => 1)
audit.reviewList(decisions).map(d => d.id)
-> ["dec_retry_rollback" (exception first), "dec_invoice_export" (sampled)]
2. # Friday check-in: Requester reads summary, optionsConsidered, and rationale, then marks miss:
decisions = audit.review(decisions, "dec_invoice_export", "should_have_asked",
"Added a column to the invoices table.", "dana", new Date("2026-11-20T16:10:00Z"))
audit.sampleOneIn(decisions, "merge_bug_fix")
-> ok (sampleOneIn immediately snaps back to 1 until 10 new clean samples pass)
3. audit.review(decisions, "dec_invoice_export", "right", "Changed mind", "dana", new Date("2026-11-20T16:12:00Z"))
-> error: already_reviewed (a decision gets a verdict only once)
4. audit.recordCause(decisions, "dec_retry_rollback", "missing_information", "List tables.")
-> error: cause_requires_should_have_asked (only misses take a root cause and fix)
5. decisions = audit.recordCause(decisions, "dec_invoice_export", "missing_information",
"Checker findings must now list every database table touched by a diff.")
-> ok (policy remains active; next 10 sampled merges are reviewed 1-in-1 until trust rebuilds)
6. # Exception without undo path is always shown, even if draw returns 5:
decisions = audit.record(decisions, dec_email_blast_no_undo, draw: () => 5)
-> exception: "cannot_undo", sampled: false (queued at top of reviewList; excluded from trackRecord)
Tradeoffs and practical guidance
Decision Audit gives you statistical confidence in delegated autonomy at a fraction of the cost of reviewing everything, with three honest constraints:
- Detection happens after the act: a bad decision has already taken effect by the time Friday's sample surfaces it. Reserve irreversible or high-severity steps for a pre-action Policy Gate.
-
Rare misses can slip past a 1-in-5 sample: sampling catches systemic
drift quickly, not every 1-in-100 edge case — which is why exception triggers
(
undone,no_policy,cannot_undo,objection) always bypass sampling. - Requires real check-in time: the pattern only pays off when reviewing the small sample takes noticeably less time than answering all the questions the policy removed.
Practical implementation notes
-
Choose
kindgranularity carefully: a category too broad (likeall_actions) hides risky acts behind safe ones; a category too narrow never accumulates ten verdicts to relax sampling. -
Attach independent hub outcomes: the agent under review wrote the
summary, so let the hub populateoutcomefrom its own telemetry (staging rollbacks, error rates, reopened tickets) before the requester's check-in. -
Separate outcome luck from delegation judgment: a merge that was rolled
back in staging can still earn a
rightverdict if the agent had proper authority to attempt it, while a bug-free schema change still earnsshould_have_asked. - Never let sampling drop to zero: even after dozens of clean verdicts, keep a floor (such as 1-in-5 or 1-in-10) so future model, codebase, or workflow drift is still caught early.
Known uses and related patterns
- Apache commit-then-review: trusted committers land changes immediately while peers review afterward and can issue a technical veto that triggers a revert; Decision Audit focuses specifically on whether the agent should have asked first.
- Amazon Augmented AI (A2I): routes low-confidence predictions (exceptions) plus a configurable random sample of routine predictions into human review loops.
- LangSmith automation rules: filters production LLM traces and routes a sampled percentage into human annotation queues for ongoing quality measurement.
- Manufacturing acceptance sampling: inspects random samples from production lots and tightens inspection automatically whenever a defect appears.
- Volgenic: records autonomous agent and hub calls with summaries and undo notes so returning requesters can inspect what happened without interrupting live work.
- Contrast with Martin Fowler's Audit Log: a standard Audit Log records data mutations for forensic lookup; Decision Audit logs delegated judgments with undo paths, active random sampling, requester verdicts, and adaptive review rates.
Related patterns
- Delegation Policy — supplies the
PolicyandPolicy usebehind each decision, and executes any policy changes the requester decides on after auditing. - Escalation Chain — settles routine questions below the requester; Decision Audit verifies those lower stops are making the right calls.
- Policy Gate — prevents risky or irreversible steps before they happen, complementing Decision Audit's after-the-fact spot checks.
- Question Inbox — establishes the check-in cadence at which the requester reviews the derived Review list.
- Orchestrator-Workers, Durable Job, and Self-Contained Question — define the
Request,Party,Job, andQuestionrecords referenced by everyDecision.