Files
Jyotisha/frontend/tests/rescore-attempts-bound.test.ts
T
jesse-uxandGrok (agent loop) 4c3485bc23 服务器长跑不再堆积取消监听,数据库少走几趟。
报告工人的等待到点就摘掉取消监听。本地数据库缓存表结构,并把设置身份合成一条语句,对照通过后默认打开,写成 off 仍走原来的语句。交付、重算和限流的内存表会过期。登录读缓存默认关闭,要开再设 IDENTITY_SESSION_COOKIE_CACHE=on。

自测:tsc 通过,lint 0 error,点名测试 134 通过,test:db 开关关和开都只有已知的 13 条失败,往返 49 降到 32。

Co-Authored-By: Grok (agent loop)
2026-10-14 03:32:39 +08:00

32 lines
1.2 KiB
TypeScript

import assert from "node:assert/strict";
import test from "node:test";
import {
noteRescoreAttemptForTests,
rescoreAttemptCountForTests,
resetStaleMinuteRescoreAttemptsForTests,
} from "../src/lib/rectification-agentic/v9/block-scan-answer.ts";
const SIX_HOURS_MS = 6 * 60 * 60 * 1000;
test("rescore attempts stay within 5000 entries", () => {
resetStaleMinuteRescoreAttemptsForTests();
for (let index = 0; index < 5_001; index += 1) {
noteRescoreAttemptForTests(`case-${index}:turn:fingerprint`, 1_000);
}
assert.ok(rescoreAttemptCountForTests() <= 5_000);
resetStaleMinuteRescoreAttemptsForTests();
});
test("a rescore attempt older than six hours is dropped on the next write", () => {
resetStaleMinuteRescoreAttemptsForTests();
noteRescoreAttemptForTests("case-old:turn:fingerprint", 0);
noteRescoreAttemptForTests("case-fresh:turn:fingerprint", SIX_HOURS_MS);
assert.equal(rescoreAttemptCountForTests(), 2);
noteRescoreAttemptForTests("case-new:turn:fingerprint", SIX_HOURS_MS + 1);
assert.equal(rescoreAttemptCountForTests(), 2);
noteRescoreAttemptForTests("case-fresh:turn:fingerprint", SIX_HOURS_MS + 1);
assert.equal(rescoreAttemptCountForTests(), 2);
resetStaleMinuteRescoreAttemptsForTests();
});