audit(gateway): fix dead /metrics endpoint, raise OOM-prone MemoryMax, trim DB pool
- gateway-metrics: collectors now run per scrape so Prometheus sees real data (process memory/uptime + live AI-analysis pipeline gauges) instead of an always-empty stub. bootstrap registers the pipeline collectors. - systemd: MemoryMax 512M -> 1G (live RSS ~500MiB, peak 508MiB; 512M left ~2% headroom and risked an OOM-kill restart; host has 8GB free). - config: POSTGRES_POOL_MIN 2 -> 0 so main + 4 Piscina worker threads don't hold ~10 permanently-open idle pg connections against PgBouncer. - docs: rewrite stale ARCHITECTURE.md / MODULE_STRUCTURE.md (winston -> pino, removed mock-crc/indonesianTextNormalizer, renamed aiAnalysisWorker/llmModerationClient). Verified: tsc clean, 129 vitest pass, biome clean on changed files. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
6244e307a3
commit
d2e97ae11d
@@ -15,7 +15,7 @@ import { makeImageCacheKey } from "../src/modules/ai-moderation/textCacheStore.j
|
||||
|
||||
function oldBuggyHash(dataUrl: string): string {
|
||||
const prefix = dataUrl.slice(0, 128);
|
||||
return "image:" + createHash("sha256").update(prefix).digest("hex").slice(0, 16);
|
||||
return `image:${createHash("sha256").update(prefix).digest("hex").slice(0, 16)}`;
|
||||
}
|
||||
|
||||
describe("makeImageCacheKey — collision prevention", () => {
|
||||
@@ -27,8 +27,8 @@ describe("makeImageCacheKey — collision prevention", () => {
|
||||
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==" +
|
||||
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // pad to >128 chars
|
||||
|
||||
const imgA = sharedPrefix + "UNIQUE_TO_A";
|
||||
const imgB = sharedPrefix + "UNIQUE_TO_B";
|
||||
const imgA = `${sharedPrefix}UNIQUE_TO_A`;
|
||||
const imgB = `${sharedPrefix}UNIQUE_TO_B`;
|
||||
|
||||
// Under the OLD buggy scheme: same prefix → same hash → COLLISION
|
||||
expect(oldBuggyHash(imgA)).toBe(oldBuggyHash(imgB));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import sharp from "sharp";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { resizeImageForVision } from "../src/modules/attachment-upload/imageResizer.js";
|
||||
|
||||
// Build a worst-case (poorly-compressing) 1024x1024 image, like a real photo.
|
||||
|
||||
@@ -11,7 +11,9 @@ const baseOpts = {
|
||||
describe("buildLlmParams — disable-thinking injection", () => {
|
||||
it("injects no thinking-disabling params when disableThinking is false", () => {
|
||||
const params = buildLlmParams(baseOpts, false);
|
||||
expect((params as Record<string, unknown>).reasoning_effort).toBeUndefined();
|
||||
expect(
|
||||
(params as Record<string, unknown>).reasoning_effort,
|
||||
).toBeUndefined();
|
||||
expect((params as Record<string, unknown>).reasoning).toBeUndefined();
|
||||
expect(
|
||||
(params as Record<string, unknown>).chat_template_kwargs,
|
||||
@@ -40,9 +42,9 @@ describe("buildLlmParams — disable-thinking injection", () => {
|
||||
expect(params.stream).toBe(true);
|
||||
expect(params.response_format).toEqual({ type: "json_object" });
|
||||
// thinking-disabled params still present
|
||||
expect(
|
||||
(params as Record<string, unknown>).chat_template_kwargs,
|
||||
).toEqual({ enable_thinking: false });
|
||||
expect((params as Record<string, unknown>).chat_template_kwargs).toEqual({
|
||||
enable_thinking: false,
|
||||
});
|
||||
});
|
||||
|
||||
it("falls back to config default model when none supplied", () => {
|
||||
|
||||
Reference in New Issue
Block a user