Planner Autonomy: добавить verdict выравнивания catalog chain

This commit is contained in:
2026-05-01 14:43:05 +03:00
parent ea96df9ca1
commit 417b51096e
11 changed files with 92 additions and 4 deletions
@@ -16,7 +16,14 @@ function entryPointContract(overrides: Record<string, unknown> = {}) {
requires_user_clarification: false,
planner: {
selected_chain_id: "value_flow_ranking",
catalog_chain_template_matches: ["value_flow_ranking", "value_flow"]
catalog_chain_template_matches: ["value_flow_ranking", "value_flow"],
catalog_chain_template_alignment: {
top_chain_template_match: "value_flow_ranking",
selected_chain_template_rank: 1,
selected_chain_is_catalog_template: true,
selected_chain_in_catalog_matches: true,
selected_chain_matches_top: true
}
},
answer_draft: {
answer_mode: "confirmed_with_bounded_inference"
@@ -43,6 +50,8 @@ describe("assistant MCP discovery debug attachment", () => {
expect(debug.mcp_discovery_bridge_status).toBe("answer_draft_ready");
expect(debug.mcp_discovery_selected_chain_id).toBe("value_flow_ranking");
expect(debug.mcp_discovery_catalog_chain_template_matches).toEqual(["value_flow_ranking", "value_flow"]);
expect(debug.mcp_discovery_catalog_chain_top_match).toBe("value_flow_ranking");
expect(debug.mcp_discovery_catalog_chain_selected_matches_top).toBe(true);
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);
@@ -62,6 +71,8 @@ describe("assistant MCP discovery debug attachment", () => {
expect(debug.mcp_discovery_bridge_status).toBeNull();
expect(debug.mcp_discovery_selected_chain_id).toBeNull();
expect(debug.mcp_discovery_catalog_chain_template_matches).toEqual([]);
expect(debug.mcp_discovery_catalog_chain_top_match).toBeNull();
expect(debug.mcp_discovery_catalog_chain_selected_matches_top).toBe(false);
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);
@@ -48,6 +48,13 @@ describe("assistant MCP discovery planner", () => {
expect(result.discovery_plan.answer_may_use_raw_model_claims).toBe(false);
expect(result.data_need_graph?.business_fact_family).toBe("value_flow");
expect(result.catalog_chain_template_matches[0]).toBe("value_flow");
expect(result.catalog_chain_template_alignment).toMatchObject({
top_chain_template_match: "value_flow",
selected_chain_template_rank: 1,
selected_chain_is_catalog_template: true,
selected_chain_in_catalog_matches: true,
selected_chain_matches_top: true
});
expect(result.discovery_plan.execution_budget.max_probe_count).toBe(30);
expect(result.reason_codes).toContain("planner_enabled_chunked_coverage_probe_budget");
expect(result.reason_codes).toContain("planner_consumed_data_need_graph_v1");
@@ -150,6 +157,7 @@ describe("assistant MCP discovery planner", () => {
expect(result.reason_codes).toContain("planner_instantiated_catalog_chain_template_document_evidence");
expect(result.reason_codes).toContain("planner_catalog_chain_template_search_top_document_evidence");
expect(result.catalog_chain_template_matches[0]).toBe("document_evidence");
expect(result.catalog_chain_template_alignment.selected_chain_matches_top).toBe(true);
expect(result.reason_codes).not.toContain("planner_fell_back_to_recipe_primitives_after_empty_catalog_search");
});
@@ -564,6 +572,7 @@ describe("assistant MCP discovery planner", () => {
expect(result.reason_codes).toContain("planner_selected_bidirectional_value_flow_comparison_from_data_need_graph");
expect(result.reason_codes).toContain("planner_instantiated_catalog_chain_template_value_flow_comparison");
expect(result.catalog_chain_template_matches[0]).toBe("value_flow_comparison");
expect(result.catalog_chain_template_alignment.selected_chain_matches_top).toBe(true);
});
it("does not collapse a ranking-shaped value graph into entity-resolution just because no subject is preselected", () => {
@@ -635,6 +644,7 @@ describe("assistant MCP discovery planner", () => {
expect(result.reason_codes).toContain("planner_selected_top_ranked_value_flow_from_data_need_graph");
expect(result.reason_codes).toContain("planner_instantiated_catalog_chain_template_value_flow_ranking");
expect(result.catalog_chain_template_matches[0]).toBe("value_flow_ranking");
expect(result.catalog_chain_template_alignment.selected_chain_matches_top).toBe(true);
});
it("does not collapse incoming-vs-outgoing comparison into entity-resolution when no counterparty is preselected", () => {
@@ -942,6 +952,12 @@ describe("assistant MCP discovery planner", () => {
expect(result.planner_status).toBe("needs_clarification");
expect(result.discovery_plan.plan_status).toBe("needs_clarification");
expect(result.catalog_chain_template_matches).toEqual([]);
expect(result.catalog_chain_template_alignment).toMatchObject({
top_chain_template_match: null,
selected_chain_template_rank: null,
selected_chain_in_catalog_matches: false,
selected_chain_matches_top: false
});
expect(result.reason_codes).toContain("planner_needs_more_user_or_scope_context");
});
@@ -148,6 +148,7 @@ describe("assistant MCP discovery runtime bridge", () => {
expect(result.loop_state.pending_axes).toContain("organization");
expect(result.loop_state.provided_axes).toContain("aggregate_axis");
expect(result.loop_state.catalog_chain_template_matches[0]).toBe("value_flow_ranking");
expect(result.loop_state.catalog_chain_template_alignment.selected_chain_matches_top).toBe(true);
expect(result.reason_codes).toContain("runtime_bridge_loop_state_awaiting_clarification");
});