mirror of
https://github.com/koala73/worldmonitor.git
synced 2026-04-25 17:14:57 +02:00
* feat(resilience): recovery capacity pillar — 6 new dimensions + 5 seeders (Phase 2 T2.2b) Add the recovery-capacity pillar with 6 new dimensions: - fiscalSpace: IMF GGR_G01_GDP_PT + GGXCNL_G01_GDP_PT + GGXWDG_NGDP_PT - reserveAdequacy: World Bank FI.RES.TOTL.MO - externalDebtCoverage: WB DT.DOD.DSTC.CD / FI.RES.TOTL.CD ratio - importConcentration: UN Comtrade HHI (stub seeder) - stateContinuity: derived from WGI + UCDP + displacement (no new fetch) - fuelStockDays: IEA/EIA (stub seeder, Enrichment tier) Each dimension has a scorer in _dimension-scorers.ts, registry entries in _indicator-registry.ts, methodology doc subsections, and fixture data. Seeders: fiscal-space (real, IMF WEO), reserve-adequacy (real, WB API), external-debt (real, WB API), import-hhi (stub), fuel-stocks (stub). Recovery domain weight is 0 until PR 4 (T2.3) ships the penalized weighted mean across pillars. The domain appears in responses structurally but does not affect the overall score. Bootstrap: STANDALONE_KEYS + SEED_META + EMPTY_DATA_OK_KEYS + ON_DEMAND_KEYS all updated in api/health.js. Source-failure mapping updated for stateContinuity (WGI adapter). Widget labels and LOCKED_PREVIEW updated. All 282 resilience tests pass, typecheck clean, methodology lint clean. * fix(resilience): ISO3→ISO2 normalization in WB recovery seeders (#2987 P1) Both seed-recovery-reserve-adequacy.mjs and seed-recovery-external-debt.mjs used countryiso3code from the World Bank API response then immediately rejected codes where length !== 2. WB returns ISO3 codes (USA, DEU, etc.), so all real rows were silently dropped and the feed was always empty. Fix: import scripts/shared/iso3-to-iso2.json and normalize before the length check. Also removed from EMPTY_DATA_OK_KEYS in health.js since empty results now indicate a real failure, not a structural absence. * fix(resilience): remove unused import + no-op overrides (#2987 review) * fix(test): update release-gate to expect 6 domains after recovery pillar
89 lines
3.7 KiB
TypeScript
89 lines
3.7 KiB
TypeScript
import assert from 'node:assert/strict';
|
|
import { describe, it } from 'node:test';
|
|
|
|
import { INDICATOR_REGISTRY } from '../server/worldmonitor/resilience/v1/_indicator-registry.ts';
|
|
|
|
const CORE_MIN_COVERAGE = 180;
|
|
|
|
describe('signal tiering registry (Phase 2 T2.2a)', () => {
|
|
it('every indicator has tier, coverage, license populated', () => {
|
|
for (const entry of INDICATOR_REGISTRY) {
|
|
assert.ok(
|
|
entry.tier === 'core' || entry.tier === 'enrichment' || entry.tier === 'experimental',
|
|
`${entry.id} missing or invalid tier`,
|
|
);
|
|
assert.ok(
|
|
Number.isFinite(entry.coverage) && entry.coverage > 0,
|
|
`${entry.id} missing or non-positive coverage`,
|
|
);
|
|
assert.ok(
|
|
typeof entry.license === 'string' && entry.license.length > 0,
|
|
`${entry.id} missing license`,
|
|
);
|
|
}
|
|
});
|
|
|
|
it('Core indicators have coverage >= 180 countries (Phase 2 A4 invariant)', () => {
|
|
const offending = INDICATOR_REGISTRY
|
|
.filter((e) => e.tier === 'core' && e.coverage < CORE_MIN_COVERAGE)
|
|
.map((e) => `${e.id} (${e.coverage} countries, dimension=${e.dimension})`);
|
|
assert.deepEqual(
|
|
offending,
|
|
[],
|
|
`Core indicators must cover at least ${CORE_MIN_COVERAGE} countries. Demote to Enrichment or fix coverage: ${offending.join(', ')}`,
|
|
);
|
|
});
|
|
|
|
it('Core indicators use a license compatible with commercial use', () => {
|
|
const commercialOk = new Set(['public-domain', 'open-data', 'open-attribution']);
|
|
const offending = INDICATOR_REGISTRY
|
|
.filter((e) => e.tier === 'core' && !commercialOk.has(e.license))
|
|
.map((e) => `${e.id} (license=${e.license})`);
|
|
// Known exceptions the plan allows: GPI (IEP non-commercial, already
|
|
// demoted to Enrichment) and UCDP (research-only, kept Core because it
|
|
// is the canonical global conflict event source). These stay on the
|
|
// allowlist until the Phase 2 A9 Licensing & Legal Review workstream
|
|
// resolves carve-outs.
|
|
const KNOWN_EXCEPTIONS = new Set<string>([
|
|
// UCDP global conflict events: research-only license, kept Core per
|
|
// parent plan section "Signal tiering". Tracked in Phase 2 A9.
|
|
'ucdpConflict',
|
|
// UCDP reused in recovery-capacity stateContinuity dimension.
|
|
'recoveryConflictPressure',
|
|
]);
|
|
const unexcused = offending.filter((s) => {
|
|
const id = s.split(' ')[0];
|
|
return !KNOWN_EXCEPTIONS.has(id);
|
|
});
|
|
assert.deepEqual(
|
|
unexcused,
|
|
[],
|
|
`Core indicators with incompatible licenses must be demoted or added to KNOWN_EXCEPTIONS: ${unexcused.join(', ')}`,
|
|
);
|
|
});
|
|
|
|
it('informationCognitive dimension indicators are Enrichment (plan mandate, demoted until T2.9)', () => {
|
|
const infoCogIndicators = INDICATOR_REGISTRY.filter((e) => e.dimension === 'informationCognitive');
|
|
assert.ok(infoCogIndicators.length > 0, 'expected informationCognitive indicators in registry');
|
|
for (const e of infoCogIndicators) {
|
|
assert.equal(
|
|
e.tier,
|
|
'enrichment',
|
|
`${e.id}: informationCognitive indicators must be 'enrichment' until PR 9 / T2.9 lands the language normalization. See parent plan, "Signal tiering" section.`,
|
|
);
|
|
}
|
|
});
|
|
|
|
it('reports unknown-license count for the licensing audit workstream', () => {
|
|
const unknown = INDICATOR_REGISTRY.filter((e) => e.license === 'unknown');
|
|
// This is a visibility report, not a failure. Phase 2 A9 (Licensing &
|
|
// Legal Review) chases these.
|
|
if (unknown.length > 0) {
|
|
console.warn(
|
|
`[T2.2a] ${unknown.length} indicators have license='unknown': ${unknown.map((e) => e.id).join(', ')}`,
|
|
);
|
|
}
|
|
assert.ok(unknown.length < INDICATOR_REGISTRY.length, 'every indicator has unknown license');
|
|
});
|
|
});
|