라우터 7 동기 갱신 복구와 E2E 격리 수정, 검증 기록 동기화
Some checks failed
API contract / OpenAPI type drift (push) Failing after 3m30s

This commit is contained in:
Yun Chan 2026-10-24 21:55:17 +09:00
parent d801a1619d
commit b0ff44a1d4
9 changed files with 236 additions and 154 deletions

View file

@ -10,6 +10,10 @@ import { expect, test, type APIResponse, type Page } from "@playwright/test";
import {
acquireGlobalEngineConfigLock,
completeAlliancePreCheckpoint,
installControlledEngineConfig,
readEngineConfigSnapshot,
restoreEngineConfig,
type EngineConfigSnapshot,
} from "./support";
const API_PORT = 8018;
@ -29,15 +33,6 @@ interface ManagedServer {
requests: () => string[];
}
interface EngineConfigSnapshot {
engine_mode: string;
engine_url: string;
model: string;
reasoning_effort: string | null;
updated_by: string | null;
updated_at: string | null;
}
interface AdminEngineConfigResponse {
engine_mode: string;
engine_url: string;
@ -348,6 +343,8 @@ async function startApi(engineUrl: string): Promise<ManagedProcess> {
ENGINE_URL: engineUrl,
ENGINE_MODE: "claude_api",
VIGNETTE_LIVE_CLIENT_PROVIDER: "claude_api",
// apps/api/.env의 jev가 상속되면 가짜 엔진 호출 전에 OpenRouter 외부 호출이 끼어든다.
VIGNETTE_CLIENT_AFFECT_PROVIDER: "legacy",
ENGINE_TIMEOUT: "20",
ENGINE_CONNECT_TIMEOUT: "2",
EVALUATOR_SEMANTIC_CACHE_ENABLED: "false",
@ -447,86 +444,6 @@ function runPsql(sql: string): string {
return String(result.stdout).trim();
}
function sqlTextValue(value: string | null): string {
return value === null ? "NULL" : `'${value.replaceAll("'", "''")}'`;
}
function readEngineConfigSnapshot(): EngineConfigSnapshot | null {
const raw = runPsql(`
SELECT COALESCE(
(
SELECT json_build_object(
'engine_mode', engine_mode,
'engine_url', engine_url,
'model', model,
'reasoning_effort', reasoning_effort,
'updated_by', updated_by,
'updated_at', updated_at
)::text
FROM app.admin_engine_config
WHERE id = TRUE
),
'null'
);
`);
return raw === "null" ? null : (JSON.parse(raw) as EngineConfigSnapshot);
}
function installControlledEngineConfig(engineUrl: string): void {
runPsql(`
INSERT INTO app.admin_engine_config (
id, engine_mode, engine_url, model, reasoning_effort, updated_by, updated_at
)
VALUES (
TRUE, 'claude_api', ${sqlTextValue(engineUrl)}, 'req005-controlled', 'medium',
'req005-e2e', now()
)
ON CONFLICT (id) DO UPDATE SET
engine_mode = EXCLUDED.engine_mode,
engine_url = EXCLUDED.engine_url,
model = EXCLUDED.model,
reasoning_effort = EXCLUDED.reasoning_effort,
updated_by = EXCLUDED.updated_by,
updated_at = EXCLUDED.updated_at;
`);
expect(readEngineConfigSnapshot()).toMatchObject({
engine_mode: "claude_api",
engine_url: engineUrl,
model: "req005-controlled",
reasoning_effort: "medium",
updated_by: "req005-e2e",
});
}
function restoreEngineConfig(snapshot: EngineConfigSnapshot | null): void {
if (snapshot === null) {
runPsql("DELETE FROM app.admin_engine_config WHERE id = TRUE;");
} else {
runPsql(`
INSERT INTO app.admin_engine_config (
id, engine_mode, engine_url, model, reasoning_effort, updated_by, updated_at
)
VALUES (
TRUE,
${sqlTextValue(snapshot.engine_mode)},
${sqlTextValue(snapshot.engine_url)},
${sqlTextValue(snapshot.model)},
${sqlTextValue(snapshot.reasoning_effort)},
${sqlTextValue(snapshot.updated_by)},
${sqlTextValue(snapshot.updated_at)}::timestamptz
)
ON CONFLICT (id) DO UPDATE SET
engine_mode = EXCLUDED.engine_mode,
engine_url = EXCLUDED.engine_url,
model = EXCLUDED.model,
reasoning_effort = EXCLUDED.reasoning_effort,
updated_by = EXCLUDED.updated_by,
updated_at = EXCLUDED.updated_at;
`);
}
expect(readEngineConfigSnapshot()).toEqual(snapshot);
}
function sqlUuidArray(values: Iterable<string>): string {
const rows = [...values];
return rows.length ? `ARRAY[${rows.map((value) => `'${value}'::uuid`).join(",")}]` : "ARRAY[]::uuid[]";
@ -703,7 +620,12 @@ test.describe("real PostgreSQL persona and protocol lifecycle", () => {
engineConfigSnapshot = readEngineConfigSnapshot();
engineConfigSnapshotCaptured = true;
engine = await startControlledEngine();
installControlledEngineConfig(engine.url);
installControlledEngineConfig({
engineUrl: engine.url,
model: "req005-controlled",
reasoningEffort: "medium",
updatedBy: "req005-e2e",
});
api = await startApi(engine.url);
const bootstrapEmail = `req005-engine-bootstrap-${Date.now()}@twentyoz.kr`;
@ -998,6 +920,10 @@ test.describe("real PostgreSQL persona and protocol lifecycle", () => {
const streamResponse = await streamResponsePromise;
await expectOk(streamResponse);
expect(streamResponse.headers()["content-type"] ?? "").toContain("text/event-stream");
// SSE 헤더가 본문 생성기보다 먼저 오는 경쟁이 있어 단발 확인 대신 폴링한다.
await expect
.poll(() => (engine?.requests() ?? []).some((request) => request.startsWith("POST /v1/stream")))
.toBe(true);
const engineRequests = engine?.requests() ?? [];
const streamDiagnostics = [
`engine=${engineRequests.join(" | ") || "<none>"}`,
@ -1007,10 +933,6 @@ test.describe("real PostgreSQL persona and protocol lifecycle", () => {
body: streamDiagnostics,
contentType: "text/plain; charset=utf-8",
});
expect(
engineRequests.some((request) => request.startsWith("POST /v1/stream")),
streamDiagnostics,
).toBe(true);
await expect(page.locator(".sx-utt").filter({ hasText: learnerText })).toBeVisible();
await expect(page.locator(".sx-utt.is-client").last()).toContainText(
"조금 더 말해볼 수 있을 것 같아요.",