#!/usr/bin/env python3
"""Build repo/coverage.html + repo/COVERAGE.md — "which US states actually
publish WARN notices, and how deep does each archive go" (c341).
WHY THIS PAGE EXISTS (read before changing it)
----------------------------------------------
Every competitor in this market advertises a state count. layoffdata.com says
"50 states, 82,000+ notices"; we hold 59,806 across 48 jurisdictions. A buyer
comparing the two reads our 48 as "incomplete" and stops there. c341 went to
find the missing three and discovered they are not missing — THEY DO NOT EXIST:
* Arkansas — no public WARN list published by the state agency.
* New Hampshire — no posted list; notices are reported to be released only in
response to a public-records request.
* Wyoming — no public WARN list published by the state agency.
(Searched 2026-09-13. Secondary sources report AR and WY treat these filings as
confidential under state law. We did NOT independently read those statutes and
this page must not claim we did — see HONESTY RAILS.)
So the honest, checkable claim is not "48 states" but "every US jurisdiction
that publishes a public WARN list — 48 of 48 — plus a named, sourced account of
the three that publish none". That converts our weakest-looking number into the
thing a data buyer actually wants: someone who has already done the survey.
The second half of the page is the one no competitor publishes at all: WHERE
OUR ARCHIVE IS SHALLOW. Our California rows start in 2014 and our Texas rows in
2019 because that is how far back those portals go, not because the layoffs did
not happen. A buyer who finds that out after paying churns; a buyer who reads it
first and buys anyway is a buyer who trusts the rest of the file.
HONESTY RAILS
- Every number is computed at build time from repo/data/coverage.json and
repo/data/warn_notices.json. Nothing is typed by hand.
- "Archive starts" is the earliest NOTICE DATE WE HOLD for that state. It is a
fact about the source portal's depth and our scraping of it, never a claim
about when the state began requiring notices. The page says so in words.
- Undated rows are counted and shown, never silently dropped (c340 rule: a
derived page that filters rows states its denominator AND the archive total).
- No statutory citation appears on the page. We report what we could and could
not find, dated, and ask readers who know better to open an issue.
- No comparison claim about a competitor's coverage. We say what we hold.
Ordering: runs AFTER gen_site.py in publish.sh (gen_site rewrites index.html and
the sitemap; this appends to the sitemap and links itself from api.html).
Usage (cwd = product/):
python3 gen_coverage_page.py --selftest # offline, asserts the invariants
python3 gen_coverage_page.py # write repo/coverage.html + COVERAGE.md
"""
import collections
import html
import json
import os
import re
import sys
HERE = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, HERE)
import dataviz # noqa: E402
import page_write # noqa: E402
import sources # noqa: E402
import tiers # noqa: E402
from gen_multistate import EXTRA_CSS, STATE_NAMES # noqa: E402
from gen_site import PAGES_URL, REPO_URL # noqa: E402
from gen_weekly import CSS # noqa: E402
OUT_ROOT = os.path.join(HERE, "repo")
REPO = OUT_ROOT
URL = PAGES_URL + "coverage.html"
ISSUES = REPO_URL.rstrip("/") + "/issues"
README_ANCHOR = ""
HF_COVERAGE_DS = "https://huggingface.co/datasets/APProjects/which-us-states-publish-warn-act-layoff-notices-coverage"
# Jurisdictions with no public WARN list we could find. Each entry carries the
# date we looked and exactly what we found — never a legal conclusion.
EXTRA_NAMES = {"AR": "Arkansas", "NH": "New Hampshire", "WY": "Wyoming"}
def sname(st):
"""STATE_NAMES only covers the 48 jurisdictions we hold data for."""
return STATE_NAMES.get(st) or EXTRA_NAMES.get(st, st)
NO_PUBLIC_LIST = [
("AR", "Arkansas Division of Workforce Services",
"https://dws.arkansas.gov/",
"No public WARN notice list on the agency site. Secondary sources report "
"that Arkansas treats WARN filings as confidential under its employment-"
"security law; we have not read the statute ourselves."),
("NH", "New Hampshire Employment Security",
"https://www.nhes.nh.gov/",
"No posted list. Secondary sources report that New Hampshire releases WARN "
"notices only in response to a public-records request, which is not a "
"source a daily pipeline can read."),
("WY", "Wyoming Department of Workforce Services",
"https://dws.wyo.gov/",
"No public WARN notice list on the agency site. Secondary sources report "
"that Wyoming treats WARN filings as confidential under state law; we have "
"not read the statute ourselves."),
]
SEARCHED_ON = "2026-09-13"
# Territories: federal WARN reaches them, but none runs a public notice portal.
TERRITORIES = "Puerto Rico, Guam and the US Virgin Islands"
# ----------------------------------------------------------------- facts
def facts():
"""Everything the page says, computed from the published files."""
cov = json.load(open(os.path.join(REPO, "data", "coverage.json")))
rows = json.load(open(os.path.join(REPO, "data", "warn_notices.json")))
years = collections.defaultdict(list)
undated = collections.Counter()
for r in rows:
st = r.get("state") or ""
d = (r.get("notice_date") or "")[:10]
if len(d) >= 4 and d[:4].isdigit():
years[st].append(d)
else:
undated[st] += 1
src = sources.load().get("states", {})
out = []
for st, meta in cov.get("states", {}).items():
ds = sorted(years.get(st, []))
out.append({
"st": st,
"name": sname(st),
"rows": int(meta.get("rows") or 0),
"dated": len(ds),
"undated": undated.get(st, 0),
"first": ds[0][:4] if ds else "",
"latest": meta.get("latest_notice_date") or "",
"scraped": (meta.get("last_scraped") or "")[:10],
"status": meta.get("status") or "",
"agency": (src.get(st) or {}).get("agency", ""),
"url": (src.get(st) or {}).get("url", ""),
})
out.sort(key=lambda d: -d["rows"])
total = int(cov.get("total_rows") or 0)
dated_total = sum(d["dated"] for d in out)
first_year = min((d["first"] for d in out if d["first"]), default="")
return {
"cov": cov, "states": out, "total": total,
"dated": dated_total, "undated": total - dated_total,
"first_year": first_year,
"generated_at": cov.get("generated_at", ""),
"n_pub": len(out),
"n_none": len(NO_PUBLIC_LIST),
}
def shallow(sts, cutoff=2015):
"""States whose archive starts late — the honest depth disclosure."""
out = [d for d in sts if d["first"] and int(d["first"]) >= cutoff]
out.sort(key=lambda d: (-d["rows"]))
return out
# ----------------------------------------------------------------- html
def build():
f = facts()
sts = f["states"]
title = ("WARN notice coverage by state — which US states publish layoff "
"notices, and which do not")
desc = (f"All {f['n_pub']} US jurisdictions that publish a public WARN Act "
f"layoff-notice list, with {f['total']:,} notices, how far back each "
f"archive goes, and the {f['n_none']} states that publish none.")
kpis = dataviz.kpi_row([
(f"{f['n_pub']}", "jurisdictions published",
"every US agency we can find that posts a public WARN list"),
(f"{f['total']:,}", "notices held",
f"{f['dated']:,} carry a usable notice date"),
(f["first_year"] or "—", "earliest notice on record",
"depth is set by each portal, not by us"),
(f"{f['n_none']}", "states publish nothing",
"Arkansas, New Hampshire, Wyoming"),
])
kpi_fig = dataviz.figure(
kpis, "US WARN-notice coverage held by WARN Feed",
source="state workforce-agency portals",
asof=f["generated_at"][:10])
top = [d for d in sts if d["rows"] >= 800][:14]
bars = dataviz.figure(
dataviz.bar_chart([(d["name"], d["rows"]) for d in top], unit=" notices"),
"Largest state archives we hold",
source="WARN Feed archive", asof=f["generated_at"][:10])
trs = []
for d in sts:
agency = (f'{html.escape(d["agency"])}'
if d["url"] and d["agency"] else html.escape(d["agency"] or "—"))
und = f' {d["undated"]:,} undated' if d["undated"] else ""
trs.append(
f'
Which US states publish WARN layoff notices — and which publish none
The federal WARN Act makes large employers notify the state before a mass
layoff or plant closing. It does not make the state publish what it
receives. So the honest coverage question is not “how many of the 50
states do you have?” — it is how many publish at all, and how far
back each one goes.
We hold {f['total']:,} notices from all {f['n_pub']} US
jurisdictions that publish a public WARN list, rebuilt every morning.
{f['n_none']} states publish none, and they are named below with what we found
when we looked. The whole file is free under CC BY 4.0.
“Archive starts” is the earliest notice date we
hold for that state. It reflects how far back that agency's portal goes and
how deeply we read it — it is not a claim about when the state started requiring
notices. Rows with no usable date are counted separately and never dropped:
{f['dated']:,} of {f['total']:,} notices carry a usable notice date,
{f['undated']:,} do not. Generated {html.escape(f['generated_at'][:10])}.
{table}
{bars}
The {f['n_none']} states you cannot get, and why
We searched for a public notice list from each of these agencies on
{SEARCHED_ON} and found none. We are reporting what we could and could not find
— not a legal conclusion. If you know of a public source for any of them,
open an issue and it will be in the file the next
morning.
State
Agency
What we found
{none_rows}
{TERRITORIES} are covered by federal WARN but run no public
notice portal we could find, so they appear in no dataset, ours or anyone
else's.
Where our archive is shallow — read this before you buy anything
Several large states publish only a recent window. Our California rows start
in {next((d['first'] for d in sts if d['st'] == 'CA'), '—')} and our Texas rows
in {next((d['first'] for d in sts if d['st'] == 'TX'), '—')} because that is how
far back those portals reach, not because nothing happened before. Any dataset
built from these portals has the same floor, whether or not it tells you. Ours
tells you:
State
Archive starts
Notices
{sh_rows}
Where a state's portal drops its own history, we keep what we already
scraped: {f['cov'].get('archive_only_rows', 0):,} notices in our file no longer
appear on the agency site at all. That is the part of this job that only gets
done if somebody is reading every portal every day.
How to check any of this
Every number above is computed from the published files at build time, and
you can recompute it yourself:
coverage.json holds the per-state row counts,
scrape times and freshness; this table is one CSV row per jurisdiction at
warn_coverage_by_state.csv (also
on Hugging Face); the free HTTP API serves the
whole archive as JSON, NDJSON and per-state CSV with no key and no login. If a
number here disagrees with the file, the file is right and it is a bug —
tell us.
"""
return page, f
# ----------------------------------------------------------------- markdown twin
def markdown():
f = facts()
sts = f["states"]
base = _served_base()
lines = [
"# WARN notice coverage by state",
"",
"Which US jurisdictions publish a public WARN Act layoff-notice list, "
"which publish none, and how far back each archive goes.",
"",
f"**{f['total']:,} notices · {f['n_pub']} publishing jurisdictions · "
f"earliest {f['first_year']} · rebuilt daily · CC BY 4.0**",
"",
f"Full page with charts: <{base}/coverage.html> · "
f"free API: <{base}/api.html>",
"",
f"This table as one CSV row per jurisdiction (51 rows, incl. the three "
f"non-publishers): [warn_coverage_by_state.csv]({base}/data/warn_coverage_by_state.csv) · "
f"[Hugging Face dataset]({HF_COVERAGE_DS})",
"",
"## States that publish no WARN list",
"",
f"Searched {SEARCHED_ON}; no public notice list found from these "
"agencies. This reports what we found, not a legal conclusion. Know a "
f"public source? [Open an issue]({ISSUES}).",
"",
"| State | Agency | What we found |",
"| --- | --- | --- |",
]
for st, agency, url, note in NO_PUBLIC_LIST:
lines.append(f"| {sname(st)} | [{agency}]({url}) | "
+ re.sub(r"\s+", " ", note) + " |")
lines += [
"",
f"{TERRITORIES} are covered by federal WARN but run no public notice "
"portal we could find.",
"",
"## Every jurisdiction we publish",
"",
"`Archive starts` is the earliest notice date **we hold** — a fact "
"about the portal's depth and our reading of it, not about when the "
f"state began requiring notices. {f['dated']:,} of {f['total']:,} "
f"notices carry a usable notice date; {f['undated']:,} do not.",
"",
"| Jurisdiction | Notices | Archive starts | Latest notice | Source |",
"| --- | ---: | ---: | ---: | --- |",
]
for d in sts:
src = f"[{d['agency']}]({d['url']})" if d["url"] and d["agency"] else (d["agency"] or "—")
lines.append(f"| {d['name']} ({d['st']}) | {d['rows']:,} | "
f"{d['first'] or '—'} | {d['latest'] or '—'} | {src} |")
lines += [
"",
"## Where the archive is shallow",
"",
"Large states that publish only a recent window. Any dataset built from "
"these portals has the same floor, whether or not it says so.",
"",
"| State | Archive starts | Notices |",
"| --- | ---: | ---: |",
]
for d in shallow(sts):
lines.append(f"| {d['name']} | {d['first']} | {d['rows']:,} |")
lines += [
"",
f"Where a portal drops its own history we keep what we already scraped: "
f"{f['cov'].get('archive_only_rows', 0):,} notices in our file no longer "
"appear on the agency site at all.",
"",
f"Generated {f['generated_at'][:10]} from the published files. "
f"Recompute from [coverage.json]({base}/data/coverage.json).",
"",
]
return "\n".join(lines)
def _served_base():
import repo_host_fix
return repo_host_fix.NEW.rstrip("/")
def inject_readme(path):
line = (f"- [Coverage by state]({_served_base()}/coverage.html) — which "
f"states publish a WARN list, which publish none, and how far back "
f"each archive goes. {README_ANCHOR}")
try:
txt = open(path, encoding="utf-8").read()
except FileNotFoundError:
return False
out = [ln for ln in txt.split("\n") if README_ANCHOR not in ln]
for i, ln in enumerate(out):
if "" in ln:
out.insert(i + 1, line)
break
else:
out.append(line)
new = "\n".join(out)
if new != txt:
open(path, "w", encoding="utf-8").write(new)
return True
def link_from_api_page():
"""api.html is the developer front door and has no byte budget problem
(index.html does — see gen_api_page.write). Idempotent."""
p = os.path.join(OUT_ROOT, "api.html")
if not os.path.exists(p):
return False
txt = open(p, encoding="utf-8").read()
if 'href="coverage.html"' in txt:
return False
needle = ''
link = 'coverage by state · '
if needle in txt:
txt = txt.replace(needle, link + needle, 1)
open(p, "w", encoding="utf-8").write(txt)
print("coverage: linked from api.html")
return True
print("WARN coverage: no anchor found in api.html — page unlinked there")
return False
def write():
page, f = build()
os.makedirs(OUT_ROOT, exist_ok=True)
path = os.path.join(OUT_ROOT, "coverage.html")
changed = page_write.write_page(path, page, site=OUT_ROOT)
sm = os.path.join(OUT_ROOT, "sitemap.xml")
keep = []
if os.path.exists(sm):
keep = [u for u in re.findall(r"(.*?)", open(sm).read()) if u != URL]
urls = keep + [URL]
open(sm, "w").write(
'\n'
'\n'
+ "\n".join(f"{u}" for u in urls) + "\n\n")
md = markdown()
md_p = os.path.join(OUT_ROOT, "COVERAGE.md")
if not os.path.exists(md_p) or open(md_p, encoding="utf-8").read() != md:
open(md_p, "w", encoding="utf-8").write(md)
print(f"coverage: wrote COVERAGE.md ({len(md):,} B)")
inject_readme(os.path.join(OUT_ROOT, "README.md"))
link_from_api_page()
print(f"coverage: wrote coverage.html ({len(page):,} B, changed={changed}) — "
f"{f['n_pub']} publishing jurisdictions, {f['n_none']} without a list, "
f"{f['total']:,} notices; sitemap now {len(urls):,} urls")
def selftest():
page, f = build()
assert f["n_pub"] >= 45, f["n_pub"]
assert f["total"] > 50000, f["total"]
# the count-honesty rule (c340): denominator AND archive total together
assert f"{f['dated']:,} of {f['total']:,} notices" in page
# every publishing jurisdiction appears exactly once in the big table
for d in f["states"]:
assert f'>{html.escape(d["name"])}' in page, d["st"]
# the three non-publishers are named, and none of them is in the data
codes = {d["st"] for d in f["states"]}
for st, agency, url, note in NO_PUBLIC_LIST:
assert st not in codes, f"{st} has rows but is listed as non-publishing"
assert sname(st) in page
assert url in page
# no statutory citation may appear (HONESTY RAILS)
assert not re.search(r"§|Ark\. Code|Wyo\. Stat", page), "statute cited"
# ship floor
assert "@media" in page, "no responsive breakpoint"
assert 'class="btn"' in page or "