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.

Research panels: unmeasurable change is said so; a kept copy's age is measured to now (review r2 behavior F2, F7)

Phoenix Agent (mac-studio)1268e33c55c3
diff --git a/src/world_intel_mcp/dashboard/index.html b/src/world_intel_mcp/dashboard/index.html
index 15b92f7..66a0c71 100644
--- a/src/world_intel_mcp/dashboard/index.html
+++ b/src/world_intel_mcp/dashboard/index.html
@@ -3807,6 +3807,19 @@ function rCoverage(d) {
function rFailedNews(d) {
return (d.reason ? '<div class="rs-note">Reason: ' + rEsc(d.reason) + '</div>' : '') + rCoverage(d) + rGaps(d);
}
+// Change is counted only over feeds whose history reaches back to the
+// prior window's start. With none (common for 7 d: the prior window starts
+// 14 d back), change cannot be measured, which is not a change of zero.
+function rNoComparable(d) {
+ var c = d.coverage && typeof d.coverage === 'object' ? d.coverage : null;
+ return !!c && c.feeds_comparable === 0;
+}
+function rNoComparableBanner(d, what) {
+ var win = d.window && typeof d.window === 'object' ? d.window : {};
+ var prior = win.prior && typeof win.prior === 'object' ? win.prior : {};
+ return '<div class="rs-banner warn">' + what + ' cannot be measured over this window: no feed keeps history back to ' +
+ rEsc(prior.start || 'the start of the prior window') + ', so no feed is comparable. This is not a finding that nothing changed.</div>';
+}
function rHeadline(item) {
item = item || {};
var meta = [item.outlet, item.published].concat(rArr(item.hostility).length ? ['hostility: ' + rArr(item.hostility).join(', ')] : []);
@@ -3815,7 +3828,12 @@ function rHeadline(item) {
function renderSituations(d, failed) {
if (failed) return rFailedNews(d);
var list = rArr(d.situations);
+ var noComp = rNoComparable(d);
var h = rCoverage(d);
+ if (noComp) {
+ h += rNoComparableBanner(d, 'Change against the prior window') +
+ (d.sort === 'change' ? '<div class="rs-note">Sorted by change, but no change is measurable, so the order is by article count.</div>' : '');
+ }
if (!list.length) {
h += '<div class="rs-banner info">No situation' + (d.kind && d.kind !== 'all' ? ' (' + rEsc(d.kind) + ')' : '') + ' reached ' +
rNum(d.min_articles, 0) + ' articles in this window, over the coverage stated above.</div>';
@@ -3829,8 +3847,9 @@ function renderSituations(d, failed) {
'<span class="rs-badge">' + rEsc(s.kind) + '</span></div>' +
'<div class="dim">' + rPlural(s.articles, 'article') + ' from ' + rPlural(s.outlet_count, 'outlet') + '; hostile ' + rNum(s.hostile_articles, 0) +
(typeof s.hostile_share === 'number' ? ' (' + rNum(s.hostile_share * 100, 0) + '%)' : '') + (catText ? ': ' + rEsc(catText) : '') +
- '; comparable feeds ' + rNum(s.current_comparable, 0) + ' now vs ' + rNum(s.prior, 0) + ' prior (change ' + rSigned(s.change, 0) +
- ', ratio ' + rNum(s.change_ratio, 3) + ')</div>' +
+ (noComp ? '; change not measurable (no comparable feed)' :
+ '; comparable feeds ' + rNum(s.current_comparable, 0) + ' now vs ' + rNum(s.prior, 0) + ' prior (change ' + rSigned(s.change, 0) +
+ ', ratio ' + rNum(s.change_ratio, 3) + ')') + '</div>' +
'<div class="rs-list">' + rArr(s.sample_headlines).map(rHeadline).join('') + '</div></div>';
});
return h + rNotes(d);
@@ -3851,7 +3870,9 @@ function renderTopStories(d, failed) {
'<div class="rs-list">' + rArr(s.items).map(rHeadline).join('') + '</div></div>';
});
h += '<div class="sub">Attention: named entities that grew against the prior window</div>';
- if (!att.length) {
+ if (rNoComparable(d)) {
+ h += rNoComparableBanner(d, 'Growth in mentions');
+ } else if (!att.length) {
h += '<div class="rs-banner info">No named country or organization grew against the prior window; only growth is listed.</div>';
} else {
h += '<table class="dtable"><thead><tr><th>Entity</th><th>Type</th><th>Now</th><th>Prior</th><th>Change</th><th>Ratio</th></tr></thead><tbody>' +
@@ -3939,8 +3960,9 @@ function rMarked(d) {
// A panel never shows figures it has not received: before the first answer
// it says so, a failure with no earlier copy shows the reason and the
// payload's diagnostics only, and a failed refresh keeps the earlier copy
-// under a banner naming the failure and when that copy was loaded.
-function renderResearch(name, st) {
+// under a banner naming the failure and when that copy was loaded. now
+// (ms) is the render time: a kept copy's age is stated against it.
+function renderResearch(name, st, now) {
var render = RESEARCH_RENDERERS[name];
if (!render) return '<div class="rs-banner err">Unknown panel: ' + rEsc(name) + '</div>';
if (!st || (!st.lastAttempt && !st.inFlight)) {
@@ -3957,10 +3979,14 @@ function renderResearch(name, st) {
'<br><span class="dim">Attempted ' + rClock(a.at) + '. Nothing has loaded for this query, so no figures are shown.</span></div>' +
(st.inFlight ? '<div class="rs-note">Retrying: request sent ' + rClock(st.requestedAt) + '.</div>' : '') + render(diag, true);
}
+ var hasNow = typeof now === 'number' && isFinite(now);
var head = a.error
? '<div class="rs-banner warn"><span class="rs-badge warn">REFRESH FAILED</span> ' + rEsc(status + a.error) + ' (' + rClock(a.at) + ').<br>' +
- 'Showing the copy loaded ' + rClock(g.at) + ', ' + rAge((a.at - g.at) / 1000) + ' before that attempt.</div>'
- : '<div class="rs-note">Loaded ' + rClock(g.at) + '; refreshes every ' + RESEARCH_REFRESH_MS / 1000 + ' s while this panel is open.</div>';
+ 'Showing the copy loaded ' + rClock(g.at) + ', ' + rAge((a.at - g.at) / 1000) + ' before that attempt.' +
+ (hasNow ? ' That copy is ' + rAge((now - g.at) / 1000) + ' old now.' : '') + '</div>'
+ : '<div class="rs-note">Loaded ' + rClock(g.at) +
+ (hasNow && now - g.at > 2 * RESEARCH_REFRESH_MS ? ', ' + rAge((now - g.at) / 1000) + ' ago' : '') +
+ '; refreshes every ' + RESEARCH_REFRESH_MS / 1000 + ' s while this panel is open.</div>';
if (st.inFlight) head += '<div class="rs-note">Refreshing: request sent ' + rClock(st.requestedAt) + '.</div>';
return head + rMarked(g.data) + render(g.data, false);
}
@@ -3988,7 +4014,7 @@ function researchRender() {
var name = researchActive, html;
$$('.rs-tab').forEach(function(b) { b.classList.toggle('active', b.getAttribute('data-rs-tab') === name); });
$$('.rs-ctl').forEach(function(c) { c.classList.toggle('on', c.getAttribute('data-rs-for') === name); });
- try { html = renderResearch(name, researchState[name]); }
+ try { html = renderResearch(name, researchState[name], Date.now()); }
catch (e) {
console.error('research panel render failed:', e);
html = '<div class="rs-banner err">This panel failed to render: ' + rEsc(String(e)) + '</div>';
diff --git a/src/world_intel_mcp/tests/test_dashboard_research.py b/src/world_intel_mcp/tests/test_dashboard_research.py
index 8c3a1da..65bf1f7 100644
--- a/src/world_intel_mcp/tests/test_dashboard_research.py
+++ b/src/world_intel_mcp/tests/test_dashboard_research.py
@@ -889,6 +889,56 @@ def test_failed_refresh_keeps_the_earlier_copy_and_says_how_old(tmp_path) -> Non
assert "Israel and Iran trade warnings" in m.text
+def test_kept_copy_age_is_measured_to_now(tmp_path) -> None:
+ """Reopened an hour after a failed refresh: the banner states how old
+ the copy is now, not only how old it was at the failed attempt; an
+ old loaded copy says how long ago it loaded."""
+ st = {
+ "lastAttempt": {"at": _T_MS + 61_000, "http": 503, "data": {"error": "boom"}, "error": "boom"},
+ "lastGood": {"at": _T_MS, "http": 200, "data": _SITUATIONS, "error": None},
+ }
+ hour_later = _T_MS + 3_720_000
+ failed_now, old_loaded, fresh_loaded = _js(tmp_path, [
+ ["renderResearch", "situations", st, hour_later],
+ ["renderResearch", "situations", _loaded(_SITUATIONS), hour_later],
+ ["renderResearch", "situations", _loaded(_SITUATIONS), _T_MS + 30_000],
+ ])
+ text = _Markup(failed_now).text
+ assert f"Showing the copy loaded {_CLOCK}, 61 s before that attempt. That copy is 62 min old now." in text
+ assert f"Loaded {_CLOCK}, 62 min ago; refreshes every 60 s" in _Markup(old_loaded).text
+ assert f"Loaded {_CLOCK}; refreshes every 60 s" in _Markup(fresh_loaded).text
+
+
+def test_no_comparable_feed_reads_as_not_measurable_never_as_no_growth(tmp_path) -> None:
+ """7 d window: the prior window starts 14 d back and no feed keeps that
+ much history, so feeds_comparable is 0 and the function reports change 0
+ and no attention. The panels say change cannot be measured."""
+ coverage = {**_COVERAGE, "feeds_comparable": 0, "items_current_window_comparable": 0}
+ window = {"hours": 168.0, "current": {"start": "2026-10-10T19:04:08Z", "end": "2026-10-17T19:04:08Z"},
+ "prior": {"start": "2026-10-03T19:04:08Z", "end": "2026-10-10T19:04:08Z"}}
+ sit = copy.deepcopy(_SITUATIONS)
+ sit.update(coverage=coverage, window=window, sort="change")
+ sit["situations"][0].update(current_comparable=0, prior=0, change=0, change_ratio=1.0)
+ top = {**_TOP, "attention": [], "coverage": coverage, "window": window}
+ html_sit, html_top, html_sit_ok = _js(tmp_path, [
+ ["renderResearch", "situations", _loaded(sit)],
+ ["renderResearch", "stories", _loaded(top)],
+ ["renderResearch", "situations", _loaded(_SITUATIONS)],
+ ])
+ s = _assert_inert(html_sit).text
+ assert ("Change against the prior window cannot be measured over this window: no feed keeps history back to "
+ "2026-10-03T19:04:08Z, so no feed is comparable. This is not a finding that nothing changed.") in s
+ assert "Sorted by change, but no change is measurable, so the order is by article count." in s
+ assert "change not measurable (no comparable feed)" in s
+ assert "(change 0" not in s and "ratio 1" not in s
+ t = _assert_inert(html_top).text
+ assert "Growth in mentions cannot be measured over this window" in t
+ assert "grew against the prior window;" not in t and "No named country" not in t
+ ok = _Markup(html_sit_ok).text # comparable feeds: change shown as measured
+ assert "comparable feeds 9 now vs 4 prior (change +5, ratio 2)" in ok
+ assert "cannot be measured" not in ok
+
+
def test_empty_result_states_its_threshold_and_coverage(tmp_path) -> None:
sit, top = _js(tmp_path, [
["renderResearch", "situations", _loaded({**_SITUATIONS, "situations": [], "count": 0})],