# Changelog of UK Companies House Scraper — Directors, PSCs & Filings (`stone_jadex/uk-companies-house-scraper`) Actor

- **URL**: https://apify.com/stone_jadex/uk-companies-house-scraper/changelog.md
- **Full Actor documentation**: https://apify.com/stone_jadex/uk-companies-house-scraper.md

## Changelog

### 2026-11-21

- Renamed incremental state store input `stateKey` to `stateRecordName` in `.actor/input_schema.json` to eliminate secret-field false positives, while keeping full backward-compatible fallback for legacy `stateKey` in `src/input.js` (and `DEFAULT_STATE_KEY` export). Updated unit tests (`test/input.test.js`, `test/incremental.test.js`, `test/schema.test.js`) to verify both `stateRecordName` and legacy `stateKey`.
- Added explicit `prefill` values (`maxItems`, `stateRecordName`) and `sectionCaption` groupings (`Search & targets`, `Enrichment & rate limits`) in `.actor/input_schema.json`.
- Updated `README.md` with `stateRecordName` docs, Store subscription tier discounts note, JavaScript and Python `ApifyClient` SDK quickstart examples, and Changelog.

### Unreleased (N2/N4/N5: live form-error text, Stopped early status, empty SIC invalid-input)

- Fix (N2): `parseAdvancedSearchErrors` now strips GOV.UK visually-hidden `<span>Error:</span>` prefixes before taking text, so errors\[] and the status message quote "Enter a valid SIC code" instead of "Enter a valid SIC code; Error:". Fixture: `test/fixtures/advanced_search_sic_error_live.html`, a byte-for-byte copy of the live page fetched 2026-11-11 15:35:26 SGT (`GET /advanced-search/get-results?sicCodes=10710+47240&status=active`, HTTP 200, `/workspace/qa/polish-final-uk/7c9dc3b/live/p9.html`). The earlier evidence directory `/workspace/apify-team/evidence/uk-ch-advanced-search/` has no validation-error page. Red: redlogs/66-n2-n4-n5.red.log; mutation: redlogs/66-mut-keep-error-prefix.log.
- Fix (N4): when `OUTPUT.failed` is true after company rows were written (platform SUCCEEDED), `buildStatusMessage` now says `Stopped early (errors) after N companies: …` and no longer says `Run failed`. The 0-row Failed wording `Run failed (…)` is unchanged. Mutation: redlogs/66-mut-status-run-failed.log.
- Fix (N5): `hasAdvancedFilters` uses `sicCodeList` (the split list), not `arr(raw.sicCodes)`. A `sicCodes` value that is only commas or whitespace (empty after the split) is rejected as `invalid-input` on the same path as other input checks, with 0 rows, no charge and no run-notice. Mutation: redlogs/66-mut-sic-punct-ok.log. Price and event names were not changed.

### Unreleased (linear fix: search page normalisation, SIC split, form-error platform status)

- Fix: a `/search/companies` start URL with an illegal `page` (non-integer, <1, empty, or a decimal such as `2.5`) now actually requests page 1. The previous code warned and set the internal page to 1, but still requested the pasted URL with the illegal `page` value. A valid `page=2` is unchanged. An omitted page is still page 1 with no warning; a present-but-empty `page=` is treated as illegal (warning + start at page 1), same as get-results. Red: redlogs/65-linear-fix.red.log; mutation: redlogs/65-mut-raw-search-page.log, redlogs/65-mut-empty-page-valid.log.
- Fix: a single `sicCodes` entry that contains spaces or commas (for example `"62020, 62090"` or `"62020 62090"`) is split into separate codes, trimmed, emptied and deduplicated, then searched one code at a time. `arr()` is unchanged, so company names and registered office addresses are not split. Mutation: redlogs/65-mut-sic-no-split.log.
- Fix (platform status): a Companies House form-validation stop after rows were already written now finishes as platform SUCCEEDED. `OUTPUT.failed` stays true, `stopReason` is `errors`, already written rows stay charged, and a run-notice is still pushed. The entry point no longer calls `Actor.fail` in that case (`shouldActorFail` is true only when `failed` and no company row was written). 0 rows plus a site error is still Failed. Chosen because this repo's other post-row stops (blocked-\*) already end SUCCEEDED via `finish()` without `Actor.fail`, and the team rule is "rows then a site error → SUCCEEDED, OUTPUT.failed=true" (same as Mudah/DBA). Mutation: redlogs/65-mut-actor-fail-always.log. Price and event names were not changed.

### Unreleased (final-acceptance rework: multi-SIC, start page, trailing slashes)

- Fix (P1, blocking): multiple `sicCodes` are no longer sent space-separated in one Companies House advanced search (that returns a form-error page and was treated as no-results). Each code is searched separately; results are merged and deduplicated by `companyNumber`; only unique written rows are charged (`result-row` event name and price unchanged). Red: redlogs/64-final-rework.red.log; mutation: redlogs/64-mut-sic-join.log.
- Fix (P1): an advanced-search results page with a GOV.UK `govuk-error-summary` (for example "Enter a valid SIC code") is no longer treated as no-results. The run stops with `stopReason` `errors` (Failed when 0 rows have been written), the original Companies House text is in `errors[]`, and a run-notice is still pushed. Chosen over `invalid-input` because the rejection is discovered after a site request; `invalid-input` is reserved for pre-request `normalizeInput` failures and skips the run-notice. Mutation: redlogs/64-mut-no-form-errors.log.
- Fix (P2, must-fix before ship): the start-URL `page=N` parameter is coerced to an integer >= 1. A non-integer or value < 1 (for example `page=2.5` or `page=-1`) starts at page 1, writes a warning, and cannot loop on page 1 until the run timeout. A valid `page=2` still starts at page 2. Red tests in test/final-rework.test.js; mutations: redlogs/64-mut-ignore-page-n.log, redlogs/64-mut-start-page-number.log.
- Fix (P4): trailing slashes on supported start URLs (`/advanced-search/get-results/`, `/search/companies/`, `/company/{n}/`, `/advanced-search/`) are accepted and the path is normalized (slash stripped). `/advanced-search/` is the form page (`errors` / Failed if it is the only input), not `invalid-input`. Mutation: redlogs/64-mut-no-slash-normalize.log.
- Fix (P5): the unsupported-form-URL status message no longer ends with a double period. Mutation: redlogs/64-mut-double-period.log.
- Not done: `newestFirst` — the offline evidence at /workspace/apify-team/evidence/uk-ch-advanced-search/ (form fetched 2026-11-11 14:47 SGT, results pages 14:48 SGT) has no public sort/order/newest URL parameter (form fields are name, address, dates, status, sicCodes, type, subtype; pagination is `page=N` only). Charges summary and postcode split were out of scope. Price and event names were not changed.

### Unreleased (advanced-search result start URLs; drop SCHEMA_PENDING comments)

- Fix: a pasted `/advanced-search/get-results?…` start URL is now crawled. The original query string is kept, later pages use `page=N` (20 results per page), and parsing, charging, block stops and incremental skipping are the existing advanced-search path — no extra API requests. A bare `/advanced-search` form page (and any other accepted-but-unusable start URL) is no longer dropped silently: a warning is logged and an `errors[]` entry explains that this URL type is not crawled. If every start URL is unusable and there is no other input (no search queries, company numbers or advanced filters), the run fails with 0 rows and `stopReason` `errors`, and nothing is charged (the existing 0-row + errors path, not `invalid-input`, because the URL is still valid input). Red: redlogs/63-advanced-start-urls.red.log; mutations: 63-mut-get-results-dropped.log, 63-mut-no-page-param.log, 63-mut-form-url-silent.log, 63-mut-schema-pending-left.log.
- Chore: removed the five leftover `// SCHEMA_PENDING` comments in src (schemas were already updated in bfa99c9).

### Unreleased (incremental mode, enrichmentIncomplete, current-name lists)

- Feature: incremental mode. New inputs `onlyNew` (default false) and `stateKey` (default `companies-house-seen`). A named key-value store record `seenCompanyNumbers` holds company numbers that were charged and successfully written. With `onlyNew` off the seen set is not loaded, each written row has `isNew: null`, and `OUTPUT.alreadySeenSkipped` is 0. With `onlyNew` on, already-seen companies are skipped at the list stage (no company or subpage request, not charged, not written) and counted in `alreadySeenSkipped` (not mixed into any duplicate count); written rows have `isNew: true`. A blocked or unwritten row is not recorded as seen. An enrichment-blocked row that was charged and written is recorded. Red: redlogs/62-incremental-enrichment-names.red.log; mutations: 62-mut-isNew-always-true.log, 62-mut-skip-still-fetches-seen.log.
- Feature: new dataset field `enrichmentIncomplete`. When a subpage (officers, PSC, charges or filing history) is blocked after a successful overview, the company row is still charged and written first (unchanged) and `enrichmentIncomplete` is true so the buyer can see that subpage data is incomplete; the run then stops. Normal rows are `false`. Mutation: redlogs/62-mut-enrichmentIncomplete-never.log.
- Change (these name columns were added this round and are not live yet, so the rule can be tightened): `directorNames` lists only serving directors (resigned directors are omitted). `pscNames` lists only current PSCs when the page marks one as ceased. New add-only PSC fields `ceasedOn`, `status` and `statusRaw` make that filter possible. Mutation: redlogs/62-mut-directornames-include-resigned.log.
- Schema sync pending (`SCHEMA_PENDING` comments in src): input `onlyNew` / `stateKey` (input.js:88); dataset `isNew` boolean|null (main.js:419), `enrichmentIncomplete` (main.js:376), PSC `ceasedOn`/`status`/`statusRaw` (parser.js:287); OUTPUT/KV `alreadySeenSkipped` (main.js:114). Unchanged: a run-notice is pushed at every finish except invalid input; a numeric block is `blocked-<n>` and a login redirect with no status is `blocked-login-redirect`; 5xx still backs off 30s then 60s. Charges-register summary paging was not added.
- Chore: deleted the untracked, unreferenced leftover `test/fixtures/advanced_search_sic62012_p1_slim.html` so the freeze tree is clean.

### Unreleased (review e25494c / throughput report 2026-11-01)

- Docs (review 6f029cf N4): the README pricing comparison now includes lexis-solutions/companies-house-uk-scraper (169 users): `apify-default-dataset-item` $0.011 (Free tier) + `apify-actor-start` $0.005 per GB = $11.005 per 1,000 rows. The price was read from the public Apify Store API on 2026-11-01 and the raw response is saved as redlogs/pricing-20261101/lexis-solutions_companies-house-uk-scraper.json. The test checks the link, the saved file, and that the quoted price matches it. Redlogs 57-pricing-lexis.
- Fix (review 6f029cf N2): the invalid `maxFilingHistoryPages` error now says "must be a whole number >= 0 (0 or anything above 10 is treated as 10)" instead of "an integer from 1 to 10". This matches the schema. Redlogs 56-input-error-n2.
- Docs (review 6f029cf N1): the 10-page BREAKING entry no longer says "1-10 (schema minimum 1, maximum 10)"; it now states the actual range (integer, minimum 0, no maximum). Redlogs 55-cl-n1-range.
- Fix (QA rescore 6f029cf): warnings were never written to the run log online. The entry passed `Actor.log || console`, but `Actor.log` is undefined in apify 3.7.2 and `console.warning` does not exist, so every `log.warning?.()` (filing clamp, robots notices, per-company errors, search-page errors, push retries) did nothing. main.js now imports `log` from apify and passes it to run(), which also uses it by default. The clamp entry below ("one log.warning is emitted") and README Pricing/Filing ("a warning is written to the run log") are now true. Tests use the real apify export: the clamp tests spy on the real `log.warning` with no injected logger, and a new test asserts that `log.warning` exists, `Actor.log` is undefined, and src/ never uses `Actor.log`. Redlogs 54-real-apify-log (red/green; .mut.log = old entry and console default restored, 3 tests red).
- Chore: commit the red log redlogs/53-pricing-comparison.red.log, which the previous commit references but left out.
- Docs: README Pricing now has a same-basis cost-per-1,000-rows comparison: ours $2.00 (draft price $0.002, may change) vs scrapesage/companies-house-scraper $4.00, parseforge/uk-companies-house-scraper $7.52 and logiover/uk-companies-house-bulk-scraper $1.50, all at Free-tier event prices read from the public Apify Store API on 2026-11-01. Raw responses are in redlogs/pricing-20261101/. A test checks the section and that each quoted price matches the saved response. Redlogs 53-pricing-comparison.
- Docs (review 5065ce6 N5): the raw filing-history page counts per company (32 sample companies, live 2026-11-01) are now in redlogs/filing-pages-per-company-20261101.tsv, linked from the README. A test recomputes 2.875 / 2.333 requests per company from it. Redlogs 52-filing-raw-data.
- Docs (review 5065ce6 N4): the mutation log for the 10-page cap is redlogs/44-filing-hard-cap-10.mut.log (an earlier report wrongly said mutation-logs/44). The interrupted partial red run, previously only in /tmp, is now in the repo as redlogs/44-filing-default-cap-10.partial-interrupted.log. Redlogs 51-cl-mut-path.
- Docs (review 5065ce6 N3): the `filing-history page cap N reached` error entry in OUTPUT `errors` was removed in 5065ce6. Hitting the cap now shows only as `filingHistoryTruncated: true` plus the clamp warning, so downstream code that matched that error text needs updating. No data fields changed. Redlogs 50-cl-error-removed.
- Docs (review 5065ce6 N2): removed the stale "default is now all pages" note from the 6b4e99d entry and pointed it to the 10-page cap. Redlogs 49-cl-stale-all-pages.
- Docs (review 5065ce6 N1): the 10-page filing cap entry is now marked **BREAKING**. Confirmed: default 10 pages. Redlogs 48-cl-breaking.
- Test (review ed8092f, non-blocking): with all four options on and a just-enough deadline (27 s), officers are not stopped early (97/97), and PSC and filing are still fetched. No code change. Red against a mutation that adds 1 to the reserve; mutations reserve+1, reserve\*2 and reserve+3 all go red. Redlogs 47-all-options-deadline (red = mutant run / green / mut).
- Fix (QA): when `maxFilingHistoryPages` is 0 or above 10 and gets clamped to 10, one log.warning is emitted and the same text is added to OUTPUT `warnings`. Tests also assert that a company with more than 10 pages (Tesco) still has filingHistoryTruncated true, and that no warning appears for unset or 1-10 values. Redlogs 46-filing-clamp-warning (red/green/mut).
- Fix (review 5065ce6 B1): input_schema `maxFilingHistoryPages` is now minimum 0 with no maximum (still an integer), so the platform accepts 0, 11 and 50 and the code treats them as 10, matching the docs. Old inputs with 0 still run. -1 and 1.5 are still rejected. The description says full history is not offered yet. A test validates the schema with ajv and checks that README states the same range. Redlogs 45-filing-cap-schema.
- **BREAKING** Change (group fallback; full paging went over the cost bar): filing history is hard-capped at 10 pages (250 filings) per company until a per-page charge is approved. `maxFilingHistoryPages` keeps default 10; the schema is an integer with minimum 0, no maximum (as fixed in review 5065ce6 B1; an earlier draft of this entry said 1-10). 0 ("unlimited") is no longer offered: 0 or anything above 10 is treated as 10; negatives and non-integers are rejected. FILING_MAX_PAGES is now 10, and the earlier 2000 runaway cap is gone. `filingHistoryTruncated` is true when more filings exist. README notes that full history is not offered yet (Tesco 335, BP 623 pages); the cost table is now ~$0.188 per 1,000 at the default cap on the 32-company sample (estimate). Redlogs: redlogs/44-filing-hard-cap-10.red.log, .green.log and redlogs/44-filing-hard-cap-10.mut.log (an interrupted partial red run is kept as redlogs/44-filing-default-cap-10.partial-interrupted.log).
- Chore (review 9bfe2b5 N5): moved aside (renamed, not deleted) the misleading redlogs/34-fixture-count-guard.green.log, which shows 1 fail (the red state at 5344adf), to 34-fixture-count-guard.actually-red-at-5344adf.log. The real green is green2.log. A new test checks that every *.green*.log ends with `# fail 0`. Redlogs 43-redlog-naming.
- Docs (review 9bfe2b5 N4 + filing pagination): README now covers 25 filings per page, one request (~2.35 s) per page, a 10-page company adding ~22 s, and the real sizes Tesco 335 / BP 623 pages. The filing cost table is labelled an estimate, not platform-verified: typical companies 2.333 requests (~$0.152 per 1,000); the full 32 sample with BP and Tesco ~32.2 requests (~$2.10 per 1,000, over the $0.267 bar), so cap 10 ~$0.188 and cap 1 ~$0.131. Documented that the per-company time check excludes extra pages. (Superseded by 5065ce6: filing history is now capped at 10 pages by default.) Redlogs 42-readme-filing-cost.
- Fix: raised the runaway cap FILING_MAX_PAGES from 500 to 2000. A live probe on 2026-11-01 found BP (00102498) really has 623 filing-history pages, so 500 would have wrongly truncated it. Redlogs 41-filing-cap-above-bp.
- Fix (review 9bfe2b5 N3): the officers page bound is now min(highest page link, ceil(officerCount/35)), with a hard cap OFFICERS_MAX_PAGES = 50 (a cap hit gives officersTruncated true plus an error). Filing history has a runaway cap FILING_MAX_PAGES = 500 (Tesco has 335). Tests cover a bogus ?page=60 link, both caps, the filing time limit (page 2 not requested) and a filing page-1 503. Redlogs 40-page-bounds.
- Fix (review 9bfe2b5 N2): officersTruncated now comes from whether paging stopped early (failed page or time limit), not from comparing officers.length with officerCount. When the page has no "N officers" text, officerCount used to fall back to page 1's 35, so a truncated list could be marked complete. officerCount now equals the officers actually fetched in that case (97, not 35). Redlogs 39-officers-stopped-early.
- Test (review 9bfe2b5 N1): a 503 on officers page 1 gives officersTruncated true, records the error, and requests no later pages. No code change. Red against mutation M12. Redlogs 38-officers-page1-503.
- Test (review 9bfe2b5 B1): the officers time-limit branch is now covered. Real BP pages with a 22 s deadline: officersTruncated true, a "skipped: run time limit" error, and no ?page=2 request. No code change. The test was red against mutations M6 (keep paging) and M6b (mark false). Redlogs 37-officers-timeout (red = M6 run / green / mut).
- Fix (round after 9bfe2b5): `includeFilingHistory` now follows `rel="next"` through every filing-history page (25 filings per page, one extra request per page, polite delay). New optional input `maxFilingHistoryPages` (integer, default 0 = unlimited). `filingHistoryTruncated` is now true only when the cap was hit, a page failed or time ran out. New OUTPUT counter `filingHistoryExtraPages`. Officers extra pages now reserve time for the company's remaining base requests, so the deadline margin holds. Default-mode request count is unchanged (tested). Fixtures: real Tesco filing pages 2-10 and 335 (its real last page). Redlogs 36-filing-pagination (red/green/mut).
- Docs (review b264fdb): re-measured cost per 1,000 companies after the officers pagination fix (model: 256 MB, ~2.35 s per request, $0.40 per compute unit, no proxy). Default: 1 request per company, unchanged, ~$0.065. `includeOfficers`: 2 -> ~2.125 requests per company on average (+0.125; 2 of 32 sample companies need extra pages), ~$0.131 -> ~$0.139. Both under the $0.267 bar. README throughput table and a new cost table updated. Redlogs 35-officers-cost-readme (red/green).
- Docs fix: commit 5344adf left the suite red (1 fail) because its own CHANGELOG line quoted the stale PSC count verbatim and the new guard caught it; reworded. Green: redlogs/34-fixture-count-guard.green2.log.
- Tests (review b264fdb): the fixture-count guard now also checks the numbers quoted in CHANGELOG (officers pages, occupation 0/N, PSC pages, charges evidence companies) against the fixture folders. It caught one stale number: the PSC natureOfControl entry quoted a PSC page count two lower than the folder holds; the test runs on all 33 (corrected). Redlogs 34-fixture-count-guard (red/green).
- Docs (review b264fdb): the date -> ISO `YYYY-MM-DD` change below is now marked **BREAKING** in this CHANGELOG and in the README (existing values changed format; acceptable because the Actor is unlisted). Redlogs 33-iso-breaking (red/green).
- Fix (review b264fdb, other lists): checked PSC, charges and filing history for the same first-page-only behaviour. Charges: already flagged by `chargesTruncated` (25 per page; 00002065 has 4 pages), unchanged. Filing history: only page 1 (most recent filings) is read, by design to keep cost flat; added row field `filingHistoryTruncated` (true when the page links to page 2; real Tesco page has 10 pages). PSC: none of the 33 saved real PSC pages is paginated; added row field `pscTruncated` (true if a page-2 link appears). Both null when the include option is off. No extra requests. Redlogs 32-list-truncation-flags (red/green/mut).
- Fix (review b264fdb completeness): `officers` only held the first officers page (35), because `enrich()` fetched `/officers` once and never followed `?page=N` (e.g. BP 00102498: 35 of 97; Tesco 00445790: 35 of 74). With `includeOfficers` on, every page is now fetched with the client's normal delay. Added row field `officersTruncated` (false when complete; true when a failed page or the run time limit left the list short; null when `includeOfficers` is off) and OUTPUT field `officersExtraPages`. Default mode request count is unchanged (test). New real fixtures `00102498_off_p2/p3.html`, `00445790_off_p2/p3.html` (fetched once, 2 s apart, 2026-11-01). Redlogs 31-officers-pagination (red/green/mut).
- Tests (review 1d0a8a4 nit): `test/wiring.test.js` R1 counter test renamed from "1 of 3" to "1 of 2" to match the 2 companies it passes. Name only; no assertion or behaviour change, so no red run.
- Docs (review 1d0a8a4 nit): officers fixture count corrected from 33 to 32 (the real number of `test/fixtures/qa-e25494c/*_off.html`) in README (`occupation` note) and in the two earlier CHANGELOG lines below; new README test checks the stated count against the fixtures. Redlogs 30-officers-count-doc (red/green).
- Evidence (review 02fbc21 non-blocking 1/2/4): the saved `/charges` pages for all 22 manifest companies (`test/fixtures/charges-signal/ch_*.html`) and `scripts/fetch-charges-evidence.mjs` are now committed. The script is serial, uses no login, defaults to a 1.2 s gap, and refuses any gap under 1 s. `test/charges-evidence.test.js` checks every manifest count against its saved page, and checks that the script keeps a gap of at least 1 s. The manifest `_source` no longer claims an unverifiable "1.2 s gap". The chargesCount wording now matches in README and CHANGELOG: chargesCount is null unless includeCharges is on; 0 when the company has no Charges tab. Redlogs 29-charges-evidence (red/green/mut).
- Tests (review 02fbc21 non-blocking 3): real Legal-person PSC fixture `qa-e25494c/04402220_psc.html` (Network Rail Limited; "Secretary Of State For Transport" with legal form/authority and no registration number). Fetched live once on 2026-11-01. A mutation removing the Legal-person branch now turns 2 tests red (redlogs/28-psc-legal-person.mut.log).
- Tests (review 02fbc21 B2): `test/wiring.test.js` covers the `chargesRequestsSkipped` counter, the R3 interval floor (`max(interval, avg)`), the R3 last-10 window, and the run-level row wiring of `chargesTruncated` and `resignationCount`. Each of those 5 mutations now turns 1 test red (redlogs/27-wiring.mut-\*.log). No code change.
- Fix (review 02fbc21 B1): `resignationCount` also reads the singular "N officers / 1 resignation" (was null for 6 of 32 real officers pages: 07420328, 11686984, 13391258, 14789912, 16197401, 16567994). Test checks all 32 officers fixtures against the page text. Redlogs 26-resignation-singular.
- New add-only fields (QA e25494c nice-to-have): `hasInsolvencyHistory` from the overview "Insolvency" tab (SC241685 true), and with `includeOfficers` `resignationCount` from "N officers / M resignations". Dataset schema and README updated. Redlogs 25-insolvency-resignations.
- **BREAKING** Change (QA e25494c issue 8; actor is unlisted, so values are converted directly instead of adding companion fields): all date fields are now ISO `YYYY-MM-DD` (`incorporatedOn`, `dissolvedOn`, `accountsNextDue`, `accountsMadeUpTo`, `lastAccountsMadeUpTo`, `confirmationStatementNextDue`, officer `appointedOn`/`resignedOn`, PSC `notifiedOn`, charge `createdOn`/`deliveredOn`, filing `date`). Before: "27 November 1947". `previousNames[].period` unchanged; unparseable text kept as written. Old parser test expectations and README samples updated. Redlogs 24-iso-dates.
- Fix (QA e25494c issue 7): `pscs[].kind` is filled ("Individual" / "Corporate entity" / "Legal person", derived from the fields the PSC page shows), and new add-only `pscs[].nationality`. Officer `occupation` stays null because no public officers list page in the sample shows it (0/32); README says so. Redlogs 23-psc-kind.
- New field `chargesTruncated` (QA e25494c issue 6, add-only): with `includeCharges`, true when `charges` lists fewer than `chargesCount` (the site shows 25 per page and only the first page is fetched; 00002065: 25 of 88). false when everything is listed or the request was skipped (no Charges tab); null without `includeCharges`. Dataset schema and README updated. Redlogs 22-charges-truncated.
- Test (QA e25494c issue 4): `hasCharges` from the overview "Charges" tab confirmed on QA pages 00445790 and 00002065 (tab, true), 00102498 and SC241685 (no tab, false), each matching its /charges page; 07420328 and 12783097 also true. Red = test run on e25494c parser. Redlogs 21-qa-charges-tab.
- Redlog fix: `redlogs/20-entities.mutation.log` regenerated; the version in f48a14d did not apply the mutation (it passed). Now mdash/hellip are removed from the entity table and 3/3 tests fail as expected.
- Fix (QA e25494c issue 5): HTML entities are decoded in every text field with one shared single-pass decoder (named entities such as `&mdash;`, `&hellip;`, `&pound;`, plus numeric ones); 16567994 `companyStatus` is now "Active — Active proposal to strike off". Test scans all parsed fields of the 32-company QA sample for leftover entities. Redlogs 20-entities.
- Fix (QA e25494c issue 3): "First accounts made up to" fills `accountsMadeUpTo` and "First statement date … due by" fills `confirmationStatementNextDue` (both were null for new companies, e.g. 16303163, 17542753, 17144059). Redlogs 19-first-accounts.
- Fix (QA e25494c issue 2): `dissolvedOn` is read from "Dissolved on" (`id=cessation-date`); it was null for all 8 dissolved companies in the QA sample (e.g. 13391258: 11 August 2026). Redlogs 18-dissolved-on.
- Fix (QA e25494c issue 1): `pscs[].natureOfControl` is read from the live `<dd id="psc-noc-…">` markup (was always \[]). Test on all 33 real PSC pages from the QA sample. Redlogs 17-psc-noc.
- README (review non-blocking): sample rows 16303163 and 04095977 mark `Active` as inferred (no status label on the search page) with a footnote. Redlogs 16-readme-inferred-active.
- Test (review non-blocking): entry point with no deadline (`deadlineFromEnv({})` = null) never stops for time; a search-page error ends that query's pagination and the next query still runs. Guards only, no code change; redlogs 15-entry-search-error (red = mutations).
- R5 docs: README section "How include options affect throughput" (default ~2.4 s/company, all includes ~11.6 s/company ≈ 307 companies in 3,600 s, measured locally 2026-11-01); README documents where `hasCharges`/`chargesCount` come from; sample row shows `hasCharges: true`; Limitations line no longer says "about 5 s". Redlogs 14-readme-throughput.
- R3: deadline estimate uses the measured time per request (rolling average of the last 10 requests incl. interval wait and retries, never below the interval) instead of the assumed 1 s, so a fully enabled run at ~2.4 s/request stops with the 20 s safety margin left to write OUTPUT. Redlogs 13-deadline-measured.
- R1: with `includeCharges` on, a company whose overview has no "Charges" tab no longer gets a /charges request; the row gets `charges: []`, `chargesCount: 0`, `hasCharges: false` (same values the page would give). If the tab list is unrecognised, /charges is still requested. New OUTPUT counter `chargesRequestsSkipped` (added field). Redlogs 12-skip-charges.
- Fix: `hasCharges` on overview-only rows now comes from the overview page's "Charges" tab (present => true, absent => false; null only if the tab list is missing). The old `company-mortgages` element exists only on /charges pages, so it was always null. chargesCount is null unless includeCharges is on; 0 when the company has no Charges tab. Validated on 23 live companies (19 with charges, 4 without); redlogs 11-charges-signal red/green/mutation.

### Unreleased (review ba2b021 fixes)

- README: "Full output example" now shows a real dataset row (officers, PSCs, charges, filing history) instead of the OUTPUT record; added a real sample table and an "Output fields" table (review blocker 1).
- A failing company (404/410/403/5xx) or search page is recorded in `OUTPUT.errors` and the batch continues; the run fails only with 0 rows and errors (review blocker 2).
- Deadline handling: reads `ACTOR_TIMEOUT_AT`, stops before the next company would overrun the timeout (requests x delay + 20 s safety), writes OUTPUT with `stopReason: "time-limit"` and a warning (review blocker 3).
- Numeric company numbers are zero-padded to 8 digits (`445790` -> `00445790`); removed dead variable in input.js (review non-blocking).
- Price set to $0.002 per company row in README and `pay_per_event.json` (review non-blocking).
- Mutation logs for blockers 2 and 3 in `mutation-logs/` (each mutation turns tests red).

### 0.1.0 (2026-11-01)

- First version: UK Companies House public HTML scraper (`find-and-update.company-information.service.gov.uk`).
- Inputs: `searchQueries`, `companyNumbers`, `startUrls`, `maxItems` (default 50, hard cap 1000), opt-in officers/PSC/charges/filing history, `requestDelaySecs` (default 1).
- PPE event `result-row`; OUTPUT summary (`rowsPushed`, `pagesFetched`, `stopReason`, `robotsDisallowedHits`, `errors`); `buildStatusMessage` + `Actor.setStatusMessage`.
- robots.txt HTTP 404 treated as no rules; Disallow matches warn + count only; Crawl-delay honoured when present.
- Privacy: strip officer/PSC dates of birth and individual correspondence/home addresses; keep registered office.
- Fail paths: first-page 403/404/410/5xx with 0 rows → FAILED after OUTPUT; empty result → SUCCEEDED with 0 charge; errors after rows → SUCCEEDED partial.
- Live smoke sample saved to `docs/live-sample.json`.
