Files
worldmonitor/tests/regulatory-contract.test.mjs
Elie Habib f210c5511a feat(regulatory): add tier classification and Redis publish (#2691)
* feat(regulatory): add tier classification and Redis publish

Builds on the fetch/parse layer from #2564. Adds keyword-based tier
classification (high/medium/low/unknown) and publishes to Redis via
runSeed with 6h TTL.

- HIGH: enforcement, fraud, penalty, injunction, etc.
- MEDIUM: rulemaking, guidance, investigation, etc.
- LOW: routine notices matching title patterns
- Register REGULATORY_ACTIONS_KEY in cache-keys.ts

Closes #2493

Co-authored-by: Lucas Passos <lspassos1@users.noreply.github.com>

* fix(regulatory): reject empty payloads, add health monitoring

- validateFn now requires actions.length > 0 to prevent overwriting
  a healthy snapshot with an empty one on parser regression
- Register regulatory:actions:v1 in STANDALONE_KEYS (api/health.js)
- Add seed-meta:regulatory:actions to SEED_META (maxStaleMin: 360,
  3x the 2h cron interval)
- Add seed-health.js monitoring (intervalMin: 120)

---------

Co-authored-by: Lucas Passos <lspassos1@users.noreply.github.com>
2026-04-04 23:19:33 +04:00

19 lines
641 B
JavaScript

import { describe, it } from 'node:test';
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
const __dirname = dirname(fileURLToPath(import.meta.url));
const root = join(__dirname, '..');
describe('regulatory cache contracts', () => {
it('exports REGULATORY_ACTIONS_KEY from cache-keys.ts', () => {
const cacheKeysSrc = readFileSync(join(root, 'server', '_shared', 'cache-keys.ts'), 'utf8');
assert.match(
cacheKeysSrc,
/export const REGULATORY_ACTIONS_KEY = 'regulatory:actions:v1';/
);
});
});