Архитектура: стабилизировать organization authority после late company switch и закрыть phase16 multi-company replay

This commit is contained in:
2026-04-19 15:31:50 +03:00
parent 6e6f94b08c
commit af15e21bf6
25 changed files with 1063 additions and 36 deletions
@@ -218,6 +218,7 @@ export function createAssistantRoutePolicy(deps) {
hasLooseAllTimeAddressLookupSignal,
hasDeepAnalysisPreferenceSignal,
hasDirectDeepAnalysisSignal,
shouldEmitOrganizationSelectionReply,
compactWhitespace,
hasDeepSessionContinuationSignal,
resolveLivingAssistantModeDecision,
@@ -526,6 +527,13 @@ export function createAssistantRoutePolicy(deps) {
!dataScopeMetaQuery &&
!capabilityMetaQuery &&
!dataRetrievalSignal);
const organizationScopeSwitchDetected = Boolean(organizationClarificationSelection &&
!dataScopeMetaQuery &&
!capabilityMetaQuery &&
(shouldEmitOrganizationSelectionReply(rawUserMessage, organizationClarificationSelection) ||
shouldEmitOrganizationSelectionReply(repairedRawUserMessage, organizationClarificationSelection) ||
shouldEmitOrganizationSelectionReply(effectiveAddressUserMessage, organizationClarificationSelection) ||
shouldEmitOrganizationSelectionReply(repairedEffectiveAddressUserMessage, organizationClarificationSelection)));
const effectiveAddressFollowupSignal = explicitAddressFollowupSignal && !dangerOrCoercionSignal;
const baseToolGate = typeof resolveAddressToolGateDecisionOverride === "function"
? resolveAddressToolGateDecisionOverride(effectiveAddressUserMessage, followupContext, llmPreDecomposeMeta, rawUserMessage)
@@ -732,6 +740,37 @@ export function createAssistantRoutePolicy(deps) {
}
};
}
if (organizationScopeSwitchDetected) {
return {
runAddressLane: false,
toolGateDecision: "skip_address_lane",
toolGateReason: "organization_scope_switch_detected",
livingMode: "chat",
livingReason: "organization_scope_switch_detected",
orchestrationContract: {
schema_version: "assistant_orchestration_contract_v1",
hard_meta_mode: null,
provider_execution: providerExecution,
address_mode: resolvedModeDetection.mode,
address_mode_confidence: resolvedModeDetection.confidence,
address_intent: resolvedIntentResolution.intent,
address_intent_confidence: resolvedIntentResolution.confidence,
strong_data_signal_detected: strongDataSignal,
data_retrieval_signal_detected: dataRetrievalSignal,
followup_context_detected: Boolean(followupContext || continuitySnapshot.hasGroundedAddressContext),
organization_scope_switch_detected: true,
organization_scope_selection: organizationClarificationSelection,
unsupported_address_intent_fallback_to_deep: false,
final_decision: {
run_address_lane: false,
tool_gate_decision: "skip_address_lane",
tool_gate_reason: "organization_scope_switch_detected",
living_mode: "chat",
living_reason: "organization_scope_switch_detected"
}
}
};
}
const supportedExactInvestigativeAddressBypass = Boolean(llmContractMode === "deep_analysis" &&
semanticApplyCanonicalRecommended &&
strictDeepInvestigationBypassAllowed &&