perf(ai-moderation): dual-key write-back — clean verdict ikut di-cache global

Analisis pertama tetap berkonteks (chat history) demi akurasi, tapi
verdict clean non-actionable (conf>=0.85) juga ditulis di bare key
tanpa konteks. Repeat teks sama di channel lain -> exact cache HIT,
bukan LLM call baru. Guard sama dgn read path; dedupe LRU per proses;
bare row tanpa embedding (tier semantic sudah global).
This commit is contained in:
asepharyana committed 2026-08-24 20:18:14 +07:00
1 parent 1accfd9390
commit ccf3fa260e
3 files changed
+58 -11

No files matched your search

@@ -157,4 +157,13 @@ describe("isGloballyReusableCleanVerdict", () => {
it("skips the age check when analyzedAt is unknown", () => {
expect(isGloballyReusableCleanVerdict(makeVerdict(), undefined)).toBe(true);
});
it("rejects non-standard statuses such as processing write-backs", () => {
expect(
isGloballyReusableCleanVerdict(
{ ...makeVerdict(), status: "processing" },
undefined,
),
).toBe(false);
});
});