Sub topic 7
Automated checks before a human reads
This chapter assumes you have read the earlier chapters on content states and approval gates. You should know that a draft moves from DRAFT to IN_REVIEW through a submit call, and you should be able to read short Python functions and regular expressions.
Why check before a person reads
A reviewer's attention is the scarcest resource in the pipeline. If a draft reaches review with a leftover TODO, a banned claim, or a missing section, the reviewer spends time on a problem a script could have found. The draft then goes back, and the review cycle is wasted.
An automated pre-check is a set of cheap, deterministic rules that run on a draft before it enters review. Its job is narrow:
- Catch mechanical problems that have a clear yes or no answer.
- Return the reasons for each failure, so the author knows what to fix.
- Leave judgment (tone, accuracy, fit for the audience) to people.
Pre-checks do not approve anything. A draft that passes every check has only shown that it is worth a human's time.
What belongs in a pre-check
A rule is a good candidate for automation when you can state it without the word "feels". These categories work well:
| Category | Example rule | Typical severity |
|---|---|---|
| Leftovers | No `TODO`, `[insert name]`, or lorem ipsum | Block |
| Policy phrases | No "guaranteed" or "risk-free" in marketing copy | Block |
| Structure | Required headings present, title under 70 characters | Block or warn |
| Length | Between 150 and 300 words | Warn |
| Links | Every URL is well formed and uses https | Warn |
| Sources | Every statistic has a citation marker | Warn |
Tone, factual accuracy, and whether the piece answers the brief are not on this list. Keyword matching cannot judge them, and pretending otherwise produces false confidence. Those belong in the review rubric from the later chapter on review criteria.
A checker that returns reasons
The simplest checker returns a list of strings, which is how the topic's base example works. An intermediate-level checker returns structured findings, so the workflow can tell a blocker from a suggestion. The code below uses only the standard library.
import re
from dataclasses import dataclass
BANNED_PHRASES = ["guaranteed", "risk-free"]
MIN_WORDS = 150
MAX_WORDS = 300
@dataclass(frozen=True)
class Finding:
rule: str
severity: str # "block" or "warn"
message: str
def pre_checks(text):
findings = []
if re.search(r"\bTODO\b", text):
findings.append(Finding("todo_marker", "block", "contains a TODO marker"))
if re.search(r"\[(?:insert|placeholder)[^\]]*\]", text, re.IGNORECASE):
findings.append(Finding("placeholder", "block", "contains a bracketed placeholder"))
for phrase in BANNED_PHRASES:
if re.search(rf"\b{re.escape(phrase)}\b", text, re.IGNORECASE):
findings.append(
Finding("banned_phrase", "block", f"contains banned phrase: {phrase}")
)
words = len(text.split())
if words < MIN_WORDS:
findings.append(Finding("too_short", "warn", f"{words} words, minimum is {MIN_WORDS}"))
elif words > MAX_WORDS:
findings.append(Finding("too_long", "warn", f"{words} words, maximum is {MAX_WORDS}"))
return findings
def ready_for_review(text):
findings = pre_checks(text)
blockers = [f for f in findings if f.severity == "block"]
return len(blockers) == 0, findings
draft = "Our plan is guaranteed to work. TODO: add pricing."
ok, findings = ready_for_review(draft)
print(ok)
for f in findings:
print(f"[{f.severity}] {f.rule}: {f.message}")Running it prints False, followed by three lines: the TODO marker, the banned phrase "guaranteed", and a warning that the draft is far under the minimum length. Each finding names its rule, so the author sees what failed and why. A bare False would tell them nothing.
A few details in this code matter:
re.escapestops a phrase containing regex characters, such as a dot or plus sign, from being read as a pattern.\banchors match whole words. Without them, a rule for "guaranteed" would also flag "unguaranteed".re.IGNORECASEcatches "Guaranteed" at the start of a sentence. TheTODOrule stays case sensitive on purpose, because a lowercase "todo" is often ordinary prose.
Block versus warn
Two severity levels keep the checks from becoming either toothless or annoying.
- A block stops the draft from entering review. Use it for things that must never reach a reviewer or a reader: leftover markers, banned claims, missing required sections.
- A warn lets the draft through but attaches the finding to the review request. Use it for things a human should weigh, such as length or a link that could not be verified.
If every rule blocks, authors learn to game the rules, for example by padding a short draft just to clear a word count. If nothing blocks, reviewers learn to ignore the warnings. Start with few blockers, and promote a warning to a block only after you see a human reviewer catching the same issue repeatedly.
Where the checks sit in the workflow
Run the checks at the DRAFT to IN_REVIEW transition. If there are blockers, the item stays in DRAFT and the author gets the findings. If there are none, the item moves to review with any warnings attached.
Two design choices keep this reliable:
- Put the check inside the transition, not beside it. If
submititself calls the checker and refuses to move the state when blockers exist, nobody can skip the step by forgetting to run a script. A check that is only a convention will eventually be skipped. - Check the exact text that will be reviewed. Run the checks again after every revision. A draft that passed once can pick up a
TODOduring the next edit.
Recording the results
Store each check run with the item, in the same log that holds state changes. Record the rule names, severities, and a digest of the text that was checked. This gives the audit trail two useful facts: the draft was checked, and it was checked in the form that was later approved. The later chapter on audit trails builds on this.
Edge cases and common errors
- False positives. A banned-phrase rule will flag a sentence like "we never say 'guaranteed'" in an internal style guide. Allow a documented override, recorded with the person's name and a reason, rather than weakening the rule for everyone.
- False negatives. A rule for "guaranteed" misses "100% certain to succeed". Pattern lists catch known problems, not new ones. When a reviewer finds a new banned claim, add it to the list.
- Checks that read model output. The text being checked is untrusted. If you run a model-based check, such as asking another model whether the draft makes unsupported claims, treat its answer as a warning only. Model checks are not deterministic, so a draft that passes them has no guarantee behind it.
- Slow or flaky checks. Link validation that fetches every URL can fail because a server was briefly down. Mark network-dependent checks as warnings, and report "could not verify" separately from "broken".
- Rule drift. Rules accumulate. Review the list every few months and delete rules that never fire, or that reviewers always override.
- Checks reported as approval. Do not display "passed all checks" in the same place as "approved". Readers will conflate them. Show them as separate lines in the review request.
What pre-checks do not replace
Passing the checks does not mean the content is accurate, appropriate, or good. It is tempting to let a green result lower the reviewer's guard, which is a form of automation bias, covered in the chapter on review failure modes. Make the review request say what was checked and what was not, for example: "Checked: placeholders, banned phrases, length. Not checked: factual accuracy, tone."
Summary of the working model
- Pre-checks are deterministic rules that run at the
DRAFTtoIN_REVIEWtransition. - Each failure returns a rule name, a severity, and a message.
- Blockers stop the transition. Warnings travel with the draft to the reviewer.
- Checks run again after every revision, on the exact text under review.
- Results are logged with the item, and they never stand in for human approval.
Exercise
A draft passes pre_checks with no findings. The author then fixes a typo, and the item is resubmitted. A teammate argues the checks do not need to run again because the draft already passed. Give two reasons the checks should run again, and say what the system should record.
Show answer
First, any edit can introduce a new problem, such as a stray TODO or a changed phrase, so a pass applies only to the exact text that was checked. Second, the reviewer and the later approval hash refer to the final text, so the checks must cover that same text. The system should record the rule results together with a digest of the checked text and a timestamp in the item's log. That shows the approved version was the one that passed the checks.
Exercise
Your team finds that reviewers keep rejecting drafts for using the word "cheap" in product descriptions. Should you add "cheap" to BANNED_PHRASES as a blocker? Explain your choice.
Show answer
Start with a warning, not a blocker. "Cheap" may be acceptable in some contexts, such as "cheap to run", so a blocker would produce false positives and encourage authors to work around the rule. If reviewers still reject the word almost every time after several weeks, promote the rule to a blocker. Add a documented override for legitimate uses.