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. You should also be comfortable reading simple Python.
What an approval gate is
An approval gate is a point in the workflow where an item cannot move forward until a qualified person says yes. A gate is not a suggestion or a notification. The system enforces it, so skipping the gate is impossible and not just discouraged.
A gate has three parts:
- A trigger: the transition it guards, such as
IN_REVIEWtoAPPROVED. - A decider: who is allowed to approve.
- A binding: what exactly was approved. For content, this is the exact text, not "the item" in general.
Where to put gates
Put a gate wherever a mistake becomes expensive to undo. Publishing is the obvious case, because readers see the text and a retraction is public. Every extra gate adds delay, so do not gate steps that are cheap to reverse.
In the draft-and-approve pipeline, two places matter most:
- Before publication. This is the main gate: a person other than the author approves the draft.
- Before the brief is trusted for sensitive topics. Some teams add an earlier gate where a subject expert signs off on the sources the model may use.
The AI drafting step itself needs no gate. A draft is only a proposal, and it has no effect until it passes the review gate.
Enforcing the gate in code
The Item class from the earlier chapter enforces the gate in two ways. The ALLOWED table makes APPROVED reachable only from IN_REVIEW. The approve method refuses the author.
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)The last line is the binding. It stores a SHA-256 hash (a fixed-length fingerprint of the text) at the moment of approval. Changing even one character produces a different hash.
At publish time, the code compares the hashes:
def publish(self, actor):
if self.approved_digest != digest(self.text):
raise ValueError("text differs from the approved version")
self._move(State.PUBLISHED, actor)This closes a common hole. Without the hash, someone could get approval and then edit the text before publishing. The revise method also blocks edits once an item is in review or approved, so the hash check is a second line of defense.
Gates need more than one approver at higher risk
One approver is enough for routine content. For high-risk content, require several independent approvers, and never count the author.
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 because only one independent approver exists. The second prints True. Using a set means the same person approving twice counts once.
Common errors
| Error | Result | Fix |
|---|---|---|
| Approval is stored as a flag on the item | Text can change after approval | Store a hash of the approved text |
| The gate is a convention, not code | Under deadline pressure, people skip it | Make the transition fail in the system |
| The author can approve | No independent check | Reject `reviewer == author` |
| Too many gates | Reviewers approve without reading | Gate only costly-to-reverse steps |
| Approver has no domain knowledge | Approval carries no meaning | Assign approvers by role |
Design checklist
- Name the transition each gate guards.
- State who may approve and who may not.
- Bind approval to the exact text.
- Make bypassing the gate an error, not an option.
- Match the number of approvers to the risk.
Exercise
An editor approves a draft on Monday. On Tuesday a colleague fixes a typo directly in the stored text, and then someone clicks Publish. With the code in this chapter, what happens and why?
Show answer
Publishing raises ValueError("text differs from the approved version"). The approved hash was computed on Monday's text, and the typo fix changed the text, so the hashes no longer match. The item must go back through review and be approved again before it can be published.
Exercise
Using can_publish, what does can_publish("high", {"ben", "ana"}, "ben") return, and why?
Show answer
It returns False. Ben is the author, so he is removed from the approver set. Only Ana remains, which is one independent approver, and the high tier requires two.