Spaces:
Sleeping

curium-intel / scripts /send_correction.py
mipwr-admin's picture
Sync from GitHub main — ERP priority, WMCA/Shropshire watchlist, network preserve-owners fix (a7395ea)
a87217c verified
Raw History Blame Contribute Delete
3.4 kB
"""
One-off: send a correction/retraction note for the 18 June LGR report.
Internal only. Recipients passed as "Name:email" args.
"""
from __future__ import annotations
import sys
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(REPO_ROOT))
try:
from dotenv import load_dotenv
load_dotenv(REPO_ROOT / ".env", override=False)
except ImportError:
pass
import mailer
import weekly_digest
DRY_RUN = "--dry-run" in sys.argv
SUBJECT = "Correction — LGR report (18 June): decision dates were wrong"
def _html(name: str) -> str:
try:
fb = weekly_digest._feedback_prompt_html(recipient_name=name)
except Exception:
fb = ""
return f"""
<div style="font-family:Calibri,Arial,sans-serif;max-width:640px;margin:0 auto;">
<h2 style="color:#b71c1c;border-bottom:2px solid #b71c1c;padding-bottom:6px;">
⚠️ Correction — LGR report (18 June)</h2>
<p>Hi {name},</p>
<p>Please <strong>disregard the decision-timing claims</strong> in the LGR
landscape report I sent earlier today. It stated that several counties —
including Oxfordshire — had ministerial decisions in March 2026.
<strong>That is incorrect. No LGR decisions have been made yet.</strong></p>
<p>The verified position (Oxfordshire County Council / GOV.UK):</p>
<ul style="font-size:0.92em;color:#333;">
<li>Proposals were submitted on <strong>27 November 2025</strong>.</li>
<li>What happened in <strong>February–March 2026 was the statutory
consultation</strong> — not a decision.</li>
<li>The government decision is expected <strong>by mid-July 2026</strong>
(before Parliament's summer recess on 16 July).</li>
<li>Shadow elections would follow in May 2027, new unitaries April 2028.</li>
</ul>
<p style="font-size:0.92em;color:#333;">More broadly: please treat the
<strong>specific named contacts, notice numbers and unitary counts</strong>
in that report as <strong>unverified</strong> until checked against source.
The warm-route mapping (Sandy Walkington, Peter Shakespear) and the overall
opportunity framing stand; the dated specifics do not.</p>
<p style="font-size:0.92em;color:#333;">We're reworking the report generator
so every claim is tied to a citable source before it goes out. Apologies for
the error.</p>
<p>Best,<br>Curium Lead Intelligence</p>
{fb}
</div>"""
def main() -> int:
recipients = []
for arg in sys.argv[1:]:
if arg.startswith("--") or ":" not in arg:
continue
name, email = arg.split(":", 1)
recipients.append((name.strip(), email.strip()))
if not recipients:
print("No recipients. Pass 'Name:email' args.")
return 1
sent = []
for name, email in recipients:
if DRY_RUN:
print(f" [dry-run] correction → {name} <{email}>")
sent.append(name)
continue
r = mailer.send(to_email=email, subject=SUBJECT, html=_html(name))
if r.get("success"):
print(f" ✓ {name} → {email}")
sent.append(name)
else:
print(f" ✗ {name} → {r.get('message')}")
print(f"\nSent to: {sent}")
return 0
if __name__ == "__main__":
raise SystemExit(main())