# NORMALISATION-v4

Normalisation version 4 of this record: every rule, in the order it runs, by
which the bytes a publisher served become the text whose SHA-256 is
written as an observation's `content_hash`, with test vectors. Two rule sets
produce such a digest, and this version states both: the **document** rule
set, which reduces a page or a PDF file, and the **register** rule set, which
reduces a public register published as HTML. This version holds
the rules in force from the commit that added the second host's exclusion, and in force now.

The rules are stated here in prose, and their machine-read parts in the fenced
`json` blocks: the identity, the rule values, the register substitutions and
the vectors. Only the blocks are checked against code. A plant in
`make gx-test` (`scripts/plants/b/test_normalisation_doc.py`) runs the live code
over every vector of this document and requires every text and every digest
to be reproduced, requires both profiles to equal the values named below, and
requires the rule values stated here to be the values the document profile is
computed from.

## Identity

```json
{
 "block": "identity",
 "normalisation_version": 4,
 "in_force_from": {
  "commit": "4472b7800",
  "date": "2026-09-14"
 },
 "register_from": {
  "commit": "e25df1609",
  "date": "2026-07-28"
 },
 "profiles": {
  "document": "5c58c19e85d5",
  "register": "fdee23da9b80"
 },
 "extractor_version": "8881121fd138"
}
```

## How the number 4 is derived

A version is one rule era in git. The commits that touch `scripts/observe.py`,
`scripts/observe_api.py` or `docs/referents/chrome-exclusions.json` are read
oldest first, and an era begins at the first commit holding the document rule
set and at each later commit where any of three things differs from the commit
before it:

- the code of the document rule set's functions (`looks_like_pdf`,
  `extract_pdf_text`, `normalise`, `digest`, `apply_chrome_exclusions`,
  `_chrome_rules`, and `_observed_text`, which fixes the order they run in),
  with comments and docstrings not read;
- its rule values (the volatile patterns, the tag and whitespace rules, the
  PDF signature, the window it is sought in and the read cap) or its host
  exclusion rules;
- the substitutions of a register rule set that already existed.

`normalisation.rule_eras()` derives the eras, and the plant requires one
document for each, numbered in that order. Four eras are derived:

| Version | First commit | Its date | What differs from the version before |
|---|---|---|---|
| v1 | `db6add9d4` | 2026-07-28 | the first commit holding the document rule set |
| v2 | `9bf3274` | 2026-09-07 | the text of a PDF file is extracted and reduced |
| v3 | `263cd57b0` | 2026-09-07 | a new tag rule, and the first host exclusions (one host) |
| v4 | `4472b7800` | 2026-09-14 | a host exclusion for a second host |

A commit's date in this repository names the day it landed and no time of day,
so v2 and v3 began on the same day. The register rule set first appears at
commit `e25df1609`, dated 2026-07-28, inside v1, and begins no version: no
register digest was taken under any earlier rule. Its four substitutions have
not changed since, and every version states them.

The profile stamp, `normalization_profile`, was written into the collectors by
commit `cfd970684`, dated 2026-10-04, while v4 was in force, and a line first
carries it on 2026-10-05. A version is therefore dated by the commit at which
its rules first ran, never by the day a stamp first named them.

## Lines reduced under this version

Three fields on a stored line can name v4's rules, each written by the
collector at the time:

- `normalisation_version` 4, on lines appended from the first nightly that
  runs the writer of this field (see "Reading a line of the store").
- `normalization_profile` `5c58c19e85d5` (document) or `fdee23da9b80`
  (register), the values named in the identity block, carried from 2026-10-05.
- `extractor_version` `8881121fd138`, carried from 2026-09-15. It is a digest of
  the document rule set's six functions and of the exclusions file's bytes, and
  not of the rule values, so it is named in the identity block and is not the
  profile. The plant requires the live code to compute it and requires no line
  carrying it to be dated before v4's first day.

A line dated 2026-09-14 that carries none of the three may have been reduced
under v3 or v4, and the line does not say which.

## Where the rules run

Found by form, as the functions whose output is passed to SHA-256 and written
as an observation's `content_hash`:

- `observe.observe_one` (the nightly document collector) and
  `start_document_series.py` (through `observe._observed_text`): the document
  rule set.
- `observe_api.poll_html_register` (the register collector, through
  `observe_api.register_normalise`): the register rule set. The JSON adapters
  of the same collector take no digest.
- `ops/attended_merge.py` enters records an attended run of `observe_one` wrote
  in a sealed store, so its digests are the document rule set's.

Each of these collectors appends through `observe.append_observation`, which
writes `normalisation_version` on each new line it appends.
`ops/attended_merge.py` enters a sealed record as it was sealed, with one key
added, so such a record carries the version only where the collector that
sealed it wrote one. The probe series, `observations/_probe/`, is appended by
`scripts/probe_matrix.py` and not through this writer; a probe line records a
request's answer and takes no digest, so no rule here reduces anything on it.

## The document rule set, for a markup body

0. **Decode** (in `observe.fetch`, before any rule here). The body's bytes are
   decoded with the charset of the response's `Content-Type`, or UTF-8 where it
   names none, and bytes that do not decode are dropped. The vectors below start
   from the decoded text.
1. **Volatile content** (`_VOLATILE`). Fourteen patterns, applied in the order
   listed under `volatile` in the rule values, each match replaced by one
   space: script, style and noscript elements; comments; nav, header, footer
   and aside elements; csrf, nonce, session, token, sid, jsessionid and
   viewstate values of eight or more characters; cache-busting query values;
   bare hexadecimal runs of 32 to 64 characters; analytics parameters; UUIDs;
   a date after "printed", "generated", "retrieved", "accessed", "downloaded"
   or "as of"; clock values with an optional zone; visitor and download
   counters; and relative times ending "ago". These run over the markup, before
   any tag is removed.
2. **Tags** (`_TAG`). Every tag is replaced by one space. A tag ends at a `>`
   outside a quoted attribute value; a `<` not followed by a letter, `/`, `!`
   or `?` is not a tag and is kept.
3. **Character references** (`html.unescape`). Named and numeric references are
   replaced by the characters they name. This runs after tags are removed, so a
   `&lt;` in the source becomes a `<` in the text and is kept.
4. **Whitespace** (`_WS`). Every run of whitespace, Unicode whitespace
   included, becomes one space, and the text is trimmed at both ends.
5. **Host exclusions** (`apply_chrome_exclusions`, rules from
   `docs/referents/chrome-exclusions.json`). The host of the answered address
   (the requested one where nothing else answered), lower-cased, selects a
   rule list; where the host has none, the same host with `www.` removed or
   added does. Each rule's matches are replaced by one space, in the order the
   file lists them, and the text is collapsed and trimmed as in step 4. The
   ids of the rules that fired are written in `chrome_excluded`.
6. **Digest** (`digest`). SHA-256 over the text's UTF-8 bytes, written as 64
   lower-case hexadecimal characters.

Two consequences of this order are stated by vectors D16, D18, D19 and D21. A
host exclusion runs after step 1, so the eCFR phrase "up to date as of"
followed by a date reaches step 5 only where markup kept step 1 from matching
the date (D16, D19). And a host exclusion runs after step 2, so the GOV.UK rule,
written over a `<meta name="csp-…">` tag, matches what steps 1 to 4 left of
one: a tag from which step 1's token rule removed a part, so that step 2 could
not read it as a tag (D18), or a tag written as character references, which
step 3 unescaped (D21).

## The document rule set, for a PDF body

A body whose first 1,024 bytes, after leading carriage returns, line feeds,
tabs, spaces, NUL bytes and UTF-8 byte-order-mark bytes are set aside, begin
`%PDF-` is read as a PDF file:

1. **Size**. A body of 4,000,000 bytes or more reached the read cap and is not
   read: no text and no digest, and the record says why.
2. **Text** (`extract_pdf_text`). Each page's text is extracted by pdfplumber
   (an empty string for a page with none), and the pages are joined with one
   line feed. Text that is empty once trimmed is not a reading: no digest.
3. **Volatile content**. The same fourteen patterns as markup step 1, in the
   same order.
4. **Whitespace**. As markup step 4. Text that is then empty, or that still
   begins `%PDF-`, is not a reading: no digest.
5. **Host exclusions** and 6. **Digest**, as markup steps 5 and 6.

No tag rule and no character-reference rule is applied to PDF text: a `<…>` or
an `&amp;` in a file's own text is that file's text.

## When a digest is taken

The reduction above yields text; a digest is written only where the read is
classed `direct` (`classify_fetch`): the response answered with status 200 or
203, a PDF's text was extracted, and the text holds at least 600 characters.
Below that floor the observation carries no digest, which is the measured
absence and not an empty document. The vectors test the reduction, and most of
their texts are shorter than the floor.

## Document rule values

The values `observe.normalization_rule_values()` returns, which the document
profile is taken over beside the source of the six reduction functions
(`looks_like_pdf`, `extract_pdf_text`, `normalise`, `digest`,
`apply_chrome_exclusions`, `_chrome_rules`). Each pattern is written with its
flags as Python's `re` module stores them: 32 is Unicode matching, 34 adds
case-insensitive matching, 48 adds dot-matches-newline, and 50 adds both.

```json
{
 "block": "document-rule-values",
 "values": {
  "volatile": [
   [
    "<script.*?</script>",
    50,
    " "
   ],
   [
    "<style.*?</style>",
    50,
    " "
   ],
   [
    "<noscript.*?</noscript>",
    50,
    " "
   ],
   [
    "<!--.*?-->",
    48,
    " "
   ],
   [
    "<(nav|header|footer|aside)\\b.*?</\\1>",
    50,
    " "
   ],
   [
    "\\b(?:csrf|nonce|session|token|sid|jsessionid|viewstate)[-_a-z]*[\"\\s:=]+[A-Za-z0-9_\\-+/=]{8,}",
    34,
    " "
   ],
   [
    "\\?(?:v|ver|version|cb|t|ts|rev|_)=[A-Za-z0-9._-]+",
    34,
    " "
   ],
   [
    "\\b[a-f0-9]{32,64}\\b",
    32,
    " "
   ],
   [
    "\\b(?:ga|gtm|utm_[a-z]+|_gid|_ga|fbclid|gclid)\\b[^\\s\\\"']*",
    34,
    " "
   ],
   [
    "\\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\\b",
    34,
    " "
   ],
   [
    "(?:printed|generated|retrieved|accessed|downloaded|as of)\\s+(?:on\\s+)?\\d{1,2}[ /-][A-Za-z0-9]{1,9}[ /-]\\d{2,4}",
    34,
    " "
   ],
   [
    "\\b\\d{1,2}:\\d{2}(?::\\d{2})?\\s*(?:AM|PM|UTC|GMT|CET|CEST)?\\b",
    34,
    " "
   ],
   [
    "\\b\\d[\\d,]*\\s+(?:views?|visitors?|downloads?|hits)\\b",
    34,
    " "
   ],
   [
    "\\b\\d+\\s+(?:seconds?|minutes?|hours?|days?)\\s+ago\\b",
    34,
    " "
   ]
  ],
  "tag": [
   "<[a-zA-Z/!?][^>\"']*(?:\"[^\"]*\"[^>\"']*|'[^']*'[^>\"']*)*>",
   32
  ],
  "whitespace": [
   "\\s+",
   32
  ],
  "pdf_signature": "%PDF-",
  "pdf_signature_window": 1024,
  "exclusions": [
   [
    "www.ecfr.gov",
    [
     [
      "Title \\d+ was last amended \\d{1,2}/\\d{1,2}/\\d{4}",
      32
     ],
     [
      "up to date as of \\d{1,2}/\\d{1,2}/\\d{4}",
      32
     ]
    ]
   ],
   [
    "www.gov.uk",
    [
     [
      "<meta name=\"csp-[^\"]{0,40}\"[A-Za-z0-9+/]{16,64}={0,2}\" />",
      32
     ]
    ]
   ]
  ],
  "missing": []
 }
}
```

## The register rule set

`observe_api.register_normalise`, over a body read as UTF-8 with undecodable
bytes dropped (at most 3,000,000 bytes are read). Four substitutions, in order,
each match replaced by one space, then the text is trimmed; the digest is
SHA-256 over the text's UTF-8 bytes. A register reading below 400 characters is
recorded as thin and carries no digest.

This rule set differs from the document rule set, and vectors R2 and R3 state
two of the differences: a tag ends at its first `>`, quoted or not, and no
character reference is unescaped.

```json
{
 "block": "register-substitutions",
 "then": "trim both ends",
 "substitutions": [
  {
   "pattern": "<script.*?</script>|<style.*?</style>|<!--.*?-->",
   "flags": "re.S | re.I",
   "replacement": " "
  },
  {
   "pattern": "<[^>]+>",
   "flags": "",
   "replacement": " "
  },
  {
   "pattern": "[?&](?:t|ts|_|v|cb|sid|jsessionid)=[A-Za-z0-9._-]+",
   "flags": "",
   "replacement": " "
  },
  {
   "pattern": "\\s+",
   "flags": "",
   "replacement": " "
  }
 ]
}
```

## Vectors

Each input is hand-written for this document and is not taken from any
publisher's page. `text` is the text the rule set yields and `sha256` is the
SHA-256 of that text's UTF-8 bytes. A document vector names the address it is
read as answered from, because step 5 reads the host. A PDF vector's input is
written as a JSON string whose every character stands for one byte.

```json
{
 "block": "vectors",
 "family": "document",
 "vectors": [
  {
   "id": "D0",
   "what": "an empty body",
   "url": "https://publisher.example/document",
   "input": "",
   "text": "",
   "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
  },
  {
   "id": "D1",
   "what": "script, style, noscript and comment removed",
   "url": "https://publisher.example/document",
   "input": "<p>Annex 1</p><script>var t=1;</script><style>p{}</style><noscript>x</noscript><!-- c --><p>Scope</p>",
   "text": "Annex 1 Scope",
   "sha256": "e57962e28a9df11d6cbdba23bac24ea1153a2d2f44ac85ae5d1d0b7fa3b5c903"
  },
  {
   "id": "D2",
   "what": "nav, header, footer and aside removed",
   "url": "https://publisher.example/document",
   "input": "<header>Menu</header><nav>Home</nav><p>Section 4</p><aside>Note</aside><footer>Contact</footer>",
   "text": "Section 4",
   "sha256": "6752a6387220ae2cc874a52b1e21c448787da63f4a78b0b927ffbcb79a952405"
  },
  {
   "id": "D3",
   "what": "a session token removed",
   "url": "https://publisher.example/document",
   "input": "<p>session: Ab12Cd34Ef56</p><p>Body</p>",
   "text": "Body",
   "sha256": "6ccaa6415b5ee449e3c5c716f57b4608ebe3b780f5aa6b077bc5d8eee5d961f9"
  },
  {
   "id": "D4",
   "what": "a cache buster removed",
   "url": "https://publisher.example/document",
   "input": "<p>Guide?v=20260101 text</p>",
   "text": "Guide text",
   "sha256": "d3ebfa5ad2fc97fee4fbffadafb4c7ca286df68a62424245cbc7ca46271a877d"
  },
  {
   "id": "D5",
   "what": "a bare digest of 32 hex characters removed",
   "url": "https://publisher.example/document",
   "input": "<p>File 0123456789abcdef0123456789abcdef final</p>",
   "text": "File final",
   "sha256": "1f269c680c7a833643c5de22092e02f711eaf71b226ef89127069c1b4f7a685f"
  },
  {
   "id": "D6",
   "what": "an analytics parameter removed",
   "url": "https://publisher.example/document",
   "input": "<p>ref utm_source=feed end</p>",
   "text": "ref end",
   "sha256": "8b691a8ceb0dc3aa9a5a7f9f730885764d76b71933f9c9d8cb21612912d73a72"
  },
  {
   "id": "D7",
   "what": "a UUID removed",
   "url": "https://publisher.example/document",
   "input": "<p>id 123e4567-e89b-12d3-a456-426614174000 x</p>",
   "text": "id x",
   "sha256": "3cd36c717c9083bec0575e9ff5c07c51e950e1e01328627e5b1bef202df9ff32"
  },
  {
   "id": "D8",
   "what": "a printed-on date removed",
   "url": "https://publisher.example/document",
   "input": "<p>Rev 3 printed on 3 May 2026 end</p>",
   "text": "Rev 3 end",
   "sha256": "966353381c7ebc5d183620a9344223eeb27a596095619b30a57af7ddb1192148"
  },
  {
   "id": "D9",
   "what": "a clock removed",
   "url": "https://publisher.example/document",
   "input": "<p>Updated 00:00 UTC daily</p>",
   "text": "Updated daily",
   "sha256": "a6aa90be2003df17c48f6e2adb5e7140036eec0a479fcb9c7bfe25f88bab9e5e"
  },
  {
   "id": "D10",
   "what": "a counter and a relative time removed",
   "url": "https://publisher.example/document",
   "input": "<p>1,204 views and 3 days ago</p>",
   "text": "and",
   "sha256": "6201111b83a0cb5b0922cb37cc442b9a40e24e3b1ce100a4bb204f4c63fd2ac0"
  },
  {
   "id": "D11",
   "what": "a tag holding a quoted greater-than sign removed whole",
   "url": "https://publisher.example/document",
   "input": "<button data-action=\"click->search#go\">Find</button><p>Part 11</p>",
   "text": "Find Part 11",
   "sha256": "1939dcf20008b32e4b06b65c2e9f1d3ca0410a0702f3b9ba38030219f73652ab"
  },
  {
   "id": "D12",
   "what": "a less-than sign in prose kept",
   "url": "https://publisher.example/document",
   "input": "<p>if a < b then</p>",
   "text": "if a < b then",
   "sha256": "386e4a1fd5b4e715b74beb0697d11bf31d65ad222b5afa7dec17d6ef14d0f02a"
  },
  {
   "id": "D13",
   "what": "character references unescaped after tags are removed",
   "url": "https://publisher.example/document",
   "input": "<p>R&amp;D &lt;draft&gt; &#8211; v2</p>",
   "text": "R&D <draft> – v2",
   "sha256": "14351575a76d2145798ebaa35462d2910c879bd985a5b7c4a759e5b0ccb2b949"
  },
  {
   "id": "D14",
   "what": "whitespace collapsed and trimmed",
   "url": "https://publisher.example/document",
   "input": "<p>  Line\n\tone   two </p>",
   "text": "Line one two",
   "sha256": "0e1dccf1fa5c1cae95dae8eaba7915678711564d19299496eb24c5cfb7eefa53"
  },
  {
   "id": "D15",
   "what": "a host exclusion applied",
   "url": "https://www.ecfr.gov/current/title-21/part-11",
   "input": "<p>Title 21 was last amended 1/02/2026 Part 11 text</p>",
   "text": "Part 11 text",
   "sha256": "fea7514ab1970c3940c0fcf21342906df0bb09728a751b4d1550137653527363"
  },
  {
   "id": "D16",
   "what": "a host exclusion applied to the host without www., where markup kept the volatile rule from reaching the date",
   "url": "https://ecfr.gov/current/title-21",
   "input": "<p>up to date as of <b>1/02/2026</b> Body</p>",
   "text": "Body",
   "sha256": "6ccaa6415b5ee449e3c5c716f57b4608ebe3b780f5aa6b077bc5d8eee5d961f9"
  },
  {
   "id": "D17",
   "what": "a host exclusion not applied on another host",
   "url": "https://publisher.example/document",
   "input": "<p>Title 21 was last amended 1/02/2026 Part 11 text</p>",
   "text": "Title 21 was last amended 1/02/2026 Part 11 text",
   "sha256": "3c9c095e09cdf9ce820b7f38df194df36c9b56e310560d50a59dcd761a4f3f34"
  },
  {
   "id": "D18",
   "what": "the volatile token rule removes part of a meta tag, the tag rule cannot then read the tag, and the host exclusion removes what is left",
   "url": "https://www.gov.uk/guidance/x",
   "input": "<meta name=\"csp-nonce\" content=\"QUJDREVGR0hJSktMTU5PUA==\" /><p>Guidance</p>",
   "text": "Guidance",
   "sha256": "10af9928ba801e7d223b816e783edf7c6d77d3bf5390ae16616eb6a5a1a195a8"
  },
  {
   "id": "D19",
   "what": "the volatile rule removes an as-of date before the host exclusion is applied",
   "url": "https://www.ecfr.gov/current/title-21",
   "input": "<p>up to date as of 1/02/2026 Body</p>",
   "text": "up to date Body",
   "sha256": "8c1adc4ec90aff99643f5116ee10f8ccfd4968defea453fc3e77c7240d44fb40"
  },
  {
   "id": "D20",
   "what": "a no-break space from a character reference collapsed with the other whitespace",
   "url": "https://publisher.example/document",
   "input": "<p>a&nbsp;&nbsp;b</p>",
   "text": "a b",
   "sha256": "c8687a08aa5d6ed2044328fa6a697ab8e96dc34291e8c2034ae8c38e6fcc6d65"
  },
  {
   "id": "P1",
   "what": "PDF text extracted, then a printed-on date removed",
   "url": "https://publisher.example/document",
   "input_latin1": "%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nendobj\n3 0 obj\n<< /Type /Page /Parent 2 0 R /MediaBox [0 0 612 792] /Contents 4 0 R /Resources << /Font << /F1 5 0 R >> >> >>\nendobj\n4 0 obj\n<< /Length 67 >>\nstream\nBT /F1 12 Tf 72 720 Td (Annex 22 printed on 3 May 2026 Scope) Tj ET\nendstream\nendobj\n5 0 obj\n<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>\nendobj\ntrailer\n<< /Root 1 0 R >>\n%%EOF\n",
   "text": "Annex 22 Scope",
   "sha256": "8f1f0ff5fa5758deff54cec1518e46a7ca2a82ab4950131f0619a89381d810fa"
  },
  {
   "id": "P2",
   "what": "two pages joined, then whitespace collapsed",
   "url": "https://publisher.example/document",
   "input_latin1": "%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R 5 0 R] /Count 2 >>\nendobj\n3 0 obj\n<< /Type /Page /Parent 2 0 R /MediaBox [0 0 612 792] /Contents 4 0 R /Resources << /Font << /F1 7 0 R >> >> >>\nendobj\n4 0 obj\n<< /Length 39 >>\nstream\nBT /F1 12 Tf 72 720 Td (Page one) Tj ET\nendstream\nendobj\n5 0 obj\n<< /Type /Page /Parent 2 0 R /MediaBox [0 0 612 792] /Contents 6 0 R /Resources << /Font << /F1 7 0 R >> >> >>\nendobj\n6 0 obj\n<< /Length 39 >>\nstream\nBT /F1 12 Tf 72 720 Td (Page two) Tj ET\nendstream\nendobj\n7 0 obj\n<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>\nendobj\ntrailer\n<< /Root 1 0 R >>\n%%EOF\n",
   "text": "Page one Page two",
   "sha256": "b134ebfcd2fa0165bed4522806440e6477ef32ded2b3003797b123b428e39095"
  },
  {
   "id": "P3",
   "what": "leading whitespace before the PDF signature",
   "url": "https://publisher.example/document",
   "input_latin1": "\n%PDF-1.4\n1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nendobj\n3 0 obj\n<< /Type /Page /Parent 2 0 R /MediaBox [0 0 612 792] /Contents 4 0 R /Resources << /Font << /F1 5 0 R >> >> >>\nendobj\n4 0 obj\n<< /Length 43 >>\nstream\nBT /F1 12 Tf 72 720 Td (Leading line) Tj ET\nendstream\nendobj\n5 0 obj\n<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>\nendobj\ntrailer\n<< /Root 1 0 R >>\n%%EOF\n",
   "text": "Leading line",
   "sha256": "2ce44f453f243770edddc6303e87aeaec346319108d3314e4f1bd4c8d245d926"
  },
  {
   "id": "D21",
   "what": "a meta tag written as character references, unescaped, then removed by the host exclusion",
   "url": "https://www.gov.uk/guidance/x",
   "input": "<p>&lt;meta name=&quot;csp-nonce&quot;QUJDREVGR0hJSktMTU5PUA==&quot; /&gt; Guidance</p>",
   "text": "Guidance",
   "sha256": "10af9928ba801e7d223b816e783edf7c6d77d3bf5390ae16616eb6a5a1a195a8"
  }
 ]
}
```

```json
{
 "block": "vectors",
 "family": "register",
 "vectors": [
  {
   "id": "R1",
   "what": "script, style and comment removed",
   "input": "<p>EudraGMDP</p><script>x</script><!-- c --><style>s</style><p>List</p>",
   "text": "EudraGMDP List",
   "sha256": "c9ce904afc5d175713fd3cf4cf5442ea097a31def0660b77efcc7b4744278abc"
  },
  {
   "id": "R2",
   "what": "a tag ends at its first greater-than sign",
   "input": "<a data-x=\"a>b\">Link</a>",
   "text": "b\">Link",
   "sha256": "a174a25f3887ff4371ab54c860f1a1c2b4646379385f485d1e3d0adddba3d54f"
  },
  {
   "id": "R3",
   "what": "a query token removed and character references kept",
   "input": "<p>Index?ts=1700000000 page &amp; more</p>",
   "text": "Index page &amp; more",
   "sha256": "c3867059704bf5f047f1e482442420f20ef8b36c2d777d83332df926725572ad"
  },
  {
   "id": "R4",
   "what": "whitespace collapsed and trimmed",
   "input": "  a \n b ",
   "text": "a b",
   "sha256": "c8687a08aa5d6ed2044328fa6a697ab8e96dc34291e8c2034ae8c38e6fcc6d65"
  },
  {
   "id": "R5",
   "what": "adjacent elements kept apart by the space each removed tag leaves",
   "input": "<td>Site</td><td>Status</td>",
   "text": "Site Status",
   "sha256": "3ce83e18855a0bb50ac44b1bd95040ecc756ff1cc6fae67e42fa84fd8edee3ae"
  }
 ]
}
```

The PDF vectors' texts hold under the PDF libraries an observation names in its
`parser_version`; a library release that extracts the same file differently
would make the plant fail on these vectors before any reading is compared.

## Reading a line of the store

- `schema_version` is the version of the record's shape; it is 1 on every line
  that carries it.
- `normalisation_version` is written by `observe.append_observation` on each
  line it appends from the first nightly that runs it: the number of the latest
  version whose identity names the line's own `normalization_profile`. Only v4
  names profiles, so while v4 is the latest version 4 is the one number
  written. It is null on a line
  that carries no profile, because no digest was taken and no rule stood
  between bytes and a digest; and null on a line whose profile no published
  version names, which the plant reads red at the next board that runs it.
- A line without the key does not state the version, and none is added to it
  afterwards. That holds for every line appended before the writer wrote the
  key, for a record `ops/attended_merge.py` enters as an attended run sealed
  it, and for a line appended while the documents could not be read: the
  writer then prints that it did not read them and writes no key, because a
  read that failed is unmeasured and not a null.
- A line's own `normalization_profile` or `extractor_version`, where it carries
  one, is the record's own statement of the rules that reduced it.

## A new version

A change to any rule above, to the rule values, to the code of the reduction
functions, to the order they run in or to the host exclusions begins a new era
in git. It is stated in a new document, `NORMALISATION-v5.md`, with its own
vectors, and this document is kept as it stands; the plant refuses a working
tree whose rules differ from the last era any document states. A reading whose
previous digest was taken under another profile is not compared with it
(`comparison_unmeasured`, from commit `cfd970684`, dated 2026-10-04), so a
version after v4 whose change moves a profile is never counted as a change in
any publisher's document; a change to the order alone (`_observed_text`) moves
no profile, and the plant's refusal is what holds it until its document is
written. The
comparisons the store made across the beginnings of v2, v3 and v4 were made
before that guard existed, and this document does not state how each was read.
The method page, `/how/method/`, lists each version by the date of its first
commit.

## What this document does not state

- The decode of markup in `observe.fetch` is stated, not tested: the vectors
  begin from decoded text.
- `html.unescape` and the `re` module belong to the Python runtime, which a
  line names in `parser_version`; their behaviour is the runtime's.
- The fetch, the classification and the floor decide whether a digest is taken.
  They are not part of the reduction and are not identified by a profile.
