АРЧ АП11 - Подключить shadow-контракты переходов и truth gate в debug payload
This commit is contained in:
@@ -61,12 +61,15 @@ describe("assistant address lane response runtime adapter", () => {
|
||||
expect.objectContaining({
|
||||
assistant_known_organizations: ["ООО Ромашка", "ООО Лютик"],
|
||||
assistant_active_organization: "ООО Ромашка",
|
||||
address_followup_offer: { suggestion: "continue_previous" }
|
||||
address_followup_offer: { suggestion: "continue_previous" },
|
||||
assistant_runtime_contract_v1: expect.objectContaining({
|
||||
schema_version: "assistant_runtime_contracts_v1"
|
||||
})
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
it("keeps debug minimal when optional enrichment is absent", () => {
|
||||
it("keeps debug bounded to shadow contracts when optional enrichment is absent", () => {
|
||||
const runtime = runAssistantAddressLaneResponseRuntime({
|
||||
sessionId: "asst-2",
|
||||
userMessage: "raw",
|
||||
@@ -97,7 +100,18 @@ describe("assistant address lane response runtime adapter", () => {
|
||||
})
|
||||
});
|
||||
|
||||
expect(runtime.debug).toEqual({});
|
||||
expect(runtime.debug).toEqual(
|
||||
expect.objectContaining({
|
||||
assistant_runtime_contract_v1: expect.objectContaining({
|
||||
transition_contract_id: null,
|
||||
capability_contract_id: null,
|
||||
truth_gate_contract_status: "unknown"
|
||||
}),
|
||||
transition_contract_id: null,
|
||||
capability_contract_id: null,
|
||||
truth_gate_contract_status: "unknown"
|
||||
})
|
||||
);
|
||||
expect(runtime.response).toEqual({ ok: true });
|
||||
});
|
||||
});
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
listAssistantTransitionContracts,
|
||||
listInventoryCapabilityContracts
|
||||
} from "../src/services/assistantRuntimeContractRegistry";
|
||||
import { resolveAssistantRuntimeContractShadow } from "../src/services/assistantRuntimeContractResolver";
|
||||
|
||||
describe("assistant runtime contract registry", () => {
|
||||
it("declares the architecture turnaround transition set T1-T10", () => {
|
||||
@@ -81,4 +82,65 @@ describe("assistant runtime contract registry", () => {
|
||||
expect(contract.execution_error_behavior).toBe("blocked_execution_error");
|
||||
}
|
||||
});
|
||||
|
||||
it("resolves shadow contract ids for selected-object provenance debug", () => {
|
||||
const decision = resolveAssistantRuntimeContractShadow({
|
||||
addressDebug: {
|
||||
detected_intent: "inventory_purchase_provenance_for_item",
|
||||
capability_id: "inventory_inventory_purchase_provenance_for_item",
|
||||
rows_matched: 1,
|
||||
route_expectation_status: "matched"
|
||||
},
|
||||
addressRuntimeMeta: {
|
||||
dialogContinuationContract: {
|
||||
decision: "continue_previous",
|
||||
target_intent: "inventory_purchase_provenance_for_item"
|
||||
}
|
||||
},
|
||||
groundingStatus: "grounded"
|
||||
});
|
||||
|
||||
expect(decision.transition_contract_id).toBe("T4");
|
||||
expect(decision.capability_contract_id).toBe("inventory_inventory_purchase_provenance_for_item");
|
||||
expect(decision.truth_gate_contract_status).toBe("full_confirmed");
|
||||
expect(decision.carryover_eligibility).toBe("object_only");
|
||||
});
|
||||
|
||||
it("resolves meta follow-up and blocked route expectation in shadow mode", () => {
|
||||
const metaDecision = resolveAssistantRuntimeContractShadow({
|
||||
addressRuntimeMeta: {
|
||||
toolGateReason: "assistant_capability_query_detected",
|
||||
orchestrationContract: {
|
||||
hard_meta_mode: "capability",
|
||||
address_intent: "inventory_on_hand_as_of_date"
|
||||
}
|
||||
}
|
||||
});
|
||||
expect(metaDecision.transition_contract_id).toBe("T8");
|
||||
expect(metaDecision.capability_contract_id).toBe("confirmed_inventory_on_hand_as_of_date");
|
||||
expect(metaDecision.carryover_eligibility).toBe("meta_only");
|
||||
|
||||
const blockedDecision = resolveAssistantRuntimeContractShadow({
|
||||
addressDebug: {
|
||||
capability_id: "confirmed_inventory_on_hand_as_of_date",
|
||||
route_expectation_status: "mismatch"
|
||||
},
|
||||
groundingStatus: "route_mismatch_blocked"
|
||||
});
|
||||
expect(blockedDecision.transition_contract_id).toBe("T10");
|
||||
expect(blockedDecision.truth_gate_contract_status).toBe("blocked_route_expectation_failure");
|
||||
expect(blockedDecision.carryover_eligibility).toBe("none");
|
||||
});
|
||||
|
||||
it("classifies temporal limitations as a distinct truth gate status", () => {
|
||||
const decision = resolveAssistantRuntimeContractShadow({
|
||||
addressDebug: {
|
||||
capability_id: "confirmed_inventory_on_hand_as_of_date",
|
||||
temporal_guard_outcome: "ambiguous_limited"
|
||||
},
|
||||
groundingStatus: "partial"
|
||||
});
|
||||
|
||||
expect(decision.truth_gate_contract_status).toBe("limited_temporal_or_contextual");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user