fix(小宝预警): 稳定风险证据与建议更新
关键改动: - 优化风险证据的日报工时与静默风险计算 - 稳定 AI 触发签名,避免证据细节变化造成重复请求 - 调整预警建议更新状态与相关测试 Co-Authored-By: Codex GPT-5 <codex@openai.com>
This commit is contained in:
@@ -429,6 +429,65 @@ test('getReusableInsight keeps showing cached insight when only refresh-volatile
|
||||
);
|
||||
});
|
||||
|
||||
test('getReusableInsight keeps cached insight when only daily report evidence details change', () => {
|
||||
const cachedRisk = risk({
|
||||
riskLevel: 'at_risk',
|
||||
riskScore: 82,
|
||||
confidence: 70,
|
||||
signals: { ...risk().signals, failedTestCount: 2, silentRiskCount: 1, daysToExpectedRelease: 1 },
|
||||
dailyEvidence: {
|
||||
todayDeliveries: [],
|
||||
todayProgress: [
|
||||
{ id: 'ev-old', title: 'Progress', summary: 'Worked on checkout flow.', occurredAt: '2026-06-30T03:00:00.000Z' },
|
||||
],
|
||||
todayCreations: [],
|
||||
todayRisks: [],
|
||||
progressNotes: [],
|
||||
needsProgressItems: [],
|
||||
recentActivityCount: 2,
|
||||
totalActivityCount: 1,
|
||||
todayActualHours: 1,
|
||||
lastActivityAt: '2026-06-30T03:00:00.000Z',
|
||||
},
|
||||
currentSnapshot: snapshot({ riskScore: 82, failedTestCount: 2, silentRiskCount: 1 }),
|
||||
});
|
||||
const current = risk({
|
||||
riskLevel: 'at_risk',
|
||||
riskScore: 82,
|
||||
confidence: 70,
|
||||
signals: { ...risk().signals, failedTestCount: 2, silentRiskCount: 1, daysToExpectedRelease: 1 },
|
||||
dailyEvidence: {
|
||||
todayDeliveries: [],
|
||||
todayProgress: [
|
||||
{ id: 'ev-new', title: 'Progress', summary: 'Updated checkout flow and added handoff notes.', occurredAt: '2026-07-01T04:00:00.000Z' },
|
||||
{ id: 'ev-new-2', title: 'Progress', summary: 'Confirmed QA scope.', occurredAt: '2026-07-01T05:00:00.000Z' },
|
||||
],
|
||||
todayCreations: [],
|
||||
todayRisks: [],
|
||||
progressNotes: [
|
||||
{ id: 'note-new', title: 'Note', summary: 'Next work starts tomorrow morning.', occurredAt: '2026-07-01T06:00:00.000Z' },
|
||||
],
|
||||
needsProgressItems: [],
|
||||
recentActivityCount: 6,
|
||||
totalActivityCount: 3,
|
||||
todayActualHours: 4,
|
||||
lastActivityAt: '2026-07-01T06:00:00.000Z',
|
||||
},
|
||||
currentSnapshot: snapshot({ riskScore: 82, failedTestCount: 2, silentRiskCount: 1 }),
|
||||
});
|
||||
const cached = insight({
|
||||
riskSignature: buildRiskInsightSignature(cachedRisk),
|
||||
insight: { ...insight().insight, summary: 'Cached advice should remain visible.' },
|
||||
generatedAt: '2026-06-30T08:00:00.000Z',
|
||||
});
|
||||
|
||||
assert.equal(getReusableInsight([cached], current)?.insight.summary, 'Cached advice should remain visible.');
|
||||
assert.equal(
|
||||
shouldRequestRiskInsightWithCacheGate(true, [cached], current, snapshot({ riskScore: 70 }), new Date('2026-07-01T09:00:00.000Z')),
|
||||
false,
|
||||
);
|
||||
});
|
||||
|
||||
test('getReusableInsight does not reuse cached insight when core risk facts change', () => {
|
||||
const cachedRisk = risk({
|
||||
riskLevel: 'likely_delayed',
|
||||
|
||||
Reference in New Issue
Block a user