Оформить business_overview как маршрутный контракт Open-World Breadth

This commit is contained in:
2026-05-03 21:30:45 +03:00
parent 284b201912
commit e65b7fdaed
16 changed files with 513 additions and 20 deletions
@@ -42,7 +42,8 @@ describe("assistant MCP catalog index", () => {
"value_flow",
"value_flow_comparison",
"value_flow_ranking",
"lifecycle"
"lifecycle",
"business_overview"
]);
for (const template of index.chain_templates) {
expect(template.safe_for_model_planning).toBe(true);
@@ -63,6 +64,7 @@ describe("assistant MCP catalog index", () => {
const valueFlowComparisonTemplate = getAssistantMcpCatalogChainTemplate("value_flow_comparison");
const valueFlowRankingTemplate = getAssistantMcpCatalogChainTemplate("value_flow_ranking");
const lifecycleTemplate = getAssistantMcpCatalogChainTemplate("lifecycle");
const businessOverviewTemplate = getAssistantMcpCatalogChainTemplate("business_overview");
const inventorySnapshotTemplate = getAssistantMcpCatalogChainTemplate("inventory_stock_snapshot");
const inventoryProvenanceTemplate = getAssistantMcpCatalogChainTemplate("inventory_purchase_provenance");
const inventorySaleTraceTemplate = getAssistantMcpCatalogChainTemplate("inventory_sale_trace");
@@ -94,6 +96,19 @@ describe("assistant MCP catalog index", () => {
expect(lifecycleTemplate.planning_tags).toEqual(
expect.arrayContaining(["bounded_inference", "activity_window", "legal_fact_boundary"])
);
expect(businessOverviewTemplate.fallback_primitives).toEqual([
"query_movements",
"aggregate_by_axis",
"query_documents",
"probe_coverage",
"explain_evidence_basis"
]);
expect(businessOverviewTemplate.base_required_axes).toEqual(
expect.arrayContaining(["organization", "aggregate_axis", "coverage_target", "profit_margin_boundary"])
);
expect(businessOverviewTemplate.planning_tags).toEqual(
expect.arrayContaining(["business_overview", "bounded_inference", "explanation"])
);
expect(inventorySnapshotTemplate.base_required_axes).toEqual(
expect.arrayContaining(["as_of_date", "warehouse", "aggregate_axis", "quantity", "coverage_target"])
);
@@ -170,10 +185,35 @@ describe("assistant MCP catalog index", () => {
ranking_need: "top_desc",
required_axes: ["organization", "period", "aggregate_axis", "amount", "coverage_target"]
});
const businessOverviewTemplates = searchAssistantMcpCatalogChainTemplatesByFactAxis({
business_fact_family: "business_overview",
action_family: "broad_evaluation",
required_axes: ["organization", "all_time_scope", "aggregate_axis", "amount", "coverage_target", "evidence_basis"]
});
expect(documentTemplates[0]).toBe("document_evidence");
expect(comparisonTemplates[0]).toBe("value_flow_comparison");
expect(rankingTemplates[0]).toBe("value_flow_ranking");
expect(businessOverviewTemplates[0]).toBe("business_overview");
});
it("can search reviewed primitives for bounded business overview chains", () => {
const primitives = searchAssistantMcpCatalogPrimitivesByFactAxis({
business_fact_family: "business_overview",
action_family: "broad_evaluation",
required_axes: ["organization", "all_time_scope", "aggregate_axis", "amount", "coverage_target", "evidence_basis"]
});
expect(primitives).toEqual(
expect.arrayContaining([
"query_movements",
"aggregate_by_axis",
"query_documents",
"probe_coverage",
"explain_evidence_basis"
])
);
expect(primitives).not.toContain("search_business_entity");
});
it("can search reviewed primitives for inventory stock snapshot chains", () => {
@@ -71,6 +71,56 @@ describe("assistant MCP discovery data need graph", () => {
expect(result.forbidden_overclaim_flags).toContain("no_unresolved_entity_claim");
});
it("models broad business evaluation as a bounded business-overview evidence graph", () => {
const result = buildAssistantMcpDiscoveryDataNeedGraph({
semanticDataNeed: "business overview evidence with bounded analyst interpretation",
rawUtterance: "дай полный анализ компании и LLM-аудит бизнеса",
turnMeaning: {
asked_domain_family: "business_overview",
asked_action_family: "broad_evaluation",
explicit_organization_scope: "ООО Альтернатива Плюс"
}
});
expect(result.business_fact_family).toBe("business_overview");
expect(result.action_family).toBe("broad_evaluation");
expect(result.time_scope_need).toBe("all_time_scope");
expect(result.proof_expectation).toBe("bounded_inference");
expect(result.clarification_gaps).toEqual([]);
expect(result.decomposition_candidates).toEqual([
"collect_scoped_movements",
"aggregate_checked_amounts",
"aggregate_ranked_axis_values",
"fetch_supporting_documents",
"probe_coverage",
"explain_evidence_basis"
]);
expect(result.forbidden_overclaim_flags).toEqual(
expect.arrayContaining([
"no_unchecked_business_health_claim",
"no_profit_or_margin_claim_without_evidence"
])
);
expect(result.reason_codes).toContain("data_need_graph_family_business_overview");
expect(result.reason_codes).toContain("data_need_graph_business_overview_defaults_to_all_time_scope");
});
it("requires organization scope before a fresh broad business overview probe", () => {
const result = buildAssistantMcpDiscoveryDataNeedGraph({
semanticDataNeed: "business overview evidence with bounded analyst interpretation",
rawUtterance: "как оценишь деятельность компании?",
turnMeaning: {
asked_domain_family: "business_overview",
asked_action_family: "broad_evaluation",
unsupported_but_understood_family: "broad_business_evaluation"
}
});
expect(result.business_fact_family).toBe("business_overview");
expect(result.clarification_gaps).toEqual(["organization"]);
expect(result.proof_expectation).toBe("clarification_required");
});
it("builds a subjectless inventory stock snapshot graph with an as-of date gate", () => {
const result = buildAssistantMcpDiscoveryDataNeedGraph({
semanticDataNeed: "inventory stock snapshot evidence",
@@ -103,6 +103,57 @@ describe("assistant MCP discovery pilot executor", () => {
expect(deps.executeAddressMcpQuery).not.toHaveBeenCalled();
});
it("keeps business overview as an explicit unsupported runtime scope until the fresh multi-probe bridge exists", async () => {
const planner = planAssistantMcpDiscovery({
dataNeedGraph: {
schema_version: "assistant_data_need_graph_v1",
policy_owner: "assistantMcpDiscoveryDataNeedGraph",
subject_candidates: [],
business_fact_family: "business_overview",
action_family: "broad_evaluation",
aggregation_need: null,
time_scope_need: "all_time_scope",
comparison_need: null,
ranking_need: null,
proof_expectation: "bounded_inference",
clarification_gaps: [],
decomposition_candidates: [
"collect_scoped_movements",
"aggregate_checked_amounts",
"aggregate_ranked_axis_values",
"fetch_supporting_documents",
"probe_coverage",
"explain_evidence_basis"
],
forbidden_overclaim_flags: ["no_raw_model_claims", "no_profit_or_margin_claim_without_evidence"],
reason_codes: ["data_need_graph_built", "data_need_graph_family_business_overview"]
},
turnMeaning: {
asked_domain_family: "business_overview",
asked_action_family: "broad_evaluation",
explicit_organization_scope: "ООО Альтернатива Плюс"
}
});
const deps = buildDeps([]);
const result = await executeAssistantMcpDiscoveryPilot(planner, deps);
expect(planner.planner_status).toBe("ready_for_execution");
expect(result.pilot_status).toBe("unsupported");
expect(result.pilot_scope).toBe("business_overview_route_template_v1");
expect(result.mcp_execution_performed).toBe(false);
expect(result.executed_primitives).toEqual([]);
expect(result.skipped_primitives).toEqual([
"query_movements",
"aggregate_by_axis",
"query_documents",
"probe_coverage",
"explain_evidence_basis"
]);
expect(result.reason_codes).toContain("pilot_scope_unsupported_for_live_execution");
expect(deps.executeAddressMcpQuery).not.toHaveBeenCalled();
});
it("uses the explicit selected chain id when choosing the movement pilot scope", async () => {
const planner = planAssistantMcpDiscovery({
turnMeaning: {
@@ -184,6 +184,18 @@ describe("assistant MCP discovery planner", () => {
}
}
},
{
name: "business_overview",
expected: "business_overview",
input: {
dataNeedGraph: graph("business_overview", "broad_evaluation", { subject_candidates: [] }),
turnMeaning: {
asked_action_family: "broad_evaluation",
explicit_organization_scope: "Org",
explicit_date_scope: "2020"
}
}
},
{
name: "inventory_stock_snapshot",
expected: "inventory_stock_snapshot",
@@ -209,6 +221,73 @@ describe("assistant MCP discovery planner", () => {
}
});
it("builds a catalog-compatible business overview plan without pretending the fresh runtime probe exists yet", () => {
const result = planAssistantMcpDiscovery({
dataNeedGraph: {
schema_version: "assistant_data_need_graph_v1",
policy_owner: "assistantMcpDiscoveryDataNeedGraph",
subject_candidates: [],
business_fact_family: "business_overview",
action_family: "broad_evaluation",
aggregation_need: null,
time_scope_need: "all_time_scope",
comparison_need: null,
ranking_need: null,
proof_expectation: "bounded_inference",
clarification_gaps: [],
decomposition_candidates: [
"collect_scoped_movements",
"aggregate_checked_amounts",
"aggregate_ranked_axis_values",
"fetch_supporting_documents",
"probe_coverage",
"explain_evidence_basis"
],
forbidden_overclaim_flags: [
"no_raw_model_claims",
"no_unchecked_business_health_claim",
"no_profit_or_margin_claim_without_evidence"
],
reason_codes: ["data_need_graph_built", "data_need_graph_family_business_overview"]
},
turnMeaning: {
asked_domain_family: "business_overview",
asked_action_family: "broad_evaluation",
explicit_organization_scope: "ООО Альтернатива Плюс"
}
});
expect(result.planner_status).toBe("ready_for_execution");
expect(result.selected_chain_id).toBe("business_overview");
expect(result.semantic_data_need).toBe("business overview evidence with bounded analyst interpretation");
expect(result.proposed_primitives).toEqual([
"query_movements",
"aggregate_by_axis",
"query_documents",
"probe_coverage",
"explain_evidence_basis"
]);
expect(result.required_axes).toEqual([
"organization",
"all_time_scope",
"aggregate_axis",
"amount",
"coverage_target",
"evidence_basis",
"profit_margin_boundary"
]);
expect(result.catalog_chain_template_matches[0]).toBe("business_overview");
expect(result.catalog_chain_template_alignment).toMatchObject({
alignment_status: "selected_matches_top",
top_chain_template_match: "business_overview",
selected_chain_template_rank: 1,
selected_chain_matches_top: true
});
expect(result.catalog_review.review_status).toBe("catalog_compatible");
expect(result.reason_codes).toContain("planner_selected_business_overview_from_data_need_graph");
expect(result.reason_codes).toContain("planner_instantiated_catalog_chain_template_business_overview");
});
it("keeps bidirectional value-flow comparison executable when checked totals are derived without aggregate_by_axis", () => {
const result = planAssistantMcpDiscovery({
dataNeedGraph: {
@@ -134,7 +134,8 @@ describe("assistant MCP discovery runtime entry point", () => {
asked_action_family: "inspect_fields"
});
expect(result.bridge?.pilot.pilot_scope).toBe("metadata_inspection_v1");
expect(result.bridge?.answer_draft.headline).toContain("метаданным 1С");
expect(result.bridge?.answer_draft.headline).toContain("схеме 1С");
expect(result.bridge?.answer_draft.headline).toContain("подходящие объекты");
});
it("runs the bridge for raw entity-resolution wording and executes the full grounding chain", async () => {