Skip to content

D63 — One polite reader for every web importer, and current values from the engine

  • Status: Accepted — amends D58 and D61
  • Date: 2026-09-30
  • Origin: the review of slice 37, before the complete data products are built on slices 32–37
  • Area: build

Decision

  • One polite reader. polite.Visit.read(url, reduce, …) is the whole courtesy of D58 in one call:
  • a reading kept within refresh_hours is reused, and counted as reused only when it was kept for the same question (sig, the filter over a whole dataset);
  • a server that refused, or has had its day's pages, is not asked;
  • requests to one server are spaced, and a 429 is waited out once, and logged;
  • each page of a listing is logged once, and a listing cut short says so;
  • a missing page reads as empty where the reader asks for that (a company with no such record), and as unread otherwise;
  • what is kept is only the rows read: as text (rows_text / text_rows), as a dataset's filtered rows (JSON with its sig), or nothing (a minute that names people).

Visit.ask is the same courtesy for a caller that keeps nothing: a report's pages, a sweep's documents, a portal's listing tab. - One shape for a web importer. importers.web.WebImporter holds what each of the six repeated: the spec, the permission to fetch, the run's Visit, what it reused and what it could not read. A Dataset carries the rows read and what its records need (rows, meta), rather than attributes added to it. - One report line. importers.report_line words what an importer reports when it finishes, and the CLI and the golden sessions print the same line. - Current values from the engine. - The public site reads the current-values table and its views (views.current, views.name_of) for the company pages and the representatives pages. - An importer reads read.held_values / read.value_of (the engine's entity_state and relation_state, staged work included). - A scope's sites, councils and linked organisations are scopes.scope_sites, scope_councils and linked_organisations, with one BEHIND.

So an entity merged into another, a retraction and a superseded value are accounted for everywhere, and a control that has ended is read as of the day the site is built, not the day the code runs.

Why

  • The copies had drifted.
  • The six copies of the reading loop no longer agreed. Two counted a kept reading as reused before finding it was kept for another question, and read it again.
  • One logged a multi-page listing's first page twice and its last page not at all.
  • Only one waited out a 429, and it did not log the first request.
  • Hand-written "value now" helpers read raw claims by the kept entity's id. They missed claims on an entity merged into it and read a retracted value as current. The review of slice 37 found both on the representatives pages; the same helpers served the slice 36 company pages.
  • The complete data products build on these importers and pages. One reader and one source of current values is what they should build on.

Verification

  • On a copy of the real graph, every web importer was run again with a reader that refuses any request. Holyrood, areas, councillors and Companies House reused every reading and changed nothing. Scottish planning gave the same counts as the code before this change.
  • The real Scotland site, rebuilt, is identical to the one built before it.
  • The goldens changed in one line: the sibling line now reads as the CLI prints it.