general code and the edge-case tail · lesson 9 of 9 · sources checked 2026-11-30
retire special cases and hold the scope
This lesson gives each override an owner, an expiry, and a hit counter, and holds the scope with a budget and a published statement.
status of this lesson: from a public sourcethis page is not legal advice.
purpose
Each special case stays a cost after the day that somebody adds it. Nobody removes a case that has no record of its use. The edge-case tail then grows with no limit, and the team stops knowing the scope of the product.
objectives
- Give each override an owner, a reason with evidence, an expiry, and a hit counter.
- Run the two release tests of an override: it is still necessary, and it still works.
- Decide each override at zero hits or after the expiry: remove, renew, or move into the general rule.
- Hold the scope with a cap, a budget of new cases, and a not-supported list.
- Describe what a scope statement holds, and why an attorney examines it.
new terms
- override expiry
- The time at which an operator grant or override stops without a further action.
- special-case budget
- A cap on active overrides and on new special cases for each period.
- not-supported list
- A published list of the targets, flows, and data types that are outside the scope of the product.
- scope statement
- A published statement of what is inside the scope of the product, what is outside the scope, and how it announces a change.
how it works
An override adds code to read, a test to run, and a rule that can go wrong. Each one costs a little. Together they can cost more than the general rule. The count of special cases of each component is in Count the special cases and measure the tail.
the record of each override
Each override gets a record with four fields:
- An owner: one person or one team that decides on the override.
- A reason, with a link to the stored evidence of the case.
- An override expiry: the day on which the override stops, unless the owner renews it.
- A hit counter: the count of the times that the override changed a result in the last period.
The same record is for each behavior flag, and for each target outside the scope of the product.
For example, an override sets the price selector of lab target a. Its owner is team a, its evidence is a stored capture, and it expires on lab day 90.
two tests at each release
Each release runs two tests on each override:
- Still necessary: run the general rule on the stored capture with no override. If the general rule fails, the override is still necessary.
- Still works: run the stored capture with the override. It must give the expected record.
For example, the target changed its layout, and the general rule now reads the price. The first test then shows that the override is not necessary.
at zero hits or after the expiry
An override with zero hits in the period, or an override after its expiry, gets one of three decisions:
| decision | when |
|---|---|
| Remove | It has zero hits, or the test "still necessary" fails. |
| Renew | It is still necessary and it still works. The owner gives a new expiry and new evidence. |
| Move into the general rule | Many targets have the same override. The general rule then covers them, and the overrides go. |
An override that is still necessary but does not work gets a correction first. Then the owner renews it.
A move changes the general code. Thus it goes through the regression corpus first.
the cap and the budget
A special-case budget holds the count of overrides. It has two parts:
- A cap on the active overrides of each target class.
- A count of new special cases for each period.
A new case over the budget waits until an old case is retired. This course gives no value for the cap or the count. For example, a team can set a cap of 20 active overrides for one target class, but this value is an estimate.
the not-supported list and the scope statement
A not-supported list names the targets, the flows, and the data types that are outside the scope of the product.
For example, a list names pages behind a login and each flow that asks for a payment. A customer then knows the limit before a silent failure.
A scope statement says what is inside the scope of the product, what is outside it, and how the product announces a change. It can have an effect on a contract. Thus an attorney of the operator examines it before publication.
the two sides
| automation side | detection side |
|---|---|
| Overrides with no hit counter and no expiry grow without a limit, and they can become dead weight. A not-supported list states the limit to the customer. | A detection exception with no expiry stays after the cause goes away. It then becomes a permanent gap that an operator can find. |
design decisions
| option | gain | cost | when it is correct |
|---|---|---|---|
| Overrides with no expiry | No work at each release | Dead overrides stay, and nobody knows which. | Never |
| An expiry and a hit counter on each override | Each dead override shows. | Each owner must decide at each expiry. | For each override |
| Remove at zero hits | The set stays small. | A rare case can come back. | When the stored capture shows that the case is gone |
| Move many overrides into the general rule | One rule in place of many | The change goes through the regression corpus. | When many targets have the same override |
| A cap and a budget of new cases | The tail has a limit. | A new case can wait. | For each target class |
| A published not-supported list | The customer sees the limit. | The list must stay current. | For each product with customers |
diagram
the override life cycle
code example
The example gives a record to each override and resolves the effective value. The narrower scope wins, as in the override precedence of The override layer. A release check then fails for an override after its expiry or at zero hits. All names are lab names.
An override record with its owner, reason, evidence, expiry, and hit counter. A resolver gives the effective value by precedence, and a release check fails after the expiry.
type Scope = "target" | "target class";
type Override = {
behavior: string; // behavior ID
scope: Scope;
key: string; // lab target name or target class name
value: string;
owner: string;
reason: string;
evidence: string; // where the evidence is stored
expires: number; // lab day of the expiry
hits: number; // hits in the last 30 lab days
};
// Precedence: the narrower scope wins over the wider scope.
const PRECEDENCE: Scope[] = ["target", "target class"];
const GENERAL: Record<string, string> = { "price selector": "span.price" };
const OVERRIDES: Override[] = [
{ behavior: "price selector", scope: "target class", key: "shop class 1", value: "div.cost",
owner: "team a", reason: "price in a div", evidence: "stored capture 12", expires: 150, hits: 41 },
{ behavior: "price selector", scope: "target", key: "lab target a", value: "td.amount",
owner: "team a", reason: "price in a table", evidence: "stored capture 17", expires: 90, hits: 6 },
{ behavior: "price selector", scope: "target", key: "lab target b", value: "b.amount",
owner: "team b", reason: "old layout", evidence: "stored capture 20", expires: 200, hits: 0 },
];
function resolve(behavior: string, target: string, targetClass: string) {
for (const scope of PRECEDENCE) {
const key = scope === "target" ? target : targetClass;
const o = OVERRIDES.find((x) => x.behavior === behavior && x.scope === scope && x.key === key);
if (o) return `${o.value} (override, ${scope} "${key}", owner ${o.owner})`;
}
return `${GENERAL[behavior]} (general rule)`;
}
// The release check: it fails after the expiry and at zero hits.
function releaseCheck(today: number): string[] {
const faults: string[] = [];
for (const o of OVERRIDES) {
if (today > o.expires) faults.push(`${o.key}: expired on lab day ${o.expires}; renew, remove, or move it into the general rule`);
if (o.hits === 0) faults.push(`${o.key}: zero hits; remove it`);
}
return faults;
}
console.log("lab target a:", resolve("price selector", "lab target a", "shop class 1"));
console.log("lab target c:", resolve("price selector", "lab target c", "shop class 1"));
console.log("lab target d:", resolve("price selector", "lab target d", "shop class 2"));
const faults = releaseCheck(100);
for (const f of faults) console.log("fault:", f);
console.log(faults.length === 0 ? "release check: pass" : `release check: fail (${faults.length} faults)`);output
The effective value for three lab targets, and the two faults of the release check on lab day 100.
lab target a: td.amount (override, target "lab target a", owner team a)
lab target c: div.cost (override, target class "shop class 1", owner team a)
lab target d: span.price (general rule)
fault: lab target a: expired on lab day 90; renew, remove, or move it into the general rule
fault: lab target b: zero hits; remove it
release check: fail (2 faults)The output shows three effective values. Lab target a gets its own override, lab target c gets the override of its target class, and lab target d gets the general rule. The release check fails on two faults: one expiry and one override with zero hits.
data
share of commits with the prefix fix, repository and general code
status of this figure: estimate, not measured
source: Benchmark platform, code (my test system): commit prefix counts, repository and general code; date 2026-11-16; condition: Non-merge commits. The prefix of the subject gives the kind, so a correction with another prefix is not counted.
data table
| commit set | % |
|---|---|
| whole repository | 35 |
| general code | 45 |
The first chart is an estimate from the commit messages of the benchmark platform, my test system. It sets the share of corrections in the general code beside the share in the whole code base. Each correction of general code is a part of the cost of the tail.
resource-blocking rules of a public filter list, by benefit in use
status of this figure: from a public source
source: Public study of the growth and use of crowdsourced filter lists, 2018 (public source, https://arxiv.org/abs/1810.09160, read 2026-11-12); date 2018-10-22; sample of 10,000; condition: The n is the count of websites. The second bar is the difference of 100 and the stated share.
data table
| benefit in use | % |
|---|---|
| no benefit in common use | 90.16 |
| some benefit in common use | 9.84 |
The list grew, and most of its resource-blocking rules gave no benefit in common use. A hit counter and a rule for removal are the minimum for each override.
overrides by age against the expiry line, split by hits
status of this figure: measured by me
- some hits in the window: inside the expiry line 146; past the expiry line 99
- zero hits in the window: inside the expiry line 25; past the expiry line 27
source: Lab result of this course: override store of the gated policy, 297 overrides; date 2026-11-13; condition: A fixed lab procedure adds each override, not a team. Teaching values for one host, not values for a real service.
data table
| series | age | overrides |
|---|---|---|
| some hits in the window | inside the expiry line | 146 |
| some hits in the window | past the expiry line | 99 |
| zero hits in the window | inside the expiry line | 25 |
| zero hits in the window | past the expiry line | 27 |
The third chart is a lab result of this course. Some overrides past the expiry line still change results, and some inside the line have zero hits. Thus the expiry alone and the hit counter alone each give wrong decisions. Use both, with the two release tests.
failure modes
| problem | cause | correction |
|---|---|---|
| The count of overrides only grows. | No override has an expiry or a hit counter. | Give each override both, and decide each one at its expiry. |
| A removed override breaks a target that still uses it. | The decision used the expiry only. | Run the test "still necessary" on the stored capture first. |
| A dead override stays for a long time. | The decision used the expiry only, and the expiry is far away. | Remove an override with zero hits, also before its expiry. |
| Nobody decides at the expiry. | The override has no owner. | Give each override one owner in its record. |
| Many targets carry the same override. | Nobody moved it into the general rule. | Move it into the general rule through the regression corpus. |
| A customer finds a limit only by a failure. | The product has no published not-supported list. | Publish the list, and keep it current with each change of scope. |
check questions
Which field of an override record shows that the override still changes results?
- The owner
- The expiry
- The hit counter
- The reason
answer
c. The hit counter
The hit counter counts the times that the override changed a result in the last period. The other fields say who decides, why the override exists, and when it stops.
Describe the two tests that each release runs on an override.
sample answer
The first test runs the general rule on the stored capture with no override. If the general rule fails, the override is still necessary. The second test runs the stored capture with the override, and it must give the expected record.
An override is past its expiry. It is still necessary, and it still works. What is the decision?
- Renew it with a new expiry and new evidence
- Remove it
- Keep it with no new expiry
answer
a. Renew it with a new expiry and new evidence
An override that is still necessary and still works gets a renewal. The owner gives a new expiry and new evidence, so that the next check comes again.
The cap of a target class is full, and a new case arrives. What occurs?
- The cap goes up by one.
- The new case waits until an old case is retired.
- The oldest override is removed with no check.
answer
b. The new case waits until an old case is retired.
A new case over the budget waits until an old case is retired. A removal still uses the two release tests.
Describe what a scope statement holds, and why an attorney examines it before publication.
sample answer
A scope statement says what is inside the scope of the product, what is outside it, and how the product announces a change. It can have an effect on a contract, thus an attorney of the operator examines it before publication.
exercise
exercise Do this task on paper on lab day 100. The cap is 3 active overrides for the target class, as an example value. All overrides are of one synthetic target class.
| override | expiry (lab day) | hits in the last 30 lab days | still necessary | still works |
|---|---|---|---|---|
| 1 | 150 | 12 | yes | yes |
| 2 | 90 | 8 | yes | yes |
| 3 | 120 | 0 | no | yes |
| 4 | 80 | 5 | yes | no |
A new case arrives for the same target class.
- Find each override that is due for a decision.
- Write the decision for each such override.
- Count the active overrides after the decisions.
- Write if the new case can start now or must wait.
sample answer
The answer uses the four synthetic overrides of the task.
Override 2 is past its expiry. It is still necessary and still works, thus the owner renews it with a new expiry. Override 3 has zero hits and is not necessary, thus you remove it. Override 4 is past its expiry and does not work, but it is still necessary. Thus the owner corrects it before a renewal. Override 1 stays active.
After the decisions, overrides 1, 2, and 4 are active: 3 overrides. The cap is 3, thus the new case waits until one more override is retired.
sources
- My model of the override record, the two release tests, the three decisions, and the special-case budget, 2026-11 (not public).