Four-eyes principle
The four-eyes principle is a control that requires a second person to approve what the first person did, so nobody can approve their own request, payment or change. It is a form of separation of duty, and in Meadowstack it is a rule of every approval flow: the person who filed a record never sees the approve button on it.
By Bohuslav PoláčekChecked
elsif (old.status, new.status) in (('submitted', 'approved'), ('submitted', 'rejected')) then
if old.requester_id = me or my_role not in ('approver', 'admin') then
raise exception 'You don''t have permission to do that.' using errcode = '42501';
end if;
if new.status = 'rejected' and coalesce(length(btrim(new.decision_reason)), 0) = 0 then
raise exception 'Write why the request is rejected.' using errcode = '22023';
end if;
new.decided_by_id := me;
new.decided_by_name := public.app_name();
if new.status = 'approved' then
new.decision_reason := null;
end if;
return new;Why it matters in a business app
Most fraud and most expensive mistakes in purchasing need one person to both ask and approve. A second pair of eyes stops the obvious cases and makes the rest visible: two names on every decision, both in the history.
NIST's glossary describes the general idea, separation of duty, as no user holding enough privileges to misuse the system alone, and names the two-person rule as its dynamic form.
How Meadowstack handles it
It is a rule in the root AGENTS.md, so people and coding tools meet it on every task: "Four-eyes: nobody approves their own record. Rejecting always needs a reason."
- The rule. In the starter,
request.approveandrequest.rejectneed the approver or admin role and a record the person did not write (!mineincanFor). - The screen. The decision card, ApprovalPanel, shows the requester a sentence instead of buttons; a rejection needs a reason before it can be sent.
- The simulated api asks the same rule before it changes anything.
- The database, in the Supabase example, refuses the move in a trigger (above), because a row policy cannot compare who decides with who asked across the change.
Steps 3 and 4 are yours to carry into a real backend in 2.1. See the approval flow pattern.
Common mistakes
- Admins exempt. An admin who may approve their own purchase is the exact hole the rule closes. The starter applies it to admins too.
- Only a hidden button. The requester calls the api, and the request is approved.
- Bulk approve skips the check. The example's bulk function fails the whole call when one row is not the caller's to decide, rather than skipping it.
- The second person is the same account. Shared logins defeat the rule; it needs real, named sign-in.
What each person sees
Sources
Questions
Is the four-eyes principle the same as segregation of duties?
It is one form of it. Segregation of duties splits incompatible tasks between people in general; four-eyes is the specific rule that a second person approves what the first one did.
Can an admin override the four-eyes rule in Meadowstack?
Not in the starter: an admin may decide on other people's requests, never their own. Change the rule in domain/permissions.ts and in your database if your process truly needs an exception, and record why.
What if a team has only one approver?
Their own requests then wait for someone else with the role, often an admin. That is the rule working; give a second person the approver role rather than removing it.
Related
- A change order that shows its price before anyone approves itScreens
- A proof the customer approves in their own portalScreens
- A time-off request waiting for a decisionScreens
- Team and roles, with the rules in codeScreens
- ApprovalPanel: the decision card on a recordComponents
- AssistantPanel: the assistant beside the pageComponents
Two ways
Build it yourself, or have it built
Build it yourself
Build your app on the framework
Get the codebase these apps stand on and build yours with Claude Code, Cursor or Codex.
One payment, lifetime updates
Get the frameworkHave it built
Have us build your app
Tell us how your team works. We plan the app with you and build it on the same framework at a fixed price.
After launch, Care keeps it improving, from €99 a month.
from €1,990
Describe your app