new-site/scripts/document_gen/templates/cpni_private_line_generator.py
justin f8cd37ac8c Initial commit — Performance West telecom compliance platform
Includes: API (Express/TypeScript), Astro site, Python workers,
document generators, FCC compliance tools, Canada CRTC formation,
Ansible infrastructure, and deployment scripts.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-27 06:54:22 -05:00

225 lines
9.2 KiB
Python

"""
Generate the FCC CPNI Annual Certification Letter — Private Line / BDS variant.
A private-line (point-to-point) or Business Data Service (BDS) offering
typically holds negligible CPNI: there is no switched calling, no PIC,
no per-call detail record, and no directory assistance. The carrier's
records are limited to circuit identifiers, service-address endpoints,
and enterprise billing data. These records generally fall outside the
statutory definition of CPNI at 47 USC § 222(h)(1), which is tied to
"telecommunications service" used by a customer.
This is a short, one-page certification that recites the carrier's
status, acknowledges the limited applicability of the CPNI rules to
its offerings, and commits to the same statutory safeguards (47 CFR
§ 1.17 truthfulness, Title 18 perjury acknowledgment, and forfeiture
awareness).
"""
from __future__ import annotations
import logging
from datetime import datetime
from pathlib import Path
from typing import Optional
LOG = logging.getLogger("document_gen.cpni_private_line")
try:
from docx import Document
from docx.shared import Pt, Inches, RGBColor
from docx.enum.text import WD_ALIGN_PARAGRAPH
except ImportError:
LOG.warning("python-docx not installed — CPNI Private Line generation unavailable")
Document = None # type: ignore[assignment,misc]
_NAVY = RGBColor(0x1A, 0x27, 0x44) if Document else None
VARIANT_ID = "private_line"
VARIANT_LABEL = "Private Line / Business Data Service (BDS)"
MAX_FORFEITURE_PER_VIOLATION = "$251,322"
MAX_FORFEITURE_CAP = "$2,513,215"
def _sp(p, after=6, before=0):
p.paragraph_format.space_after = Pt(after)
if before:
p.paragraph_format.space_before = Pt(before)
def _h(doc, text):
p = doc.add_paragraph(); r = p.add_run(text)
r.font.size = Pt(12); r.bold = True; r.font.color.rgb = _NAVY
_sp(p, after=4, before=8)
def _b(doc, text, bold=False, size=10):
p = doc.add_paragraph(); p.alignment = WD_ALIGN_PARAGRAPH.LEFT
r = p.add_run(text); r.font.size = Pt(size); r.bold = bold
_sp(p, after=6)
def generate_cpni_private_line(
output_path: str,
entity_name: str,
frn: str = "",
filer_id_499: str = "",
officer_name: str = "",
officer_title: str = "Chief Executive Officer",
complaints_count: int = 0,
complaints_description: str = "",
has_data_broker_inquiries: bool = False,
data_broker_description: str = "",
reporting_year: int = 0,
address_street: str = "",
address_city: str = "",
address_state: str = "",
address_zip: str = "",
contact_email: str = "",
contact_phone: str = "",
breaches: list[dict] | None = None,
**_: dict,
) -> Optional[str]:
if Document is None:
LOG.error("python-docx not installed")
return None
if reporting_year == 0:
reporting_year = datetime.now().year - 1
breaches = breaches or []
doc = Document()
for s in doc.sections:
s.top_margin = Inches(0.9); s.bottom_margin = Inches(0.9)
s.left_margin = Inches(1); s.right_margin = Inches(1)
today = datetime.now().strftime("%B %d, %Y")
signer = officer_name or "Authorized Officer"
title = officer_title or "Officer"
tp = doc.add_paragraph(); tp.alignment = WD_ALIGN_PARAGRAPH.CENTER
t = tp.add_run("CPNI Annual Certification Letter")
t.font.size = Pt(14); t.bold = True; t.font.color.rgb = _NAVY
_sp(tp, after=2)
sp = doc.add_paragraph(); sp.alignment = WD_ALIGN_PARAGRAPH.CENTER
s = sp.add_run(
f"Private Line / Business Data Service \u2014 "
f"47 CFR \u00a7 64.2009 \u2014 Calendar Year {reporting_year}"
)
s.font.size = Pt(10); s.font.color.rgb = RGBColor(0x55, 0x55, 0x55)
_sp(sp, after=6)
_h(doc, "1. Provider Information and Scope")
lines = [f"Company Name: {entity_name}", f"Variant: {VARIANT_LABEL}"]
if frn: lines.append(f"FCC Registration Number (FRN): {frn}")
if filer_id_499: lines.append(f"FCC Form 499 Filer ID: {filer_id_499}")
addr = ", ".join(filter(None, [address_street, address_city]))
if address_state or address_zip:
addr += f", {address_state} {address_zip}".strip()
if addr.strip(", "):
lines.append(f"Address: {addr.strip(', ')}")
if contact_phone: lines.append(f"Telephone: {contact_phone}")
if contact_email: lines.append(f"Email: {contact_email}")
lines.append(f"Certifying Officer: {signer}, {title}")
lines.append(f"Date of Filing: {today}")
lines.append(f"Filing Deadline: March 2, {reporting_year + 1}")
_b(doc, "\n".join(lines))
_h(doc, "2. Officer Statement of Personal Knowledge")
_b(doc, (
f"I, {signer}, {title} of {entity_name}, state that I have personal "
f"knowledge of the matters certified herein and have reviewed "
f"{entity_name}'s records-handling procedures for private-line / "
f"Business Data Service (BDS) circuits covering the reporting "
f"period."
))
_h(doc, "3. Limited Applicability of CPNI Rules")
_b(doc, (
f"{entity_name}'s offerings consist principally of dedicated "
f"point-to-point private-line and/or Business Data Service "
f"circuits. These offerings generate no switched-call detail "
f"records, no presubscribed interexchange carrier (PIC) "
f"information, and no directory-assistance records. The records "
f"{entity_name} maintains \u2014 circuit identifiers, A-end and "
f"Z-end service addresses, and enterprise billing data \u2014 "
f"generally fall outside the statutory definition of Customer "
f"Proprietary Network Information at 47 USC \u00a7 222(h)(1), "
f"which is tied to the customer's use of a telecommunications "
f"service."
))
_b(doc, (
f"To the extent any subset of these records constitutes CPNI "
f"under the Commission's rules, {entity_name} certifies compliance "
f"with 47 CFR \u00a7\u00a7 64.2001 through 64.2011 for the period "
f"January 1, {reporting_year} through December 31, {reporting_year}. "
f"Specifically, access to customer circuit records is restricted "
f"to authenticated personnel; authentication is required before "
f"disclosure in response to customer inquiries; annual training "
f"is provided; and breach-notification procedures comply with "
f"47 CFR \u00a7 64.2011 as amended by FCC 23-111."
))
_h(doc, "4. Customer Complaints and Data Broker Inquiries")
if complaints_count == 0 and not has_data_broker_inquiries:
_b(doc, (
f"{entity_name} has NOT received any customer complaints "
f"concerning the unauthorized release or use of CPNI during "
f"the reporting period, and has NOT received any inquiries or "
f"communications from data brokers or other unauthorized "
f"parties seeking CPNI."
))
else:
if complaints_count == 0:
_b(doc, (
f"{entity_name} has NOT received any customer complaints "
f"during the reporting period."
))
else:
desc = complaints_description or "Each was investigated and resolved."
_b(doc, (
f"{entity_name} HAS received {complaints_count} customer "
f"complaint{'s' if complaints_count != 1 else ''}. {desc}"
))
if not has_data_broker_inquiries:
_b(doc, (
f"{entity_name} has NOT received any data broker or "
f"pretexting inquiries during the reporting period."
))
else:
desc = data_broker_description or "Each was refused and documented."
_b(doc, (
f"{entity_name} HAS received data broker / pretexting "
f"inquiries. {desc}"
))
_h(doc, "5. Penalties, Truthfulness, and Perjury Acknowledgment")
_b(doc, (
f"{entity_name} acknowledges that CPNI rule violations may subject "
f"the carrier to forfeitures up to {MAX_FORFEITURE_PER_VIOLATION} "
f"per violation and up to {MAX_FORFEITURE_CAP} for any single act "
f"or failure to act. Pursuant to 47 CFR \u00a7 1.17, the "
f"undersigned represents that no material factual information has "
f"been withheld and all statements are truthful, accurate, and "
f"complete. Willful false statements are punishable under Title "
f"18, U.S.C. \u00a7 1001, and by forfeiture under 47 U.S.C. "
f"\u00a7 503."
))
_h(doc, "6. Signature of Certifying Officer")
_b(doc, (
"I declare under penalty of perjury under the laws of the United "
"States of America that the foregoing is true and correct."
))
sig = doc.add_paragraph(); sig.add_run("_" * 45).font.size = Pt(10); _sp(sig, after=2)
nm = doc.add_paragraph(); nr = nm.add_run(signer); nr.bold = True
nr.font.size = Pt(10); _sp(nm, after=2)
tpp = doc.add_paragraph(); tpp.add_run(f"{title}, {entity_name}").font.size = Pt(10)
_sp(tpp, after=2)
dp = doc.add_paragraph(); dp.add_run(f"Date: {today}").font.size = Pt(10)
_sp(dp, after=2)
out = Path(output_path)
out.parent.mkdir(parents=True, exist_ok=True)
doc.save(str(out))
LOG.info("CPNI Private Line certification letter generated: %s", out)
return str(out)