세션 평가·라이브코치·교수자 분석 라운드 마감 + 문서 정리 + 코드품질 리팩터

- 누적 작업트리 커밋: 회기 평가 복구·durable 저장, 라이브 코치 이력/근거, 교수자 학생분석, 음성 비언어 메타, PII 마스킹, 운영 티켓/헬스 등
- 문서: 완료 기록 docs/archive/ 냉동 보관, docs/ 단일 인덱스(docs/README.md)+통합 TODO(docs/TODO.md)로 정리
- 리팩터(행위 보존): Stage enum SSOT(taxonomy 소유·state_machine re-export), store recent/masked_turns 중복 제거, speaker_ko_label 단일 헬퍼, _list_sessions N+1 제거(state/turns 배치 + 턴평가 하이드레이션 배치)
- 검증: 백엔드 pytest 352 passed, _list_sessions E2E chromium-single-run 2 passed
This commit is contained in:
Yun Chan 2026-07-02 02:50:36 +09:00
parent 7c41c3ce79
commit 778e8526d4
108 changed files with 6457 additions and 455 deletions

View file

@ -137,6 +137,7 @@ interface AdminTicketsResponse {
open_count: number;
high_priority_count: number;
stale_count: number;
by_category: Record<string, number>;
};
}
@ -146,6 +147,134 @@ async function expectResponseOk(response: APIResponse | Response) {
}
}
async function mockApprovedAdminWithoutOnboarding(page: Page) {
const seenAdminEndpoints = new Set<string>();
const json = (body: unknown) => JSON.stringify(body);
await page.route("**/api/**", async (route) => {
const request = route.request();
const url = new URL(request.url());
const method = request.method();
const path = url.pathname;
const fulfillJson = (body: unknown, status = 200) =>
route.fulfill({
status,
contentType: "application/json",
body: json(body),
});
if (method === "GET" && path.endsWith("/auth/me")) {
await fulfillJson({
user_id: "stale-admin",
email: "stale-admin@twentyoz.kr",
display_name: "Stale Admin",
role: "admin",
admin_access: false,
super_admin: false,
account_status: "approved",
approval_required: false,
cohort_ids: [],
consent_at: null,
onboarding_completed_at: null,
nickname: "",
self_introduction: "",
avatar_url: "",
});
return;
}
if (method === "GET" && path.endsWith("/admin/health")) {
seenAdminEndpoints.add("health");
await fulfillJson({
status: "degraded",
environment: "dev",
engine_mode: "openai",
services: [],
});
return;
}
if (method === "GET" && path.endsWith("/admin/users")) {
seenAdminEndpoints.add("users");
await fulfillJson({
source: "database",
durable: true,
users: [],
});
return;
}
if (method === "GET" && path.endsWith("/admin/usage")) {
seenAdminEndpoints.add("usage");
await fulfillJson({
source: "database",
durable: true,
window_days: 7,
total_turns: 0,
metered_turns: 0,
tokens_in: 0,
tokens_out: 0,
cost_usd: 0,
budget: {
limit_usd: 0,
used_ratio: 0,
remaining_usd: null,
status: "disabled",
},
evaluator_cache: {
enabled: false,
entries: 0,
hits: 0,
misses: 0,
stores: 0,
evictions: 0,
requests: 0,
hit_rate: 0,
},
by_provider: [],
daily_cost: [],
});
return;
}
if (method === "GET" && path.endsWith("/admin/uptime")) {
seenAdminEndpoints.add("uptime");
await fulfillJson({
source: "database",
durable: true,
window_hours: 24,
sample_count: 0,
ok_ratio: 0,
degraded_events: 0,
down_events: 0,
last_down_at: null,
});
return;
}
if (method === "GET" && path.endsWith("/admin/tickets")) {
seenAdminEndpoints.add("tickets");
await fulfillJson({
source: "database",
durable: true,
tickets: [],
summary: {
total: 0,
open_count: 0,
high_priority_count: 0,
stale_count: 0,
by_category: {},
},
});
return;
}
await fulfillJson({ detail: `unmocked API request: ${method} ${path}` }, 404);
});
return seenAdminEndpoints;
}
async function signInAsAdmin(page: Page) {
let res: APIResponse | null = null;
for (let attempt = 0; attempt < 3; attempt += 1) {
@ -451,6 +580,21 @@ async function expectVisibleButtonsFit(page: Page, selector: string, context: st
expect(clippedButtons, `${context}: ${JSON.stringify(clippedButtons)}`).toEqual([]);
}
test.describe("admin route guards", () => {
test("allows an approved admin without onboarding to open the admin console", async ({ page }) => {
const seenAdminEndpoints = await mockApprovedAdminWithoutOnboarding(page);
await page.goto("/admin");
await expect(page).toHaveURL(/\/admin$/);
await expect(page.getByRole("heading", { name: "현재 서비스 상태" })).toBeVisible();
await expect(page.locator(".ad-status")).toContainText("개발");
await expect
.poll(() => Array.from(seenAdminEndpoints).sort())
.toEqual(["health", "tickets", "uptime", "usage", "users"]);
});
});
test.describe("admin route", () => {
test.beforeEach(async ({ page }) => {
await useRealApi(page);