Skip to content

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.

Scheduled AOI sweeps: aoi_digest rides the collector daemon

Phoenix Agent (Marcs-Mac-Studio)2160984b17e2
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 906c527..bb5c6e2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,23 @@
# Changelog
+## Unreleased
+
+### Added
+- Scheduled AOI sweeps: `aoi_digest` is now a collector source
+ (`analysis.aoi.fetch_aoi_sweep`, a fetcher-only wrapper that opens
+ the AOI store on the fetcher's own cache database), so
+ `intel-collector --daemon` advances every defined geofence's change
+ snapshot on each cycle - the daemon interval is the watch cadence,
+ and the existing launchd wrapper makes it survive reboots. New `aoi`
+ domain group for `--sources aoi`. No push notification sink yet
+ (tracked in ROADMAP); digests land in the collector log and the
+ vector store.
+- Per-source collector timeout overrides (`SOURCE_TIMEOUTS`): a live
+ smoke caught a single 50 km AOI sweep on a cold cache blowing the
+ flat 45 s budget (the digest fans out to ~8 domains per AOI, several
+ rate-floored); the sweep now gets 240 s and the override path is
+ regression-tested.
+
## 0.8.0 - 2026-09-01
AOIs become operational (one-call sweeps and a full CLI), and the
diff --git a/CLAUDE.md b/CLAUDE.md
index 9f3b8c5..aa881ef 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -57,7 +57,7 @@ collector.py (daemon) ──┘
**Vector store** (`vector_store.py`): Optional Qdrant + FastEmbed (BAAI/bge-small-en-v1.5, 384-dim ONNX). Async background worker queue (`asyncio.Queue` + `asyncio.to_thread()`) for non-blocking storage. Fetcher auto-stores on fresh HTTP fetches. 65+ source name → category mappings for filtered search.
-**Collector** (`collector.py`): Standalone daemon for 24/7 vector store population. 50 sources organized by domain, with `--daemon`, `--interval`, `--sources` CLI args. Dynamic import via `_import_fetch_fn()`. Entry point: `intel-collector`.
+**Collector** (`collector.py`): Standalone daemon for 24/7 vector store population. 51 sources organized by domain, with `--daemon`, `--interval`, `--sources` CLI args. Dynamic import via `_import_fetch_fn()`. Per-source timeout overrides in `SOURCE_TIMEOUTS` (the `aoi_digest` sweep gets 240 s; everything else the flat 45 s). Entry point: `intel-collector`.
**Reports** (`reports.py`): PDF/HTML intelligence report generator. Collects 18 domains in parallel, renders styled HTML, converts to PDF via WeasyPrint. Optional dependency: `pip install -e ".[pdf]"`.
diff --git a/README.md b/README.md
index 1ffeff3..b8653af 100644
--- a/README.md
+++ b/README.md
@@ -145,7 +145,7 @@ collector.py (daemon) ─┘
- **CircuitBreaker**: Per-source tracking. 3 consecutive failures trips for 5 minutes. Each RSS feed gets its own breaker.
- **Cache**: SQLite WAL-mode TTL cache. `get()` returns live data, `get_stale()` returns expired data for fallback.
- **VectorStore**: Qdrant + FastEmbed (BAAI/bge-small-en-v1.5, 384-dim). Async background worker queue for non-blocking storage. Enables semantic search across all accumulated intelligence.
-- **Collector**: Standalone daemon that fetches all 50 sources in parallel and populates the vector store. Run once or as a daemon (default: 5-minute interval).
+- **Collector**: Standalone daemon that fetches all 51 sources in parallel and populates the vector store. Run once or as a daemon (default: 5-minute interval). Includes the AOI change sweep, so a running daemon continuously watches every defined geofence.
- **Sources** (`sources/*.py`): 30+ modules, each exports `async def fetch_*(fetcher, **kwargs) -> dict`.
- **Analysis** (`analysis/*.py`): Cross-domain synthesis — signal aggregation, instability indexing, NLP, company enrichment, macro composite.
- **Config** (`config/*.py`): Curated datasets — 22 hotspots, 70+ bases, 40 ports, 24 pipelines, 24 nuclear facilities, 34 cables, 48 datacenters, 27 spaceports, 82 exchanges.
@@ -535,8 +535,15 @@ intel-collector --daemon # every 5 minutes
intel-collector --daemon --interval 120 # every 2 minutes
intel-collector --sources markets,cyber # specific domains only
intel-collector # single collection cycle
+intel-collector --daemon --sources aoi --interval 900 # AOI watch only: sweep every geofence every 15 min
```
+The `aoi` group runs `intel_aoi_digest` as a sweep: each cycle diffs every
+defined AOI against its stored snapshot and advances it, so the daemon
+interval is your geofence watch cadence. Change digests are logged and
+(when the vector store is enabled) stored for semantic search. There is no
+push notification sink yet — see ROADMAP.
+
### Running as a macOS launchd Service
`scripts/collector-daemon.sh` manages the collector as a `launchd` agent so it
diff --git a/ROADMAP.md b/ROADMAP.md
index 117a68e..4cf3e8a 100644
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@ -534,7 +534,8 @@ Ordered by value; numbers are proposals, not commitments.
| Geo-scoped news | AOI news is name-mention only; a generic AOI name ("Home") yields junk. Investigate GDELT geo filters / GKG location fields | :yellow_circle: |
| CLI parity | `intel aoi` group with all 9 subcommands, shared store semantics, live-smoked | :white_check_mark: Shipped in 0.8.0 |
| Dashboard AOI layer | Draw defined AOIs on the Leaflet map; show per-AOI counts | :red_circle: |
-| Scheduled AOI sweeps | Collector-driven periodic `intel_aoi_changes` with a notification sink (the Pittsburgh-watch use case, generalized) | :red_circle: |
+| Scheduled AOI sweeps | `aoi_digest` is a collector source (`fetch_aoi_sweep`, 240 s budget): every daemon cycle advances all AOI snapshots, so `--daemon` + the launchd wrapper IS the schedule. Change digests land in the collector log and vector store | :white_check_mark: Shipped (unreleased) |
+| AOI change notifications | A push sink for non-empty sweeps (webhook/ntfy/email) — today the digest is pulled from the log or vector store, nothing pushes | :red_circle: |
### Phase 24 (planned): Test Coverage Gate
Measured 2026-09-01 (before the current test push): 59% statement
diff --git a/src/world_intel_mcp/analysis/aoi.py b/src/world_intel_mcp/analysis/aoi.py
index 684d631..c157e82 100644
--- a/src/world_intel_mcp/analysis/aoi.py
+++ b/src/world_intel_mcp/analysis/aoi.py
@@ -1875,3 +1875,19 @@ async def fetch_aoi_digest(fetcher, store: AOIStore, names: Any = None) -> dict:
"source": "aoi-digest",
"timestamp": _utc_now_iso(),
}
+
+
+async def fetch_aoi_sweep(fetcher) -> dict:
+ """Collector-daemon entry point for the AOI change sweep.
+
+ The collector calls every source as ``fn(fetcher)`` and cannot
+ supply the store ``fetch_aoi_digest`` needs, so this wrapper opens
+ the AOI store on the fetcher's own cache database — the same SQLite
+ file the MCP server and CLI write AOIs to — runs the digest (every
+ AOI's snapshot advances), and closes the store handle.
+ """
+ store = AOIStore(fetcher.cache.db_path)
+ try:
+ return await fetch_aoi_digest(fetcher, store)
+ finally:
+ store.close()
diff --git a/src/world_intel_mcp/collector.py b/src/world_intel_mcp/collector.py
index 50b2a50..9d12970 100644
--- a/src/world_intel_mcp/collector.py
+++ b/src/world_intel_mcp/collector.py
@@ -108,8 +108,19 @@ SOURCES = [
("strategic_posture", "analysis.posture", "fetch_strategic_posture", {}),
("fleet_report", "sources.fleet", "fetch_fleet_report", {}),
("usni_fleet", "sources.usni_fleet", "fetch_usni_fleet", {}),
+ # AOI (change sweep across every user-defined geofence; each AOI's
+ # snapshot advances, so the daemon interval IS the watch cadence)
+ ("aoi_digest", "analysis.aoi", "fetch_aoi_sweep", {}),
]
+# Per-source timeout overrides (seconds), consulted instead of the flat
+# collect_once budget. The AOI sweep fans out to ~8 domains per defined
+# AOI, several behind rate floors: one 50 km AOI on a cold cache was
+# measured (2026-09-01) to exceed the default 45 s.
+SOURCE_TIMEOUTS: dict[str, float] = {
+ "aoi_digest": 240.0,
+}
+
# Domain name → list of source names for --sources filtering
DOMAIN_GROUPS = {
"markets": [
@@ -153,6 +164,7 @@ DOMAIN_GROUPS = {
"social": ["social_signals"],
"nuclear": ["nuclear_monitor"],
"traffic": ["traffic_flow", "traffic_incidents"],
+ "aoi": ["aoi_digest"],
"analysis": [
"risk_scores",
"signal_convergence",
@@ -204,12 +216,13 @@ async def collect_once(
]
async def _fetch_one(name: str, module_path: str, fn_name: str, kwargs: dict):
+ budget = SOURCE_TIMEOUTS.get(name, timeout)
try:
fn = _import_fetch_fn(module_path, fn_name)
- result = await asyncio.wait_for(fn(fetcher, **kwargs), timeout=timeout)
+ result = await asyncio.wait_for(fn(fetcher, **kwargs), timeout=budget)
return name, result, None
except asyncio.TimeoutError:
- return name, None, f"timeout ({timeout}s)"
+ return name, None, f"timeout ({budget}s)"
except Exception as exc:
return name, None, str(exc)[:120]
diff --git a/src/world_intel_mcp/tests/test_aoi.py b/src/world_intel_mcp/tests/test_aoi.py
index 5f00e6f..ca4f853 100644
--- a/src/world_intel_mcp/tests/test_aoi.py
+++ b/src/world_intel_mcp/tests/test_aoi.py
@@ -1770,3 +1770,55 @@ async def test_aoi_digest_domain_error_stays_per_aoi(
assert any("Earthquakes" in g for g in entry["data_gaps"])
assert "error" not in result # the digest itself succeeded
s.close()
+
+
+# ---------------------------------------------------------------------------
+# fetch_aoi_sweep — the collector-daemon entry point
+# ---------------------------------------------------------------------------
+
+
+async def test_aoi_sweep_derives_store_from_fetcher_cache(
+ fetcher, monkeypatch: pytest.MonkeyPatch
+) -> None:
+ """The collector calls every source as ``fn(fetcher)``; the sweep
+ wrapper must open the AOI store on the same SQLite file the
+ fetcher's cache uses — the store the MCP server and CLI write to,
+ not a fresh default-path database."""
+ seen: dict = {}
+
+ async def _fake_digest(fetcher_, store, names=None):
+ seen["db"] = Path(store.db_path)
+ return {"marker": "digest"}
+
+ monkeypatch.setattr(aoi, "fetch_aoi_digest", _fake_digest)
+ result = await aoi.fetch_aoi_sweep(fetcher)
+ assert result == {"marker": "digest"}
+ assert seen["db"] == Path(fetcher.cache.db_path)
+
+
+async def test_aoi_sweep_real_path_no_aois(fetcher) -> None:
+ """Real (unmocked-digest) path: no AOIs defined is the honest note,
+ not an error, and the wrapper leaves no store handle behind."""
+ result = await aoi.fetch_aoi_sweep(fetcher)
+ assert "error" not in result
+ assert result["count"] == 0
+ assert "No AOIs defined" in result["note"]
+
+
+async def test_aoi_sweep_sees_aois_defined_via_cache_db(
+ fetcher, monkeypatch: pytest.MonkeyPatch
+) -> None:
+ """AOIs defined through another store handle on the same cache DB
+ (as the MCP server or CLI would) are picked up by the sweep."""
+ _patch_all_domains(monkeypatch)
+ s = AOIStore(fetcher.cache.db_path)
+ aoi.define_aoi(s, "Pittsburgh", _PGH_LAT, _PGH_LON, _PGH_RADIUS_KM)
+ s.close()
+
+ result = await aoi.fetch_aoi_sweep(fetcher)
+ assert result["count"] == 1
+ assert result["aois"][0]["name"] == "Pittsburgh"
+ assert result["aois"][0]["baseline"] is True
diff --git a/src/world_intel_mcp/tests/test_collector.py b/src/world_intel_mcp/tests/test_collector.py
index d634819..b7d7391 100644
--- a/src/world_intel_mcp/tests/test_collector.py
+++ b/src/world_intel_mcp/tests/test_collector.py
@@ -13,8 +13,8 @@ from world_intel_mcp import collector
def test_sources_count_matches_docs() -> None:
- # CLAUDE.md and the collector docstring both say 50; measured here.
- assert len(collector.SOURCES) == 50
+ # CLAUDE.md says 51; measured here.
+ assert len(collector.SOURCES) == 51
def test_source_names_unique() -> None:
@@ -53,3 +53,21 @@ def test_every_source_kwarg_is_accepted_by_its_function() -> None:
assert kw in sig.parameters, (
f"{name}: {module_path}.{fn_name} does not accept kwarg {kw!r}"
)
+
+
+def test_aoi_sweep_is_a_collector_source() -> None:
+ """Phase 27: the scheduled AOI sweep rides the collector daemon.
+ ``aoi_digest`` must reference the fetcher-only sweep wrapper (the
+ digest itself needs a store argument the collector can't supply)
+ and be reachable via the ``aoi`` domain group."""
+ entries = {name: (mod, fn) for name, mod, fn, _ in collector.SOURCES}
+ assert entries["aoi_digest"] == ("analysis.aoi", "fetch_aoi_sweep")
+ assert collector.DOMAIN_GROUPS["aoi"] == ["aoi_digest"]
+
+
+def test_aoi_sweep_has_extended_timeout() -> None:
+ """Measured 2026-09-01: a single 50 km AOI sweep on a cold cache
+ exceeded the flat 45 s per-source budget (the digest fans out to
+ ~8 domains per AOI, several rate-floored). The override map must
+ give aoi_digest a real budget."""
+ assert collector.SOURCE_TIMEOUTS["aoi_digest"] >= 120.0
diff --git a/src/world_intel_mcp/tests/test_collector_runtime.py b/src/world_intel_mcp/tests/test_collector_runtime.py
index 3fc53b6..55b30ba 100644
--- a/src/world_intel_mcp/tests/test_collector_runtime.py
+++ b/src/world_intel_mcp/tests/test_collector_runtime.py
@@ -429,3 +429,27 @@ def test_main_daemon_flag_forwards_interval_and_sources(
collector.main() # daemon branch returns without SystemExit
assert seen == {"interval": 60, "source_filter": "markets"}
+
+
+async def test_collect_once_honors_per_source_timeout(
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ """A SOURCE_TIMEOUTS override must actually reach asyncio.wait_for —
+ a slow source with a short override times out even though the
+ default budget would have let it finish."""
+ import asyncio as _asyncio
+
+ async def _slow(fetcher, **kwargs):
+ await _asyncio.sleep(0.3)
+ return {"ok": True}
+
+ monkeypatch.setattr(
+ collector, "SOURCES", [("slowpoke", "sources.markets", "fetch_market_quotes", {})]
+ )
+ monkeypatch.setattr(collector, "SOURCE_TIMEOUTS", {"slowpoke": 0.05})
+ monkeypatch.setattr(collector, "_import_fetch_fn", lambda m, f: _slow)
+
+ store = FakeVectorStore()
+ summary = await collector.collect_once(FakeFetcher(), store, timeout=45.0)
+ assert summary["failures"] == 1
+ assert any("timeout (0.05s)" in e for e in summary["errors"])