change management for a collector · lesson 2 of 6 · sources checked 2026-11-30
the blast radius of a change in shared code
This lesson maps each shared function, constant, and data file to the targets that use it, and counts the affected targets of one change.
purpose
One line of shared code can reach each target that uses it. Before a release, you must know which targets and which target classes a change reaches. Without that count, a small change can become a large failure.
objectives
- Build a dependency map from each shared function, constant, and data file to the targets that use it.
- Explain why a map of code imports alone misses some targets.
- Compute the impact count of one change for each target class.
- Find two copies of one fact, and map both of them.
new terms
- dependency map
- A map from each shared function, constant, and data file to the overrides and targets that use it.
- impact count
- The count of affected targets for each target class that a dependency map gives for one change.
how it works
The blast radius of a change is the set of targets and overrides that one change in shared code can affect. Shared code is the code that many targets use, for example a text cleaner or a date reader.
the dependency map
A dependency map goes from each shared item to the targets that use it. A shared item is a function, a constant, or a data file. The map has four levels:
- The shared item, for example the function
parse_date. - Each override that uses the item. An override is a special case in data for one scope.
- Each target that uses the item directly or through an override.
- The target class of each target, for example "article" or "listing".
imports alone miss the data files
A map of code imports shows which code calls which function. It does not read a data file. Some targets reach a shared item only through an override in a data file. For example, the file says that one target uses a special date format. The code of that target imports nothing new.
Thus an import map misses that target. Scan the data files of the overrides too, and add each link that they give to the map.
two copies of one fact are one fact
Sometimes one fact is in two places. For example, a list of failure forms is in the retry code and in the record code. A change updates one copy. The two copies now disagree. A failure form can then be terminal in one place and still get a retry in the other place.
Treat the two copies as one fact, and map both readers. A better correction is one shared constant that both readers import.
the impact count
The impact count of one change is the count of affected targets for each target class. Read it from the map:
- Find the changed item.
- Follow each link to the overrides and the targets.
- Count the targets in each target class.
For example, a change to the list of author names reaches 6 article targets, 1 event target, and no product target. This count is a synthetic example. The count shows which target classes the release must test first.
two kinds of count
A static count reads the code and the data files. It gives each target that can reach the item. A dynamic count records each target that really used the item on one day.
For example, a date reader has a path for a rare date form that no page used on that day. The static count holds the target of that path, and the dynamic count does not. Thus a static count can be larger, and a dynamic count can miss a path.
Say which count a statement uses. The count gives the reach of a change. It does not give the effect. A differential run runs the old code and the new code on the same input, and lists each difference. More detail is in The regression corpus and the differential run.
the view of a defender
A change in shared code reaches many targets at one time. A defender of one site sees only its own site. For example, a new retry wait shows on each target in the same hour.
But a defender with many sites can see the same change on each of them at the same time. That common change can link the sites to one operator.
the two sides
| automation side | detection side |
|---|---|
| An impact count shows the team which target classes a change touches before the release. | A defender sees a change in shared code as a change on many targets at one time. The same change on many sites can link them to one operator. |
design decisions
| option | gain | cost | when it is correct |
|---|---|---|---|
| Map the code imports only | A tool can make the map from the code. | It misses each target that an override in a data file links. | Only when no data file holds overrides |
| Map the imports and scan the data files | The map holds each link of the code and the data. | The scan must know the format of each data file. | For a collector with overrides in data |
| Static count | It finds each path that can reach the item. | It can count paths that no page uses. | Before a release, as the upper limit |
| Dynamic count | It counts only the paths that pages really use. | It misses a path that a page uses on other days. | To find the targets to test first |
| One shared constant for one fact | A change reaches each reader at one time. | The readers depend on one more shared item. | Each time two places hold the same fact |
diagram
the dependency map: shared items, overrides, targets, and target classes
code example
The example builds a small map from a synthetic import graph and a synthetic data file of overrides. It gives the impact count of one changed item, first from the imports only, then with the data file. All names are synthetic.
Build a dependency map from code imports and an override data file, and print the impact count of one change.
type Target = { id: string; cls: string; imports: string[] };
// Synthetic code imports of each target.
const targets: Target[] = [
{ id: "a1", cls: "article", imports: ["clean_text", "parse_date"] },
{ id: "a2", cls: "article", imports: ["clean_text"] },
{ id: "e1", cls: "event", imports: ["clean_text"] },
{ id: "e2", cls: "event", imports: ["clean_text", "parse_date"] },
{ id: "p1", cls: "product", imports: ["clean_text", "read_price"] },
{ id: "l1", cls: "listing", imports: ["clean_text"] },
];
// Synthetic override data file: each override names a target and a shared item.
const overrides = [
{ id: "ov-1", target: "a2", uses: "DATE_FORMATS" },
{ id: "ov-2", target: "e1", uses: "DATE_FORMATS" },
{ id: "ov-3", target: "l1", uses: "DATE_FORMATS" },
];
// The code link between shared items: parse_date reads DATE_FORMATS.
const codeUses: Record<string, string[]> = { parse_date: ["DATE_FORMATS"] };
function reaches(t: Target, item: string, withData: boolean): boolean {
const direct = t.imports.some((i) => i === item || (codeUses[i] ?? []).includes(item));
const viaData = withData && overrides.some((o) => o.target === t.id && o.uses === item);
return direct || viaData;
}
function impactCount(item: string, withData: boolean): Record<string, number> {
const count: Record<string, number> = {};
for (const t of targets) count[t.cls] = count[t.cls] ?? 0;
for (const t of targets) if (reaches(t, item, withData)) count[t.cls] += 1;
return count;
}
const changed = process.argv[2] ?? "DATE_FORMATS";
console.log(`changed item: ${changed}`);
console.log("imports only:", JSON.stringify(impactCount(changed, false)));
console.log("with data file:", JSON.stringify(impactCount(changed, true)));output
The impact count of the changed item for each target class, from the imports only and with the data file.
changed item: DATE_FORMATS
imports only: {"article":1,"event":1,"product":0,"listing":0}
with data file: {"article":2,"event":2,"product":0,"listing":1}The output shows that the import map finds two targets, and the scan of the data file finds three more. The listing class has no import link to the item, so only the scan finds it.
data
targets that a change to each shared item of a lab collector reaches
status of this figure: measured by me
- product: DATE_FMT_MAP 0; DATE_FORMATS 25; EU_PRICE 25; ITEMPROP 13; KEYWORDS 4; NEGATIVE 4; adapt_article 0; adapt_event 0; adapt_listing 0; adapt_product 25; bespoke_extract 2; class_match 4; clean_text 25; find_by_class 4; find_raw 13; generic_extract 25; parse_avail 25; parse_date 0; parse_date_fmt 0; parse_price 22; parse_price_fmt 5; pick_title 25; read_jsonld 25
- article: DATE_FMT_MAP 3; DATE_FORMATS 25; EU_PRICE 25; ITEMPROP 22; KEYWORDS 14; NEGATIVE 14; adapt_article 25; adapt_event 0; adapt_listing 0; adapt_product 0; bespoke_extract 7; class_match 14; clean_text 25; find_by_class 14; find_raw 22; generic_extract 25; parse_avail 0; parse_date 25; parse_date_fmt 3; parse_price 0; parse_price_fmt 0; pick_title 25; read_jsonld 25
- event: DATE_FMT_MAP 4; DATE_FORMATS 25; EU_PRICE 25; ITEMPROP 21; KEYWORDS 7; NEGATIVE 7; adapt_article 0; adapt_event 25; adapt_listing 0; adapt_product 0; bespoke_extract 4; class_match 7; clean_text 25; find_by_class 7; find_raw 21; generic_extract 25; parse_avail 0; parse_date 25; parse_date_fmt 4; parse_price 20; parse_price_fmt 6; pick_title 25; read_jsonld 25
- listing: DATE_FMT_MAP 9; DATE_FORMATS 25; EU_PRICE 25; ITEMPROP 11; KEYWORDS 4; NEGATIVE 4; adapt_article 0; adapt_event 0; adapt_listing 25; adapt_product 0; bespoke_extract 12; class_match 4; clean_text 25; find_by_class 4; find_raw 11; generic_extract 25; parse_avail 0; parse_date 25; parse_date_fmt 9; parse_price 0; parse_price_fmt 0; pick_title 25; read_jsonld 25
source: Lab result of this course: dynamic trace of one lab collector on 100 lab targets; date 2026-11-13; condition: One small lab code base, one seed, one host. A trace shows only the paths that the pages of one lab day use. Lab teaching values, not values for a real service.
data table
| series | shared item | targets |
|---|---|---|
| product | DATE_FMT_MAP | 0 |
| product | DATE_FORMATS | 25 |
| product | EU_PRICE | 25 |
| product | ITEMPROP | 13 |
| product | KEYWORDS | 4 |
| product | NEGATIVE | 4 |
| product | adapt_article | 0 |
| product | adapt_event | 0 |
| product | adapt_listing | 0 |
| product | adapt_product | 25 |
| product | bespoke_extract | 2 |
| product | class_match | 4 |
| product | clean_text | 25 |
| product | find_by_class | 4 |
| product | find_raw | 13 |
| product | generic_extract | 25 |
| product | parse_avail | 25 |
| product | parse_date | 0 |
| product | parse_date_fmt | 0 |
| product | parse_price | 22 |
| product | parse_price_fmt | 5 |
| product | pick_title | 25 |
| product | read_jsonld | 25 |
| article | DATE_FMT_MAP | 3 |
| article | DATE_FORMATS | 25 |
| article | EU_PRICE | 25 |
| article | ITEMPROP | 22 |
| article | KEYWORDS | 14 |
| article | NEGATIVE | 14 |
| article | adapt_article | 25 |
| article | adapt_event | 0 |
| article | adapt_listing | 0 |
| article | adapt_product | 0 |
| article | bespoke_extract | 7 |
| article | class_match | 14 |
| article | clean_text | 25 |
| article | find_by_class | 14 |
| article | find_raw | 22 |
| article | generic_extract | 25 |
| article | parse_avail | 0 |
| article | parse_date | 25 |
| article | parse_date_fmt | 3 |
| article | parse_price | 0 |
| article | parse_price_fmt | 0 |
| article | pick_title | 25 |
| article | read_jsonld | 25 |
| event | DATE_FMT_MAP | 4 |
| event | DATE_FORMATS | 25 |
| event | EU_PRICE | 25 |
| event | ITEMPROP | 21 |
| event | KEYWORDS | 7 |
| event | NEGATIVE | 7 |
| event | adapt_article | 0 |
| event | adapt_event | 25 |
| event | adapt_listing | 0 |
| event | adapt_product | 0 |
| event | bespoke_extract | 4 |
| event | class_match | 7 |
| event | clean_text | 25 |
| event | find_by_class | 7 |
| event | find_raw | 21 |
| event | generic_extract | 25 |
| event | parse_avail | 0 |
| event | parse_date | 25 |
| event | parse_date_fmt | 4 |
| event | parse_price | 20 |
| event | parse_price_fmt | 6 |
| event | pick_title | 25 |
| event | read_jsonld | 25 |
| listing | DATE_FMT_MAP | 9 |
| listing | DATE_FORMATS | 25 |
| listing | EU_PRICE | 25 |
| listing | ITEMPROP | 11 |
| listing | KEYWORDS | 4 |
| listing | NEGATIVE | 4 |
| listing | adapt_article | 0 |
| listing | adapt_event | 0 |
| listing | adapt_listing | 25 |
| listing | adapt_product | 0 |
| listing | bespoke_extract | 12 |
| listing | class_match | 4 |
| listing | clean_text | 25 |
| listing | find_by_class | 4 |
| listing | find_raw | 11 |
| listing | generic_extract | 25 |
| listing | parse_avail | 0 |
| listing | parse_date | 25 |
| listing | parse_date_fmt | 9 |
| listing | parse_price | 0 |
| listing | parse_price_fmt | 0 |
| listing | pick_title | 25 |
| listing | read_jsonld | 25 |
The chart is a lab result of this course on one small lab code base. It is not a value for a real service.
Some items reach each target class, and other items reach only some classes.
failure modes
| problem | cause | correction |
|---|---|---|
| A change to a shared format table breaks targets that the review did not expect. | The map read the code imports only, and an override in a data file linked those targets. | Scan the data files of the overrides, and add each link to the map. |
| A failure form is terminal in one place and still gets a retry in a different place. | Two copies of one list drifted, because a change updated one copy only. | Map both readers, and use one shared constant in place of the two copies. |
| The team tests the wrong target class first. | The impact count was not made, or it was made for all targets with no class. | Count the affected targets for each target class before the release. |
| A statement gives a count of affected targets, and a reader cannot check it. | The statement does not say if the count is static or dynamic. | Say which count each statement uses. |
check questions
Which levels does a dependency map hold, from the start to the end?
- Shared item, override, target, target class
- Target class, release, test, way back
- Shared item, target class, release, defender
answer
a. Shared item, override, target, target class
The map goes from each shared item to the overrides and the targets. Then it goes to the target class of each target.
Explain why a map of code imports alone misses some targets.
sample answer
Some targets reach a shared item only through an override in a data file. The code of such a target imports nothing new. An import map does not read the data file, so it misses that target. A scan of the data files finds the link.
A change reaches 2 article targets and 1 listing target, and no product target. What is this result?
- The blast radius in one number
- The impact count of the change for each target class
- The effect of the change on the records
answer
b. The impact count of the change for each target class
The impact count is the count of affected targets for each target class. It gives the reach of a change, not its effect. A differential run measures the effect.
A list of failure forms is in the retry code and in the record code. A change updates one copy only. What is the better correction?
- Update the second copy by hand at each release.
- Remove the list from the record code.
- Use one shared constant that both readers import, in place of the two copies.
answer
c. Use one shared constant that both readers import, in place of the two copies.
Two copies of one fact are one fact. One shared constant lets a change reach each reader at one time.
exercise
exercise Do this task on paper. Use the synthetic records of a lab collector below. The changed item is the constant UNIT_TABLE.
Code imports of each target:
- Target a1 (article):
clean_text. - Target a2 (article):
clean_text,read_size. - Target p1 (product):
clean_text,read_size. - Target p2 (product):
clean_text. - Target l1 (listing):
clean_text.
Code links: the function read_size reads UNIT_TABLE.
Override data file:
- Override ov-7: target p2 uses
UNIT_TABLE. - Override ov-8: target l1 uses
UNIT_TABLE.
- Draw the dependency map from
UNIT_TABLEto the targets. - Write the impact count for each target class from the imports only.
- Write the impact count for each target class with the data file.
- Write the target class that only the scan of the data file finds.
sample answer
The answer uses the synthetic records of the task.
UNIT_TABLE goes to read_size, and read_size goes to a2 and p1. It also goes to the overrides ov-7 and ov-8, and they go to p2 and l1.
From the imports only, the count is article 1, product 1, and listing 0. With the data file, the count is article 1, product 2, and listing 1. Only the scan of the data file finds the listing class.
sources
- My model of the dependency map, the impact count, and the two kinds of count, 2026-11 (not public).