skip to content

general code and the edge-case tail · lesson 4 of 9 · sources checked 2026-11-30

the unknown class and the review loop

This lesson gives each classifier a closed list with an unknown member, and a queue that an owner works at a fixed interval.

status of this lesson: documented in my test system

purpose

A classifier that guesses on an input that it does not know gives a wrong result with no warning. The wrong result looks like a correct one, and nobody finds it. An explicit unknown class makes each such input visible, and a queue with an owner turns it into a rule.

objectives

  1. Build a closed output list with an unknown member, and name the part that emits each pattern.
  2. Explain the difference between the unknown policy of verdict code and of dispatch code.
  3. Write the cost of a wrong guess and of an unknown result for one classifier.
  4. Set an alarm on the unknown rate with a sample floor.
  5. Describe the four parts of a queue rule for the unknown queue.

new terms

how it works

A classifier reads one input and gives one class from a closed list. A closed list holds each class that the classifier can give, and no other. The last member of the list is "unknown". The classifier gives it when no rule matches.

two policies for an unknown input

I use two policies, one for each kind of code:

  • Verdict code gives a verdict or a class that other parts trust. Examples are an error classifier and the reader of a page form. When no rule matches, it refuses to guess. It returns the unknown member, and it stores the input.
  • Dispatch code chooses one path, for example a parser for each format. The work must continue. Thus the switch has a default arm that records "not covered". A silent default arm is the fault: it takes the absent case and records nothing.

For example, a lab error "request timed out after 3000 ms (stream closed)" is near the class "timeout". It does not match the timeout rule. Verdict code returns unknown, because the stream close can have a different cause.

the closed list on the benchmark platform

The error classifier of the benchmark platform, my test system, gives one reason from a closed list, or no class. For an error that no rule matches, it returns no class. The closed list starts in Reconstruct why an attempt failed: the class and the evidence chain (not yet published).

The platform records show faults of this kind. A tool can give no rows and no error class. The correction is a function that fills the default from catalog data, and a classifier that knows the old error shape.

what to store with an unknown input

A stored unknown input is evidence for the next rule. Store the input, each facet of the response, and the version of the configuration. For example, the record "empty body with status 200" keeps the status, the body size, and the configuration name. A record with no facets cannot go into a cluster later.

A tolerant extractor can give a partial record on an unknown page. Thus make the extractor tolerant only when it can parse the page, and give the output step a fail closed design.

The output step can quarantine the record for a later review.

the cost of each wrong answer

Write two costs for each classifier before you set its policy:

  • the cost of a wrong guess: for example, a false record reaches a customer, or a false verdict reaches a rate;
  • the cost of an unknown result: one item in the queue, and one review.

When the first cost is higher, the classifier refuses. A detection classifier has the same choice. A guess on an unknown client can give a false positive on a real user.

the alarm on the unknown rate

The unknown rate is the count of unknown results divided by the count of attempts in one day. An alarm fires when the rate is over a limit. It must have a sample floor: with few attempts, one unknown result gives a high rate. For example, with a floor of 40 attempts, a day with 30 attempts gives no decision.

the queue rule

An unknown result goes to a review queue. A queue with no owner grows until nobody reads it. The platform records show such a queue for unknown detectors. That queue has no owner, no fixed interval, and no path to a rule. The queue rule below closes these gaps.

The queue rule has four parts:

  1. An owner: one person or team.
  2. A fixed interval for the review, for example each seventh day.
  3. Clusters: the owner reviews groups of similar inputs, not single items.
  4. A path for each cluster. The path is a new rule with a test, an entry on the exclusion list, or a wait.

The full design of the queue is in Operate a review queue (not yet published).

the two sides

automation sidedetection side
An unknown page form must not give a partial record to the customer. The record goes to quarantine, and the input goes to the review queue.A detection classifier that guesses on an unknown client gives false positives on real users. An explicit unknown class with a review queue keeps that cost visible.

design decisions

optiongaincostwhen it is correct
Guess the nearest classNo queue to workA wrong result looks correct.Never in verdict code
Return unknown and store the inputEach new form becomes visible.The queue must have an owner.For verdict code
Default arm that records "not covered"The work continues, and the gap has a count.The record of each case is short.For dispatch code
Silent default armNo code for an absent caseThe gap has no record.Never
Review clusters at a fixed intervalOne review closes many items.Rare items wait.When the queue has an owner

diagram

The first diagram compares the two policies.

A matrix of two columns, verdict code and dispatch code, against five rows. The rows are an example, the action when no rule matches, the record, the effect, and the next step. Verdict code returns the unknown member and sends the item to the queue. Dispatch code takes the default arm and sends a count to the alarm.

two policies for an input that no rule matches
questionverdict codedispatch code
Exampleerror classifier, page form readerswitch over formats or methods
When no rule matchesrefuse: return the unknown membertake the default arm
What it recordsthe input, its facets, its configone not covered record
Effect on the workno record goes outthe work continues
Next stepthe item goes to the unknown queuethe count goes to the alarm
Verdict code refuses and stores the input. Dispatch code continues and records the gap.source: My model of the two unknown policies

The second diagram shows the path of an item through the queue.

the unknown queue from capture to a decision

A reviewed cluster ends as a rule with a test or as an entry on the exclusion list, or it waits.source: My model of the unknown queue

code example

The first example is a classifier with a closed list. Each pattern names the part that emits the error. The errors are synthetic lab lines.

m53-x05-classify.tstypescript

Classify synthetic lab errors with a closed list, return null for an unknown error, and send it to the queue with its facets.

// A closed list of error classes. Each pattern names the part that emits the error.
type ErrorClass = "timeout" | "tool-did-not-start" | "field-missing" | "status-5xx";
type Pattern = { cls: ErrorClass; emitter: string; test: RegExp };

const PATTERNS: Pattern[] = [
  { cls: "timeout", emitter: "http client", test: /^request timed out after \d+ ms$/ },
  { cls: "tool-did-not-start", emitter: "tool launcher", test: /^launch failed: exit code \d+$/ },
  { cls: "field-missing", emitter: "extractor", test: /^no record: field "[a-z]+" missing$/ },
  { cls: "status-5xx", emitter: "http client", test: /^status 5\d\d$/ },
];

type Known = { cls: ErrorClass; emitter: string };

// The classifier returns null when no pattern matches. It never guesses.
function classify(message: string): Known | null {
  for (const p of PATTERNS) {
    if (p.test.test(message)) return { cls: p.cls, emitter: p.emitter };
  }
  return null;
}

// An unknown input goes to the queue with its facets and its configuration version.
type QueueItem = { message: string; facets: Record<string, string>; config: string };
const queue: QueueItem[] = [];

// Synthetic errors of a lab collector. No line comes from a real system.
const errors = [
  { message: "request timed out after 3000 ms", facets: { status: "none" } },
  { message: "status 503", facets: { status: "503" } },
  { message: 'no record: field "price" missing', facets: { status: "200" } },
  { message: "request timed out after 3000 ms (stream closed)", facets: { status: "none" } },
  { message: "launch failed: exit code 1", facets: { status: "none" } },
  { message: "empty body with status 200", facets: { status: "200", bytes: "0" } },
];

for (const e of errors) {
  const r = classify(e.message);
  if (r) {
    console.log(`${r.cls.padEnd(18)} ${("from " + r.emitter).padEnd(18)} <- ${e.message}`);
  } else {
    queue.push({ message: e.message, facets: e.facets, config: "lab-config-7" });
    console.log(`${"unknown".padEnd(18)} ${"to the queue".padEnd(18)} <- ${e.message}`);
  }
}

const rate = (100 * queue.length) / errors.length;
console.log(`unknown: ${queue.length} of ${errors.length} (${rate.toFixed(1)}%)`);
console.log(`first queue item: ${JSON.stringify(queue[0])}`);

output

One line for each error, the unknown count, and the first queue item.

timeout            from http client   <- request timed out after 3000 ms
status-5xx         from http client   <- status 503
field-missing      from extractor     <- no record: field "price" missing
unknown            to the queue       <- request timed out after 3000 ms (stream closed)
tool-did-not-start from tool launcher <- launch failed: exit code 1
unknown            to the queue       <- empty body with status 200
unknown: 2 of 6 (33.3%)
first queue item: {"message":"request timed out after 3000 ms (stream closed)","facets":{"status":"none"},"config":"lab-config-7"}

The output shows that the line with "stream closed" goes to the queue, and not to the class "timeout".

The second example is the alarm on the unknown rate, with a sample floor. It reads a synthetic lab table.

m53-x06-unknown-alarm.tstypescript

Compute the daily unknown rate of a synthetic lab table, and give an alarm only on a day at or over the sample floor.

// Unknown-rate alarm with a sample floor, on a synthetic lab table.
// Each row is one attempt. errorClass is null for a success, a class of the
// closed list for a known error, and "unknown" when no rule matches.
type Attempt = { day: number; errorClass: string | null };

const SAMPLE_FLOOR = 40; // example value: attempts in one day
const LIMIT_PCT = 10; // example value: alarm limit in percent

// Make the synthetic table: [day, attempts, unknown results, known errors].
const plan: [number, number, number, number][] = [
  [3, 60, 9, 4],
  [1, 25, 5, 1],
  [2, 90, 6, 3],
  [4, 44, 4, 2],
];
const table: Attempt[] = [];
for (const [day, attempts, unknowns, known] of plan) {
  for (let i = 0; i < attempts; i++) {
    const errorClass = i < unknowns ? "unknown" : i < unknowns + known ? "timeout" : null;
    table.push({ day, errorClass });
  }
}

const daily = new Map<number, { attempts: number; unknowns: number }>();
for (const a of table) {
  const d = daily.get(a.day) ?? { attempts: 0, unknowns: 0 };
  d.attempts += 1;
  if (a.errorClass === "unknown") d.unknowns += 1;
  daily.set(a.day, d);
}

console.log("day,attempts,unknowns,unknown_pct,state");
for (const day of [...daily.keys()].sort((x, y) => x - y)) {
  const { attempts, unknowns } = daily.get(day)!;
  const pct = (100 * unknowns) / attempts;
  const state =
    attempts < SAMPLE_FLOOR ? "no decision: below the sample floor" : pct > LIMIT_PCT ? "alarm" : "ok";
  console.log(`${day},${attempts},${unknowns},${pct.toFixed(1)},${state}`);
}

output

One row for each day in day order: the attempts, the unknown results, the unknown rate, and the state.

day,attempts,unknowns,unknown_pct,state
1,25,5,20.0,no decision: below the sample floor
2,90,6,6.7,ok
3,60,9,15.0,alarm
4,44,4,9.1,ok

The output shows that day 1 has the highest rate, but it gives no decision, because its attempts are below the floor.

data

unknown rate of page runs on each seventh lab day, with the alarm line

status of this figure: measured by me

unknown rate of page runs on each seventh lab day, with the alarm line0%3%alarm line 10%day 0day 7day 14day 21day 28day 35day 42day 49day 56day 63day 70day 77day 84day 91day 98day 105day 112day 119%

band: interval, level 0.95

source: Lab result of this course: own lab collector, one run of 120 lab days; date 2026-11-13; sample of 1,332; condition: Seed 1 of 5. The review labels come from the true page form, not from a person. The n is the sum of the runs of the 18 points. Teaching values for one host.

data table
unknown rate of page runs on each seventh lab day, with the alarm line
lab day%interval
day 000 to 79.35 (level 0.95)
day 717.656.19 to 41.03 (level 0.95)
day 1413.795.5 to 30.56 (level 0.95)
day 218.823.05 to 22.96 (level 0.95)
day 284.651.28 to 15.46 (level 0.95)
day 356.452.54 to 15.45 (level 0.95)
day 426.943 to 15.25 (level 0.95)
day 492.440.67 to 8.46 (level 0.95)
day 563.261.12 to 9.15 (level 0.95)
day 6320.55 to 7 (level 0.95)
day 7010.18 to 5.45 (level 0.95)
day 7710.18 to 5.45 (level 0.95)
day 8420.55 to 7 (level 0.95)
day 9141.57 to 9.84 (level 0.95)
day 9800 to 3.7 (level 0.95)
day 10520.55 to 7 (level 0.95)
day 11220.55 to 7 (level 0.95)
day 11931.03 to 8.45 (level 0.95)
One lab run of 120 lab days. Intervals are Wilson 95%. The sample floor is 40 runs a day, and the first four points are below it. Review occurs each seventh day.

The chart is a lab result of this course, not a value of a real service. It shows the unknown rate fall under the alarm line after the first reviews. The review labels in the lab come from the true page form, with no person and no delay. Thus the fall is a best case.

failure modes

problemcausecorrection
A new page form gives a partial record to a customer.The extractor is tolerant also at the output step.Fail closed at the output step, and quarantine the record.
A new error goes into the nearest class.The classifier guesses when no rule matches.Return the unknown member, and store the input.
An absent format gives no record.The switch has a silent default arm.Record "not covered" in the default arm, and count it.
The unknown queue grows, and nobody reads it.The queue has no owner and no fixed interval.Give it an owner, a fixed interval, and clusters.
The alarm fires on a quiet day.The alarm has no sample floor.Give no decision below the floor.
A reviewed cluster cannot become a rule.The stored items have no facets or configuration.Store the facets and the configuration version with each item.

check questions

  1. An error classifier with a closed list gets the line "request timed out after 3000 ms (stream closed)". No pattern matches it exactly. What does verdict code return?

    1. The class timeout, because it is the nearest class.
    2. The unknown member, and it stores the input with its facets.
    3. No result, and it deletes the input.
    answer

    b. The unknown member, and it stores the input with its facets.

    Verdict code refuses to guess. It returns the unknown member and stores the input, so that the owner of the queue can review it.

  2. Explain the difference between the unknown policy of verdict code and the unknown policy of dispatch code.

    sample answer

    Verdict code gives a result that other parts trust. When no rule matches, it returns the unknown member and stores the input, and no record goes out. Dispatch code must let the work continue. It takes a default arm that records "not covered", and the count goes to the alarm. A silent default arm records nothing, and that is the fault.

  3. For one classifier, a wrong guess sends a false record to a customer. An unknown result adds one item to the queue. Which policy is correct?

    1. Guess, because the queue costs time.
    2. Use a silent default arm.
    3. Refuse and return unknown, because the cost of a wrong guess is higher.
    answer

    c. Refuse and return unknown, because the cost of a wrong guess is higher.

    When the cost of a wrong guess is higher than the cost of one review, the classifier refuses and returns the unknown member.

  4. The sample floor is 40 attempts and the limit is 10%. A day has 25 attempts and 5 unknown results. What does the alarm give?

    1. No decision, because the day is below the sample floor.
    2. An alarm, because the rate is 20%.
    3. Ok, because 5 results are few.
    answer

    a. No decision, because the day is below the sample floor.

    Below the sample floor, one unknown result gives a high rate. Thus the alarm gives no decision for that day.

  5. Describe the four parts of a queue rule for the unknown queue.

    sample answer

    An owner, which is one person or team. A fixed interval for the review, for example each seventh day. Clusters, so that the owner reviews groups of similar inputs. A path for each cluster: a new rule with a test, an entry on the exclusion list, or a wait.

exercise

exercise Do this task on paper. Use the synthetic daily counts of a lab collector. The sample floor is 40 attempts, and the alarm limit is 10%.

dayattemptsunknown results
1306
21209
38012
4504
5456
  1. Compute the unknown rate of each day.
  2. Mark each day below the sample floor as "no decision".
  3. Mark each other day as "alarm" or "ok".
  4. Write the four parts of the queue rule for the owner of this queue.
sample answer

The answer uses the five synthetic days of the task.

Day 1 has 20.0%, but 30 attempts are below the floor, thus it gives no decision. Day 2 has 7.5% and is ok. Day 3 has 15.0% and gives an alarm. Day 4 has 8.0% and is ok. Day 5 has 13.3% and gives an alarm.

The queue rule has one owner, a review each seventh day, and clusters of similar inputs. Each cluster gets a new rule with a test, an entry on the exclusion list, or a wait.

sources

  1. Benchmark platform, code (my test system): the closed list of error reasons, and no class for an unknown error, 2026-11 (not public).
  2. Benchmark platform, code (my test system): the fault of an empty field, and a queue with no owner, 2026-11 (not public).
  3. My model of the two unknown policies and of the cost of each wrong answer, 2026-11 (not public).
  4. My model of the queue rule, 2026-11 (not public).