Document Routing Rules: First-Match-Wins and Its Limit
RedHub AI Editorialupdated November 5, 20266 min read

Jump to a section9
Document routing rules are plain if-then lines: if a file shows these signals, it is this type and it goes to that queue. Most advice stops at the order. Put them in a list, check from the top, first match wins. That holds until one document satisfies two rules that point to two different desks. At that point the order of the list is making a decision nobody chose to make.
TL;DR: First-match-wins is readable and repeatable, and it is safe only when the matching rules agree on the destination. When they disagree, hold the file for a person. Use a signal count as the confidence floor, and watch short keywords. The Document Classify & Route Kit ($69) evaluates rules in priority order and quarantines a destination conflict regardless of priority. Background: Document Classification & Routing.
What a rule is made of
In the Document Classify & Route Kit, a rule has four parts: a priority, a condition block, a document type and a destination. The condition block is either "all of," where every listed signal must match, or "any of," where one is enough. Two rules from the kit's sample pack:
| Priority | Condition | Type | Destination |
|---|---|---|---|
| 2 | All of: text contains "invoice"; amount under 5,000 | Invoice | AP - standard queue |
| 4 | All of: text contains "agreement"; text contains "signature" | Signed contract | Legal - executed |
Anyone on the team can read those two lines and say what they do. That readability is the whole case for rules.
What first-match-wins gets right
The alternative is to score every rule against a document and route to the highest score. It sounds smarter. But two rules can score close together, and the winner can flip on a reworded subject line. First-match-wins has no score to explain. The outcome traces to one rule at one position. It also puts the ordering on you. Nothing works out which rule matters more, so you decide it up front and write it down.
Where it breaks
Take a signed master services agreement that mentions an invoice for a $1,500 setup fee. Against the two rules above, it matches both. The invoice rule is priority 2 and the contract rule is priority 4, so first-match-wins sends the contract to accounts payable. Every step worked as written. A lawyer never sees the document.
The trouble is not the order. Swap the two rules and a real invoice that happens to quote "the agreement" and "signature required" goes to Legal instead. No ordering fixes it, because the two rules belong to two departments and the document plausibly belongs to either.
The kit's answer is an ambiguity gate. When a document matches two or more rules that resolve to different destinations, the verdict is QUARANTINE, and priority is not consulted. That exact file ships in the kit's sample batch as vendor-msa-signed.pdf, and the engine prints it as a conflict between "AP - standard queue" and "Legal - executed."
So what is priority for?
Less than the name suggests. If two matching rules name the same destination, there is no conflict. The file routes, and the higher-priority rule supplies the document type on the label. Priority picks between rules that already agree on where the file goes.
That changes how you write tiers. If large invoices go to a manager and small ones to the standard queue, those are two destinations, so the two rules must never match the same invoice. One says "amount at least 5,000" and the other says "amount under 5,000." Leave the second limit off and every large invoice quarantines as a false conflict.
The confidence floor counts signals
The kit has no percentage score. Its confidence floor is a whole number: the fewest independent signals the winning rule must have matched. The default is 1. Raise it to 2 and a match resting on one signal is quarantined as low-confidence.
The count works differently for the two block types. An "all of" rule with two conditions always matches on two signals. An "any of" rule with three alternatives may have matched on one. So at a floor of 2, a rule with a single condition can never route. If you raise the floor, give every rule a second signal first. On the kit's six-document sample, raising the floor to 2 changed nothing when we ran it, because each routed document's rule already rested on two signals.
Short keywords are traps
The kit's filename_contains and text_contains signals match fragments, ignoring case. That is forgiving, and it bites. A contains rule looking for "cv" in a filename also matches recvd. A contains rule looking for "invoice" in the text also matches "uninvoiced." The kit also has whole-word signals, filename_word and text_word, which match neither.
The gate catches the first kind only when it collides with another rule. With a contains rule for "cv," a received invoice named acme-recvd-0420.pdf matches a resume rule and an invoice rule, two destinations, and it is held. The kit's sample pack matches "cv" as a whole word for that reason, so the same file routes to payables. The gate cannot catch the second. A memo that says "these hours are uninvoiced," with a small amount attached, matches the sample pack's standard invoice rule, which is a contains rule, and nothing else. One rule and one destination means it routes to payables with a clean verdict. The gate does not detect that. The checks are to match short keywords as whole words, to prefer longer phrases over short fragments, and to read a sample of what routed, not just what was held.
Ordering, briefly
- Rank by how specific a rule is, not by how often it fires.
- Keep rules for different destinations from overlapping where you can, and accept a quarantine where you cannot.
- Re-run your test batch after every change. Adding a rule can turn a file that used to route into a conflict.
A rule engine that will not break a tie for you
The Document Classify & Route Kit evaluates your rule pack in priority order and returns ROUTE, QUARANTINE or UNMATCHED for each document. Two rules with two destinations is always a quarantine. The confidence floor is yours to set. It ships as a Python engine with no dependencies, a workbook and two guides.
Get the Document Classify & Route Kit — $69Pairs well with
Routing rules decide the queue. The Document Field Validator ($79) applies the same rule-pack idea to the fields inside a record and returns PASS, REVIEW or REJECT. The Document Intake Completeness Checker ($69) checks a packet against a requirements list and returns COMPLETE, CHASE or HOLD INTAKE. For exported data, the CSV / Data-Export Schema & Quality Gate ($69) grades whether a file is structurally fit to process and returns READY, FIX or BLOCK.
More in this guide
What does first-match-wins mean in document routing?
Rules are checked in a fixed priority order, and the first rule a document satisfies decides its type and destination. No scores are compared. It is safe when every rule the document matches points to the same destination.
What happens when two rules match the same document?
If both name the same destination, the document routes and the higher-priority rule supplies the type. If they name different destinations, the Document Classify & Route Kit quarantines the document regardless of priority, so a person decides.
Why not score every rule and pick the highest?
Close scores can flip on a small change in the document, and the reason behind a winning score is harder to explain. An ordered list traces every outcome to one rule you can read.
What is a confidence floor in a routing rule?
In the kit it is the minimum number of independent signals a match must rest on before the document routes without review. The default is 1. At 2, a match resting on a single signal is quarantined as low-confidence.
How do I stop tiered rules from conflicting?
Make them mutually exclusive. If invoices of 5,000 or more go to a manager, the standard rule needs its own condition of under 5,000. Otherwise a large invoice matches both rules and is held as a conflict.
Can a rule route a document to the wrong queue without any warning?
Yes. If a loose keyword matches an unrelated document and no other rule matches it, the document routes with a clean verdict. Use longer phrases, combine two signals and read a sample of routed files.


The gate this post refers to, drawn from the tool’s own logic. See the tool.