45 lines
1.4 KiB
JavaScript
45 lines
1.4 KiB
JavaScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { mkdtempSync, rmSync } from 'node:fs';
|
|
import { tmpdir } from 'node:os';
|
|
import { join } from 'node:path';
|
|
import { IntelligenceStore } from '../lib/intelligence-store.mjs';
|
|
|
|
test('records LLM ideas as stable predictions', async (t) => {
|
|
const directory = mkdtempSync(join(tmpdir(), 'intelligence-store-'));
|
|
t.after(() => rmSync(directory, { recursive: true, force: true }));
|
|
|
|
const store = await new IntelligenceStore(join(directory, 'intelligence.db')).init();
|
|
if (!store.available) {
|
|
t.skip(`node:sqlite unavailable: ${store.reason}`);
|
|
return;
|
|
}
|
|
|
|
store.recordRun({
|
|
meta: {
|
|
timestamp: '2026-07-04T10:17:51.011Z',
|
|
sourcesOk: 22,
|
|
sourcesDegraded: 7,
|
|
sourcesFailed: 0,
|
|
},
|
|
ideasSource: 'llm',
|
|
ideas: [{
|
|
title: 'Gold safe-haven hedge',
|
|
type: 'HEDGE',
|
|
ticker: 'GLD',
|
|
confidence: 'MEDIUM',
|
|
rationale: 'Geopolitical risk remains elevated.',
|
|
risk: 'Risk appetite recovers.',
|
|
horizon: 'Weeks',
|
|
signals: ['geopolitical escalation'],
|
|
source: 'llm',
|
|
}],
|
|
}, { summary: { direction: 'risk-off' } });
|
|
|
|
const result = store.listPredictions({ limit: 10 });
|
|
assert.equal(result.available, true);
|
|
assert.equal(result.predictions.length, 1);
|
|
assert.equal(result.predictions[0].title, 'Gold safe-haven hedge');
|
|
assert.match(result.predictions[0].stable_id, /^[a-f0-9]{24}$/);
|
|
});
|