Sub topic 5
Where and how to place approval gates
This chapter assumes you have read the earlier chapters on the pipeline overview and on modeling content as states and transitions. It also assumes you can read simple Python. By the end you should be able to decide which transitions in a content workflow need a human gate and how to build a gate that cannot be bypassed.
What an approval gate is
An approval gate is a transition in your state machine that the system refuses to perform until a qualified person has recorded a decision. The word "refuses" matters. A gate is not a convention such as "please get a second opinion". The code or platform enforces it, so that skipping it is impossible without leaving a trace.
A working gate has four properties:
- A named decision. The gate has an approve outcome and a reject or request-changes outcome, and the person must choose one.
- A qualified decider. Only people with the right role can decide. The author is never one of them for their own item.
- A bound subject. The approval applies to one exact version of the text, not to "the item" in general.
- Enforcement at the transition. The next step checks that the approval exists and is still valid.
If any of the four is missing, you have a ritual, not a gate.
Where to place gates
Gates cost time, and each one adds waiting. Putting a gate after every step teaches reviewers to click through. Put gates where a wrong decision is expensive or hard to undo.
| Candidate location | Gate? | Reason |
|---|---|---|
| Brief to AI draft | Usually no | A bad brief produces a bad draft, which review will catch. The cost of the mistake is low. |
| AI draft to human review | No, use automated checks | This hand-off is mechanical. Cheap checks filter obvious problems first. |
| Review to approved | Yes | This is the main gate. A person with judgment decides whether the text is acceptable. |
| Approved to published | Yes, enforced by the system | This step is public and hard to retract. It must verify the approval. |
| Published to updated | Yes | A change to live content needs the same scrutiny as the original. |
The rule of thumb is to gate before irreversible or externally visible actions, and before steps that consume expensive downstream effort, such as translation or design. Reversible internal steps rarely need one.
Some content needs a gate earlier. If the brief itself carries commitments, such as pricing, legal claims, or quotes attributed to named people, have someone sign off on the brief's facts before drafting. Otherwise a reviewer later has to discover that the sources were wrong.
The pipeline with gates marked
Gate 1 is a human decision. Gate 2 is a machine check that a human decision exists and still applies. You need both. Gate 1 without Gate 2 allows text to change after approval and then go out under the approval's authority.
Building the gates in code
This implementation uses the state machine from the earlier chapter. The allowed-transitions table already blocks illegal moves. The two gate-specific parts are approve (separation of duties) and publish (the digest check).
import hashlib
from dataclasses import dataclass, field
from datetime import datetime, timezone
from enum import Enum
class State(Enum):
DRAFT = "draft"
IN_REVIEW = "in_review"
CHANGES_REQUESTED = "changes_requested"
APPROVED = "approved"
PUBLISHED = "published"
ALLOWED = {
State.DRAFT: {State.IN_REVIEW},
State.IN_REVIEW: {State.APPROVED, State.CHANGES_REQUESTED},
State.CHANGES_REQUESTED: {State.IN_REVIEW},
State.APPROVED: {State.PUBLISHED},
State.PUBLISHED: set(),
}
def digest(text):
return hashlib.sha256(text.encode("utf-8")).hexdigest()
@dataclass
class Item:
text: str
author: str
state: State = State.DRAFT
approved_digest: str | None = None
log: list = field(default_factory=list)
def _move(self, new_state, actor, note=""):
if new_state not in ALLOWED[self.state]:
raise ValueError(f"cannot go from {self.state.value} to {new_state.value}")
self.log.append({
"at": datetime.now(timezone.utc).isoformat(),
"actor": actor,
"from": self.state.value,
"to": new_state.value,
"note": note,
})
self.state = new_state
def submit(self, actor):
self._move(State.IN_REVIEW, actor)
def approve(self, reviewer):
if reviewer == self.author:
raise PermissionError("the author cannot approve their own item")
self._move(State.APPROVED, reviewer)
self.approved_digest = digest(self.text)
def publish(self, actor):
if self.approved_digest != digest(self.text):
raise ValueError("text differs from the approved version")
self._move(State.PUBLISHED, actor)
item = Item(text="Spring sale starts Monday.", author="ben")
item.submit("ben")
try:
item.approve("ben")
except PermissionError as err:
print("blocked:", err)
item.approve("ana")
item.text = "Spring sale starts Monday. Everything is half price."
try:
item.publish("ana")
except ValueError as err:
print("blocked:", err)
item.text = "Spring sale starts Monday."
item.publish("ana")
print(item.state)The run prints three lines: the self-approval block, the text-changed block, and State.PUBLISHED.
Three details are worth noticing:
- The digest is a SHA-256 hash, a fixed-length fingerprint of the text. Changing even one character changes the fingerprint, so "approved" is tied to exact content.
approvechecks the reviewer against the author before moving state. The check runs on every approval, so there is no code path where it is skipped.- The demo edits
item.textdirectly to simulate a bypass, such as a script or a manual database edit.publishstill catches it, because the check compares content and does not rely on every caller behaving.
Make approval specific to a version
The most common gate defect is approving "the item" while the item keeps changing. Reviewers read version 3, and version 4 goes out. There are two ways to prevent this.
- Lock the text during review and after approval. The
revisemethod in the earlier chapter only works in Draft and Changes requested. Review therefore sees stable text. - Verify at publish time. The digest comparison above catches any change that gets around the lock.
When the digests differ, the correct response is to send the item back to review, not to let someone override the check. If you permit overrides, record who overrode it and why, and treat each override as an event you will review later.
Who can open a gate
Approval needs identity and role, not just a name in a text field. Define who may approve for each kind of content. A legal reviewer may approve claims about contracts, and an editor may approve tone and structure. Check the role when the approval is recorded, not afterwards.
Two cases need explicit rules:
- The AI model. The model that drafted the text must never count as an approver, and neither should a second model acting alone. A model can run automated checks and produce a report for the human, but a person records the decision. If a service account performs the approve action on a person's behalf, you have lost the gate.
- Delegation. If reviewers can delegate approval, the delegate must hold the required role. Otherwise delegation becomes a way to route around separation of duties.
How many approvals a piece needs depends on its risk. The next chapters cover tiers in detail, but the principle is already visible in a small function:
REQUIRED_APPROVALS = {"low": 1, "medium": 1, "high": 2}
def can_publish(risk_tier, approvers, author):
independent = {name for name in approvers if name != author}
return len(independent) >= REQUIRED_APPROVALS[risk_tier]
print(can_publish("high", {"ana"}, "ben"))
print(can_publish("high", {"ana", "carla"}, "ben"))The first call prints False and the second prints True. Using a set means one person approving twice still counts once.
Common mistakes
- Gates on everything. Reviewers approve in bulk without reading. Remove gates that rarely change an outcome and keep the ones that do.
- Gate in the tool, bypass in the side door. If an administrator can write directly to the published store, the gate protects nothing. Route every publishing path through the same check.
- Approval stored but never checked. A log entry saying "approved by Ana" does nothing unless the publish step reads it.
- No record of rejection. A request-changes decision is as important as an approval. Store the note, because the revision loop depends on it.
- Reviewer sees only a diff of the AI's last change. For a first review they need the whole text and the brief, so they can judge whether the draft met its purpose.
Check your understanding
Exercise
A teammate proposes this publish function: it checks that state == State.APPROVED and then publishes. Approved items can be edited by anyone with the "editor" role to fix typos. Name the defect, and describe the smallest change that fixes it.
Show answer
The state check proves that someone approved some earlier version, not the text that is about to go out. An editor's "typo fix" can change meaning (for example, a price) and still be published under the old approval. Fix it by storing a digest of the text at approval time and comparing it with the digest of the current text in publish. If they differ, refuse and send the item back to review. Optionally also stop edits in the Approved state.
Exercise
Your pipeline has gates at brief, draft, review, translation, and publish, and reviewers now approve most items in under ten seconds. Which gates would you keep, which would you remove or replace, and why?
Show answer
Keep the review gate and the publish gate, because they precede the externally visible and hard-to-reverse step and require judgment. Replace the draft gate with automated pre-checks, because it is a mechanical hand-off. Remove the brief gate unless the brief carries factual or legal commitments. Keep the translation gate only if translation is costly or the translated text is reviewed separately. Ten-second approvals suggest reviewers are rubber-stamping, and fewer, better-placed gates help.