Why Àgora has no live results feed on election night
Àgora has no live results feed. There is no counter that moves while the votes are being counted, no push to the browser and no map that fills in province by province. The result is published as a file, once the provisional count is complete, and again when the final count is known. This post describes how that is built, from the code at commit ed8170d0 of the Àgora repo, and what the script refuses to accept.
It is a description of the design and the checks. It does not report what happened on the night or any figure from the count.
What was dropped, and what replaced it
The first plan for the site had a live feed. PLA-V2-LEGISLATURA.md (section 1) lists what was removed: a LiveHub, server-sent events, a key-value store, a poller of the Interior ministry, a cron job every minute, and a replay mode and a manual mode. It also removes the live municipality view, the live projection and the “rewind the night” feature, because all of them depended on the feed. The same table records that nothing of this was deployed yet, so no migration was needed.
Decision 8 of that document sets the consequence: the site is 100% static, served by Cloudflare Workers Assets with no script, no KV and no Durable Object. The document records the decision and the list of parts; it does not give a longer argument for it. What the code does show is what a static site can do on the night: it can serve whatever files were in the last deploy, and nothing else. The poll blackout post describes the other side of that: the same limitation is why the site has to be redeployed to go quiet.
So the result is a file in data/results/, read at build time: 2026-11-29-congreso-provincias.json is the one that turns on the final-result mode (docs/runbook-29n.md). The seat projection from polls, explained in From polls to seats, is a different thing and stays under the blackout rules until 21:00 on the 29th.
One script, two ways in
The file is produced by scripts/results/final.mjs, run as npm run results:final. It needs Node 22.18 or later because it imports src/lib/dhondt.ts directly. There are two inputs, and they cannot be combined: the script exits with a message if both are given.
--csv: a template with one row per province and candidacy, filled in by hand from the Interior ministry’s public results site. This is the reference route in the runbook. On the first row of each of the 52 provinces go the census, voters, null votes and blank votes; on every row, the votes and the seats. The delimiter, comma or semicolon, is detected, and the template can be regenerated with--template.--feed: one or more JSON documents from the Interior ministry viewer: the one for Spain, and optionally those of provinces that need fixing. A province document overrides the same province in the Spain one. The adapter (scripts/results/lib/interior.mjs) comes from the old live poller, and the runbook tells whoever runs it not to spend the night repairing it if the format has changed: fall back to the CSV.
A separate --senate-csv produces the Senate file. It is optional: without it the Senate section is hidden.
Both routes end in the same validation, so a number typed by hand and a number read from a feed are held to the same rules.
What makes it refuse
The validation runs before anything is written. scripts/results/lib/build.mjs collects every problem into a list, not just the first. For each province, these are errors:
- valid votes are not the sum of the candidacies’ votes plus blank votes;
- voters are not valid plus null votes;
- voters exceed the census, or there are no voters;
- the seats handed out do not add up to the province’s seats for 2026 in
data/circumscriptions.json; - a candidacy has a seat and zero votes;
- the residual bucket
otroshas a seat: a candidacy that wins a seat has to be mapped to a party indata/results/party-codes-2026.json; - a province code is unknown, or a province is missing;
- a value that should be a number is not.
If the list has any error, the script prints each one, says how many there are and exits with status 1. No file is written, for either chamber. The runbook states that this is intended: a file with errors cannot be forced through. A test in scripts/results/final.test.mjs runs the command line on a deliberately broken CSV and checks for exit status 1, the word ERROR in the output and no output folder. Another test checks that the blank template for the 29th fails validation and lists every missing item.
The D’Hondt check is a warning, on purpose
Seats are the one thing the script computes itself, with src/lib/dhondt.ts. It follows article 163 of the electoral law: only candidacies above 3% of valid votes, with blank votes counted as valid, share the seats by the quotients v/1, v/2, v/3 and so on. Ties go to the party with more votes and then to the lower id, which the file says is deterministic and not what the law does (the law draws lots).
The script then compares that result to the seats declared in the input. If they differ, it prints a warning with both numbers for each party that differs. It does not block. The warning text says to check against the Interior ministry: ties, coalitions and the 3% threshold are the usual reasons. The runbook says to look at each warning and, if the ministry says what the template says, go ahead. The official distribution wins, and the check only exists to catch a typo.
--compute-seats covers the case where seats are not available at all. If a province comes with no seats, the script fills them with D’Hondt and warns that it did. The runbook allows leaving the seats column empty only for a whole province, and only with that option.
Dry run, then deploy
--dry-run runs the whole validation and writes nothing. The runbook has two rehearsals with it: before the night, the 2023 example CSV must report “validated (0 warnings)”; on the night, the filled CSV is checked with --dry-run first and generated only when the errors are gone.
Writing the file is not publishing it. The sequence in the runbook is: generate the JSON, run scripts/data/verify-results.mjs for coherence with known figures, build, look at the preview (the hemicycle must add up to 350 and the totals must match the Interior’s), run the checks and the tests, deploy, and then scripts/ops/verify-site.mjs --expect open against production. The national total is the sum of the provinces, not a separate input.
One rule ties this to the blackout: the runbook forbids any build or deploy of the result before 21:00 on 29 November, because it would either put the poll silence back or lift it too early. A rollback to a version from before 24 November 00:00 is also forbidden until after that hour, since it would bring the polls back.
What this does not do
- No live view. Between the close of the polling stations and the deploy, the site shows what the last deploy contained. Anyone who wants the count as it comes in has to use the Interior ministry’s own site.
- Typing is manual on the main route. The CSV route depends on someone copying numbers from the ministry. The checks catch inconsistent totals and wrong seat counts. They cannot catch a mistake that keeps the totals consistent, for instance two parties’ votes swapped within a province.
- Municipalities are separate. This script does not produce the municipal map or “My vote” for the 29th. Those need the ministry’s DAT files and
scripts/data/infoelectoral.mjs(runbook, section 4). - A decision left open. At the commit we read, the runbook flags as pending where the 29 November result is shown, because the results page then displayed the latest past general election and publishing the JSON did not change it. Check the results page for what it shows now.
- Nothing here is an official source. The published file is a transcription of the provisional count, republished when the final count arrives. The ministry’s figures are the reference.