general code and the edge-case tail · lesson 8 of 9 · sources checked 2026-11-30
corrections that reach the past
This lesson runs a corrected rule again over stored evidence and changes only the old results that the evidence proves wrong.
status of this lesson: documented in my test systempurpose
A fix of a rule also changes the meaning of each result that the old rule made. When the fix reaches only new results, each chart mixes two meanings. You must find the old results that are wrong, change only those, and show where the meaning changed.
objectives
- Write a corrected rule as a pure predicate over stored evidence.
- Run a correction replay as a dry run, and put each row in a correction class.
- Quarantine only the rows that the evidence proves wrong, and mark the rows with no stored evidence.
- Explain why each verdict carries its rule version.
new terms
- correction replay
- A run of a corrected rule over stored evidence to find the old results that it proves wrong.
how it works
Each attempt leaves evidence: what the collector stored. For example, the evidence is the status, the response body, and the markers that it found.
A verdict rule reads that evidence and gives a verdict. When you correct the rule, the old verdicts keep the old meaning. Some of them are now wrong.
the rule of the benchmark platform
The benchmark platform, my test system, keeps a quarantine mark with a reason on a past row. For one correction, a dry run read the stored evidence. Only the rows that the evidence proves wrong change state. A correction cannot reach a row that has no stored observation.
The platform has no rule version on a verdict yet.
For example, a row has a verdict and a stored response body. A corrected rule can test that row again. A row with no stored body stays as it is.
the corrected rule as a pure predicate
A pure predicate reads only the stored evidence of one row and gives yes or no. It reads no clock, no network, and no live page. Thus the same evidence gives the same answer each time.
For example, the old rule read each page with a vendor script as a block. The corrected rule gives a block only when the page has no real content. The predicate asks one question of each row: "Does the stored body hold real content?"
the dry run and the correction classes
A correction replay runs the predicate over each stored row. The first run is a dry run: it writes a report and changes no row. The report puts each row in one of four correction classes:
| correction class | condition |
|---|---|
| Proven wrong | The evidence shows that the old verdict is wrong. |
| Confirmed | The evidence agrees with the old verdict. |
| Undecided | Evidence is stored, but the predicate cannot decide. For example, the old capture has no body field. |
| No stored evidence | The row has a verdict, but its evidence is gone. |
Read the report before you change a row. A predicate that matches zero rows can be a broken predicate, not a good result. A predicate that matches each row can also be broken.
quarantine and the mark
After the review of the dry run, you quarantine only the proven wrong rows. Each row gets a quarantine stamp: a time and a reason. The reason names the rule version and the evidence. The stamp removes the row from each published rate, and you can remove the stamp again. Nothing is deleted.
A row with no stored evidence does not get the stamp, because no evidence proves it wrong. It gets a mark that says so. A report then gives these rows as a separate part, not as correct rows.
For example, a chart shows a pass rate. It gives the confirmed rows, the quarantined rows, and the rows that nobody can check. The reader sees how much of the old number is unknown.
the break at the rule period
The corrected rule writes each new verdict with the new rule version. Thus each chart can show a break where the version changes. Each side of the break is one rule period. Do not pool rates across two periods.
For example, a pass rate is 40% under rule version 3 and 55% under version 4. The chart shows two lines with a gap, not one line that rises. More detail on rule periods is in Rule periods, chart breaks, and the statistics library (not yet published).
the two sides
| automation side | detection side |
|---|---|
| A correction that cannot reach old rows leaves wrong numbers in each chart. A rule version on each verdict lets the chart show the rule period. | A detection team runs a corrected rule again over stored web sessions and withdraws the verdicts that the evidence proves wrong. |
design decisions
| option | gain | cost | when it is correct |
|---|---|---|---|
| Correct the rule for new rows only | No work on old rows | Each chart mixes two meanings with no mark. | Never for a published number |
| Run the old attempts again on the live targets | New evidence for each row | The targets changed, and the new runs add load on them. | Never as a correction of an old verdict |
| A correction replay over stored evidence | Old rows change only on proof. | It cannot reach rows with no stored evidence. | For each corrected rule |
| A dry run before the change | You see the classes before a row changes. | One more step | Always |
| Quarantine with a stamp, not a delete | You can reverse each change. | Readers of the store must respect the stamp. | Always |
| A mark on rows with no evidence | The unknown part of a number is visible. | The report has one more part. | Always |
diagram
the correction replay over stored evidence
code example
The example runs a correction replay over synthetic stored rows. It writes a dry-run report first. It then stamps only the proven wrong rows, with a reason and the rule version. The rows and the rule are synthetic.
Correction replay: a pure predicate over stored evidence in a dry run, a quarantine stamp with a reason, and a rule version stamp.
// Correction replay over synthetic stored rows: a dry run first, then the stamps.
type Evidence = { status?: number; body?: { realContent: boolean } };
type Row = {
id: string;
verdict: "block" | "pass";
ruleVersion: number;
evidence: Evidence | null;
quarantine?: { time: string; reason: string };
mark?: string;
};
type CorrectionClass = "no stored evidence" | "undecided" | "confirmed" | "proven wrong";
const NEW_VERSION = 4;
// Pure predicate: true is a block, false is not a block, null is no decision.
// It reads only the stored evidence: no clock, no network, no live page.
function correctedRule(e: Evidence): boolean | null {
if (e.body === undefined) return null;
return !e.body.realContent;
}
function correctionClass(row: Row): CorrectionClass {
if (row.evidence === null) return "no stored evidence";
const blockNow = correctedRule(row.evidence);
if (blockNow === null) return "undecided";
return blockNow === (row.verdict === "block") ? "confirmed" : "proven wrong";
}
// The dry run writes a report and changes no row.
const dryRun = (rows: Row[]) => new Map(rows.map((r) => [r.id, correctionClass(r)]));
function apply(rows: Row[], report: Map<string, CorrectionClass>, now: string): void {
for (const row of rows) {
const cls = report.get(row.id);
if (cls === "proven wrong") {
row.quarantine = { time: now, reason: `rule version ${NEW_VERSION}: stored body holds real content` };
} else if (cls === "no stored evidence") {
row.mark = "cannot check: no stored evidence";
}
}
}
const rows: Row[] = [
// synthetic rows of rule version 3
{ id: "r1", verdict: "block", ruleVersion: 3, evidence: { body: { realContent: true } } },
{ id: "r2", verdict: "block", ruleVersion: 3, evidence: { body: { realContent: false } } },
{ id: "r3", verdict: "block", ruleVersion: 3, evidence: { status: 200 } },
{ id: "r4", verdict: "block", ruleVersion: 3, evidence: null },
];
const report = dryRun(rows);
const counts: Record<string, number> = {};
for (const cls of report.values()) counts[cls] = (counts[cls] ?? 0) + 1;
console.log(JSON.stringify(counts));
apply(rows, report, "lab day 40");
console.log(JSON.stringify(rows[0].quarantine));
const newRow: Row = { id: "r5", verdict: "pass", ruleVersion: NEW_VERSION, evidence: { body: { realContent: true } } };
console.log(JSON.stringify({ id: newRow.id, verdict: newRow.verdict, ruleVersion: newRow.ruleVersion }));output
The count of rows in each correction class, the stamp of the proven wrong row, and a new row with the new rule version.
{"proven wrong":1,"confirmed":1,"undecided":1,"no stored evidence":1}
{"time":"lab day 40","reason":"rule version 4: stored body holds real content"}
{"id":"r5","verdict":"pass","ruleVersion":4}The output shows one row in each correction class. Only the proven wrong row gets a stamp, and the new row carries rule version 4.
data
verdict rows of one correction replay, by correction class
status of this figure: measured by me
- proven wrong and quarantined: rows of the old rule 1491
- confirmed: rows of the old rule 1933
- undecided (evidence present): rows of the old rule 159
- no stored evidence: rows of the old rule 7898
source: Lab result of this course: correction replay of a corrected rule on a lab store; date 2026-11-13; sample of 11,481; condition: Synthetic pages. The store keeps evidence for 30 lab days and loses 5% at random. Teaching values for one host, not values for a real service.
data table
| series | rows | rows |
|---|---|---|
| proven wrong and quarantined | rows of the old rule | 1491 |
| confirmed | rows of the old rule | 1933 |
| undecided (evidence present) | rows of the old rule | 159 |
| no stored evidence | rows of the old rule | 7898 |
The chart is a lab result of this course on a lab store with synthetic pages. Most rows of the old rule had no stored evidence, because the lab store kept evidence for a short time only. Thus the time for which you keep evidence sets how far a correction can reach.
failure modes
| problem | cause | correction |
|---|---|---|
| A chart mixes old and new verdicts with no mark. | The fix reached only new rows, and the verdicts carry no rule version. | Write the rule version on each verdict, and show a break at each change. |
| The correction replay gives a different result each time. | The predicate reads the clock, the network, or a live page. | Make the predicate read only the stored evidence of the row. |
| The quarantine holds correct rows. | The change ran with no dry run and no review of the classes. | Run the dry run first, and read the report before the change. |
| The predicate matches zero rows. | The predicate reads a field that the old captures do not have. | Treat zero matches as a fault of the predicate, and test it on known rows. |
| Rows with no evidence count as correct. | The report shows only confirmed and quarantined rows. | Give the rows with no stored evidence as a separate part. |
| Old rows are lost after a correction. | The change deleted rows in place of a stamp. | Use a quarantine stamp with a reason, and never delete. |
check questions
Which predicate is pure and safe for a correction replay?
- A predicate that fetches the live page again
- A predicate that reads only the stored body of the row
- A predicate that reads the time of the correction replay
answer
b. A predicate that reads only the stored body of the row
A pure predicate reads only the stored evidence of the row. Thus the same evidence gives the same answer each time, and the correction replay adds no load on a target.
A row has an old verdict and a stored status, but the old capture has no body field. The corrected rule reads the body. What is the correction class of the row?
- Undecided
- Proven wrong
- Confirmed
- No stored evidence
answer
a. Undecided
Evidence is stored, but the predicate cannot decide without the body. Thus the row is undecided. It does not get a quarantine stamp.
Explain why a row with no stored evidence gets a mark and not a quarantine stamp.
sample answer
A quarantine stamp is only for a row that the evidence proves wrong. A row with no stored evidence has no proof. Thus it gets a mark, and the report gives these rows as a separate part, not as correct rows.
Explain why each verdict carries its rule version.
sample answer
The rule version shows which rule made the verdict. A chart can then show a break where the version changes. Each side of the break is one rule period, and you do not pool rates across two periods.
exercise
exercise Do this task on paper with the synthetic rows below. The old rule read each page with a vendor script as a block. The corrected rule gives a block only when the stored body has no real content.
| row | old verdict | stored evidence | real content in the stored body |
|---|---|---|---|
| 1 | block | body stored | yes |
| 2 | block | body stored | no |
| 3 | block | none | not known |
| 4 | pass | body stored | yes |
| 5 | block | status only, no body field | not known |
| 6 | block | body stored | yes |
- Put each row in its correction class.
- Write the rows that get a quarantine stamp.
- Write the rows that get the mark for no stored evidence.
- Write the report of the correction replay: the count of rows in each class.
sample answer
The answer uses the six synthetic rows of the task.
Rows 1 and 6 are proven wrong: the body holds real content, so they are not a block. Row 2 is confirmed. Row 4 is confirmed, because the corrected rule also gives a pass for it. Row 5 is undecided, because no body field is stored. Row 3 has no stored evidence.
Rows 1 and 6 get a quarantine stamp with the new rule version in the reason. Row 3 gets the mark. The report gives 2 proven wrong, 2 confirmed, 1 undecided, and 1 with no stored evidence.
sources
- Benchmark platform, code (my test system): the quarantine of past rows, and the limit of a correction to rows with stored evidence, 2026-11 (not public).
- My model of the dry run, the correction classes, and the mark on rows with no stored evidence, 2026-11 (not public).