Stage 2 завершён: problem-first ответы и follow-up continuity - ассистент переведён от entity-heavy логики к problem-first ответам с problem-unit слоем, удержанием контекста в follow-up и очисткой пользовательского ответа от сырых технических ссылок.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { AssistantSessionStore } from "../src/services/assistantSessionStore";
|
||||
import { createEmptyInvestigationState } from "../src/services/investigationState";
|
||||
|
||||
describe("assistant session backward compatibility", () => {
|
||||
it("lazy-upgrades legacy session objects without investigation_state", () => {
|
||||
@@ -35,4 +36,42 @@ describe("assistant session backward compatibility", () => {
|
||||
expect(ensured.items.length).toBe(0);
|
||||
expect(ensured.investigation_state?.schema_version).toBe("investigation_state_v1");
|
||||
});
|
||||
|
||||
it("preserves optional stage2 problem_unit_state in session clone flow", () => {
|
||||
const store = new AssistantSessionStore();
|
||||
const sessionsMap = (store as unknown as { sessions: Map<string, unknown> }).sessions;
|
||||
const sessionId = "legacy-session-3";
|
||||
const baseState = createEmptyInvestigationState(sessionId, "2026-03-26T10:00:00.000Z");
|
||||
|
||||
sessionsMap.set(sessionId, {
|
||||
session_id: sessionId,
|
||||
updated_at: "2026-03-26T10:00:00.000Z",
|
||||
items: [],
|
||||
investigation_state: {
|
||||
...baseState,
|
||||
status: "active",
|
||||
problem_unit_state: {
|
||||
active_problem_units: ["pu-1", "pu-2"],
|
||||
resolved_problem_units: ["pu-0"],
|
||||
problem_unit_backlinks: [
|
||||
{
|
||||
problem_unit_id: "pu-1",
|
||||
entity_backlinks: [
|
||||
{
|
||||
entity: "counterparty",
|
||||
id: "cp-1"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
focus_problem_types: ["broken_chain_segment"]
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const session = store.getSession(sessionId);
|
||||
expect(session).toBeTruthy();
|
||||
expect(session?.investigation_state?.problem_unit_state?.active_problem_units).toEqual(["pu-1", "pu-2"]);
|
||||
expect(session?.investigation_state?.problem_unit_state?.focus_problem_types).toEqual(["broken_chain_segment"]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user