fix(小宝预警): 稳定AI建议缓存签名
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
||||
buildRiskInterpretRequest,
|
||||
findLatestRiskInsightForVersion,
|
||||
findPreviousRiskSnapshot,
|
||||
getReusableInsight,
|
||||
shouldRequestRiskInsight,
|
||||
shouldRequestRiskInsightWithCacheGate,
|
||||
shouldRequestRiskInsightWithCooldown,
|
||||
@@ -328,6 +329,38 @@ test('buildRiskInsightSignature changes when trend direction delta or activity m
|
||||
assert.notEqual(base, changed);
|
||||
});
|
||||
|
||||
test('buildRiskInsightSignature stays stable when only volatile same-day forecast timing changes', () => {
|
||||
const base = buildRiskInsightSignature(risk({
|
||||
forecastReleaseDate: '2026-07-14T03:06:58.211Z',
|
||||
signals: { ...risk().signals, daysToExpectedRelease: 30.9 },
|
||||
}));
|
||||
const changed = buildRiskInsightSignature(risk({
|
||||
forecastReleaseDate: '2026-07-14T03:37:15.903Z',
|
||||
signals: { ...risk().signals, daysToExpectedRelease: 30.1 },
|
||||
}));
|
||||
|
||||
assert.equal(base, changed);
|
||||
});
|
||||
|
||||
test('getReusableInsight reuses legacy signatures with volatile forecast timestamps', () => {
|
||||
const current = risk({
|
||||
forecastReleaseDate: '2026-07-14T03:37:15.903Z',
|
||||
signals: { ...risk().signals, daysToExpectedRelease: 30.1 },
|
||||
});
|
||||
const legacy = insight({
|
||||
riskSignature: JSON.stringify({
|
||||
...JSON.parse(buildRiskInsightSignature(current)),
|
||||
forecastReleaseDate: '2026-07-14T03:06:58.211Z',
|
||||
signals: {
|
||||
...current.signals,
|
||||
daysToExpectedRelease: 30.9,
|
||||
},
|
||||
}),
|
||||
});
|
||||
|
||||
assert.equal(getReusableInsight([legacy], current)?.insight.summary, legacy.insight.summary);
|
||||
});
|
||||
|
||||
test('buildRiskInterpretRequest compresses frontend risk evidence for the backend AI contract', () => {
|
||||
const payload = buildRiskInterpretRequest(risk());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user