fixes: immunity outcomes without political connection, ORF fee rows, dropped WKStA investigations

- parlament.items (parser 3): a committee finding of no connection to the political activity
  (Art. 57 Abs. 3 B-VG) means prosecution may proceed; it was left at 'requested'. Authority and
  case number no longer run into the following sentence on older reports.
- rtr.medientransparenz (parser 2): notice type 31 is the ORF's licence-fee income under section 31
  ORF-G, not a payment to an organisation named after the paragraph.
- enrich.legal: 'Einstellung der Ermittlungen' is proceedings_dropped, not an investigation.
- reparse -p kinds=a,b replays only responses of these request kinds (no stale sweep then).
- migration 0010 removes the wrong ORF rows and organisations and re-queues the affected headlines.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
simonandClaude Opus 5.5 committed 2026-11-20 10:03:11 +01:00
1 parent d2039a9dc3
commit f2d72fe464
8 files changed
+130 -7

No files matched your search

@@ -0,0 +1,28 @@
-- Data fixes that go with parser changes of November 2026.
-- 1. RTR notice type 31 (§ 31 ORF-G) is the ORF's licence-fee income. It was stored as a "payment" from the ORF to
-- an organisation named after the legal basis. rtr.medientransparenz (parser_version 2) now emits it as ORF income;
-- `politrack reparse rtr.medientransparenz -p kinds=quartal` recreates the rows.
DELETE FROM claim c USING money_flow mf
WHERE mf.claim_id = c.id AND c.created_by = 'rtr.medientransparenz' AND mf.kind = 'other'
AND mf.payee_name ~ '§ 31 Abs\. [0-9]+ ORF-G';
DELETE FROM alias WHERE entity_type = 'organization'
AND entity_id IN (SELECT id FROM organization WHERE name ~ '^(Programmentgelt|Abgeltung) gemäß § 31 Abs\. [0-9]+ ORF-G$');
DELETE FROM identifier WHERE entity_type = 'organization'
AND entity_id IN (SELECT id FROM organization WHERE name ~ '^(Programmentgelt|Abgeltung) gemäß § 31 Abs\. [0-9]+ ORF-G$');
DELETE FROM organization o
WHERE o.name ~ '^(Programmentgelt|Abgeltung) gemäß § 31 Abs\. [0-9]+ ORF-G$'
AND NOT EXISTS (SELECT 1 FROM claim c WHERE c.organization_id = o.id OR c.counterpart_org_id = o.id)
AND NOT EXISTS (SELECT 1 FROM money_flow m WHERE m.payer_org_id = o.id OR m.payee_org_id = o.id);
-- 2. enrich.legal read "Einstellung der Ermittlungen" (proceedings dropped) as an investigation. Drop those unreviewed
-- proposals and let the enricher look at the headlines again.
DELETE FROM claim c
WHERE c.created_by = 'enrich.legal' AND c.review_status = 'pending'
AND EXISTS (SELECT 1 FROM claim_evidence e JOIN document d ON d.id = e.document_id
WHERE e.claim_id = c.id AND d.title ~* 'Einstellung(en)?\M.{0,40}(Verfahren|Ermittlung)');
UPDATE claim c SET data = c.data - 'legal_checked'
WHERE c.claim_type = 'media_mention' AND c.data ? 'legal_checked'
AND EXISTS (SELECT 1 FROM claim_evidence e JOIN document d ON d.id = e.document_id
WHERE e.claim_id = c.id AND d.title ~* 'Einstellung(en)?\M.{0,40}(Verfahren|Ermittlung)');
+6 -1
View File
@@ -155,6 +155,11 @@ def _reparse(adapter: Adapter, ctx: RunContext, conn: Connection) -> None:
loader = Loader(conn, ctx)
started = conn.execute("SELECT now() AS t").fetchone()["t"]
rows = archive.latest_stored(conn, adapter.name)
# -p kinds=a,b reparses only responses of these request kinds (e.g. one parser of a large adapter). Claims
# of the other kinds are not reproduced then, so the stale-claim sweep is skipped.
kinds = {k for k in str(ctx.params.get("kinds", "")).split(",") if k}
if kinds:
rows = [r for r in rows if (r["request"] or {}).get("kind", "default") in kinds]
ctx.log.info("reparsing %s archived responses", len(rows))
# Parse list/index responses before detail responses: records referencing others (vote positions ->
# vote events) are emitted by the parent's parse() in order, so the original order is preserved
@@ -173,7 +178,7 @@ def _reparse(adapter: Adapter, ctx: RunContext, conn: Connection) -> None:
tdm_reserved=row["tdm_reserved"], from_archive=True)
ctx.stats["responses"] += 1
_parse_and_load(adapter, ctx, conn, loader, resp) # follow-ups are archived separately
if not ctx.stats.get("errors") and not ctx.stats.get("missing_blobs"):
if not kinds and not ctx.stats.get("errors") and not ctx.stats.get("missing_blobs"):
_sweep_stale_claims(adapter, ctx, conn, started)
+3 -1
View File
@@ -26,7 +26,9 @@ STAGES = [
r"schuldig gesprochen|Schuldspruch|\bverurteilt\b)", re.I)),
("acquitted", re.compile(r"\b(freigesprochen|Freispruch)\b", re.I)),
("diversion", re.compile(r"\bDiversion\b", re.I)),
("proceedings_dropped", re.compile(r"\b(Verfahren|Ermittlungen)\b.*\beingestellt\b|\beingestellt\b.*\bVerfahren\b", re.I)),
# "Einstellung(en) der Ermittlungen gegen ..." as well as "Verfahren eingestellt"
("proceedings_dropped", re.compile(r"\b(Verfahren|Ermittlungen)\b.*\beingestellt\b|\beingestellt\b.*\bVerfahren\b|"
r"\bEinstellung(en)?\b.{0,40}\b(Verfahrens?|Ermittlung(en|sverfahren)?)\b", re.I)),
("trial", re.compile(r"\b(Prozess|Strafprozess|vor Gericht|Prozessauftakt|Hauptverhandlung)\b", re.I)),
("indicted", re.compile(r"\b(angeklagt|Anklage|Strafantrag)\b", re.I)),
("investigation", re.compile(r"\b(ermittelt|Ermittlungen|Ermittlungsverfahren|Beschuldigte[rn]?|Hausdurchsuchung|"
@@ -170,8 +170,9 @@ STGB_OFFENSES = {
def parse_immunity_report(text: str) -> dict[str, Any]:
authority = re.search(r"Ersuchen (?:der|des) (.+?),\s*(?:do\.|GZ|Zl)", text)
case_ref = re.search(r"\bGZ\.?\s*([^,]+?),", text)
# "Ersuchen der Staatsanwaltschaft Wien, do. GZ. 501 St 68/24k, um ..." or "... Wien (GZ 25 St 407/08i) um ..."
authority = re.search(r"Ersuchen (?:der|des) ([^,()]{3,90}?)\s*(?:,|\(|\bum\b)", text)
case_ref = re.search(r"\b(?:GZ|Zl)\.?:?\s*([^,()]{3,60}?)\s*[,)]", text)
# "wegen des Verdachtes einer strafbaren Handlung nach § 283 Abs. 1 Z 1 und Z 2, Abs. 2 StGB"
offense = re.search(r"wegen[^§]{0,90}?(§§? ?\d+.{0,120}?\b(?:StGB|VerbotsG|FinStrG|[A-Z][A-Za-z]*G)\b)", text)
offense_text = offense.group(1).strip() if offense else None
@@ -183,12 +184,16 @@ def parse_immunity_report(text: str) -> dict[str, Any]:
recommendation = None
if decision:
recommendation = "refuse" if (decision.group(1) or decision.group(2)) else "consent"
elif re.search(r"festgestellt, dass kein Zusammenhang", text):
# Art. 57 Abs. 3 B-VG: without a connection to the political activity, immunity does not apply and the
# authority may prosecute without the Nationalrat's consent.
recommendation = "no_connection"
connection = None
if re.search(r"\bkein Zusammenhang\b", text):
connection = False
elif re.search(r"\bein Zusammenhang\b", text):
connection = True
quote = re.search(r"Als Ergebnis seiner Beratungen.*?(?:zugestimmt|nicht zugestimmt)\s*\.", text)
quote = re.search(r"Als Ergebnis seiner Beratungen.*?(?:zugestimmt|kein Zusammenhang\b.{0,300}?\bbesteht)\s*\.", text)
return {
"authority": authority.group(1).strip() if authority else None,
"case_ref": case_ref.group(1).strip() if case_ref else None,
+13 -2
View File
@@ -56,7 +56,7 @@ class ParlamentItems(Adapter):
name = "parlament.items"
description = "Votes (faction + roll call), immunity requests, written questions, U-committee hearings"
schedule = "45 3 * * *"
parser_version = 2
parser_version = 3 # 3: immunity reports finding no political connection, cleaner authority and case number
def start(self, ctx: RunContext) -> Iterator[Request]:
for gp in ctx.params.get("periods") or get_settings().parlament_periods:
@@ -232,12 +232,23 @@ class ParlamentItems(Adapter):
name = re.sub(r"^.*?(Abgeordneten zum Nationalrat|Mitglied(es)? des Bundesrates)\s*(Klubobmann|Klubobfrau)?",
"", title).strip()
decided = str(meta.get("status")) == "5"
recommendation = details["recommendation"] or ""
stage = {"consent": "immunity_waived" if decided else "immunity_waiver_requested",
"no_connection": "immunity_waived" if decided else "immunity_waiver_requested",
"refuse": "immunity_refused" if decided else "immunity_waiver_requested"}.get(
details["recommendation"] or "", "immunity_waiver_requested")
recommendation, "immunity_waiver_requested")
stage_de = {"immunity_waived": "Nationalrat stimmte der behördlichen Verfolgung zu (Immunität aufgehoben)",
"immunity_refused": "Nationalrat verweigerte die Zustimmung zur behördlichen Verfolgung",
"immunity_waiver_requested": "Ersuchen um Aufhebung der Immunität"}[stage]
if recommendation == "no_connection":
# Art. 57 Abs. 3 B-VG: no connection to the political activity -> no immunity, prosecution may proceed.
stage_de = ("Nationalrat stellte fest: kein Zusammenhang mit der politischen Tätigkeit, behördliche "
"Verfolgung zulässig" if decided else
"Ersuchen um Zustimmung zur behördlichen Verfolgung (Ausschuss empfiehlt: kein Zusammenhang "
"mit der politischen Tätigkeit, Verfolgung zulässig)")
elif stage == "immunity_waiver_requested" and recommendation:
stage_de += {"consent": " (Ausschuss empfiehlt Zustimmung)",
"refuse": " (Ausschuss empfiehlt, nicht zuzustimmen)"}[recommendation]
offense = details["offense"]
requested = parse_date(meta.get("date"))
yield Claim(
+25
View File
@@ -33,6 +33,9 @@ SPEC = SourceSpec(
"no use for defamatory/discriminatory purposes.",
)
KIND = {2: "government_ad", 4: "subsidy"}
# Notice type 31 (until 2023): the ORF reports what it received under § 31 ORF-G (licence fee "Programmentgelt",
# compensation under Abs. 11). The "medium" column then holds the legal basis, not a recipient.
ORF_FEE_REPORT = 31
def half_years(since_year: int) -> list[str]:
@@ -52,6 +55,7 @@ class MediaTransparency(Adapter):
description = "Government advertising and media subsidies per public body and media owner"
schedule = "0 4 * * 2"
queue = "bulk"
parser_version = 2 # 2: § 31 ORF-G fee reports are the ORF's income, not payments to a medium
def start(self, ctx: RunContext) -> Iterator[Request]:
for period in half_years(int(ctx.params.get("since_year", 2024))):
@@ -61,6 +65,23 @@ class MediaTransparency(Adapter):
yield Request(url=f"{API}/mt-bekanntgabe.json", params={"quartal": period, "size": PAGE_SIZE, "page": 0},
kind="quartal", meta={"period": period})
@staticmethod
def orf_fee(row: dict[str, Any], amount: float, label: str, period: str) -> Claim:
orf_name = (row.get("rechtstraeger") or "Österreichischer Rundfunk").strip().strip('"')
basis = (row.get("mediumMedieninhaber") or row.get("medium") or "§ 31 ORF-G").strip()
orf = OrgRef(name=orf_name, kind="media")
return Claim(
claim_type="money_flow", org=orf,
summary_de=f"{orf_name}: Einnahmen aus {basis}, {format_eur_de(amount)} € ({label})",
summary_en=f"{orf_name}: income under {basis} (licence fee), EUR {amount:,.2f} ({label})",
data={"legal_basis": basis, "period": label},
evidence=[Evidence(url=f"{API}/mt-bekanntgabe.json?quartal={period}", doc_type="dataset_row",
title=f"Medientransparenz {label}: {orf_name}", quote=f"{orf_name}: {basis}: {amount} €")],
topics=("Information und Medien",),
facet=Money(kind="other", amount=amount, payee=orf, payee_name=orf_name, payer_name=basis, period=label,
reference=basis, category="orf_fee"),
)
def parse(self, ctx: RunContext, response: Response) -> Iterator[Any]:
rows = response.json().get("data") or []
params = response.request.params or {}
@@ -74,6 +95,10 @@ class MediaTransparency(Adapter):
amount = row.get("euro")
if row.get("leermeldung") or amount is None or float(amount) < min_euro:
continue
if row.get("bekanntgabe") == ORF_FEE_REPORT:
if float(amount) > 0:
yield self.orf_fee(row, float(amount), label, period)
continue
kind = KIND.get(row.get("bekanntgabe"), "other")
payer_name = (row.get("rechtstraeger") or "").strip().strip('"')
owner = (row.get("medieninhaber") or row.get("mediumMedieninhaber") or "").strip()
+35
View File
@@ -135,3 +135,38 @@ def test_event_records_use_the_date_from_the_sentence():
claim = next(r for r in records if isinstance(r, Claim))
assert event.starts_at == claim.occurred_at == date(2026, 11, 11)
assert claim.data["date_precision"] == "day"
IMMUNITY_NO_CONNECTION = (
"Bericht des Immunitätsausschusses über das Ersuchen der Staatsanwaltschaft Wien, do. GZ. 501 St 68/24k, um "
"Zustimmung zur behördlichen Verfolgung des Abgeordneten zum Nationalrat Mag. Dr. Martin Graf gemäß Art. 57 Abs. 3 "
"B-VG Die Staatsanwaltschaft Wien ersucht ... wegen des Verdachtes einer strafbaren Handlung nach § 3g Abs. 1 und "
"Abs. 2 VerbotsG. ... Als Ergebnis seiner Beratungen stellt der Immunitätsausschuss somit den Antrag , der Nationalrat "
"wolle beschließen: In Behandlung des Ersuchens der Staatsanwaltschaft Wien (GZ 501 St 68/24k) um Zustimmung ... wird "
"im Sinne des Art. 57 Abs. 3 B‑VG festgestellt, dass kein Zusammenhang zwischen der inkriminierten Handlung und der "
"politischen Tätigkeit des Abgeordneten zum Nationalrat Mag. Dr. Martin Graf besteht. Wien, 2024 12 11"
)
def test_immunity_without_political_connection_allows_prosecution():
r = parse_immunity_report(IMMUNITY_NO_CONNECTION)
assert r["recommendation"] == "no_connection" and r["political_connection"] is False
assert r["offense"] == "§ 3g Abs. 1 und Abs. 2 VerbotsG"
assert r["quote"].endswith("Martin Graf besteht.")
def test_immunity_authority_and_case_number_in_brackets():
# older reports: "Ersuchen der Staatsanwaltschaft Wien (GZ 25 St 407/08i) um Zustimmung ..."
r = parse_immunity_report("Bericht über das Ersuchen der Staatsanwaltschaft Wien (GZ 25 St 407/08i) um Zustimmung zur "
"behördlichen Verfolgung des Abgeordneten Mag. Dr. Martin Graf Die Staatsanwaltschaft Wien "
"ersucht mit Schreiben vom 29. Jänner 2009, GZ 25 St 407/08i, um Zustimmung")
assert (r["authority"], r["case_ref"]) == ("Staatsanwaltschaft Wien", "25 St 407/08i")
r = parse_immunity_report("Ersuchen des Magistrats der Stadt Wien (GZ. MBA/210000025592/2021) um Zustimmung")
assert (r["authority"], r["case_ref"]) == ("Magistrats der Stadt Wien", "MBA/210000025592/2021")
def test_dropped_investigation_is_not_an_investigation():
assert classify("Verfahrenskomplex CASAG / Anzeige wegen Falschaussage: Einstellung von Ermittlungen gegen Thomas "
"Schmid") == "proceedings_dropped"
assert classify("Einstellungen der Ermittlungen gegen zwei Beschuldigte") == "proceedings_dropped"
assert classify("Causa Inserate: Weitere Ermittlungen") == "investigation"
+12
View File
@@ -235,3 +235,15 @@ def test_speech_segments_end_at_next_ru_anchor_or_chair():
assert seg["RU_1"].startswith("Abgeordnete Anna Eins (Grüne): Erste Rede.") and "Vorsitz" not in seg["RU_1"]
assert seg["RU_2"].startswith("Abgeordneter Bernd Zwei (SPÖ): Zweite Rede.")
assert "RU_2" in seg and len(seg["RU_2"]) < 200_000 # the rest of the session protocol is not one speech
def test_orf_fee_report_is_orf_income_not_a_payment_to_a_medium():
from politrack.sources.rtr import MediaTransparency
claim = MediaTransparency.orf_fee({"rechtstraeger": "Österreichischer Rundfunk", "bekanntgabe": 31,
"mediumMedieninhaber": "Programmentgelt gemäß § 31 Abs. 1 ORF-G"},
176200000.0, "2023-Q3", "20233")
assert claim.org.name == "Österreichischer Rundfunk" and claim.counterpart_org is None
assert claim.facet.payee.name == "Österreichischer Rundfunk" and claim.facet.payer is None
assert claim.facet.payer_name == "Programmentgelt gemäß § 31 Abs. 1 ORF-G" and claim.facet.category == "orf_fee"
assert claim.summary_de == ("Österreichischer Rundfunk: Einnahmen aus Programmentgelt gemäß § 31 Abs. 1 ORF-G, "
"176.200.000,00 € (2023-Q3)")