fix(t1-live): remove questionnaire dependency from T1 Live session
Some checks are pending
CI / quality (push) Waiting to run

- buildT1SystemPrompt() now static (no reponses param); examiner
  formulates questions from what it hears in real-time audio stream
- Remove context guard + close 4004 CONTEXT_MISSING; Gemini session
  opens immediately after auth (aligns with T2 flow)
- Remove parseT1Context, validateReponses import from route
- Unknown WS message types silently ignored (debug log + return)
- Update Prompt_t1live.md and CHANGELOG-backend
- Tests: 309/309 green
This commit is contained in:
Hermann_Kitio 2026-06-30 02:57:17 +03:00
parent 01707c0b74
commit 74770b6402
6 changed files with 105 additions and 209 deletions

View file

@ -33,7 +33,7 @@ vi.mock("../../lib/geminiPhonology", () => ({
import { supabase } from "../../lib/supabase";
import { correctEO as deepseekCorrectEO } from "../../lib/deepseek";
import { parseT1Context, runT1LiveCorrection } from "../t1live";
import { runT1LiveCorrection } from "../t1live";
import type { WebSocketLike } from "../../lib/geminiLive";
// ─── Helpers ─────────────────────────────────────────────────────────────────
@ -87,14 +87,6 @@ function mockProductionUpdate(errorMsg: string | null = null) {
} as any);
}
const REPONSES = {
prenom_age_ville: "Hermann, 35 ans, Lyon",
formation_metier: "ingénieur en informatique",
situation_familiale: "marié, deux enfants",
loisirs: "la randonnée et la photographie",
motivation_canada: "de meilleures opportunités professionnelles",
};
const FAKE_RAPPORT = {
score: 14,
nclc: 8,
@ -108,34 +100,6 @@ const FAKE_RAPPORT = {
// ─── Tests ───────────────────────────────────────────────────────────────────
describe("parseT1Context", () => {
it("accepte un message {type:'context', reponses} valide", () => {
const result = parseT1Context(
JSON.stringify({ type: "context", reponses: REPONSES }),
);
expect(result).toEqual({ ok: true, reponses: REPONSES });
});
it("refuse un message sans type 'context'", () => {
const result = parseT1Context(
JSON.stringify({ type: "audio", data: "AAAA" }),
);
expect(result).toEqual({ ok: false });
});
it("refuse un contexte aux réponses invalides (champ manquant)", () => {
const { motivation_canada: _omit, ...partiel } = REPONSES;
const result = parseT1Context(
JSON.stringify({ type: "context", reponses: partiel }),
);
expect(result).toEqual({ ok: false });
});
it("refuse un payload non-JSON", () => {
expect(parseT1Context("pas du json {")).toEqual({ ok: false });
});
});
describe("runT1LiveCorrection", () => {
beforeEach(() => {
vi.clearAllMocks();