АРЧ АП11 - Архитектура после регресса: Архитектура: централизовать organization authority в continuity policy для route, living-chat и data-scope
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { resolveAssistantOrganizationAuthority } from "../src/services/assistantContinuityPolicy";
|
||||
|
||||
describe("assistantContinuityPolicy organization authority", () => {
|
||||
it("prefers explicit assistant organization authority over older grounded continuity and merges known organizations once", () => {
|
||||
const authority = resolveAssistantOrganizationAuthority({
|
||||
sessionItems: [
|
||||
{
|
||||
role: "assistant",
|
||||
debug: {
|
||||
execution_lane: "address_query",
|
||||
answer_grounding_check: { status: "grounded" },
|
||||
extracted_filters: {
|
||||
organization: "Org Grounded",
|
||||
as_of_date: "2020-03-31"
|
||||
},
|
||||
detected_intent: "receivables_confirmed_as_of_date"
|
||||
}
|
||||
},
|
||||
{
|
||||
role: "assistant",
|
||||
debug: {
|
||||
execution_lane: "living_chat",
|
||||
living_chat_selected_organization: "Org Selected",
|
||||
assistant_active_organization: "Org Selected",
|
||||
assistant_known_organizations: ["Org Selected", "Org Known"],
|
||||
living_chat_data_scope_probe_organizations: ["Org Probe"]
|
||||
}
|
||||
}
|
||||
],
|
||||
sessionKnownOrganizations: ["Org Session"],
|
||||
lastOrganizationClarificationDebug: {
|
||||
organization_candidates: ["Org Candidate", "Org Selected"]
|
||||
}
|
||||
});
|
||||
|
||||
expect(authority.continuitySnapshot.activeOrganization).toBe("Org Grounded");
|
||||
expect(authority.continuityActiveOrganization).toBe("Org Selected");
|
||||
expect(authority.selectedOrganization).toBe("Org Selected");
|
||||
expect(authority.activeOrganization).toBe("Org Selected");
|
||||
expect(authority.knownOrganizations).toEqual([
|
||||
"Org Session",
|
||||
"Org Selected",
|
||||
"Org Known",
|
||||
"Org Probe",
|
||||
"Org Grounded"
|
||||
]);
|
||||
expect(authority.organizationClarificationCandidates).toEqual([
|
||||
"Org Candidate",
|
||||
"Org Selected",
|
||||
"Org Session",
|
||||
"Org Known",
|
||||
"Org Probe",
|
||||
"Org Grounded"
|
||||
]);
|
||||
expect(authority.organizationClarificationSelectionFromScope).toBe("Org Selected");
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,31 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { createAssistantDataScopePolicy } from "../src/services/assistantDataScopePolicy";
|
||||
|
||||
function createPolicy() {
|
||||
return createAssistantDataScopePolicy({
|
||||
activeMcpChannel: "default",
|
||||
mcpProxyUrl: "http://localhost",
|
||||
executeAddressMcpQuery: vi.fn(async () => ({ rows: [] })),
|
||||
repairAddressMojibake: (value: unknown) => String(value ?? "")
|
||||
});
|
||||
}
|
||||
|
||||
describe("assistantDataScopePolicy", () => {
|
||||
it("recovers active organization from assistant-side living chat authority when grounded answer is absent", () => {
|
||||
const policy = createPolicy();
|
||||
|
||||
const activeOrganization = policy.findLastAssistantActiveOrganization([
|
||||
{
|
||||
role: "assistant",
|
||||
debug: {
|
||||
execution_lane: "living_chat",
|
||||
living_chat_selected_organization: "Org Selected",
|
||||
assistant_active_organization: "Org Selected",
|
||||
assistant_known_organizations: ["Org Selected", "Org Backup"]
|
||||
}
|
||||
}
|
||||
]);
|
||||
|
||||
expect(activeOrganization).toBe("Org Selected");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user