63 lines
2.7 KiB
TypeScript
63 lines
2.7 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { attachAssistantMcpDiscoveryDebug } from "../src/services/assistantMcpDiscoveryDebugAttachment";
|
|
|
|
function entryPointContract(overrides: Record<string, unknown> = {}) {
|
|
return {
|
|
schema_version: "assistant_mcp_discovery_runtime_entry_point_v1",
|
|
policy_owner: "assistantMcpDiscoveryRuntimeEntryPoint",
|
|
entry_status: "bridge_executed",
|
|
hot_runtime_wired: false,
|
|
discovery_attempted: true,
|
|
turn_input: { adapter_status: "ready" },
|
|
bridge: {
|
|
bridge_status: "answer_draft_ready",
|
|
user_facing_response_allowed: true,
|
|
business_fact_answer_allowed: true,
|
|
requires_user_clarification: false,
|
|
answer_draft: {
|
|
answer_mode: "confirmed_with_bounded_inference"
|
|
}
|
|
},
|
|
reason_codes: ["runtime_entry_point_bridge_executed"],
|
|
...overrides
|
|
};
|
|
}
|
|
|
|
describe("assistant MCP discovery debug attachment", () => {
|
|
it("attaches a validated entry point contract and exposes summary flags", () => {
|
|
const debug = attachAssistantMcpDiscoveryDebug(
|
|
{ trace_id: "trace-1" },
|
|
{ addressRuntimeMeta: { mcpDiscoveryRuntimeEntryPoint: entryPointContract() } }
|
|
);
|
|
|
|
expect(debug.assistant_mcp_discovery_entry_point_v1?.schema_version).toBe(
|
|
"assistant_mcp_discovery_runtime_entry_point_v1"
|
|
);
|
|
expect(debug.mcp_discovery_entry_status).toBe("bridge_executed");
|
|
expect(debug.mcp_discovery_attempted).toBe(true);
|
|
expect(debug.mcp_discovery_hot_runtime_wired).toBe(false);
|
|
expect(debug.mcp_discovery_bridge_status).toBe("answer_draft_ready");
|
|
expect(debug.mcp_discovery_answer_mode).toBe("confirmed_with_bounded_inference");
|
|
expect(debug.mcp_discovery_business_fact_answer_allowed).toBe(true);
|
|
expect(debug.mcp_discovery_user_facing_response_allowed).toBe(true);
|
|
expect(debug.mcp_discovery_requires_clarification).toBe(false);
|
|
});
|
|
|
|
it("keeps safe null flags when no validated entry point exists", () => {
|
|
const debug = attachAssistantMcpDiscoveryDebug(
|
|
{ trace_id: "trace-1" },
|
|
{ addressRuntimeMeta: { mcpDiscoveryRuntimeEntryPoint: { schema_version: "wrong" } } }
|
|
);
|
|
|
|
expect(debug.assistant_mcp_discovery_entry_point_v1).toBeNull();
|
|
expect(debug.mcp_discovery_entry_status).toBeNull();
|
|
expect(debug.mcp_discovery_attempted).toBe(false);
|
|
expect(debug.mcp_discovery_hot_runtime_wired).toBe(false);
|
|
expect(debug.mcp_discovery_bridge_status).toBeNull();
|
|
expect(debug.mcp_discovery_answer_mode).toBeNull();
|
|
expect(debug.mcp_discovery_business_fact_answer_allowed).toBe(false);
|
|
expect(debug.mcp_discovery_user_facing_response_allowed).toBe(false);
|
|
expect(debug.mcp_discovery_requires_clarification).toBe(false);
|
|
});
|
|
});
|