Skip to content

fix(pipeline): report a link only once it has answered the same way twice - #5

Merged
clay-good merged 1 commit into
mainfrom
fix/link-check-noise
Nov 15, 2026
Merged

clay-good merged 1 commit into
mainfrom
fix/link-check-noise

Conversation

@clay-good

Copy link
Copy Markdown
Owner

Status: LGTM — ready to merge. Towards #1 (the four links that really moved are updated in a separate PR).

What was wrong

The weekly link check opened #1 listing 47 links: 24 blocked, 18 moved, 5 broken. I checked every one by hand on 2026-11-14. Four needed anything.

Not one of the five "broken" links was dead:

Link Reported Actually
psc.ms.gov HTTP 500 200 — a moment's trouble
ctsportal.psc.ms.gov/portal/document-search HTTP 0 200 — same
psc.mt.gov HTTP 0 200 — same
psc.mt.gov/Documents-Proceedings/Public-Participation HTTP 0 200 — same
puco.ohio.gov HTTP 404 200 to a browser, 404 to our user-agent — a bot wall

Of the eighteen "moved", four had really moved. The other fourteen were artifacts:

  • Nine were a bot wall, not a move: eight eCFR and Federal Register links redirected to unblock.federalregister.gov, and Minnesota's PUC to a ShieldSquare challenge at validate.perfdrive.com. Following those would have stored a URL that cites nothing.
  • Two dockets (Wyoming's dms.wyo.gov, Montana's reddi.mt.gov) mint a fresh session id per visit, so they "moved" every single week to an address that expires before anyone could use it.
  • Two DOIs were doing exactly their job.
  • The PUDL README only looked moved because fetch drops the #licensing fragment from res.url, so the comparison on the old line 73 never matched.

A report where 4 of 47 lines are actionable does not get read, which is the real cost. But this reaches further than the issue: core/lib/ledger.mjs publishes every link in state broken as a dead citation on the limits page. So Mississippi's and Montana's momentary network trouble, and Ohio's bot wall, were being published to the public as cited sources that no longer resolve. That is a correctness bug on a public page, not just inbox noise.

How it was fixed

Each cause is now judged on what it actually means.

1. A first bad answer is held back. A result still records honestly what this check saw — the health record does not lie. But a link is reported, and published as a dead citation, only once the previous check saw the same thing. A new since field says how long the answer has held, and the issue body now reads unchanged since <date>.

This one rule also settles the session-URL dockets: a redirect counts as "the same answer" only if it points to the same target as last time, so an address that changes every visit never confirms.

2. A redirect onto an interstitial is a refusal, not a move. unblock.federalregister.gov and validate.perfdrive.com now classify as blocked — a state the project already defines as "a person checks this by hand." That is 9 of the 18.

3. A DOI that resolves is working. Resolving is a DOI's entire job. Storing where it pointed today would trade a permanent citation for a perishable one, so doi.org and dx.doi.org are ok when they resolve — and still broken when they don't.

4. The fragment is ours, not the server's. Comparison now ignores it, alongside the trailing slash it already ignored.

Classification moved into an exported classify() so it can be tested directly instead of through a live fetch.

The 24 blocked links are deliberately unaffected. They are real 403s, and the project means a person to check them by hand. That was a design decision, not a bug.

Proof it works

verify/tests/pipeline/automation.test.mjs — 16 tests, all passing. Six are new or rewritten, each pinning one of the false positives above against the real URL that produced it:

  • a link that fails once and works again is never called broken in public — asserts buildLedger(...).deadLinks is empty on the first failure. This is the Mississippi/Montana bug.
  • a page that stays broken is confirmed, reported, and published — the other half: a real dead link still reaches both the issue and the limits page, one week later.
  • a docket that hands out a fresh session URL every visit has not moved — uses the real dms.wyo.gov URL from the data.
  • an interstitial is the refusal of an automated check — the real eCFR and Minnesota URLs.
  • a DOI that resolves is working — both DOIs from the issue, plus a 404 DOI to confirm a dead one is still caught.
  • the fragment is ours — the real PUDL README URL.

The existing moved-handoff test was extended rather than replaced: it now asserts nothing is reported on the first sighting and everything is on the second.

verify/tests/{core,site,mcp} ledger, limits, and protocol suites: 32/32 passing — the published contract is unchanged (consumers project only url/status/lastOk/usedBy/archive, so the new since/confirmed fields stay internal). Full unit suite passes.

Notes / nits

  • One-week quiet period on merge. Existing records have no previous answer to agree with, so the first run after this ships confirms nothing and the limits page shows no dead links for that week. The run after it behaves normally. Called out in the commit message too.
  • Ohio is not fixed by this. puco.ohio.gov returns a persistent 404 to our user-agent, so it will confirm and be reported as broken — and published as a dead citation, which it is not. It is genuinely indistinguishable from a dead page without trying a second user-agent, which I did not want to do quietly. Worth a follow-up decision: either retry a confirmed-broken link once with a browser user-agent, or record the state sites known to wall us off.
  • INTERSTITIALS is a two-entry list, not a pattern. It will need an entry when another publisher adopts a different wall. I judged a named list more honest than guessing at a heuristic.

🤖 Generated with Claude Code

…wice

The weekly link check opened an issue listing 47 links: 24 blocked, 18
moved, 5 broken. Checked by hand on 2026-11-14, four of them needed
anything. Not one of the five "broken" links was dead: Mississippi and
Montana answered 200 again, and puco.ohio.gov answers 404 to our
user-agent and 200 to a browser. Of the eighteen "moved", four had
really moved.

This matters beyond the issue. The limits page publishes every link in
state "broken" as a dead citation, so a moment's network trouble named a
live source dead in public.

Four things made the noise, and each is now judged on what it means:

- A first bad answer is held back. A result still records honestly what
  the check saw, but it is reported, and published as a dead citation,
  only once the previous check saw the same thing, with `since` saying
  how long it has held. This also settles dockets that mint a fresh
  session URL every visit (Wyoming's, Montana's, two of the eighteen),
  which "moved" weekly to an address that expires before anyone could
  use it.
- A redirect onto an interstitial is the refusal of an automated check,
  not a move: eCFR and the Federal Register send one to
  unblock.federalregister.gov and Minnesota's PUC to a ShieldSquare
  challenge. Nine of the eighteen were this. They now read "blocked",
  which already means "a person checks this by hand".
- A DOI that resolves is working, which covers two more. Resolving is
  its whole job, and storing where it pointed today would trade a
  permanent citation for a perishable one.
- The fragment is ours, not the server's, and `fetch` drops it, so
  #licensing alone made the PUDL README look moved every week.

The 24 blocked links are unaffected: they are real refusals, and the
project means a person to check them by hand.

The first run after this ships confirms nothing, as there is no previous
answer to agree with; the run after it reports as usual.

Towards #1; the four links that really moved are updated separately.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@clay-good
clay-good force-pushed the fix/link-check-noise branch from 1de8b42 to bfe9c28 Compare November 14, 2026 18:16
@clay-good
clay-good merged commit 4ec1475 into main Nov 15, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant