"""Study: company pensions that report funding at the 80% line, plan year 2025 (PRD 5.139). Writes the frozen files. Reads the Labor Department's Form 5500 datasets ("Latest" versions) and nothing else: F_SCH_SB, F_SCH_R and F_5500 for the form years 2021-2025. No Attovar database is needed. The rule (set 2026-11-10, after an outside audit of a draft; the draft counted 116 plans with a simpler subtraction and grouped filings by form year): - A plan record is one sponsor EIN and plan number. One filing per plan record and plan-year start date: the latest acknowledgement ID. A plan year belongs to the calendar year it begins in, whatever form it was filed on; when a plan record has two plan years beginning in one calendar year, the later one counts. - Large: Schedule SB reports 100 or more total participants. - AFTAP is Schedule SB line 15, FTAP is line 14. A blank or zero line 15 is "not reported" and sits in no band. - Assets to target: actuarial value of assets (line 2b) over the funding target (line 3d). - Year to year: plan records that were large in plan year 2024 and reported an AFTAP for 2024 and 2025. - Credit reductions: flag every large plan that reported a reduction (line 12), an AFTAP of 80 or more, and an AFTAP under 80 once the reduction over the funding target is subtracted. Rebuild each flagged AFTAP as (assets - credit at the start of the year, line 13 + annuity purchases) / (target + annuity purchases), with no credit subtracted when assets are at least the target (26 U.S.C. 436(j)(3)). Tiers: A rebuilt within 0.5 from the schedule alone, and under 80 before the reduction; B1 rebuilt with the annuity purchase the actuary states in the filing's line 15 attachment (ANNUITY below); B2 the filing's financial statements show an annuity purchase but not the amount that counts; the amount is solved from line 15, so the rebuild matches by construction; C assets at least the target: the reduction did not change the AFTAP; D none of the above. "Needed" is the part of the reduction that reaching 80 accounts for. Credit used in the year is line 35. - Added 2026-11-11 (PRD 5.140), for readers with a pension. Status, from the reported AFTAP alone: "none" under 60 (lump sums generally not allowed), "partial" 60 to under 80, "watch" 80 to under 90 (the band where the law presumes 10 points lower if the next certification is late, 26 CFR 1.436-1(h)), "clear" 90 or more. Single sums paid: Schedule R line 3 of the same filing (participants whose benefits were paid in a single sum that plan year; it includes small automatic cashouts); blank when the filing has no Schedule R. Usage: python -I tools/line80_study.py ZIP_DIR OUT_DIR """ from __future__ import annotations import csv import glob import hashlib import io import json import os import re import shutil import statistics import sys import zipfile from collections import defaultdict PY = 2025 YEARS = (2022, 2023, 2024, 2025) LARGE = 100 LINE = 80.0 AT_LINE = 80.1 # "at the line": 80.00 to 80.09 TOLERANCE = 0.5 NEAR_ROWS = 15 # the lookup lists every plan under 80 and the largest at 80 to under 90 STATUS = (("none", 0, 60), ("partial", 60, 80), ("watch", 80, 90), ("clear", 90, 1e9)) DATA_RELEASE = "dol-latest-2026-11-10" # the DOL "Latest" datasets, downloaded 2026-11-10 (hashes in summary.json) SB_NUM = {"participants": "SB_TOT_PARTCP_CNT", "former": "SB_TERM_PARTCP_CNT", "ftap": "SB_FNDNG_TGT_PRCNT", "aftap": "SB_ADJ_FNDNG_TGT_PRCNT", "target": "SB_TOT_FNDNG_TGT_AMT", "assets": "SB_ACTRL_VALUE_AST_AMT", "red_a": "SB_CARRYOVER_REDUCTION_AMT", "red_b": "SB_PRE_FNDNG_REDUCTION_AMT", "boy_a": "SB_CARRYOVER_BOY_TOT_AMT", "boy_b": "SB_PRE_FNDNG_BOY_TOT_AMT", "use_a": "SB_OFFSET_CARRYOVER_AMT", "use_b": "SB_OFFSET_PRE_FNDNG_AMT"} # Annuity purchases added to both sides of the AFTAP, read from each filing's public PDF (acknowledgement ID -> amount # for non-highly-compensated employees, or None when the filing shows a purchase but not that amount). ANNUITY = { "20261014125634NAL0007034544001": 1132552449.0, # 3M: line 15 attachment "20261014101040NAL0006252098001": 683034000.0, # FirstEnergy: line 15 attachment "20261008230730NAL0037742146001": None, # Union Carbide: financial statement note, December 2023 "20261015145603NAL0009173938001": None, # Lanxess: financial statement note, December 2024 "20261013141805NAL0004030385001": None, # White & Case: financial statement note, May 2024 } TIERS = {"A": "Rebuilt from the schedule's own lines", "B1": "Annuity purchase stated by the actuary in the filing", "B2": "Annuity purchase in the filing's financial statements; amount inferred", "C": "Assets at or above the target: the reduction did not change the percentage", "D": "Unresolved"} def csv_rows(path: str): zf = zipfile.ZipFile(path) name = next(n for n in zf.namelist() if n.lower().endswith(".csv")) rd = csv.reader(io.TextIOWrapper(zf.open(name), encoding="latin-1", newline="")) head = [h.strip().upper() for h in next(rd)] for row in rd: yield dict(zip(head, row)) def num(x: str | None) -> float | None: try: return float(x) if x and x.strip() else None except ValueError: return None def sha256(path: str) -> str: h = hashlib.sha256() with open(path, "rb") as fh: for block in iter(lambda: fh.read(1 << 20), b""): h.update(block) return h.hexdigest() def load(zdir: str) -> dict: """(EIN, PN, plan year) -> the filing that counts, with its Schedule SB facts.""" by_period: dict = {} for z in sorted(glob.glob(os.path.join(zdir, "F_SCH_SB_20*_Latest.zip"))): fy = int(re.search(r"F_SCH_SB_(\d{4})_", os.path.basename(z)).group(1)) for r in csv_rows(z): begin = (r.get("SB_PLAN_YEAR_BEGIN_DATE") or "").strip() k = (r["SB_EIN"], r["SB_PN"], begin) if k not in by_period or r["ACK_ID"] > by_period[k]["ack"]: rec = {name: num(r.get(col)) for name, col in SB_NUM.items()} rec.update(ack=r["ACK_ID"], ein=r["SB_EIN"], pn=r["SB_PN"], begin=begin, form_year=fy) by_period[k] = rec out: dict = {} for (ein, pn, begin), rec in by_period.items(): if not begin[:4].isdigit(): continue k = (ein, pn, int(begin[:4])) if k not in out or (begin, rec["ack"]) > (out[k]["begin"], out[k]["ack"]): out[k] = rec for rec in out.values(): z = lambda v: v or 0.0 # noqa: E731 a = rec["aftap"] rec["status"] = "blank" if a is None else "zero" if a == 0 else "reported" rec["a"] = a if rec["status"] == "reported" else None rec["large"] = (rec["participants"] or 0) >= LARGE rec["reduced"] = z(rec["red_a"]) + z(rec["red_b"]) rec["credit_boy"] = z(rec["boy_a"]) + z(rec["boy_b"]) rec["credit_used"] = z(rec["use_a"]) + z(rec["use_b"]) t = rec["target"] rec["ratio"] = rec["assets"] / t * 100 if t and t > 0 and rec["assets"] is not None else None return out def single_sums(zdir: str) -> dict: """Acknowledgement ID -> Schedule R line 3 (None when the line is blank).""" out = {} for z in sorted(glob.glob(os.path.join(zdir, "F_SCH_R_20*_Latest.zip"))): for r in csv_rows(z): out[r["ACK_ID"]] = num(r.get("PEN_BNFT_DISTRIB_SNGL_SUM_CNT")) return out def status(a: float) -> str: return next(name for name, lo, hi in STATUS if lo <= a < hi) def paid(v: list) -> dict: """How many of these plans paid a benefit as a single sum, from the Schedule R each filed.""" has = [r for r in v if r["sums"] is not None] pos = [r for r in has if r["sums"] > 0] return {"plans": len(v), "with_schedule_r": len(has), "paid_any": len(pos), "single_sums": int(sum(r["sums"] for r in pos)), "participants": people(has), "per_1000_participants": round(1000 * sum(r["sums"] for r in pos) / max(1, people(has)), 1)} def names(zdir: str, acks: set) -> dict: out = {} for z in sorted(glob.glob(os.path.join(zdir, "F_5500_20*_Latest.zip"))): for r in csv_rows(z): if r["ACK_ID"] in acks: out[r["ACK_ID"]] = (r.get("SPONSOR_DFE_NAME", "").strip(), r.get("PLAN_NAME", "").strip(), r.get("SPONS_DFE_MAIL_US_STATE", "").strip()) return out def band(v: list, lo: float, hi: float) -> list: return [r for r in v if r["a"] is not None and lo <= r["a"] < hi] def people(v: list, key: str = "participants") -> int: return int(sum(r[key] or 0 for r in v)) def yearly(plans: dict) -> list: out = [] for y in YEARS: v = [r for (_e, _p, py), r in plans.items() if py == y and r["large"]] at = band(v, LINE, AT_LINE) rep = [r["a"] for r in v if r["a"] is not None] out.append({"plan_year": y, "plans": len(v), "under_60": len(band(v, 0, 60)), "from_60_under_80": len(band(v, 60, 80)), "from_79_under_80": len(band(v, 79, 80)), "from_80_under_81": len(band(v, 80, 81)), "from_80_under_90": len(band(v, 80, 90)), "participants_80_under_90": people(band(v, 80, 90)), "at_line": len(at), "participants_at_line": people(at), "median_aftap": round(statistics.median(rep), 1), "aftap_blank": sum(1 for r in v if r["status"] == "blank"), "aftap_zero": sum(1 for r in v if r["status"] == "zero"), "filed_on_another_form_year": sum(1 for r in v if r["form_year"] != y)}) return out def panel(plans: dict) -> dict: a = {(e, p): r for (e, p, py), r in plans.items() if py == PY - 1 and r["large"]} b = {(e, p): r for (e, p, py), r in plans.items() if py == PY} both = [(a[k], b[k]) for k in a if k in b and a[k]["a"] is not None and b[k]["a"] is not None] d = [y["a"] - x["a"] for x, y in both] falls = [v for v in d if v < 0] def moved(test) -> list: return [y for x, y in both if test(x["a"], y["a"])] down, up = moved(lambda x, y: x >= 90 and 80 <= y < 90), moved(lambda x, y: 80 <= x < 90 and y >= 90) below, above = moved(lambda x, y: x >= 80 and y < 80), moved(lambda x, y: x < 80 and y >= 80) return {"large_prior_year": len(a), "with_this_year_filing": sum(1 for k in a if k in b), "plans": len(both), "fell": len(falls), "median_change": round(statistics.median(d), 2), "median_change_among_falls": round(statistics.median(falls), 2), "from_90_into_80s": len(down), "participants_from_90_into_80s": people(down), "from_80s_to_90": len(up), "crossed_below_80": len(below), "participants_crossed_below_80": people(below), "rose_above_80": len(above)} def credit(v: list) -> list: """Every flagged plan, with its tier (the rule is in the module docstring).""" rows = [] for r in v: t, a = r["target"], r["a"] if a is None or not t or t <= 0 or r["reduced"] <= 0 or a < LINE or a - r["reduced"] / t * 100 >= LINE: continue assets = r["assets"] or 0.0 full = assets / t >= 1.0 basis = ("documented" if ANNUITY[r["ack"]] else "inferred") if r["ack"] in ANNUITY else "" p = ANNUITY.get(r["ack"]) or 0.0 if basis == "inferred": p = (a / 100 * t - (assets - r["credit_boy"])) / (1 - a / 100) after = assets / t * 100 if full else (assets - r["credit_boy"] + p) / (t + p) * 100 before = assets / t * 100 if full else (assets - r["credit_boy"] - r["reduced"] + p) / (t + p) * 100 need = 0.0 if full else min(max(0.0, LINE / 100 * (t + p) - (assets - r["credit_boy"] - r["reduced"] + p)), r["reduced"]) ok = abs(after - a) <= TOLERANCE tier = ("C" if full else "A" if ok and not basis and before < LINE else "B1" if ok and basis == "documented" and before < LINE else "B2" if basis == "inferred" and before < LINE else "D") rows.append({**r, "tier": tier, "annuity": round(p, 2), "basis": basis, "after_rebuilt": round(after, 2), "before": round(before, 2), "needed": round(need, 2)}) return sorted(rows, key=lambda r: (-r["reduced"], r["ack"])) def summarize(plans: dict, cr: list, inputs: dict, nm: dict) -> dict: v = [r for (_e, _p, py), r in plans.items() if py == PY and r["large"]] at, near = band(v, LINE, AT_LINE), band(v, 80, 90) at_ratio = [r["ratio"] for r in at if r["ratio"] is not None] thin = [r for r in at if r["ratio"] is not None and r["ratio"] < 83] low = [r for r in near if r["ratio"] is not None and r["ratio"] < 85] top4 = sorted(at, key=lambda r: -(r["participants"] or 0))[:4] tiers = [] for t in TIERS: g = [r for r in cr if r["tier"] == t] tiers.append({"tier": t, "what": TIERS[t], "plans": len(g), "participants": people(g), "reduced_usd": round(sum(r["reduced"] for r in g), 2), "needed_usd": round(sum(r["needed"] for r in g), 2)}) res = [r for r in cr if r["tier"] in ("A", "B1", "B2")] two = {"aftap_at_line": 0, "ftap_at_line": 0, "plans": 0} for (_e, _p, py), r in plans.items(): if py in YEARS and r["large"] and r["a"] is not None and r["ftap"] is not None and r["a"] < 100 and r["ftap"] < 100 \ and abs(r["a"] - r["ftap"]) > 0.25: two["plans"] += 1 two["aftap_at_line"] += LINE <= r["a"] < AT_LINE two["ftap_at_line"] += LINE <= r["ftap"] < AT_LINE states: dict = defaultdict(lambda: {"plans_80_under_90": 0, "participants_80_under_90": 0, "plans_under_80": 0, "participants_under_80": 0}) for r in v: if r["a"] is None or r["a"] >= 90: continue s = states[nm.get(r["ack"], ("", "", ""))[2]] k = "80_under_90" if r["a"] >= 80 else "under_80" s["plans_" + k] += 1 s["participants_" + k] += int(r["participants"] or 0) return { "plan_year": PY, "data_release": DATA_RELEASE, "inputs": inputs, "rule": {"large": LARGE, "at_line": [LINE, AT_LINE], "tolerance": TOLERANCE, "cohort": "plan year begin date", "filing": "latest acknowledgement ID per EIN, PN and plan-year start"}, "plans": len(v), "yearly": yearly(plans), "at_line": {"plans": len(at), "participants": people(at), "reported_a_reduction": sum(1 for r in at if r["reduced"] > 0), "median_assets_to_target": round(statistics.median(at_ratio), 1), "assets_under_83": len(thin), "participants_assets_under_83": people(thin), "top4_participant_share": round(people(top4) / people(at), 4), "top4": [nm.get(r["ack"], ("",))[0] for r in top4]}, "under_80": {"plans": len(band(v, 0, 80)), "participants": people(band(v, 0, 80)), "under_60": len(band(v, 0, 60))}, "under_90": len(band(v, 0, 90)), "status": {name: len(band(v, lo, hi)) for name, lo, hi in STATUS}, "reported": sum(1 for r in v if r["a"] is not None), "paid": {"all": paid([r for r in v if r["a"] is not None]), "under_80": paid(band(v, 0, 80)), "at_line": paid(at), "from_80_under_90": paid(near)}, "from_80_under_90": {"plans": len(near), "assets_under_85": len(low), "participants_assets_under_85": people(low), "former_assets_under_85": people(low, "former")}, "panel": panel(plans), "credit": {"flagged": len(cr), "tiers": tiers, "resolved_plans": len(res), "resolved_participants": people(res), "resolved_reduced_usd": round(sum(r["reduced"] for r in res), 2), "resolved_needed_usd": round(sum(r["needed"] for r in res), 2), "median_before": round(statistics.median(r["before"] for r in res), 1), "resolved_at_line": sum(1 for r in res if r["a"] < AT_LINE), "credit_start_of_year_usd": round(sum(r["credit_boy"] for r in res), 2), "credit_used_usd": round(sum(r["credit_used"] for r in res), 2), "tier_c_ftap_at_line": sum(1 for r in cr if r["tier"] == "C" and r["ftap"] is not None and LINE <= r["ftap"] < AT_LINE)}, "two_lines": two, "by_state": sorted(({"state": k, **s} for k, s in states.items()), key=lambda x: (-x["participants_80_under_90"], x["state"])), } PLAN_COLS = ("plan_id", "ein", "pn", "plan_year_begin", "form_year", "ack_id", "sponsor", "plan_name", "state", "participants", "former_employees_owed_a_benefit", "aftap", "ftap", "assets_to_target", "credit_start_of_year_usd", "credit_reduced_usd", "credit_used_usd", "single_sums_paid") STATUS_COLS = ("plan_id", "ein", "pn", "ack_id", "plan_year_begin", "participants", "former_employees_owed_a_benefit", "aftap", "status", "single_sums_paid") CREDIT_COLS = PLAN_COLS + ("tier", "annuity_usd", "annuity_basis", "aftap_rebuilt", "aftap_before_reduction", "needed_usd") def _row(r: dict, nm: dict) -> dict: sponsor, plan, st = nm.get(r["ack"], ("", "", "")) return {"plan_id": f"{r['ein']}-{r['pn']}", "ein": r["ein"], "pn": r["pn"], "plan_year_begin": r["begin"], "form_year": r["form_year"], "ack_id": r["ack"], "sponsor": sponsor, "plan_name": plan, "state": st, "participants": int(r["participants"] or 0), "former_employees_owed_a_benefit": int(r["former"] or 0), "aftap": r["a"], "ftap": r["ftap"], "assets_to_target": round(r["ratio"], 2) if r["ratio"] is not None else "", "credit_start_of_year_usd": round(r["credit_boy"], 2), "credit_reduced_usd": round(r["reduced"], 2), "credit_used_usd": round(r["credit_used"], 2), "single_sums_paid": "" if r["sums"] is None else int(r["sums"])} def write(out: str, rows: list, cr: list, summary: dict, nm: dict, every: list) -> None: os.makedirs(out, exist_ok=True) pub = [_row(r, nm) for r in rows] with open(os.path.join(out, "status.csv"), "w", newline="") as fh: w = csv.DictWriter(fh, fieldnames=STATUS_COLS, lineterminator="\n", extrasaction="ignore") w.writeheader() w.writerows({**_row(r, nm), "status": status(r["a"])} for r in every) with open(os.path.join(out, "plans.csv"), "w", newline="") as fh: w = csv.DictWriter(fh, fieldnames=PLAN_COLS, lineterminator="\n") w.writeheader() w.writerows(pub) with open(os.path.join(out, "credit.csv"), "w", newline="") as fh: w = csv.DictWriter(fh, fieldnames=CREDIT_COLS, lineterminator="\n") w.writeheader() w.writerows({**_row(r, nm), "tier": r["tier"], "annuity_usd": r["annuity"] or "", "annuity_basis": r["basis"], "aftap_rebuilt": r["after_rebuilt"], "aftap_before_reduction": r["before"], "needed_usd": r["needed"]} for r in cr) keep = ("plan_id", "ein", "pn", "sponsor", "plan_name", "state", "ack_id", "participants", "former_employees_owed_a_benefit", "aftap", "assets_to_target", "single_sums_paid") look = {"near": [{k: x[k] for k in keep} for x in pub if x["aftap"] >= 80][:NEAR_ROWS], "under": [{k: x[k] for k in keep} for x in pub if x["aftap"] < 80], "annuity": [{"ack_id": r["ack"], "ein": r["ein"], "sponsor": nm.get(r["ack"], ("",))[0], "tier": r["tier"], "annuity_usd": r["annuity"], "basis": r["basis"]} for r in cr if r["basis"]]} with open(os.path.join(out, "lookup.json"), "w") as fh: json.dump(look, fh, indent=1) fh.write("\n") with open(os.path.join(out, "summary.json"), "w") as fh: json.dump(summary, fh, indent=1) fh.write("\n") shutil.copyfile(os.path.abspath(__file__), os.path.join(out, "line80_study.py.txt")) def main(zdir: str, out: str) -> dict: inputs = {os.path.basename(z): sha256(z) for z in sorted(glob.glob(os.path.join(zdir, "F_*_Latest.zip")))} plans = load(zdir) sums = single_sums(zdir) for r in plans.values(): r["sums"] = sums.get(r["ack"]) v = [r for (_e, _p, py), r in plans.items() if py == PY and r["large"]] nm = names(zdir, {r["ack"] for r in v}) cr = credit(v) rows = sorted(band(v, 0, 90), key=lambda r: (-(r["participants"] or 0), r["ein"], r["pn"])) s = summarize(plans, cr, inputs, nm) every = sorted((r for r in v if r["a"] is not None), key=lambda r: (r["ein"], r["pn"])) write(out, rows, cr, s, nm, every) return s if __name__ == "__main__": if len(sys.argv) != 3: sys.exit(__doc__) s = main(sys.argv[1], sys.argv[2]) print(json.dumps({"plans": s["plans"], "at_line": s["at_line"], "yearly": s["yearly"], "panel": s["panel"], "credit": s["credit"], "two_lines": s["two_lines"], "under_80": s["under_80"], "status": s["status"], "paid": s["paid"]}, indent=1))