Добавить handoff допуска для автономного value-flow

This commit is contained in:
2026-05-22 19:11:16 +03:00
parent d64d7f84cc
commit 5125c747d8
8 changed files with 345 additions and 14 deletions
@@ -15,12 +15,12 @@ function entryPointContract(overrides: Record<string, unknown> = {}) {
business_fact_answer_allowed: true,
requires_user_clarification: false,
planner: {
selected_chain_id: "value_flow_ranking",
selected_chain_id: "value_flow",
evidence_plan: {
schema_version: "assistant_evidence_planner_v1",
policy_owner: "assistantEvidencePlanner",
planner_status: "ready_for_execution",
selected_chain_id: "value_flow_ranking",
selected_chain_id: "value_flow",
evidence_axes: {
missing_axes: []
},
@@ -31,10 +31,10 @@ function entryPointContract(overrides: Record<string, unknown> = {}) {
answer_mode: "confirmed_business_answer"
}
},
catalog_chain_template_matches: ["value_flow_ranking", "value_flow"],
catalog_chain_template_matches: ["value_flow"],
catalog_chain_template_alignment: {
alignment_status: "selected_matches_top",
top_chain_template_match: "value_flow_ranking",
top_chain_template_match: "value_flow",
selected_chain_template_rank: 1,
selected_chain_is_catalog_template: true,
selected_chain_in_catalog_matches: true,
@@ -45,9 +45,9 @@ function entryPointContract(overrides: Record<string, unknown> = {}) {
schema_version: "assistant_mcp_route_candidate_v1",
policy_owner: "assistantMcpDiscoveryRuntimeBridge",
candidate_status: "ready_for_reviewed_execution",
selected_chain_id: "value_flow_ranking",
selected_chain_summary: "Rank value flow",
nearest_catalog_chain_template: "value_flow_ranking",
selected_chain_id: "value_flow",
selected_chain_summary: "Measure value flow",
nearest_catalog_chain_template: "value_flow",
catalog_alignment_status: "selected_matches_top",
business_fact_family: "value_flow",
action_family: "turnover",
@@ -63,6 +63,22 @@ function entryPointContract(overrides: Record<string, unknown> = {}) {
recommended_next_action: "Execute through the reviewed runtime bridge and truth gate.",
forbidden_overclaim_flags: ["no_unchecked_fact_totals"]
},
execution_handoff: {
schema_version: "assistant_mcp_discovery_execution_handoff_v1",
policy_owner: "assistantMcpDiscoveryExecutionHandoff",
handoff_status: "ready_for_guarded_response",
selected_chain_id: "value_flow",
route_candidate_status: "ready_for_reviewed_execution",
evidence_answer_mode: "confirmed_business_answer",
evidence_expected_coverage: "confirmed_coverage",
pilot_status: "executed",
answer_mode: "confirmed_with_bounded_inference",
mcp_execution_performed: true,
allowed_hot_chain: true,
can_use_guarded_response: true,
must_keep_internal_mechanics_hidden: true,
reason_codes: ["execution_handoff_guarded_response_ready"]
},
answer_draft: {
answer_mode: "confirmed_with_bounded_inference"
}
@@ -86,14 +102,14 @@ describe("assistant MCP discovery debug attachment", () => {
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_selected_chain_id).toBe("value_flow_ranking");
expect(debug.mcp_discovery_selected_chain_id).toBe("value_flow");
expect(debug.mcp_discovery_evidence_plan_status).toBe("ready_for_execution");
expect(debug.mcp_discovery_evidence_plan_answer_mode).toBe("confirmed_business_answer");
expect(debug.mcp_discovery_evidence_plan_expected_coverage).toBe("confirmed_coverage");
expect(debug.mcp_discovery_evidence_plan_missing_axes).toEqual([]);
expect(debug.mcp_discovery_catalog_chain_template_matches).toEqual(["value_flow_ranking", "value_flow"]);
expect(debug.mcp_discovery_catalog_chain_template_matches).toEqual(["value_flow"]);
expect(debug.mcp_discovery_catalog_chain_alignment_status).toBe("selected_matches_top");
expect(debug.mcp_discovery_catalog_chain_top_match).toBe("value_flow_ranking");
expect(debug.mcp_discovery_catalog_chain_top_match).toBe("value_flow");
expect(debug.mcp_discovery_catalog_chain_selected_matches_top).toBe(true);
expect(debug.mcp_discovery_route_candidate_status).toBe("ready_for_reviewed_execution");
expect(debug.mcp_discovery_route_candidate_fact_family).toBe("value_flow");
@@ -107,6 +123,9 @@ describe("assistant MCP discovery debug attachment", () => {
expect(debug.mcp_discovery_route_candidate_next_action).toBe(
"Execute through the reviewed runtime bridge and truth gate."
);
expect(debug.mcp_discovery_execution_handoff_status).toBe("ready_for_guarded_response");
expect(debug.mcp_discovery_execution_handoff_allowed_hot_chain).toBe(true);
expect(debug.mcp_discovery_execution_handoff_can_use_guarded_response).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);
@@ -142,6 +161,10 @@ describe("assistant MCP discovery debug attachment", () => {
expect(debug.mcp_discovery_route_candidate_missing_axes).toEqual([]);
expect(debug.mcp_discovery_route_candidate_provided_axes).toEqual([]);
expect(debug.mcp_discovery_route_candidate_executable_now).toBe(false);
expect(debug.mcp_discovery_execution_handoff_v1).toBeNull();
expect(debug.mcp_discovery_execution_handoff_status).toBeNull();
expect(debug.mcp_discovery_execution_handoff_allowed_hot_chain).toBe(false);
expect(debug.mcp_discovery_execution_handoff_can_use_guarded_response).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);
@@ -71,6 +71,11 @@ describe("assistant MCP discovery runtime bridge", () => {
expect(result.answer_draft.answer_mode).toBe("confirmed_with_bounded_inference");
expect(result.business_fact_answer_allowed).toBe(true);
expect(result.user_facing_response_allowed).toBe(true);
expect(result.execution_handoff).toMatchObject({
handoff_status: "not_enabled_for_chain",
allowed_hot_chain: false,
can_use_guarded_response: false
});
expect(result.reason_codes).toContain("runtime_bridge_not_wired_to_hot_assistant_answer");
});
@@ -88,6 +93,10 @@ describe("assistant MCP discovery runtime bridge", () => {
expect(result.requires_user_clarification).toBe(true);
expect(result.pilot.mcp_execution_performed).toBe(false);
expect(result.business_fact_answer_allowed).toBe(false);
expect(result.execution_handoff).toMatchObject({
handoff_status: "awaiting_user_scope",
can_use_guarded_response: false
});
expect(result.answer_draft.next_step_line).toContain("Уточните контрагента");
});
@@ -242,6 +251,11 @@ describe("assistant MCP discovery runtime bridge", () => {
executable_now: true,
enablement_reason: null
});
expect(result.execution_handoff).toMatchObject({
handoff_status: "not_enabled_for_chain",
allowed_hot_chain: false,
can_use_guarded_response: false
});
expect(result.answer_draft.confirmed_lines.join("\n")).toContain("СВК-А");
});
@@ -1065,6 +1079,19 @@ describe("assistant MCP discovery runtime bridge", () => {
period_scope: "2020",
total_amount: 5000
});
expect(result.execution_handoff).toMatchObject({
schema_version: "assistant_mcp_discovery_execution_handoff_v1",
handoff_status: "ready_for_guarded_response",
selected_chain_id: "value_flow",
route_candidate_status: "ready_for_reviewed_execution",
pilot_status: "executed",
mcp_execution_performed: true,
allowed_hot_chain: true,
can_use_guarded_response: true,
must_keep_internal_mechanics_hidden: true
});
expect(result.reason_codes).toContain("runtime_bridge_execution_handoff_ready_for_guarded_response");
expect(result.reason_codes).toContain("execution_handoff_guarded_response_ready");
expect(result.answer_draft.confirmed_lines.join("\n")).toContain("5 000");
expect(result.answer_draft.confirmed_lines.join("\n")).not.toContain("контрагенту");
});