160-tool MCP server for real-time global intelligence from free public APIs: markets, liquidity, prediction markets, SEC filings, conflict, military, aircraft-cohort early warning, migration and border flows, cyber, climate, news and more. Dated observation history, 29 research prompts, cited briefs, geofences, SSE dashboard. MIT, no paid API keys.
Python ai-toolsai-watchanthropicclaudecybersecuritydashboardgeofencinggeopoliticalgeospatialintelligencemarketsmcpmigrationmilitarymodel-context-protocolnuclearosintreal-timespace-weatherthreat-intelligence
Fixes #24: resolved post-mortems are not active incidents; dead status feeds are disclosed
Phoenix Agent (Marcs-Mac-Studio)c0667e276e5c
diff --git a/src/world_intel_mcp/sources/service_status.py b/src/world_intel_mcp/sources/service_status.pyindex f8b0d52..14d546a 100644--- a/src/world_intel_mcp/sources/service_status.py+++ b/src/world_intel_mcp/sources/service_status.py@@ -71,6 +71,7 @@ _SEVERITY_KEYWORDS: dict[str, str] = {# Helpers# ---------------------------------------------------------------------------+def _utc_now_iso() -> str:return datetime.now(timezone.utc).isoformat()@@ -93,8 +94,15 @@ def _parse_published(entry: dict) -> str | None:def _classify_severity(title: str, summary: str) -> str:- """Classify incident severity from title and summary text."""+ """Classify incident severity from title and summary text.++ Resolution status outranks incident words: a 'Resolved: Major+ outage' post-mortem is resolved, not an active critical incident+ (scanning the keyword table in insertion order used to classify it+ critical and inflate active_incidents)."""combined = f"{title} {summary}".lower()+ if "resolved" in combined:+ return "resolved"for keyword, severity in _SEVERITY_KEYWORDS.items():if keyword in combined:return severity@@ -105,6 +113,7 @@ def _classify_severity(title: str, summary: str) -> str:# Public API# ---------------------------------------------------------------------------+async def fetch_service_status(fetcher: Fetcher,provider: str | None = None,@@ -145,7 +154,10 @@ async def fetch_service_status(all_incidents: list[dict] = []- async def _fetch_provider(feed: dict) -> list[dict]:+ async def _fetch_provider(feed: dict) -> tuple[str, list[dict] | None]:+ """Returns (provider, incidents), with None — not an empty list —+ when the feed was unreachable: a dead feed must not be+ shape-identical to a healthy provider with no incidents."""safe_name = feed["provider"].lower()xml_text = await fetcher.get_xml(feed["url"],@@ -156,7 +168,7 @@ async def fetch_service_status(if xml_text is None:logger.debug("No data from %s status feed", feed["provider"])- return []+ return (feed["provider"], None)parsed = feedparser.parse(xml_text)incidents: list[dict] = []@@ -166,21 +178,28 @@ async def fetch_service_status(summary = entry.get("summary") or entry.get("description") or ""severity = _classify_severity(title, summary)- incidents.append({- "provider": feed["provider"],- "title": title,- "link": entry.get("link", ""),- "published": _parse_published(entry),- "summary": summary[:300] if len(summary) > 300 else summary,- "severity": severity,- })+ incidents.append(+ {+ "provider": feed["provider"],+ "title": title,+ "link": entry.get("link", ""),+ "published": _parse_published(entry),+ "summary": summary[:300] if len(summary) > 300 else summary,+ "severity": severity,+ }+ )- return incidents+ return (feed["provider"], incidents)tasks = [_fetch_provider(f) for f in feeds]results = await asyncio.gather(*tasks)- for incidents in results:+ unavailable_providers: list[str] = []+ for provider_name, incidents in results:+ if incidents is None:+ unavailable_providers.append(provider_name)+ continueall_incidents.extend(incidents)+ unavailable_providers.sort()# Sort by published descendingall_incidents.sort(key=lambda i: i.get("published") or "", reverse=True)@@ -194,7 +213,7 @@ async def fetch_service_status(if inc.get("severity") not in ("resolved", "info", "unknown"):active_count += 1- return {+ response = {"incidents": all_incidents,"count": len(all_incidents),"active_incidents": active_count,@@ -203,3 +222,15 @@ async def fetch_service_status("source": "service-status","timestamp": _utc_now_iso(),}+ if unavailable_providers:+ # An unreachable feed is named, not silently folded into "no+ # incidents": providers_checked means attempted, and+ # unavailable_providers says which attempts got no data.+ response["unavailable_providers"] = unavailable_providers+ response["degraded"] = True+ if len(unavailable_providers) == len(feeds):+ response["error"] = "All status feeds unavailable: " + ", ".join(+ unavailable_providers+ )+ response["reason"] = "status_feeds_unavailable"+ return responsediff --git a/src/world_intel_mcp/tests/test_sources_service_status.py b/src/world_intel_mcp/tests/test_sources_service_status.pyindex 9015620..ce545d2 100644--- a/src/world_intel_mcp/tests/test_sources_service_status.py+++ b/src/world_intel_mcp/tests/test_sources_service_status.py@@ -123,10 +123,10 @@ async def test_fetch_service_status_unknown_provider(fetcher: Fetcher) -> None:async def test_fetch_service_status_one_feed_down(fetcher: Fetcher, monkeypatch: pytest.MonkeyPatch) -> None:- """A failing feed contributes zero incidents while others still report.- Observation (flagged in review, not fixed): the response does not say- WHICH provider's feed failed — a dead AWS feed is shape-identical to a- healthy AWS with no incidents."""+ """A failing feed contributes zero incidents while others still report,+ and the failure is NAMED: before this fix a dead AWS feed was+ shape-identical to a healthy AWS with no incidents (the+ silent-degradation class)."""async def _no_sleep(*args, **kwargs) -> None:return None@@ -144,18 +144,21 @@ async def test_fetch_service_status_one_feed_down(result = await fetch_service_status(fetcher)assert result["count"] == 12 # 3 x 4 surviving providersassert "AWS" not in result["by_provider"]- assert "AWS" in result["providers_checked"] # still claimed as checked+ assert "AWS" in result["providers_checked"] # attempted, and...+ assert result["unavailable_providers"] == ["AWS"] # ...named as down+ assert result["degraded"] is True+ assert "error" not in result # partial failure is degraded, not an error@respx.mock@pytest.mark.asyncio-async def test_resolved_incident_with_severity_words_counts_active(+async def test_resolved_incident_with_severity_words_is_not_active(fetcher: Fetcher,) -> None:- """Suspected bug (documented, not fixed): _SEVERITY_KEYWORDS is scanned- in insertion order and "major"/"outage" precede "resolved", so a- 'Resolved: Major outage' post-mortem classifies as critical and inflates- active_incidents."""+ """Regression: _SEVERITY_KEYWORDS is scanned in insertion order and+ "major"/"outage" used to precede "resolved", so a 'Resolved: Major+ outage' post-mortem classified as critical and inflated+ active_incidents. Resolution status must outrank incident words."""rss = """<?xml version="1.0"?><rss version="2.0"><channel><title>S</title><item><title>Resolved: Major outage restored</title>@@ -168,8 +171,8 @@ async def test_resolved_incident_with_severity_words_counts_active()result = await fetch_service_status(fetcher, provider="github")- assert result["incidents"][0]["severity"] == "critical" # current behavior- assert result["active_incidents"] == 1 # inflated+ assert result["incidents"][0]["severity"] == "resolved"+ assert result["active_incidents"] == 0def test_classify_severity() -> None:@@ -196,3 +199,29 @@ def test_parse_published() -> None:assert _parse_published({"published": "raw-date"}) == "raw-date"assert _parse_published({"updated": "other-date"}) == "other-date"assert _parse_published({}) is None+++async def test_fetch_service_status_all_feeds_down(+ fetcher: Fetcher, monkeypatch: pytest.MonkeyPatch+) -> None:+ """A total outage of every status feed is an error with a reason,+ not an empty-but-healthy-looking response."""++ async def _no_sleep(*args, **kwargs) -> None:+ return None++ monkeypatch.setattr(asyncio_mod, "sleep", _no_sleep)++ for pattern in _FEED_PATTERNS.values():+ respx.get(url__regex=pattern).mock(return_value=httpx.Response(500))++ result = await fetch_service_status(fetcher)+ assert result["count"] == 0+ assert sorted(result["unavailable_providers"]) == sorted(+ f["provider"] for f in _STATUS_FEEDS+ )+ assert result["degraded"] is True+ assert result["reason"] == "status_feeds_unavailable"+ assert "unavailable" in result["error"].lower()