Sub topic 7
Automated checks before a human reads
This chapter assumes you know how the pipeline moves an item through states, and that you can read simple Python. It covers cheap automated checks that run after the AI draft is written and before a reviewer opens it.
Why check before review
A reviewer's time is the scarcest resource in the pipeline. If a person spends ten minutes reading a draft only to find a leftover TODO or a banned claim, that time was wasted. Automated checks catch mechanical problems first, so the human can focus on judgment: accuracy, tone, and fit for the audience.
Automated checks do not replace review. They only remove problems a program can find reliably.
Where the checks sit
The checks run when the author submits a draft. If they find problems, the item goes back for revision and no reviewer is notified.
A check that returns reasons
A good check returns a list of reasons instead of a bare pass or fail. The author can then fix each problem without guessing.
import re
BANNED_PHRASES = ["guaranteed", "risk-free"]
def pre_checks(text):
problems = []
if "TODO" in text:
problems.append("contains a TODO marker")
for phrase in BANNED_PHRASES:
if re.search(rf"\b{re.escape(phrase)}\b", text, re.IGNORECASE):
problems.append(f"contains banned phrase: {phrase}")
return problems
draft = "Our plan is guaranteed to work. TODO: add pricing."
print(pre_checks(draft))Running this prints ['contains a TODO marker', 'contains banned phrase: guaranteed']. An empty list means the draft passed.
Two details matter here:
re.escapetreats the phrase as plain text, so a phrase containing characters such as.or-cannot change the pattern.\bmatches word boundaries, so "guaranteed" is flagged but a longer word that merely contains it is not.
What to check automatically
Good candidates are rules with a clear yes or no answer:
| Check | Example |
|---|---|
| Leftover markers | `TODO`, `[insert name]`, `lorem ipsum` |
| Banned or required phrases | Banned claims, a required disclaimer |
| Length limits | Title under 70 characters |
| Structure | Required headings are present |
| Links | Every URL is well formed |
| Sensitive data | Patterns that look like email addresses or keys |
Questions such as "Is this claim true?" or "Does this suit our readers?" need a person. A program that guesses at them produces false confidence.
Connecting checks to the state machine
Run the checks inside the submit step. If they return problems, refuse the transition and report the reasons. The item stays in DRAFT, so a reviewer never sees it.
def submit_with_checks(item, actor):
problems = pre_checks(item.text)
if problems:
return problems
item.submit(actor)
return []This uses the Item class from the earlier chapter on states. Placing the check at the gate means no one can skip it by accident.
Common errors
- Too many rules. Authors learn to ignore a noisy checker. Keep only rules whose failures you would always want fixed.
- Treating a pass as approval. A clean result means "no mechanical problems found". Tell reviewers this, so they do not relax.
- Silent failures. A check that errors out and returns an empty list looks like a pass. Make a crashed check block the item.
- Checking an old version. Run the checks on the exact text being submitted, and again after any revision.
Exercise
Your pre_checks function crashes with an exception on unusual input, and the calling code catches the exception and returns an empty list. What is the risk, and what should happen instead?
Show answer
The crash looks like a pass, so a draft that was never checked reaches a human reviewer, who assumes it was. Instead, treat a crashed check as a failure: let the exception stop the submission, or return a problem such as "checks could not run". The item should stay in DRAFT until the checks complete.