Planner Autonomy: добавить reason-коды catalog-alignment
This commit is contained in:
@@ -40,6 +40,24 @@ function pushAllUnique(target, values) {
|
||||
pushUnique(target, value);
|
||||
}
|
||||
}
|
||||
function pushCatalogChainTemplateAlignmentReasons(target, alignment) {
|
||||
if (alignment.top_chain_template_match) {
|
||||
pushReason(target, "planner_catalog_chain_template_alignment_evaluated");
|
||||
if (alignment.selected_chain_matches_top) {
|
||||
pushReason(target, "planner_selected_chain_matches_catalog_top");
|
||||
}
|
||||
else if (alignment.selected_chain_in_catalog_matches) {
|
||||
pushReason(target, "planner_selected_chain_uses_lower_rank_catalog_match");
|
||||
}
|
||||
else {
|
||||
pushReason(target, "planner_selected_chain_outside_catalog_match_set");
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (alignment.selected_chain_is_catalog_template) {
|
||||
pushReason(target, "planner_catalog_chain_template_alignment_unscored");
|
||||
}
|
||||
}
|
||||
const LIFECYCLE_BOUNDED_INFERENCE_REASON_CODES = [
|
||||
"planner_lifecycle_bounded_activity_window_template",
|
||||
"planner_lifecycle_legal_fact_boundary_required"
|
||||
@@ -1000,6 +1018,7 @@ function planAssistantMcpDiscovery(input) {
|
||||
if (budgetOverride.maxProbeCount) {
|
||||
pushReason(reasonCodes, "planner_enabled_chunked_coverage_probe_budget");
|
||||
}
|
||||
pushCatalogChainTemplateAlignmentReasons(reasonCodes, catalogChainTemplateAlignment);
|
||||
const plan = (0, assistantMcpDiscoveryPolicy_1.buildAssistantMcpDiscoveryPlan)({
|
||||
semanticDataNeed,
|
||||
turnMeaning: input.turnMeaning,
|
||||
|
||||
@@ -142,6 +142,27 @@ function pushAllUnique(target: string[], values: string[]): void {
|
||||
}
|
||||
}
|
||||
|
||||
function pushCatalogChainTemplateAlignmentReasons(
|
||||
target: string[],
|
||||
alignment: AssistantMcpDiscoveryCatalogChainTemplateAlignment
|
||||
): void {
|
||||
if (alignment.top_chain_template_match) {
|
||||
pushReason(target, "planner_catalog_chain_template_alignment_evaluated");
|
||||
if (alignment.selected_chain_matches_top) {
|
||||
pushReason(target, "planner_selected_chain_matches_catalog_top");
|
||||
} else if (alignment.selected_chain_in_catalog_matches) {
|
||||
pushReason(target, "planner_selected_chain_uses_lower_rank_catalog_match");
|
||||
} else {
|
||||
pushReason(target, "planner_selected_chain_outside_catalog_match_set");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (alignment.selected_chain_is_catalog_template) {
|
||||
pushReason(target, "planner_catalog_chain_template_alignment_unscored");
|
||||
}
|
||||
}
|
||||
|
||||
const LIFECYCLE_BOUNDED_INFERENCE_REASON_CODES = [
|
||||
"planner_lifecycle_bounded_activity_window_template",
|
||||
"planner_lifecycle_legal_fact_boundary_required"
|
||||
@@ -1255,6 +1276,7 @@ export function planAssistantMcpDiscovery(
|
||||
if (budgetOverride.maxProbeCount) {
|
||||
pushReason(reasonCodes, "planner_enabled_chunked_coverage_probe_budget");
|
||||
}
|
||||
pushCatalogChainTemplateAlignmentReasons(reasonCodes, catalogChainTemplateAlignment);
|
||||
|
||||
const plan = buildAssistantMcpDiscoveryPlan({
|
||||
semanticDataNeed,
|
||||
|
||||
@@ -61,6 +61,8 @@ describe("assistant MCP discovery planner", () => {
|
||||
expect(result.reason_codes).toContain("planner_selected_catalog_primitives_from_decomposition_candidates");
|
||||
expect(result.reason_codes).toContain("planner_scored_catalog_chain_templates_from_fact_axis");
|
||||
expect(result.reason_codes).toContain("planner_catalog_chain_template_search_top_value_flow");
|
||||
expect(result.reason_codes).toContain("planner_catalog_chain_template_alignment_evaluated");
|
||||
expect(result.reason_codes).toContain("planner_selected_chain_matches_catalog_top");
|
||||
});
|
||||
|
||||
it("keeps representative graph-selected chains aligned with top catalog template matches", () => {
|
||||
@@ -201,6 +203,7 @@ describe("assistant MCP discovery planner", () => {
|
||||
expect(result.catalog_chain_template_alignment.top_chain_template_match, item.name).toBe(item.expected);
|
||||
expect(result.catalog_chain_template_alignment.selected_chain_template_rank, item.name).toBe(1);
|
||||
expect(result.catalog_chain_template_alignment.selected_chain_matches_top, item.name).toBe(true);
|
||||
expect(result.reason_codes, item.name).toContain("planner_selected_chain_matches_catalog_top");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -217,6 +220,7 @@ describe("assistant MCP discovery planner", () => {
|
||||
expect(result.catalog_review.review_status).toBe("needs_more_axes");
|
||||
expect(result.catalog_review.missing_axes_by_primitive.query_movements).toContainEqual(["period", "counterparty"]);
|
||||
expect(result.reason_codes).toContain("planner_needs_more_user_or_scope_context");
|
||||
expect(result.reason_codes).toContain("planner_catalog_chain_template_alignment_unscored");
|
||||
});
|
||||
|
||||
it("keeps requested monthly aggregation as an explicit planning axis for value-flow discovery", () => {
|
||||
|
||||
@@ -149,6 +149,7 @@ describe("assistant MCP discovery runtime bridge", () => {
|
||||
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("planner_selected_chain_matches_catalog_top");
|
||||
expect(result.reason_codes).toContain("runtime_bridge_loop_state_awaiting_clarification");
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user