Repository navigation
QC Gate
Every draft passes qc.py check before it is sent. The checks are filters: data in
playbook/qc/filters.json, each with a type, a severity, where it applies, a message, the incident or rule it came
from, and examples it must catch and examples it must pass. The names and phrases filters look for (your app's
names, competitors, never-say claims...) are in playbook/qc/lists.json.
The gate has two halves:
-
qc.py checkgives a verdict and writes a receipt. -
audit.py addrefuses to log a reply or post whose exact words have no passing receipt.
So a draft that skipped QC can't be logged quietly, and a mistake that got through once becomes a filter that runs on every later draft.
| Severity | Means | What to do |
|---|---|---|
block |
The draft can't go out. | Fix it and check again. audit.py add refuses the text unless --override "why", which the run report lists. |
warn |
The draft can go out. | The warning is recorded on the receipt and the audit entry, and run.py finish lists it for the report. |
ask |
A judgment a script can't make ("which README did you read for this claim?"). | Answer with --ok <id>="evidence" and check again. An unanswered ask blocks. |
A block filter marked "waivable": true also takes --ok <id>="why", for the cases where the rule really
doesn't apply (a link the thread asked for, a comment on your own channel). An answered ask or a waived block
prints as OK with the answer, and the answer is stored on the receipt.
The verdict is block if any block finding isn't waived or any ask isn't answered, warn if anything warned, otherwise pass.
python playbook/qc.py check --platform X --account @acmenotes_demo --action reply --text-file draft.txt --target https://x.com/a_reader/status/3001| Flag | Notes |
|---|---|
--platform, --account, --action
|
Required. Use the platform and handle exactly as pb.py accounts prints them. |
--text-file FILE or --text "..."
|
Exactly one of them. Prefer a file: the words you check, send and log must match. |
--target URL |
What a reply answers. Required for reply and comment. |
--target-author NAME |
The person replied to. Read from the target link on X, Bluesky, Threads and Instagram; give it yourself elsewhere. Required for replies when the link doesn't show it. |
--place PLACE |
Where it goes: a subreddit, a group, a channel. Caps, duplicates and question ratio compare within a place. |
--project ID |
The app it is about (a key in lists.json projects). Turns on that app's never-say list. |
--promo / --no-promo
|
Whether it promotes the owner's app. Without either, a draft is promo when it names one of the apps in lists.json projects, or --project is one of them. |
--recipe ID |
Defaults to the open run's recipe. Some filters apply only to one recipe. |
--media FILE |
Repeatable. Turns on filters for posts with images or video. |
--scheduled-for TIME |
For a scheduled post: time-based checks (caps, spacing) use this time instead of now. |
--ok ID="EVIDENCE" |
Repeatable. Answers an ask, or waives a waivable block. The id must be a real filter id. |
Actions are grouped into two kinds that filters use: reply and comment are replies; post, article,
video, reel, short, carousel and quote are posts. Any other action gets only the filters that don't ask
for a kind, with a note on stderr.
Output lists findings, blocks first, then the verdict:
ASK facts-read it is about the owner's app: which README, CHANGELOG or release did you read this session for every claim? (URL or commit) (answer: --ok facts-read="...")
BLOCKED (qc-20261118T181032-8d63d7): fix the draft and check again; audit.py add refuses this text unless --override "why"
Exit codes: 0 pass or pass with warnings, 1 blocked, 2 the command line was wrong or a file couldn't be read
(including a missing draft file, an empty draft, a reply without --target, an --ok for an unknown filter, or a
malformed filters.json).
Write the evidence, not a promise: what you read, where, this session.
python playbook/qc.py check ... --ok "facts-read=README section Tags, read this session"
python playbook/qc.py check ... --ok "links-in-reply=they asked for the install guide link"Quoting the whole id=evidence argument works the same in bash and PowerShell. Answers are trimmed to 400
characters on the receipt.
Every check, whatever its verdict, appends a receipt to playbook/audit/qc.jsonl (ignored by git): its id, the
time, a hash of the words, platform, account, action, place, project, recipe, target, verdict, every finding, and
the first 80 characters of the text. python playbook/qc.py receipts [-n 20] lists the latest.
When you log a send, audit.py add looks for the newest receipt that matches:
- the same words: the hash ignores differences in whitespace and line endings, nothing else;
- the same platform and account (not case-sensitive);
- made within the last 72 hours.
Then:
| Newest matching receipt | audit.py add |
|---|---|
| none | Refused: "no QC receipt for this text on X @handle in the last 72 hours", with the exact qc.py check command to run |
| blocked | Refused, with the filters that blocked |
| pass or warn | Logged. The entry records the receipt id in qc and any warning filter ids in qc_warn. |
--override "why" logs it anyway. The reason is stored as qc_override and run.py finish lists it under "QC
overrides".
The gate covers entries with status live, pending or scheduled and an action of either kind (reply or
post). A reply, comment, post or quote must include its words (--text or --text-file) so the receipt
can be matched; an article, video, reel, short or carousel logged without text needs no receipt. The gate is off
when playbook/qc/filters.json doesn't exist.
python playbook/qc.py filters lists them; --platform, --action, --recipe and --promo narrow the list
to those that apply. python playbook/qc.py explain <id> prints one filter in full.
| Id | Type | Severity | Applies to |
|---|---|---|---|
account-registry |
account | block | everything |
ignore-list |
ignore | block | everything |
already-replied |
already-replied | block | replies |
author-cap |
author-cap | warn | replies |
ai-denial |
pattern | block | everything |
never-say |
never-say | block | everything |
ad-copy |
pattern | block | everything |
brand-launch |
pattern | block | everything |
product-news |
pattern | ask | posts |
competitor-original |
pattern | block | posts |
competitor-claim |
pattern | ask | everything |
links-in-reply |
links | block, waivable | replies that aren't promo |
links-in-post |
links | warn | posts |
youtube-comment-links |
links | block, waivable | replies and comments on YouTube |
hashtags |
hashtags | warn | everything |
length |
length | block | everything |
tld-autolink |
tld | warn | Facebook, Facebook group, LinkedIn, X, Threads, Bluesky |
new-post-rule |
new-post-rule | block | action post
|
caps |
caps | block | everything |
pacing-now |
pacing | warn | everything |
near-duplicate |
duplicate | warn (block when nearly identical in the same place) | everything |
question-ratio |
question-ratio | warn | posts |
facts-read |
ask | ask | promo drafts |
source-read |
ask | ask | recipe news-share
|
news-screen |
ask | ask | recipe news-share
|
media-qc |
ask | ask | drafts with --media
|
{
"id": "links-in-reply",
"type": "links",
"severity": "block",
"waivable": true,
"applies": {"kinds": ["reply"], "promo": false},
"max": 0,
"message": "organic replies carry no links unless the thread asks; if it did, --ok links-in-reply=\"what they asked\"",
"src": "flow pacing: links, sparingly",
"examples": {
"bad": [{"text": "This explains it: https://example.com/guide", "platform": "Bluesky", "account": "acmenotes.example", "action": "reply"}],
"good": [{"text": "Clearing the cache first usually fixes that.", "platform": "Bluesky", "account": "acmenotes.example", "action": "reply"}]
}
}| Field | Required | What it is |
|---|---|---|
id |
yes | Unique. Used in --ok, in receipts and in the audit log. |
type |
yes | One of the types below |
severity |
yes |
block, warn or ask
|
waivable |
no | A block that --ok can waive |
severity_by_kind |
no | A different severity for replies or posts, e.g. {"reply": "warn"}
|
applies |
no | Where it runs (below). Missing means everywhere. |
message |
yes | What the agent reads when it fires |
src |
yes | The rule or incident it came from (a flow and node, usually) |
examples |
yes | At least one bad (must be caught) and one good (must pass) |
| type parameters | depends |
patterns, list, max... per type |
applies keys, all optional and all must match:
| Key | Matches when |
|---|---|
platforms |
The draft's platform is in the list (not case-sensitive) |
kinds |
The draft is a reply or a post as listed |
actions |
The exact action is listed (post, comment...) |
recipes |
The draft's recipe is listed |
promo |
true: only promo drafts; false: only non-promo drafts |
media |
true: only drafts with --media
|
| Type | Checks | Parameters |
|---|---|---|
pattern |
Any regular expression in patterns, or in the list named by list, found in the text |
patterns, list; and_list: fire only when that list matches too; unless_own_project: true: skip drafts about one of your apps |
never-say |
The never_say entries for _all and for every app the draft is about |
none (entries in lists.json; an entry may carry its own severity) |
links |
More http(s):// links than max
|
max (default 0) |
hashtags |
More hashtags than the platform allows |
max: a table by lower-case platform with a default (default 2) |
length |
Longer than the platform's limit. X is measured the way X counts: a link counts 23, and wide characters and emoji count 2. |
max: a table by lower-case platform; platforms not listed aren't checked |
tld |
Words that end in a real top-level domain (.md, .ai, .io, .sh, .dev, .app, .com, .net, .org) outside a link, which platforms turn into links to someone else's site |
allow: words that are fine (your own domain) |
ignore |
The person replied to (the target's author) or anyone @-mentioned is on the list |
list (default ignore). Entries are compared as whole names, not case-sensitive, @ ignored. |
already-replied |
This account already replied to the same target on this platform | none |
author-cap |
This account replied to the same author max times in the last day. Replies on your own threads don't count. |
max (default 2) |
account |
The account isn't in the registry for this platform, or the registry marks it retired or skip
|
none |
pacing |
Too soon after the last send of the same kind: replies 30 seconds apart, posts 10 minutes, Facebook group posts by state/groups.tsv
|
none |
caps |
A platform's daily cap is used up (the draft's local calendar day), or another post is closer than min_hours
|
caps: a list of {"platform", "kind", "max", "promo", "min_hours"}
|
new-post-rule |
A promo post where the app was already posted in this place (or on this platform, without --place) and at least one of the account's last last posts on the platform promoted an app. A first post of an app in a new place always passes. The demo states the rule in flow pacing ("Promo again in the same place"). |
last (default 4) |
duplicate |
Nearly the same words as something sent in the last days, links ignored. Blocks at block_ratio in the same platform and place; warns at warn_ratio anywhere. |
warn_ratio (0.8), block_ratio (0.92), days (14), min_len (40) |
question-ratio |
A post ending on a question when max of the last last posts in the same place did too |
last (4), max (3) |
ask |
Always asks; the agent answers with --ok
|
none |
Checks that read history (already-replied, author-cap, caps, new-post-rule, duplicate,
question-ratio, pacing) count audit entries with status live, pending or scheduled; a scheduled entry
counts at its scheduled time.
{
"projects": {"acme-notes": {"names": ["\\bAcme Notes\\b", "acme-notes", "\\bacmenotes\\b"]}},
"ignore": [{"pattern": "some_handle", "why": "the owner asked: never reply to this account"}],
"competitors": [{"pattern": "\\bRivalPad\\b", "rival_of": "acme-notes", "why": "a direct competitor"}],
"brands": [{"pattern": "\\bGlobex\\b", "why": "another company: no free ads"}],
"ad_copy": [{"pattern": "\\bfree (tier|plan|trial)\\b", "why": "plan or pricing copy"}],
"launch_wording": [{"pattern": "..."}],
"ai_denial": [{"pattern": "\\bnot an? (bot|AI)\\b"}],
"never_say": {
"_all": [{"pattern": "\\bguaranteed?\\b", "why": "no guarantees", "severity": "warn"}],
"acme-notes": [{"pattern": "\\bend-to-end encrypt", "why": "notes are plain files; no encryption claims"}]
}
}- Patterns are Python regular expressions, matched without regard to case. Write
(?-i:...)for a case-sensitive part. In JSON, a backslash is written twice:"\\b". - A list entry can be a string or an object with a
pattern. The other keys (why,rival_of) are for people. -
projectskeys are your apps' ids: use the same id for the project flow, the accounts'projects, the--projectflag andnever_say. - The
ignorelist holds names, compared whole: a handle as it appears in links and @-mentions, or the name you pass as--target-author.
lists.json and filters.json each start with an about line saying how to edit them.
When a mistake gets past QC, turn it into a filter so it can't happen again. Example: the agent keeps asking people to "DM me".
- Copy the closest filter in
playbook/qc/filters.json, give it a new id and itssrc. - Use the text that slipped through as the
badexample, and add agoodone that must still pass. - Run the selftest, then the full check.
{
"id": "dm-me",
"type": "pattern",
"severity": "warn",
"applies": {"kinds": ["reply"]},
"patterns": ["\\bDM me\\b"],
"message": "moves the talk to DMs; answer in the thread",
"src": "flow pacing: answers stay in public",
"examples": {
"bad": [{"text": "DM me and I'll explain.", "platform": "X", "account": "@acmenotes_demo", "action": "reply"}],
"good": [{"text": "Short version: clear the cache first.", "platform": "X", "account": "@acmenotes_demo", "action": "reply"}]
}
}python playbook/qc.py selftest
python playbook/qc.py explain dm-me
python playbook/pb.py check --strict27 filters, 71 examples: all pass
Prefer a list entry over a new filter when an existing filter already does the job: a new competitor goes in
competitors, a new false claim in never_say. Use ask when a person has to judge it, and say in the message
what evidence answers it.
qc.py selftest runs every filter against its own examples: each bad example must produce a finding and each
good one must pass. It exits 1 and prints FAIL <id> bad example 1: not caught (or good example ...: flagged: ...) for each miss. pb.py check runs it too, so a broken filter fails the playbook check and CI.
An example is a draft: text, platform, account, action, and any of place, project, promo, recipe,
target, target_author, media, ok and at. Two extra keys make history-based filters testable without
your real log:
-
history: a list of audit entries that stand in for the log (each withid,platform,account,action,status,atand whatever the check reads); -
registry:{"X": ["@acmenotes_demo"]}, standing in for the accounts registry.
Give time-based examples a fixed at so they pass on any day.
Changing lists.json can break examples. The demo's never-say, competitor-original, competitor-claim
and facts-read examples name the demo app and its competitors. Replace the demo's project and competitors in
lists.json without updating those examples and the selftest reports them as "not caught". Update the examples
to your own app's names at the same time (see Make it yours).
Agent Playbook is released under the MIT licence. Source: github.com/RandyNorthrup/agent-playbook